mjswan 0.7.0-beta.1 → 0.7.0-beta.2
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.
|
@@ -2,10 +2,10 @@ function Uz(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&
|
|
|
2
2
|
`+L+u}var oe=!1;function Ae(u,f){if(!u||oe)return"";oe=!0;var v=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(f)if(f=function(){throw Error()},Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(Pe){var E=Pe}Reflect.construct(u,[],f)}else{try{f.call()}catch(Pe){E=Pe}u.call(f.prototype)}else{try{throw Error()}catch(Pe){E=Pe}u()}}catch(Pe){if(Pe&&E&&typeof Pe.stack=="string"){for(var D=Pe.stack.split(`
|
|
3
3
|
`),P=E.stack.split(`
|
|
4
4
|
`),te=D.length-1,pe=P.length-1;1<=te&&0<=pe&&D[te]!==P[pe];)pe--;for(;1<=te&&0<=pe;te--,pe--)if(D[te]!==P[pe]){if(te!==1||pe!==1)do if(te--,pe--,0>pe||D[te]!==P[pe]){var we=`
|
|
5
|
-
`+D[te].replace(" at new "," at ");return u.displayName&&we.includes("<anonymous>")&&(we=we.replace("<anonymous>",u.displayName)),we}while(1<=te&&0<=pe);break}}}finally{oe=!1,Error.prepareStackTrace=v}return(u=u?u.displayName||u.name:"")?G(u):""}function ye(u){switch(u.tag){case 5:return G(u.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return u=Ae(u.type,!1),u;case 11:return u=Ae(u.type.render,!1),u;case 1:return u=Ae(u.type,!0),u;default:return""}}function he(u){if(u==null)return null;if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case M:return"Fragment";case S:return"Portal";case R:return"Profiler";case T:return"StrictMode";case V:return"Suspense";case B:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case H:return(u.displayName||"Context")+".Consumer";case k:return(u._context.displayName||"Context")+".Provider";case Q:var f=u.render;return u=u.displayName,u||(u=f.displayName||f.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case W:return f=u.displayName||null,f!==null?f:he(u.type)||"Memo";case K:f=u._payload,u=u._init;try{return he(u(f))}catch{}}return null}function fe(u){var f=u.type;switch(u.tag){case 24:return"Cache";case 9:return(f.displayName||"Context")+".Consumer";case 10:return(f._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=f.render,u=u.displayName||u.name||"",f.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return f;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(f);case 8:return f===T?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f}return null}function Ie(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function Re(u){var f=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(f==="checkbox"||f==="radio")}function ge(u){var f=Re(u)?"checked":"value",v=Object.getOwnPropertyDescriptor(u.constructor.prototype,f),E=""+u[f];if(!u.hasOwnProperty(f)&&typeof v<"u"&&typeof v.get=="function"&&typeof v.set=="function"){var D=v.get,P=v.set;return Object.defineProperty(u,f,{configurable:!0,get:function(){return D.call(this)},set:function(te){E=""+te,P.call(this,te)}}),Object.defineProperty(u,f,{enumerable:v.enumerable}),{getValue:function(){return E},setValue:function(te){E=""+te},stopTracking:function(){u._valueTracker=null,delete u[f]}}}}function Ne(u){u._valueTracker||(u._valueTracker=ge(u))}function tt(u){if(!u)return!1;var f=u._valueTracker;if(!f)return!0;var v=f.getValue(),E="";return u&&(E=Re(u)?u.checked?"true":"false":u.value),u=E,u!==v?(f.setValue(u),!0):!1}function Ge(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}function F(u,f){var v=f.checked;return ne({},f,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:v??u._wrapperState.initialChecked})}function re(u,f){var v=f.defaultValue==null?"":f.defaultValue,E=f.checked!=null?f.checked:f.defaultChecked;v=Ie(f.value!=null?f.value:v),u._wrapperState={initialChecked:E,initialValue:v,controlled:f.type==="checkbox"||f.type==="radio"?f.checked!=null:f.value!=null}}function Ee(u,f){f=f.checked,f!=null&&b(u,"checked",f,!1)}function q(u,f){Ee(u,f);var v=Ie(f.value),E=f.type;if(v!=null)E==="number"?(v===0&&u.value===""||u.value!=v)&&(u.value=""+v):u.value!==""+v&&(u.value=""+v);else if(E==="submit"||E==="reset"){u.removeAttribute("value");return}f.hasOwnProperty("value")?ie(u,f.type,v):f.hasOwnProperty("defaultValue")&&ie(u,f.type,Ie(f.defaultValue)),f.checked==null&&f.defaultChecked!=null&&(u.defaultChecked=!!f.defaultChecked)}function ee(u,f,v){if(f.hasOwnProperty("value")||f.hasOwnProperty("defaultValue")){var E=f.type;if(!(E!=="submit"&&E!=="reset"||f.value!==void 0&&f.value!==null))return;f=""+u._wrapperState.initialValue,v||f===u.value||(u.value=f),u.defaultValue=f}v=u.name,v!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,v!==""&&(u.name=v)}function ie(u,f,v){(f!=="number"||Ge(u.ownerDocument)!==u)&&(v==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+v&&(u.defaultValue=""+v))}var be=Array.isArray;function ve(u,f,v,E){if(u=u.options,f){f={};for(var D=0;D<v.length;D++)f["$"+v[D]]=!0;for(v=0;v<u.length;v++)D=f.hasOwnProperty("$"+u[v].value),u[v].selected!==D&&(u[v].selected=D),D&&E&&(u[v].defaultSelected=!0)}else{for(v=""+Ie(v),f=null,D=0;D<u.length;D++){if(u[D].value===v){u[D].selected=!0,E&&(u[D].defaultSelected=!0);return}f!==null||u[D].disabled||(f=u[D])}f!==null&&(f.selected=!0)}}function ce(u,f){if(f.dangerouslySetInnerHTML!=null)throw Error(t(91));return ne({},f,{value:void 0,defaultValue:void 0,children:""+u._wrapperState.initialValue})}function Z(u,f){var v=f.value;if(v==null){if(v=f.children,f=f.defaultValue,v!=null){if(f!=null)throw Error(t(92));if(be(v)){if(1<v.length)throw Error(t(93));v=v[0]}f=v}f==null&&(f=""),v=f}u._wrapperState={initialValue:Ie(v)}}function Y(u,f){var v=Ie(f.value),E=Ie(f.defaultValue);v!=null&&(v=""+v,v!==u.value&&(u.value=v),f.defaultValue==null&&u.defaultValue!==v&&(u.defaultValue=v)),E!=null&&(u.defaultValue=""+E)}function le(u){var f=u.textContent;f===u._wrapperState.initialValue&&f!==""&&f!==null&&(u.value=f)}function Ce(u){switch(u){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function me(u,f){return u==null||u==="http://www.w3.org/1999/xhtml"?Ce(f):u==="http://www.w3.org/2000/svg"&&f==="foreignObject"?"http://www.w3.org/1999/xhtml":u}var xe,st=(function(u){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(f,v,E,D){MSApp.execUnsafeLocalFunction(function(){return u(f,v,E,D)})}:u})(function(u,f){if(u.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in u)u.innerHTML=f;else{for(xe=xe||document.createElement("div"),xe.innerHTML="<svg>"+f.valueOf().toString()+"</svg>",f=xe.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;f.firstChild;)u.appendChild(f.firstChild)}});function He(u,f){if(f){var v=u.firstChild;if(v&&v===u.lastChild&&v.nodeType===3){v.nodeValue=f;return}}u.textContent=f}var Ke={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},nt=["Webkit","ms","Moz","O"];Object.keys(Ke).forEach(function(u){nt.forEach(function(f){f=f+u.charAt(0).toUpperCase()+u.substring(1),Ke[f]=Ke[u]})});function ze(u,f,v){return f==null||typeof f=="boolean"||f===""?"":v||typeof f!="number"||f===0||Ke.hasOwnProperty(u)&&Ke[u]?(""+f).trim():f+"px"}function Ze(u,f){u=u.style;for(var v in f)if(f.hasOwnProperty(v)){var E=v.indexOf("--")===0,D=ze(v,f[v],E);v==="float"&&(v="cssFloat"),E?u.setProperty(v,D):u[v]=D}}var pt=ne({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ft(u,f){if(f){if(pt[u]&&(f.children!=null||f.dangerouslySetInnerHTML!=null))throw Error(t(137,u));if(f.dangerouslySetInnerHTML!=null){if(f.children!=null)throw Error(t(60));if(typeof f.dangerouslySetInnerHTML!="object"||!("__html"in f.dangerouslySetInnerHTML))throw Error(t(61))}if(f.style!=null&&typeof f.style!="object")throw Error(t(62))}}function dt(u,f){if(u.indexOf("-")===-1)return typeof f.is=="string";switch(u){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 Mt=null;function _e(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var ut=null,je=null,Ye=null;function We(u){if(u=sc(u)){if(typeof ut!="function")throw Error(t(280));var f=u.stateNode;f&&(f=zu(f),ut(u.stateNode,u.type,f))}}function Ve(u){je?Ye?Ye.push(u):Ye=[u]:je=u}function _t(){if(je){var u=je,f=Ye;if(Ye=je=null,We(u),f)for(u=0;u<f.length;u++)We(f[u])}}function Ot(u,f){return u(f)}function En(){}var dn=!1;function hn(u,f,v){if(dn)return u(f,v);dn=!0;try{return Ot(u,f,v)}finally{dn=!1,(je!==null||Ye!==null)&&(En(),_t())}}function tr(u,f){var v=u.stateNode;if(v===null)return null;var E=zu(v);if(E===null)return null;v=E[f];e:switch(f){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(E=!E.disabled)||(u=u.type,E=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!E;break e;default:u=!1}if(u)return null;if(v&&typeof v!="function")throw Error(t(231,f,typeof v));return v}var No=!1;if(o)try{var ys={};Object.defineProperty(ys,"passive",{get:function(){No=!0}}),window.addEventListener("test",ys,ys),window.removeEventListener("test",ys,ys)}catch{No=!1}function Wl(u,f,v,E,D,P,te,pe,we){var Pe=Array.prototype.slice.call(arguments,3);try{f.apply(v,Pe)}catch(Xe){this.onError(Xe)}}var Ur=!1,xs=null,sa=!1,Oa=null,$a={onError:function(u){Ur=!0,xs=u}};function ql(u,f,v,E,D,P,te,pe,we){Ur=!1,xs=null,Wl.apply($a,arguments)}function Ga(u,f,v,E,D,P,te,pe,we){if(ql.apply(this,arguments),Ur){if(Ur){var Pe=xs;Ur=!1,xs=null}else throw Error(t(198));sa||(sa=!0,Oa=Pe)}}function ki(u){var f=u,v=u;if(u.alternate)for(;f.return;)f=f.return;else{u=f;do f=u,(f.flags&4098)!==0&&(v=f.return),u=f.return;while(u)}return f.tag===3?v:null}function Qo(u){if(u.tag===13){var f=u.memoizedState;if(f===null&&(u=u.alternate,u!==null&&(f=u.memoizedState)),f!==null)return f.dehydrated}return null}function du(u){if(ki(u)!==u)throw Error(t(188))}function mi(u){var f=u.alternate;if(!f){if(f=ki(u),f===null)throw Error(t(188));return f!==u?null:u}for(var v=u,E=f;;){var D=v.return;if(D===null)break;var P=D.alternate;if(P===null){if(E=D.return,E!==null){v=E;continue}break}if(D.child===P.child){for(P=D.child;P;){if(P===v)return du(D),u;if(P===E)return du(D),f;P=P.sibling}throw Error(t(188))}if(v.return!==E.return)v=D,E=P;else{for(var te=!1,pe=D.child;pe;){if(pe===v){te=!0,v=D,E=P;break}if(pe===E){te=!0,E=D,v=P;break}pe=pe.sibling}if(!te){for(pe=P.child;pe;){if(pe===v){te=!0,v=P,E=D;break}if(pe===E){te=!0,E=P,v=D;break}pe=pe.sibling}if(!te)throw Error(t(189))}}if(v.alternate!==E)throw Error(t(190))}if(v.tag!==3)throw Error(t(188));return v.stateNode.current===v?u:f}function Po(u){return u=mi(u),u!==null?Lo(u):null}function Lo(u){if(u.tag===5||u.tag===6)return u;for(u=u.child;u!==null;){var f=Lo(u);if(f!==null)return f;u=u.sibling}return null}var vs=e.unstable_scheduleCallback,gi=e.unstable_cancelCallback,ae=e.unstable_shouldYield,Te=e.unstable_requestPaint,De=e.unstable_now,Fe=e.unstable_getCurrentPriorityLevel,Me=e.unstable_ImmediatePriority,at=e.unstable_UserBlockingPriority,lt=e.unstable_NormalPriority,At=e.unstable_LowPriority,gt=e.unstable_IdlePriority,Qt=null,St=null;function kt(u){if(St&&typeof St.onCommitFiberRoot=="function")try{St.onCommitFiberRoot(Qt,u,void 0,(u.current.flags&128)===128)}catch{}}var $t=Math.clz32?Math.clz32:pn,xn=Math.log,Fn=Math.LN2;function pn(u){return u>>>=0,u===0?32:31-(xn(u)/Fn|0)|0}var an=64,Rt=4194304;function vn(u){switch(u&-u){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: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 u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function tn(u,f){var v=u.pendingLanes;if(v===0)return 0;var E=0,D=u.suspendedLanes,P=u.pingedLanes,te=v&268435455;if(te!==0){var pe=te&~D;pe!==0?E=vn(pe):(P&=te,P!==0&&(E=vn(P)))}else te=v&~D,te!==0?E=vn(te):P!==0&&(E=vn(P));if(E===0)return 0;if(f!==0&&f!==E&&(f&D)===0&&(D=E&-E,P=f&-f,D>=P||D===16&&(P&4194240)!==0))return f;if((E&4)!==0&&(E|=v&16),f=u.entangledLanes,f!==0)for(u=u.entanglements,f&=E;0<f;)v=31-$t(f),D=1<<v,E|=u[v],f&=~D;return E}function Nr(u,f){switch(u){case 1:case 2:case 4:return f+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return f+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function aa(u,f){for(var v=u.suspendedLanes,E=u.pingedLanes,D=u.expirationTimes,P=u.pendingLanes;0<P;){var te=31-$t(P),pe=1<<te,we=D[te];we===-1?((pe&v)===0||(pe&E)!==0)&&(D[te]=Nr(pe,f)):we<=f&&(u.expiredLanes|=pe),P&=~pe}}function cr(u){return u=u.pendingLanes&-1073741825,u!==0?u:u&1073741824?1073741824:0}function oa(){var u=an;return an<<=1,(an&4194240)===0&&(an=64),u}function Cn(u){for(var f=[],v=0;31>v;v++)f.push(u);return f}function Yn(u,f,v){u.pendingLanes|=f,f!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,f=31-$t(f),u[f]=v}function Or(u,f){var v=u.pendingLanes&~f;u.pendingLanes=f,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=f,u.mutableReadLanes&=f,u.entangledLanes&=f,f=u.entanglements;var E=u.eventTimes;for(u=u.expirationTimes;0<v;){var D=31-$t(v),P=1<<D;f[D]=0,E[D]=-1,u[D]=-1,v&=~P}}function Kn(u,f){var v=u.entangledLanes|=f;for(u=u.entanglements;v;){var E=31-$t(v),D=1<<E;D&f|u[E]&f&&(u[E]|=f),v&=~D}}var Gt=0;function Fo(u){return u&=-u,1<u?4<u?(u&268435455)!==0?16:536870912:4:1}var yi,zo,Wp,hu,qp,bh=!1,fu=[],la=null,Ni=null,ca=null,xi=new Map,$r=new Map,_s=[],pu="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 submit".split(" ");function Au(u,f){switch(u){case"focusin":case"focusout":la=null;break;case"dragenter":case"dragleave":Ni=null;break;case"mouseover":case"mouseout":ca=null;break;case"pointerover":case"pointerout":xi.delete(f.pointerId);break;case"gotpointercapture":case"lostpointercapture":$r.delete(f.pointerId)}}function Uo(u,f,v,E,D,P){return u===null||u.nativeEvent!==P?(u={blockedOn:f,domEventName:v,eventSystemFlags:E,nativeEvent:P,targetContainers:[D]},f!==null&&(f=sc(f),f!==null&&zo(f)),u):(u.eventSystemFlags|=E,f=u.targetContainers,D!==null&&f.indexOf(D)===-1&&f.push(D),u)}function Yp(u,f,v,E,D){switch(f){case"focusin":return la=Uo(la,u,f,v,E,D),!0;case"dragenter":return Ni=Uo(Ni,u,f,v,E,D),!0;case"mouseover":return ca=Uo(ca,u,f,v,E,D),!0;case"pointerover":var P=D.pointerId;return xi.set(P,Uo(xi.get(P)||null,u,f,v,E,D)),!0;case"gotpointercapture":return P=D.pointerId,$r.set(P,Uo($r.get(P)||null,u,f,v,E,D)),!0}return!1}function Xp(u){var f=Xa(u.target);if(f!==null){var v=ki(f);if(v!==null){if(f=v.tag,f===13){if(f=Qo(v),f!==null){u.blockedOn=f,qp(u.priority,function(){Wp(v)});return}}else if(f===3&&v.stateNode.current.memoizedState.isDehydrated){u.blockedOn=v.tag===3?v.stateNode.containerInfo:null;return}}}u.blockedOn=null}function Oo(u){if(u.blockedOn!==null)return!1;for(var f=u.targetContainers;0<f.length;){var v=wh(u.domEventName,u.eventSystemFlags,f[0],u.nativeEvent);if(v===null){v=u.nativeEvent;var E=new v.constructor(v.type,v);Mt=E,v.target.dispatchEvent(E),Mt=null}else return f=sc(v),f!==null&&zo(f),u.blockedOn=v,!1;f.shift()}return!0}function Jp(u,f,v){Oo(u)&&v.delete(f)}function Kp(){bh=!1,la!==null&&Oo(la)&&(la=null),Ni!==null&&Oo(Ni)&&(Ni=null),ca!==null&&Oo(ca)&&(ca=null),xi.forEach(Jp),$r.forEach(Jp)}function Yl(u,f){u.blockedOn===f&&(u.blockedOn=null,bh||(bh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Kp)))}function Va(u){function f(D){return Yl(D,u)}if(0<fu.length){Yl(fu[0],u);for(var v=1;v<fu.length;v++){var E=fu[v];E.blockedOn===u&&(E.blockedOn=null)}}for(la!==null&&Yl(la,u),Ni!==null&&Yl(Ni,u),ca!==null&&Yl(ca,u),xi.forEach(f),$r.forEach(f),v=0;v<_s.length;v++)E=_s[v],E.blockedOn===u&&(E.blockedOn=null);for(;0<_s.length&&(v=_s[0],v.blockedOn===null);)Xp(v),v.blockedOn===null&&_s.shift()}var $o=w.ReactCurrentBatchConfig,mu=!0;function ny(u,f,v,E){var D=Gt,P=$o.transition;$o.transition=null;try{Gt=1,Go(u,f,v,E)}finally{Gt=D,$o.transition=P}}function ry(u,f,v,E){var D=Gt,P=$o.transition;$o.transition=null;try{Gt=4,Go(u,f,v,E)}finally{Gt=D,$o.transition=P}}function Go(u,f,v,E){if(mu){var D=wh(u,f,v,E);if(D===null)Pu(u,f,E,gu,v),Au(u,E);else if(Yp(D,u,f,v,E))E.stopPropagation();else if(Au(u,E),f&4&&-1<pu.indexOf(u)){for(;D!==null;){var P=sc(D);if(P!==null&&yi(P),P=wh(u,f,v,E),P===null&&Pu(u,f,E,gu,v),P===D)break;D=P}D!==null&&E.stopPropagation()}else Pu(u,f,E,null,v)}}var gu=null;function wh(u,f,v,E){if(gu=null,u=_e(E),u=Xa(u),u!==null)if(f=ki(u),f===null)u=null;else if(v=f.tag,v===13){if(u=Qo(f),u!==null)return u;u=null}else if(v===3){if(f.stateNode.current.memoizedState.isDehydrated)return f.tag===3?f.stateNode.containerInfo:null;u=null}else f!==u&&(u=null);return gu=u,null}function Zp(u){switch(u){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Fe()){case Me:return 1;case at:return 4;case lt:case At:return 16;case gt:return 536870912;default:return 16}default:return 16}}var ua=null,Eh=null,yu=null;function Ih(){if(yu)return yu;var u,f=Eh,v=f.length,E,D="value"in ua?ua.value:ua.textContent,P=D.length;for(u=0;u<v&&f[u]===D[u];u++);var te=v-u;for(E=1;E<=te&&f[v-E]===D[P-E];E++);return yu=D.slice(u,1<E?1-E:void 0)}function xu(u){var f=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&f===13&&(u=13)):u=f,u===10&&(u=13),32<=u||u===13?u:0}function vu(){return!0}function eA(){return!1}function ii(u){function f(v,E,D,P,te){this._reactName=v,this._targetInst=D,this.type=E,this.nativeEvent=P,this.target=te,this.currentTarget=null;for(var pe in u)u.hasOwnProperty(pe)&&(v=u[pe],this[pe]=v?v(P):P[pe]);return this.isDefaultPrevented=(P.defaultPrevented!=null?P.defaultPrevented:P.returnValue===!1)?vu:eA,this.isPropagationStopped=eA,this}return ne(f.prototype,{preventDefault:function(){this.defaultPrevented=!0;var v=this.nativeEvent;v&&(v.preventDefault?v.preventDefault():typeof v.returnValue!="unknown"&&(v.returnValue=!1),this.isDefaultPrevented=vu)},stopPropagation:function(){var v=this.nativeEvent;v&&(v.stopPropagation?v.stopPropagation():typeof v.cancelBubble!="unknown"&&(v.cancelBubble=!0),this.isPropagationStopped=vu)},persist:function(){},isPersistent:vu}),f}var Vo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ch=ii(Vo),Xl=ne({},Vo,{view:0,detail:0}),iy=ii(Xl),_u,bu,Ho,wu=ne({},Xl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Th,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==Ho&&(Ho&&u.type==="mousemove"?(_u=u.screenX-Ho.screenX,bu=u.screenY-Ho.screenY):bu=_u=0,Ho=u),_u)},movementY:function(u){return"movementY"in u?u.movementY:bu}}),tA=ii(wu),nA=ne({},wu,{dataTransfer:0}),rA=ii(nA),Jl=ne({},Xl,{relatedTarget:0}),Sh=ii(Jl),iA=ne({},Vo,{animationName:0,elapsedTime:0,pseudoElement:0}),sy=ii(iA),ay=ne({},Vo,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),oy=ii(ay),Bh=ne({},Vo,{data:0}),Mh=ii(Bh),ly={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cy={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"},uy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dy(u){var f=this.nativeEvent;return f.getModifierState?f.getModifierState(u):(u=uy[u])?!!f[u]:!1}function Th(){return dy}var hy=ne({},Xl,{key:function(u){if(u.key){var f=ly[u.key]||u.key;if(f!=="Unidentified")return f}return u.type==="keypress"?(u=xu(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?cy[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Th,charCode:function(u){return u.type==="keypress"?xu(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?xu(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),fy=ii(hy),Ha=ne({},wu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Kl=ii(Ha),sA=ne({},Xl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Th}),py=ii(sA),Eu=ne({},Vo,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ay=ii(Eu),my=ne({},wu,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),Rh=ii(my),Dh=[9,13,27,32],Iu=o&&"CompositionEvent"in window,jo=null;o&&"documentMode"in document&&(jo=document.documentMode);var aA=o&&"TextEvent"in window&&!jo,kh=o&&(!Iu||jo&&8<jo&&11>=jo),Nh=" ",Qh=!1;function oA(u,f){switch(u){case"keyup":return Dh.indexOf(f.keyCode)!==-1;case"keydown":return f.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ph(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var Wo=!1;function lA(u,f){switch(u){case"compositionend":return Ph(f);case"keypress":return f.which!==32?null:(Qh=!0,Nh);case"textInput":return u=f.data,u===Nh&&Qh?null:u;default:return null}}function cA(u,f){if(Wo)return u==="compositionend"||!Iu&&oA(u,f)?(u=Ih(),yu=Eh=ua=null,Wo=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(f.ctrlKey||f.altKey||f.metaKey)||f.ctrlKey&&f.altKey){if(f.char&&1<f.char.length)return f.char;if(f.which)return String.fromCharCode(f.which)}return null;case"compositionend":return kh&&f.locale!=="ko"?null:f.data;default:return null}}var Cu={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 Qi(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f==="input"?!!Cu[u.type]:f==="textarea"}function qo(u,f,v,E){Ve(E),f=rc(f,"onChange"),0<f.length&&(v=new Ch("onChange","change",null,v,E),u.push({event:v,listeners:f}))}var ja=null,Yo=null;function uA(u){ef(u,0)}function Zl(u){var f=rl(u);if(tt(f))return u}function Lh(u,f){if(u==="change")return f}var Fh=!1;if(o){var Su;if(o){var Yt="oninput"in document;if(!Yt){var Xo=document.createElement("div");Xo.setAttribute("oninput","return;"),Yt=typeof Xo.oninput=="function"}Su=Yt}else Su=!1;Fh=Su&&(!document.documentMode||9<document.documentMode)}function zh(){ja&&(ja.detachEvent("onpropertychange",qt),Yo=ja=null)}function qt(u){if(u.propertyName==="value"&&Zl(Yo)){var f=[];qo(f,Yo,u,_e(u)),hn(uA,f)}}function Uh(u,f,v){u==="focusin"?(zh(),ja=f,Yo=v,ja.attachEvent("onpropertychange",qt)):u==="focusout"&&zh()}function Xt(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return Zl(Yo)}function dA(u,f){if(u==="click")return Zl(f)}function Oh(u,f){if(u==="input"||u==="change")return Zl(f)}function hA(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var vi=typeof Object.is=="function"?Object.is:hA;function Jo(u,f){if(vi(u,f))return!0;if(typeof u!="object"||u===null||typeof f!="object"||f===null)return!1;var v=Object.keys(u),E=Object.keys(f);if(v.length!==E.length)return!1;for(E=0;E<v.length;E++){var D=v[E];if(!l.call(f,D)||!vi(u[D],f[D]))return!1}return!0}function Bu(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function $h(u,f){var v=Bu(u);u=0;for(var E;v;){if(v.nodeType===3){if(E=u+v.textContent.length,u<=f&&E>=f)return{node:v,offset:f-u};u=E}e:{for(;v;){if(v.nextSibling){v=v.nextSibling;break e}v=v.parentNode}v=void 0}v=Bu(v)}}function Gh(u,f){return u&&f?u===f?!0:u&&u.nodeType===3?!1:f&&f.nodeType===3?Gh(u,f.parentNode):"contains"in u?u.contains(f):u.compareDocumentPosition?!!(u.compareDocumentPosition(f)&16):!1:!1}function Vh(){for(var u=window,f=Ge();f instanceof u.HTMLIFrameElement;){try{var v=typeof f.contentWindow.location.href=="string"}catch{v=!1}if(v)u=f.contentWindow;else break;f=Ge(u.document)}return f}function Mu(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f&&(f==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||f==="textarea"||u.contentEditable==="true")}function fA(u){var f=Vh(),v=u.focusedElem,E=u.selectionRange;if(f!==v&&v&&v.ownerDocument&&Gh(v.ownerDocument.documentElement,v)){if(E!==null&&Mu(v)){if(f=E.start,u=E.end,u===void 0&&(u=f),"selectionStart"in v)v.selectionStart=f,v.selectionEnd=Math.min(u,v.value.length);else if(u=(f=v.ownerDocument||document)&&f.defaultView||window,u.getSelection){u=u.getSelection();var D=v.textContent.length,P=Math.min(E.start,D);E=E.end===void 0?P:Math.min(E.end,D),!u.extend&&P>E&&(D=E,E=P,P=D),D=$h(v,P);var te=$h(v,E);D&&te&&(u.rangeCount!==1||u.anchorNode!==D.node||u.anchorOffset!==D.offset||u.focusNode!==te.node||u.focusOffset!==te.offset)&&(f=f.createRange(),f.setStart(D.node,D.offset),u.removeAllRanges(),P>E?(u.addRange(f),u.extend(te.node,te.offset)):(f.setEnd(te.node,te.offset),u.addRange(f)))}}for(f=[],u=v;u=u.parentNode;)u.nodeType===1&&f.push({element:u,left:u.scrollLeft,top:u.scrollTop});for(typeof v.focus=="function"&&v.focus(),v=0;v<f.length;v++)u=f[v],u.element.scrollLeft=u.left,u.element.scrollTop=u.top}}var pA=o&&"documentMode"in document&&11>=document.documentMode,Wa=null,Tu=null,Ko=null,Ru=!1;function Hh(u,f,v){var E=v.window===v?v.document:v.nodeType===9?v:v.ownerDocument;Ru||Wa==null||Wa!==Ge(E)||(E=Wa,"selectionStart"in E&&Mu(E)?E={start:E.selectionStart,end:E.selectionEnd}:(E=(E.ownerDocument&&E.ownerDocument.defaultView||window).getSelection(),E={anchorNode:E.anchorNode,anchorOffset:E.anchorOffset,focusNode:E.focusNode,focusOffset:E.focusOffset}),Ko&&Jo(Ko,E)||(Ko=E,E=rc(Tu,"onSelect"),0<E.length&&(f=new Ch("onSelect","select",null,f,v),u.push({event:f,listeners:E}),f.target=Wa)))}function ec(u,f){var v={};return v[u.toLowerCase()]=f.toLowerCase(),v["Webkit"+u]="webkit"+f,v["Moz"+u]="moz"+f,v}var qa={animationend:ec("Animation","AnimationEnd"),animationiteration:ec("Animation","AnimationIteration"),animationstart:ec("Animation","AnimationStart"),transitionend:ec("Transition","TransitionEnd")},Du={},jh={};o&&(jh=document.createElement("div").style,"AnimationEvent"in window||(delete qa.animationend.animation,delete qa.animationiteration.animation,delete qa.animationstart.animation),"TransitionEvent"in window||delete qa.transitionend.transition);function tc(u){if(Du[u])return Du[u];if(!qa[u])return u;var f=qa[u],v;for(v in f)if(f.hasOwnProperty(v)&&v in jh)return Du[u]=f[v];return u}var Wh=tc("animationend"),qh=tc("animationiteration"),Yh=tc("animationstart"),Xh=tc("transitionend"),Jh=new Map,Kh="abort auxClick 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 bs(u,f){Jh.set(u,f),s(f,[u])}for(var ku=0;ku<Kh.length;ku++){var Nu=Kh[ku],AA=Nu.toLowerCase(),mA=Nu[0].toUpperCase()+Nu.slice(1);bs(AA,"on"+mA)}bs(Wh,"onAnimationEnd"),bs(qh,"onAnimationIteration"),bs(Yh,"onAnimationStart"),bs("dblclick","onDoubleClick"),bs("focusin","onFocus"),bs("focusout","onBlur"),bs(Xh,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zo="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(" "),gA=new Set("cancel close invalid load scroll toggle".split(" ").concat(Zo));function Zh(u,f,v){var E=u.type||"unknown-event";u.currentTarget=v,Ga(E,f,void 0,u),u.currentTarget=null}function ef(u,f){f=(f&4)!==0;for(var v=0;v<u.length;v++){var E=u[v],D=E.event;E=E.listeners;e:{var P=void 0;if(f)for(var te=E.length-1;0<=te;te--){var pe=E[te],we=pe.instance,Pe=pe.currentTarget;if(pe=pe.listener,we!==P&&D.isPropagationStopped())break e;Zh(D,pe,Pe),P=we}else for(te=0;te<E.length;te++){if(pe=E[te],we=pe.instance,Pe=pe.currentTarget,pe=pe.listener,we!==P&&D.isPropagationStopped())break e;Zh(D,pe,Pe),P=we}}}if(sa)throw u=Oa,sa=!1,Oa=null,u}function Mn(u,f){var v=f[cf];v===void 0&&(v=f[cf]=new Set);var E=u+"__bubble";v.has(E)||(tf(f,u,2,!1),v.add(E))}function Qu(u,f,v){var E=0;f&&(E|=4),tf(v,u,E,f)}var nc="_reactListening"+Math.random().toString(36).slice(2);function el(u){if(!u[nc]){u[nc]=!0,r.forEach(function(v){v!=="selectionchange"&&(gA.has(v)||Qu(v,!1,u),Qu(v,!0,u))});var f=u.nodeType===9?u:u.ownerDocument;f===null||f[nc]||(f[nc]=!0,Qu("selectionchange",!1,f))}}function tf(u,f,v,E){switch(Zp(f)){case 1:var D=ny;break;case 4:D=ry;break;default:D=Go}v=D.bind(null,f,v,u),D=void 0,!No||f!=="touchstart"&&f!=="touchmove"&&f!=="wheel"||(D=!0),E?D!==void 0?u.addEventListener(f,v,{capture:!0,passive:D}):u.addEventListener(f,v,!0):D!==void 0?u.addEventListener(f,v,{passive:D}):u.addEventListener(f,v,!1)}function Pu(u,f,v,E,D){var P=E;if((f&1)===0&&(f&2)===0&&E!==null)e:for(;;){if(E===null)return;var te=E.tag;if(te===3||te===4){var pe=E.stateNode.containerInfo;if(pe===D||pe.nodeType===8&&pe.parentNode===D)break;if(te===4)for(te=E.return;te!==null;){var we=te.tag;if((we===3||we===4)&&(we=te.stateNode.containerInfo,we===D||we.nodeType===8&&we.parentNode===D))return;te=te.return}for(;pe!==null;){if(te=Xa(pe),te===null)return;if(we=te.tag,we===5||we===6){E=P=te;continue e}pe=pe.parentNode}}E=E.return}hn(function(){var Pe=P,Xe=_e(v),rt=[];e:{var qe=Jh.get(u);if(qe!==void 0){var yt=Ch,Et=u;switch(u){case"keypress":if(xu(v)===0)break e;case"keydown":case"keyup":yt=fy;break;case"focusin":Et="focus",yt=Sh;break;case"focusout":Et="blur",yt=Sh;break;case"beforeblur":case"afterblur":yt=Sh;break;case"click":if(v.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":yt=tA;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":yt=rA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":yt=py;break;case Wh:case qh:case Yh:yt=sy;break;case Xh:yt=Ay;break;case"scroll":yt=iy;break;case"wheel":yt=Rh;break;case"copy":case"cut":case"paste":yt=oy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":yt=Kl}var Ct=(f&4)!==0,Zn=!Ct&&u==="scroll",ke=Ct?qe!==null?qe+"Capture":null:qe;Ct=[];for(var Be=Pe,Qe;Be!==null;){Qe=Be;var ot=Qe.stateNode;if(Qe.tag===5&&ot!==null&&(Qe=ot,ke!==null&&(ot=tr(Be,ke),ot!=null&&Ct.push(tl(Be,ot,Qe)))),Zn)break;Be=Be.return}0<Ct.length&&(qe=new yt(qe,Et,null,v,Xe),rt.push({event:qe,listeners:Ct}))}}if((f&7)===0){e:{if(qe=u==="mouseover"||u==="pointerover",yt=u==="mouseout"||u==="pointerout",qe&&v!==Mt&&(Et=v.relatedTarget||v.fromElement)&&(Xa(Et)||Et[ws]))break e;if((yt||qe)&&(qe=Xe.window===Xe?Xe:(qe=Xe.ownerDocument)?qe.defaultView||qe.parentWindow:window,yt?(Et=v.relatedTarget||v.toElement,yt=Pe,Et=Et?Xa(Et):null,Et!==null&&(Zn=ki(Et),Et!==Zn||Et.tag!==5&&Et.tag!==6)&&(Et=null)):(yt=null,Et=Pe),yt!==Et)){if(Ct=tA,ot="onMouseLeave",ke="onMouseEnter",Be="mouse",(u==="pointerout"||u==="pointerover")&&(Ct=Kl,ot="onPointerLeave",ke="onPointerEnter",Be="pointer"),Zn=yt==null?qe:rl(yt),Qe=Et==null?qe:rl(Et),qe=new Ct(ot,Be+"leave",yt,v,Xe),qe.target=Zn,qe.relatedTarget=Qe,ot=null,Xa(Xe)===Pe&&(Ct=new Ct(ke,Be+"enter",Et,v,Xe),Ct.target=Qe,Ct.relatedTarget=Zn,ot=Ct),Zn=ot,yt&&Et)t:{for(Ct=yt,ke=Et,Be=0,Qe=Ct;Qe;Qe=Ya(Qe))Be++;for(Qe=0,ot=ke;ot;ot=Ya(ot))Qe++;for(;0<Be-Qe;)Ct=Ya(Ct),Be--;for(;0<Qe-Be;)ke=Ya(ke),Qe--;for(;Be--;){if(Ct===ke||ke!==null&&Ct===ke.alternate)break t;Ct=Ya(Ct),ke=Ya(ke)}Ct=null}else Ct=null;yt!==null&&Wi(rt,qe,yt,Ct,!1),Et!==null&&Zn!==null&&Wi(rt,Zn,Et,Ct,!0)}}e:{if(qe=Pe?rl(Pe):window,yt=qe.nodeName&&qe.nodeName.toLowerCase(),yt==="select"||yt==="input"&&qe.type==="file")var Bt=Lh;else if(Qi(qe))if(Fh)Bt=Oh;else{Bt=Xt;var zt=Uh}else(yt=qe.nodeName)&&yt.toLowerCase()==="input"&&(qe.type==="checkbox"||qe.type==="radio")&&(Bt=dA);if(Bt&&(Bt=Bt(u,Pe))){qo(rt,Bt,v,Xe);break e}zt&&zt(u,qe,Pe),u==="focusout"&&(zt=qe._wrapperState)&&zt.controlled&&qe.type==="number"&&ie(qe,"number",qe.value)}switch(zt=Pe?rl(Pe):window,u){case"focusin":(Qi(zt)||zt.contentEditable==="true")&&(Wa=zt,Tu=Pe,Ko=null);break;case"focusout":Ko=Tu=Wa=null;break;case"mousedown":Ru=!0;break;case"contextmenu":case"mouseup":case"dragend":Ru=!1,Hh(rt,v,Xe);break;case"selectionchange":if(pA)break;case"keydown":case"keyup":Hh(rt,v,Xe)}var Ut;if(Iu)e:{switch(u){case"compositionstart":var Ht="onCompositionStart";break e;case"compositionend":Ht="onCompositionEnd";break e;case"compositionupdate":Ht="onCompositionUpdate";break e}Ht=void 0}else Wo?oA(u,v)&&(Ht="onCompositionEnd"):u==="keydown"&&v.keyCode===229&&(Ht="onCompositionStart");Ht&&(kh&&v.locale!=="ko"&&(Wo||Ht!=="onCompositionStart"?Ht==="onCompositionEnd"&&Wo&&(Ut=Ih()):(ua=Xe,Eh="value"in ua?ua.value:ua.textContent,Wo=!0)),zt=rc(Pe,Ht),0<zt.length&&(Ht=new Mh(Ht,u,null,v,Xe),rt.push({event:Ht,listeners:zt}),Ut?Ht.data=Ut:(Ut=Ph(v),Ut!==null&&(Ht.data=Ut)))),(Ut=aA?lA(u,v):cA(u,v))&&(Pe=rc(Pe,"onBeforeInput"),0<Pe.length&&(Xe=new Mh("onBeforeInput","beforeinput",null,v,Xe),rt.push({event:Xe,listeners:Pe}),Xe.data=Ut))}ef(rt,f)})}function tl(u,f,v){return{instance:u,listener:f,currentTarget:v}}function rc(u,f){for(var v=f+"Capture",E=[];u!==null;){var D=u,P=D.stateNode;D.tag===5&&P!==null&&(D=P,P=tr(u,v),P!=null&&E.unshift(tl(u,P,D)),P=tr(u,f),P!=null&&E.push(tl(u,P,D))),u=u.return}return E}function Ya(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5);return u||null}function Wi(u,f,v,E,D){for(var P=f._reactName,te=[];v!==null&&v!==E;){var pe=v,we=pe.alternate,Pe=pe.stateNode;if(we!==null&&we===E)break;pe.tag===5&&Pe!==null&&(pe=Pe,D?(we=tr(v,P),we!=null&&te.unshift(tl(v,we,pe))):D||(we=tr(v,P),we!=null&&te.push(tl(v,we,pe)))),v=v.return}te.length!==0&&u.push({event:f,listeners:te})}var gy=/\r\n?/g,nf=/\u0000|\uFFFD/g;function yA(u){return(typeof u=="string"?u:""+u).replace(gy,`
|
|
6
|
-
`).replace(nf,"")}function Lu(u,f,v){if(f=yA(f),yA(u)!==f&&v)throw Error(t(425))}function Fu(){}var rf=null,sf=null;function af(u,f){return u==="textarea"||u==="noscript"||typeof f.children=="string"||typeof f.children=="number"||typeof f.dangerouslySetInnerHTML=="object"&&f.dangerouslySetInnerHTML!==null&&f.dangerouslySetInnerHTML.__html!=null}var of=typeof setTimeout=="function"?setTimeout:void 0,yy=typeof clearTimeout=="function"?clearTimeout:void 0,xA=typeof Promise=="function"?Promise:void 0,xy=typeof queueMicrotask=="function"?queueMicrotask:typeof xA<"u"?function(u){return xA.resolve(null).then(u).catch(vy)}:of;function vy(u){setTimeout(function(){throw u})}function lf(u,f){var v=f,E=0;do{var D=v.nextSibling;if(u.removeChild(v),D&&D.nodeType===8)if(v=D.data,v==="/$"){if(E===0){u.removeChild(D),Va(f);return}E--}else v!=="$"&&v!=="$?"&&v!=="$!"||E++;v=D}while(v);Va(f)}function da(u){for(;u!=null;u=u.nextSibling){var f=u.nodeType;if(f===1||f===3)break;if(f===8){if(f=u.data,f==="$"||f==="$!"||f==="$?")break;if(f==="/$")return null}}return u}function vA(u){u=u.previousSibling;for(var f=0;u;){if(u.nodeType===8){var v=u.data;if(v==="$"||v==="$!"||v==="$?"){if(f===0)return u;f--}else v==="/$"&&f++}u=u.previousSibling}return null}var nl=Math.random().toString(36).slice(2),qi="__reactFiber$"+nl,ic="__reactProps$"+nl,ws="__reactContainer$"+nl,cf="__reactEvents$"+nl,_y="__reactListeners$"+nl,by="__reactHandles$"+nl;function Xa(u){var f=u[qi];if(f)return f;for(var v=u.parentNode;v;){if(f=v[ws]||v[qi]){if(v=f.alternate,f.child!==null||v!==null&&v.child!==null)for(u=vA(u);u!==null;){if(v=u[qi])return v;u=vA(u)}return f}u=v,v=u.parentNode}return null}function sc(u){return u=u[qi]||u[ws],!u||u.tag!==5&&u.tag!==6&&u.tag!==13&&u.tag!==3?null:u}function rl(u){if(u.tag===5||u.tag===6)return u.stateNode;throw Error(t(33))}function zu(u){return u[ic]||null}var uf=[],il=-1;function ha(u){return{current:u}}function Pn(u){0>il||(u.current=uf[il],uf[il]=null,il--)}function Tn(u,f){il++,uf[il]=u.current,u.current=f}var fa={},br=ha(fa),Gr=ha(!1),Ja=fa;function sl(u,f){var v=u.type.contextTypes;if(!v)return fa;var E=u.stateNode;if(E&&E.__reactInternalMemoizedUnmaskedChildContext===f)return E.__reactInternalMemoizedMaskedChildContext;var D={},P;for(P in v)D[P]=f[P];return E&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=f,u.__reactInternalMemoizedMaskedChildContext=D),D}function Vr(u){return u=u.childContextTypes,u!=null}function Uu(){Pn(Gr),Pn(br)}function _A(u,f,v){if(br.current!==fa)throw Error(t(168));Tn(br,f),Tn(Gr,v)}function bA(u,f,v){var E=u.stateNode;if(f=f.childContextTypes,typeof E.getChildContext!="function")return v;E=E.getChildContext();for(var D in E)if(!(D in f))throw Error(t(108,fe(u)||"Unknown",D));return ne({},v,E)}function Ou(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||fa,Ja=br.current,Tn(br,u),Tn(Gr,Gr.current),!0}function ac(u,f,v){var E=u.stateNode;if(!E)throw Error(t(169));v?(u=bA(u,f,Ja),E.__reactInternalMemoizedMergedChildContext=u,Pn(Gr),Pn(br),Tn(br,u)):Pn(Gr),Tn(Gr,v)}var C=null,N=!1,O=!1;function z(u){C===null?C=[u]:C.push(u)}function se(u){N=!0,z(u)}function ue(){if(!O&&C!==null){O=!0;var u=0,f=Gt;try{var v=C;for(Gt=1;u<v.length;u++){var E=v[u];do E=E(!0);while(E!==null)}C=null,N=!1}catch(D){throw C!==null&&(C=C.slice(u+1)),vs(Me,ue),D}finally{Gt=f,O=!1}}return null}var Se=[],Ue=0,it=null,ht=0,Nt=[],Vt=0,on=null,ln=1,wr="";function Es(u,f){Se[Ue++]=ht,Se[Ue++]=it,it=u,ht=f}function wA(u,f,v){Nt[Vt++]=ln,Nt[Vt++]=wr,Nt[Vt++]=on,on=u;var E=ln;u=wr;var D=32-$t(E)-1;E&=~(1<<D),v+=1;var P=32-$t(f)+D;if(30<P){var te=D-D%5;P=(E&(1<<te)-1).toString(32),E>>=te,D-=te,ln=1<<32-$t(f)+D|v<<D|E,wr=P+u}else ln=1<<P|v<<D|E,wr=u}function oc(u){u.return!==null&&(Es(u,1),wA(u,1,0))}function wy(u){for(;u===it;)it=Se[--Ue],Se[Ue]=null,ht=Se[--Ue],Se[Ue]=null;for(;u===on;)on=Nt[--Vt],Nt[Vt]=null,wr=Nt[--Vt],Nt[Vt]=null,ln=Nt[--Vt],Nt[Vt]=null}var Pi=null,Li=null,Gn=!1,Is=null;function _C(u,f){var v=Ki(5,null,null,0);v.elementType="DELETED",v.stateNode=f,v.return=u,f=u.deletions,f===null?(u.deletions=[v],u.flags|=16):f.push(v)}function bC(u,f){switch(u.tag){case 5:var v=u.type;return f=f.nodeType!==1||v.toLowerCase()!==f.nodeName.toLowerCase()?null:f,f!==null?(u.stateNode=f,Pi=u,Li=da(f.firstChild),!0):!1;case 6:return f=u.pendingProps===""||f.nodeType!==3?null:f,f!==null?(u.stateNode=f,Pi=u,Li=null,!0):!1;case 13:return f=f.nodeType!==8?null:f,f!==null?(v=on!==null?{id:ln,overflow:wr}:null,u.memoizedState={dehydrated:f,treeContext:v,retryLane:1073741824},v=Ki(18,null,null,0),v.stateNode=f,v.return=u,u.child=v,Pi=u,Li=null,!0):!1;default:return!1}}function Ey(u){return(u.mode&1)!==0&&(u.flags&128)===0}function Iy(u){if(Gn){var f=Li;if(f){var v=f;if(!bC(u,f)){if(Ey(u))throw Error(t(418));f=da(v.nextSibling);var E=Pi;f&&bC(u,f)?_C(E,v):(u.flags=u.flags&-4097|2,Gn=!1,Pi=u)}}else{if(Ey(u))throw Error(t(418));u.flags=u.flags&-4097|2,Gn=!1,Pi=u}}}function wC(u){for(u=u.return;u!==null&&u.tag!==5&&u.tag!==3&&u.tag!==13;)u=u.return;Pi=u}function EA(u){if(u!==Pi)return!1;if(!Gn)return wC(u),Gn=!0,!1;var f;if((f=u.tag!==3)&&!(f=u.tag!==5)&&(f=u.type,f=f!=="head"&&f!=="body"&&!af(u.type,u.memoizedProps)),f&&(f=Li)){if(Ey(u))throw EC(),Error(t(418));for(;f;)_C(u,f),f=da(f.nextSibling)}if(wC(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(t(317));e:{for(u=u.nextSibling,f=0;u;){if(u.nodeType===8){var v=u.data;if(v==="/$"){if(f===0){Li=da(u.nextSibling);break e}f--}else v!=="$"&&v!=="$!"&&v!=="$?"||f++}u=u.nextSibling}Li=null}}else Li=Pi?da(u.stateNode.nextSibling):null;return!0}function EC(){for(var u=Li;u;)u=da(u.nextSibling)}function $u(){Li=Pi=null,Gn=!1}function Cy(u){Is===null?Is=[u]:Is.push(u)}var az=w.ReactCurrentBatchConfig;function df(u,f,v){if(u=v.ref,u!==null&&typeof u!="function"&&typeof u!="object"){if(v._owner){if(v=v._owner,v){if(v.tag!==1)throw Error(t(309));var E=v.stateNode}if(!E)throw Error(t(147,u));var D=E,P=""+u;return f!==null&&f.ref!==null&&typeof f.ref=="function"&&f.ref._stringRef===P?f.ref:(f=function(te){var pe=D.refs;te===null?delete pe[P]:pe[P]=te},f._stringRef=P,f)}if(typeof u!="string")throw Error(t(284));if(!v._owner)throw Error(t(290,u))}return u}function IA(u,f){throw u=Object.prototype.toString.call(f),Error(t(31,u==="[object Object]"?"object with keys {"+Object.keys(f).join(", ")+"}":u))}function IC(u){var f=u._init;return f(u._payload)}function CC(u){function f(ke,Be){if(u){var Qe=ke.deletions;Qe===null?(ke.deletions=[Be],ke.flags|=16):Qe.push(Be)}}function v(ke,Be){if(!u)return null;for(;Be!==null;)f(ke,Be),Be=Be.sibling;return null}function E(ke,Be){for(ke=new Map;Be!==null;)Be.key!==null?ke.set(Be.key,Be):ke.set(Be.index,Be),Be=Be.sibling;return ke}function D(ke,Be){return ke=fl(ke,Be),ke.index=0,ke.sibling=null,ke}function P(ke,Be,Qe){return ke.index=Qe,u?(Qe=ke.alternate,Qe!==null?(Qe=Qe.index,Qe<Be?(ke.flags|=2,Be):Qe):(ke.flags|=2,Be)):(ke.flags|=1048576,Be)}function te(ke){return u&&ke.alternate===null&&(ke.flags|=2),ke}function pe(ke,Be,Qe,ot){return Be===null||Be.tag!==6?(Be=mx(Qe,ke.mode,ot),Be.return=ke,Be):(Be=D(Be,Qe),Be.return=ke,Be)}function we(ke,Be,Qe,ot){var Bt=Qe.type;return Bt===M?Xe(ke,Be,Qe.props.children,ot,Qe.key):Be!==null&&(Be.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===K&&IC(Bt)===Be.type)?(ot=D(Be,Qe.props),ot.ref=df(ke,Be,Qe),ot.return=ke,ot):(ot=YA(Qe.type,Qe.key,Qe.props,null,ke.mode,ot),ot.ref=df(ke,Be,Qe),ot.return=ke,ot)}function Pe(ke,Be,Qe,ot){return Be===null||Be.tag!==4||Be.stateNode.containerInfo!==Qe.containerInfo||Be.stateNode.implementation!==Qe.implementation?(Be=gx(Qe,ke.mode,ot),Be.return=ke,Be):(Be=D(Be,Qe.children||[]),Be.return=ke,Be)}function Xe(ke,Be,Qe,ot,Bt){return Be===null||Be.tag!==7?(Be=Ac(Qe,ke.mode,ot,Bt),Be.return=ke,Be):(Be=D(Be,Qe),Be.return=ke,Be)}function rt(ke,Be,Qe){if(typeof Be=="string"&&Be!==""||typeof Be=="number")return Be=mx(""+Be,ke.mode,Qe),Be.return=ke,Be;if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case I:return Qe=YA(Be.type,Be.key,Be.props,null,ke.mode,Qe),Qe.ref=df(ke,null,Be),Qe.return=ke,Qe;case S:return Be=gx(Be,ke.mode,Qe),Be.return=ke,Be;case K:var ot=Be._init;return rt(ke,ot(Be._payload),Qe)}if(be(Be)||J(Be))return Be=Ac(Be,ke.mode,Qe,null),Be.return=ke,Be;IA(ke,Be)}return null}function qe(ke,Be,Qe,ot){var Bt=Be!==null?Be.key:null;if(typeof Qe=="string"&&Qe!==""||typeof Qe=="number")return Bt!==null?null:pe(ke,Be,""+Qe,ot);if(typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case I:return Qe.key===Bt?we(ke,Be,Qe,ot):null;case S:return Qe.key===Bt?Pe(ke,Be,Qe,ot):null;case K:return Bt=Qe._init,qe(ke,Be,Bt(Qe._payload),ot)}if(be(Qe)||J(Qe))return Bt!==null?null:Xe(ke,Be,Qe,ot,null);IA(ke,Qe)}return null}function yt(ke,Be,Qe,ot,Bt){if(typeof ot=="string"&&ot!==""||typeof ot=="number")return ke=ke.get(Qe)||null,pe(Be,ke,""+ot,Bt);if(typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case I:return ke=ke.get(ot.key===null?Qe:ot.key)||null,we(Be,ke,ot,Bt);case S:return ke=ke.get(ot.key===null?Qe:ot.key)||null,Pe(Be,ke,ot,Bt);case K:var zt=ot._init;return yt(ke,Be,Qe,zt(ot._payload),Bt)}if(be(ot)||J(ot))return ke=ke.get(Qe)||null,Xe(Be,ke,ot,Bt,null);IA(Be,ot)}return null}function Et(ke,Be,Qe,ot){for(var Bt=null,zt=null,Ut=Be,Ht=Be=0,Cr=null;Ut!==null&&Ht<Qe.length;Ht++){Ut.index>Ht?(Cr=Ut,Ut=null):Cr=Ut.sibling;var _n=qe(ke,Ut,Qe[Ht],ot);if(_n===null){Ut===null&&(Ut=Cr);break}u&&Ut&&_n.alternate===null&&f(ke,Ut),Be=P(_n,Be,Ht),zt===null?Bt=_n:zt.sibling=_n,zt=_n,Ut=Cr}if(Ht===Qe.length)return v(ke,Ut),Gn&&Es(ke,Ht),Bt;if(Ut===null){for(;Ht<Qe.length;Ht++)Ut=rt(ke,Qe[Ht],ot),Ut!==null&&(Be=P(Ut,Be,Ht),zt===null?Bt=Ut:zt.sibling=Ut,zt=Ut);return Gn&&Es(ke,Ht),Bt}for(Ut=E(ke,Ut);Ht<Qe.length;Ht++)Cr=yt(Ut,ke,Ht,Qe[Ht],ot),Cr!==null&&(u&&Cr.alternate!==null&&Ut.delete(Cr.key===null?Ht:Cr.key),Be=P(Cr,Be,Ht),zt===null?Bt=Cr:zt.sibling=Cr,zt=Cr);return u&&Ut.forEach(function(pl){return f(ke,pl)}),Gn&&Es(ke,Ht),Bt}function Ct(ke,Be,Qe,ot){var Bt=J(Qe);if(typeof Bt!="function")throw Error(t(150));if(Qe=Bt.call(Qe),Qe==null)throw Error(t(151));for(var zt=Bt=null,Ut=Be,Ht=Be=0,Cr=null,_n=Qe.next();Ut!==null&&!_n.done;Ht++,_n=Qe.next()){Ut.index>Ht?(Cr=Ut,Ut=null):Cr=Ut.sibling;var pl=qe(ke,Ut,_n.value,ot);if(pl===null){Ut===null&&(Ut=Cr);break}u&&Ut&&pl.alternate===null&&f(ke,Ut),Be=P(pl,Be,Ht),zt===null?Bt=pl:zt.sibling=pl,zt=pl,Ut=Cr}if(_n.done)return v(ke,Ut),Gn&&Es(ke,Ht),Bt;if(Ut===null){for(;!_n.done;Ht++,_n=Qe.next())_n=rt(ke,_n.value,ot),_n!==null&&(Be=P(_n,Be,Ht),zt===null?Bt=_n:zt.sibling=_n,zt=_n);return Gn&&Es(ke,Ht),Bt}for(Ut=E(ke,Ut);!_n.done;Ht++,_n=Qe.next())_n=yt(Ut,ke,Ht,_n.value,ot),_n!==null&&(u&&_n.alternate!==null&&Ut.delete(_n.key===null?Ht:_n.key),Be=P(_n,Be,Ht),zt===null?Bt=_n:zt.sibling=_n,zt=_n);return u&&Ut.forEach(function(zz){return f(ke,zz)}),Gn&&Es(ke,Ht),Bt}function Zn(ke,Be,Qe,ot){if(typeof Qe=="object"&&Qe!==null&&Qe.type===M&&Qe.key===null&&(Qe=Qe.props.children),typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case I:e:{for(var Bt=Qe.key,zt=Be;zt!==null;){if(zt.key===Bt){if(Bt=Qe.type,Bt===M){if(zt.tag===7){v(ke,zt.sibling),Be=D(zt,Qe.props.children),Be.return=ke,ke=Be;break e}}else if(zt.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===K&&IC(Bt)===zt.type){v(ke,zt.sibling),Be=D(zt,Qe.props),Be.ref=df(ke,zt,Qe),Be.return=ke,ke=Be;break e}v(ke,zt);break}else f(ke,zt);zt=zt.sibling}Qe.type===M?(Be=Ac(Qe.props.children,ke.mode,ot,Qe.key),Be.return=ke,ke=Be):(ot=YA(Qe.type,Qe.key,Qe.props,null,ke.mode,ot),ot.ref=df(ke,Be,Qe),ot.return=ke,ke=ot)}return te(ke);case S:e:{for(zt=Qe.key;Be!==null;){if(Be.key===zt)if(Be.tag===4&&Be.stateNode.containerInfo===Qe.containerInfo&&Be.stateNode.implementation===Qe.implementation){v(ke,Be.sibling),Be=D(Be,Qe.children||[]),Be.return=ke,ke=Be;break e}else{v(ke,Be);break}else f(ke,Be);Be=Be.sibling}Be=gx(Qe,ke.mode,ot),Be.return=ke,ke=Be}return te(ke);case K:return zt=Qe._init,Zn(ke,Be,zt(Qe._payload),ot)}if(be(Qe))return Et(ke,Be,Qe,ot);if(J(Qe))return Ct(ke,Be,Qe,ot);IA(ke,Qe)}return typeof Qe=="string"&&Qe!==""||typeof Qe=="number"?(Qe=""+Qe,Be!==null&&Be.tag===6?(v(ke,Be.sibling),Be=D(Be,Qe),Be.return=ke,ke=Be):(v(ke,Be),Be=mx(Qe,ke.mode,ot),Be.return=ke,ke=Be),te(ke)):v(ke,Be)}return Zn}var Gu=CC(!0),SC=CC(!1),CA=ha(null),SA=null,Vu=null,Sy=null;function By(){Sy=Vu=SA=null}function My(u){var f=CA.current;Pn(CA),u._currentValue=f}function Ty(u,f,v){for(;u!==null;){var E=u.alternate;if((u.childLanes&f)!==f?(u.childLanes|=f,E!==null&&(E.childLanes|=f)):E!==null&&(E.childLanes&f)!==f&&(E.childLanes|=f),u===v)break;u=u.return}}function Hu(u,f){SA=u,Sy=Vu=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&f)!==0&&(_i=!0),u.firstContext=null)}function Yi(u){var f=u._currentValue;if(Sy!==u)if(u={context:u,memoizedValue:f,next:null},Vu===null){if(SA===null)throw Error(t(308));Vu=u,SA.dependencies={lanes:0,firstContext:u}}else Vu=Vu.next=u;return f}var lc=null;function Ry(u){lc===null?lc=[u]:lc.push(u)}function BC(u,f,v,E){var D=f.interleaved;return D===null?(v.next=v,Ry(f)):(v.next=D.next,D.next=v),f.interleaved=v,Ka(u,E)}function Ka(u,f){u.lanes|=f;var v=u.alternate;for(v!==null&&(v.lanes|=f),v=u,u=u.return;u!==null;)u.childLanes|=f,v=u.alternate,v!==null&&(v.childLanes|=f),v=u,u=u.return;return v.tag===3?v.stateNode:null}var al=!1;function Dy(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function MC(u,f){u=u.updateQueue,f.updateQueue===u&&(f.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function Za(u,f){return{eventTime:u,lane:f,tag:0,payload:null,callback:null,next:null}}function ol(u,f,v){var E=u.updateQueue;if(E===null)return null;if(E=E.shared,(An&2)!==0){var D=E.pending;return D===null?f.next=f:(f.next=D.next,D.next=f),E.pending=f,Ka(u,v)}return D=E.interleaved,D===null?(f.next=f,Ry(E)):(f.next=D.next,D.next=f),E.interleaved=f,Ka(u,v)}function BA(u,f,v){if(f=f.updateQueue,f!==null&&(f=f.shared,(v&4194240)!==0)){var E=f.lanes;E&=u.pendingLanes,v|=E,f.lanes=v,Kn(u,v)}}function TC(u,f){var v=u.updateQueue,E=u.alternate;if(E!==null&&(E=E.updateQueue,v===E)){var D=null,P=null;if(v=v.firstBaseUpdate,v!==null){do{var te={eventTime:v.eventTime,lane:v.lane,tag:v.tag,payload:v.payload,callback:v.callback,next:null};P===null?D=P=te:P=P.next=te,v=v.next}while(v!==null);P===null?D=P=f:P=P.next=f}else D=P=f;v={baseState:E.baseState,firstBaseUpdate:D,lastBaseUpdate:P,shared:E.shared,effects:E.effects},u.updateQueue=v;return}u=v.lastBaseUpdate,u===null?v.firstBaseUpdate=f:u.next=f,v.lastBaseUpdate=f}function MA(u,f,v,E){var D=u.updateQueue;al=!1;var P=D.firstBaseUpdate,te=D.lastBaseUpdate,pe=D.shared.pending;if(pe!==null){D.shared.pending=null;var we=pe,Pe=we.next;we.next=null,te===null?P=Pe:te.next=Pe,te=we;var Xe=u.alternate;Xe!==null&&(Xe=Xe.updateQueue,pe=Xe.lastBaseUpdate,pe!==te&&(pe===null?Xe.firstBaseUpdate=Pe:pe.next=Pe,Xe.lastBaseUpdate=we))}if(P!==null){var rt=D.baseState;te=0,Xe=Pe=we=null,pe=P;do{var qe=pe.lane,yt=pe.eventTime;if((E&qe)===qe){Xe!==null&&(Xe=Xe.next={eventTime:yt,lane:0,tag:pe.tag,payload:pe.payload,callback:pe.callback,next:null});e:{var Et=u,Ct=pe;switch(qe=f,yt=v,Ct.tag){case 1:if(Et=Ct.payload,typeof Et=="function"){rt=Et.call(yt,rt,qe);break e}rt=Et;break e;case 3:Et.flags=Et.flags&-65537|128;case 0:if(Et=Ct.payload,qe=typeof Et=="function"?Et.call(yt,rt,qe):Et,qe==null)break e;rt=ne({},rt,qe);break e;case 2:al=!0}}pe.callback!==null&&pe.lane!==0&&(u.flags|=64,qe=D.effects,qe===null?D.effects=[pe]:qe.push(pe))}else yt={eventTime:yt,lane:qe,tag:pe.tag,payload:pe.payload,callback:pe.callback,next:null},Xe===null?(Pe=Xe=yt,we=rt):Xe=Xe.next=yt,te|=qe;if(pe=pe.next,pe===null){if(pe=D.shared.pending,pe===null)break;qe=pe,pe=qe.next,qe.next=null,D.lastBaseUpdate=qe,D.shared.pending=null}}while(!0);if(Xe===null&&(we=rt),D.baseState=we,D.firstBaseUpdate=Pe,D.lastBaseUpdate=Xe,f=D.shared.interleaved,f!==null){D=f;do te|=D.lane,D=D.next;while(D!==f)}else P===null&&(D.shared.lanes=0);dc|=te,u.lanes=te,u.memoizedState=rt}}function RC(u,f,v){if(u=f.effects,f.effects=null,u!==null)for(f=0;f<u.length;f++){var E=u[f],D=E.callback;if(D!==null){if(E.callback=null,E=v,typeof D!="function")throw Error(t(191,D));D.call(E)}}}var hf={},pa=ha(hf),ff=ha(hf),pf=ha(hf);function cc(u){if(u===hf)throw Error(t(174));return u}function ky(u,f){switch(Tn(pf,f),Tn(ff,u),Tn(pa,hf),u=f.nodeType,u){case 9:case 11:f=(f=f.documentElement)?f.namespaceURI:me(null,"");break;default:u=u===8?f.parentNode:f,f=u.namespaceURI||null,u=u.tagName,f=me(f,u)}Pn(pa),Tn(pa,f)}function ju(){Pn(pa),Pn(ff),Pn(pf)}function DC(u){cc(pf.current);var f=cc(pa.current),v=me(f,u.type);f!==v&&(Tn(ff,u),Tn(pa,v))}function Ny(u){ff.current===u&&(Pn(pa),Pn(ff))}var Hn=ha(0);function TA(u){for(var f=u;f!==null;){if(f.tag===13){var v=f.memoizedState;if(v!==null&&(v=v.dehydrated,v===null||v.data==="$?"||v.data==="$!"))return f}else if(f.tag===19&&f.memoizedProps.revealOrder!==void 0){if((f.flags&128)!==0)return f}else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return null;f=f.return}f.sibling.return=f.return,f=f.sibling}return null}var Qy=[];function Py(){for(var u=0;u<Qy.length;u++)Qy[u]._workInProgressVersionPrimary=null;Qy.length=0}var RA=w.ReactCurrentDispatcher,Ly=w.ReactCurrentBatchConfig,uc=0,jn=null,ur=null,Er=null,DA=!1,Af=!1,mf=0,oz=0;function Hr(){throw Error(t(321))}function Fy(u,f){if(f===null)return!1;for(var v=0;v<f.length&&v<u.length;v++)if(!vi(u[v],f[v]))return!1;return!0}function zy(u,f,v,E,D,P){if(uc=P,jn=f,f.memoizedState=null,f.updateQueue=null,f.lanes=0,RA.current=u===null||u.memoizedState===null?dz:hz,u=v(E,D),Af){P=0;do{if(Af=!1,mf=0,25<=P)throw Error(t(301));P+=1,Er=ur=null,f.updateQueue=null,RA.current=fz,u=v(E,D)}while(Af)}if(RA.current=QA,f=ur!==null&&ur.next!==null,uc=0,Er=ur=jn=null,DA=!1,f)throw Error(t(300));return u}function Uy(){var u=mf!==0;return mf=0,u}function Aa(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Er===null?jn.memoizedState=Er=u:Er=Er.next=u,Er}function Xi(){if(ur===null){var u=jn.alternate;u=u!==null?u.memoizedState:null}else u=ur.next;var f=Er===null?jn.memoizedState:Er.next;if(f!==null)Er=f,ur=u;else{if(u===null)throw Error(t(310));ur=u,u={memoizedState:ur.memoizedState,baseState:ur.baseState,baseQueue:ur.baseQueue,queue:ur.queue,next:null},Er===null?jn.memoizedState=Er=u:Er=Er.next=u}return Er}function gf(u,f){return typeof f=="function"?f(u):f}function Oy(u){var f=Xi(),v=f.queue;if(v===null)throw Error(t(311));v.lastRenderedReducer=u;var E=ur,D=E.baseQueue,P=v.pending;if(P!==null){if(D!==null){var te=D.next;D.next=P.next,P.next=te}E.baseQueue=D=P,v.pending=null}if(D!==null){P=D.next,E=E.baseState;var pe=te=null,we=null,Pe=P;do{var Xe=Pe.lane;if((uc&Xe)===Xe)we!==null&&(we=we.next={lane:0,action:Pe.action,hasEagerState:Pe.hasEagerState,eagerState:Pe.eagerState,next:null}),E=Pe.hasEagerState?Pe.eagerState:u(E,Pe.action);else{var rt={lane:Xe,action:Pe.action,hasEagerState:Pe.hasEagerState,eagerState:Pe.eagerState,next:null};we===null?(pe=we=rt,te=E):we=we.next=rt,jn.lanes|=Xe,dc|=Xe}Pe=Pe.next}while(Pe!==null&&Pe!==P);we===null?te=E:we.next=pe,vi(E,f.memoizedState)||(_i=!0),f.memoizedState=E,f.baseState=te,f.baseQueue=we,v.lastRenderedState=E}if(u=v.interleaved,u!==null){D=u;do P=D.lane,jn.lanes|=P,dc|=P,D=D.next;while(D!==u)}else D===null&&(v.lanes=0);return[f.memoizedState,v.dispatch]}function $y(u){var f=Xi(),v=f.queue;if(v===null)throw Error(t(311));v.lastRenderedReducer=u;var E=v.dispatch,D=v.pending,P=f.memoizedState;if(D!==null){v.pending=null;var te=D=D.next;do P=u(P,te.action),te=te.next;while(te!==D);vi(P,f.memoizedState)||(_i=!0),f.memoizedState=P,f.baseQueue===null&&(f.baseState=P),v.lastRenderedState=P}return[P,E]}function kC(){}function NC(u,f){var v=jn,E=Xi(),D=f(),P=!vi(E.memoizedState,D);if(P&&(E.memoizedState=D,_i=!0),E=E.queue,Gy(LC.bind(null,v,E,u),[u]),E.getSnapshot!==f||P||Er!==null&&Er.memoizedState.tag&1){if(v.flags|=2048,yf(9,PC.bind(null,v,E,D,f),void 0,null),Ir===null)throw Error(t(349));(uc&30)!==0||QC(v,f,D)}return D}function QC(u,f,v){u.flags|=16384,u={getSnapshot:f,value:v},f=jn.updateQueue,f===null?(f={lastEffect:null,stores:null},jn.updateQueue=f,f.stores=[u]):(v=f.stores,v===null?f.stores=[u]:v.push(u))}function PC(u,f,v,E){f.value=v,f.getSnapshot=E,FC(f)&&zC(u)}function LC(u,f,v){return v(function(){FC(f)&&zC(u)})}function FC(u){var f=u.getSnapshot;u=u.value;try{var v=f();return!vi(u,v)}catch{return!0}}function zC(u){var f=Ka(u,1);f!==null&&Ms(f,u,1,-1)}function UC(u){var f=Aa();return typeof u=="function"&&(u=u()),f.memoizedState=f.baseState=u,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:gf,lastRenderedState:u},f.queue=u,u=u.dispatch=uz.bind(null,jn,u),[f.memoizedState,u]}function yf(u,f,v,E){return u={tag:u,create:f,destroy:v,deps:E,next:null},f=jn.updateQueue,f===null?(f={lastEffect:null,stores:null},jn.updateQueue=f,f.lastEffect=u.next=u):(v=f.lastEffect,v===null?f.lastEffect=u.next=u:(E=v.next,v.next=u,u.next=E,f.lastEffect=u)),u}function OC(){return Xi().memoizedState}function kA(u,f,v,E){var D=Aa();jn.flags|=u,D.memoizedState=yf(1|f,v,void 0,E===void 0?null:E)}function NA(u,f,v,E){var D=Xi();E=E===void 0?null:E;var P=void 0;if(ur!==null){var te=ur.memoizedState;if(P=te.destroy,E!==null&&Fy(E,te.deps)){D.memoizedState=yf(f,v,P,E);return}}jn.flags|=u,D.memoizedState=yf(1|f,v,P,E)}function $C(u,f){return kA(8390656,8,u,f)}function Gy(u,f){return NA(2048,8,u,f)}function GC(u,f){return NA(4,2,u,f)}function VC(u,f){return NA(4,4,u,f)}function HC(u,f){if(typeof f=="function")return u=u(),f(u),function(){f(null)};if(f!=null)return u=u(),f.current=u,function(){f.current=null}}function jC(u,f,v){return v=v!=null?v.concat([u]):null,NA(4,4,HC.bind(null,f,u),v)}function Vy(){}function WC(u,f){var v=Xi();f=f===void 0?null:f;var E=v.memoizedState;return E!==null&&f!==null&&Fy(f,E[1])?E[0]:(v.memoizedState=[u,f],u)}function qC(u,f){var v=Xi();f=f===void 0?null:f;var E=v.memoizedState;return E!==null&&f!==null&&Fy(f,E[1])?E[0]:(u=u(),v.memoizedState=[u,f],u)}function YC(u,f,v){return(uc&21)===0?(u.baseState&&(u.baseState=!1,_i=!0),u.memoizedState=v):(vi(v,f)||(v=oa(),jn.lanes|=v,dc|=v,u.baseState=!0),f)}function lz(u,f){var v=Gt;Gt=v!==0&&4>v?v:4,u(!0);var E=Ly.transition;Ly.transition={};try{u(!1),f()}finally{Gt=v,Ly.transition=E}}function XC(){return Xi().memoizedState}function cz(u,f,v){var E=dl(u);if(v={lane:E,action:v,hasEagerState:!1,eagerState:null,next:null},JC(u))KC(f,v);else if(v=BC(u,f,v,E),v!==null){var D=ai();Ms(v,u,E,D),ZC(v,f,E)}}function uz(u,f,v){var E=dl(u),D={lane:E,action:v,hasEagerState:!1,eagerState:null,next:null};if(JC(u))KC(f,D);else{var P=u.alternate;if(u.lanes===0&&(P===null||P.lanes===0)&&(P=f.lastRenderedReducer,P!==null))try{var te=f.lastRenderedState,pe=P(te,v);if(D.hasEagerState=!0,D.eagerState=pe,vi(pe,te)){var we=f.interleaved;we===null?(D.next=D,Ry(f)):(D.next=we.next,we.next=D),f.interleaved=D;return}}catch{}v=BC(u,f,D,E),v!==null&&(D=ai(),Ms(v,u,E,D),ZC(v,f,E))}}function JC(u){var f=u.alternate;return u===jn||f!==null&&f===jn}function KC(u,f){Af=DA=!0;var v=u.pending;v===null?f.next=f:(f.next=v.next,v.next=f),u.pending=f}function ZC(u,f,v){if((v&4194240)!==0){var E=f.lanes;E&=u.pendingLanes,v|=E,f.lanes=v,Kn(u,v)}}var QA={readContext:Yi,useCallback:Hr,useContext:Hr,useEffect:Hr,useImperativeHandle:Hr,useInsertionEffect:Hr,useLayoutEffect:Hr,useMemo:Hr,useReducer:Hr,useRef:Hr,useState:Hr,useDebugValue:Hr,useDeferredValue:Hr,useTransition:Hr,useMutableSource:Hr,useSyncExternalStore:Hr,useId:Hr,unstable_isNewReconciler:!1},dz={readContext:Yi,useCallback:function(u,f){return Aa().memoizedState=[u,f===void 0?null:f],u},useContext:Yi,useEffect:$C,useImperativeHandle:function(u,f,v){return v=v!=null?v.concat([u]):null,kA(4194308,4,HC.bind(null,f,u),v)},useLayoutEffect:function(u,f){return kA(4194308,4,u,f)},useInsertionEffect:function(u,f){return kA(4,2,u,f)},useMemo:function(u,f){var v=Aa();return f=f===void 0?null:f,u=u(),v.memoizedState=[u,f],u},useReducer:function(u,f,v){var E=Aa();return f=v!==void 0?v(f):f,E.memoizedState=E.baseState=f,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:f},E.queue=u,u=u.dispatch=cz.bind(null,jn,u),[E.memoizedState,u]},useRef:function(u){var f=Aa();return u={current:u},f.memoizedState=u},useState:UC,useDebugValue:Vy,useDeferredValue:function(u){return Aa().memoizedState=u},useTransition:function(){var u=UC(!1),f=u[0];return u=lz.bind(null,u[1]),Aa().memoizedState=u,[f,u]},useMutableSource:function(){},useSyncExternalStore:function(u,f,v){var E=jn,D=Aa();if(Gn){if(v===void 0)throw Error(t(407));v=v()}else{if(v=f(),Ir===null)throw Error(t(349));(uc&30)!==0||QC(E,f,v)}D.memoizedState=v;var P={value:v,getSnapshot:f};return D.queue=P,$C(LC.bind(null,E,P,u),[u]),E.flags|=2048,yf(9,PC.bind(null,E,P,v,f),void 0,null),v},useId:function(){var u=Aa(),f=Ir.identifierPrefix;if(Gn){var v=wr,E=ln;v=(E&~(1<<32-$t(E)-1)).toString(32)+v,f=":"+f+"R"+v,v=mf++,0<v&&(f+="H"+v.toString(32)),f+=":"}else v=oz++,f=":"+f+"r"+v.toString(32)+":";return u.memoizedState=f},unstable_isNewReconciler:!1},hz={readContext:Yi,useCallback:WC,useContext:Yi,useEffect:Gy,useImperativeHandle:jC,useInsertionEffect:GC,useLayoutEffect:VC,useMemo:qC,useReducer:Oy,useRef:OC,useState:function(){return Oy(gf)},useDebugValue:Vy,useDeferredValue:function(u){var f=Xi();return YC(f,ur.memoizedState,u)},useTransition:function(){var u=Oy(gf)[0],f=Xi().memoizedState;return[u,f]},useMutableSource:kC,useSyncExternalStore:NC,useId:XC,unstable_isNewReconciler:!1},fz={readContext:Yi,useCallback:WC,useContext:Yi,useEffect:Gy,useImperativeHandle:jC,useInsertionEffect:GC,useLayoutEffect:VC,useMemo:qC,useReducer:$y,useRef:OC,useState:function(){return $y(gf)},useDebugValue:Vy,useDeferredValue:function(u){var f=Xi();return ur===null?f.memoizedState=u:YC(f,ur.memoizedState,u)},useTransition:function(){var u=$y(gf)[0],f=Xi().memoizedState;return[u,f]},useMutableSource:kC,useSyncExternalStore:NC,useId:XC,unstable_isNewReconciler:!1};function Cs(u,f){if(u&&u.defaultProps){f=ne({},f),u=u.defaultProps;for(var v in u)f[v]===void 0&&(f[v]=u[v]);return f}return f}function Hy(u,f,v,E){f=u.memoizedState,v=v(E,f),v=v==null?f:ne({},f,v),u.memoizedState=v,u.lanes===0&&(u.updateQueue.baseState=v)}var PA={isMounted:function(u){return(u=u._reactInternals)?ki(u)===u:!1},enqueueSetState:function(u,f,v){u=u._reactInternals;var E=ai(),D=dl(u),P=Za(E,D);P.payload=f,v!=null&&(P.callback=v),f=ol(u,P,D),f!==null&&(Ms(f,u,D,E),BA(f,u,D))},enqueueReplaceState:function(u,f,v){u=u._reactInternals;var E=ai(),D=dl(u),P=Za(E,D);P.tag=1,P.payload=f,v!=null&&(P.callback=v),f=ol(u,P,D),f!==null&&(Ms(f,u,D,E),BA(f,u,D))},enqueueForceUpdate:function(u,f){u=u._reactInternals;var v=ai(),E=dl(u),D=Za(v,E);D.tag=2,f!=null&&(D.callback=f),f=ol(u,D,E),f!==null&&(Ms(f,u,E,v),BA(f,u,E))}};function e1(u,f,v,E,D,P,te){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(E,P,te):f.prototype&&f.prototype.isPureReactComponent?!Jo(v,E)||!Jo(D,P):!0}function t1(u,f,v){var E=!1,D=fa,P=f.contextType;return typeof P=="object"&&P!==null?P=Yi(P):(D=Vr(f)?Ja:br.current,E=f.contextTypes,P=(E=E!=null)?sl(u,D):fa),f=new f(v,P),u.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=PA,u.stateNode=f,f._reactInternals=u,E&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=D,u.__reactInternalMemoizedMaskedChildContext=P),f}function n1(u,f,v,E){u=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(v,E),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(v,E),f.state!==u&&PA.enqueueReplaceState(f,f.state,null)}function jy(u,f,v,E){var D=u.stateNode;D.props=v,D.state=u.memoizedState,D.refs={},Dy(u);var P=f.contextType;typeof P=="object"&&P!==null?D.context=Yi(P):(P=Vr(f)?Ja:br.current,D.context=sl(u,P)),D.state=u.memoizedState,P=f.getDerivedStateFromProps,typeof P=="function"&&(Hy(u,f,P,v),D.state=u.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(f=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),f!==D.state&&PA.enqueueReplaceState(D,D.state,null),MA(u,v,D,E),D.state=u.memoizedState),typeof D.componentDidMount=="function"&&(u.flags|=4194308)}function Wu(u,f){try{var v="",E=f;do v+=ye(E),E=E.return;while(E);var D=v}catch(P){D=`
|
|
5
|
+
`+D[te].replace(" at new "," at ");return u.displayName&&we.includes("<anonymous>")&&(we=we.replace("<anonymous>",u.displayName)),we}while(1<=te&&0<=pe);break}}}finally{oe=!1,Error.prepareStackTrace=v}return(u=u?u.displayName||u.name:"")?G(u):""}function ye(u){switch(u.tag){case 5:return G(u.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return u=Ae(u.type,!1),u;case 11:return u=Ae(u.type.render,!1),u;case 1:return u=Ae(u.type,!0),u;default:return""}}function he(u){if(u==null)return null;if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case M:return"Fragment";case S:return"Portal";case R:return"Profiler";case T:return"StrictMode";case V:return"Suspense";case B:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case H:return(u.displayName||"Context")+".Consumer";case k:return(u._context.displayName||"Context")+".Provider";case Q:var f=u.render;return u=u.displayName,u||(u=f.displayName||f.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case W:return f=u.displayName||null,f!==null?f:he(u.type)||"Memo";case K:f=u._payload,u=u._init;try{return he(u(f))}catch{}}return null}function fe(u){var f=u.type;switch(u.tag){case 24:return"Cache";case 9:return(f.displayName||"Context")+".Consumer";case 10:return(f._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=f.render,u=u.displayName||u.name||"",f.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return f;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(f);case 8:return f===T?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f}return null}function Ie(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function Re(u){var f=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(f==="checkbox"||f==="radio")}function ge(u){var f=Re(u)?"checked":"value",v=Object.getOwnPropertyDescriptor(u.constructor.prototype,f),E=""+u[f];if(!u.hasOwnProperty(f)&&typeof v<"u"&&typeof v.get=="function"&&typeof v.set=="function"){var D=v.get,P=v.set;return Object.defineProperty(u,f,{configurable:!0,get:function(){return D.call(this)},set:function(te){E=""+te,P.call(this,te)}}),Object.defineProperty(u,f,{enumerable:v.enumerable}),{getValue:function(){return E},setValue:function(te){E=""+te},stopTracking:function(){u._valueTracker=null,delete u[f]}}}}function Ne(u){u._valueTracker||(u._valueTracker=ge(u))}function tt(u){if(!u)return!1;var f=u._valueTracker;if(!f)return!0;var v=f.getValue(),E="";return u&&(E=Re(u)?u.checked?"true":"false":u.value),u=E,u!==v?(f.setValue(u),!0):!1}function Ge(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}function F(u,f){var v=f.checked;return ne({},f,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:v??u._wrapperState.initialChecked})}function re(u,f){var v=f.defaultValue==null?"":f.defaultValue,E=f.checked!=null?f.checked:f.defaultChecked;v=Ie(f.value!=null?f.value:v),u._wrapperState={initialChecked:E,initialValue:v,controlled:f.type==="checkbox"||f.type==="radio"?f.checked!=null:f.value!=null}}function Ee(u,f){f=f.checked,f!=null&&b(u,"checked",f,!1)}function q(u,f){Ee(u,f);var v=Ie(f.value),E=f.type;if(v!=null)E==="number"?(v===0&&u.value===""||u.value!=v)&&(u.value=""+v):u.value!==""+v&&(u.value=""+v);else if(E==="submit"||E==="reset"){u.removeAttribute("value");return}f.hasOwnProperty("value")?ie(u,f.type,v):f.hasOwnProperty("defaultValue")&&ie(u,f.type,Ie(f.defaultValue)),f.checked==null&&f.defaultChecked!=null&&(u.defaultChecked=!!f.defaultChecked)}function ee(u,f,v){if(f.hasOwnProperty("value")||f.hasOwnProperty("defaultValue")){var E=f.type;if(!(E!=="submit"&&E!=="reset"||f.value!==void 0&&f.value!==null))return;f=""+u._wrapperState.initialValue,v||f===u.value||(u.value=f),u.defaultValue=f}v=u.name,v!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,v!==""&&(u.name=v)}function ie(u,f,v){(f!=="number"||Ge(u.ownerDocument)!==u)&&(v==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+v&&(u.defaultValue=""+v))}var be=Array.isArray;function ve(u,f,v,E){if(u=u.options,f){f={};for(var D=0;D<v.length;D++)f["$"+v[D]]=!0;for(v=0;v<u.length;v++)D=f.hasOwnProperty("$"+u[v].value),u[v].selected!==D&&(u[v].selected=D),D&&E&&(u[v].defaultSelected=!0)}else{for(v=""+Ie(v),f=null,D=0;D<u.length;D++){if(u[D].value===v){u[D].selected=!0,E&&(u[D].defaultSelected=!0);return}f!==null||u[D].disabled||(f=u[D])}f!==null&&(f.selected=!0)}}function ce(u,f){if(f.dangerouslySetInnerHTML!=null)throw Error(t(91));return ne({},f,{value:void 0,defaultValue:void 0,children:""+u._wrapperState.initialValue})}function Z(u,f){var v=f.value;if(v==null){if(v=f.children,f=f.defaultValue,v!=null){if(f!=null)throw Error(t(92));if(be(v)){if(1<v.length)throw Error(t(93));v=v[0]}f=v}f==null&&(f=""),v=f}u._wrapperState={initialValue:Ie(v)}}function Y(u,f){var v=Ie(f.value),E=Ie(f.defaultValue);v!=null&&(v=""+v,v!==u.value&&(u.value=v),f.defaultValue==null&&u.defaultValue!==v&&(u.defaultValue=v)),E!=null&&(u.defaultValue=""+E)}function le(u){var f=u.textContent;f===u._wrapperState.initialValue&&f!==""&&f!==null&&(u.value=f)}function Ce(u){switch(u){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function me(u,f){return u==null||u==="http://www.w3.org/1999/xhtml"?Ce(f):u==="http://www.w3.org/2000/svg"&&f==="foreignObject"?"http://www.w3.org/1999/xhtml":u}var xe,st=(function(u){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(f,v,E,D){MSApp.execUnsafeLocalFunction(function(){return u(f,v,E,D)})}:u})(function(u,f){if(u.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in u)u.innerHTML=f;else{for(xe=xe||document.createElement("div"),xe.innerHTML="<svg>"+f.valueOf().toString()+"</svg>",f=xe.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;f.firstChild;)u.appendChild(f.firstChild)}});function He(u,f){if(f){var v=u.firstChild;if(v&&v===u.lastChild&&v.nodeType===3){v.nodeValue=f;return}}u.textContent=f}var Ke={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},nt=["Webkit","ms","Moz","O"];Object.keys(Ke).forEach(function(u){nt.forEach(function(f){f=f+u.charAt(0).toUpperCase()+u.substring(1),Ke[f]=Ke[u]})});function ze(u,f,v){return f==null||typeof f=="boolean"||f===""?"":v||typeof f!="number"||f===0||Ke.hasOwnProperty(u)&&Ke[u]?(""+f).trim():f+"px"}function Ze(u,f){u=u.style;for(var v in f)if(f.hasOwnProperty(v)){var E=v.indexOf("--")===0,D=ze(v,f[v],E);v==="float"&&(v="cssFloat"),E?u.setProperty(v,D):u[v]=D}}var pt=ne({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ft(u,f){if(f){if(pt[u]&&(f.children!=null||f.dangerouslySetInnerHTML!=null))throw Error(t(137,u));if(f.dangerouslySetInnerHTML!=null){if(f.children!=null)throw Error(t(60));if(typeof f.dangerouslySetInnerHTML!="object"||!("__html"in f.dangerouslySetInnerHTML))throw Error(t(61))}if(f.style!=null&&typeof f.style!="object")throw Error(t(62))}}function dt(u,f){if(u.indexOf("-")===-1)return typeof f.is=="string";switch(u){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 Mt=null;function _e(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var ut=null,je=null,Ye=null;function We(u){if(u=sc(u)){if(typeof ut!="function")throw Error(t(280));var f=u.stateNode;f&&(f=zu(f),ut(u.stateNode,u.type,f))}}function Ve(u){je?Ye?Ye.push(u):Ye=[u]:je=u}function _t(){if(je){var u=je,f=Ye;if(Ye=je=null,We(u),f)for(u=0;u<f.length;u++)We(f[u])}}function Ot(u,f){return u(f)}function En(){}var dn=!1;function hn(u,f,v){if(dn)return u(f,v);dn=!0;try{return Ot(u,f,v)}finally{dn=!1,(je!==null||Ye!==null)&&(En(),_t())}}function tr(u,f){var v=u.stateNode;if(v===null)return null;var E=zu(v);if(E===null)return null;v=E[f];e:switch(f){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(E=!E.disabled)||(u=u.type,E=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!E;break e;default:u=!1}if(u)return null;if(v&&typeof v!="function")throw Error(t(231,f,typeof v));return v}var No=!1;if(o)try{var ys={};Object.defineProperty(ys,"passive",{get:function(){No=!0}}),window.addEventListener("test",ys,ys),window.removeEventListener("test",ys,ys)}catch{No=!1}function Wl(u,f,v,E,D,P,te,pe,we){var Pe=Array.prototype.slice.call(arguments,3);try{f.apply(v,Pe)}catch(Xe){this.onError(Xe)}}var Ur=!1,xs=null,sa=!1,Oa=null,$a={onError:function(u){Ur=!0,xs=u}};function ql(u,f,v,E,D,P,te,pe,we){Ur=!1,xs=null,Wl.apply($a,arguments)}function Ga(u,f,v,E,D,P,te,pe,we){if(ql.apply(this,arguments),Ur){if(Ur){var Pe=xs;Ur=!1,xs=null}else throw Error(t(198));sa||(sa=!0,Oa=Pe)}}function ki(u){var f=u,v=u;if(u.alternate)for(;f.return;)f=f.return;else{u=f;do f=u,(f.flags&4098)!==0&&(v=f.return),u=f.return;while(u)}return f.tag===3?v:null}function Qo(u){if(u.tag===13){var f=u.memoizedState;if(f===null&&(u=u.alternate,u!==null&&(f=u.memoizedState)),f!==null)return f.dehydrated}return null}function du(u){if(ki(u)!==u)throw Error(t(188))}function mi(u){var f=u.alternate;if(!f){if(f=ki(u),f===null)throw Error(t(188));return f!==u?null:u}for(var v=u,E=f;;){var D=v.return;if(D===null)break;var P=D.alternate;if(P===null){if(E=D.return,E!==null){v=E;continue}break}if(D.child===P.child){for(P=D.child;P;){if(P===v)return du(D),u;if(P===E)return du(D),f;P=P.sibling}throw Error(t(188))}if(v.return!==E.return)v=D,E=P;else{for(var te=!1,pe=D.child;pe;){if(pe===v){te=!0,v=D,E=P;break}if(pe===E){te=!0,E=D,v=P;break}pe=pe.sibling}if(!te){for(pe=P.child;pe;){if(pe===v){te=!0,v=P,E=D;break}if(pe===E){te=!0,E=P,v=D;break}pe=pe.sibling}if(!te)throw Error(t(189))}}if(v.alternate!==E)throw Error(t(190))}if(v.tag!==3)throw Error(t(188));return v.stateNode.current===v?u:f}function Po(u){return u=mi(u),u!==null?Lo(u):null}function Lo(u){if(u.tag===5||u.tag===6)return u;for(u=u.child;u!==null;){var f=Lo(u);if(f!==null)return f;u=u.sibling}return null}var vs=e.unstable_scheduleCallback,gi=e.unstable_cancelCallback,ae=e.unstable_shouldYield,Te=e.unstable_requestPaint,De=e.unstable_now,Fe=e.unstable_getCurrentPriorityLevel,Me=e.unstable_ImmediatePriority,at=e.unstable_UserBlockingPriority,lt=e.unstable_NormalPriority,At=e.unstable_LowPriority,gt=e.unstable_IdlePriority,Qt=null,St=null;function kt(u){if(St&&typeof St.onCommitFiberRoot=="function")try{St.onCommitFiberRoot(Qt,u,void 0,(u.current.flags&128)===128)}catch{}}var $t=Math.clz32?Math.clz32:pn,xn=Math.log,Fn=Math.LN2;function pn(u){return u>>>=0,u===0?32:31-(xn(u)/Fn|0)|0}var an=64,Rt=4194304;function vn(u){switch(u&-u){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: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 u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function tn(u,f){var v=u.pendingLanes;if(v===0)return 0;var E=0,D=u.suspendedLanes,P=u.pingedLanes,te=v&268435455;if(te!==0){var pe=te&~D;pe!==0?E=vn(pe):(P&=te,P!==0&&(E=vn(P)))}else te=v&~D,te!==0?E=vn(te):P!==0&&(E=vn(P));if(E===0)return 0;if(f!==0&&f!==E&&(f&D)===0&&(D=E&-E,P=f&-f,D>=P||D===16&&(P&4194240)!==0))return f;if((E&4)!==0&&(E|=v&16),f=u.entangledLanes,f!==0)for(u=u.entanglements,f&=E;0<f;)v=31-$t(f),D=1<<v,E|=u[v],f&=~D;return E}function Nr(u,f){switch(u){case 1:case 2:case 4:return f+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return f+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function aa(u,f){for(var v=u.suspendedLanes,E=u.pingedLanes,D=u.expirationTimes,P=u.pendingLanes;0<P;){var te=31-$t(P),pe=1<<te,we=D[te];we===-1?((pe&v)===0||(pe&E)!==0)&&(D[te]=Nr(pe,f)):we<=f&&(u.expiredLanes|=pe),P&=~pe}}function cr(u){return u=u.pendingLanes&-1073741825,u!==0?u:u&1073741824?1073741824:0}function oa(){var u=an;return an<<=1,(an&4194240)===0&&(an=64),u}function Cn(u){for(var f=[],v=0;31>v;v++)f.push(u);return f}function Yn(u,f,v){u.pendingLanes|=f,f!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,f=31-$t(f),u[f]=v}function Or(u,f){var v=u.pendingLanes&~f;u.pendingLanes=f,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=f,u.mutableReadLanes&=f,u.entangledLanes&=f,f=u.entanglements;var E=u.eventTimes;for(u=u.expirationTimes;0<v;){var D=31-$t(v),P=1<<D;f[D]=0,E[D]=-1,u[D]=-1,v&=~P}}function Kn(u,f){var v=u.entangledLanes|=f;for(u=u.entanglements;v;){var E=31-$t(v),D=1<<E;D&f|u[E]&f&&(u[E]|=f),v&=~D}}var Gt=0;function Fo(u){return u&=-u,1<u?4<u?(u&268435455)!==0?16:536870912:4:1}var yi,zo,Wp,hu,qp,bh=!1,fu=[],la=null,Ni=null,ca=null,xi=new Map,$r=new Map,_s=[],pu="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 submit".split(" ");function Au(u,f){switch(u){case"focusin":case"focusout":la=null;break;case"dragenter":case"dragleave":Ni=null;break;case"mouseover":case"mouseout":ca=null;break;case"pointerover":case"pointerout":xi.delete(f.pointerId);break;case"gotpointercapture":case"lostpointercapture":$r.delete(f.pointerId)}}function Uo(u,f,v,E,D,P){return u===null||u.nativeEvent!==P?(u={blockedOn:f,domEventName:v,eventSystemFlags:E,nativeEvent:P,targetContainers:[D]},f!==null&&(f=sc(f),f!==null&&zo(f)),u):(u.eventSystemFlags|=E,f=u.targetContainers,D!==null&&f.indexOf(D)===-1&&f.push(D),u)}function Yp(u,f,v,E,D){switch(f){case"focusin":return la=Uo(la,u,f,v,E,D),!0;case"dragenter":return Ni=Uo(Ni,u,f,v,E,D),!0;case"mouseover":return ca=Uo(ca,u,f,v,E,D),!0;case"pointerover":var P=D.pointerId;return xi.set(P,Uo(xi.get(P)||null,u,f,v,E,D)),!0;case"gotpointercapture":return P=D.pointerId,$r.set(P,Uo($r.get(P)||null,u,f,v,E,D)),!0}return!1}function Xp(u){var f=Xa(u.target);if(f!==null){var v=ki(f);if(v!==null){if(f=v.tag,f===13){if(f=Qo(v),f!==null){u.blockedOn=f,qp(u.priority,function(){Wp(v)});return}}else if(f===3&&v.stateNode.current.memoizedState.isDehydrated){u.blockedOn=v.tag===3?v.stateNode.containerInfo:null;return}}}u.blockedOn=null}function Oo(u){if(u.blockedOn!==null)return!1;for(var f=u.targetContainers;0<f.length;){var v=wh(u.domEventName,u.eventSystemFlags,f[0],u.nativeEvent);if(v===null){v=u.nativeEvent;var E=new v.constructor(v.type,v);Mt=E,v.target.dispatchEvent(E),Mt=null}else return f=sc(v),f!==null&&zo(f),u.blockedOn=v,!1;f.shift()}return!0}function Jp(u,f,v){Oo(u)&&v.delete(f)}function Kp(){bh=!1,la!==null&&Oo(la)&&(la=null),Ni!==null&&Oo(Ni)&&(Ni=null),ca!==null&&Oo(ca)&&(ca=null),xi.forEach(Jp),$r.forEach(Jp)}function Yl(u,f){u.blockedOn===f&&(u.blockedOn=null,bh||(bh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Kp)))}function Va(u){function f(D){return Yl(D,u)}if(0<fu.length){Yl(fu[0],u);for(var v=1;v<fu.length;v++){var E=fu[v];E.blockedOn===u&&(E.blockedOn=null)}}for(la!==null&&Yl(la,u),Ni!==null&&Yl(Ni,u),ca!==null&&Yl(ca,u),xi.forEach(f),$r.forEach(f),v=0;v<_s.length;v++)E=_s[v],E.blockedOn===u&&(E.blockedOn=null);for(;0<_s.length&&(v=_s[0],v.blockedOn===null);)Xp(v),v.blockedOn===null&&_s.shift()}var $o=w.ReactCurrentBatchConfig,mu=!0;function ny(u,f,v,E){var D=Gt,P=$o.transition;$o.transition=null;try{Gt=1,Go(u,f,v,E)}finally{Gt=D,$o.transition=P}}function ry(u,f,v,E){var D=Gt,P=$o.transition;$o.transition=null;try{Gt=4,Go(u,f,v,E)}finally{Gt=D,$o.transition=P}}function Go(u,f,v,E){if(mu){var D=wh(u,f,v,E);if(D===null)Pu(u,f,E,gu,v),Au(u,E);else if(Yp(D,u,f,v,E))E.stopPropagation();else if(Au(u,E),f&4&&-1<pu.indexOf(u)){for(;D!==null;){var P=sc(D);if(P!==null&&yi(P),P=wh(u,f,v,E),P===null&&Pu(u,f,E,gu,v),P===D)break;D=P}D!==null&&E.stopPropagation()}else Pu(u,f,E,null,v)}}var gu=null;function wh(u,f,v,E){if(gu=null,u=_e(E),u=Xa(u),u!==null)if(f=ki(u),f===null)u=null;else if(v=f.tag,v===13){if(u=Qo(f),u!==null)return u;u=null}else if(v===3){if(f.stateNode.current.memoizedState.isDehydrated)return f.tag===3?f.stateNode.containerInfo:null;u=null}else f!==u&&(u=null);return gu=u,null}function Zp(u){switch(u){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Fe()){case Me:return 1;case at:return 4;case lt:case At:return 16;case gt:return 536870912;default:return 16}default:return 16}}var ua=null,Eh=null,yu=null;function Ih(){if(yu)return yu;var u,f=Eh,v=f.length,E,D="value"in ua?ua.value:ua.textContent,P=D.length;for(u=0;u<v&&f[u]===D[u];u++);var te=v-u;for(E=1;E<=te&&f[v-E]===D[P-E];E++);return yu=D.slice(u,1<E?1-E:void 0)}function xu(u){var f=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&f===13&&(u=13)):u=f,u===10&&(u=13),32<=u||u===13?u:0}function vu(){return!0}function eA(){return!1}function ii(u){function f(v,E,D,P,te){this._reactName=v,this._targetInst=D,this.type=E,this.nativeEvent=P,this.target=te,this.currentTarget=null;for(var pe in u)u.hasOwnProperty(pe)&&(v=u[pe],this[pe]=v?v(P):P[pe]);return this.isDefaultPrevented=(P.defaultPrevented!=null?P.defaultPrevented:P.returnValue===!1)?vu:eA,this.isPropagationStopped=eA,this}return ne(f.prototype,{preventDefault:function(){this.defaultPrevented=!0;var v=this.nativeEvent;v&&(v.preventDefault?v.preventDefault():typeof v.returnValue!="unknown"&&(v.returnValue=!1),this.isDefaultPrevented=vu)},stopPropagation:function(){var v=this.nativeEvent;v&&(v.stopPropagation?v.stopPropagation():typeof v.cancelBubble!="unknown"&&(v.cancelBubble=!0),this.isPropagationStopped=vu)},persist:function(){},isPersistent:vu}),f}var Vo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ch=ii(Vo),Xl=ne({},Vo,{view:0,detail:0}),iy=ii(Xl),_u,bu,Ho,wu=ne({},Xl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Th,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==Ho&&(Ho&&u.type==="mousemove"?(_u=u.screenX-Ho.screenX,bu=u.screenY-Ho.screenY):bu=_u=0,Ho=u),_u)},movementY:function(u){return"movementY"in u?u.movementY:bu}}),tA=ii(wu),nA=ne({},wu,{dataTransfer:0}),rA=ii(nA),Jl=ne({},Xl,{relatedTarget:0}),Sh=ii(Jl),iA=ne({},Vo,{animationName:0,elapsedTime:0,pseudoElement:0}),sy=ii(iA),ay=ne({},Vo,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),oy=ii(ay),Bh=ne({},Vo,{data:0}),Mh=ii(Bh),ly={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cy={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"},uy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function dy(u){var f=this.nativeEvent;return f.getModifierState?f.getModifierState(u):(u=uy[u])?!!f[u]:!1}function Th(){return dy}var hy=ne({},Xl,{key:function(u){if(u.key){var f=ly[u.key]||u.key;if(f!=="Unidentified")return f}return u.type==="keypress"?(u=xu(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?cy[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Th,charCode:function(u){return u.type==="keypress"?xu(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?xu(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),fy=ii(hy),Ha=ne({},wu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Kl=ii(Ha),sA=ne({},Xl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Th}),py=ii(sA),Eu=ne({},Vo,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ay=ii(Eu),my=ne({},wu,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),Rh=ii(my),Dh=[9,13,27,32],Iu=o&&"CompositionEvent"in window,jo=null;o&&"documentMode"in document&&(jo=document.documentMode);var aA=o&&"TextEvent"in window&&!jo,kh=o&&(!Iu||jo&&8<jo&&11>=jo),Nh=" ",Qh=!1;function oA(u,f){switch(u){case"keyup":return Dh.indexOf(f.keyCode)!==-1;case"keydown":return f.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ph(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var Wo=!1;function lA(u,f){switch(u){case"compositionend":return Ph(f);case"keypress":return f.which!==32?null:(Qh=!0,Nh);case"textInput":return u=f.data,u===Nh&&Qh?null:u;default:return null}}function cA(u,f){if(Wo)return u==="compositionend"||!Iu&&oA(u,f)?(u=Ih(),yu=Eh=ua=null,Wo=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(f.ctrlKey||f.altKey||f.metaKey)||f.ctrlKey&&f.altKey){if(f.char&&1<f.char.length)return f.char;if(f.which)return String.fromCharCode(f.which)}return null;case"compositionend":return kh&&f.locale!=="ko"?null:f.data;default:return null}}var Cu={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 Qi(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f==="input"?!!Cu[u.type]:f==="textarea"}function qo(u,f,v,E){Ve(E),f=rc(f,"onChange"),0<f.length&&(v=new Ch("onChange","change",null,v,E),u.push({event:v,listeners:f}))}var ja=null,Yo=null;function uA(u){ef(u,0)}function Zl(u){var f=rl(u);if(tt(f))return u}function Lh(u,f){if(u==="change")return f}var Fh=!1;if(o){var Su;if(o){var Yt="oninput"in document;if(!Yt){var Xo=document.createElement("div");Xo.setAttribute("oninput","return;"),Yt=typeof Xo.oninput=="function"}Su=Yt}else Su=!1;Fh=Su&&(!document.documentMode||9<document.documentMode)}function zh(){ja&&(ja.detachEvent("onpropertychange",qt),Yo=ja=null)}function qt(u){if(u.propertyName==="value"&&Zl(Yo)){var f=[];qo(f,Yo,u,_e(u)),hn(uA,f)}}function Uh(u,f,v){u==="focusin"?(zh(),ja=f,Yo=v,ja.attachEvent("onpropertychange",qt)):u==="focusout"&&zh()}function Xt(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return Zl(Yo)}function dA(u,f){if(u==="click")return Zl(f)}function Oh(u,f){if(u==="input"||u==="change")return Zl(f)}function hA(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var vi=typeof Object.is=="function"?Object.is:hA;function Jo(u,f){if(vi(u,f))return!0;if(typeof u!="object"||u===null||typeof f!="object"||f===null)return!1;var v=Object.keys(u),E=Object.keys(f);if(v.length!==E.length)return!1;for(E=0;E<v.length;E++){var D=v[E];if(!l.call(f,D)||!vi(u[D],f[D]))return!1}return!0}function Bu(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function $h(u,f){var v=Bu(u);u=0;for(var E;v;){if(v.nodeType===3){if(E=u+v.textContent.length,u<=f&&E>=f)return{node:v,offset:f-u};u=E}e:{for(;v;){if(v.nextSibling){v=v.nextSibling;break e}v=v.parentNode}v=void 0}v=Bu(v)}}function Gh(u,f){return u&&f?u===f?!0:u&&u.nodeType===3?!1:f&&f.nodeType===3?Gh(u,f.parentNode):"contains"in u?u.contains(f):u.compareDocumentPosition?!!(u.compareDocumentPosition(f)&16):!1:!1}function Vh(){for(var u=window,f=Ge();f instanceof u.HTMLIFrameElement;){try{var v=typeof f.contentWindow.location.href=="string"}catch{v=!1}if(v)u=f.contentWindow;else break;f=Ge(u.document)}return f}function Mu(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f&&(f==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||f==="textarea"||u.contentEditable==="true")}function fA(u){var f=Vh(),v=u.focusedElem,E=u.selectionRange;if(f!==v&&v&&v.ownerDocument&&Gh(v.ownerDocument.documentElement,v)){if(E!==null&&Mu(v)){if(f=E.start,u=E.end,u===void 0&&(u=f),"selectionStart"in v)v.selectionStart=f,v.selectionEnd=Math.min(u,v.value.length);else if(u=(f=v.ownerDocument||document)&&f.defaultView||window,u.getSelection){u=u.getSelection();var D=v.textContent.length,P=Math.min(E.start,D);E=E.end===void 0?P:Math.min(E.end,D),!u.extend&&P>E&&(D=E,E=P,P=D),D=$h(v,P);var te=$h(v,E);D&&te&&(u.rangeCount!==1||u.anchorNode!==D.node||u.anchorOffset!==D.offset||u.focusNode!==te.node||u.focusOffset!==te.offset)&&(f=f.createRange(),f.setStart(D.node,D.offset),u.removeAllRanges(),P>E?(u.addRange(f),u.extend(te.node,te.offset)):(f.setEnd(te.node,te.offset),u.addRange(f)))}}for(f=[],u=v;u=u.parentNode;)u.nodeType===1&&f.push({element:u,left:u.scrollLeft,top:u.scrollTop});for(typeof v.focus=="function"&&v.focus(),v=0;v<f.length;v++)u=f[v],u.element.scrollLeft=u.left,u.element.scrollTop=u.top}}var pA=o&&"documentMode"in document&&11>=document.documentMode,Wa=null,Tu=null,Ko=null,Ru=!1;function Hh(u,f,v){var E=v.window===v?v.document:v.nodeType===9?v:v.ownerDocument;Ru||Wa==null||Wa!==Ge(E)||(E=Wa,"selectionStart"in E&&Mu(E)?E={start:E.selectionStart,end:E.selectionEnd}:(E=(E.ownerDocument&&E.ownerDocument.defaultView||window).getSelection(),E={anchorNode:E.anchorNode,anchorOffset:E.anchorOffset,focusNode:E.focusNode,focusOffset:E.focusOffset}),Ko&&Jo(Ko,E)||(Ko=E,E=rc(Tu,"onSelect"),0<E.length&&(f=new Ch("onSelect","select",null,f,v),u.push({event:f,listeners:E}),f.target=Wa)))}function ec(u,f){var v={};return v[u.toLowerCase()]=f.toLowerCase(),v["Webkit"+u]="webkit"+f,v["Moz"+u]="moz"+f,v}var qa={animationend:ec("Animation","AnimationEnd"),animationiteration:ec("Animation","AnimationIteration"),animationstart:ec("Animation","AnimationStart"),transitionend:ec("Transition","TransitionEnd")},Du={},jh={};o&&(jh=document.createElement("div").style,"AnimationEvent"in window||(delete qa.animationend.animation,delete qa.animationiteration.animation,delete qa.animationstart.animation),"TransitionEvent"in window||delete qa.transitionend.transition);function tc(u){if(Du[u])return Du[u];if(!qa[u])return u;var f=qa[u],v;for(v in f)if(f.hasOwnProperty(v)&&v in jh)return Du[u]=f[v];return u}var Wh=tc("animationend"),qh=tc("animationiteration"),Yh=tc("animationstart"),Xh=tc("transitionend"),Jh=new Map,Kh="abort auxClick 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 bs(u,f){Jh.set(u,f),s(f,[u])}for(var ku=0;ku<Kh.length;ku++){var Nu=Kh[ku],AA=Nu.toLowerCase(),mA=Nu[0].toUpperCase()+Nu.slice(1);bs(AA,"on"+mA)}bs(Wh,"onAnimationEnd"),bs(qh,"onAnimationIteration"),bs(Yh,"onAnimationStart"),bs("dblclick","onDoubleClick"),bs("focusin","onFocus"),bs("focusout","onBlur"),bs(Xh,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zo="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(" "),gA=new Set("cancel close invalid load scroll toggle".split(" ").concat(Zo));function Zh(u,f,v){var E=u.type||"unknown-event";u.currentTarget=v,Ga(E,f,void 0,u),u.currentTarget=null}function ef(u,f){f=(f&4)!==0;for(var v=0;v<u.length;v++){var E=u[v],D=E.event;E=E.listeners;e:{var P=void 0;if(f)for(var te=E.length-1;0<=te;te--){var pe=E[te],we=pe.instance,Pe=pe.currentTarget;if(pe=pe.listener,we!==P&&D.isPropagationStopped())break e;Zh(D,pe,Pe),P=we}else for(te=0;te<E.length;te++){if(pe=E[te],we=pe.instance,Pe=pe.currentTarget,pe=pe.listener,we!==P&&D.isPropagationStopped())break e;Zh(D,pe,Pe),P=we}}}if(sa)throw u=Oa,sa=!1,Oa=null,u}function Tn(u,f){var v=f[cf];v===void 0&&(v=f[cf]=new Set);var E=u+"__bubble";v.has(E)||(tf(f,u,2,!1),v.add(E))}function Qu(u,f,v){var E=0;f&&(E|=4),tf(v,u,E,f)}var nc="_reactListening"+Math.random().toString(36).slice(2);function el(u){if(!u[nc]){u[nc]=!0,r.forEach(function(v){v!=="selectionchange"&&(gA.has(v)||Qu(v,!1,u),Qu(v,!0,u))});var f=u.nodeType===9?u:u.ownerDocument;f===null||f[nc]||(f[nc]=!0,Qu("selectionchange",!1,f))}}function tf(u,f,v,E){switch(Zp(f)){case 1:var D=ny;break;case 4:D=ry;break;default:D=Go}v=D.bind(null,f,v,u),D=void 0,!No||f!=="touchstart"&&f!=="touchmove"&&f!=="wheel"||(D=!0),E?D!==void 0?u.addEventListener(f,v,{capture:!0,passive:D}):u.addEventListener(f,v,!0):D!==void 0?u.addEventListener(f,v,{passive:D}):u.addEventListener(f,v,!1)}function Pu(u,f,v,E,D){var P=E;if((f&1)===0&&(f&2)===0&&E!==null)e:for(;;){if(E===null)return;var te=E.tag;if(te===3||te===4){var pe=E.stateNode.containerInfo;if(pe===D||pe.nodeType===8&&pe.parentNode===D)break;if(te===4)for(te=E.return;te!==null;){var we=te.tag;if((we===3||we===4)&&(we=te.stateNode.containerInfo,we===D||we.nodeType===8&&we.parentNode===D))return;te=te.return}for(;pe!==null;){if(te=Xa(pe),te===null)return;if(we=te.tag,we===5||we===6){E=P=te;continue e}pe=pe.parentNode}}E=E.return}hn(function(){var Pe=P,Xe=_e(v),rt=[];e:{var qe=Jh.get(u);if(qe!==void 0){var yt=Ch,Et=u;switch(u){case"keypress":if(xu(v)===0)break e;case"keydown":case"keyup":yt=fy;break;case"focusin":Et="focus",yt=Sh;break;case"focusout":Et="blur",yt=Sh;break;case"beforeblur":case"afterblur":yt=Sh;break;case"click":if(v.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":yt=tA;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":yt=rA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":yt=py;break;case Wh:case qh:case Yh:yt=sy;break;case Xh:yt=Ay;break;case"scroll":yt=iy;break;case"wheel":yt=Rh;break;case"copy":case"cut":case"paste":yt=oy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":yt=Kl}var Ct=(f&4)!==0,Zn=!Ct&&u==="scroll",ke=Ct?qe!==null?qe+"Capture":null:qe;Ct=[];for(var Be=Pe,Qe;Be!==null;){Qe=Be;var ot=Qe.stateNode;if(Qe.tag===5&&ot!==null&&(Qe=ot,ke!==null&&(ot=tr(Be,ke),ot!=null&&Ct.push(tl(Be,ot,Qe)))),Zn)break;Be=Be.return}0<Ct.length&&(qe=new yt(qe,Et,null,v,Xe),rt.push({event:qe,listeners:Ct}))}}if((f&7)===0){e:{if(qe=u==="mouseover"||u==="pointerover",yt=u==="mouseout"||u==="pointerout",qe&&v!==Mt&&(Et=v.relatedTarget||v.fromElement)&&(Xa(Et)||Et[ws]))break e;if((yt||qe)&&(qe=Xe.window===Xe?Xe:(qe=Xe.ownerDocument)?qe.defaultView||qe.parentWindow:window,yt?(Et=v.relatedTarget||v.toElement,yt=Pe,Et=Et?Xa(Et):null,Et!==null&&(Zn=ki(Et),Et!==Zn||Et.tag!==5&&Et.tag!==6)&&(Et=null)):(yt=null,Et=Pe),yt!==Et)){if(Ct=tA,ot="onMouseLeave",ke="onMouseEnter",Be="mouse",(u==="pointerout"||u==="pointerover")&&(Ct=Kl,ot="onPointerLeave",ke="onPointerEnter",Be="pointer"),Zn=yt==null?qe:rl(yt),Qe=Et==null?qe:rl(Et),qe=new Ct(ot,Be+"leave",yt,v,Xe),qe.target=Zn,qe.relatedTarget=Qe,ot=null,Xa(Xe)===Pe&&(Ct=new Ct(ke,Be+"enter",Et,v,Xe),Ct.target=Qe,Ct.relatedTarget=Zn,ot=Ct),Zn=ot,yt&&Et)t:{for(Ct=yt,ke=Et,Be=0,Qe=Ct;Qe;Qe=Ya(Qe))Be++;for(Qe=0,ot=ke;ot;ot=Ya(ot))Qe++;for(;0<Be-Qe;)Ct=Ya(Ct),Be--;for(;0<Qe-Be;)ke=Ya(ke),Qe--;for(;Be--;){if(Ct===ke||ke!==null&&Ct===ke.alternate)break t;Ct=Ya(Ct),ke=Ya(ke)}Ct=null}else Ct=null;yt!==null&&Wi(rt,qe,yt,Ct,!1),Et!==null&&Zn!==null&&Wi(rt,Zn,Et,Ct,!0)}}e:{if(qe=Pe?rl(Pe):window,yt=qe.nodeName&&qe.nodeName.toLowerCase(),yt==="select"||yt==="input"&&qe.type==="file")var Bt=Lh;else if(Qi(qe))if(Fh)Bt=Oh;else{Bt=Xt;var zt=Uh}else(yt=qe.nodeName)&&yt.toLowerCase()==="input"&&(qe.type==="checkbox"||qe.type==="radio")&&(Bt=dA);if(Bt&&(Bt=Bt(u,Pe))){qo(rt,Bt,v,Xe);break e}zt&&zt(u,qe,Pe),u==="focusout"&&(zt=qe._wrapperState)&&zt.controlled&&qe.type==="number"&&ie(qe,"number",qe.value)}switch(zt=Pe?rl(Pe):window,u){case"focusin":(Qi(zt)||zt.contentEditable==="true")&&(Wa=zt,Tu=Pe,Ko=null);break;case"focusout":Ko=Tu=Wa=null;break;case"mousedown":Ru=!0;break;case"contextmenu":case"mouseup":case"dragend":Ru=!1,Hh(rt,v,Xe);break;case"selectionchange":if(pA)break;case"keydown":case"keyup":Hh(rt,v,Xe)}var Ut;if(Iu)e:{switch(u){case"compositionstart":var Ht="onCompositionStart";break e;case"compositionend":Ht="onCompositionEnd";break e;case"compositionupdate":Ht="onCompositionUpdate";break e}Ht=void 0}else Wo?oA(u,v)&&(Ht="onCompositionEnd"):u==="keydown"&&v.keyCode===229&&(Ht="onCompositionStart");Ht&&(kh&&v.locale!=="ko"&&(Wo||Ht!=="onCompositionStart"?Ht==="onCompositionEnd"&&Wo&&(Ut=Ih()):(ua=Xe,Eh="value"in ua?ua.value:ua.textContent,Wo=!0)),zt=rc(Pe,Ht),0<zt.length&&(Ht=new Mh(Ht,u,null,v,Xe),rt.push({event:Ht,listeners:zt}),Ut?Ht.data=Ut:(Ut=Ph(v),Ut!==null&&(Ht.data=Ut)))),(Ut=aA?lA(u,v):cA(u,v))&&(Pe=rc(Pe,"onBeforeInput"),0<Pe.length&&(Xe=new Mh("onBeforeInput","beforeinput",null,v,Xe),rt.push({event:Xe,listeners:Pe}),Xe.data=Ut))}ef(rt,f)})}function tl(u,f,v){return{instance:u,listener:f,currentTarget:v}}function rc(u,f){for(var v=f+"Capture",E=[];u!==null;){var D=u,P=D.stateNode;D.tag===5&&P!==null&&(D=P,P=tr(u,v),P!=null&&E.unshift(tl(u,P,D)),P=tr(u,f),P!=null&&E.push(tl(u,P,D))),u=u.return}return E}function Ya(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5);return u||null}function Wi(u,f,v,E,D){for(var P=f._reactName,te=[];v!==null&&v!==E;){var pe=v,we=pe.alternate,Pe=pe.stateNode;if(we!==null&&we===E)break;pe.tag===5&&Pe!==null&&(pe=Pe,D?(we=tr(v,P),we!=null&&te.unshift(tl(v,we,pe))):D||(we=tr(v,P),we!=null&&te.push(tl(v,we,pe)))),v=v.return}te.length!==0&&u.push({event:f,listeners:te})}var gy=/\r\n?/g,nf=/\u0000|\uFFFD/g;function yA(u){return(typeof u=="string"?u:""+u).replace(gy,`
|
|
6
|
+
`).replace(nf,"")}function Lu(u,f,v){if(f=yA(f),yA(u)!==f&&v)throw Error(t(425))}function Fu(){}var rf=null,sf=null;function af(u,f){return u==="textarea"||u==="noscript"||typeof f.children=="string"||typeof f.children=="number"||typeof f.dangerouslySetInnerHTML=="object"&&f.dangerouslySetInnerHTML!==null&&f.dangerouslySetInnerHTML.__html!=null}var of=typeof setTimeout=="function"?setTimeout:void 0,yy=typeof clearTimeout=="function"?clearTimeout:void 0,xA=typeof Promise=="function"?Promise:void 0,xy=typeof queueMicrotask=="function"?queueMicrotask:typeof xA<"u"?function(u){return xA.resolve(null).then(u).catch(vy)}:of;function vy(u){setTimeout(function(){throw u})}function lf(u,f){var v=f,E=0;do{var D=v.nextSibling;if(u.removeChild(v),D&&D.nodeType===8)if(v=D.data,v==="/$"){if(E===0){u.removeChild(D),Va(f);return}E--}else v!=="$"&&v!=="$?"&&v!=="$!"||E++;v=D}while(v);Va(f)}function da(u){for(;u!=null;u=u.nextSibling){var f=u.nodeType;if(f===1||f===3)break;if(f===8){if(f=u.data,f==="$"||f==="$!"||f==="$?")break;if(f==="/$")return null}}return u}function vA(u){u=u.previousSibling;for(var f=0;u;){if(u.nodeType===8){var v=u.data;if(v==="$"||v==="$!"||v==="$?"){if(f===0)return u;f--}else v==="/$"&&f++}u=u.previousSibling}return null}var nl=Math.random().toString(36).slice(2),qi="__reactFiber$"+nl,ic="__reactProps$"+nl,ws="__reactContainer$"+nl,cf="__reactEvents$"+nl,_y="__reactListeners$"+nl,by="__reactHandles$"+nl;function Xa(u){var f=u[qi];if(f)return f;for(var v=u.parentNode;v;){if(f=v[ws]||v[qi]){if(v=f.alternate,f.child!==null||v!==null&&v.child!==null)for(u=vA(u);u!==null;){if(v=u[qi])return v;u=vA(u)}return f}u=v,v=u.parentNode}return null}function sc(u){return u=u[qi]||u[ws],!u||u.tag!==5&&u.tag!==6&&u.tag!==13&&u.tag!==3?null:u}function rl(u){if(u.tag===5||u.tag===6)return u.stateNode;throw Error(t(33))}function zu(u){return u[ic]||null}var uf=[],il=-1;function ha(u){return{current:u}}function Pn(u){0>il||(u.current=uf[il],uf[il]=null,il--)}function Rn(u,f){il++,uf[il]=u.current,u.current=f}var fa={},br=ha(fa),Gr=ha(!1),Ja=fa;function sl(u,f){var v=u.type.contextTypes;if(!v)return fa;var E=u.stateNode;if(E&&E.__reactInternalMemoizedUnmaskedChildContext===f)return E.__reactInternalMemoizedMaskedChildContext;var D={},P;for(P in v)D[P]=f[P];return E&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=f,u.__reactInternalMemoizedMaskedChildContext=D),D}function Vr(u){return u=u.childContextTypes,u!=null}function Uu(){Pn(Gr),Pn(br)}function _A(u,f,v){if(br.current!==fa)throw Error(t(168));Rn(br,f),Rn(Gr,v)}function bA(u,f,v){var E=u.stateNode;if(f=f.childContextTypes,typeof E.getChildContext!="function")return v;E=E.getChildContext();for(var D in E)if(!(D in f))throw Error(t(108,fe(u)||"Unknown",D));return ne({},v,E)}function Ou(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||fa,Ja=br.current,Rn(br,u),Rn(Gr,Gr.current),!0}function ac(u,f,v){var E=u.stateNode;if(!E)throw Error(t(169));v?(u=bA(u,f,Ja),E.__reactInternalMemoizedMergedChildContext=u,Pn(Gr),Pn(br),Rn(br,u)):Pn(Gr),Rn(Gr,v)}var C=null,N=!1,O=!1;function z(u){C===null?C=[u]:C.push(u)}function se(u){N=!0,z(u)}function ue(){if(!O&&C!==null){O=!0;var u=0,f=Gt;try{var v=C;for(Gt=1;u<v.length;u++){var E=v[u];do E=E(!0);while(E!==null)}C=null,N=!1}catch(D){throw C!==null&&(C=C.slice(u+1)),vs(Me,ue),D}finally{Gt=f,O=!1}}return null}var Se=[],Ue=0,it=null,ht=0,Nt=[],Vt=0,on=null,ln=1,wr="";function Es(u,f){Se[Ue++]=ht,Se[Ue++]=it,it=u,ht=f}function wA(u,f,v){Nt[Vt++]=ln,Nt[Vt++]=wr,Nt[Vt++]=on,on=u;var E=ln;u=wr;var D=32-$t(E)-1;E&=~(1<<D),v+=1;var P=32-$t(f)+D;if(30<P){var te=D-D%5;P=(E&(1<<te)-1).toString(32),E>>=te,D-=te,ln=1<<32-$t(f)+D|v<<D|E,wr=P+u}else ln=1<<P|v<<D|E,wr=u}function oc(u){u.return!==null&&(Es(u,1),wA(u,1,0))}function wy(u){for(;u===it;)it=Se[--Ue],Se[Ue]=null,ht=Se[--Ue],Se[Ue]=null;for(;u===on;)on=Nt[--Vt],Nt[Vt]=null,wr=Nt[--Vt],Nt[Vt]=null,ln=Nt[--Vt],Nt[Vt]=null}var Pi=null,Li=null,Gn=!1,Is=null;function _C(u,f){var v=Ki(5,null,null,0);v.elementType="DELETED",v.stateNode=f,v.return=u,f=u.deletions,f===null?(u.deletions=[v],u.flags|=16):f.push(v)}function bC(u,f){switch(u.tag){case 5:var v=u.type;return f=f.nodeType!==1||v.toLowerCase()!==f.nodeName.toLowerCase()?null:f,f!==null?(u.stateNode=f,Pi=u,Li=da(f.firstChild),!0):!1;case 6:return f=u.pendingProps===""||f.nodeType!==3?null:f,f!==null?(u.stateNode=f,Pi=u,Li=null,!0):!1;case 13:return f=f.nodeType!==8?null:f,f!==null?(v=on!==null?{id:ln,overflow:wr}:null,u.memoizedState={dehydrated:f,treeContext:v,retryLane:1073741824},v=Ki(18,null,null,0),v.stateNode=f,v.return=u,u.child=v,Pi=u,Li=null,!0):!1;default:return!1}}function Ey(u){return(u.mode&1)!==0&&(u.flags&128)===0}function Iy(u){if(Gn){var f=Li;if(f){var v=f;if(!bC(u,f)){if(Ey(u))throw Error(t(418));f=da(v.nextSibling);var E=Pi;f&&bC(u,f)?_C(E,v):(u.flags=u.flags&-4097|2,Gn=!1,Pi=u)}}else{if(Ey(u))throw Error(t(418));u.flags=u.flags&-4097|2,Gn=!1,Pi=u}}}function wC(u){for(u=u.return;u!==null&&u.tag!==5&&u.tag!==3&&u.tag!==13;)u=u.return;Pi=u}function EA(u){if(u!==Pi)return!1;if(!Gn)return wC(u),Gn=!0,!1;var f;if((f=u.tag!==3)&&!(f=u.tag!==5)&&(f=u.type,f=f!=="head"&&f!=="body"&&!af(u.type,u.memoizedProps)),f&&(f=Li)){if(Ey(u))throw EC(),Error(t(418));for(;f;)_C(u,f),f=da(f.nextSibling)}if(wC(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(t(317));e:{for(u=u.nextSibling,f=0;u;){if(u.nodeType===8){var v=u.data;if(v==="/$"){if(f===0){Li=da(u.nextSibling);break e}f--}else v!=="$"&&v!=="$!"&&v!=="$?"||f++}u=u.nextSibling}Li=null}}else Li=Pi?da(u.stateNode.nextSibling):null;return!0}function EC(){for(var u=Li;u;)u=da(u.nextSibling)}function $u(){Li=Pi=null,Gn=!1}function Cy(u){Is===null?Is=[u]:Is.push(u)}var az=w.ReactCurrentBatchConfig;function df(u,f,v){if(u=v.ref,u!==null&&typeof u!="function"&&typeof u!="object"){if(v._owner){if(v=v._owner,v){if(v.tag!==1)throw Error(t(309));var E=v.stateNode}if(!E)throw Error(t(147,u));var D=E,P=""+u;return f!==null&&f.ref!==null&&typeof f.ref=="function"&&f.ref._stringRef===P?f.ref:(f=function(te){var pe=D.refs;te===null?delete pe[P]:pe[P]=te},f._stringRef=P,f)}if(typeof u!="string")throw Error(t(284));if(!v._owner)throw Error(t(290,u))}return u}function IA(u,f){throw u=Object.prototype.toString.call(f),Error(t(31,u==="[object Object]"?"object with keys {"+Object.keys(f).join(", ")+"}":u))}function IC(u){var f=u._init;return f(u._payload)}function CC(u){function f(ke,Be){if(u){var Qe=ke.deletions;Qe===null?(ke.deletions=[Be],ke.flags|=16):Qe.push(Be)}}function v(ke,Be){if(!u)return null;for(;Be!==null;)f(ke,Be),Be=Be.sibling;return null}function E(ke,Be){for(ke=new Map;Be!==null;)Be.key!==null?ke.set(Be.key,Be):ke.set(Be.index,Be),Be=Be.sibling;return ke}function D(ke,Be){return ke=fl(ke,Be),ke.index=0,ke.sibling=null,ke}function P(ke,Be,Qe){return ke.index=Qe,u?(Qe=ke.alternate,Qe!==null?(Qe=Qe.index,Qe<Be?(ke.flags|=2,Be):Qe):(ke.flags|=2,Be)):(ke.flags|=1048576,Be)}function te(ke){return u&&ke.alternate===null&&(ke.flags|=2),ke}function pe(ke,Be,Qe,ot){return Be===null||Be.tag!==6?(Be=mx(Qe,ke.mode,ot),Be.return=ke,Be):(Be=D(Be,Qe),Be.return=ke,Be)}function we(ke,Be,Qe,ot){var Bt=Qe.type;return Bt===M?Xe(ke,Be,Qe.props.children,ot,Qe.key):Be!==null&&(Be.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===K&&IC(Bt)===Be.type)?(ot=D(Be,Qe.props),ot.ref=df(ke,Be,Qe),ot.return=ke,ot):(ot=YA(Qe.type,Qe.key,Qe.props,null,ke.mode,ot),ot.ref=df(ke,Be,Qe),ot.return=ke,ot)}function Pe(ke,Be,Qe,ot){return Be===null||Be.tag!==4||Be.stateNode.containerInfo!==Qe.containerInfo||Be.stateNode.implementation!==Qe.implementation?(Be=gx(Qe,ke.mode,ot),Be.return=ke,Be):(Be=D(Be,Qe.children||[]),Be.return=ke,Be)}function Xe(ke,Be,Qe,ot,Bt){return Be===null||Be.tag!==7?(Be=Ac(Qe,ke.mode,ot,Bt),Be.return=ke,Be):(Be=D(Be,Qe),Be.return=ke,Be)}function rt(ke,Be,Qe){if(typeof Be=="string"&&Be!==""||typeof Be=="number")return Be=mx(""+Be,ke.mode,Qe),Be.return=ke,Be;if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case I:return Qe=YA(Be.type,Be.key,Be.props,null,ke.mode,Qe),Qe.ref=df(ke,null,Be),Qe.return=ke,Qe;case S:return Be=gx(Be,ke.mode,Qe),Be.return=ke,Be;case K:var ot=Be._init;return rt(ke,ot(Be._payload),Qe)}if(be(Be)||J(Be))return Be=Ac(Be,ke.mode,Qe,null),Be.return=ke,Be;IA(ke,Be)}return null}function qe(ke,Be,Qe,ot){var Bt=Be!==null?Be.key:null;if(typeof Qe=="string"&&Qe!==""||typeof Qe=="number")return Bt!==null?null:pe(ke,Be,""+Qe,ot);if(typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case I:return Qe.key===Bt?we(ke,Be,Qe,ot):null;case S:return Qe.key===Bt?Pe(ke,Be,Qe,ot):null;case K:return Bt=Qe._init,qe(ke,Be,Bt(Qe._payload),ot)}if(be(Qe)||J(Qe))return Bt!==null?null:Xe(ke,Be,Qe,ot,null);IA(ke,Qe)}return null}function yt(ke,Be,Qe,ot,Bt){if(typeof ot=="string"&&ot!==""||typeof ot=="number")return ke=ke.get(Qe)||null,pe(Be,ke,""+ot,Bt);if(typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case I:return ke=ke.get(ot.key===null?Qe:ot.key)||null,we(Be,ke,ot,Bt);case S:return ke=ke.get(ot.key===null?Qe:ot.key)||null,Pe(Be,ke,ot,Bt);case K:var zt=ot._init;return yt(ke,Be,Qe,zt(ot._payload),Bt)}if(be(ot)||J(ot))return ke=ke.get(Qe)||null,Xe(Be,ke,ot,Bt,null);IA(Be,ot)}return null}function Et(ke,Be,Qe,ot){for(var Bt=null,zt=null,Ut=Be,Ht=Be=0,Cr=null;Ut!==null&&Ht<Qe.length;Ht++){Ut.index>Ht?(Cr=Ut,Ut=null):Cr=Ut.sibling;var _n=qe(ke,Ut,Qe[Ht],ot);if(_n===null){Ut===null&&(Ut=Cr);break}u&&Ut&&_n.alternate===null&&f(ke,Ut),Be=P(_n,Be,Ht),zt===null?Bt=_n:zt.sibling=_n,zt=_n,Ut=Cr}if(Ht===Qe.length)return v(ke,Ut),Gn&&Es(ke,Ht),Bt;if(Ut===null){for(;Ht<Qe.length;Ht++)Ut=rt(ke,Qe[Ht],ot),Ut!==null&&(Be=P(Ut,Be,Ht),zt===null?Bt=Ut:zt.sibling=Ut,zt=Ut);return Gn&&Es(ke,Ht),Bt}for(Ut=E(ke,Ut);Ht<Qe.length;Ht++)Cr=yt(Ut,ke,Ht,Qe[Ht],ot),Cr!==null&&(u&&Cr.alternate!==null&&Ut.delete(Cr.key===null?Ht:Cr.key),Be=P(Cr,Be,Ht),zt===null?Bt=Cr:zt.sibling=Cr,zt=Cr);return u&&Ut.forEach(function(pl){return f(ke,pl)}),Gn&&Es(ke,Ht),Bt}function Ct(ke,Be,Qe,ot){var Bt=J(Qe);if(typeof Bt!="function")throw Error(t(150));if(Qe=Bt.call(Qe),Qe==null)throw Error(t(151));for(var zt=Bt=null,Ut=Be,Ht=Be=0,Cr=null,_n=Qe.next();Ut!==null&&!_n.done;Ht++,_n=Qe.next()){Ut.index>Ht?(Cr=Ut,Ut=null):Cr=Ut.sibling;var pl=qe(ke,Ut,_n.value,ot);if(pl===null){Ut===null&&(Ut=Cr);break}u&&Ut&&pl.alternate===null&&f(ke,Ut),Be=P(pl,Be,Ht),zt===null?Bt=pl:zt.sibling=pl,zt=pl,Ut=Cr}if(_n.done)return v(ke,Ut),Gn&&Es(ke,Ht),Bt;if(Ut===null){for(;!_n.done;Ht++,_n=Qe.next())_n=rt(ke,_n.value,ot),_n!==null&&(Be=P(_n,Be,Ht),zt===null?Bt=_n:zt.sibling=_n,zt=_n);return Gn&&Es(ke,Ht),Bt}for(Ut=E(ke,Ut);!_n.done;Ht++,_n=Qe.next())_n=yt(Ut,ke,Ht,_n.value,ot),_n!==null&&(u&&_n.alternate!==null&&Ut.delete(_n.key===null?Ht:_n.key),Be=P(_n,Be,Ht),zt===null?Bt=_n:zt.sibling=_n,zt=_n);return u&&Ut.forEach(function(zz){return f(ke,zz)}),Gn&&Es(ke,Ht),Bt}function Zn(ke,Be,Qe,ot){if(typeof Qe=="object"&&Qe!==null&&Qe.type===M&&Qe.key===null&&(Qe=Qe.props.children),typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case I:e:{for(var Bt=Qe.key,zt=Be;zt!==null;){if(zt.key===Bt){if(Bt=Qe.type,Bt===M){if(zt.tag===7){v(ke,zt.sibling),Be=D(zt,Qe.props.children),Be.return=ke,ke=Be;break e}}else if(zt.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===K&&IC(Bt)===zt.type){v(ke,zt.sibling),Be=D(zt,Qe.props),Be.ref=df(ke,zt,Qe),Be.return=ke,ke=Be;break e}v(ke,zt);break}else f(ke,zt);zt=zt.sibling}Qe.type===M?(Be=Ac(Qe.props.children,ke.mode,ot,Qe.key),Be.return=ke,ke=Be):(ot=YA(Qe.type,Qe.key,Qe.props,null,ke.mode,ot),ot.ref=df(ke,Be,Qe),ot.return=ke,ke=ot)}return te(ke);case S:e:{for(zt=Qe.key;Be!==null;){if(Be.key===zt)if(Be.tag===4&&Be.stateNode.containerInfo===Qe.containerInfo&&Be.stateNode.implementation===Qe.implementation){v(ke,Be.sibling),Be=D(Be,Qe.children||[]),Be.return=ke,ke=Be;break e}else{v(ke,Be);break}else f(ke,Be);Be=Be.sibling}Be=gx(Qe,ke.mode,ot),Be.return=ke,ke=Be}return te(ke);case K:return zt=Qe._init,Zn(ke,Be,zt(Qe._payload),ot)}if(be(Qe))return Et(ke,Be,Qe,ot);if(J(Qe))return Ct(ke,Be,Qe,ot);IA(ke,Qe)}return typeof Qe=="string"&&Qe!==""||typeof Qe=="number"?(Qe=""+Qe,Be!==null&&Be.tag===6?(v(ke,Be.sibling),Be=D(Be,Qe),Be.return=ke,ke=Be):(v(ke,Be),Be=mx(Qe,ke.mode,ot),Be.return=ke,ke=Be),te(ke)):v(ke,Be)}return Zn}var Gu=CC(!0),SC=CC(!1),CA=ha(null),SA=null,Vu=null,Sy=null;function By(){Sy=Vu=SA=null}function My(u){var f=CA.current;Pn(CA),u._currentValue=f}function Ty(u,f,v){for(;u!==null;){var E=u.alternate;if((u.childLanes&f)!==f?(u.childLanes|=f,E!==null&&(E.childLanes|=f)):E!==null&&(E.childLanes&f)!==f&&(E.childLanes|=f),u===v)break;u=u.return}}function Hu(u,f){SA=u,Sy=Vu=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&f)!==0&&(_i=!0),u.firstContext=null)}function Yi(u){var f=u._currentValue;if(Sy!==u)if(u={context:u,memoizedValue:f,next:null},Vu===null){if(SA===null)throw Error(t(308));Vu=u,SA.dependencies={lanes:0,firstContext:u}}else Vu=Vu.next=u;return f}var lc=null;function Ry(u){lc===null?lc=[u]:lc.push(u)}function BC(u,f,v,E){var D=f.interleaved;return D===null?(v.next=v,Ry(f)):(v.next=D.next,D.next=v),f.interleaved=v,Ka(u,E)}function Ka(u,f){u.lanes|=f;var v=u.alternate;for(v!==null&&(v.lanes|=f),v=u,u=u.return;u!==null;)u.childLanes|=f,v=u.alternate,v!==null&&(v.childLanes|=f),v=u,u=u.return;return v.tag===3?v.stateNode:null}var al=!1;function Dy(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function MC(u,f){u=u.updateQueue,f.updateQueue===u&&(f.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function Za(u,f){return{eventTime:u,lane:f,tag:0,payload:null,callback:null,next:null}}function ol(u,f,v){var E=u.updateQueue;if(E===null)return null;if(E=E.shared,(An&2)!==0){var D=E.pending;return D===null?f.next=f:(f.next=D.next,D.next=f),E.pending=f,Ka(u,v)}return D=E.interleaved,D===null?(f.next=f,Ry(E)):(f.next=D.next,D.next=f),E.interleaved=f,Ka(u,v)}function BA(u,f,v){if(f=f.updateQueue,f!==null&&(f=f.shared,(v&4194240)!==0)){var E=f.lanes;E&=u.pendingLanes,v|=E,f.lanes=v,Kn(u,v)}}function TC(u,f){var v=u.updateQueue,E=u.alternate;if(E!==null&&(E=E.updateQueue,v===E)){var D=null,P=null;if(v=v.firstBaseUpdate,v!==null){do{var te={eventTime:v.eventTime,lane:v.lane,tag:v.tag,payload:v.payload,callback:v.callback,next:null};P===null?D=P=te:P=P.next=te,v=v.next}while(v!==null);P===null?D=P=f:P=P.next=f}else D=P=f;v={baseState:E.baseState,firstBaseUpdate:D,lastBaseUpdate:P,shared:E.shared,effects:E.effects},u.updateQueue=v;return}u=v.lastBaseUpdate,u===null?v.firstBaseUpdate=f:u.next=f,v.lastBaseUpdate=f}function MA(u,f,v,E){var D=u.updateQueue;al=!1;var P=D.firstBaseUpdate,te=D.lastBaseUpdate,pe=D.shared.pending;if(pe!==null){D.shared.pending=null;var we=pe,Pe=we.next;we.next=null,te===null?P=Pe:te.next=Pe,te=we;var Xe=u.alternate;Xe!==null&&(Xe=Xe.updateQueue,pe=Xe.lastBaseUpdate,pe!==te&&(pe===null?Xe.firstBaseUpdate=Pe:pe.next=Pe,Xe.lastBaseUpdate=we))}if(P!==null){var rt=D.baseState;te=0,Xe=Pe=we=null,pe=P;do{var qe=pe.lane,yt=pe.eventTime;if((E&qe)===qe){Xe!==null&&(Xe=Xe.next={eventTime:yt,lane:0,tag:pe.tag,payload:pe.payload,callback:pe.callback,next:null});e:{var Et=u,Ct=pe;switch(qe=f,yt=v,Ct.tag){case 1:if(Et=Ct.payload,typeof Et=="function"){rt=Et.call(yt,rt,qe);break e}rt=Et;break e;case 3:Et.flags=Et.flags&-65537|128;case 0:if(Et=Ct.payload,qe=typeof Et=="function"?Et.call(yt,rt,qe):Et,qe==null)break e;rt=ne({},rt,qe);break e;case 2:al=!0}}pe.callback!==null&&pe.lane!==0&&(u.flags|=64,qe=D.effects,qe===null?D.effects=[pe]:qe.push(pe))}else yt={eventTime:yt,lane:qe,tag:pe.tag,payload:pe.payload,callback:pe.callback,next:null},Xe===null?(Pe=Xe=yt,we=rt):Xe=Xe.next=yt,te|=qe;if(pe=pe.next,pe===null){if(pe=D.shared.pending,pe===null)break;qe=pe,pe=qe.next,qe.next=null,D.lastBaseUpdate=qe,D.shared.pending=null}}while(!0);if(Xe===null&&(we=rt),D.baseState=we,D.firstBaseUpdate=Pe,D.lastBaseUpdate=Xe,f=D.shared.interleaved,f!==null){D=f;do te|=D.lane,D=D.next;while(D!==f)}else P===null&&(D.shared.lanes=0);dc|=te,u.lanes=te,u.memoizedState=rt}}function RC(u,f,v){if(u=f.effects,f.effects=null,u!==null)for(f=0;f<u.length;f++){var E=u[f],D=E.callback;if(D!==null){if(E.callback=null,E=v,typeof D!="function")throw Error(t(191,D));D.call(E)}}}var hf={},pa=ha(hf),ff=ha(hf),pf=ha(hf);function cc(u){if(u===hf)throw Error(t(174));return u}function ky(u,f){switch(Rn(pf,f),Rn(ff,u),Rn(pa,hf),u=f.nodeType,u){case 9:case 11:f=(f=f.documentElement)?f.namespaceURI:me(null,"");break;default:u=u===8?f.parentNode:f,f=u.namespaceURI||null,u=u.tagName,f=me(f,u)}Pn(pa),Rn(pa,f)}function ju(){Pn(pa),Pn(ff),Pn(pf)}function DC(u){cc(pf.current);var f=cc(pa.current),v=me(f,u.type);f!==v&&(Rn(ff,u),Rn(pa,v))}function Ny(u){ff.current===u&&(Pn(pa),Pn(ff))}var Hn=ha(0);function TA(u){for(var f=u;f!==null;){if(f.tag===13){var v=f.memoizedState;if(v!==null&&(v=v.dehydrated,v===null||v.data==="$?"||v.data==="$!"))return f}else if(f.tag===19&&f.memoizedProps.revealOrder!==void 0){if((f.flags&128)!==0)return f}else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return null;f=f.return}f.sibling.return=f.return,f=f.sibling}return null}var Qy=[];function Py(){for(var u=0;u<Qy.length;u++)Qy[u]._workInProgressVersionPrimary=null;Qy.length=0}var RA=w.ReactCurrentDispatcher,Ly=w.ReactCurrentBatchConfig,uc=0,jn=null,ur=null,Er=null,DA=!1,Af=!1,mf=0,oz=0;function Hr(){throw Error(t(321))}function Fy(u,f){if(f===null)return!1;for(var v=0;v<f.length&&v<u.length;v++)if(!vi(u[v],f[v]))return!1;return!0}function zy(u,f,v,E,D,P){if(uc=P,jn=f,f.memoizedState=null,f.updateQueue=null,f.lanes=0,RA.current=u===null||u.memoizedState===null?dz:hz,u=v(E,D),Af){P=0;do{if(Af=!1,mf=0,25<=P)throw Error(t(301));P+=1,Er=ur=null,f.updateQueue=null,RA.current=fz,u=v(E,D)}while(Af)}if(RA.current=QA,f=ur!==null&&ur.next!==null,uc=0,Er=ur=jn=null,DA=!1,f)throw Error(t(300));return u}function Uy(){var u=mf!==0;return mf=0,u}function Aa(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Er===null?jn.memoizedState=Er=u:Er=Er.next=u,Er}function Xi(){if(ur===null){var u=jn.alternate;u=u!==null?u.memoizedState:null}else u=ur.next;var f=Er===null?jn.memoizedState:Er.next;if(f!==null)Er=f,ur=u;else{if(u===null)throw Error(t(310));ur=u,u={memoizedState:ur.memoizedState,baseState:ur.baseState,baseQueue:ur.baseQueue,queue:ur.queue,next:null},Er===null?jn.memoizedState=Er=u:Er=Er.next=u}return Er}function gf(u,f){return typeof f=="function"?f(u):f}function Oy(u){var f=Xi(),v=f.queue;if(v===null)throw Error(t(311));v.lastRenderedReducer=u;var E=ur,D=E.baseQueue,P=v.pending;if(P!==null){if(D!==null){var te=D.next;D.next=P.next,P.next=te}E.baseQueue=D=P,v.pending=null}if(D!==null){P=D.next,E=E.baseState;var pe=te=null,we=null,Pe=P;do{var Xe=Pe.lane;if((uc&Xe)===Xe)we!==null&&(we=we.next={lane:0,action:Pe.action,hasEagerState:Pe.hasEagerState,eagerState:Pe.eagerState,next:null}),E=Pe.hasEagerState?Pe.eagerState:u(E,Pe.action);else{var rt={lane:Xe,action:Pe.action,hasEagerState:Pe.hasEagerState,eagerState:Pe.eagerState,next:null};we===null?(pe=we=rt,te=E):we=we.next=rt,jn.lanes|=Xe,dc|=Xe}Pe=Pe.next}while(Pe!==null&&Pe!==P);we===null?te=E:we.next=pe,vi(E,f.memoizedState)||(_i=!0),f.memoizedState=E,f.baseState=te,f.baseQueue=we,v.lastRenderedState=E}if(u=v.interleaved,u!==null){D=u;do P=D.lane,jn.lanes|=P,dc|=P,D=D.next;while(D!==u)}else D===null&&(v.lanes=0);return[f.memoizedState,v.dispatch]}function $y(u){var f=Xi(),v=f.queue;if(v===null)throw Error(t(311));v.lastRenderedReducer=u;var E=v.dispatch,D=v.pending,P=f.memoizedState;if(D!==null){v.pending=null;var te=D=D.next;do P=u(P,te.action),te=te.next;while(te!==D);vi(P,f.memoizedState)||(_i=!0),f.memoizedState=P,f.baseQueue===null&&(f.baseState=P),v.lastRenderedState=P}return[P,E]}function kC(){}function NC(u,f){var v=jn,E=Xi(),D=f(),P=!vi(E.memoizedState,D);if(P&&(E.memoizedState=D,_i=!0),E=E.queue,Gy(LC.bind(null,v,E,u),[u]),E.getSnapshot!==f||P||Er!==null&&Er.memoizedState.tag&1){if(v.flags|=2048,yf(9,PC.bind(null,v,E,D,f),void 0,null),Ir===null)throw Error(t(349));(uc&30)!==0||QC(v,f,D)}return D}function QC(u,f,v){u.flags|=16384,u={getSnapshot:f,value:v},f=jn.updateQueue,f===null?(f={lastEffect:null,stores:null},jn.updateQueue=f,f.stores=[u]):(v=f.stores,v===null?f.stores=[u]:v.push(u))}function PC(u,f,v,E){f.value=v,f.getSnapshot=E,FC(f)&&zC(u)}function LC(u,f,v){return v(function(){FC(f)&&zC(u)})}function FC(u){var f=u.getSnapshot;u=u.value;try{var v=f();return!vi(u,v)}catch{return!0}}function zC(u){var f=Ka(u,1);f!==null&&Ms(f,u,1,-1)}function UC(u){var f=Aa();return typeof u=="function"&&(u=u()),f.memoizedState=f.baseState=u,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:gf,lastRenderedState:u},f.queue=u,u=u.dispatch=uz.bind(null,jn,u),[f.memoizedState,u]}function yf(u,f,v,E){return u={tag:u,create:f,destroy:v,deps:E,next:null},f=jn.updateQueue,f===null?(f={lastEffect:null,stores:null},jn.updateQueue=f,f.lastEffect=u.next=u):(v=f.lastEffect,v===null?f.lastEffect=u.next=u:(E=v.next,v.next=u,u.next=E,f.lastEffect=u)),u}function OC(){return Xi().memoizedState}function kA(u,f,v,E){var D=Aa();jn.flags|=u,D.memoizedState=yf(1|f,v,void 0,E===void 0?null:E)}function NA(u,f,v,E){var D=Xi();E=E===void 0?null:E;var P=void 0;if(ur!==null){var te=ur.memoizedState;if(P=te.destroy,E!==null&&Fy(E,te.deps)){D.memoizedState=yf(f,v,P,E);return}}jn.flags|=u,D.memoizedState=yf(1|f,v,P,E)}function $C(u,f){return kA(8390656,8,u,f)}function Gy(u,f){return NA(2048,8,u,f)}function GC(u,f){return NA(4,2,u,f)}function VC(u,f){return NA(4,4,u,f)}function HC(u,f){if(typeof f=="function")return u=u(),f(u),function(){f(null)};if(f!=null)return u=u(),f.current=u,function(){f.current=null}}function jC(u,f,v){return v=v!=null?v.concat([u]):null,NA(4,4,HC.bind(null,f,u),v)}function Vy(){}function WC(u,f){var v=Xi();f=f===void 0?null:f;var E=v.memoizedState;return E!==null&&f!==null&&Fy(f,E[1])?E[0]:(v.memoizedState=[u,f],u)}function qC(u,f){var v=Xi();f=f===void 0?null:f;var E=v.memoizedState;return E!==null&&f!==null&&Fy(f,E[1])?E[0]:(u=u(),v.memoizedState=[u,f],u)}function YC(u,f,v){return(uc&21)===0?(u.baseState&&(u.baseState=!1,_i=!0),u.memoizedState=v):(vi(v,f)||(v=oa(),jn.lanes|=v,dc|=v,u.baseState=!0),f)}function lz(u,f){var v=Gt;Gt=v!==0&&4>v?v:4,u(!0);var E=Ly.transition;Ly.transition={};try{u(!1),f()}finally{Gt=v,Ly.transition=E}}function XC(){return Xi().memoizedState}function cz(u,f,v){var E=dl(u);if(v={lane:E,action:v,hasEagerState:!1,eagerState:null,next:null},JC(u))KC(f,v);else if(v=BC(u,f,v,E),v!==null){var D=ai();Ms(v,u,E,D),ZC(v,f,E)}}function uz(u,f,v){var E=dl(u),D={lane:E,action:v,hasEagerState:!1,eagerState:null,next:null};if(JC(u))KC(f,D);else{var P=u.alternate;if(u.lanes===0&&(P===null||P.lanes===0)&&(P=f.lastRenderedReducer,P!==null))try{var te=f.lastRenderedState,pe=P(te,v);if(D.hasEagerState=!0,D.eagerState=pe,vi(pe,te)){var we=f.interleaved;we===null?(D.next=D,Ry(f)):(D.next=we.next,we.next=D),f.interleaved=D;return}}catch{}v=BC(u,f,D,E),v!==null&&(D=ai(),Ms(v,u,E,D),ZC(v,f,E))}}function JC(u){var f=u.alternate;return u===jn||f!==null&&f===jn}function KC(u,f){Af=DA=!0;var v=u.pending;v===null?f.next=f:(f.next=v.next,v.next=f),u.pending=f}function ZC(u,f,v){if((v&4194240)!==0){var E=f.lanes;E&=u.pendingLanes,v|=E,f.lanes=v,Kn(u,v)}}var QA={readContext:Yi,useCallback:Hr,useContext:Hr,useEffect:Hr,useImperativeHandle:Hr,useInsertionEffect:Hr,useLayoutEffect:Hr,useMemo:Hr,useReducer:Hr,useRef:Hr,useState:Hr,useDebugValue:Hr,useDeferredValue:Hr,useTransition:Hr,useMutableSource:Hr,useSyncExternalStore:Hr,useId:Hr,unstable_isNewReconciler:!1},dz={readContext:Yi,useCallback:function(u,f){return Aa().memoizedState=[u,f===void 0?null:f],u},useContext:Yi,useEffect:$C,useImperativeHandle:function(u,f,v){return v=v!=null?v.concat([u]):null,kA(4194308,4,HC.bind(null,f,u),v)},useLayoutEffect:function(u,f){return kA(4194308,4,u,f)},useInsertionEffect:function(u,f){return kA(4,2,u,f)},useMemo:function(u,f){var v=Aa();return f=f===void 0?null:f,u=u(),v.memoizedState=[u,f],u},useReducer:function(u,f,v){var E=Aa();return f=v!==void 0?v(f):f,E.memoizedState=E.baseState=f,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:f},E.queue=u,u=u.dispatch=cz.bind(null,jn,u),[E.memoizedState,u]},useRef:function(u){var f=Aa();return u={current:u},f.memoizedState=u},useState:UC,useDebugValue:Vy,useDeferredValue:function(u){return Aa().memoizedState=u},useTransition:function(){var u=UC(!1),f=u[0];return u=lz.bind(null,u[1]),Aa().memoizedState=u,[f,u]},useMutableSource:function(){},useSyncExternalStore:function(u,f,v){var E=jn,D=Aa();if(Gn){if(v===void 0)throw Error(t(407));v=v()}else{if(v=f(),Ir===null)throw Error(t(349));(uc&30)!==0||QC(E,f,v)}D.memoizedState=v;var P={value:v,getSnapshot:f};return D.queue=P,$C(LC.bind(null,E,P,u),[u]),E.flags|=2048,yf(9,PC.bind(null,E,P,v,f),void 0,null),v},useId:function(){var u=Aa(),f=Ir.identifierPrefix;if(Gn){var v=wr,E=ln;v=(E&~(1<<32-$t(E)-1)).toString(32)+v,f=":"+f+"R"+v,v=mf++,0<v&&(f+="H"+v.toString(32)),f+=":"}else v=oz++,f=":"+f+"r"+v.toString(32)+":";return u.memoizedState=f},unstable_isNewReconciler:!1},hz={readContext:Yi,useCallback:WC,useContext:Yi,useEffect:Gy,useImperativeHandle:jC,useInsertionEffect:GC,useLayoutEffect:VC,useMemo:qC,useReducer:Oy,useRef:OC,useState:function(){return Oy(gf)},useDebugValue:Vy,useDeferredValue:function(u){var f=Xi();return YC(f,ur.memoizedState,u)},useTransition:function(){var u=Oy(gf)[0],f=Xi().memoizedState;return[u,f]},useMutableSource:kC,useSyncExternalStore:NC,useId:XC,unstable_isNewReconciler:!1},fz={readContext:Yi,useCallback:WC,useContext:Yi,useEffect:Gy,useImperativeHandle:jC,useInsertionEffect:GC,useLayoutEffect:VC,useMemo:qC,useReducer:$y,useRef:OC,useState:function(){return $y(gf)},useDebugValue:Vy,useDeferredValue:function(u){var f=Xi();return ur===null?f.memoizedState=u:YC(f,ur.memoizedState,u)},useTransition:function(){var u=$y(gf)[0],f=Xi().memoizedState;return[u,f]},useMutableSource:kC,useSyncExternalStore:NC,useId:XC,unstable_isNewReconciler:!1};function Cs(u,f){if(u&&u.defaultProps){f=ne({},f),u=u.defaultProps;for(var v in u)f[v]===void 0&&(f[v]=u[v]);return f}return f}function Hy(u,f,v,E){f=u.memoizedState,v=v(E,f),v=v==null?f:ne({},f,v),u.memoizedState=v,u.lanes===0&&(u.updateQueue.baseState=v)}var PA={isMounted:function(u){return(u=u._reactInternals)?ki(u)===u:!1},enqueueSetState:function(u,f,v){u=u._reactInternals;var E=ai(),D=dl(u),P=Za(E,D);P.payload=f,v!=null&&(P.callback=v),f=ol(u,P,D),f!==null&&(Ms(f,u,D,E),BA(f,u,D))},enqueueReplaceState:function(u,f,v){u=u._reactInternals;var E=ai(),D=dl(u),P=Za(E,D);P.tag=1,P.payload=f,v!=null&&(P.callback=v),f=ol(u,P,D),f!==null&&(Ms(f,u,D,E),BA(f,u,D))},enqueueForceUpdate:function(u,f){u=u._reactInternals;var v=ai(),E=dl(u),D=Za(v,E);D.tag=2,f!=null&&(D.callback=f),f=ol(u,D,E),f!==null&&(Ms(f,u,E,v),BA(f,u,E))}};function e1(u,f,v,E,D,P,te){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(E,P,te):f.prototype&&f.prototype.isPureReactComponent?!Jo(v,E)||!Jo(D,P):!0}function t1(u,f,v){var E=!1,D=fa,P=f.contextType;return typeof P=="object"&&P!==null?P=Yi(P):(D=Vr(f)?Ja:br.current,E=f.contextTypes,P=(E=E!=null)?sl(u,D):fa),f=new f(v,P),u.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=PA,u.stateNode=f,f._reactInternals=u,E&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=D,u.__reactInternalMemoizedMaskedChildContext=P),f}function n1(u,f,v,E){u=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(v,E),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(v,E),f.state!==u&&PA.enqueueReplaceState(f,f.state,null)}function jy(u,f,v,E){var D=u.stateNode;D.props=v,D.state=u.memoizedState,D.refs={},Dy(u);var P=f.contextType;typeof P=="object"&&P!==null?D.context=Yi(P):(P=Vr(f)?Ja:br.current,D.context=sl(u,P)),D.state=u.memoizedState,P=f.getDerivedStateFromProps,typeof P=="function"&&(Hy(u,f,P,v),D.state=u.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(f=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),f!==D.state&&PA.enqueueReplaceState(D,D.state,null),MA(u,v,D,E),D.state=u.memoizedState),typeof D.componentDidMount=="function"&&(u.flags|=4194308)}function Wu(u,f){try{var v="",E=f;do v+=ye(E),E=E.return;while(E);var D=v}catch(P){D=`
|
|
7
7
|
Error generating stack: `+P.message+`
|
|
8
|
-
`+P.stack}return{value:u,source:f,stack:D,digest:null}}function Wy(u,f,v){return{value:u,source:null,stack:v??null,digest:f??null}}function Vne(u,f){}var pz=typeof WeakMap=="function"?WeakMap:Map;function r1(u,f,v){v=Za(-1,v),v.tag=3,v.payload={element:null};var E=f.value;return v.callback=function(){GA||(GA=!0,lx=E)},v}function i1(u,f,v){v=Za(-1,v),v.tag=3;var E=u.type.getDerivedStateFromError;if(typeof E=="function"){var D=f.value;v.payload=function(){return E(D)},v.callback=function(){}}var P=u.stateNode;return P!==null&&typeof P.componentDidCatch=="function"&&(v.callback=function(){typeof E!="function"&&(cl===null?cl=new Set([this]):cl.add(this));var te=f.stack;this.componentDidCatch(f.value,{componentStack:te!==null?te:""})}),v}function s1(u,f,v){var E=u.pingCache;if(E===null){E=u.pingCache=new pz;var D=new Set;E.set(f,D)}else D=E.get(f),D===void 0&&(D=new Set,E.set(f,D));D.has(v)||(D.add(v),u=Bz.bind(null,u,f,v),f.then(u,u))}function a1(u){do{var f;if((f=u.tag===13)&&(f=u.memoizedState,f=f!==null?f.dehydrated!==null:!0),f)return u;u=u.return}while(u!==null);return null}function o1(u,f,v,E,D){return(u.mode&1)===0?(u===f?u.flags|=65536:(u.flags|=128,v.flags|=131072,v.flags&=-52805,v.tag===1&&(v.alternate===null?v.tag=17:(f=Za(-1,1),f.tag=2,ol(v,f,1))),v.lanes|=1),u):(u.flags|=65536,u.lanes=D,u)}var Az=w.ReactCurrentOwner,_i=!1;function si(u,f,v,E){f.child=u===null?SC(f,null,v,E):Gu(f,u.child,v,E)}function l1(u,f,v,E,D){v=v.render;var P=f.ref;return Hu(f,D),E=zy(u,f,v,E,P,D),v=Uy(),u!==null&&!_i?(f.updateQueue=u.updateQueue,f.flags&=-2053,u.lanes&=~D,eo(u,f,D)):(Gn&&v&&oc(f),f.flags|=1,si(u,f,E,D),f.child)}function c1(u,f,v,E,D){if(u===null){var P=v.type;return typeof P=="function"&&!Ax(P)&&P.defaultProps===void 0&&v.compare===null&&v.defaultProps===void 0?(f.tag=15,f.type=P,u1(u,f,P,E,D)):(u=YA(v.type,null,E,f,f.mode,D),u.ref=f.ref,u.return=f,f.child=u)}if(P=u.child,(u.lanes&D)===0){var te=P.memoizedProps;if(v=v.compare,v=v!==null?v:Jo,v(te,E)&&u.ref===f.ref)return eo(u,f,D)}return f.flags|=1,u=fl(P,E),u.ref=f.ref,u.return=f,f.child=u}function u1(u,f,v,E,D){if(u!==null){var P=u.memoizedProps;if(Jo(P,E)&&u.ref===f.ref)if(_i=!1,f.pendingProps=E=P,(u.lanes&D)!==0)(u.flags&131072)!==0&&(_i=!0);else return f.lanes=u.lanes,eo(u,f,D)}return qy(u,f,v,E,D)}function d1(u,f,v){var E=f.pendingProps,D=E.children,P=u!==null?u.memoizedState:null;if(E.mode==="hidden")if((f.mode&1)===0)f.memoizedState={baseLanes:0,cachePool:null,transitions:null},Tn(Yu,Fi),Fi|=v;else{if((v&1073741824)===0)return u=P!==null?P.baseLanes|v:v,f.lanes=f.childLanes=1073741824,f.memoizedState={baseLanes:u,cachePool:null,transitions:null},f.updateQueue=null,Tn(Yu,Fi),Fi|=u,null;f.memoizedState={baseLanes:0,cachePool:null,transitions:null},E=P!==null?P.baseLanes:v,Tn(Yu,Fi),Fi|=E}else P!==null?(E=P.baseLanes|v,f.memoizedState=null):E=v,Tn(Yu,Fi),Fi|=E;return si(u,f,D,v),f.child}function h1(u,f){var v=f.ref;(u===null&&v!==null||u!==null&&u.ref!==v)&&(f.flags|=512,f.flags|=2097152)}function qy(u,f,v,E,D){var P=Vr(v)?Ja:br.current;return P=sl(f,P),Hu(f,D),v=zy(u,f,v,E,P,D),E=Uy(),u!==null&&!_i?(f.updateQueue=u.updateQueue,f.flags&=-2053,u.lanes&=~D,eo(u,f,D)):(Gn&&E&&oc(f),f.flags|=1,si(u,f,v,D),f.child)}function f1(u,f,v,E,D){if(Vr(v)){var P=!0;Ou(f)}else P=!1;if(Hu(f,D),f.stateNode===null)FA(u,f),t1(f,v,E),jy(f,v,E,D),E=!0;else if(u===null){var te=f.stateNode,pe=f.memoizedProps;te.props=pe;var we=te.context,Pe=v.contextType;typeof Pe=="object"&&Pe!==null?Pe=Yi(Pe):(Pe=Vr(v)?Ja:br.current,Pe=sl(f,Pe));var Xe=v.getDerivedStateFromProps,rt=typeof Xe=="function"||typeof te.getSnapshotBeforeUpdate=="function";rt||typeof te.UNSAFE_componentWillReceiveProps!="function"&&typeof te.componentWillReceiveProps!="function"||(pe!==E||we!==Pe)&&n1(f,te,E,Pe),al=!1;var qe=f.memoizedState;te.state=qe,MA(f,E,te,D),we=f.memoizedState,pe!==E||qe!==we||Gr.current||al?(typeof Xe=="function"&&(Hy(f,v,Xe,E),we=f.memoizedState),(pe=al||e1(f,v,pe,E,qe,we,Pe))?(rt||typeof te.UNSAFE_componentWillMount!="function"&&typeof te.componentWillMount!="function"||(typeof te.componentWillMount=="function"&&te.componentWillMount(),typeof te.UNSAFE_componentWillMount=="function"&&te.UNSAFE_componentWillMount()),typeof te.componentDidMount=="function"&&(f.flags|=4194308)):(typeof te.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=E,f.memoizedState=we),te.props=E,te.state=we,te.context=Pe,E=pe):(typeof te.componentDidMount=="function"&&(f.flags|=4194308),E=!1)}else{te=f.stateNode,MC(u,f),pe=f.memoizedProps,Pe=f.type===f.elementType?pe:Cs(f.type,pe),te.props=Pe,rt=f.pendingProps,qe=te.context,we=v.contextType,typeof we=="object"&&we!==null?we=Yi(we):(we=Vr(v)?Ja:br.current,we=sl(f,we));var yt=v.getDerivedStateFromProps;(Xe=typeof yt=="function"||typeof te.getSnapshotBeforeUpdate=="function")||typeof te.UNSAFE_componentWillReceiveProps!="function"&&typeof te.componentWillReceiveProps!="function"||(pe!==rt||qe!==we)&&n1(f,te,E,we),al=!1,qe=f.memoizedState,te.state=qe,MA(f,E,te,D);var Et=f.memoizedState;pe!==rt||qe!==Et||Gr.current||al?(typeof yt=="function"&&(Hy(f,v,yt,E),Et=f.memoizedState),(Pe=al||e1(f,v,Pe,E,qe,Et,we)||!1)?(Xe||typeof te.UNSAFE_componentWillUpdate!="function"&&typeof te.componentWillUpdate!="function"||(typeof te.componentWillUpdate=="function"&&te.componentWillUpdate(E,Et,we),typeof te.UNSAFE_componentWillUpdate=="function"&&te.UNSAFE_componentWillUpdate(E,Et,we)),typeof te.componentDidUpdate=="function"&&(f.flags|=4),typeof te.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof te.componentDidUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=4),typeof te.getSnapshotBeforeUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=1024),f.memoizedProps=E,f.memoizedState=Et),te.props=E,te.state=Et,te.context=we,E=Pe):(typeof te.componentDidUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=4),typeof te.getSnapshotBeforeUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=1024),E=!1)}return Yy(u,f,v,E,P,D)}function Yy(u,f,v,E,D,P){h1(u,f);var te=(f.flags&128)!==0;if(!E&&!te)return D&&ac(f,v,!1),eo(u,f,P);E=f.stateNode,Az.current=f;var pe=te&&typeof v.getDerivedStateFromError!="function"?null:E.render();return f.flags|=1,u!==null&&te?(f.child=Gu(f,u.child,null,P),f.child=Gu(f,null,pe,P)):si(u,f,pe,P),f.memoizedState=E.state,D&&ac(f,v,!0),f.child}function p1(u){var f=u.stateNode;f.pendingContext?_A(u,f.pendingContext,f.pendingContext!==f.context):f.context&&_A(u,f.context,!1),ky(u,f.containerInfo)}function A1(u,f,v,E,D){return $u(),Cy(D),f.flags|=256,si(u,f,v,E),f.child}var Xy={dehydrated:null,treeContext:null,retryLane:0};function Jy(u){return{baseLanes:u,cachePool:null,transitions:null}}function m1(u,f,v){var E=f.pendingProps,D=Hn.current,P=!1,te=(f.flags&128)!==0,pe;if((pe=te)||(pe=u!==null&&u.memoizedState===null?!1:(D&2)!==0),pe?(P=!0,f.flags&=-129):(u===null||u.memoizedState!==null)&&(D|=1),Tn(Hn,D&1),u===null)return Iy(f),u=f.memoizedState,u!==null&&(u=u.dehydrated,u!==null)?((f.mode&1)===0?f.lanes=1:u.data==="$!"?f.lanes=8:f.lanes=1073741824,null):(te=E.children,u=E.fallback,P?(E=f.mode,P=f.child,te={mode:"hidden",children:te},(E&1)===0&&P!==null?(P.childLanes=0,P.pendingProps=te):P=XA(te,E,0,null),u=Ac(u,E,v,null),P.return=f,u.return=f,P.sibling=u,f.child=P,f.child.memoizedState=Jy(v),f.memoizedState=Xy,u):Ky(f,te));if(D=u.memoizedState,D!==null&&(pe=D.dehydrated,pe!==null))return mz(u,f,te,E,pe,D,v);if(P){P=E.fallback,te=f.mode,D=u.child,pe=D.sibling;var we={mode:"hidden",children:E.children};return(te&1)===0&&f.child!==D?(E=f.child,E.childLanes=0,E.pendingProps=we,f.deletions=null):(E=fl(D,we),E.subtreeFlags=D.subtreeFlags&14680064),pe!==null?P=fl(pe,P):(P=Ac(P,te,v,null),P.flags|=2),P.return=f,E.return=f,E.sibling=P,f.child=E,E=P,P=f.child,te=u.child.memoizedState,te=te===null?Jy(v):{baseLanes:te.baseLanes|v,cachePool:null,transitions:te.transitions},P.memoizedState=te,P.childLanes=u.childLanes&~v,f.memoizedState=Xy,E}return P=u.child,u=P.sibling,E=fl(P,{mode:"visible",children:E.children}),(f.mode&1)===0&&(E.lanes=v),E.return=f,E.sibling=null,u!==null&&(v=f.deletions,v===null?(f.deletions=[u],f.flags|=16):v.push(u)),f.child=E,f.memoizedState=null,E}function Ky(u,f){return f=XA({mode:"visible",children:f},u.mode,0,null),f.return=u,u.child=f}function LA(u,f,v,E){return E!==null&&Cy(E),Gu(f,u.child,null,v),u=Ky(f,f.pendingProps.children),u.flags|=2,f.memoizedState=null,u}function mz(u,f,v,E,D,P,te){if(v)return f.flags&256?(f.flags&=-257,E=Wy(Error(t(422))),LA(u,f,te,E)):f.memoizedState!==null?(f.child=u.child,f.flags|=128,null):(P=E.fallback,D=f.mode,E=XA({mode:"visible",children:E.children},D,0,null),P=Ac(P,D,te,null),P.flags|=2,E.return=f,P.return=f,E.sibling=P,f.child=E,(f.mode&1)!==0&&Gu(f,u.child,null,te),f.child.memoizedState=Jy(te),f.memoizedState=Xy,P);if((f.mode&1)===0)return LA(u,f,te,null);if(D.data==="$!"){if(E=D.nextSibling&&D.nextSibling.dataset,E)var pe=E.dgst;return E=pe,P=Error(t(419)),E=Wy(P,E,void 0),LA(u,f,te,E)}if(pe=(te&u.childLanes)!==0,_i||pe){if(E=Ir,E!==null){switch(te&-te){case 4:D=2;break;case 16:D=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:D=32;break;case 536870912:D=268435456;break;default:D=0}D=(D&(E.suspendedLanes|te))!==0?0:D,D!==0&&D!==P.retryLane&&(P.retryLane=D,Ka(u,D),Ms(E,u,D,-1))}return px(),E=Wy(Error(t(421))),LA(u,f,te,E)}return D.data==="$?"?(f.flags|=128,f.child=u.child,f=Mz.bind(null,u),D._reactRetry=f,null):(u=P.treeContext,Li=da(D.nextSibling),Pi=f,Gn=!0,Is=null,u!==null&&(Nt[Vt++]=ln,Nt[Vt++]=wr,Nt[Vt++]=on,ln=u.id,wr=u.overflow,on=f),f=Ky(f,E.children),f.flags|=4096,f)}function g1(u,f,v){u.lanes|=f;var E=u.alternate;E!==null&&(E.lanes|=f),Ty(u.return,f,v)}function Zy(u,f,v,E,D){var P=u.memoizedState;P===null?u.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:E,tail:v,tailMode:D}:(P.isBackwards=f,P.rendering=null,P.renderingStartTime=0,P.last=E,P.tail=v,P.tailMode=D)}function y1(u,f,v){var E=f.pendingProps,D=E.revealOrder,P=E.tail;if(si(u,f,E.children,v),E=Hn.current,(E&2)!==0)E=E&1|2,f.flags|=128;else{if(u!==null&&(u.flags&128)!==0)e:for(u=f.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&g1(u,v,f);else if(u.tag===19)g1(u,v,f);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===f)break e;for(;u.sibling===null;){if(u.return===null||u.return===f)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}E&=1}if(Tn(Hn,E),(f.mode&1)===0)f.memoizedState=null;else switch(D){case"forwards":for(v=f.child,D=null;v!==null;)u=v.alternate,u!==null&&TA(u)===null&&(D=v),v=v.sibling;v=D,v===null?(D=f.child,f.child=null):(D=v.sibling,v.sibling=null),Zy(f,!1,D,v,P);break;case"backwards":for(v=null,D=f.child,f.child=null;D!==null;){if(u=D.alternate,u!==null&&TA(u)===null){f.child=D;break}u=D.sibling,D.sibling=v,v=D,D=u}Zy(f,!0,v,null,P);break;case"together":Zy(f,!1,null,null,void 0);break;default:f.memoizedState=null}return f.child}function FA(u,f){(f.mode&1)===0&&u!==null&&(u.alternate=null,f.alternate=null,f.flags|=2)}function eo(u,f,v){if(u!==null&&(f.dependencies=u.dependencies),dc|=f.lanes,(v&f.childLanes)===0)return null;if(u!==null&&f.child!==u.child)throw Error(t(153));if(f.child!==null){for(u=f.child,v=fl(u,u.pendingProps),f.child=v,v.return=f;u.sibling!==null;)u=u.sibling,v=v.sibling=fl(u,u.pendingProps),v.return=f;v.sibling=null}return f.child}function gz(u,f,v){switch(f.tag){case 3:p1(f),$u();break;case 5:DC(f);break;case 1:Vr(f.type)&&Ou(f);break;case 4:ky(f,f.stateNode.containerInfo);break;case 10:var E=f.type._context,D=f.memoizedProps.value;Tn(CA,E._currentValue),E._currentValue=D;break;case 13:if(E=f.memoizedState,E!==null)return E.dehydrated!==null?(Tn(Hn,Hn.current&1),f.flags|=128,null):(v&f.child.childLanes)!==0?m1(u,f,v):(Tn(Hn,Hn.current&1),u=eo(u,f,v),u!==null?u.sibling:null);Tn(Hn,Hn.current&1);break;case 19:if(E=(v&f.childLanes)!==0,(u.flags&128)!==0){if(E)return y1(u,f,v);f.flags|=128}if(D=f.memoizedState,D!==null&&(D.rendering=null,D.tail=null,D.lastEffect=null),Tn(Hn,Hn.current),E)break;return null;case 22:case 23:return f.lanes=0,d1(u,f,v)}return eo(u,f,v)}var x1,ex,v1,_1;x1=function(u,f){for(var v=f.child;v!==null;){if(v.tag===5||v.tag===6)u.appendChild(v.stateNode);else if(v.tag!==4&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===f)break;for(;v.sibling===null;){if(v.return===null||v.return===f)return;v=v.return}v.sibling.return=v.return,v=v.sibling}},ex=function(){},v1=function(u,f,v,E){var D=u.memoizedProps;if(D!==E){u=f.stateNode,cc(pa.current);var P=null;switch(v){case"input":D=F(u,D),E=F(u,E),P=[];break;case"select":D=ne({},D,{value:void 0}),E=ne({},E,{value:void 0}),P=[];break;case"textarea":D=ce(u,D),E=ce(u,E),P=[];break;default:typeof D.onClick!="function"&&typeof E.onClick=="function"&&(u.onclick=Fu)}ft(v,E);var te;v=null;for(Pe in D)if(!E.hasOwnProperty(Pe)&&D.hasOwnProperty(Pe)&&D[Pe]!=null)if(Pe==="style"){var pe=D[Pe];for(te in pe)pe.hasOwnProperty(te)&&(v||(v={}),v[te]="")}else Pe!=="dangerouslySetInnerHTML"&&Pe!=="children"&&Pe!=="suppressContentEditableWarning"&&Pe!=="suppressHydrationWarning"&&Pe!=="autoFocus"&&(i.hasOwnProperty(Pe)?P||(P=[]):(P=P||[]).push(Pe,null));for(Pe in E){var we=E[Pe];if(pe=D?.[Pe],E.hasOwnProperty(Pe)&&we!==pe&&(we!=null||pe!=null))if(Pe==="style")if(pe){for(te in pe)!pe.hasOwnProperty(te)||we&&we.hasOwnProperty(te)||(v||(v={}),v[te]="");for(te in we)we.hasOwnProperty(te)&&pe[te]!==we[te]&&(v||(v={}),v[te]=we[te])}else v||(P||(P=[]),P.push(Pe,v)),v=we;else Pe==="dangerouslySetInnerHTML"?(we=we?we.__html:void 0,pe=pe?pe.__html:void 0,we!=null&&pe!==we&&(P=P||[]).push(Pe,we)):Pe==="children"?typeof we!="string"&&typeof we!="number"||(P=P||[]).push(Pe,""+we):Pe!=="suppressContentEditableWarning"&&Pe!=="suppressHydrationWarning"&&(i.hasOwnProperty(Pe)?(we!=null&&Pe==="onScroll"&&Mn("scroll",u),P||pe===we||(P=[])):(P=P||[]).push(Pe,we))}v&&(P=P||[]).push("style",v);var Pe=P;(f.updateQueue=Pe)&&(f.flags|=4)}},_1=function(u,f,v,E){v!==E&&(f.flags|=4)};function xf(u,f){if(!Gn)switch(u.tailMode){case"hidden":f=u.tail;for(var v=null;f!==null;)f.alternate!==null&&(v=f),f=f.sibling;v===null?u.tail=null:v.sibling=null;break;case"collapsed":v=u.tail;for(var E=null;v!==null;)v.alternate!==null&&(E=v),v=v.sibling;E===null?f||u.tail===null?u.tail=null:u.tail.sibling=null:E.sibling=null}}function jr(u){var f=u.alternate!==null&&u.alternate.child===u.child,v=0,E=0;if(f)for(var D=u.child;D!==null;)v|=D.lanes|D.childLanes,E|=D.subtreeFlags&14680064,E|=D.flags&14680064,D.return=u,D=D.sibling;else for(D=u.child;D!==null;)v|=D.lanes|D.childLanes,E|=D.subtreeFlags,E|=D.flags,D.return=u,D=D.sibling;return u.subtreeFlags|=E,u.childLanes=v,f}function yz(u,f,v){var E=f.pendingProps;switch(wy(f),f.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jr(f),null;case 1:return Vr(f.type)&&Uu(),jr(f),null;case 3:return E=f.stateNode,ju(),Pn(Gr),Pn(br),Py(),E.pendingContext&&(E.context=E.pendingContext,E.pendingContext=null),(u===null||u.child===null)&&(EA(f)?f.flags|=4:u===null||u.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,Is!==null&&(dx(Is),Is=null))),ex(u,f),jr(f),null;case 5:Ny(f);var D=cc(pf.current);if(v=f.type,u!==null&&f.stateNode!=null)v1(u,f,v,E,D),u.ref!==f.ref&&(f.flags|=512,f.flags|=2097152);else{if(!E){if(f.stateNode===null)throw Error(t(166));return jr(f),null}if(u=cc(pa.current),EA(f)){E=f.stateNode,v=f.type;var P=f.memoizedProps;switch(E[qi]=f,E[ic]=P,u=(f.mode&1)!==0,v){case"dialog":Mn("cancel",E),Mn("close",E);break;case"iframe":case"object":case"embed":Mn("load",E);break;case"video":case"audio":for(D=0;D<Zo.length;D++)Mn(Zo[D],E);break;case"source":Mn("error",E);break;case"img":case"image":case"link":Mn("error",E),Mn("load",E);break;case"details":Mn("toggle",E);break;case"input":re(E,P),Mn("invalid",E);break;case"select":E._wrapperState={wasMultiple:!!P.multiple},Mn("invalid",E);break;case"textarea":Z(E,P),Mn("invalid",E)}ft(v,P),D=null;for(var te in P)if(P.hasOwnProperty(te)){var pe=P[te];te==="children"?typeof pe=="string"?E.textContent!==pe&&(P.suppressHydrationWarning!==!0&&Lu(E.textContent,pe,u),D=["children",pe]):typeof pe=="number"&&E.textContent!==""+pe&&(P.suppressHydrationWarning!==!0&&Lu(E.textContent,pe,u),D=["children",""+pe]):i.hasOwnProperty(te)&&pe!=null&&te==="onScroll"&&Mn("scroll",E)}switch(v){case"input":Ne(E),ee(E,P,!0);break;case"textarea":Ne(E),le(E);break;case"select":case"option":break;default:typeof P.onClick=="function"&&(E.onclick=Fu)}E=D,f.updateQueue=E,E!==null&&(f.flags|=4)}else{te=D.nodeType===9?D:D.ownerDocument,u==="http://www.w3.org/1999/xhtml"&&(u=Ce(v)),u==="http://www.w3.org/1999/xhtml"?v==="script"?(u=te.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild)):typeof E.is=="string"?u=te.createElement(v,{is:E.is}):(u=te.createElement(v),v==="select"&&(te=u,E.multiple?te.multiple=!0:E.size&&(te.size=E.size))):u=te.createElementNS(u,v),u[qi]=f,u[ic]=E,x1(u,f,!1,!1),f.stateNode=u;e:{switch(te=dt(v,E),v){case"dialog":Mn("cancel",u),Mn("close",u),D=E;break;case"iframe":case"object":case"embed":Mn("load",u),D=E;break;case"video":case"audio":for(D=0;D<Zo.length;D++)Mn(Zo[D],u);D=E;break;case"source":Mn("error",u),D=E;break;case"img":case"image":case"link":Mn("error",u),Mn("load",u),D=E;break;case"details":Mn("toggle",u),D=E;break;case"input":re(u,E),D=F(u,E),Mn("invalid",u);break;case"option":D=E;break;case"select":u._wrapperState={wasMultiple:!!E.multiple},D=ne({},E,{value:void 0}),Mn("invalid",u);break;case"textarea":Z(u,E),D=ce(u,E),Mn("invalid",u);break;default:D=E}ft(v,D),pe=D;for(P in pe)if(pe.hasOwnProperty(P)){var we=pe[P];P==="style"?Ze(u,we):P==="dangerouslySetInnerHTML"?(we=we?we.__html:void 0,we!=null&&st(u,we)):P==="children"?typeof we=="string"?(v!=="textarea"||we!=="")&&He(u,we):typeof we=="number"&&He(u,""+we):P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&P!=="autoFocus"&&(i.hasOwnProperty(P)?we!=null&&P==="onScroll"&&Mn("scroll",u):we!=null&&b(u,P,we,te))}switch(v){case"input":Ne(u),ee(u,E,!1);break;case"textarea":Ne(u),le(u);break;case"option":E.value!=null&&u.setAttribute("value",""+Ie(E.value));break;case"select":u.multiple=!!E.multiple,P=E.value,P!=null?ve(u,!!E.multiple,P,!1):E.defaultValue!=null&&ve(u,!!E.multiple,E.defaultValue,!0);break;default:typeof D.onClick=="function"&&(u.onclick=Fu)}switch(v){case"button":case"input":case"select":case"textarea":E=!!E.autoFocus;break e;case"img":E=!0;break e;default:E=!1}}E&&(f.flags|=4)}f.ref!==null&&(f.flags|=512,f.flags|=2097152)}return jr(f),null;case 6:if(u&&f.stateNode!=null)_1(u,f,u.memoizedProps,E);else{if(typeof E!="string"&&f.stateNode===null)throw Error(t(166));if(v=cc(pf.current),cc(pa.current),EA(f)){if(E=f.stateNode,v=f.memoizedProps,E[qi]=f,(P=E.nodeValue!==v)&&(u=Pi,u!==null))switch(u.tag){case 3:Lu(E.nodeValue,v,(u.mode&1)!==0);break;case 5:u.memoizedProps.suppressHydrationWarning!==!0&&Lu(E.nodeValue,v,(u.mode&1)!==0)}P&&(f.flags|=4)}else E=(v.nodeType===9?v:v.ownerDocument).createTextNode(E),E[qi]=f,f.stateNode=E}return jr(f),null;case 13:if(Pn(Hn),E=f.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(Gn&&Li!==null&&(f.mode&1)!==0&&(f.flags&128)===0)EC(),$u(),f.flags|=98560,P=!1;else if(P=EA(f),E!==null&&E.dehydrated!==null){if(u===null){if(!P)throw Error(t(318));if(P=f.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(t(317));P[qi]=f}else $u(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;jr(f),P=!1}else Is!==null&&(dx(Is),Is=null),P=!0;if(!P)return f.flags&65536?f:null}return(f.flags&128)!==0?(f.lanes=v,f):(E=E!==null,E!==(u!==null&&u.memoizedState!==null)&&E&&(f.child.flags|=8192,(f.mode&1)!==0&&(u===null||(Hn.current&1)!==0?dr===0&&(dr=3):px())),f.updateQueue!==null&&(f.flags|=4),jr(f),null);case 4:return ju(),ex(u,f),u===null&&el(f.stateNode.containerInfo),jr(f),null;case 10:return My(f.type._context),jr(f),null;case 17:return Vr(f.type)&&Uu(),jr(f),null;case 19:if(Pn(Hn),P=f.memoizedState,P===null)return jr(f),null;if(E=(f.flags&128)!==0,te=P.rendering,te===null)if(E)xf(P,!1);else{if(dr!==0||u!==null&&(u.flags&128)!==0)for(u=f.child;u!==null;){if(te=TA(u),te!==null){for(f.flags|=128,xf(P,!1),E=te.updateQueue,E!==null&&(f.updateQueue=E,f.flags|=4),f.subtreeFlags=0,E=v,v=f.child;v!==null;)P=v,u=E,P.flags&=14680066,te=P.alternate,te===null?(P.childLanes=0,P.lanes=u,P.child=null,P.subtreeFlags=0,P.memoizedProps=null,P.memoizedState=null,P.updateQueue=null,P.dependencies=null,P.stateNode=null):(P.childLanes=te.childLanes,P.lanes=te.lanes,P.child=te.child,P.subtreeFlags=0,P.deletions=null,P.memoizedProps=te.memoizedProps,P.memoizedState=te.memoizedState,P.updateQueue=te.updateQueue,P.type=te.type,u=te.dependencies,P.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),v=v.sibling;return Tn(Hn,Hn.current&1|2),f.child}u=u.sibling}P.tail!==null&&De()>Xu&&(f.flags|=128,E=!0,xf(P,!1),f.lanes=4194304)}else{if(!E)if(u=TA(te),u!==null){if(f.flags|=128,E=!0,v=u.updateQueue,v!==null&&(f.updateQueue=v,f.flags|=4),xf(P,!0),P.tail===null&&P.tailMode==="hidden"&&!te.alternate&&!Gn)return jr(f),null}else 2*De()-P.renderingStartTime>Xu&&v!==1073741824&&(f.flags|=128,E=!0,xf(P,!1),f.lanes=4194304);P.isBackwards?(te.sibling=f.child,f.child=te):(v=P.last,v!==null?v.sibling=te:f.child=te,P.last=te)}return P.tail!==null?(f=P.tail,P.rendering=f,P.tail=f.sibling,P.renderingStartTime=De(),f.sibling=null,v=Hn.current,Tn(Hn,E?v&1|2:v&1),f):(jr(f),null);case 22:case 23:return fx(),E=f.memoizedState!==null,u!==null&&u.memoizedState!==null!==E&&(f.flags|=8192),E&&(f.mode&1)!==0?(Fi&1073741824)!==0&&(jr(f),f.subtreeFlags&6&&(f.flags|=8192)):jr(f),null;case 24:return null;case 25:return null}throw Error(t(156,f.tag))}function xz(u,f){switch(wy(f),f.tag){case 1:return Vr(f.type)&&Uu(),u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 3:return ju(),Pn(Gr),Pn(br),Py(),u=f.flags,(u&65536)!==0&&(u&128)===0?(f.flags=u&-65537|128,f):null;case 5:return Ny(f),null;case 13:if(Pn(Hn),u=f.memoizedState,u!==null&&u.dehydrated!==null){if(f.alternate===null)throw Error(t(340));$u()}return u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 19:return Pn(Hn),null;case 4:return ju(),null;case 10:return My(f.type._context),null;case 22:case 23:return fx(),null;case 24:return null;default:return null}}var zA=!1,Wr=!1,vz=typeof WeakSet=="function"?WeakSet:Set,bt=null;function qu(u,f){var v=u.ref;if(v!==null)if(typeof v=="function")try{v(null)}catch(E){Xn(u,f,E)}else v.current=null}function tx(u,f,v){try{v()}catch(E){Xn(u,f,E)}}var b1=!1;function _z(u,f){if(rf=mu,u=Vh(),Mu(u)){if("selectionStart"in u)var v={start:u.selectionStart,end:u.selectionEnd};else e:{v=(v=u.ownerDocument)&&v.defaultView||window;var E=v.getSelection&&v.getSelection();if(E&&E.rangeCount!==0){v=E.anchorNode;var D=E.anchorOffset,P=E.focusNode;E=E.focusOffset;try{v.nodeType,P.nodeType}catch{v=null;break e}var te=0,pe=-1,we=-1,Pe=0,Xe=0,rt=u,qe=null;t:for(;;){for(var yt;rt!==v||D!==0&&rt.nodeType!==3||(pe=te+D),rt!==P||E!==0&&rt.nodeType!==3||(we=te+E),rt.nodeType===3&&(te+=rt.nodeValue.length),(yt=rt.firstChild)!==null;)qe=rt,rt=yt;for(;;){if(rt===u)break t;if(qe===v&&++Pe===D&&(pe=te),qe===P&&++Xe===E&&(we=te),(yt=rt.nextSibling)!==null)break;rt=qe,qe=rt.parentNode}rt=yt}v=pe===-1||we===-1?null:{start:pe,end:we}}else v=null}v=v||{start:0,end:0}}else v=null;for(sf={focusedElem:u,selectionRange:v},mu=!1,bt=f;bt!==null;)if(f=bt,u=f.child,(f.subtreeFlags&1028)!==0&&u!==null)u.return=f,bt=u;else for(;bt!==null;){f=bt;try{var Et=f.alternate;if((f.flags&1024)!==0)switch(f.tag){case 0:case 11:case 15:break;case 1:if(Et!==null){var Ct=Et.memoizedProps,Zn=Et.memoizedState,ke=f.stateNode,Be=ke.getSnapshotBeforeUpdate(f.elementType===f.type?Ct:Cs(f.type,Ct),Zn);ke.__reactInternalSnapshotBeforeUpdate=Be}break;case 3:var Qe=f.stateNode.containerInfo;Qe.nodeType===1?Qe.textContent="":Qe.nodeType===9&&Qe.documentElement&&Qe.removeChild(Qe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ot){Xn(f,f.return,ot)}if(u=f.sibling,u!==null){u.return=f.return,bt=u;break}bt=f.return}return Et=b1,b1=!1,Et}function vf(u,f,v){var E=f.updateQueue;if(E=E!==null?E.lastEffect:null,E!==null){var D=E=E.next;do{if((D.tag&u)===u){var P=D.destroy;D.destroy=void 0,P!==void 0&&tx(f,v,P)}D=D.next}while(D!==E)}}function UA(u,f){if(f=f.updateQueue,f=f!==null?f.lastEffect:null,f!==null){var v=f=f.next;do{if((v.tag&u)===u){var E=v.create;v.destroy=E()}v=v.next}while(v!==f)}}function nx(u){var f=u.ref;if(f!==null){var v=u.stateNode;u.tag,u=v,typeof f=="function"?f(u):f.current=u}}function w1(u){var f=u.alternate;f!==null&&(u.alternate=null,w1(f)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(f=u.stateNode,f!==null&&(delete f[qi],delete f[ic],delete f[cf],delete f[_y],delete f[by])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function E1(u){return u.tag===5||u.tag===3||u.tag===4}function I1(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||E1(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function rx(u,f,v){var E=u.tag;if(E===5||E===6)u=u.stateNode,f?v.nodeType===8?v.parentNode.insertBefore(u,f):v.insertBefore(u,f):(v.nodeType===8?(f=v.parentNode,f.insertBefore(u,v)):(f=v,f.appendChild(u)),v=v._reactRootContainer,v!=null||f.onclick!==null||(f.onclick=Fu));else if(E!==4&&(u=u.child,u!==null))for(rx(u,f,v),u=u.sibling;u!==null;)rx(u,f,v),u=u.sibling}function ix(u,f,v){var E=u.tag;if(E===5||E===6)u=u.stateNode,f?v.insertBefore(u,f):v.appendChild(u);else if(E!==4&&(u=u.child,u!==null))for(ix(u,f,v),u=u.sibling;u!==null;)ix(u,f,v),u=u.sibling}var Qr=null,Ss=!1;function ll(u,f,v){for(v=v.child;v!==null;)C1(u,f,v),v=v.sibling}function C1(u,f,v){if(St&&typeof St.onCommitFiberUnmount=="function")try{St.onCommitFiberUnmount(Qt,v)}catch{}switch(v.tag){case 5:Wr||qu(v,f);case 6:var E=Qr,D=Ss;Qr=null,ll(u,f,v),Qr=E,Ss=D,Qr!==null&&(Ss?(u=Qr,v=v.stateNode,u.nodeType===8?u.parentNode.removeChild(v):u.removeChild(v)):Qr.removeChild(v.stateNode));break;case 18:Qr!==null&&(Ss?(u=Qr,v=v.stateNode,u.nodeType===8?lf(u.parentNode,v):u.nodeType===1&&lf(u,v),Va(u)):lf(Qr,v.stateNode));break;case 4:E=Qr,D=Ss,Qr=v.stateNode.containerInfo,Ss=!0,ll(u,f,v),Qr=E,Ss=D;break;case 0:case 11:case 14:case 15:if(!Wr&&(E=v.updateQueue,E!==null&&(E=E.lastEffect,E!==null))){D=E=E.next;do{var P=D,te=P.destroy;P=P.tag,te!==void 0&&((P&2)!==0||(P&4)!==0)&&tx(v,f,te),D=D.next}while(D!==E)}ll(u,f,v);break;case 1:if(!Wr&&(qu(v,f),E=v.stateNode,typeof E.componentWillUnmount=="function"))try{E.props=v.memoizedProps,E.state=v.memoizedState,E.componentWillUnmount()}catch(pe){Xn(v,f,pe)}ll(u,f,v);break;case 21:ll(u,f,v);break;case 22:v.mode&1?(Wr=(E=Wr)||v.memoizedState!==null,ll(u,f,v),Wr=E):ll(u,f,v);break;default:ll(u,f,v)}}function S1(u){var f=u.updateQueue;if(f!==null){u.updateQueue=null;var v=u.stateNode;v===null&&(v=u.stateNode=new vz),f.forEach(function(E){var D=Tz.bind(null,u,E);v.has(E)||(v.add(E),E.then(D,D))})}}function Bs(u,f){var v=f.deletions;if(v!==null)for(var E=0;E<v.length;E++){var D=v[E];try{var P=u,te=f,pe=te;e:for(;pe!==null;){switch(pe.tag){case 5:Qr=pe.stateNode,Ss=!1;break e;case 3:Qr=pe.stateNode.containerInfo,Ss=!0;break e;case 4:Qr=pe.stateNode.containerInfo,Ss=!0;break e}pe=pe.return}if(Qr===null)throw Error(t(160));C1(P,te,D),Qr=null,Ss=!1;var we=D.alternate;we!==null&&(we.return=null),D.return=null}catch(Pe){Xn(D,f,Pe)}}if(f.subtreeFlags&12854)for(f=f.child;f!==null;)B1(f,u),f=f.sibling}function B1(u,f){var v=u.alternate,E=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:if(Bs(f,u),ma(u),E&4){try{vf(3,u,u.return),UA(3,u)}catch(Ct){Xn(u,u.return,Ct)}try{vf(5,u,u.return)}catch(Ct){Xn(u,u.return,Ct)}}break;case 1:Bs(f,u),ma(u),E&512&&v!==null&&qu(v,v.return);break;case 5:if(Bs(f,u),ma(u),E&512&&v!==null&&qu(v,v.return),u.flags&32){var D=u.stateNode;try{He(D,"")}catch(Ct){Xn(u,u.return,Ct)}}if(E&4&&(D=u.stateNode,D!=null)){var P=u.memoizedProps,te=v!==null?v.memoizedProps:P,pe=u.type,we=u.updateQueue;if(u.updateQueue=null,we!==null)try{pe==="input"&&P.type==="radio"&&P.name!=null&&Ee(D,P),dt(pe,te);var Pe=dt(pe,P);for(te=0;te<we.length;te+=2){var Xe=we[te],rt=we[te+1];Xe==="style"?Ze(D,rt):Xe==="dangerouslySetInnerHTML"?st(D,rt):Xe==="children"?He(D,rt):b(D,Xe,rt,Pe)}switch(pe){case"input":q(D,P);break;case"textarea":Y(D,P);break;case"select":var qe=D._wrapperState.wasMultiple;D._wrapperState.wasMultiple=!!P.multiple;var yt=P.value;yt!=null?ve(D,!!P.multiple,yt,!1):qe!==!!P.multiple&&(P.defaultValue!=null?ve(D,!!P.multiple,P.defaultValue,!0):ve(D,!!P.multiple,P.multiple?[]:"",!1))}D[ic]=P}catch(Ct){Xn(u,u.return,Ct)}}break;case 6:if(Bs(f,u),ma(u),E&4){if(u.stateNode===null)throw Error(t(162));D=u.stateNode,P=u.memoizedProps;try{D.nodeValue=P}catch(Ct){Xn(u,u.return,Ct)}}break;case 3:if(Bs(f,u),ma(u),E&4&&v!==null&&v.memoizedState.isDehydrated)try{Va(f.containerInfo)}catch(Ct){Xn(u,u.return,Ct)}break;case 4:Bs(f,u),ma(u);break;case 13:Bs(f,u),ma(u),D=u.child,D.flags&8192&&(P=D.memoizedState!==null,D.stateNode.isHidden=P,!P||D.alternate!==null&&D.alternate.memoizedState!==null||(ox=De())),E&4&&S1(u);break;case 22:if(Xe=v!==null&&v.memoizedState!==null,u.mode&1?(Wr=(Pe=Wr)||Xe,Bs(f,u),Wr=Pe):Bs(f,u),ma(u),E&8192){if(Pe=u.memoizedState!==null,(u.stateNode.isHidden=Pe)&&!Xe&&(u.mode&1)!==0)for(bt=u,Xe=u.child;Xe!==null;){for(rt=bt=Xe;bt!==null;){switch(qe=bt,yt=qe.child,qe.tag){case 0:case 11:case 14:case 15:vf(4,qe,qe.return);break;case 1:qu(qe,qe.return);var Et=qe.stateNode;if(typeof Et.componentWillUnmount=="function"){E=qe,v=qe.return;try{f=E,Et.props=f.memoizedProps,Et.state=f.memoizedState,Et.componentWillUnmount()}catch(Ct){Xn(E,v,Ct)}}break;case 5:qu(qe,qe.return);break;case 22:if(qe.memoizedState!==null){R1(rt);continue}}yt!==null?(yt.return=qe,bt=yt):R1(rt)}Xe=Xe.sibling}e:for(Xe=null,rt=u;;){if(rt.tag===5){if(Xe===null){Xe=rt;try{D=rt.stateNode,Pe?(P=D.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none"):(pe=rt.stateNode,we=rt.memoizedProps.style,te=we!=null&&we.hasOwnProperty("display")?we.display:null,pe.style.display=ze("display",te))}catch(Ct){Xn(u,u.return,Ct)}}}else if(rt.tag===6){if(Xe===null)try{rt.stateNode.nodeValue=Pe?"":rt.memoizedProps}catch(Ct){Xn(u,u.return,Ct)}}else if((rt.tag!==22&&rt.tag!==23||rt.memoizedState===null||rt===u)&&rt.child!==null){rt.child.return=rt,rt=rt.child;continue}if(rt===u)break e;for(;rt.sibling===null;){if(rt.return===null||rt.return===u)break e;Xe===rt&&(Xe=null),rt=rt.return}Xe===rt&&(Xe=null),rt.sibling.return=rt.return,rt=rt.sibling}}break;case 19:Bs(f,u),ma(u),E&4&&S1(u);break;case 21:break;default:Bs(f,u),ma(u)}}function ma(u){var f=u.flags;if(f&2){try{e:{for(var v=u.return;v!==null;){if(E1(v)){var E=v;break e}v=v.return}throw Error(t(160))}switch(E.tag){case 5:var D=E.stateNode;E.flags&32&&(He(D,""),E.flags&=-33);var P=I1(u);ix(u,P,D);break;case 3:case 4:var te=E.stateNode.containerInfo,pe=I1(u);rx(u,pe,te);break;default:throw Error(t(161))}}catch(we){Xn(u,u.return,we)}u.flags&=-3}f&4096&&(u.flags&=-4097)}function bz(u,f,v){bt=u,M1(u)}function M1(u,f,v){for(var E=(u.mode&1)!==0;bt!==null;){var D=bt,P=D.child;if(D.tag===22&&E){var te=D.memoizedState!==null||zA;if(!te){var pe=D.alternate,we=pe!==null&&pe.memoizedState!==null||Wr;pe=zA;var Pe=Wr;if(zA=te,(Wr=we)&&!Pe)for(bt=D;bt!==null;)te=bt,we=te.child,te.tag===22&&te.memoizedState!==null?D1(D):we!==null?(we.return=te,bt=we):D1(D);for(;P!==null;)bt=P,M1(P),P=P.sibling;bt=D,zA=pe,Wr=Pe}T1(u)}else(D.subtreeFlags&8772)!==0&&P!==null?(P.return=D,bt=P):T1(u)}}function T1(u){for(;bt!==null;){var f=bt;if((f.flags&8772)!==0){var v=f.alternate;try{if((f.flags&8772)!==0)switch(f.tag){case 0:case 11:case 15:Wr||UA(5,f);break;case 1:var E=f.stateNode;if(f.flags&4&&!Wr)if(v===null)E.componentDidMount();else{var D=f.elementType===f.type?v.memoizedProps:Cs(f.type,v.memoizedProps);E.componentDidUpdate(D,v.memoizedState,E.__reactInternalSnapshotBeforeUpdate)}var P=f.updateQueue;P!==null&&RC(f,P,E);break;case 3:var te=f.updateQueue;if(te!==null){if(v=null,f.child!==null)switch(f.child.tag){case 5:v=f.child.stateNode;break;case 1:v=f.child.stateNode}RC(f,te,v)}break;case 5:var pe=f.stateNode;if(v===null&&f.flags&4){v=pe;var we=f.memoizedProps;switch(f.type){case"button":case"input":case"select":case"textarea":we.autoFocus&&v.focus();break;case"img":we.src&&(v.src=we.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(f.memoizedState===null){var Pe=f.alternate;if(Pe!==null){var Xe=Pe.memoizedState;if(Xe!==null){var rt=Xe.dehydrated;rt!==null&&Va(rt)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}Wr||f.flags&512&&nx(f)}catch(qe){Xn(f,f.return,qe)}}if(f===u){bt=null;break}if(v=f.sibling,v!==null){v.return=f.return,bt=v;break}bt=f.return}}function R1(u){for(;bt!==null;){var f=bt;if(f===u){bt=null;break}var v=f.sibling;if(v!==null){v.return=f.return,bt=v;break}bt=f.return}}function D1(u){for(;bt!==null;){var f=bt;try{switch(f.tag){case 0:case 11:case 15:var v=f.return;try{UA(4,f)}catch(we){Xn(f,v,we)}break;case 1:var E=f.stateNode;if(typeof E.componentDidMount=="function"){var D=f.return;try{E.componentDidMount()}catch(we){Xn(f,D,we)}}var P=f.return;try{nx(f)}catch(we){Xn(f,P,we)}break;case 5:var te=f.return;try{nx(f)}catch(we){Xn(f,te,we)}}}catch(we){Xn(f,f.return,we)}if(f===u){bt=null;break}var pe=f.sibling;if(pe!==null){pe.return=f.return,bt=pe;break}bt=f.return}}var wz=Math.ceil,OA=w.ReactCurrentDispatcher,sx=w.ReactCurrentOwner,Ji=w.ReactCurrentBatchConfig,An=0,Ir=null,nr=null,Pr=0,Fi=0,Yu=ha(0),dr=0,_f=null,dc=0,$A=0,ax=0,bf=null,bi=null,ox=0,Xu=1/0,to=null,GA=!1,lx=null,cl=null,VA=!1,ul=null,HA=0,wf=0,cx=null,jA=-1,WA=0;function ai(){return(An&6)!==0?De():jA!==-1?jA:jA=De()}function dl(u){return(u.mode&1)===0?1:(An&2)!==0&&Pr!==0?Pr&-Pr:az.transition!==null?(WA===0&&(WA=oa()),WA):(u=Gt,u!==0||(u=window.event,u=u===void 0?16:Zp(u.type)),u)}function Ms(u,f,v,E){if(50<wf)throw wf=0,cx=null,Error(t(185));Yn(u,v,E),((An&2)===0||u!==Ir)&&(u===Ir&&((An&2)===0&&($A|=v),dr===4&&hl(u,Pr)),wi(u,E),v===1&&An===0&&(f.mode&1)===0&&(Xu=De()+500,N&&ue()))}function wi(u,f){var v=u.callbackNode;aa(u,f);var E=tn(u,u===Ir?Pr:0);if(E===0)v!==null&&gi(v),u.callbackNode=null,u.callbackPriority=0;else if(f=E&-E,u.callbackPriority!==f){if(v!=null&&gi(v),f===1)u.tag===0?se(N1.bind(null,u)):z(N1.bind(null,u)),xy(function(){(An&6)===0&&ue()}),v=null;else{switch(Fo(E)){case 1:v=Me;break;case 4:v=at;break;case 16:v=lt;break;case 536870912:v=gt;break;default:v=lt}v=$1(v,k1.bind(null,u))}u.callbackPriority=f,u.callbackNode=v}}function k1(u,f){if(jA=-1,WA=0,(An&6)!==0)throw Error(t(327));var v=u.callbackNode;if(Ju()&&u.callbackNode!==v)return null;var E=tn(u,u===Ir?Pr:0);if(E===0)return null;if((E&30)!==0||(E&u.expiredLanes)!==0||f)f=qA(u,E);else{f=E;var D=An;An|=2;var P=P1();(Ir!==u||Pr!==f)&&(to=null,Xu=De()+500,fc(u,f));do try{Cz();break}catch(pe){Q1(u,pe)}while(!0);By(),OA.current=P,An=D,nr!==null?f=0:(Ir=null,Pr=0,f=dr)}if(f!==0){if(f===2&&(D=cr(u),D!==0&&(E=D,f=ux(u,D))),f===1)throw v=_f,fc(u,0),hl(u,E),wi(u,De()),v;if(f===6)hl(u,E);else{if(D=u.current.alternate,(E&30)===0&&!Ez(D)&&(f=qA(u,E),f===2&&(P=cr(u),P!==0&&(E=P,f=ux(u,P))),f===1))throw v=_f,fc(u,0),hl(u,E),wi(u,De()),v;switch(u.finishedWork=D,u.finishedLanes=E,f){case 0:case 1:throw Error(t(345));case 2:pc(u,bi,to);break;case 3:if(hl(u,E),(E&130023424)===E&&(f=ox+500-De(),10<f)){if(tn(u,0)!==0)break;if(D=u.suspendedLanes,(D&E)!==E){ai(),u.pingedLanes|=u.suspendedLanes&D;break}u.timeoutHandle=of(pc.bind(null,u,bi,to),f);break}pc(u,bi,to);break;case 4:if(hl(u,E),(E&4194240)===E)break;for(f=u.eventTimes,D=-1;0<E;){var te=31-$t(E);P=1<<te,te=f[te],te>D&&(D=te),E&=~P}if(E=D,E=De()-E,E=(120>E?120:480>E?480:1080>E?1080:1920>E?1920:3e3>E?3e3:4320>E?4320:1960*wz(E/1960))-E,10<E){u.timeoutHandle=of(pc.bind(null,u,bi,to),E);break}pc(u,bi,to);break;case 5:pc(u,bi,to);break;default:throw Error(t(329))}}}return wi(u,De()),u.callbackNode===v?k1.bind(null,u):null}function ux(u,f){var v=bf;return u.current.memoizedState.isDehydrated&&(fc(u,f).flags|=256),u=qA(u,f),u!==2&&(f=bi,bi=v,f!==null&&dx(f)),u}function dx(u){bi===null?bi=u:bi.push.apply(bi,u)}function Ez(u){for(var f=u;;){if(f.flags&16384){var v=f.updateQueue;if(v!==null&&(v=v.stores,v!==null))for(var E=0;E<v.length;E++){var D=v[E],P=D.getSnapshot;D=D.value;try{if(!vi(P(),D))return!1}catch{return!1}}}if(v=f.child,f.subtreeFlags&16384&&v!==null)v.return=f,f=v;else{if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return!0;f=f.return}f.sibling.return=f.return,f=f.sibling}}return!0}function hl(u,f){for(f&=~ax,f&=~$A,u.suspendedLanes|=f,u.pingedLanes&=~f,u=u.expirationTimes;0<f;){var v=31-$t(f),E=1<<v;u[v]=-1,f&=~E}}function N1(u){if((An&6)!==0)throw Error(t(327));Ju();var f=tn(u,0);if((f&1)===0)return wi(u,De()),null;var v=qA(u,f);if(u.tag!==0&&v===2){var E=cr(u);E!==0&&(f=E,v=ux(u,E))}if(v===1)throw v=_f,fc(u,0),hl(u,f),wi(u,De()),v;if(v===6)throw Error(t(345));return u.finishedWork=u.current.alternate,u.finishedLanes=f,pc(u,bi,to),wi(u,De()),null}function hx(u,f){var v=An;An|=1;try{return u(f)}finally{An=v,An===0&&(Xu=De()+500,N&&ue())}}function hc(u){ul!==null&&ul.tag===0&&(An&6)===0&&Ju();var f=An;An|=1;var v=Ji.transition,E=Gt;try{if(Ji.transition=null,Gt=1,u)return u()}finally{Gt=E,Ji.transition=v,An=f,(An&6)===0&&ue()}}function fx(){Fi=Yu.current,Pn(Yu)}function fc(u,f){u.finishedWork=null,u.finishedLanes=0;var v=u.timeoutHandle;if(v!==-1&&(u.timeoutHandle=-1,yy(v)),nr!==null)for(v=nr.return;v!==null;){var E=v;switch(wy(E),E.tag){case 1:E=E.type.childContextTypes,E!=null&&Uu();break;case 3:ju(),Pn(Gr),Pn(br),Py();break;case 5:Ny(E);break;case 4:ju();break;case 13:Pn(Hn);break;case 19:Pn(Hn);break;case 10:My(E.type._context);break;case 22:case 23:fx()}v=v.return}if(Ir=u,nr=u=fl(u.current,null),Pr=Fi=f,dr=0,_f=null,ax=$A=dc=0,bi=bf=null,lc!==null){for(f=0;f<lc.length;f++)if(v=lc[f],E=v.interleaved,E!==null){v.interleaved=null;var D=E.next,P=v.pending;if(P!==null){var te=P.next;P.next=D,E.next=te}v.pending=E}lc=null}return u}function Q1(u,f){do{var v=nr;try{if(By(),RA.current=QA,DA){for(var E=jn.memoizedState;E!==null;){var D=E.queue;D!==null&&(D.pending=null),E=E.next}DA=!1}if(uc=0,Er=ur=jn=null,Af=!1,mf=0,sx.current=null,v===null||v.return===null){dr=1,_f=f,nr=null;break}e:{var P=u,te=v.return,pe=v,we=f;if(f=Pr,pe.flags|=32768,we!==null&&typeof we=="object"&&typeof we.then=="function"){var Pe=we,Xe=pe,rt=Xe.tag;if((Xe.mode&1)===0&&(rt===0||rt===11||rt===15)){var qe=Xe.alternate;qe?(Xe.updateQueue=qe.updateQueue,Xe.memoizedState=qe.memoizedState,Xe.lanes=qe.lanes):(Xe.updateQueue=null,Xe.memoizedState=null)}var yt=a1(te);if(yt!==null){yt.flags&=-257,o1(yt,te,pe,P,f),yt.mode&1&&s1(P,Pe,f),f=yt,we=Pe;var Et=f.updateQueue;if(Et===null){var Ct=new Set;Ct.add(we),f.updateQueue=Ct}else Et.add(we);break e}else{if((f&1)===0){s1(P,Pe,f),px();break e}we=Error(t(426))}}else if(Gn&&pe.mode&1){var Zn=a1(te);if(Zn!==null){(Zn.flags&65536)===0&&(Zn.flags|=256),o1(Zn,te,pe,P,f),Cy(Wu(we,pe));break e}}P=we=Wu(we,pe),dr!==4&&(dr=2),bf===null?bf=[P]:bf.push(P),P=te;do{switch(P.tag){case 3:P.flags|=65536,f&=-f,P.lanes|=f;var ke=r1(P,we,f);TC(P,ke);break e;case 1:pe=we;var Be=P.type,Qe=P.stateNode;if((P.flags&128)===0&&(typeof Be.getDerivedStateFromError=="function"||Qe!==null&&typeof Qe.componentDidCatch=="function"&&(cl===null||!cl.has(Qe)))){P.flags|=65536,f&=-f,P.lanes|=f;var ot=i1(P,pe,f);TC(P,ot);break e}}P=P.return}while(P!==null)}F1(v)}catch(Bt){f=Bt,nr===v&&v!==null&&(nr=v=v.return);continue}break}while(!0)}function P1(){var u=OA.current;return OA.current=QA,u===null?QA:u}function px(){(dr===0||dr===3||dr===2)&&(dr=4),Ir===null||(dc&268435455)===0&&($A&268435455)===0||hl(Ir,Pr)}function qA(u,f){var v=An;An|=2;var E=P1();(Ir!==u||Pr!==f)&&(to=null,fc(u,f));do try{Iz();break}catch(D){Q1(u,D)}while(!0);if(By(),An=v,OA.current=E,nr!==null)throw Error(t(261));return Ir=null,Pr=0,dr}function Iz(){for(;nr!==null;)L1(nr)}function Cz(){for(;nr!==null&&!ae();)L1(nr)}function L1(u){var f=O1(u.alternate,u,Fi);u.memoizedProps=u.pendingProps,f===null?F1(u):nr=f,sx.current=null}function F1(u){var f=u;do{var v=f.alternate;if(u=f.return,(f.flags&32768)===0){if(v=yz(v,f,Fi),v!==null){nr=v;return}}else{if(v=xz(v,f),v!==null){v.flags&=32767,nr=v;return}if(u!==null)u.flags|=32768,u.subtreeFlags=0,u.deletions=null;else{dr=6,nr=null;return}}if(f=f.sibling,f!==null){nr=f;return}nr=f=u}while(f!==null);dr===0&&(dr=5)}function pc(u,f,v){var E=Gt,D=Ji.transition;try{Ji.transition=null,Gt=1,Sz(u,f,v,E)}finally{Ji.transition=D,Gt=E}return null}function Sz(u,f,v,E){do Ju();while(ul!==null);if((An&6)!==0)throw Error(t(327));v=u.finishedWork;var D=u.finishedLanes;if(v===null)return null;if(u.finishedWork=null,u.finishedLanes=0,v===u.current)throw Error(t(177));u.callbackNode=null,u.callbackPriority=0;var P=v.lanes|v.childLanes;if(Or(u,P),u===Ir&&(nr=Ir=null,Pr=0),(v.subtreeFlags&2064)===0&&(v.flags&2064)===0||VA||(VA=!0,$1(lt,function(){return Ju(),null})),P=(v.flags&15990)!==0,(v.subtreeFlags&15990)!==0||P){P=Ji.transition,Ji.transition=null;var te=Gt;Gt=1;var pe=An;An|=4,sx.current=null,_z(u,v),B1(v,u),fA(sf),mu=!!rf,sf=rf=null,u.current=v,bz(v),Te(),An=pe,Gt=te,Ji.transition=P}else u.current=v;if(VA&&(VA=!1,ul=u,HA=D),P=u.pendingLanes,P===0&&(cl=null),kt(v.stateNode),wi(u,De()),f!==null)for(E=u.onRecoverableError,v=0;v<f.length;v++)D=f[v],E(D.value,{componentStack:D.stack,digest:D.digest});if(GA)throw GA=!1,u=lx,lx=null,u;return(HA&1)!==0&&u.tag!==0&&Ju(),P=u.pendingLanes,(P&1)!==0?u===cx?wf++:(wf=0,cx=u):wf=0,ue(),null}function Ju(){if(ul!==null){var u=Fo(HA),f=Ji.transition,v=Gt;try{if(Ji.transition=null,Gt=16>u?16:u,ul===null)var E=!1;else{if(u=ul,ul=null,HA=0,(An&6)!==0)throw Error(t(331));var D=An;for(An|=4,bt=u.current;bt!==null;){var P=bt,te=P.child;if((bt.flags&16)!==0){var pe=P.deletions;if(pe!==null){for(var we=0;we<pe.length;we++){var Pe=pe[we];for(bt=Pe;bt!==null;){var Xe=bt;switch(Xe.tag){case 0:case 11:case 15:vf(8,Xe,P)}var rt=Xe.child;if(rt!==null)rt.return=Xe,bt=rt;else for(;bt!==null;){Xe=bt;var qe=Xe.sibling,yt=Xe.return;if(w1(Xe),Xe===Pe){bt=null;break}if(qe!==null){qe.return=yt,bt=qe;break}bt=yt}}}var Et=P.alternate;if(Et!==null){var Ct=Et.child;if(Ct!==null){Et.child=null;do{var Zn=Ct.sibling;Ct.sibling=null,Ct=Zn}while(Ct!==null)}}bt=P}}if((P.subtreeFlags&2064)!==0&&te!==null)te.return=P,bt=te;else e:for(;bt!==null;){if(P=bt,(P.flags&2048)!==0)switch(P.tag){case 0:case 11:case 15:vf(9,P,P.return)}var ke=P.sibling;if(ke!==null){ke.return=P.return,bt=ke;break e}bt=P.return}}var Be=u.current;for(bt=Be;bt!==null;){te=bt;var Qe=te.child;if((te.subtreeFlags&2064)!==0&&Qe!==null)Qe.return=te,bt=Qe;else e:for(te=Be;bt!==null;){if(pe=bt,(pe.flags&2048)!==0)try{switch(pe.tag){case 0:case 11:case 15:UA(9,pe)}}catch(Bt){Xn(pe,pe.return,Bt)}if(pe===te){bt=null;break e}var ot=pe.sibling;if(ot!==null){ot.return=pe.return,bt=ot;break e}bt=pe.return}}if(An=D,ue(),St&&typeof St.onPostCommitFiberRoot=="function")try{St.onPostCommitFiberRoot(Qt,u)}catch{}E=!0}return E}finally{Gt=v,Ji.transition=f}}return!1}function z1(u,f,v){f=Wu(v,f),f=r1(u,f,1),u=ol(u,f,1),f=ai(),u!==null&&(Yn(u,1,f),wi(u,f))}function Xn(u,f,v){if(u.tag===3)z1(u,u,v);else for(;f!==null;){if(f.tag===3){z1(f,u,v);break}else if(f.tag===1){var E=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof E.componentDidCatch=="function"&&(cl===null||!cl.has(E))){u=Wu(v,u),u=i1(f,u,1),f=ol(f,u,1),u=ai(),f!==null&&(Yn(f,1,u),wi(f,u));break}}f=f.return}}function Bz(u,f,v){var E=u.pingCache;E!==null&&E.delete(f),f=ai(),u.pingedLanes|=u.suspendedLanes&v,Ir===u&&(Pr&v)===v&&(dr===4||dr===3&&(Pr&130023424)===Pr&&500>De()-ox?fc(u,0):ax|=v),wi(u,f)}function U1(u,f){f===0&&((u.mode&1)===0?f=1:(f=Rt,Rt<<=1,(Rt&130023424)===0&&(Rt=4194304)));var v=ai();u=Ka(u,f),u!==null&&(Yn(u,f,v),wi(u,v))}function Mz(u){var f=u.memoizedState,v=0;f!==null&&(v=f.retryLane),U1(u,v)}function Tz(u,f){var v=0;switch(u.tag){case 13:var E=u.stateNode,D=u.memoizedState;D!==null&&(v=D.retryLane);break;case 19:E=u.stateNode;break;default:throw Error(t(314))}E!==null&&E.delete(f),U1(u,v)}var O1;O1=function(u,f,v){if(u!==null)if(u.memoizedProps!==f.pendingProps||Gr.current)_i=!0;else{if((u.lanes&v)===0&&(f.flags&128)===0)return _i=!1,gz(u,f,v);_i=(u.flags&131072)!==0}else _i=!1,Gn&&(f.flags&1048576)!==0&&wA(f,ht,f.index);switch(f.lanes=0,f.tag){case 2:var E=f.type;FA(u,f),u=f.pendingProps;var D=sl(f,br.current);Hu(f,v),D=zy(null,f,E,u,D,v);var P=Uy();return f.flags|=1,typeof D=="object"&&D!==null&&typeof D.render=="function"&&D.$$typeof===void 0?(f.tag=1,f.memoizedState=null,f.updateQueue=null,Vr(E)?(P=!0,Ou(f)):P=!1,f.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,Dy(f),D.updater=PA,f.stateNode=D,D._reactInternals=f,jy(f,E,u,v),f=Yy(null,f,E,!0,P,v)):(f.tag=0,Gn&&P&&oc(f),si(null,f,D,v),f=f.child),f;case 16:E=f.elementType;e:{switch(FA(u,f),u=f.pendingProps,D=E._init,E=D(E._payload),f.type=E,D=f.tag=Dz(E),u=Cs(E,u),D){case 0:f=qy(null,f,E,u,v);break e;case 1:f=f1(null,f,E,u,v);break e;case 11:f=l1(null,f,E,u,v);break e;case 14:f=c1(null,f,E,Cs(E.type,u),v);break e}throw Error(t(306,E,""))}return f;case 0:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),qy(u,f,E,D,v);case 1:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),f1(u,f,E,D,v);case 3:e:{if(p1(f),u===null)throw Error(t(387));E=f.pendingProps,P=f.memoizedState,D=P.element,MC(u,f),MA(f,E,null,v);var te=f.memoizedState;if(E=te.element,P.isDehydrated)if(P={element:E,isDehydrated:!1,cache:te.cache,pendingSuspenseBoundaries:te.pendingSuspenseBoundaries,transitions:te.transitions},f.updateQueue.baseState=P,f.memoizedState=P,f.flags&256){D=Wu(Error(t(423)),f),f=A1(u,f,E,v,D);break e}else if(E!==D){D=Wu(Error(t(424)),f),f=A1(u,f,E,v,D);break e}else for(Li=da(f.stateNode.containerInfo.firstChild),Pi=f,Gn=!0,Is=null,v=SC(f,null,E,v),f.child=v;v;)v.flags=v.flags&-3|4096,v=v.sibling;else{if($u(),E===D){f=eo(u,f,v);break e}si(u,f,E,v)}f=f.child}return f;case 5:return DC(f),u===null&&Iy(f),E=f.type,D=f.pendingProps,P=u!==null?u.memoizedProps:null,te=D.children,af(E,D)?te=null:P!==null&&af(E,P)&&(f.flags|=32),h1(u,f),si(u,f,te,v),f.child;case 6:return u===null&&Iy(f),null;case 13:return m1(u,f,v);case 4:return ky(f,f.stateNode.containerInfo),E=f.pendingProps,u===null?f.child=Gu(f,null,E,v):si(u,f,E,v),f.child;case 11:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),l1(u,f,E,D,v);case 7:return si(u,f,f.pendingProps,v),f.child;case 8:return si(u,f,f.pendingProps.children,v),f.child;case 12:return si(u,f,f.pendingProps.children,v),f.child;case 10:e:{if(E=f.type._context,D=f.pendingProps,P=f.memoizedProps,te=D.value,Tn(CA,E._currentValue),E._currentValue=te,P!==null)if(vi(P.value,te)){if(P.children===D.children&&!Gr.current){f=eo(u,f,v);break e}}else for(P=f.child,P!==null&&(P.return=f);P!==null;){var pe=P.dependencies;if(pe!==null){te=P.child;for(var we=pe.firstContext;we!==null;){if(we.context===E){if(P.tag===1){we=Za(-1,v&-v),we.tag=2;var Pe=P.updateQueue;if(Pe!==null){Pe=Pe.shared;var Xe=Pe.pending;Xe===null?we.next=we:(we.next=Xe.next,Xe.next=we),Pe.pending=we}}P.lanes|=v,we=P.alternate,we!==null&&(we.lanes|=v),Ty(P.return,v,f),pe.lanes|=v;break}we=we.next}}else if(P.tag===10)te=P.type===f.type?null:P.child;else if(P.tag===18){if(te=P.return,te===null)throw Error(t(341));te.lanes|=v,pe=te.alternate,pe!==null&&(pe.lanes|=v),Ty(te,v,f),te=P.sibling}else te=P.child;if(te!==null)te.return=P;else for(te=P;te!==null;){if(te===f){te=null;break}if(P=te.sibling,P!==null){P.return=te.return,te=P;break}te=te.return}P=te}si(u,f,D.children,v),f=f.child}return f;case 9:return D=f.type,E=f.pendingProps.children,Hu(f,v),D=Yi(D),E=E(D),f.flags|=1,si(u,f,E,v),f.child;case 14:return E=f.type,D=Cs(E,f.pendingProps),D=Cs(E.type,D),c1(u,f,E,D,v);case 15:return u1(u,f,f.type,f.pendingProps,v);case 17:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),FA(u,f),f.tag=1,Vr(E)?(u=!0,Ou(f)):u=!1,Hu(f,v),t1(f,E,D),jy(f,E,D,v),Yy(null,f,E,!0,u,v);case 19:return y1(u,f,v);case 22:return d1(u,f,v)}throw Error(t(156,f.tag))};function $1(u,f){return vs(u,f)}function Rz(u,f,v,E){this.tag=u,this.key=v,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ki(u,f,v,E){return new Rz(u,f,v,E)}function Ax(u){return u=u.prototype,!(!u||!u.isReactComponent)}function Dz(u){if(typeof u=="function")return Ax(u)?1:0;if(u!=null){if(u=u.$$typeof,u===Q)return 11;if(u===W)return 14}return 2}function fl(u,f){var v=u.alternate;return v===null?(v=Ki(u.tag,f,u.key,u.mode),v.elementType=u.elementType,v.type=u.type,v.stateNode=u.stateNode,v.alternate=u,u.alternate=v):(v.pendingProps=f,v.type=u.type,v.flags=0,v.subtreeFlags=0,v.deletions=null),v.flags=u.flags&14680064,v.childLanes=u.childLanes,v.lanes=u.lanes,v.child=u.child,v.memoizedProps=u.memoizedProps,v.memoizedState=u.memoizedState,v.updateQueue=u.updateQueue,f=u.dependencies,v.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},v.sibling=u.sibling,v.index=u.index,v.ref=u.ref,v}function YA(u,f,v,E,D,P){var te=2;if(E=u,typeof u=="function")Ax(u)&&(te=1);else if(typeof u=="string")te=5;else e:switch(u){case M:return Ac(v.children,D,P,f);case T:te=8,D|=8;break;case R:return u=Ki(12,v,f,D|2),u.elementType=R,u.lanes=P,u;case V:return u=Ki(13,v,f,D),u.elementType=V,u.lanes=P,u;case B:return u=Ki(19,v,f,D),u.elementType=B,u.lanes=P,u;case X:return XA(v,D,P,f);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case k:te=10;break e;case H:te=9;break e;case Q:te=11;break e;case W:te=14;break e;case K:te=16,E=null;break e}throw Error(t(130,u==null?u:typeof u,""))}return f=Ki(te,v,f,D),f.elementType=u,f.type=E,f.lanes=P,f}function Ac(u,f,v,E){return u=Ki(7,u,E,f),u.lanes=v,u}function XA(u,f,v,E){return u=Ki(22,u,E,f),u.elementType=X,u.lanes=v,u.stateNode={isHidden:!1},u}function mx(u,f,v){return u=Ki(6,u,null,f),u.lanes=v,u}function gx(u,f,v){return f=Ki(4,u.children!==null?u.children:[],u.key,f),f.lanes=v,f.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},f}function kz(u,f,v,E,D){this.tag=f,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Cn(0),this.expirationTimes=Cn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Cn(0),this.identifierPrefix=E,this.onRecoverableError=D,this.mutableSourceEagerHydrationData=null}function yx(u,f,v,E,D,P,te,pe,we){return u=new kz(u,f,v,pe,we),f===1?(f=1,P===!0&&(f|=8)):f=0,P=Ki(3,null,null,f),u.current=P,P.stateNode=u,P.memoizedState={element:E,isDehydrated:v,cache:null,transitions:null,pendingSuspenseBoundaries:null},Dy(P),u}function Nz(u,f,v){var E=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:S,key:E==null?null:""+E,children:u,containerInfo:f,implementation:v}}function G1(u){if(!u)return fa;u=u._reactInternals;e:{if(ki(u)!==u||u.tag!==1)throw Error(t(170));var f=u;do{switch(f.tag){case 3:f=f.stateNode.context;break e;case 1:if(Vr(f.type)){f=f.stateNode.__reactInternalMemoizedMergedChildContext;break e}}f=f.return}while(f!==null);throw Error(t(171))}if(u.tag===1){var v=u.type;if(Vr(v))return bA(u,v,f)}return f}function V1(u,f,v,E,D,P,te,pe,we){return u=yx(v,E,!0,u,D,P,te,pe,we),u.context=G1(null),v=u.current,E=ai(),D=dl(v),P=Za(E,D),P.callback=f??null,ol(v,P,D),u.current.lanes=D,Yn(u,D,E),wi(u,E),u}function JA(u,f,v,E){var D=f.current,P=ai(),te=dl(D);return v=G1(v),f.context===null?f.context=v:f.pendingContext=v,f=Za(P,te),f.payload={element:u},E=E===void 0?null:E,E!==null&&(f.callback=E),u=ol(D,f,te),u!==null&&(Ms(u,D,te,P),BA(u,D,te)),te}function KA(u){return u=u.current,u.child?(u.child.tag===5,u.child.stateNode):null}function H1(u,f){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var v=u.retryLane;u.retryLane=v!==0&&v<f?v:f}}function xx(u,f){H1(u,f),(u=u.alternate)&&H1(u,f)}function Qz(){return null}var j1=typeof reportError=="function"?reportError:function(u){};function vx(u){this._internalRoot=u}ZA.prototype.render=vx.prototype.render=function(u){var f=this._internalRoot;if(f===null)throw Error(t(409));JA(u,f,null,null)},ZA.prototype.unmount=vx.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var f=u.containerInfo;hc(function(){JA(null,u,null,null)}),f[ws]=null}};function ZA(u){this._internalRoot=u}ZA.prototype.unstable_scheduleHydration=function(u){if(u){var f=hu();u={blockedOn:null,target:u,priority:f};for(var v=0;v<_s.length&&f!==0&&f<_s[v].priority;v++);_s.splice(v,0,u),v===0&&Xp(u)}};function _x(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function em(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11&&(u.nodeType!==8||u.nodeValue!==" react-mount-point-unstable "))}function W1(){}function Pz(u,f,v,E,D){if(D){if(typeof E=="function"){var P=E;E=function(){var Pe=KA(te);P.call(Pe)}}var te=V1(f,E,u,0,null,!1,!1,"",W1);return u._reactRootContainer=te,u[ws]=te.current,el(u.nodeType===8?u.parentNode:u),hc(),te}for(;D=u.lastChild;)u.removeChild(D);if(typeof E=="function"){var pe=E;E=function(){var Pe=KA(we);pe.call(Pe)}}var we=yx(u,0,!1,null,null,!1,!1,"",W1);return u._reactRootContainer=we,u[ws]=we.current,el(u.nodeType===8?u.parentNode:u),hc(function(){JA(f,we,v,E)}),we}function tm(u,f,v,E,D){var P=v._reactRootContainer;if(P){var te=P;if(typeof D=="function"){var pe=D;D=function(){var we=KA(te);pe.call(we)}}JA(f,te,u,D)}else te=Pz(v,f,u,D,E);return KA(te)}yi=function(u){switch(u.tag){case 3:var f=u.stateNode;if(f.current.memoizedState.isDehydrated){var v=vn(f.pendingLanes);v!==0&&(Kn(f,v|1),wi(f,De()),(An&6)===0&&(Xu=De()+500,ue()))}break;case 13:hc(function(){var E=Ka(u,1);if(E!==null){var D=ai();Ms(E,u,1,D)}}),xx(u,1)}},zo=function(u){if(u.tag===13){var f=Ka(u,134217728);if(f!==null){var v=ai();Ms(f,u,134217728,v)}xx(u,134217728)}},Wp=function(u){if(u.tag===13){var f=dl(u),v=Ka(u,f);if(v!==null){var E=ai();Ms(v,u,f,E)}xx(u,f)}},hu=function(){return Gt},qp=function(u,f){var v=Gt;try{return Gt=u,f()}finally{Gt=v}},ut=function(u,f,v){switch(f){case"input":if(q(u,v),f=v.name,v.type==="radio"&&f!=null){for(v=u;v.parentNode;)v=v.parentNode;for(v=v.querySelectorAll("input[name="+JSON.stringify(""+f)+'][type="radio"]'),f=0;f<v.length;f++){var E=v[f];if(E!==u&&E.form===u.form){var D=zu(E);if(!D)throw Error(t(90));tt(E),q(E,D)}}}break;case"textarea":Y(u,v);break;case"select":f=v.value,f!=null&&ve(u,!!v.multiple,f,!1)}},Ot=hx,En=hc;var Lz={usingClientEntryPoint:!1,Events:[sc,rl,zu,Ve,_t,hx]},Ef={findFiberByHostInstance:Xa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Fz={bundleType:Ef.bundleType,version:Ef.version,rendererPackageName:Ef.rendererPackageName,rendererConfig:Ef.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:w.ReactCurrentDispatcher,findHostInstanceByFiber:function(u){return u=Po(u),u===null?null:u.stateNode},findFiberByHostInstance:Ef.findFiberByHostInstance||Qz,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nm.isDisabled&&nm.supportsFiber)try{Qt=nm.inject(Fz),St=nm}catch{}}return Ei.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Lz,Ei.createPortal=function(u,f){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_x(f))throw Error(t(200));return Nz(u,f,null,v)},Ei.createRoot=function(u,f){if(!_x(u))throw Error(t(299));var v=!1,E="",D=j1;return f!=null&&(f.unstable_strictMode===!0&&(v=!0),f.identifierPrefix!==void 0&&(E=f.identifierPrefix),f.onRecoverableError!==void 0&&(D=f.onRecoverableError)),f=yx(u,1,!1,null,null,v,!1,E,D),u[ws]=f.current,el(u.nodeType===8?u.parentNode:u),new vx(f)},Ei.findDOMNode=function(u){if(u==null)return null;if(u.nodeType===1)return u;var f=u._reactInternals;if(f===void 0)throw typeof u.render=="function"?Error(t(188)):(u=Object.keys(u).join(","),Error(t(268,u)));return u=Po(f),u=u===null?null:u.stateNode,u},Ei.flushSync=function(u){return hc(u)},Ei.hydrate=function(u,f,v){if(!em(f))throw Error(t(200));return tm(null,u,f,!0,v)},Ei.hydrateRoot=function(u,f,v){if(!_x(u))throw Error(t(405));var E=v!=null&&v.hydratedSources||null,D=!1,P="",te=j1;if(v!=null&&(v.unstable_strictMode===!0&&(D=!0),v.identifierPrefix!==void 0&&(P=v.identifierPrefix),v.onRecoverableError!==void 0&&(te=v.onRecoverableError)),f=V1(f,null,u,1,v??null,D,!1,P,te),u[ws]=f.current,el(u),E)for(u=0;u<E.length;u++)v=E[u],D=v._getVersion,D=D(v._source),f.mutableSourceEagerHydrationData==null?f.mutableSourceEagerHydrationData=[v,D]:f.mutableSourceEagerHydrationData.push(v,D);return new ZA(f)},Ei.render=function(u,f,v){if(!em(f))throw Error(t(200));return tm(null,u,f,!1,v)},Ei.unmountComponentAtNode=function(u){if(!em(u))throw Error(t(40));return u._reactRootContainer?(hc(function(){tm(null,null,u,!1,function(){u._reactRootContainer=null,u[ws]=null})}),!0):!1},Ei.unstable_batchedUpdates=hx,Ei.unstable_renderSubtreeIntoContainer=function(u,f,v,E){if(!em(v))throw Error(t(200));if(u==null||u._reactInternals===void 0)throw Error(t(38));return tm(u,f,v,!1,E)},Ei.version="18.3.1-next-f1338f8080-20240426",Ei}var t2;function iD(){if(t2)return Ex.exports;t2=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch{}}return n(),Ex.exports=jz(),Ex.exports}var n2;function Wz(){if(n2)return im;n2=1;var n=iD();return im.createRoot=n.createRoot,im.hydrateRoot=n.hydrateRoot,im}var qz=Wz(),ba=function(){return ba=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},ba.apply(this,arguments)};function sD(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function Yz(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return n.concat(s||Array.prototype.slice.call(e))}var cg="right-scroll-bar-position",ug="width-before-scroll-bar",Xz="with-scroll-bars-hidden",Jz="--removed-body-scroll-bar-size";function Sx(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function Kz(n,e){var t=U.useState(function(){return{value:n,callback:e,facade:{get current(){return t.value},set current(r){var i=t.value;i!==r&&(t.value=r,t.callback(r,i))}}}})[0];return t.callback=e,t.facade}var Zz=typeof window<"u"?U.useLayoutEffect:U.useEffect,r2=new WeakMap;function eU(n,e){var t=Kz(null,function(r){return n.forEach(function(i){return Sx(i,r)})});return Zz(function(){var r=r2.get(t);if(r){var i=new Set(r),s=new Set(n),a=t.current;i.forEach(function(o){s.has(o)||Sx(o,null)}),s.forEach(function(o){i.has(o)||Sx(o,a)})}r2.set(t,n)},[n]),t}function tU(n){return n}function nU(n,e){e===void 0&&(e=tU);var t=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return t.length?t[t.length-1]:n},useMedium:function(s){var a=e(s,r);return t.push(a),function(){t=t.filter(function(o){return o!==a})}},assignSyncMedium:function(s){for(r=!0;t.length;){var a=t;t=[],a.forEach(s)}t={push:function(o){return s(o)},filter:function(){return t}}},assignMedium:function(s){r=!0;var a=[];if(t.length){var o=t;t=[],o.forEach(s),a=t}var l=function(){var d=a;a=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),t={push:function(d){a.push(d),c()},filter:function(d){return a=a.filter(d),t}}}};return i}function rU(n){n===void 0&&(n={});var e=nU(null);return e.options=ba({async:!0,ssr:!1},n),e}var aD=function(n){var e=n.sideCar,t=sD(n,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return U.createElement(r,ba({},t))};aD.isSideCarExport=!0;function iU(n,e){return n.useMedium(e),aD}var oD=rU(),Bx=function(){},i0=U.forwardRef(function(n,e){var t=U.useRef(null),r=U.useState({onScrollCapture:Bx,onWheelCapture:Bx,onTouchMoveCapture:Bx}),i=r[0],s=r[1],a=n.forwardProps,o=n.children,l=n.className,c=n.removeScrollBar,d=n.enabled,h=n.shards,p=n.sideCar,A=n.noRelative,y=n.noIsolation,m=n.inert,x=n.allowPinchZoom,g=n.as,_=g===void 0?"div":g,b=n.gapMode,w=sD(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=p,S=eU([t,e]),M=ba(ba({},w),i);return U.createElement(U.Fragment,null,d&&U.createElement(I,{sideCar:oD,removeScrollBar:c,shards:h,noRelative:A,noIsolation:y,inert:m,setCallbacks:s,allowPinchZoom:!!x,lockRef:t,gapMode:b}),a?U.cloneElement(U.Children.only(o),ba(ba({},M),{ref:S})):U.createElement(_,ba({},M,{className:l,ref:S}),o))});i0.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};i0.classNames={fullWidth:ug,zeroRight:cg};var sU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function aU(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=sU();return e&&n.setAttribute("nonce",e),n}function oU(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function lU(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var cU=function(){var n=0,e=null;return{add:function(t){n==0&&(e=aU())&&(oU(e,t),lU(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},uU=function(){var n=cU();return function(e,t){U.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},lD=function(){var n=uU(),e=function(t){var r=t.styles,i=t.dynamic;return n(r,i),null};return e},dU={left:0,top:0,right:0,gap:0},Mx=function(n){return parseInt(n||"",10)||0},hU=function(n){var e=window.getComputedStyle(document.body),t=e[n==="padding"?"paddingLeft":"marginLeft"],r=e[n==="padding"?"paddingTop":"marginTop"],i=e[n==="padding"?"paddingRight":"marginRight"];return[Mx(t),Mx(r),Mx(i)]},fU=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return dU;var e=hU(n),t=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-t+e[2]-e[0])}},pU=lD(),Dd="data-scroll-locked",AU=function(n,e,t,r){var i=n.left,s=n.top,a=n.right,o=n.gap;return t===void 0&&(t="margin"),`
|
|
8
|
+
`+P.stack}return{value:u,source:f,stack:D,digest:null}}function Wy(u,f,v){return{value:u,source:null,stack:v??null,digest:f??null}}function Vne(u,f){}var pz=typeof WeakMap=="function"?WeakMap:Map;function r1(u,f,v){v=Za(-1,v),v.tag=3,v.payload={element:null};var E=f.value;return v.callback=function(){GA||(GA=!0,lx=E)},v}function i1(u,f,v){v=Za(-1,v),v.tag=3;var E=u.type.getDerivedStateFromError;if(typeof E=="function"){var D=f.value;v.payload=function(){return E(D)},v.callback=function(){}}var P=u.stateNode;return P!==null&&typeof P.componentDidCatch=="function"&&(v.callback=function(){typeof E!="function"&&(cl===null?cl=new Set([this]):cl.add(this));var te=f.stack;this.componentDidCatch(f.value,{componentStack:te!==null?te:""})}),v}function s1(u,f,v){var E=u.pingCache;if(E===null){E=u.pingCache=new pz;var D=new Set;E.set(f,D)}else D=E.get(f),D===void 0&&(D=new Set,E.set(f,D));D.has(v)||(D.add(v),u=Bz.bind(null,u,f,v),f.then(u,u))}function a1(u){do{var f;if((f=u.tag===13)&&(f=u.memoizedState,f=f!==null?f.dehydrated!==null:!0),f)return u;u=u.return}while(u!==null);return null}function o1(u,f,v,E,D){return(u.mode&1)===0?(u===f?u.flags|=65536:(u.flags|=128,v.flags|=131072,v.flags&=-52805,v.tag===1&&(v.alternate===null?v.tag=17:(f=Za(-1,1),f.tag=2,ol(v,f,1))),v.lanes|=1),u):(u.flags|=65536,u.lanes=D,u)}var Az=w.ReactCurrentOwner,_i=!1;function si(u,f,v,E){f.child=u===null?SC(f,null,v,E):Gu(f,u.child,v,E)}function l1(u,f,v,E,D){v=v.render;var P=f.ref;return Hu(f,D),E=zy(u,f,v,E,P,D),v=Uy(),u!==null&&!_i?(f.updateQueue=u.updateQueue,f.flags&=-2053,u.lanes&=~D,eo(u,f,D)):(Gn&&v&&oc(f),f.flags|=1,si(u,f,E,D),f.child)}function c1(u,f,v,E,D){if(u===null){var P=v.type;return typeof P=="function"&&!Ax(P)&&P.defaultProps===void 0&&v.compare===null&&v.defaultProps===void 0?(f.tag=15,f.type=P,u1(u,f,P,E,D)):(u=YA(v.type,null,E,f,f.mode,D),u.ref=f.ref,u.return=f,f.child=u)}if(P=u.child,(u.lanes&D)===0){var te=P.memoizedProps;if(v=v.compare,v=v!==null?v:Jo,v(te,E)&&u.ref===f.ref)return eo(u,f,D)}return f.flags|=1,u=fl(P,E),u.ref=f.ref,u.return=f,f.child=u}function u1(u,f,v,E,D){if(u!==null){var P=u.memoizedProps;if(Jo(P,E)&&u.ref===f.ref)if(_i=!1,f.pendingProps=E=P,(u.lanes&D)!==0)(u.flags&131072)!==0&&(_i=!0);else return f.lanes=u.lanes,eo(u,f,D)}return qy(u,f,v,E,D)}function d1(u,f,v){var E=f.pendingProps,D=E.children,P=u!==null?u.memoizedState:null;if(E.mode==="hidden")if((f.mode&1)===0)f.memoizedState={baseLanes:0,cachePool:null,transitions:null},Rn(Yu,Fi),Fi|=v;else{if((v&1073741824)===0)return u=P!==null?P.baseLanes|v:v,f.lanes=f.childLanes=1073741824,f.memoizedState={baseLanes:u,cachePool:null,transitions:null},f.updateQueue=null,Rn(Yu,Fi),Fi|=u,null;f.memoizedState={baseLanes:0,cachePool:null,transitions:null},E=P!==null?P.baseLanes:v,Rn(Yu,Fi),Fi|=E}else P!==null?(E=P.baseLanes|v,f.memoizedState=null):E=v,Rn(Yu,Fi),Fi|=E;return si(u,f,D,v),f.child}function h1(u,f){var v=f.ref;(u===null&&v!==null||u!==null&&u.ref!==v)&&(f.flags|=512,f.flags|=2097152)}function qy(u,f,v,E,D){var P=Vr(v)?Ja:br.current;return P=sl(f,P),Hu(f,D),v=zy(u,f,v,E,P,D),E=Uy(),u!==null&&!_i?(f.updateQueue=u.updateQueue,f.flags&=-2053,u.lanes&=~D,eo(u,f,D)):(Gn&&E&&oc(f),f.flags|=1,si(u,f,v,D),f.child)}function f1(u,f,v,E,D){if(Vr(v)){var P=!0;Ou(f)}else P=!1;if(Hu(f,D),f.stateNode===null)FA(u,f),t1(f,v,E),jy(f,v,E,D),E=!0;else if(u===null){var te=f.stateNode,pe=f.memoizedProps;te.props=pe;var we=te.context,Pe=v.contextType;typeof Pe=="object"&&Pe!==null?Pe=Yi(Pe):(Pe=Vr(v)?Ja:br.current,Pe=sl(f,Pe));var Xe=v.getDerivedStateFromProps,rt=typeof Xe=="function"||typeof te.getSnapshotBeforeUpdate=="function";rt||typeof te.UNSAFE_componentWillReceiveProps!="function"&&typeof te.componentWillReceiveProps!="function"||(pe!==E||we!==Pe)&&n1(f,te,E,Pe),al=!1;var qe=f.memoizedState;te.state=qe,MA(f,E,te,D),we=f.memoizedState,pe!==E||qe!==we||Gr.current||al?(typeof Xe=="function"&&(Hy(f,v,Xe,E),we=f.memoizedState),(pe=al||e1(f,v,pe,E,qe,we,Pe))?(rt||typeof te.UNSAFE_componentWillMount!="function"&&typeof te.componentWillMount!="function"||(typeof te.componentWillMount=="function"&&te.componentWillMount(),typeof te.UNSAFE_componentWillMount=="function"&&te.UNSAFE_componentWillMount()),typeof te.componentDidMount=="function"&&(f.flags|=4194308)):(typeof te.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=E,f.memoizedState=we),te.props=E,te.state=we,te.context=Pe,E=pe):(typeof te.componentDidMount=="function"&&(f.flags|=4194308),E=!1)}else{te=f.stateNode,MC(u,f),pe=f.memoizedProps,Pe=f.type===f.elementType?pe:Cs(f.type,pe),te.props=Pe,rt=f.pendingProps,qe=te.context,we=v.contextType,typeof we=="object"&&we!==null?we=Yi(we):(we=Vr(v)?Ja:br.current,we=sl(f,we));var yt=v.getDerivedStateFromProps;(Xe=typeof yt=="function"||typeof te.getSnapshotBeforeUpdate=="function")||typeof te.UNSAFE_componentWillReceiveProps!="function"&&typeof te.componentWillReceiveProps!="function"||(pe!==rt||qe!==we)&&n1(f,te,E,we),al=!1,qe=f.memoizedState,te.state=qe,MA(f,E,te,D);var Et=f.memoizedState;pe!==rt||qe!==Et||Gr.current||al?(typeof yt=="function"&&(Hy(f,v,yt,E),Et=f.memoizedState),(Pe=al||e1(f,v,Pe,E,qe,Et,we)||!1)?(Xe||typeof te.UNSAFE_componentWillUpdate!="function"&&typeof te.componentWillUpdate!="function"||(typeof te.componentWillUpdate=="function"&&te.componentWillUpdate(E,Et,we),typeof te.UNSAFE_componentWillUpdate=="function"&&te.UNSAFE_componentWillUpdate(E,Et,we)),typeof te.componentDidUpdate=="function"&&(f.flags|=4),typeof te.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof te.componentDidUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=4),typeof te.getSnapshotBeforeUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=1024),f.memoizedProps=E,f.memoizedState=Et),te.props=E,te.state=Et,te.context=we,E=Pe):(typeof te.componentDidUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=4),typeof te.getSnapshotBeforeUpdate!="function"||pe===u.memoizedProps&&qe===u.memoizedState||(f.flags|=1024),E=!1)}return Yy(u,f,v,E,P,D)}function Yy(u,f,v,E,D,P){h1(u,f);var te=(f.flags&128)!==0;if(!E&&!te)return D&&ac(f,v,!1),eo(u,f,P);E=f.stateNode,Az.current=f;var pe=te&&typeof v.getDerivedStateFromError!="function"?null:E.render();return f.flags|=1,u!==null&&te?(f.child=Gu(f,u.child,null,P),f.child=Gu(f,null,pe,P)):si(u,f,pe,P),f.memoizedState=E.state,D&&ac(f,v,!0),f.child}function p1(u){var f=u.stateNode;f.pendingContext?_A(u,f.pendingContext,f.pendingContext!==f.context):f.context&&_A(u,f.context,!1),ky(u,f.containerInfo)}function A1(u,f,v,E,D){return $u(),Cy(D),f.flags|=256,si(u,f,v,E),f.child}var Xy={dehydrated:null,treeContext:null,retryLane:0};function Jy(u){return{baseLanes:u,cachePool:null,transitions:null}}function m1(u,f,v){var E=f.pendingProps,D=Hn.current,P=!1,te=(f.flags&128)!==0,pe;if((pe=te)||(pe=u!==null&&u.memoizedState===null?!1:(D&2)!==0),pe?(P=!0,f.flags&=-129):(u===null||u.memoizedState!==null)&&(D|=1),Rn(Hn,D&1),u===null)return Iy(f),u=f.memoizedState,u!==null&&(u=u.dehydrated,u!==null)?((f.mode&1)===0?f.lanes=1:u.data==="$!"?f.lanes=8:f.lanes=1073741824,null):(te=E.children,u=E.fallback,P?(E=f.mode,P=f.child,te={mode:"hidden",children:te},(E&1)===0&&P!==null?(P.childLanes=0,P.pendingProps=te):P=XA(te,E,0,null),u=Ac(u,E,v,null),P.return=f,u.return=f,P.sibling=u,f.child=P,f.child.memoizedState=Jy(v),f.memoizedState=Xy,u):Ky(f,te));if(D=u.memoizedState,D!==null&&(pe=D.dehydrated,pe!==null))return mz(u,f,te,E,pe,D,v);if(P){P=E.fallback,te=f.mode,D=u.child,pe=D.sibling;var we={mode:"hidden",children:E.children};return(te&1)===0&&f.child!==D?(E=f.child,E.childLanes=0,E.pendingProps=we,f.deletions=null):(E=fl(D,we),E.subtreeFlags=D.subtreeFlags&14680064),pe!==null?P=fl(pe,P):(P=Ac(P,te,v,null),P.flags|=2),P.return=f,E.return=f,E.sibling=P,f.child=E,E=P,P=f.child,te=u.child.memoizedState,te=te===null?Jy(v):{baseLanes:te.baseLanes|v,cachePool:null,transitions:te.transitions},P.memoizedState=te,P.childLanes=u.childLanes&~v,f.memoizedState=Xy,E}return P=u.child,u=P.sibling,E=fl(P,{mode:"visible",children:E.children}),(f.mode&1)===0&&(E.lanes=v),E.return=f,E.sibling=null,u!==null&&(v=f.deletions,v===null?(f.deletions=[u],f.flags|=16):v.push(u)),f.child=E,f.memoizedState=null,E}function Ky(u,f){return f=XA({mode:"visible",children:f},u.mode,0,null),f.return=u,u.child=f}function LA(u,f,v,E){return E!==null&&Cy(E),Gu(f,u.child,null,v),u=Ky(f,f.pendingProps.children),u.flags|=2,f.memoizedState=null,u}function mz(u,f,v,E,D,P,te){if(v)return f.flags&256?(f.flags&=-257,E=Wy(Error(t(422))),LA(u,f,te,E)):f.memoizedState!==null?(f.child=u.child,f.flags|=128,null):(P=E.fallback,D=f.mode,E=XA({mode:"visible",children:E.children},D,0,null),P=Ac(P,D,te,null),P.flags|=2,E.return=f,P.return=f,E.sibling=P,f.child=E,(f.mode&1)!==0&&Gu(f,u.child,null,te),f.child.memoizedState=Jy(te),f.memoizedState=Xy,P);if((f.mode&1)===0)return LA(u,f,te,null);if(D.data==="$!"){if(E=D.nextSibling&&D.nextSibling.dataset,E)var pe=E.dgst;return E=pe,P=Error(t(419)),E=Wy(P,E,void 0),LA(u,f,te,E)}if(pe=(te&u.childLanes)!==0,_i||pe){if(E=Ir,E!==null){switch(te&-te){case 4:D=2;break;case 16:D=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:D=32;break;case 536870912:D=268435456;break;default:D=0}D=(D&(E.suspendedLanes|te))!==0?0:D,D!==0&&D!==P.retryLane&&(P.retryLane=D,Ka(u,D),Ms(E,u,D,-1))}return px(),E=Wy(Error(t(421))),LA(u,f,te,E)}return D.data==="$?"?(f.flags|=128,f.child=u.child,f=Mz.bind(null,u),D._reactRetry=f,null):(u=P.treeContext,Li=da(D.nextSibling),Pi=f,Gn=!0,Is=null,u!==null&&(Nt[Vt++]=ln,Nt[Vt++]=wr,Nt[Vt++]=on,ln=u.id,wr=u.overflow,on=f),f=Ky(f,E.children),f.flags|=4096,f)}function g1(u,f,v){u.lanes|=f;var E=u.alternate;E!==null&&(E.lanes|=f),Ty(u.return,f,v)}function Zy(u,f,v,E,D){var P=u.memoizedState;P===null?u.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:E,tail:v,tailMode:D}:(P.isBackwards=f,P.rendering=null,P.renderingStartTime=0,P.last=E,P.tail=v,P.tailMode=D)}function y1(u,f,v){var E=f.pendingProps,D=E.revealOrder,P=E.tail;if(si(u,f,E.children,v),E=Hn.current,(E&2)!==0)E=E&1|2,f.flags|=128;else{if(u!==null&&(u.flags&128)!==0)e:for(u=f.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&g1(u,v,f);else if(u.tag===19)g1(u,v,f);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===f)break e;for(;u.sibling===null;){if(u.return===null||u.return===f)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}E&=1}if(Rn(Hn,E),(f.mode&1)===0)f.memoizedState=null;else switch(D){case"forwards":for(v=f.child,D=null;v!==null;)u=v.alternate,u!==null&&TA(u)===null&&(D=v),v=v.sibling;v=D,v===null?(D=f.child,f.child=null):(D=v.sibling,v.sibling=null),Zy(f,!1,D,v,P);break;case"backwards":for(v=null,D=f.child,f.child=null;D!==null;){if(u=D.alternate,u!==null&&TA(u)===null){f.child=D;break}u=D.sibling,D.sibling=v,v=D,D=u}Zy(f,!0,v,null,P);break;case"together":Zy(f,!1,null,null,void 0);break;default:f.memoizedState=null}return f.child}function FA(u,f){(f.mode&1)===0&&u!==null&&(u.alternate=null,f.alternate=null,f.flags|=2)}function eo(u,f,v){if(u!==null&&(f.dependencies=u.dependencies),dc|=f.lanes,(v&f.childLanes)===0)return null;if(u!==null&&f.child!==u.child)throw Error(t(153));if(f.child!==null){for(u=f.child,v=fl(u,u.pendingProps),f.child=v,v.return=f;u.sibling!==null;)u=u.sibling,v=v.sibling=fl(u,u.pendingProps),v.return=f;v.sibling=null}return f.child}function gz(u,f,v){switch(f.tag){case 3:p1(f),$u();break;case 5:DC(f);break;case 1:Vr(f.type)&&Ou(f);break;case 4:ky(f,f.stateNode.containerInfo);break;case 10:var E=f.type._context,D=f.memoizedProps.value;Rn(CA,E._currentValue),E._currentValue=D;break;case 13:if(E=f.memoizedState,E!==null)return E.dehydrated!==null?(Rn(Hn,Hn.current&1),f.flags|=128,null):(v&f.child.childLanes)!==0?m1(u,f,v):(Rn(Hn,Hn.current&1),u=eo(u,f,v),u!==null?u.sibling:null);Rn(Hn,Hn.current&1);break;case 19:if(E=(v&f.childLanes)!==0,(u.flags&128)!==0){if(E)return y1(u,f,v);f.flags|=128}if(D=f.memoizedState,D!==null&&(D.rendering=null,D.tail=null,D.lastEffect=null),Rn(Hn,Hn.current),E)break;return null;case 22:case 23:return f.lanes=0,d1(u,f,v)}return eo(u,f,v)}var x1,ex,v1,_1;x1=function(u,f){for(var v=f.child;v!==null;){if(v.tag===5||v.tag===6)u.appendChild(v.stateNode);else if(v.tag!==4&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===f)break;for(;v.sibling===null;){if(v.return===null||v.return===f)return;v=v.return}v.sibling.return=v.return,v=v.sibling}},ex=function(){},v1=function(u,f,v,E){var D=u.memoizedProps;if(D!==E){u=f.stateNode,cc(pa.current);var P=null;switch(v){case"input":D=F(u,D),E=F(u,E),P=[];break;case"select":D=ne({},D,{value:void 0}),E=ne({},E,{value:void 0}),P=[];break;case"textarea":D=ce(u,D),E=ce(u,E),P=[];break;default:typeof D.onClick!="function"&&typeof E.onClick=="function"&&(u.onclick=Fu)}ft(v,E);var te;v=null;for(Pe in D)if(!E.hasOwnProperty(Pe)&&D.hasOwnProperty(Pe)&&D[Pe]!=null)if(Pe==="style"){var pe=D[Pe];for(te in pe)pe.hasOwnProperty(te)&&(v||(v={}),v[te]="")}else Pe!=="dangerouslySetInnerHTML"&&Pe!=="children"&&Pe!=="suppressContentEditableWarning"&&Pe!=="suppressHydrationWarning"&&Pe!=="autoFocus"&&(i.hasOwnProperty(Pe)?P||(P=[]):(P=P||[]).push(Pe,null));for(Pe in E){var we=E[Pe];if(pe=D?.[Pe],E.hasOwnProperty(Pe)&&we!==pe&&(we!=null||pe!=null))if(Pe==="style")if(pe){for(te in pe)!pe.hasOwnProperty(te)||we&&we.hasOwnProperty(te)||(v||(v={}),v[te]="");for(te in we)we.hasOwnProperty(te)&&pe[te]!==we[te]&&(v||(v={}),v[te]=we[te])}else v||(P||(P=[]),P.push(Pe,v)),v=we;else Pe==="dangerouslySetInnerHTML"?(we=we?we.__html:void 0,pe=pe?pe.__html:void 0,we!=null&&pe!==we&&(P=P||[]).push(Pe,we)):Pe==="children"?typeof we!="string"&&typeof we!="number"||(P=P||[]).push(Pe,""+we):Pe!=="suppressContentEditableWarning"&&Pe!=="suppressHydrationWarning"&&(i.hasOwnProperty(Pe)?(we!=null&&Pe==="onScroll"&&Tn("scroll",u),P||pe===we||(P=[])):(P=P||[]).push(Pe,we))}v&&(P=P||[]).push("style",v);var Pe=P;(f.updateQueue=Pe)&&(f.flags|=4)}},_1=function(u,f,v,E){v!==E&&(f.flags|=4)};function xf(u,f){if(!Gn)switch(u.tailMode){case"hidden":f=u.tail;for(var v=null;f!==null;)f.alternate!==null&&(v=f),f=f.sibling;v===null?u.tail=null:v.sibling=null;break;case"collapsed":v=u.tail;for(var E=null;v!==null;)v.alternate!==null&&(E=v),v=v.sibling;E===null?f||u.tail===null?u.tail=null:u.tail.sibling=null:E.sibling=null}}function jr(u){var f=u.alternate!==null&&u.alternate.child===u.child,v=0,E=0;if(f)for(var D=u.child;D!==null;)v|=D.lanes|D.childLanes,E|=D.subtreeFlags&14680064,E|=D.flags&14680064,D.return=u,D=D.sibling;else for(D=u.child;D!==null;)v|=D.lanes|D.childLanes,E|=D.subtreeFlags,E|=D.flags,D.return=u,D=D.sibling;return u.subtreeFlags|=E,u.childLanes=v,f}function yz(u,f,v){var E=f.pendingProps;switch(wy(f),f.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jr(f),null;case 1:return Vr(f.type)&&Uu(),jr(f),null;case 3:return E=f.stateNode,ju(),Pn(Gr),Pn(br),Py(),E.pendingContext&&(E.context=E.pendingContext,E.pendingContext=null),(u===null||u.child===null)&&(EA(f)?f.flags|=4:u===null||u.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,Is!==null&&(dx(Is),Is=null))),ex(u,f),jr(f),null;case 5:Ny(f);var D=cc(pf.current);if(v=f.type,u!==null&&f.stateNode!=null)v1(u,f,v,E,D),u.ref!==f.ref&&(f.flags|=512,f.flags|=2097152);else{if(!E){if(f.stateNode===null)throw Error(t(166));return jr(f),null}if(u=cc(pa.current),EA(f)){E=f.stateNode,v=f.type;var P=f.memoizedProps;switch(E[qi]=f,E[ic]=P,u=(f.mode&1)!==0,v){case"dialog":Tn("cancel",E),Tn("close",E);break;case"iframe":case"object":case"embed":Tn("load",E);break;case"video":case"audio":for(D=0;D<Zo.length;D++)Tn(Zo[D],E);break;case"source":Tn("error",E);break;case"img":case"image":case"link":Tn("error",E),Tn("load",E);break;case"details":Tn("toggle",E);break;case"input":re(E,P),Tn("invalid",E);break;case"select":E._wrapperState={wasMultiple:!!P.multiple},Tn("invalid",E);break;case"textarea":Z(E,P),Tn("invalid",E)}ft(v,P),D=null;for(var te in P)if(P.hasOwnProperty(te)){var pe=P[te];te==="children"?typeof pe=="string"?E.textContent!==pe&&(P.suppressHydrationWarning!==!0&&Lu(E.textContent,pe,u),D=["children",pe]):typeof pe=="number"&&E.textContent!==""+pe&&(P.suppressHydrationWarning!==!0&&Lu(E.textContent,pe,u),D=["children",""+pe]):i.hasOwnProperty(te)&&pe!=null&&te==="onScroll"&&Tn("scroll",E)}switch(v){case"input":Ne(E),ee(E,P,!0);break;case"textarea":Ne(E),le(E);break;case"select":case"option":break;default:typeof P.onClick=="function"&&(E.onclick=Fu)}E=D,f.updateQueue=E,E!==null&&(f.flags|=4)}else{te=D.nodeType===9?D:D.ownerDocument,u==="http://www.w3.org/1999/xhtml"&&(u=Ce(v)),u==="http://www.w3.org/1999/xhtml"?v==="script"?(u=te.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild)):typeof E.is=="string"?u=te.createElement(v,{is:E.is}):(u=te.createElement(v),v==="select"&&(te=u,E.multiple?te.multiple=!0:E.size&&(te.size=E.size))):u=te.createElementNS(u,v),u[qi]=f,u[ic]=E,x1(u,f,!1,!1),f.stateNode=u;e:{switch(te=dt(v,E),v){case"dialog":Tn("cancel",u),Tn("close",u),D=E;break;case"iframe":case"object":case"embed":Tn("load",u),D=E;break;case"video":case"audio":for(D=0;D<Zo.length;D++)Tn(Zo[D],u);D=E;break;case"source":Tn("error",u),D=E;break;case"img":case"image":case"link":Tn("error",u),Tn("load",u),D=E;break;case"details":Tn("toggle",u),D=E;break;case"input":re(u,E),D=F(u,E),Tn("invalid",u);break;case"option":D=E;break;case"select":u._wrapperState={wasMultiple:!!E.multiple},D=ne({},E,{value:void 0}),Tn("invalid",u);break;case"textarea":Z(u,E),D=ce(u,E),Tn("invalid",u);break;default:D=E}ft(v,D),pe=D;for(P in pe)if(pe.hasOwnProperty(P)){var we=pe[P];P==="style"?Ze(u,we):P==="dangerouslySetInnerHTML"?(we=we?we.__html:void 0,we!=null&&st(u,we)):P==="children"?typeof we=="string"?(v!=="textarea"||we!=="")&&He(u,we):typeof we=="number"&&He(u,""+we):P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&P!=="autoFocus"&&(i.hasOwnProperty(P)?we!=null&&P==="onScroll"&&Tn("scroll",u):we!=null&&b(u,P,we,te))}switch(v){case"input":Ne(u),ee(u,E,!1);break;case"textarea":Ne(u),le(u);break;case"option":E.value!=null&&u.setAttribute("value",""+Ie(E.value));break;case"select":u.multiple=!!E.multiple,P=E.value,P!=null?ve(u,!!E.multiple,P,!1):E.defaultValue!=null&&ve(u,!!E.multiple,E.defaultValue,!0);break;default:typeof D.onClick=="function"&&(u.onclick=Fu)}switch(v){case"button":case"input":case"select":case"textarea":E=!!E.autoFocus;break e;case"img":E=!0;break e;default:E=!1}}E&&(f.flags|=4)}f.ref!==null&&(f.flags|=512,f.flags|=2097152)}return jr(f),null;case 6:if(u&&f.stateNode!=null)_1(u,f,u.memoizedProps,E);else{if(typeof E!="string"&&f.stateNode===null)throw Error(t(166));if(v=cc(pf.current),cc(pa.current),EA(f)){if(E=f.stateNode,v=f.memoizedProps,E[qi]=f,(P=E.nodeValue!==v)&&(u=Pi,u!==null))switch(u.tag){case 3:Lu(E.nodeValue,v,(u.mode&1)!==0);break;case 5:u.memoizedProps.suppressHydrationWarning!==!0&&Lu(E.nodeValue,v,(u.mode&1)!==0)}P&&(f.flags|=4)}else E=(v.nodeType===9?v:v.ownerDocument).createTextNode(E),E[qi]=f,f.stateNode=E}return jr(f),null;case 13:if(Pn(Hn),E=f.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(Gn&&Li!==null&&(f.mode&1)!==0&&(f.flags&128)===0)EC(),$u(),f.flags|=98560,P=!1;else if(P=EA(f),E!==null&&E.dehydrated!==null){if(u===null){if(!P)throw Error(t(318));if(P=f.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(t(317));P[qi]=f}else $u(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;jr(f),P=!1}else Is!==null&&(dx(Is),Is=null),P=!0;if(!P)return f.flags&65536?f:null}return(f.flags&128)!==0?(f.lanes=v,f):(E=E!==null,E!==(u!==null&&u.memoizedState!==null)&&E&&(f.child.flags|=8192,(f.mode&1)!==0&&(u===null||(Hn.current&1)!==0?dr===0&&(dr=3):px())),f.updateQueue!==null&&(f.flags|=4),jr(f),null);case 4:return ju(),ex(u,f),u===null&&el(f.stateNode.containerInfo),jr(f),null;case 10:return My(f.type._context),jr(f),null;case 17:return Vr(f.type)&&Uu(),jr(f),null;case 19:if(Pn(Hn),P=f.memoizedState,P===null)return jr(f),null;if(E=(f.flags&128)!==0,te=P.rendering,te===null)if(E)xf(P,!1);else{if(dr!==0||u!==null&&(u.flags&128)!==0)for(u=f.child;u!==null;){if(te=TA(u),te!==null){for(f.flags|=128,xf(P,!1),E=te.updateQueue,E!==null&&(f.updateQueue=E,f.flags|=4),f.subtreeFlags=0,E=v,v=f.child;v!==null;)P=v,u=E,P.flags&=14680066,te=P.alternate,te===null?(P.childLanes=0,P.lanes=u,P.child=null,P.subtreeFlags=0,P.memoizedProps=null,P.memoizedState=null,P.updateQueue=null,P.dependencies=null,P.stateNode=null):(P.childLanes=te.childLanes,P.lanes=te.lanes,P.child=te.child,P.subtreeFlags=0,P.deletions=null,P.memoizedProps=te.memoizedProps,P.memoizedState=te.memoizedState,P.updateQueue=te.updateQueue,P.type=te.type,u=te.dependencies,P.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),v=v.sibling;return Rn(Hn,Hn.current&1|2),f.child}u=u.sibling}P.tail!==null&&De()>Xu&&(f.flags|=128,E=!0,xf(P,!1),f.lanes=4194304)}else{if(!E)if(u=TA(te),u!==null){if(f.flags|=128,E=!0,v=u.updateQueue,v!==null&&(f.updateQueue=v,f.flags|=4),xf(P,!0),P.tail===null&&P.tailMode==="hidden"&&!te.alternate&&!Gn)return jr(f),null}else 2*De()-P.renderingStartTime>Xu&&v!==1073741824&&(f.flags|=128,E=!0,xf(P,!1),f.lanes=4194304);P.isBackwards?(te.sibling=f.child,f.child=te):(v=P.last,v!==null?v.sibling=te:f.child=te,P.last=te)}return P.tail!==null?(f=P.tail,P.rendering=f,P.tail=f.sibling,P.renderingStartTime=De(),f.sibling=null,v=Hn.current,Rn(Hn,E?v&1|2:v&1),f):(jr(f),null);case 22:case 23:return fx(),E=f.memoizedState!==null,u!==null&&u.memoizedState!==null!==E&&(f.flags|=8192),E&&(f.mode&1)!==0?(Fi&1073741824)!==0&&(jr(f),f.subtreeFlags&6&&(f.flags|=8192)):jr(f),null;case 24:return null;case 25:return null}throw Error(t(156,f.tag))}function xz(u,f){switch(wy(f),f.tag){case 1:return Vr(f.type)&&Uu(),u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 3:return ju(),Pn(Gr),Pn(br),Py(),u=f.flags,(u&65536)!==0&&(u&128)===0?(f.flags=u&-65537|128,f):null;case 5:return Ny(f),null;case 13:if(Pn(Hn),u=f.memoizedState,u!==null&&u.dehydrated!==null){if(f.alternate===null)throw Error(t(340));$u()}return u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 19:return Pn(Hn),null;case 4:return ju(),null;case 10:return My(f.type._context),null;case 22:case 23:return fx(),null;case 24:return null;default:return null}}var zA=!1,Wr=!1,vz=typeof WeakSet=="function"?WeakSet:Set,bt=null;function qu(u,f){var v=u.ref;if(v!==null)if(typeof v=="function")try{v(null)}catch(E){Xn(u,f,E)}else v.current=null}function tx(u,f,v){try{v()}catch(E){Xn(u,f,E)}}var b1=!1;function _z(u,f){if(rf=mu,u=Vh(),Mu(u)){if("selectionStart"in u)var v={start:u.selectionStart,end:u.selectionEnd};else e:{v=(v=u.ownerDocument)&&v.defaultView||window;var E=v.getSelection&&v.getSelection();if(E&&E.rangeCount!==0){v=E.anchorNode;var D=E.anchorOffset,P=E.focusNode;E=E.focusOffset;try{v.nodeType,P.nodeType}catch{v=null;break e}var te=0,pe=-1,we=-1,Pe=0,Xe=0,rt=u,qe=null;t:for(;;){for(var yt;rt!==v||D!==0&&rt.nodeType!==3||(pe=te+D),rt!==P||E!==0&&rt.nodeType!==3||(we=te+E),rt.nodeType===3&&(te+=rt.nodeValue.length),(yt=rt.firstChild)!==null;)qe=rt,rt=yt;for(;;){if(rt===u)break t;if(qe===v&&++Pe===D&&(pe=te),qe===P&&++Xe===E&&(we=te),(yt=rt.nextSibling)!==null)break;rt=qe,qe=rt.parentNode}rt=yt}v=pe===-1||we===-1?null:{start:pe,end:we}}else v=null}v=v||{start:0,end:0}}else v=null;for(sf={focusedElem:u,selectionRange:v},mu=!1,bt=f;bt!==null;)if(f=bt,u=f.child,(f.subtreeFlags&1028)!==0&&u!==null)u.return=f,bt=u;else for(;bt!==null;){f=bt;try{var Et=f.alternate;if((f.flags&1024)!==0)switch(f.tag){case 0:case 11:case 15:break;case 1:if(Et!==null){var Ct=Et.memoizedProps,Zn=Et.memoizedState,ke=f.stateNode,Be=ke.getSnapshotBeforeUpdate(f.elementType===f.type?Ct:Cs(f.type,Ct),Zn);ke.__reactInternalSnapshotBeforeUpdate=Be}break;case 3:var Qe=f.stateNode.containerInfo;Qe.nodeType===1?Qe.textContent="":Qe.nodeType===9&&Qe.documentElement&&Qe.removeChild(Qe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ot){Xn(f,f.return,ot)}if(u=f.sibling,u!==null){u.return=f.return,bt=u;break}bt=f.return}return Et=b1,b1=!1,Et}function vf(u,f,v){var E=f.updateQueue;if(E=E!==null?E.lastEffect:null,E!==null){var D=E=E.next;do{if((D.tag&u)===u){var P=D.destroy;D.destroy=void 0,P!==void 0&&tx(f,v,P)}D=D.next}while(D!==E)}}function UA(u,f){if(f=f.updateQueue,f=f!==null?f.lastEffect:null,f!==null){var v=f=f.next;do{if((v.tag&u)===u){var E=v.create;v.destroy=E()}v=v.next}while(v!==f)}}function nx(u){var f=u.ref;if(f!==null){var v=u.stateNode;u.tag,u=v,typeof f=="function"?f(u):f.current=u}}function w1(u){var f=u.alternate;f!==null&&(u.alternate=null,w1(f)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(f=u.stateNode,f!==null&&(delete f[qi],delete f[ic],delete f[cf],delete f[_y],delete f[by])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function E1(u){return u.tag===5||u.tag===3||u.tag===4}function I1(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||E1(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function rx(u,f,v){var E=u.tag;if(E===5||E===6)u=u.stateNode,f?v.nodeType===8?v.parentNode.insertBefore(u,f):v.insertBefore(u,f):(v.nodeType===8?(f=v.parentNode,f.insertBefore(u,v)):(f=v,f.appendChild(u)),v=v._reactRootContainer,v!=null||f.onclick!==null||(f.onclick=Fu));else if(E!==4&&(u=u.child,u!==null))for(rx(u,f,v),u=u.sibling;u!==null;)rx(u,f,v),u=u.sibling}function ix(u,f,v){var E=u.tag;if(E===5||E===6)u=u.stateNode,f?v.insertBefore(u,f):v.appendChild(u);else if(E!==4&&(u=u.child,u!==null))for(ix(u,f,v),u=u.sibling;u!==null;)ix(u,f,v),u=u.sibling}var Qr=null,Ss=!1;function ll(u,f,v){for(v=v.child;v!==null;)C1(u,f,v),v=v.sibling}function C1(u,f,v){if(St&&typeof St.onCommitFiberUnmount=="function")try{St.onCommitFiberUnmount(Qt,v)}catch{}switch(v.tag){case 5:Wr||qu(v,f);case 6:var E=Qr,D=Ss;Qr=null,ll(u,f,v),Qr=E,Ss=D,Qr!==null&&(Ss?(u=Qr,v=v.stateNode,u.nodeType===8?u.parentNode.removeChild(v):u.removeChild(v)):Qr.removeChild(v.stateNode));break;case 18:Qr!==null&&(Ss?(u=Qr,v=v.stateNode,u.nodeType===8?lf(u.parentNode,v):u.nodeType===1&&lf(u,v),Va(u)):lf(Qr,v.stateNode));break;case 4:E=Qr,D=Ss,Qr=v.stateNode.containerInfo,Ss=!0,ll(u,f,v),Qr=E,Ss=D;break;case 0:case 11:case 14:case 15:if(!Wr&&(E=v.updateQueue,E!==null&&(E=E.lastEffect,E!==null))){D=E=E.next;do{var P=D,te=P.destroy;P=P.tag,te!==void 0&&((P&2)!==0||(P&4)!==0)&&tx(v,f,te),D=D.next}while(D!==E)}ll(u,f,v);break;case 1:if(!Wr&&(qu(v,f),E=v.stateNode,typeof E.componentWillUnmount=="function"))try{E.props=v.memoizedProps,E.state=v.memoizedState,E.componentWillUnmount()}catch(pe){Xn(v,f,pe)}ll(u,f,v);break;case 21:ll(u,f,v);break;case 22:v.mode&1?(Wr=(E=Wr)||v.memoizedState!==null,ll(u,f,v),Wr=E):ll(u,f,v);break;default:ll(u,f,v)}}function S1(u){var f=u.updateQueue;if(f!==null){u.updateQueue=null;var v=u.stateNode;v===null&&(v=u.stateNode=new vz),f.forEach(function(E){var D=Tz.bind(null,u,E);v.has(E)||(v.add(E),E.then(D,D))})}}function Bs(u,f){var v=f.deletions;if(v!==null)for(var E=0;E<v.length;E++){var D=v[E];try{var P=u,te=f,pe=te;e:for(;pe!==null;){switch(pe.tag){case 5:Qr=pe.stateNode,Ss=!1;break e;case 3:Qr=pe.stateNode.containerInfo,Ss=!0;break e;case 4:Qr=pe.stateNode.containerInfo,Ss=!0;break e}pe=pe.return}if(Qr===null)throw Error(t(160));C1(P,te,D),Qr=null,Ss=!1;var we=D.alternate;we!==null&&(we.return=null),D.return=null}catch(Pe){Xn(D,f,Pe)}}if(f.subtreeFlags&12854)for(f=f.child;f!==null;)B1(f,u),f=f.sibling}function B1(u,f){var v=u.alternate,E=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:if(Bs(f,u),ma(u),E&4){try{vf(3,u,u.return),UA(3,u)}catch(Ct){Xn(u,u.return,Ct)}try{vf(5,u,u.return)}catch(Ct){Xn(u,u.return,Ct)}}break;case 1:Bs(f,u),ma(u),E&512&&v!==null&&qu(v,v.return);break;case 5:if(Bs(f,u),ma(u),E&512&&v!==null&&qu(v,v.return),u.flags&32){var D=u.stateNode;try{He(D,"")}catch(Ct){Xn(u,u.return,Ct)}}if(E&4&&(D=u.stateNode,D!=null)){var P=u.memoizedProps,te=v!==null?v.memoizedProps:P,pe=u.type,we=u.updateQueue;if(u.updateQueue=null,we!==null)try{pe==="input"&&P.type==="radio"&&P.name!=null&&Ee(D,P),dt(pe,te);var Pe=dt(pe,P);for(te=0;te<we.length;te+=2){var Xe=we[te],rt=we[te+1];Xe==="style"?Ze(D,rt):Xe==="dangerouslySetInnerHTML"?st(D,rt):Xe==="children"?He(D,rt):b(D,Xe,rt,Pe)}switch(pe){case"input":q(D,P);break;case"textarea":Y(D,P);break;case"select":var qe=D._wrapperState.wasMultiple;D._wrapperState.wasMultiple=!!P.multiple;var yt=P.value;yt!=null?ve(D,!!P.multiple,yt,!1):qe!==!!P.multiple&&(P.defaultValue!=null?ve(D,!!P.multiple,P.defaultValue,!0):ve(D,!!P.multiple,P.multiple?[]:"",!1))}D[ic]=P}catch(Ct){Xn(u,u.return,Ct)}}break;case 6:if(Bs(f,u),ma(u),E&4){if(u.stateNode===null)throw Error(t(162));D=u.stateNode,P=u.memoizedProps;try{D.nodeValue=P}catch(Ct){Xn(u,u.return,Ct)}}break;case 3:if(Bs(f,u),ma(u),E&4&&v!==null&&v.memoizedState.isDehydrated)try{Va(f.containerInfo)}catch(Ct){Xn(u,u.return,Ct)}break;case 4:Bs(f,u),ma(u);break;case 13:Bs(f,u),ma(u),D=u.child,D.flags&8192&&(P=D.memoizedState!==null,D.stateNode.isHidden=P,!P||D.alternate!==null&&D.alternate.memoizedState!==null||(ox=De())),E&4&&S1(u);break;case 22:if(Xe=v!==null&&v.memoizedState!==null,u.mode&1?(Wr=(Pe=Wr)||Xe,Bs(f,u),Wr=Pe):Bs(f,u),ma(u),E&8192){if(Pe=u.memoizedState!==null,(u.stateNode.isHidden=Pe)&&!Xe&&(u.mode&1)!==0)for(bt=u,Xe=u.child;Xe!==null;){for(rt=bt=Xe;bt!==null;){switch(qe=bt,yt=qe.child,qe.tag){case 0:case 11:case 14:case 15:vf(4,qe,qe.return);break;case 1:qu(qe,qe.return);var Et=qe.stateNode;if(typeof Et.componentWillUnmount=="function"){E=qe,v=qe.return;try{f=E,Et.props=f.memoizedProps,Et.state=f.memoizedState,Et.componentWillUnmount()}catch(Ct){Xn(E,v,Ct)}}break;case 5:qu(qe,qe.return);break;case 22:if(qe.memoizedState!==null){R1(rt);continue}}yt!==null?(yt.return=qe,bt=yt):R1(rt)}Xe=Xe.sibling}e:for(Xe=null,rt=u;;){if(rt.tag===5){if(Xe===null){Xe=rt;try{D=rt.stateNode,Pe?(P=D.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none"):(pe=rt.stateNode,we=rt.memoizedProps.style,te=we!=null&&we.hasOwnProperty("display")?we.display:null,pe.style.display=ze("display",te))}catch(Ct){Xn(u,u.return,Ct)}}}else if(rt.tag===6){if(Xe===null)try{rt.stateNode.nodeValue=Pe?"":rt.memoizedProps}catch(Ct){Xn(u,u.return,Ct)}}else if((rt.tag!==22&&rt.tag!==23||rt.memoizedState===null||rt===u)&&rt.child!==null){rt.child.return=rt,rt=rt.child;continue}if(rt===u)break e;for(;rt.sibling===null;){if(rt.return===null||rt.return===u)break e;Xe===rt&&(Xe=null),rt=rt.return}Xe===rt&&(Xe=null),rt.sibling.return=rt.return,rt=rt.sibling}}break;case 19:Bs(f,u),ma(u),E&4&&S1(u);break;case 21:break;default:Bs(f,u),ma(u)}}function ma(u){var f=u.flags;if(f&2){try{e:{for(var v=u.return;v!==null;){if(E1(v)){var E=v;break e}v=v.return}throw Error(t(160))}switch(E.tag){case 5:var D=E.stateNode;E.flags&32&&(He(D,""),E.flags&=-33);var P=I1(u);ix(u,P,D);break;case 3:case 4:var te=E.stateNode.containerInfo,pe=I1(u);rx(u,pe,te);break;default:throw Error(t(161))}}catch(we){Xn(u,u.return,we)}u.flags&=-3}f&4096&&(u.flags&=-4097)}function bz(u,f,v){bt=u,M1(u)}function M1(u,f,v){for(var E=(u.mode&1)!==0;bt!==null;){var D=bt,P=D.child;if(D.tag===22&&E){var te=D.memoizedState!==null||zA;if(!te){var pe=D.alternate,we=pe!==null&&pe.memoizedState!==null||Wr;pe=zA;var Pe=Wr;if(zA=te,(Wr=we)&&!Pe)for(bt=D;bt!==null;)te=bt,we=te.child,te.tag===22&&te.memoizedState!==null?D1(D):we!==null?(we.return=te,bt=we):D1(D);for(;P!==null;)bt=P,M1(P),P=P.sibling;bt=D,zA=pe,Wr=Pe}T1(u)}else(D.subtreeFlags&8772)!==0&&P!==null?(P.return=D,bt=P):T1(u)}}function T1(u){for(;bt!==null;){var f=bt;if((f.flags&8772)!==0){var v=f.alternate;try{if((f.flags&8772)!==0)switch(f.tag){case 0:case 11:case 15:Wr||UA(5,f);break;case 1:var E=f.stateNode;if(f.flags&4&&!Wr)if(v===null)E.componentDidMount();else{var D=f.elementType===f.type?v.memoizedProps:Cs(f.type,v.memoizedProps);E.componentDidUpdate(D,v.memoizedState,E.__reactInternalSnapshotBeforeUpdate)}var P=f.updateQueue;P!==null&&RC(f,P,E);break;case 3:var te=f.updateQueue;if(te!==null){if(v=null,f.child!==null)switch(f.child.tag){case 5:v=f.child.stateNode;break;case 1:v=f.child.stateNode}RC(f,te,v)}break;case 5:var pe=f.stateNode;if(v===null&&f.flags&4){v=pe;var we=f.memoizedProps;switch(f.type){case"button":case"input":case"select":case"textarea":we.autoFocus&&v.focus();break;case"img":we.src&&(v.src=we.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(f.memoizedState===null){var Pe=f.alternate;if(Pe!==null){var Xe=Pe.memoizedState;if(Xe!==null){var rt=Xe.dehydrated;rt!==null&&Va(rt)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}Wr||f.flags&512&&nx(f)}catch(qe){Xn(f,f.return,qe)}}if(f===u){bt=null;break}if(v=f.sibling,v!==null){v.return=f.return,bt=v;break}bt=f.return}}function R1(u){for(;bt!==null;){var f=bt;if(f===u){bt=null;break}var v=f.sibling;if(v!==null){v.return=f.return,bt=v;break}bt=f.return}}function D1(u){for(;bt!==null;){var f=bt;try{switch(f.tag){case 0:case 11:case 15:var v=f.return;try{UA(4,f)}catch(we){Xn(f,v,we)}break;case 1:var E=f.stateNode;if(typeof E.componentDidMount=="function"){var D=f.return;try{E.componentDidMount()}catch(we){Xn(f,D,we)}}var P=f.return;try{nx(f)}catch(we){Xn(f,P,we)}break;case 5:var te=f.return;try{nx(f)}catch(we){Xn(f,te,we)}}}catch(we){Xn(f,f.return,we)}if(f===u){bt=null;break}var pe=f.sibling;if(pe!==null){pe.return=f.return,bt=pe;break}bt=f.return}}var wz=Math.ceil,OA=w.ReactCurrentDispatcher,sx=w.ReactCurrentOwner,Ji=w.ReactCurrentBatchConfig,An=0,Ir=null,nr=null,Pr=0,Fi=0,Yu=ha(0),dr=0,_f=null,dc=0,$A=0,ax=0,bf=null,bi=null,ox=0,Xu=1/0,to=null,GA=!1,lx=null,cl=null,VA=!1,ul=null,HA=0,wf=0,cx=null,jA=-1,WA=0;function ai(){return(An&6)!==0?De():jA!==-1?jA:jA=De()}function dl(u){return(u.mode&1)===0?1:(An&2)!==0&&Pr!==0?Pr&-Pr:az.transition!==null?(WA===0&&(WA=oa()),WA):(u=Gt,u!==0||(u=window.event,u=u===void 0?16:Zp(u.type)),u)}function Ms(u,f,v,E){if(50<wf)throw wf=0,cx=null,Error(t(185));Yn(u,v,E),((An&2)===0||u!==Ir)&&(u===Ir&&((An&2)===0&&($A|=v),dr===4&&hl(u,Pr)),wi(u,E),v===1&&An===0&&(f.mode&1)===0&&(Xu=De()+500,N&&ue()))}function wi(u,f){var v=u.callbackNode;aa(u,f);var E=tn(u,u===Ir?Pr:0);if(E===0)v!==null&&gi(v),u.callbackNode=null,u.callbackPriority=0;else if(f=E&-E,u.callbackPriority!==f){if(v!=null&&gi(v),f===1)u.tag===0?se(N1.bind(null,u)):z(N1.bind(null,u)),xy(function(){(An&6)===0&&ue()}),v=null;else{switch(Fo(E)){case 1:v=Me;break;case 4:v=at;break;case 16:v=lt;break;case 536870912:v=gt;break;default:v=lt}v=$1(v,k1.bind(null,u))}u.callbackPriority=f,u.callbackNode=v}}function k1(u,f){if(jA=-1,WA=0,(An&6)!==0)throw Error(t(327));var v=u.callbackNode;if(Ju()&&u.callbackNode!==v)return null;var E=tn(u,u===Ir?Pr:0);if(E===0)return null;if((E&30)!==0||(E&u.expiredLanes)!==0||f)f=qA(u,E);else{f=E;var D=An;An|=2;var P=P1();(Ir!==u||Pr!==f)&&(to=null,Xu=De()+500,fc(u,f));do try{Cz();break}catch(pe){Q1(u,pe)}while(!0);By(),OA.current=P,An=D,nr!==null?f=0:(Ir=null,Pr=0,f=dr)}if(f!==0){if(f===2&&(D=cr(u),D!==0&&(E=D,f=ux(u,D))),f===1)throw v=_f,fc(u,0),hl(u,E),wi(u,De()),v;if(f===6)hl(u,E);else{if(D=u.current.alternate,(E&30)===0&&!Ez(D)&&(f=qA(u,E),f===2&&(P=cr(u),P!==0&&(E=P,f=ux(u,P))),f===1))throw v=_f,fc(u,0),hl(u,E),wi(u,De()),v;switch(u.finishedWork=D,u.finishedLanes=E,f){case 0:case 1:throw Error(t(345));case 2:pc(u,bi,to);break;case 3:if(hl(u,E),(E&130023424)===E&&(f=ox+500-De(),10<f)){if(tn(u,0)!==0)break;if(D=u.suspendedLanes,(D&E)!==E){ai(),u.pingedLanes|=u.suspendedLanes&D;break}u.timeoutHandle=of(pc.bind(null,u,bi,to),f);break}pc(u,bi,to);break;case 4:if(hl(u,E),(E&4194240)===E)break;for(f=u.eventTimes,D=-1;0<E;){var te=31-$t(E);P=1<<te,te=f[te],te>D&&(D=te),E&=~P}if(E=D,E=De()-E,E=(120>E?120:480>E?480:1080>E?1080:1920>E?1920:3e3>E?3e3:4320>E?4320:1960*wz(E/1960))-E,10<E){u.timeoutHandle=of(pc.bind(null,u,bi,to),E);break}pc(u,bi,to);break;case 5:pc(u,bi,to);break;default:throw Error(t(329))}}}return wi(u,De()),u.callbackNode===v?k1.bind(null,u):null}function ux(u,f){var v=bf;return u.current.memoizedState.isDehydrated&&(fc(u,f).flags|=256),u=qA(u,f),u!==2&&(f=bi,bi=v,f!==null&&dx(f)),u}function dx(u){bi===null?bi=u:bi.push.apply(bi,u)}function Ez(u){for(var f=u;;){if(f.flags&16384){var v=f.updateQueue;if(v!==null&&(v=v.stores,v!==null))for(var E=0;E<v.length;E++){var D=v[E],P=D.getSnapshot;D=D.value;try{if(!vi(P(),D))return!1}catch{return!1}}}if(v=f.child,f.subtreeFlags&16384&&v!==null)v.return=f,f=v;else{if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return!0;f=f.return}f.sibling.return=f.return,f=f.sibling}}return!0}function hl(u,f){for(f&=~ax,f&=~$A,u.suspendedLanes|=f,u.pingedLanes&=~f,u=u.expirationTimes;0<f;){var v=31-$t(f),E=1<<v;u[v]=-1,f&=~E}}function N1(u){if((An&6)!==0)throw Error(t(327));Ju();var f=tn(u,0);if((f&1)===0)return wi(u,De()),null;var v=qA(u,f);if(u.tag!==0&&v===2){var E=cr(u);E!==0&&(f=E,v=ux(u,E))}if(v===1)throw v=_f,fc(u,0),hl(u,f),wi(u,De()),v;if(v===6)throw Error(t(345));return u.finishedWork=u.current.alternate,u.finishedLanes=f,pc(u,bi,to),wi(u,De()),null}function hx(u,f){var v=An;An|=1;try{return u(f)}finally{An=v,An===0&&(Xu=De()+500,N&&ue())}}function hc(u){ul!==null&&ul.tag===0&&(An&6)===0&&Ju();var f=An;An|=1;var v=Ji.transition,E=Gt;try{if(Ji.transition=null,Gt=1,u)return u()}finally{Gt=E,Ji.transition=v,An=f,(An&6)===0&&ue()}}function fx(){Fi=Yu.current,Pn(Yu)}function fc(u,f){u.finishedWork=null,u.finishedLanes=0;var v=u.timeoutHandle;if(v!==-1&&(u.timeoutHandle=-1,yy(v)),nr!==null)for(v=nr.return;v!==null;){var E=v;switch(wy(E),E.tag){case 1:E=E.type.childContextTypes,E!=null&&Uu();break;case 3:ju(),Pn(Gr),Pn(br),Py();break;case 5:Ny(E);break;case 4:ju();break;case 13:Pn(Hn);break;case 19:Pn(Hn);break;case 10:My(E.type._context);break;case 22:case 23:fx()}v=v.return}if(Ir=u,nr=u=fl(u.current,null),Pr=Fi=f,dr=0,_f=null,ax=$A=dc=0,bi=bf=null,lc!==null){for(f=0;f<lc.length;f++)if(v=lc[f],E=v.interleaved,E!==null){v.interleaved=null;var D=E.next,P=v.pending;if(P!==null){var te=P.next;P.next=D,E.next=te}v.pending=E}lc=null}return u}function Q1(u,f){do{var v=nr;try{if(By(),RA.current=QA,DA){for(var E=jn.memoizedState;E!==null;){var D=E.queue;D!==null&&(D.pending=null),E=E.next}DA=!1}if(uc=0,Er=ur=jn=null,Af=!1,mf=0,sx.current=null,v===null||v.return===null){dr=1,_f=f,nr=null;break}e:{var P=u,te=v.return,pe=v,we=f;if(f=Pr,pe.flags|=32768,we!==null&&typeof we=="object"&&typeof we.then=="function"){var Pe=we,Xe=pe,rt=Xe.tag;if((Xe.mode&1)===0&&(rt===0||rt===11||rt===15)){var qe=Xe.alternate;qe?(Xe.updateQueue=qe.updateQueue,Xe.memoizedState=qe.memoizedState,Xe.lanes=qe.lanes):(Xe.updateQueue=null,Xe.memoizedState=null)}var yt=a1(te);if(yt!==null){yt.flags&=-257,o1(yt,te,pe,P,f),yt.mode&1&&s1(P,Pe,f),f=yt,we=Pe;var Et=f.updateQueue;if(Et===null){var Ct=new Set;Ct.add(we),f.updateQueue=Ct}else Et.add(we);break e}else{if((f&1)===0){s1(P,Pe,f),px();break e}we=Error(t(426))}}else if(Gn&&pe.mode&1){var Zn=a1(te);if(Zn!==null){(Zn.flags&65536)===0&&(Zn.flags|=256),o1(Zn,te,pe,P,f),Cy(Wu(we,pe));break e}}P=we=Wu(we,pe),dr!==4&&(dr=2),bf===null?bf=[P]:bf.push(P),P=te;do{switch(P.tag){case 3:P.flags|=65536,f&=-f,P.lanes|=f;var ke=r1(P,we,f);TC(P,ke);break e;case 1:pe=we;var Be=P.type,Qe=P.stateNode;if((P.flags&128)===0&&(typeof Be.getDerivedStateFromError=="function"||Qe!==null&&typeof Qe.componentDidCatch=="function"&&(cl===null||!cl.has(Qe)))){P.flags|=65536,f&=-f,P.lanes|=f;var ot=i1(P,pe,f);TC(P,ot);break e}}P=P.return}while(P!==null)}F1(v)}catch(Bt){f=Bt,nr===v&&v!==null&&(nr=v=v.return);continue}break}while(!0)}function P1(){var u=OA.current;return OA.current=QA,u===null?QA:u}function px(){(dr===0||dr===3||dr===2)&&(dr=4),Ir===null||(dc&268435455)===0&&($A&268435455)===0||hl(Ir,Pr)}function qA(u,f){var v=An;An|=2;var E=P1();(Ir!==u||Pr!==f)&&(to=null,fc(u,f));do try{Iz();break}catch(D){Q1(u,D)}while(!0);if(By(),An=v,OA.current=E,nr!==null)throw Error(t(261));return Ir=null,Pr=0,dr}function Iz(){for(;nr!==null;)L1(nr)}function Cz(){for(;nr!==null&&!ae();)L1(nr)}function L1(u){var f=O1(u.alternate,u,Fi);u.memoizedProps=u.pendingProps,f===null?F1(u):nr=f,sx.current=null}function F1(u){var f=u;do{var v=f.alternate;if(u=f.return,(f.flags&32768)===0){if(v=yz(v,f,Fi),v!==null){nr=v;return}}else{if(v=xz(v,f),v!==null){v.flags&=32767,nr=v;return}if(u!==null)u.flags|=32768,u.subtreeFlags=0,u.deletions=null;else{dr=6,nr=null;return}}if(f=f.sibling,f!==null){nr=f;return}nr=f=u}while(f!==null);dr===0&&(dr=5)}function pc(u,f,v){var E=Gt,D=Ji.transition;try{Ji.transition=null,Gt=1,Sz(u,f,v,E)}finally{Ji.transition=D,Gt=E}return null}function Sz(u,f,v,E){do Ju();while(ul!==null);if((An&6)!==0)throw Error(t(327));v=u.finishedWork;var D=u.finishedLanes;if(v===null)return null;if(u.finishedWork=null,u.finishedLanes=0,v===u.current)throw Error(t(177));u.callbackNode=null,u.callbackPriority=0;var P=v.lanes|v.childLanes;if(Or(u,P),u===Ir&&(nr=Ir=null,Pr=0),(v.subtreeFlags&2064)===0&&(v.flags&2064)===0||VA||(VA=!0,$1(lt,function(){return Ju(),null})),P=(v.flags&15990)!==0,(v.subtreeFlags&15990)!==0||P){P=Ji.transition,Ji.transition=null;var te=Gt;Gt=1;var pe=An;An|=4,sx.current=null,_z(u,v),B1(v,u),fA(sf),mu=!!rf,sf=rf=null,u.current=v,bz(v),Te(),An=pe,Gt=te,Ji.transition=P}else u.current=v;if(VA&&(VA=!1,ul=u,HA=D),P=u.pendingLanes,P===0&&(cl=null),kt(v.stateNode),wi(u,De()),f!==null)for(E=u.onRecoverableError,v=0;v<f.length;v++)D=f[v],E(D.value,{componentStack:D.stack,digest:D.digest});if(GA)throw GA=!1,u=lx,lx=null,u;return(HA&1)!==0&&u.tag!==0&&Ju(),P=u.pendingLanes,(P&1)!==0?u===cx?wf++:(wf=0,cx=u):wf=0,ue(),null}function Ju(){if(ul!==null){var u=Fo(HA),f=Ji.transition,v=Gt;try{if(Ji.transition=null,Gt=16>u?16:u,ul===null)var E=!1;else{if(u=ul,ul=null,HA=0,(An&6)!==0)throw Error(t(331));var D=An;for(An|=4,bt=u.current;bt!==null;){var P=bt,te=P.child;if((bt.flags&16)!==0){var pe=P.deletions;if(pe!==null){for(var we=0;we<pe.length;we++){var Pe=pe[we];for(bt=Pe;bt!==null;){var Xe=bt;switch(Xe.tag){case 0:case 11:case 15:vf(8,Xe,P)}var rt=Xe.child;if(rt!==null)rt.return=Xe,bt=rt;else for(;bt!==null;){Xe=bt;var qe=Xe.sibling,yt=Xe.return;if(w1(Xe),Xe===Pe){bt=null;break}if(qe!==null){qe.return=yt,bt=qe;break}bt=yt}}}var Et=P.alternate;if(Et!==null){var Ct=Et.child;if(Ct!==null){Et.child=null;do{var Zn=Ct.sibling;Ct.sibling=null,Ct=Zn}while(Ct!==null)}}bt=P}}if((P.subtreeFlags&2064)!==0&&te!==null)te.return=P,bt=te;else e:for(;bt!==null;){if(P=bt,(P.flags&2048)!==0)switch(P.tag){case 0:case 11:case 15:vf(9,P,P.return)}var ke=P.sibling;if(ke!==null){ke.return=P.return,bt=ke;break e}bt=P.return}}var Be=u.current;for(bt=Be;bt!==null;){te=bt;var Qe=te.child;if((te.subtreeFlags&2064)!==0&&Qe!==null)Qe.return=te,bt=Qe;else e:for(te=Be;bt!==null;){if(pe=bt,(pe.flags&2048)!==0)try{switch(pe.tag){case 0:case 11:case 15:UA(9,pe)}}catch(Bt){Xn(pe,pe.return,Bt)}if(pe===te){bt=null;break e}var ot=pe.sibling;if(ot!==null){ot.return=pe.return,bt=ot;break e}bt=pe.return}}if(An=D,ue(),St&&typeof St.onPostCommitFiberRoot=="function")try{St.onPostCommitFiberRoot(Qt,u)}catch{}E=!0}return E}finally{Gt=v,Ji.transition=f}}return!1}function z1(u,f,v){f=Wu(v,f),f=r1(u,f,1),u=ol(u,f,1),f=ai(),u!==null&&(Yn(u,1,f),wi(u,f))}function Xn(u,f,v){if(u.tag===3)z1(u,u,v);else for(;f!==null;){if(f.tag===3){z1(f,u,v);break}else if(f.tag===1){var E=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof E.componentDidCatch=="function"&&(cl===null||!cl.has(E))){u=Wu(v,u),u=i1(f,u,1),f=ol(f,u,1),u=ai(),f!==null&&(Yn(f,1,u),wi(f,u));break}}f=f.return}}function Bz(u,f,v){var E=u.pingCache;E!==null&&E.delete(f),f=ai(),u.pingedLanes|=u.suspendedLanes&v,Ir===u&&(Pr&v)===v&&(dr===4||dr===3&&(Pr&130023424)===Pr&&500>De()-ox?fc(u,0):ax|=v),wi(u,f)}function U1(u,f){f===0&&((u.mode&1)===0?f=1:(f=Rt,Rt<<=1,(Rt&130023424)===0&&(Rt=4194304)));var v=ai();u=Ka(u,f),u!==null&&(Yn(u,f,v),wi(u,v))}function Mz(u){var f=u.memoizedState,v=0;f!==null&&(v=f.retryLane),U1(u,v)}function Tz(u,f){var v=0;switch(u.tag){case 13:var E=u.stateNode,D=u.memoizedState;D!==null&&(v=D.retryLane);break;case 19:E=u.stateNode;break;default:throw Error(t(314))}E!==null&&E.delete(f),U1(u,v)}var O1;O1=function(u,f,v){if(u!==null)if(u.memoizedProps!==f.pendingProps||Gr.current)_i=!0;else{if((u.lanes&v)===0&&(f.flags&128)===0)return _i=!1,gz(u,f,v);_i=(u.flags&131072)!==0}else _i=!1,Gn&&(f.flags&1048576)!==0&&wA(f,ht,f.index);switch(f.lanes=0,f.tag){case 2:var E=f.type;FA(u,f),u=f.pendingProps;var D=sl(f,br.current);Hu(f,v),D=zy(null,f,E,u,D,v);var P=Uy();return f.flags|=1,typeof D=="object"&&D!==null&&typeof D.render=="function"&&D.$$typeof===void 0?(f.tag=1,f.memoizedState=null,f.updateQueue=null,Vr(E)?(P=!0,Ou(f)):P=!1,f.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,Dy(f),D.updater=PA,f.stateNode=D,D._reactInternals=f,jy(f,E,u,v),f=Yy(null,f,E,!0,P,v)):(f.tag=0,Gn&&P&&oc(f),si(null,f,D,v),f=f.child),f;case 16:E=f.elementType;e:{switch(FA(u,f),u=f.pendingProps,D=E._init,E=D(E._payload),f.type=E,D=f.tag=Dz(E),u=Cs(E,u),D){case 0:f=qy(null,f,E,u,v);break e;case 1:f=f1(null,f,E,u,v);break e;case 11:f=l1(null,f,E,u,v);break e;case 14:f=c1(null,f,E,Cs(E.type,u),v);break e}throw Error(t(306,E,""))}return f;case 0:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),qy(u,f,E,D,v);case 1:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),f1(u,f,E,D,v);case 3:e:{if(p1(f),u===null)throw Error(t(387));E=f.pendingProps,P=f.memoizedState,D=P.element,MC(u,f),MA(f,E,null,v);var te=f.memoizedState;if(E=te.element,P.isDehydrated)if(P={element:E,isDehydrated:!1,cache:te.cache,pendingSuspenseBoundaries:te.pendingSuspenseBoundaries,transitions:te.transitions},f.updateQueue.baseState=P,f.memoizedState=P,f.flags&256){D=Wu(Error(t(423)),f),f=A1(u,f,E,v,D);break e}else if(E!==D){D=Wu(Error(t(424)),f),f=A1(u,f,E,v,D);break e}else for(Li=da(f.stateNode.containerInfo.firstChild),Pi=f,Gn=!0,Is=null,v=SC(f,null,E,v),f.child=v;v;)v.flags=v.flags&-3|4096,v=v.sibling;else{if($u(),E===D){f=eo(u,f,v);break e}si(u,f,E,v)}f=f.child}return f;case 5:return DC(f),u===null&&Iy(f),E=f.type,D=f.pendingProps,P=u!==null?u.memoizedProps:null,te=D.children,af(E,D)?te=null:P!==null&&af(E,P)&&(f.flags|=32),h1(u,f),si(u,f,te,v),f.child;case 6:return u===null&&Iy(f),null;case 13:return m1(u,f,v);case 4:return ky(f,f.stateNode.containerInfo),E=f.pendingProps,u===null?f.child=Gu(f,null,E,v):si(u,f,E,v),f.child;case 11:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),l1(u,f,E,D,v);case 7:return si(u,f,f.pendingProps,v),f.child;case 8:return si(u,f,f.pendingProps.children,v),f.child;case 12:return si(u,f,f.pendingProps.children,v),f.child;case 10:e:{if(E=f.type._context,D=f.pendingProps,P=f.memoizedProps,te=D.value,Rn(CA,E._currentValue),E._currentValue=te,P!==null)if(vi(P.value,te)){if(P.children===D.children&&!Gr.current){f=eo(u,f,v);break e}}else for(P=f.child,P!==null&&(P.return=f);P!==null;){var pe=P.dependencies;if(pe!==null){te=P.child;for(var we=pe.firstContext;we!==null;){if(we.context===E){if(P.tag===1){we=Za(-1,v&-v),we.tag=2;var Pe=P.updateQueue;if(Pe!==null){Pe=Pe.shared;var Xe=Pe.pending;Xe===null?we.next=we:(we.next=Xe.next,Xe.next=we),Pe.pending=we}}P.lanes|=v,we=P.alternate,we!==null&&(we.lanes|=v),Ty(P.return,v,f),pe.lanes|=v;break}we=we.next}}else if(P.tag===10)te=P.type===f.type?null:P.child;else if(P.tag===18){if(te=P.return,te===null)throw Error(t(341));te.lanes|=v,pe=te.alternate,pe!==null&&(pe.lanes|=v),Ty(te,v,f),te=P.sibling}else te=P.child;if(te!==null)te.return=P;else for(te=P;te!==null;){if(te===f){te=null;break}if(P=te.sibling,P!==null){P.return=te.return,te=P;break}te=te.return}P=te}si(u,f,D.children,v),f=f.child}return f;case 9:return D=f.type,E=f.pendingProps.children,Hu(f,v),D=Yi(D),E=E(D),f.flags|=1,si(u,f,E,v),f.child;case 14:return E=f.type,D=Cs(E,f.pendingProps),D=Cs(E.type,D),c1(u,f,E,D,v);case 15:return u1(u,f,f.type,f.pendingProps,v);case 17:return E=f.type,D=f.pendingProps,D=f.elementType===E?D:Cs(E,D),FA(u,f),f.tag=1,Vr(E)?(u=!0,Ou(f)):u=!1,Hu(f,v),t1(f,E,D),jy(f,E,D,v),Yy(null,f,E,!0,u,v);case 19:return y1(u,f,v);case 22:return d1(u,f,v)}throw Error(t(156,f.tag))};function $1(u,f){return vs(u,f)}function Rz(u,f,v,E){this.tag=u,this.key=v,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ki(u,f,v,E){return new Rz(u,f,v,E)}function Ax(u){return u=u.prototype,!(!u||!u.isReactComponent)}function Dz(u){if(typeof u=="function")return Ax(u)?1:0;if(u!=null){if(u=u.$$typeof,u===Q)return 11;if(u===W)return 14}return 2}function fl(u,f){var v=u.alternate;return v===null?(v=Ki(u.tag,f,u.key,u.mode),v.elementType=u.elementType,v.type=u.type,v.stateNode=u.stateNode,v.alternate=u,u.alternate=v):(v.pendingProps=f,v.type=u.type,v.flags=0,v.subtreeFlags=0,v.deletions=null),v.flags=u.flags&14680064,v.childLanes=u.childLanes,v.lanes=u.lanes,v.child=u.child,v.memoizedProps=u.memoizedProps,v.memoizedState=u.memoizedState,v.updateQueue=u.updateQueue,f=u.dependencies,v.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},v.sibling=u.sibling,v.index=u.index,v.ref=u.ref,v}function YA(u,f,v,E,D,P){var te=2;if(E=u,typeof u=="function")Ax(u)&&(te=1);else if(typeof u=="string")te=5;else e:switch(u){case M:return Ac(v.children,D,P,f);case T:te=8,D|=8;break;case R:return u=Ki(12,v,f,D|2),u.elementType=R,u.lanes=P,u;case V:return u=Ki(13,v,f,D),u.elementType=V,u.lanes=P,u;case B:return u=Ki(19,v,f,D),u.elementType=B,u.lanes=P,u;case X:return XA(v,D,P,f);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case k:te=10;break e;case H:te=9;break e;case Q:te=11;break e;case W:te=14;break e;case K:te=16,E=null;break e}throw Error(t(130,u==null?u:typeof u,""))}return f=Ki(te,v,f,D),f.elementType=u,f.type=E,f.lanes=P,f}function Ac(u,f,v,E){return u=Ki(7,u,E,f),u.lanes=v,u}function XA(u,f,v,E){return u=Ki(22,u,E,f),u.elementType=X,u.lanes=v,u.stateNode={isHidden:!1},u}function mx(u,f,v){return u=Ki(6,u,null,f),u.lanes=v,u}function gx(u,f,v){return f=Ki(4,u.children!==null?u.children:[],u.key,f),f.lanes=v,f.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},f}function kz(u,f,v,E,D){this.tag=f,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Cn(0),this.expirationTimes=Cn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Cn(0),this.identifierPrefix=E,this.onRecoverableError=D,this.mutableSourceEagerHydrationData=null}function yx(u,f,v,E,D,P,te,pe,we){return u=new kz(u,f,v,pe,we),f===1?(f=1,P===!0&&(f|=8)):f=0,P=Ki(3,null,null,f),u.current=P,P.stateNode=u,P.memoizedState={element:E,isDehydrated:v,cache:null,transitions:null,pendingSuspenseBoundaries:null},Dy(P),u}function Nz(u,f,v){var E=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:S,key:E==null?null:""+E,children:u,containerInfo:f,implementation:v}}function G1(u){if(!u)return fa;u=u._reactInternals;e:{if(ki(u)!==u||u.tag!==1)throw Error(t(170));var f=u;do{switch(f.tag){case 3:f=f.stateNode.context;break e;case 1:if(Vr(f.type)){f=f.stateNode.__reactInternalMemoizedMergedChildContext;break e}}f=f.return}while(f!==null);throw Error(t(171))}if(u.tag===1){var v=u.type;if(Vr(v))return bA(u,v,f)}return f}function V1(u,f,v,E,D,P,te,pe,we){return u=yx(v,E,!0,u,D,P,te,pe,we),u.context=G1(null),v=u.current,E=ai(),D=dl(v),P=Za(E,D),P.callback=f??null,ol(v,P,D),u.current.lanes=D,Yn(u,D,E),wi(u,E),u}function JA(u,f,v,E){var D=f.current,P=ai(),te=dl(D);return v=G1(v),f.context===null?f.context=v:f.pendingContext=v,f=Za(P,te),f.payload={element:u},E=E===void 0?null:E,E!==null&&(f.callback=E),u=ol(D,f,te),u!==null&&(Ms(u,D,te,P),BA(u,D,te)),te}function KA(u){return u=u.current,u.child?(u.child.tag===5,u.child.stateNode):null}function H1(u,f){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var v=u.retryLane;u.retryLane=v!==0&&v<f?v:f}}function xx(u,f){H1(u,f),(u=u.alternate)&&H1(u,f)}function Qz(){return null}var j1=typeof reportError=="function"?reportError:function(u){};function vx(u){this._internalRoot=u}ZA.prototype.render=vx.prototype.render=function(u){var f=this._internalRoot;if(f===null)throw Error(t(409));JA(u,f,null,null)},ZA.prototype.unmount=vx.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var f=u.containerInfo;hc(function(){JA(null,u,null,null)}),f[ws]=null}};function ZA(u){this._internalRoot=u}ZA.prototype.unstable_scheduleHydration=function(u){if(u){var f=hu();u={blockedOn:null,target:u,priority:f};for(var v=0;v<_s.length&&f!==0&&f<_s[v].priority;v++);_s.splice(v,0,u),v===0&&Xp(u)}};function _x(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function em(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11&&(u.nodeType!==8||u.nodeValue!==" react-mount-point-unstable "))}function W1(){}function Pz(u,f,v,E,D){if(D){if(typeof E=="function"){var P=E;E=function(){var Pe=KA(te);P.call(Pe)}}var te=V1(f,E,u,0,null,!1,!1,"",W1);return u._reactRootContainer=te,u[ws]=te.current,el(u.nodeType===8?u.parentNode:u),hc(),te}for(;D=u.lastChild;)u.removeChild(D);if(typeof E=="function"){var pe=E;E=function(){var Pe=KA(we);pe.call(Pe)}}var we=yx(u,0,!1,null,null,!1,!1,"",W1);return u._reactRootContainer=we,u[ws]=we.current,el(u.nodeType===8?u.parentNode:u),hc(function(){JA(f,we,v,E)}),we}function tm(u,f,v,E,D){var P=v._reactRootContainer;if(P){var te=P;if(typeof D=="function"){var pe=D;D=function(){var we=KA(te);pe.call(we)}}JA(f,te,u,D)}else te=Pz(v,f,u,D,E);return KA(te)}yi=function(u){switch(u.tag){case 3:var f=u.stateNode;if(f.current.memoizedState.isDehydrated){var v=vn(f.pendingLanes);v!==0&&(Kn(f,v|1),wi(f,De()),(An&6)===0&&(Xu=De()+500,ue()))}break;case 13:hc(function(){var E=Ka(u,1);if(E!==null){var D=ai();Ms(E,u,1,D)}}),xx(u,1)}},zo=function(u){if(u.tag===13){var f=Ka(u,134217728);if(f!==null){var v=ai();Ms(f,u,134217728,v)}xx(u,134217728)}},Wp=function(u){if(u.tag===13){var f=dl(u),v=Ka(u,f);if(v!==null){var E=ai();Ms(v,u,f,E)}xx(u,f)}},hu=function(){return Gt},qp=function(u,f){var v=Gt;try{return Gt=u,f()}finally{Gt=v}},ut=function(u,f,v){switch(f){case"input":if(q(u,v),f=v.name,v.type==="radio"&&f!=null){for(v=u;v.parentNode;)v=v.parentNode;for(v=v.querySelectorAll("input[name="+JSON.stringify(""+f)+'][type="radio"]'),f=0;f<v.length;f++){var E=v[f];if(E!==u&&E.form===u.form){var D=zu(E);if(!D)throw Error(t(90));tt(E),q(E,D)}}}break;case"textarea":Y(u,v);break;case"select":f=v.value,f!=null&&ve(u,!!v.multiple,f,!1)}},Ot=hx,En=hc;var Lz={usingClientEntryPoint:!1,Events:[sc,rl,zu,Ve,_t,hx]},Ef={findFiberByHostInstance:Xa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Fz={bundleType:Ef.bundleType,version:Ef.version,rendererPackageName:Ef.rendererPackageName,rendererConfig:Ef.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:w.ReactCurrentDispatcher,findHostInstanceByFiber:function(u){return u=Po(u),u===null?null:u.stateNode},findFiberByHostInstance:Ef.findFiberByHostInstance||Qz,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nm.isDisabled&&nm.supportsFiber)try{Qt=nm.inject(Fz),St=nm}catch{}}return Ei.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Lz,Ei.createPortal=function(u,f){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_x(f))throw Error(t(200));return Nz(u,f,null,v)},Ei.createRoot=function(u,f){if(!_x(u))throw Error(t(299));var v=!1,E="",D=j1;return f!=null&&(f.unstable_strictMode===!0&&(v=!0),f.identifierPrefix!==void 0&&(E=f.identifierPrefix),f.onRecoverableError!==void 0&&(D=f.onRecoverableError)),f=yx(u,1,!1,null,null,v,!1,E,D),u[ws]=f.current,el(u.nodeType===8?u.parentNode:u),new vx(f)},Ei.findDOMNode=function(u){if(u==null)return null;if(u.nodeType===1)return u;var f=u._reactInternals;if(f===void 0)throw typeof u.render=="function"?Error(t(188)):(u=Object.keys(u).join(","),Error(t(268,u)));return u=Po(f),u=u===null?null:u.stateNode,u},Ei.flushSync=function(u){return hc(u)},Ei.hydrate=function(u,f,v){if(!em(f))throw Error(t(200));return tm(null,u,f,!0,v)},Ei.hydrateRoot=function(u,f,v){if(!_x(u))throw Error(t(405));var E=v!=null&&v.hydratedSources||null,D=!1,P="",te=j1;if(v!=null&&(v.unstable_strictMode===!0&&(D=!0),v.identifierPrefix!==void 0&&(P=v.identifierPrefix),v.onRecoverableError!==void 0&&(te=v.onRecoverableError)),f=V1(f,null,u,1,v??null,D,!1,P,te),u[ws]=f.current,el(u),E)for(u=0;u<E.length;u++)v=E[u],D=v._getVersion,D=D(v._source),f.mutableSourceEagerHydrationData==null?f.mutableSourceEagerHydrationData=[v,D]:f.mutableSourceEagerHydrationData.push(v,D);return new ZA(f)},Ei.render=function(u,f,v){if(!em(f))throw Error(t(200));return tm(null,u,f,!1,v)},Ei.unmountComponentAtNode=function(u){if(!em(u))throw Error(t(40));return u._reactRootContainer?(hc(function(){tm(null,null,u,!1,function(){u._reactRootContainer=null,u[ws]=null})}),!0):!1},Ei.unstable_batchedUpdates=hx,Ei.unstable_renderSubtreeIntoContainer=function(u,f,v,E){if(!em(v))throw Error(t(200));if(u==null||u._reactInternals===void 0)throw Error(t(38));return tm(u,f,v,!1,E)},Ei.version="18.3.1-next-f1338f8080-20240426",Ei}var t2;function iD(){if(t2)return Ex.exports;t2=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch{}}return n(),Ex.exports=jz(),Ex.exports}var n2;function Wz(){if(n2)return im;n2=1;var n=iD();return im.createRoot=n.createRoot,im.hydrateRoot=n.hydrateRoot,im}var qz=Wz(),ba=function(){return ba=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},ba.apply(this,arguments)};function sD(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function Yz(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return n.concat(s||Array.prototype.slice.call(e))}var cg="right-scroll-bar-position",ug="width-before-scroll-bar",Xz="with-scroll-bars-hidden",Jz="--removed-body-scroll-bar-size";function Sx(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function Kz(n,e){var t=U.useState(function(){return{value:n,callback:e,facade:{get current(){return t.value},set current(r){var i=t.value;i!==r&&(t.value=r,t.callback(r,i))}}}})[0];return t.callback=e,t.facade}var Zz=typeof window<"u"?U.useLayoutEffect:U.useEffect,r2=new WeakMap;function eU(n,e){var t=Kz(null,function(r){return n.forEach(function(i){return Sx(i,r)})});return Zz(function(){var r=r2.get(t);if(r){var i=new Set(r),s=new Set(n),a=t.current;i.forEach(function(o){s.has(o)||Sx(o,null)}),s.forEach(function(o){i.has(o)||Sx(o,a)})}r2.set(t,n)},[n]),t}function tU(n){return n}function nU(n,e){e===void 0&&(e=tU);var t=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return t.length?t[t.length-1]:n},useMedium:function(s){var a=e(s,r);return t.push(a),function(){t=t.filter(function(o){return o!==a})}},assignSyncMedium:function(s){for(r=!0;t.length;){var a=t;t=[],a.forEach(s)}t={push:function(o){return s(o)},filter:function(){return t}}},assignMedium:function(s){r=!0;var a=[];if(t.length){var o=t;t=[],o.forEach(s),a=t}var l=function(){var d=a;a=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),t={push:function(d){a.push(d),c()},filter:function(d){return a=a.filter(d),t}}}};return i}function rU(n){n===void 0&&(n={});var e=nU(null);return e.options=ba({async:!0,ssr:!1},n),e}var aD=function(n){var e=n.sideCar,t=sD(n,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return U.createElement(r,ba({},t))};aD.isSideCarExport=!0;function iU(n,e){return n.useMedium(e),aD}var oD=rU(),Bx=function(){},i0=U.forwardRef(function(n,e){var t=U.useRef(null),r=U.useState({onScrollCapture:Bx,onWheelCapture:Bx,onTouchMoveCapture:Bx}),i=r[0],s=r[1],a=n.forwardProps,o=n.children,l=n.className,c=n.removeScrollBar,d=n.enabled,h=n.shards,p=n.sideCar,A=n.noRelative,y=n.noIsolation,m=n.inert,x=n.allowPinchZoom,g=n.as,_=g===void 0?"div":g,b=n.gapMode,w=sD(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),I=p,S=eU([t,e]),M=ba(ba({},w),i);return U.createElement(U.Fragment,null,d&&U.createElement(I,{sideCar:oD,removeScrollBar:c,shards:h,noRelative:A,noIsolation:y,inert:m,setCallbacks:s,allowPinchZoom:!!x,lockRef:t,gapMode:b}),a?U.cloneElement(U.Children.only(o),ba(ba({},M),{ref:S})):U.createElement(_,ba({},M,{className:l,ref:S}),o))});i0.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};i0.classNames={fullWidth:ug,zeroRight:cg};var sU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function aU(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=sU();return e&&n.setAttribute("nonce",e),n}function oU(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function lU(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var cU=function(){var n=0,e=null;return{add:function(t){n==0&&(e=aU())&&(oU(e,t),lU(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},uU=function(){var n=cU();return function(e,t){U.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},lD=function(){var n=uU(),e=function(t){var r=t.styles,i=t.dynamic;return n(r,i),null};return e},dU={left:0,top:0,right:0,gap:0},Mx=function(n){return parseInt(n||"",10)||0},hU=function(n){var e=window.getComputedStyle(document.body),t=e[n==="padding"?"paddingLeft":"marginLeft"],r=e[n==="padding"?"paddingTop":"marginTop"],i=e[n==="padding"?"paddingRight":"marginRight"];return[Mx(t),Mx(r),Mx(i)]},fU=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return dU;var e=hU(n),t=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-t+e[2]-e[0])}},pU=lD(),Dd="data-scroll-locked",AU=function(n,e,t,r){var i=n.left,s=n.top,a=n.right,o=n.gap;return t===void 0&&(t="margin"),`
|
|
9
9
|
.`.concat(Xz,` {
|
|
10
10
|
overflow: hidden `).concat(r,`;
|
|
11
11
|
padding-right: `).concat(o,"px ").concat(r,`;
|
|
@@ -53,7 +53,7 @@ ${c}`}function iE({color:n,theme:e,autoContrast:t}){return(typeof t=="boolean"?t
|
|
|
53
53
|
Decimal separator can't be same as thousand separator.
|
|
54
54
|
thousandSeparator: `+t+` (thousandSeparator = {true} is same as thousandSeparator = ",")
|
|
55
55
|
decimalSeparator: `+r+` (default value for decimalSeparator is .)
|
|
56
|
-
`);return i.startsWith("-")&&s&&(s=!1),Object.assign(Object.assign({},n),{allowNegative:s})}function eV(n){n=Z6(n),n.decimalSeparator,n.allowedDecimalSeparators,n.thousandsGroupStyle;var e=n.suffix,t=n.allowNegative,r=n.allowLeadingZeros,i=n.onKeyDown;i===void 0&&(i=Rl);var s=n.onBlur;s===void 0&&(s=Rl);var a=n.thousandSeparator,o=n.decimalScale,l=n.fixedDecimalScale,c=n.prefix;c===void 0&&(c="");var d=n.defaultValue,h=n.value,p=n.valueIsNumericString,A=n.onValueChange,y=vN(n,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),m=Q0(n),x=m.decimalSeparator,g=m.allowedDecimalSeparators,_=function(K){return oS(K,n)},b=function(K,X){return J6(K,X,n)},w=kl(h)?d:h,I=p??X6(w,c,e);kl(h)?kl(d)||(I=I||typeof d=="number"):I=I||typeof h=="number";var S=function(K){return _N(K)?K:(typeof K=="number"&&(K=EN(K)),I&&typeof o=="number"?sS(K,o,!!l):K)},M=CN(S(h),S(d),!!I,_,b,A),T=M[0],R=T.numAsString,k=T.formattedValue,H=M[1],Q=function(K){var X=K.target,$=K.key,J=X.selectionStart,ne=X.selectionEnd,L=X.value;if(L===void 0&&(L=""),($==="Backspace"||$==="Delete")&&ne<c.length&&L!=="-"){K.preventDefault();return}if(J!==ne){i(K);return}$==="Backspace"&&L[0]==="-"&&J===c.length+1&&t&&Rc(X,1),o&&l&&($==="Backspace"&&L[J-1]===x?(Rc(X,J-1),K.preventDefault()):$==="Delete"&&L[J]===x&&K.preventDefault()),g?.includes($)&&L[J]===x&&Rc(X,J+1);var G=a===!0?",":a;$==="Backspace"&&L[J-1]===G&&Rc(X,J-1),$==="Delete"&&L[J]===G&&Rc(X,J+1),i(K)},V=function(K){var X=R;if(X.match(/\d/g)||(X=""),r||(X=L6(X)),l&&o&&(X=sS(X,o,l)),X!==R){var $=oS(X,n);H({formattedValue:$,value:X,floatValue:parseFloat(X)},{event:K,source:Vd.event})}s(K)},B=function(K){return K===x?!0:Ep(K)},W=function(K){var X=K.currentValue,$=K.lastValue,J=K.formattedValue,ne=K.currentValueIndex,L=K.formattedValueIndex,G=X[ne],oe=J[L],Ae=IN($,X),ye=Ae.to,he=function(fe){return b(fe).indexOf(".")+c.length};return h===0&&l&&o&&X[ye.start]===x&&he(X)<ne&&he(J)>L?!1:ne>=ye.start&&ne<ye.end&&g&&g.includes(G)&&oe===x?!0:G===oe};return Object.assign(Object.assign({},y),{value:k,valueIsNumericString:!1,isValidInputCharacter:B,isCharacterSame:W,onValueChange:H,format:_,removeFormatting:b,getCaretBoundary:function(K){return K6(K,n)},onKeyDown:Q,onBlur:V})}function tV(n){var e=eV(n);return On.createElement(W6,Object.assign({},e))}var yb={root:"m_e2f5cd4e",controls:"m_95e17d22",control:"m_80b4b171"};function lS({direction:n,style:e,...t}){return j.jsx("svg",{style:{width:"var(--ni-chevron-size)",height:"var(--ni-chevron-size)",transform:n==="up"?"rotate(180deg)":void 0,...e},viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:j.jsx("path",{d:"M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}const nV=/^(0\.0*|-0(\.0*)?)$/,rV=/^-?0\d+(\.\d+)?\.?$/,iV=/\.\d*0$/,SN=/^-?\d+\.$/;function xb(n){return typeof n=="string"&&n!==""&&!Number.isNaN(Number(n))}function qx(n){return typeof n=="number"?n<Number.MAX_SAFE_INTEGER:n===""||xb(n)&&Number(n)<Number.MAX_SAFE_INTEGER}function sV(n){return n.toString().replace(".","").length}function aV(n,e){return(typeof n=="number"?n<Number.MAX_SAFE_INTEGER:!Number.isNaN(Number(n)))&&!Number.isNaN(n)&&sV(e)<14&&e!==""}function cS(n,e,t){if(n===void 0)return!0;const r=e===void 0||n>=e,i=t===void 0||n<=t;return r&&i}const oV={step:1,clampBehavior:"blur",allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0,allowedDecimalSeparators:[".",","]},lV=(n,{size:e})=>({controls:{"--ni-chevron-size":gn(e,"ni-chevron-size")}});function cV(n,e,t){const r=n.toString(),i=SN.test(r),s=r.replace(/^0+(?=\d)/,""),a=parseFloat(s);if(Number.isNaN(a))return s;if(a>Number.MAX_SAFE_INTEGER)return e!==void 0?e:s;const o=ss(a,t,e);return i?`${o.toString().replace(/^0+(?=\d)/,"")}.`:o}const sI=Tt((n,e)=>{const t=ct("NumberInput",oV,n),{className:r,classNames:i,styles:s,unstyled:a,vars:o,onChange:l,onValueChange:c,value:d,defaultValue:h,max:p,min:A,step:y,hideControls:m,rightSection:x,isAllowed:g,clampBehavior:_,onBlur:b,allowDecimal:w,decimalScale:I,onKeyDown:S,onKeyDownCapture:M,handlersRef:T,startValue:R,disabled:k,rightSectionPointerEvents:H,allowNegative:Q,readOnly:V,size:B,rightSectionWidth:W,stepHoldInterval:K,stepHoldDelay:X,allowLeadingZeros:$,withKeyboardEvents:J,trimLeadingZeroesOnBlur:ne,allowedDecimalSeparators:L,attributes:G,...oe}=t,Ae=en({name:"NumberInput",classes:yb,props:t,classNames:i,styles:s,unstyled:a,attributes:G,vars:o,varsResolver:lV}),{resolvedClassNames:ye,resolvedStyles:he}=ih({classNames:i,styles:s,props:t}),[fe,Ie]=Ks({value:d,defaultValue:h,finalValue:"",onChange:l}),Re=X!==void 0&&K!==void 0,ge=U.useRef(null),Ne=U.useRef(null),tt=U.useRef(0),Ge=(me,xe)=>{xe.source==="event"&&Ie(aV(me.floatValue,me.value)&&!nV.test(me.value)&&!($&&rV.test(me.value))&&!iV.test(me.value)&&!SN.test(me.value)?me.floatValue:me.value),c?.(me,xe)},F=me=>{const xe=String(me).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return xe?Math.max(0,(xe[1]?xe[1].length:0)-(xe[2]?+xe[2]:0)):0},re=me=>{ge.current&&typeof me<"u"&&ge.current.setSelectionRange(me,me)},Ee=U.useRef(eb);Ee.current=()=>{if(!qx(fe))return;let me;const xe=F(fe),st=F(y),He=Math.max(xe,st),Ke=10**He;if(!xb(fe)&&(typeof fe!="number"||Number.isNaN(fe)))me=ss(R,A,p);else if(p!==void 0){const ze=(Math.round(Number(fe)*Ke)+Math.round(y*Ke))/Ke;me=ze<=p?ze:p}else me=(Math.round(Number(fe)*Ke)+Math.round(y*Ke))/Ke;const nt=me.toFixed(He);Ie(parseFloat(nt)),c?.({floatValue:parseFloat(nt),formattedValue:nt,value:nt},{source:"increment"}),setTimeout(()=>re(ge.current?.value.length),0)};const q=U.useRef(eb);q.current=()=>{if(!qx(fe))return;let me;const xe=A!==void 0?A:Q?Number.MIN_SAFE_INTEGER:0,st=F(fe),He=F(y),Ke=Math.max(st,He),nt=10**Ke;if(!xb(fe)&&typeof fe!="number"||Number.isNaN(fe))me=ss(R,xe,p);else{const Ze=(Math.round(Number(fe)*nt)-Math.round(y*nt))/nt;me=xe!==void 0&&Ze<xe?xe:Ze}const ze=me.toFixed(Ke);Ie(parseFloat(ze)),c?.({floatValue:parseFloat(ze),formattedValue:ze,value:ze},{source:"decrement"}),setTimeout(()=>re(ge.current?.value.length),0)};const ee=me=>{const xe=me.clipboardData.getData("text"),st=oe.decimalSeparator||".",He=(L||[".",","]).filter(Ke=>Ke!==st);if(He.some(Ke=>xe.includes(Ke))){me.preventDefault();let Ke=xe;He.forEach(ze=>{Ke=Ke.split(ze).join(st)});const nt=ge.current;if(nt){const ze=nt.selectionStart??0,Ze=nt.selectionEnd??0,pt=nt.value,ft=pt.substring(0,ze)+Ke+pt.substring(Ze);Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(nt,ft),nt.dispatchEvent(new Event("change",{bubbles:!0}));const Mt=ze+Ke.length;setTimeout(()=>re(Mt),0)}}oe.onPaste?.(me)},ie=me=>{S?.(me),!(V||!J)&&(me.key==="ArrowUp"&&(me.preventDefault(),Ee.current?.()),me.key==="ArrowDown"&&(me.preventDefault(),q.current?.()))},be=me=>{if(M?.(me),me.key==="Backspace"){const xe=ge.current;xe&&xe.selectionStart===0&&xe.selectionStart===xe.selectionEnd&&(me.preventDefault(),window.setTimeout(()=>re(0),0))}},ve=me=>{let xe=fe;_==="blur"&&typeof xe=="number"&&(xe=ss(xe,A,p)),ne&&typeof xe=="string"&&F(xe)<15&&(xe=cV(xe,p,A)),fe!==xe&&Ie(xe),b?.(me)};Bg(T,{increment:Ee.current,decrement:q.current});const ce=me=>{me?Ee.current?.():q.current?.(),tt.current+=1},Z=me=>{if(ce(me),Re){const xe=typeof K=="number"?K:K(tt.current);Ne.current=window.setTimeout(()=>Z(me),xe)}},Y=(me,xe)=>{me.preventDefault(),ge.current?.focus(),ce(xe),Re&&(Ne.current=window.setTimeout(()=>Z(xe),X))},le=()=>{Ne.current&&window.clearTimeout(Ne.current),Ne.current=null,tt.current=0},Ce=j.jsxs("div",{...Ae("controls"),children:[j.jsx(ka,{...Ae("control"),tabIndex:-1,"aria-hidden":!0,disabled:k||typeof fe=="number"&&p!==void 0&&fe>=p,mod:{direction:"up"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{Y(me,!0)},onPointerUp:le,onPointerLeave:le,children:j.jsx(lS,{direction:"up"})}),j.jsx(ka,{...Ae("control"),tabIndex:-1,"aria-hidden":!0,disabled:k||typeof fe=="number"&&A!==void 0&&fe<=A,mod:{direction:"down"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{Y(me,!1)},onPointerUp:le,onPointerLeave:le,children:j.jsx(lS,{direction:"down"})})]});return j.jsx(na,{component:tV,allowNegative:Q,className:Rr(yb.root,r),size:B,inputMode:"decimal",...oe,readOnly:V,disabled:k,value:fe,getInputRef:er(e,ge),onValueChange:Ge,rightSection:m||V||!qx(fe)?x:x||Ce,classNames:ye,styles:he,unstyled:a,__staticSelector:"NumberInput",decimalScale:w?I:0,onPaste:ee,onKeyDown:ie,onKeyDownCapture:be,rightSectionPointerEvents:H??(k?"none":void 0),rightSectionWidth:W??`var(--ni-right-section-width-${B||"sm"})`,allowLeadingZeros:$,allowedDecimalSeparators:L,onBlur:ve,attributes:G,isAllowed:me=>_==="strict"?g?g(me)&&cS(me.floatValue,A,p):cS(me.floatValue,A,p):g?g(me):!0})});sI.classes={...na.classes,...yb};sI.displayName="@mantine/core/NumberInput";const uV={duration:100,transition:"fade"};function uS(n,e){return{...uV,...e,...n}}var P0={tooltip:"m_1b3c8819",arrow:"m_f898399f"};function dV({offset:n,position:e,defaultOpened:t}){const[r,i]=U.useState(t),s=U.useRef(null),{x:a,y:o,elements:l,refs:c,update:d,placement:h}=gE({placement:e,middleware:[fE({crossAxis:!0,padding:5,rootBoundary:"document"})]}),p=h.includes("right")?n:e.includes("left")?n*-1:0,A=h.includes("bottom")?n:e.includes("top")?n*-1:0,y=U.useCallback(({clientX:m,clientY:x})=>{c.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:m,y:x,left:m+p,top:x+A,right:m,bottom:x}}})},[l.reference]);return U.useEffect(()=>{if(c.floating.current){const m=s.current;m.addEventListener("mousemove",y);const x=yo(c.floating.current);return x.forEach(g=>{g.addEventListener("scroll",d)}),()=>{m.removeEventListener("mousemove",y),x.forEach(g=>{g.removeEventListener("scroll",d)})}}},[l.reference,c.floating.current,d,y,r]),{handleMouseMove:y,x:a,y:o,opened:r,setOpened:i,boundaryRef:s,floating:c.setFloating}}const hV={refProp:"ref",withinPortal:!0,offset:10,position:"right",zIndex:Bo("popover")},fV=(n,{radius:e,color:t})=>({tooltip:{"--tooltip-radius":e===void 0?void 0:Dr(e),"--tooltip-bg":t?cs(t,n):void 0,"--tooltip-color":t?"var(--mantine-color-white)":void 0}}),aI=Tt((n,e)=>{const t=ct("TooltipFloating",hV,n),{children:r,refProp:i,withinPortal:s,style:a,className:o,classNames:l,styles:c,unstyled:d,radius:h,color:p,label:A,offset:y,position:m,multiline:x,zIndex:g,disabled:_,defaultOpened:b,variant:w,vars:I,portalProps:S,attributes:M,...T}=t,R=Ri(),k=en({name:"TooltipFloating",props:t,classes:P0,className:o,style:a,classNames:l,styles:c,unstyled:d,attributes:M,rootSelector:"tooltip",vars:I,varsResolver:fV}),{handleMouseMove:H,x:Q,y:V,opened:B,boundaryRef:W,floating:K,setOpened:X}=dV({offset:y,position:m,defaultOpened:b}),$=ru(r);if(!$)throw new Error("[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const J=er(W,l0($),e),ne=$.props,L=oe=>{ne.onMouseEnter?.(oe),H(oe),X(!0)},G=oe=>{ne.onMouseLeave?.(oe),X(!1)};return j.jsxs(j.Fragment,{children:[j.jsx(Jc,{...S,withinPortal:s,children:j.jsx(Je,{...T,...k("tooltip",{style:{...aE(a,R),zIndex:g,display:!_&&B?"block":"none",top:(V&&Math.round(V))??"",left:(Q&&Math.round(Q))??""}}),variant:w,ref:K,mod:{multiline:x},children:A})}),U.cloneElement($,{...ne,[i]:J,onMouseEnter:L,onMouseLeave:G})]})});aI.classes=P0;aI.displayName="@mantine/core/TooltipFloating";const BN=U.createContext(!1),pV=BN.Provider,AV=()=>U.useContext(BN),mV={openDelay:0,closeDelay:0};function oI(n){const{openDelay:e,closeDelay:t,children:r}=ct("TooltipGroup",mV,n);return j.jsx(pV,{value:!0,children:j.jsx(j5,{delay:{open:e,close:t},children:r})})}oI.displayName="@mantine/core/TooltipGroup";oI.extend=n=>n;function gV(n){if(n===void 0)return{shift:!0,flip:!0};const e={...n};return n.shift===void 0&&(e.shift=!0),n.flip===void 0&&(e.flip=!0),e}function yV(n){const e=gV(n.middlewares),t=[YD(n.offset)];return e.shift&&t.push(fE(typeof e.shift=="boolean"?{padding:8}:{padding:8,...e.shift})),e.flip&&t.push(typeof e.flip=="boolean"?Ng():Ng(e.flip)),t.push(XD({element:n.arrowRef,padding:n.arrowOffset})),e.inline?t.push(typeof e.inline=="boolean"?dp():dp(e.inline)):n.inline&&t.push(dp()),t}function xV(n){const[e,t]=U.useState(n.defaultOpened),i=typeof n.opened=="boolean"?n.opened:e,s=AV(),a=Mo(),o=U.useCallback(I=>{t(I),I&&g(a)},[a]),{x:l,y:c,context:d,refs:h,placement:p,middlewareData:{arrow:{x:A,y}={}}}=gE({strategy:n.strategy,placement:n.position,open:i,onOpenChange:o,middleware:yV(n),whileElementsMounted:db}),{delay:m,currentId:x,setCurrentId:g}=W5(d,{id:a}),{getReferenceProps:_,getFloatingProps:b}=Z5([V5(d,{enabled:n.events?.hover,delay:s?m:{open:n.openDelay,close:n.closeDelay},mouseOnly:!n.events?.touch}),K5(d,{enabled:n.events?.focus,visibleOnly:!0}),t8(d,{role:"tooltip"}),X5(d,{enabled:typeof n.opened>"u"})]);Ra(()=>{n.onPositionChange?.(p)},[p]);const w=i&&x&&x!==a;return{x:l,y:c,arrowX:A,arrowY:y,reference:h.setReference,floating:h.setFloating,getFloatingProps:b,getReferenceProps:_,isGroupPhase:w,opened:i,placement:p}}const dS={position:"top",refProp:"ref",withinPortal:!0,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:Bo("popover"),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},vV=(n,{radius:e,color:t,variant:r,autoContrast:i})=>{const s=n.variantColorResolver({theme:n,color:t||n.primaryColor,autoContrast:i,variant:r||"filled"});return{tooltip:{"--tooltip-radius":e===void 0?void 0:Dr(e),"--tooltip-bg":t?s.background:void 0,"--tooltip-color":t?s.color:void 0}}},Ql=Tt((n,e)=>{const t=ct("Tooltip",dS,n),{children:r,position:i,refProp:s,label:a,openDelay:o,closeDelay:l,onPositionChange:c,opened:d,defaultOpened:h,withinPortal:p,radius:A,color:y,classNames:m,styles:x,unstyled:g,style:_,className:b,withArrow:w,arrowSize:I,arrowOffset:S,arrowRadius:M,arrowPosition:T,offset:R,transitionProps:k,multiline:H,events:Q,zIndex:V,disabled:B,positionDependencies:W,onClick:K,onMouseEnter:X,onMouseLeave:$,inline:J,variant:ne,keepMounted:L,vars:G,portalProps:oe,mod:Ae,floatingStrategy:ye,middlewares:he,autoContrast:fe,attributes:Ie,target:Re,...ge}=ct("Tooltip",dS,t),{dir:Ne}=iu(),tt=U.useRef(null),Ge=xV({position:Ak(Ne,i),closeDelay:l,openDelay:o,onPositionChange:c,opened:d,defaultOpened:h,events:Q,arrowRef:tt,arrowOffset:S,offset:typeof R=="number"?R+(w?I/2:0):R,positionDependencies:[...W,Re??r],inline:J,strategy:ye,middlewares:he});U.useEffect(()=>{const ie=Re instanceof HTMLElement?Re:typeof Re=="string"?document.querySelector(Re):Re?.current||null;ie&&Ge.reference(ie)},[Re,Ge]);const F=en({name:"Tooltip",props:t,classes:P0,className:b,style:_,classNames:m,styles:x,unstyled:g,attributes:Ie,rootSelector:"tooltip",vars:G,varsResolver:vV}),re=ru(r);if(!Re&&!re)throw new Error("[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");if(Re){const ie=uS(k,{duration:100,transition:"fade"});return j.jsx(j.Fragment,{children:j.jsx(Jc,{...oe,withinPortal:p,children:j.jsx(Na,{...ie,keepMounted:L,mounted:!B&&!!Ge.opened,duration:Ge.isGroupPhase?10:ie.duration,children:be=>j.jsxs(Je,{...ge,"data-fixed":ye==="fixed"||void 0,variant:ne,mod:[{multiline:H},Ae],...Ge.getFloatingProps({ref:Ge.floating,className:F("tooltip").className,style:{...F("tooltip").style,...be,zIndex:V,top:Ge.y??0,left:Ge.x??0}}),children:[a,j.jsx(Pg,{ref:tt,arrowX:Ge.arrowX,arrowY:Ge.arrowY,visible:w,position:Ge.placement,arrowSize:I,arrowOffset:S,arrowRadius:M,arrowPosition:T,...F("arrow")})]})})})})}const Ee=re.props,q=er(Ge.reference,l0(re),e),ee=uS(k,{duration:100,transition:"fade"});return j.jsxs(j.Fragment,{children:[j.jsx(Jc,{...oe,withinPortal:p,children:j.jsx(Na,{...ee,keepMounted:L,mounted:!B&&!!Ge.opened,duration:Ge.isGroupPhase?10:ee.duration,children:ie=>j.jsxs(Je,{...ge,"data-fixed":ye==="fixed"||void 0,variant:ne,mod:[{multiline:H},Ae],...Ge.getFloatingProps({ref:Ge.floating,className:F("tooltip").className,style:{...F("tooltip").style,...ie,zIndex:V,top:Ge.y??0,left:Ge.x??0}}),children:[a,j.jsx(Pg,{ref:tt,arrowX:Ge.arrowX,arrowY:Ge.arrowY,visible:w,position:Ge.placement,arrowSize:I,arrowOffset:S,arrowRadius:M,arrowPosition:T,...F("arrow")})]})})}),U.cloneElement(re,Ge.getReferenceProps({onClick:K,onMouseEnter:X,onMouseLeave:$,onMouseMove:t.onMouseMove,onPointerDown:t.onPointerDown,onPointerEnter:t.onPointerEnter,...Ee,className:Rr(b,Ee.className),[s]:q}))]})});Ql.classes=P0;Ql.displayName="@mantine/core/Tooltip";Ql.Floating=aI;Ql.Group=oI;const _V={withCheckIcon:!0,allowDeselect:!0,checkIconPosition:"left",openOnFocus:!0},Uc=Tt((n,e)=>{const t=ct("Select",_V,n),{classNames:r,styles:i,unstyled:s,vars:a,dropdownOpened:o,defaultDropdownOpened:l,onDropdownClose:c,onDropdownOpen:d,onFocus:h,onBlur:p,onClick:A,onChange:y,data:m,value:x,defaultValue:g,selectFirstOptionOnChange:_,selectFirstOptionOnDropdownOpen:b,onOptionSubmit:w,comboboxProps:I,readOnly:S,disabled:M,filter:T,limit:R,withScrollArea:k,maxDropdownHeight:H,size:Q,searchable:V,rightSection:B,checkIconPosition:W,withCheckIcon:K,withAlignedLabels:X,nothingFoundMessage:$,name:J,form:ne,searchValue:L,defaultSearchValue:G,onSearchChange:oe,allowDeselect:Ae,error:ye,rightSectionPointerEvents:he,id:fe,clearable:Ie,clearButtonProps:Re,hiddenInputProps:ge,renderOption:Ne,onClear:tt,autoComplete:Ge,scrollAreaProps:F,__defaultRightSection:re,__clearSection:Ee,__clearable:q,chevronColor:ee,autoSelectOnBlur:ie,openOnFocus:be,attributes:ve,...ce}=t,Z=U.useMemo(()=>cG(m),[m]),Y=U.useRef({}),le=U.useMemo(()=>Gk(Z),[Z]),Ce=Mo(fe),[me,xe,st]=Ks({value:x,defaultValue:g,finalValue:null,onChange:y}),He=typeof me=="string"?me in le?le[me]:Y.current[me]:void 0,Ke=nO(He),[nt,ze,Ze]=Ks({value:L,defaultValue:G,finalValue:He?He.label:"",onChange:oe}),pt=Yk({opened:o,defaultOpened:l,onDropdownOpen:()=>{d?.(),b?pt.selectFirstOption():pt.updateSelectedOptionIndex("active",{scrollIntoView:!0})},onDropdownClose:()=>{c?.(),setTimeout(pt.resetSelectedOption,0)}}),ft=je=>{ze(je),pt.resetSelectedOption()},{resolvedClassNames:dt,resolvedStyles:Mt}=ih({props:t,styles:i,classNames:r});U.useEffect(()=>{_&&pt.selectFirstOption()},[_,nt]),U.useEffect(()=>{x===null&&ft(""),typeof x=="string"&&He&&(Ke?.value!==He.value||Ke?.label!==He.label)&&ft(He.label)},[x,He]),U.useEffect(()=>{!st&&!Ze&&ft(typeof me=="string"?me in le?le[me]?.label:Y.current[me]?.label||"":"")},[le,me]),U.useEffect(()=>{me&&me in le&&(Y.current[me]=le[me])},[le,me]);const _e=j.jsx(Qn.ClearButton,{...Re,onClear:()=>{xe(null,null),ft(""),tt?.()}}),ut=Ie&&!!me&&!M&&!S;return j.jsxs(j.Fragment,{children:[j.jsxs(Qn,{store:pt,__staticSelector:"Select",classNames:dt,styles:Mt,unstyled:s,readOnly:S,size:Q,attributes:ve,keepMounted:ie,onOptionSubmit:je=>{w?.(je);const Ye=Ae&&le[je].value===me?null:le[je],We=Ye?Ye.value:null;We!==me&&xe(We,Ye),!st&&ft(typeof We=="string"&&Ye?.label||""),pt.closeDropdown()},...I,children:[j.jsx(Qn.Target,{targetType:V?"input":"button",autoComplete:Ge,children:j.jsx(na,{id:Ce,ref:e,__defaultRightSection:j.jsx(Qn.Chevron,{size:Q,error:ye,unstyled:s,color:ee}),__clearSection:_e,__clearable:ut,rightSection:B,rightSectionPointerEvents:he||"none",...ce,size:Q,__staticSelector:"Select",disabled:M,readOnly:S||!V,value:nt,onChange:je=>{ft(je.currentTarget.value),pt.openDropdown(),_&&pt.selectFirstOption()},onFocus:je=>{be&&V&&pt.openDropdown(),h?.(je)},onBlur:je=>{ie&&pt.clickSelectedOption(),V&&pt.closeDropdown();const Ye=typeof me=="string"&&(me in le?le[me]:Y.current[me]);ft(Ye&&Ye.label||""),p?.(je)},onClick:je=>{V?pt.openDropdown():pt.toggleDropdown(),A?.(je)},classNames:dt,styles:Mt,unstyled:s,pointer:!V,error:ye,attributes:ve})}),j.jsx(PG,{data:Z,hidden:S||M,filter:T,search:nt,limit:R,hiddenWhenEmpty:!$,withScrollArea:k,maxDropdownHeight:H,filterOptions:!!V&&He?.label!==nt,value:me,checkIconPosition:W,withCheckIcon:K,withAlignedLabels:X,nothingFoundMessage:$,unstyled:s,labelId:ce.label?`${Ce}-label`:void 0,"aria-label":ce.label?void 0:ce["aria-label"],renderOption:Ne,scrollAreaProps:F})]}),j.jsx(Qn.HiddenInput,{value:me,name:J,form:ne,disabled:M,...ge})]})});Uc.classes={...na.classes,...Qn.classes};Uc.displayName="@mantine/core/Select";const[bV,L0]=Ol("SliderProvider was not found in tree");var MN={root:"m_dd36362e",label:"m_c9357328",thumb:"m_c9a9a60a",trackContainer:"m_a8645c2",track:"m_c9ade57f",bar:"m_38aeed47",markWrapper:"m_b7b0423a",mark:"m_dd33bc19",markLabel:"m_68c77a5b"};const TN=U.forwardRef(({size:n,disabled:e,variant:t,color:r,thumbSize:i,radius:s,...a},o)=>{const{getStyles:l}=L0();return j.jsx(Je,{tabIndex:-1,variant:t,size:n,ref:o,...l("root"),...a})});TN.displayName="@mantine/core/SliderRoot";const RN=U.forwardRef(({max:n,min:e,value:t,position:r,label:i,dragging:s,onMouseDown:a,onKeyDownCapture:o,labelTransitionProps:l,labelAlwaysOn:c,thumbLabel:d,onFocus:h,onBlur:p,showLabelOnHover:A,isHovered:y,children:m=null,disabled:x},g)=>{const{getStyles:_}=L0(),[b,w]=U.useState(!1),I=c||s||b||A&&y;return j.jsxs(Je,{tabIndex:0,role:"slider","aria-label":d,"aria-valuemax":n,"aria-valuemin":e,"aria-valuenow":t,ref:g,__vars:{"--slider-thumb-offset":`${r}%`},..._("thumb",{focusable:!0}),mod:{dragging:s,disabled:x},onFocus:S=>{w(!0),typeof h=="function"&&h(S)},onBlur:S=>{w(!1),typeof p=="function"&&p(S)},onTouchStart:a,onMouseDown:a,onKeyDownCapture:o,onClick:S=>S.stopPropagation(),children:[m,j.jsx(Na,{mounted:i!=null&&!!I,transition:"fade",duration:0,...l,children:S=>j.jsx("div",{..._("label",{style:S}),children:i})})]})});RN.displayName="@mantine/core/SliderThumb";function DN({value:n,min:e,max:t}){const r=(n-e)/(t-e)*100;return Math.min(Math.max(r,0),100)}function wV({mark:n,offset:e,value:t,inverted:r=!1}){return r?typeof e=="number"&&n.value<=e||n.value>=t:typeof e=="number"?n.value>=e&&n.value<=t:n.value<=t}function kN({marks:n,min:e,max:t,disabled:r,value:i,offset:s,inverted:a}){const{getStyles:o}=L0();if(!n)return null;const l=n.map((c,d)=>U.createElement(Je,{...o("markWrapper"),__vars:{"--mark-offset":`${DN({value:c.value,min:e,max:t})}%`},key:d},j.jsx(Je,{...o("mark"),mod:{filled:wV({mark:c,value:i,offset:s,inverted:a}),disabled:r}}),c.label&&j.jsx("div",{...o("markLabel"),children:c.label})));return j.jsx("div",{children:l})}kN.displayName="@mantine/core/SliderMarks";function NN({filled:n,children:e,offset:t,disabled:r,marksOffset:i,inverted:s,containerProps:a,...o}){const{getStyles:l}=L0();return j.jsx(Je,{...l("trackContainer"),mod:{disabled:r},...a,children:j.jsxs(Je,{...l("track"),mod:{inverted:s,disabled:r},children:[j.jsx(Je,{mod:{inverted:s,disabled:r},__vars:{"--slider-bar-width":`calc(${n}% + 2 * var(--slider-size))`,"--slider-bar-offset":`calc(${t}% - var(--slider-size))`},...l("bar")}),e,j.jsx(kN,{...o,offset:i,disabled:r,inverted:s})]})})}NN.displayName="@mantine/core/SliderTrack";function EV({value:n,containerWidth:e,min:t,max:r,step:i,precision:s}){const o=(e?Math.min(Math.max(n,0),e)/e:n)*(r-t),l=(o!==0?Math.round(o/i)*i:0)+t,c=Math.max(l,t);return s!==void 0?Number(c.toFixed(s)):c}function hm(n,e){return parseFloat(n.toFixed(e))}function IV(n){if(!n)return 0;const e=n.toString().split(".");return e.length>1?e[1].length:0}function Yx(n,e){const r=[...e].sort((i,s)=>i.value-s.value).find(i=>i.value>n);return r?r.value:n}function Xx(n,e){const r=[...e].sort((i,s)=>s.value-i.value).find(i=>i.value<n);return r?r.value:n}function hS(n){const e=[...n].sort((t,r)=>t.value-r.value);return e.length>0?e[0].value:0}function fS(n){const e=[...n].sort((t,r)=>t.value-r.value);return e.length>0?e[e.length-1].value:100}const CV={radius:"xl",min:0,max:100,step:1,marks:[],label:n=>n,labelTransitionProps:{transition:"fade",duration:0},thumbLabel:"",showLabelOnHover:!0,scale:n=>n,size:"md"},SV=(n,{size:e,color:t,thumbSize:r,radius:i})=>({root:{"--slider-size":gn(e,"slider-size"),"--slider-color":t?cs(t,n):void 0,"--slider-radius":i===void 0?void 0:Dr(i),"--slider-thumb-size":r!==void 0?$e(r):"calc(var(--slider-size) * 2)"}}),F0=Tt((n,e)=>{const t=ct("Slider",CV,n),{classNames:r,styles:i,value:s,onChange:a,onChangeEnd:o,size:l,min:c,max:d,domain:h,step:p,precision:A,defaultValue:y,name:m,marks:x,label:g,labelTransitionProps:_,labelAlwaysOn:b,thumbLabel:w,showLabelOnHover:I,thumbChildren:S,disabled:M,unstyled:T,scale:R,inverted:k,className:H,style:Q,vars:V,hiddenInputProps:B,restrictToMarks:W,thumbProps:K,attributes:X,...$}=t,J=en({name:"Slider",props:t,classes:MN,classNames:r,className:H,styles:i,style:Q,attributes:X,vars:V,varsResolver:SV,unstyled:T}),{dir:ne}=iu(),[L,G]=U.useState(!1),[oe,Ae]=Ks({value:typeof s=="number"?ss(s,c,d):s,defaultValue:typeof y=="number"?ss(y,c,d):y,finalValue:ss(0,c,d),onChange:a}),ye=U.useRef(oe),he=U.useRef(o);U.useEffect(()=>{he.current=o},[o]);const fe=U.useRef(null),Ie=U.useRef(null),[Re,ge]=h||[c,d],Ne=DN({value:oe,min:Re,max:ge}),tt=R(oe),Ge=typeof g=="function"?g(tt):g,F=A??IV(p),re=U.useCallback(({x:ve})=>{if(!M){const ce=EV({value:ve,min:Re,max:ge,step:p,precision:F}),Z=ss(ce,c,d);Ae(W&&x?.length?c2(Z,x.map(Y=>Y.value)):Z),ye.current=Z}},[M,c,d,Re,ge,p,F,Ae,x,W]),Ee=U.useCallback(()=>{if(!M&&he.current){const ve=W&&x?.length?c2(ye.current,x.map(ce=>ce.value)):ye.current;he.current(ve)}},[M,x,W]),{ref:q,active:ee}=Zw(re,{onScrubEnd:Ee},ne),ie=U.useCallback(ve=>{!M&&he.current&&he.current(ve)},[M]),be=ve=>{if(!M)switch(ve.key){case"ArrowUp":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=Yx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(oe+p,c),d),F);Ae(ce),ie(ce);break}case"ArrowRight":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=ne==="rtl"?Xx(oe,x):Yx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(ne==="rtl"?oe-p:oe+p,c),d),F);Ae(ce),ie(ce);break}case"ArrowDown":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=Xx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(oe-p,c),d),F);Ae(ce),ie(ce);break}case"ArrowLeft":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=ne==="rtl"?Yx(oe,x):Xx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(ne==="rtl"?oe+p:oe-p,c),d),F);Ae(ce),ie(ce);break}case"Home":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){Ae(hS(x)),ie(hS(x));break}Ae(c),ie(c);break}case"End":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){Ae(fS(x)),ie(fS(x));break}Ae(d),ie(d);break}}};return j.jsx(bV,{value:{getStyles:J},children:j.jsxs(TN,{...$,ref:er(e,fe),onKeyDownCapture:be,onMouseDownCapture:()=>fe.current?.focus(),size:l,disabled:M,children:[j.jsx(NN,{inverted:k,offset:0,filled:Ne,marks:x,min:Re,max:ge,value:tt,disabled:M,containerProps:{ref:q,onMouseEnter:I?()=>G(!0):void 0,onMouseLeave:I?()=>G(!1):void 0},children:j.jsx(RN,{max:ge,min:Re,value:tt,position:Ne,dragging:ee,label:Ge,ref:Ie,labelTransitionProps:_,labelAlwaysOn:b,thumbLabel:w,showLabelOnHover:I,isHovered:L,disabled:M,...K,children:S})}),j.jsx("input",{type:"hidden",name:m,value:tt,...B})]})})});F0.classes=MN;F0.displayName="@mantine/core/Slider";var QN={root:"m_6d731127"};const BV={gap:"md",align:"stretch",justify:"flex-start"},MV=(n,{gap:e,align:t,justify:r})=>({root:{"--stack-gap":Jw(e),"--stack-align":t,"--stack-justify":r}}),lI=Tt((n,e)=>{const t=ct("Stack",BV,n),{classNames:r,className:i,style:s,styles:a,unstyled:o,vars:l,align:c,justify:d,gap:h,variant:p,attributes:A,...y}=t,m=en({name:"Stack",props:t,classes:QN,className:i,style:s,classNames:r,styles:a,unstyled:o,attributes:A,vars:l,varsResolver:MV});return j.jsx(Je,{ref:e,...m("root"),variant:p,...y})});lI.classes=QN;lI.displayName="@mantine/core/Stack";const cI=Tt((n,e)=>{const t=ct("TextInput",null,n);return j.jsx(na,{component:"input",ref:e,...t,__staticSelector:"TextInput"})});cI.classes=na.classes;cI.displayName="@mantine/core/TextInput";const TV="modulepreload",RV=function(n){return"/"+n},pS={},DV=function(e,t,r){let i=Promise.resolve();if(t&&t.length>0){let l=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=a?.nonce||a?.getAttribute("nonce");i=l(t.map(c=>{if(c=RV(c),c in pS)return;pS[c]=!0;const d=c.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":TV,d||(p.as="script"),p.crossOrigin="",p.href=c,o&&p.setAttribute("nonce",o),document.head.appendChild(p),d)return new Promise((A,y)=>{p.addEventListener("load",A),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return e().catch(s)})};const uI="181",Qd={ROTATE:0,DOLLY:1,PAN:2},Bd={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},kV=0,AS=1,NV=2,PN=1,LN=2,uo=3,Eo=0,Bi=1,rs=2,xo=0,Pd=1,mS=2,gS=3,yS=4,QV=5,Dc=100,PV=101,LV=102,FV=103,zV=104,UV=200,OV=201,$V=202,GV=203,vb=204,_b=205,VV=206,HV=207,jV=208,WV=209,qV=210,YV=211,XV=212,JV=213,KV=214,bb=0,wb=1,Eb=2,Hd=3,Ib=4,Cb=5,Sb=6,Bb=7,dI=0,ZV=1,eH=2,Pl=0,tH=1,nH=2,rH=3,FN=4,iH=5,sH=6,aH=7,xS="attached",oH="detached",zN=300,jd=301,Wd=302,Mb=303,Tb=304,z0=306,Fl=1e3,os=1001,Fg=1002,mr=1003,UN=1004,tp=1005,ir=1006,mg=1007,Ia=1008,lH=1008,ni=1009,ON=1010,$N=1011,Ip=1012,hI=1013,Mi=1014,js=1015,fh=1016,fI=1017,pI=1018,Cp=1020,GN=35902,VN=35899,HN=1021,jN=1022,sr=1023,Sp=1026,Bp=1027,AI=1028,mI=1029,gI=1030,U0=1031,vo=1033,gg=33776,yg=33777,xg=33778,vg=33779,Rb=35840,Db=35841,kb=35842,Nb=35843,Qb=36196,Pb=37492,Lb=37496,Fb=37808,zb=37809,Ub=37810,Ob=37811,$b=37812,Gb=37813,Vb=37814,Hb=37815,jb=37816,Wb=37817,qb=37818,Yb=37819,Xb=37820,Jb=37821,Kb=36492,Zb=36494,ew=36495,tw=36283,nw=36284,rw=36285,iw=36286,Mp=2300,Tp=2301,Jx=2302,vS=2400,_S=2401,bS=2402,cH=2500,uH=0,WN=1,sw=2,dH=3200,hH=3201,yI=0,fH=1,Dl="",Ar="srgb",ri="srgb-linear",zg="linear",Rn="srgb",rd=7680,wS=519,pH=512,AH=513,mH=514,qN=515,gH=516,yH=517,xH=518,vH=519,aw=35044,ow=35048,Ug="300 es",Ca=2e3,Og=2001;function YN(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Rp(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function _H(){const n=Rp("canvas");return n.style.display="block",n}const ES={};function $g(...n){const e="THREE."+n.shift()}function Pt(...n){const e="THREE."+n.shift()}function sn(...n){const e="THREE."+n.shift()}function Dp(...n){const e=n.join(" ");e in ES||(ES[e]=!0,Pt(...n))}function bH(n,e,t){return new Promise(function(r,i){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:i();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:r()}}setTimeout(s,t)})}class ou{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const r=t[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const qr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let IS=1234567;const fp=Math.PI/180,qd=180/Math.PI;function Ys(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(qr[n&255]+qr[n>>8&255]+qr[n>>16&255]+qr[n>>24&255]+"-"+qr[e&255]+qr[e>>8&255]+"-"+qr[e>>16&15|64]+qr[e>>24&255]+"-"+qr[t&63|128]+qr[t>>8&255]+"-"+qr[t>>16&255]+qr[t>>24&255]+qr[r&255]+qr[r>>8&255]+qr[r>>16&255]+qr[r>>24&255]).toLowerCase()}function nn(n,e,t){return Math.max(e,Math.min(t,n))}function xI(n,e){return(n%e+e)%e}function wH(n,e,t,r,i){return r+(n-e)*(i-r)/(t-e)}function EH(n,e,t){return n!==e?(t-n)/(e-n):0}function pp(n,e,t){return(1-t)*n+t*e}function IH(n,e,t,r){return pp(n,e,1-Math.exp(-t*r))}function CH(n,e=1){return e-Math.abs(xI(n,e*2)-e)}function SH(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function BH(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function MH(n,e){return n+Math.floor(Math.random()*(e-n+1))}function TH(n,e){return n+Math.random()*(e-n)}function RH(n){return n*(.5-Math.random())}function DH(n){n!==void 0&&(IS=n);let e=IS+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function kH(n){return n*fp}function NH(n){return n*qd}function QH(n){return(n&n-1)===0&&n!==0}function PH(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function LH(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function FH(n,e,t,r,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+r)/2),d=a((e+r)/2),h=s((e-r)/2),p=a((e-r)/2),A=s((r-e)/2),y=a((r-e)/2);switch(i){case"XYX":n.set(o*d,l*h,l*p,o*c);break;case"YZY":n.set(l*p,o*d,l*h,o*c);break;case"ZXZ":n.set(l*h,l*p,o*d,o*c);break;case"XZX":n.set(o*d,l*y,l*A,o*c);break;case"YXY":n.set(l*A,o*d,l*y,o*c);break;case"ZYZ":n.set(l*y,l*A,o*d,o*c);break;default:Pt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function $s(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Sn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const XN={DEG2RAD:fp,RAD2DEG:qd,generateUUID:Ys,clamp:nn,euclideanModulo:xI,mapLinear:wH,inverseLerp:EH,lerp:pp,damp:IH,pingpong:CH,smoothstep:SH,smootherstep:BH,randInt:MH,randFloat:TH,randFloatSpread:RH,seededRandom:DH,degToRad:kH,radToDeg:NH,isPowerOfTwo:QH,ceilPowerOfTwo:PH,floorPowerOfTwo:LH,setQuaternionFromProperEuler:FH,normalize:Sn,denormalize:$s};class Dt{constructor(e=0,t=0){Dt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+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=nn(this.x,e.x,t.x),this.y=nn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=nn(this.x,e,t),this.y=nn(this.y,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(nn(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(nn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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 r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class In{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,a,o){let l=r[i+0],c=r[i+1],d=r[i+2],h=r[i+3],p=s[a+0],A=s[a+1],y=s[a+2],m=s[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h;return}if(o>=1){e[t+0]=p,e[t+1]=A,e[t+2]=y,e[t+3]=m;return}if(h!==m||l!==p||c!==A||d!==y){let x=l*p+c*A+d*y+h*m;x<0&&(p=-p,A=-A,y=-y,m=-m,x=-x);let g=1-o;if(x<.9995){const _=Math.acos(x),b=Math.sin(_);g=Math.sin(g*_)/b,o=Math.sin(o*_)/b,l=l*g+p*o,c=c*g+A*o,d=d*g+y*o,h=h*g+m*o}else{l=l*g+p*o,c=c*g+A*o,d=d*g+y*o,h=h*g+m*o;const _=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=_,c*=_,d*=_,h*=_}}e[t]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h}static multiplyQuaternionsFlat(e,t,r,i,s,a){const o=r[i],l=r[i+1],c=r[i+2],d=r[i+3],h=s[a],p=s[a+1],A=s[a+2],y=s[a+3];return e[t]=o*y+d*h+l*A-c*p,e[t+1]=l*y+d*p+c*h-o*A,e[t+2]=c*y+d*A+o*p-l*h,e[t+3]=d*y-o*h-l*p-c*A,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,r,i){return this._x=e,this._y=t,this._z=r,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 r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(r/2),d=o(i/2),h=o(s/2),p=l(r/2),A=l(i/2),y=l(s/2);switch(a){case"XYZ":this._x=p*d*h+c*A*y,this._y=c*A*h-p*d*y,this._z=c*d*y+p*A*h,this._w=c*d*h-p*A*y;break;case"YXZ":this._x=p*d*h+c*A*y,this._y=c*A*h-p*d*y,this._z=c*d*y-p*A*h,this._w=c*d*h+p*A*y;break;case"ZXY":this._x=p*d*h-c*A*y,this._y=c*A*h+p*d*y,this._z=c*d*y+p*A*h,this._w=c*d*h-p*A*y;break;case"ZYX":this._x=p*d*h-c*A*y,this._y=c*A*h+p*d*y,this._z=c*d*y-p*A*h,this._w=c*d*h+p*A*y;break;case"YZX":this._x=p*d*h+c*A*y,this._y=c*A*h+p*d*y,this._z=c*d*y-p*A*h,this._w=c*d*h-p*A*y;break;case"XZY":this._x=p*d*h-c*A*y,this._y=c*A*h-p*d*y,this._z=c*d*y+p*A*h,this._w=c*d*h+p*A*y;break;default:Pt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],d=t[6],h=t[10],p=r+o+h;if(p>0){const A=.5/Math.sqrt(p+1);this._w=.25/A,this._x=(d-l)*A,this._y=(s-c)*A,this._z=(a-i)*A}else if(r>o&&r>h){const A=2*Math.sqrt(1+r-o-h);this._w=(d-l)/A,this._x=.25*A,this._y=(i+a)/A,this._z=(s+c)/A}else if(o>h){const A=2*Math.sqrt(1+o-r-h);this._w=(s-c)/A,this._x=(i+a)/A,this._y=.25*A,this._z=(l+d)/A}else{const A=2*Math.sqrt(1+h-r-o);this._w=(a-i)/A,this._x=(s+c)/A,this._y=(l+d)/A,this._z=.25*A}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(nn(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,t/r);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 e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,d=t._w;return this._x=r*d+a*o+i*c-s*l,this._y=i*d+a*l+s*o-r*c,this._z=s*d+a*c+r*l-i*o,this._w=a*d-r*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let r=e._x,i=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),d=Math.sin(c);l=Math.sin(l*c)/d,t=Math.sin(t*c)/d,this._x=this._x*l+r*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+r*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class de{constructor(e=0,t=0,r=0){de.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,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(CS.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(CS.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*r),d=2*(o*t-s*i),h=2*(s*r-a*t);return this.x=t+l*c+a*h-o*d,this.y=r+l*d+o*c-s*h,this.z=i+l*h+s*d-a*c,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,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[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=nn(this.x,e.x,t.x),this.y=nn(this.y,e.y,t.y),this.z=nn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=nn(this.x,e,t),this.y=nn(this.y,e,t),this.z=nn(this.z,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(nn(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Kx.copy(this).projectOnVector(e),this.sub(Kx)}reflect(e){return this.sub(Kx.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(nn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+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,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,r=Math.sqrt(1-t*t);return this.x=r*Math.cos(e),this.y=t,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Kx=new de,CS=new In;class Jt{constructor(e,t,r,i,s,a,o,l,c){Jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,r,i,s,a,o,l,c)}set(e,t,r,i,s,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=t,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.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 r=e.elements,i=t.elements,s=this.elements,a=r[0],o=r[3],l=r[6],c=r[1],d=r[4],h=r[7],p=r[2],A=r[5],y=r[8],m=i[0],x=i[3],g=i[6],_=i[1],b=i[4],w=i[7],I=i[2],S=i[5],M=i[8];return s[0]=a*m+o*_+l*I,s[3]=a*x+o*b+l*S,s[6]=a*g+o*w+l*M,s[1]=c*m+d*_+h*I,s[4]=c*x+d*b+h*S,s[7]=c*g+d*w+h*M,s[2]=p*m+A*_+y*I,s[5]=p*x+A*b+y*S,s[8]=p*g+A*w+y*M,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],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return t*a*d-t*o*c-r*s*d+r*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,p=o*l-d*s,A=c*s-a*l,y=t*h+r*p+i*A;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/y;return e[0]=h*m,e[1]=(i*c-d*r)*m,e[2]=(o*r-i*a)*m,e[3]=p*m,e[4]=(d*t-i*l)*m,e[5]=(i*s-o*t)*m,e[6]=A*m,e[7]=(r*l-c*t)*m,e[8]=(a*t-r*s)*m,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,r,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Zx.makeScale(e,t)),this}rotate(e){return this.premultiply(Zx.makeRotation(-e)),this}translate(e,t){return this.premultiply(Zx.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),r=Math.sin(e);return this.set(t,-r,0,r,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,r=e.elements;for(let i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Zx=new Jt,SS=new Jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),BS=new Jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zH(){const n={enabled:!0,workingColorSpace:ri,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Rn&&(i.r=_o(i.r),i.g=_o(i.g),i.b=_o(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Rn&&(i.r=Ld(i.r),i.g=Ld(i.g),i.b=Ld(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Dl?zg:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return Dp("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return Dp("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[ri]:{primaries:e,whitePoint:r,transfer:zg,toXYZ:SS,fromXYZ:BS,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ar},outputColorSpaceConfig:{drawingBufferColorSpace:Ar}},[Ar]:{primaries:e,whitePoint:r,transfer:Rn,toXYZ:SS,fromXYZ:BS,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ar}}}),n}const mn=zH();function _o(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Ld(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let id;class UH{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{id===void 0&&(id=Rp("canvas")),id.width=e.width,id.height=e.height;const i=id.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=id}return r.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Rp("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=_o(s[a]/255)*255;return r.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let r=0;r<t.length;r++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[r]=Math.floor(_o(t[r]/255)*255):t[r]=_o(t[r]);return{data:t,width:e.width,height:e.height}}else return Pt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let OH=0;class vI{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:OH++}),this.uuid=Ys(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(ev(i[a].image)):s.push(ev(i[a]))}else s=ev(i);r.url=s}return t||(e.images[this.uuid]=r),r}}function ev(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?UH.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Pt("Texture: Unable to serialize Texture."),{})}let $H=0;const tv=new de;class ar extends ou{constructor(e=ar.DEFAULT_IMAGE,t=ar.DEFAULT_MAPPING,r=os,i=os,s=ir,a=Ia,o=sr,l=ni,c=ar.DEFAULT_ANISOTROPY,d=Dl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:$H++}),this.uuid=Ys(),this.name="",this.source=new vI(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Dt(0,0),this.repeat=new Dt(1,1),this.center=new Dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Jt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(tv).x}get height(){return this.source.getSize(tv).y}get depth(){return this.source.getSize(tv).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 r=e[t];if(r===void 0){Pt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Pt(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={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&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==zN)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Fl:e.x=e.x-Math.floor(e.x);break;case os:e.x=e.x<0?0:1;break;case Fg:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Fl:e.y=e.y-Math.floor(e.y);break;case os:e.y=e.y<0?0:1;break;case Fg:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ar.DEFAULT_IMAGE=null;ar.DEFAULT_MAPPING=zN;ar.DEFAULT_ANISOTROPY=1;class Kt{constructor(e=0,t=0,r=0,i=1){Kt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,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,r,i){return this.x=e,this.y=t,this.z=r,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=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*r+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,i,s;const l=e.elements,c=l[0],d=l[4],h=l[8],p=l[1],A=l[5],y=l[9],m=l[2],x=l[6],g=l[10];if(Math.abs(d-p)<.01&&Math.abs(h-m)<.01&&Math.abs(y-x)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+m)<.1&&Math.abs(y+x)<.1&&Math.abs(c+A+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,w=(A+1)/2,I=(g+1)/2,S=(d+p)/4,M=(h+m)/4,T=(y+x)/4;return b>w&&b>I?b<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(b),i=S/r,s=M/r):w>I?w<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),r=S/i,s=T/i):I<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(I),r=M/s,i=T/s),this.set(r,i,s,t),this}let _=Math.sqrt((x-y)*(x-y)+(h-m)*(h-m)+(p-d)*(p-d));return Math.abs(_)<.001&&(_=1),this.x=(x-y)/_,this.y=(h-m)/_,this.z=(p-d)/_,this.w=Math.acos((c+A+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=nn(this.x,e.x,t.x),this.y=nn(this.y,e.y,t.y),this.z=nn(this.z,e.z,t.z),this.w=nn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=nn(this.x,e,t),this.y=nn(this.y,e,t),this.z=nn(this.z,e,t),this.w=nn(this.w,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(nn(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,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 GH extends ou{constructor(e=1,t=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ir,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=r.depth,this.scissor=new Kt(0,0,e,t),this.scissorTest=!1,this.viewport=new Kt(0,0,e,t);const i={width:e,height:t,depth:r.depth},s=new ar(i);this.textures=[];const a=r.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const t={minFilter:ir,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,r=1){if(this.width!==e||this.height!==t||this.depth!==r){this.width=e,this.height=t,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(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,r=e.textures.length;t<r;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new vI(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Qa extends GH{constructor(e=1,t=1,r={}){super(e,t,r),this.isWebGLRenderTarget=!0}}class Ta extends ar{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=mr,this.minFilter=mr,this.wrapR=os,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class JN extends Qa{constructor(e=1,t=1,r=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=r,this.texture=new Ta(null,e,t,r),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class KN extends ar{constructor(e=null,t=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=mr,this.minFilter=mr,this.wrapR=os,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ms{constructor(e=new de(1/0,1/0,1/0),t=new de(-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,r=e.length;t<r;t+=3)this.expandByPoint(Ts.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(Ts.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const r=Ts.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),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 r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ts):Ts.fromBufferAttribute(s,a),Ts.applyMatrix4(e.matrixWorld),this.expandByPoint(Ts);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),fm.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),fm.copy(r.boundingBox)),fm.applyMatrix4(e.matrixWorld),this.union(fm)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ts),Ts.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Mf),pm.subVectors(this.max,Mf),sd.subVectors(e.a,Mf),ad.subVectors(e.b,Mf),od.subVectors(e.c,Mf),ml.subVectors(ad,sd),gl.subVectors(od,ad),gc.subVectors(sd,od);let t=[0,-ml.z,ml.y,0,-gl.z,gl.y,0,-gc.z,gc.y,ml.z,0,-ml.x,gl.z,0,-gl.x,gc.z,0,-gc.x,-ml.y,ml.x,0,-gl.y,gl.x,0,-gc.y,gc.x,0];return!nv(t,sd,ad,od,pm)||(t=[1,0,0,0,1,0,0,0,1],!nv(t,sd,ad,od,pm))?!1:(Am.crossVectors(ml,gl),t=[Am.x,Am.y,Am.z],nv(t,sd,ad,od,pm))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ts).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ts).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(no[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),no[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),no[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),no[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),no[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),no[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),no[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),no[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(no),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 no=[new de,new de,new de,new de,new de,new de,new de,new de],Ts=new de,fm=new ms,sd=new de,ad=new de,od=new de,ml=new de,gl=new de,gc=new de,Mf=new de,pm=new de,Am=new de,yc=new de;function nv(n,e,t,r,i){for(let s=0,a=n.length-3;s<=a;s+=3){yc.fromArray(n,s);const o=i.x*Math.abs(yc.x)+i.y*Math.abs(yc.y)+i.z*Math.abs(yc.z),l=e.dot(yc),c=t.dot(yc),d=r.dot(yc);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const VH=new ms,Tf=new de,rv=new de;class Fa{constructor(e=new de,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 r=this.center;t!==void 0?r.copy(t):VH.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));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 r=this.center.distanceToSquared(e);return t.copy(e),r>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;Tf.subVectors(e,this.center);const t=Tf.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),i=(r-this.radius)*.5;this.center.addScaledVector(Tf,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(rv.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Tf.copy(e.center).add(rv)),this.expandByPoint(Tf.copy(e.center).sub(rv))),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 ro=new de,iv=new de,mm=new de,yl=new de,sv=new de,gm=new de,av=new de;class ph{constructor(e=new de,t=new de(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,ro)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ro.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ro.copy(this.origin).addScaledVector(this.direction,t),ro.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){iv.copy(e).add(t).multiplyScalar(.5),mm.copy(t).sub(e).normalize(),yl.copy(this.origin).sub(iv);const s=e.distanceTo(t)*.5,a=-this.direction.dot(mm),o=yl.dot(this.direction),l=-yl.dot(mm),c=yl.lengthSq(),d=Math.abs(1-a*a);let h,p,A,y;if(d>0)if(h=a*l-o,p=a*o-l,y=s*d,h>=0)if(p>=-y)if(p<=y){const m=1/d;h*=m,p*=m,A=h*(h+a*p+2*o)+p*(a*h+p+2*l)+c}else p=s,h=Math.max(0,-(a*p+o)),A=-h*h+p*(p+2*l)+c;else p=-s,h=Math.max(0,-(a*p+o)),A=-h*h+p*(p+2*l)+c;else p<=-y?(h=Math.max(0,-(-a*s+o)),p=h>0?-s:Math.min(Math.max(-s,-l),s),A=-h*h+p*(p+2*l)+c):p<=y?(h=0,p=Math.min(Math.max(-s,-l),s),A=p*(p+2*l)+c):(h=Math.max(0,-(a*s+o)),p=h>0?s:Math.min(Math.max(-s,-l),s),A=-h*h+p*(p+2*l)+c);else p=a>0?-s:s,h=Math.max(0,-(a*p+o)),A=-h*h+p*(p+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(iv).addScaledVector(mm,p),A}intersectSphere(e,t){ro.subVectors(e.center,this.origin);const r=ro.dot(this.direction),i=ro.dot(ro)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,s,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,p=this.origin;return c>=0?(r=(e.min.x-p.x)*c,i=(e.max.x-p.x)*c):(r=(e.max.x-p.x)*c,i=(e.min.x-p.x)*c),d>=0?(s=(e.min.y-p.y)*d,a=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,a=(e.min.y-p.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-p.z)*h,l=(e.max.z-p.z)*h):(o=(e.max.z-p.z)*h,l=(e.min.z-p.z)*h),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,t)}intersectsBox(e){return this.intersectBox(e,ro)!==null}intersectTriangle(e,t,r,i,s){sv.subVectors(t,e),gm.subVectors(r,e),av.crossVectors(sv,gm);let a=this.direction.dot(av),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;yl.subVectors(this.origin,e);const l=o*this.direction.dot(gm.crossVectors(yl,gm));if(l<0)return null;const c=o*this.direction.dot(sv.cross(yl));if(c<0||l+c>a)return null;const d=-o*yl.dot(av);return d<0?null:this.at(d/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ft{constructor(e,t,r,i,s,a,o,l,c,d,h,p,A,y,m,x){Ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,r,i,s,a,o,l,c,d,h,p,A,y,m,x)}set(e,t,r,i,s,a,o,l,c,d,h,p,A,y,m,x){const g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=i,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=d,g[10]=h,g[14]=p,g[3]=A,g[7]=y,g[11]=m,g[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ft().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[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,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,i=1/ld.setFromMatrixColumn(e,0).length(),s=1/ld.setFromMatrixColumn(e,1).length(),a=1/ld.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*s,t[5]=r[5]*s,t[6]=r[6]*s,t[7]=0,t[8]=r[8]*a,t[9]=r[9]*a,t[10]=r[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=a*d,A=a*h,y=o*d,m=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=A+y*c,t[5]=p-m*c,t[9]=-o*l,t[2]=m-p*c,t[6]=y+A*c,t[10]=a*l}else if(e.order==="YXZ"){const p=l*d,A=l*h,y=c*d,m=c*h;t[0]=p+m*o,t[4]=y*o-A,t[8]=a*c,t[1]=a*h,t[5]=a*d,t[9]=-o,t[2]=A*o-y,t[6]=m+p*o,t[10]=a*l}else if(e.order==="ZXY"){const p=l*d,A=l*h,y=c*d,m=c*h;t[0]=p-m*o,t[4]=-a*h,t[8]=y+A*o,t[1]=A+y*o,t[5]=a*d,t[9]=m-p*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const p=a*d,A=a*h,y=o*d,m=o*h;t[0]=l*d,t[4]=y*c-A,t[8]=p*c+m,t[1]=l*h,t[5]=m*c+p,t[9]=A*c-y,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const p=a*l,A=a*c,y=o*l,m=o*c;t[0]=l*d,t[4]=m-p*h,t[8]=y*h+A,t[1]=h,t[5]=a*d,t[9]=-o*d,t[2]=-c*d,t[6]=A*h+y,t[10]=p-m*h}else if(e.order==="XZY"){const p=a*l,A=a*c,y=o*l,m=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=p*h+m,t[5]=a*d,t[9]=A*h-y,t[2]=y*h-A,t[6]=o*d,t[10]=m*h+p}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(HH,e,jH)}lookAt(e,t,r){const i=this.elements;return zi.subVectors(e,t),zi.lengthSq()===0&&(zi.z=1),zi.normalize(),xl.crossVectors(r,zi),xl.lengthSq()===0&&(Math.abs(r.z)===1?zi.x+=1e-4:zi.z+=1e-4,zi.normalize(),xl.crossVectors(r,zi)),xl.normalize(),ym.crossVectors(zi,xl),i[0]=xl.x,i[4]=ym.x,i[8]=zi.x,i[1]=xl.y,i[5]=ym.y,i[9]=zi.y,i[2]=xl.z,i[6]=ym.z,i[10]=zi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,a=r[0],o=r[4],l=r[8],c=r[12],d=r[1],h=r[5],p=r[9],A=r[13],y=r[2],m=r[6],x=r[10],g=r[14],_=r[3],b=r[7],w=r[11],I=r[15],S=i[0],M=i[4],T=i[8],R=i[12],k=i[1],H=i[5],Q=i[9],V=i[13],B=i[2],W=i[6],K=i[10],X=i[14],$=i[3],J=i[7],ne=i[11],L=i[15];return s[0]=a*S+o*k+l*B+c*$,s[4]=a*M+o*H+l*W+c*J,s[8]=a*T+o*Q+l*K+c*ne,s[12]=a*R+o*V+l*X+c*L,s[1]=d*S+h*k+p*B+A*$,s[5]=d*M+h*H+p*W+A*J,s[9]=d*T+h*Q+p*K+A*ne,s[13]=d*R+h*V+p*X+A*L,s[2]=y*S+m*k+x*B+g*$,s[6]=y*M+m*H+x*W+g*J,s[10]=y*T+m*Q+x*K+g*ne,s[14]=y*R+m*V+x*X+g*L,s[3]=_*S+b*k+w*B+I*$,s[7]=_*M+b*H+w*W+I*J,s[11]=_*T+b*Q+w*K+I*ne,s[15]=_*R+b*V+w*X+I*L,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],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],p=e[10],A=e[14],y=e[3],m=e[7],x=e[11],g=e[15];return y*(+s*l*h-i*c*h-s*o*p+r*c*p+i*o*A-r*l*A)+m*(+t*l*A-t*c*p+s*a*p-i*a*A+i*c*d-s*l*d)+x*(+t*c*h-t*o*A-s*a*h+r*a*A+s*o*d-r*c*d)+g*(-i*o*d-t*l*h+t*o*p+i*a*h-r*a*p+r*l*d)}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,r){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]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],p=e[10],A=e[11],y=e[12],m=e[13],x=e[14],g=e[15],_=h*x*c-m*p*c+m*l*A-o*x*A-h*l*g+o*p*g,b=y*p*c-d*x*c-y*l*A+a*x*A+d*l*g-a*p*g,w=d*m*c-y*h*c+y*o*A-a*m*A-d*o*g+a*h*g,I=y*h*l-d*m*l-y*o*p+a*m*p+d*o*x-a*h*x,S=t*_+r*b+i*w+s*I;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/S;return e[0]=_*M,e[1]=(m*p*s-h*x*s-m*i*A+r*x*A+h*i*g-r*p*g)*M,e[2]=(o*x*s-m*l*s+m*i*c-r*x*c-o*i*g+r*l*g)*M,e[3]=(h*l*s-o*p*s-h*i*c+r*p*c+o*i*A-r*l*A)*M,e[4]=b*M,e[5]=(d*x*s-y*p*s+y*i*A-t*x*A-d*i*g+t*p*g)*M,e[6]=(y*l*s-a*x*s-y*i*c+t*x*c+a*i*g-t*l*g)*M,e[7]=(a*p*s-d*l*s+d*i*c-t*p*c-a*i*A+t*l*A)*M,e[8]=w*M,e[9]=(y*h*s-d*m*s-y*r*A+t*m*A+d*r*g-t*h*g)*M,e[10]=(a*m*s-y*o*s+y*r*c-t*m*c-a*r*g+t*o*g)*M,e[11]=(d*o*s-a*h*s-d*r*c+t*h*c+a*r*A-t*o*A)*M,e[12]=I*M,e[13]=(d*m*i-y*h*i+y*r*p-t*m*p-d*r*x+t*h*x)*M,e[14]=(y*o*i-a*m*i-y*r*l+t*m*l+a*r*x-t*o*x)*M,e[15]=(a*h*i-d*o*i+d*r*l-t*h*l-a*r*p+t*o*p)*M,this}scale(e){const t=this.elements,r=e.x,i=e.y,s=e.z;return t[0]*=r,t[4]*=i,t[8]*=s,t[1]*=r,t[5]*=i,t[9]*=s,t[2]*=r,t[6]*=i,t[10]*=s,t[3]*=r,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=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,r,i))}makeTranslation(e,t,r){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,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),i=Math.sin(t),s=1-r,a=e.x,o=e.y,l=e.z,c=s*a,d=s*o;return this.set(c*a+r,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+r,d*l-i*a,0,c*l-i*o,d*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){const i=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,d=a+a,h=o+o,p=s*c,A=s*d,y=s*h,m=a*d,x=a*h,g=o*h,_=l*c,b=l*d,w=l*h,I=r.x,S=r.y,M=r.z;return i[0]=(1-(m+g))*I,i[1]=(A+w)*I,i[2]=(y-b)*I,i[3]=0,i[4]=(A-w)*S,i[5]=(1-(p+g))*S,i[6]=(x+_)*S,i[7]=0,i[8]=(y+b)*M,i[9]=(x-_)*M,i[10]=(1-(p+m))*M,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){const i=this.elements;let s=ld.set(i[0],i[1],i[2]).length();const a=ld.set(i[4],i[5],i[6]).length(),o=ld.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Rs.copy(this);const c=1/s,d=1/a,h=1/o;return Rs.elements[0]*=c,Rs.elements[1]*=c,Rs.elements[2]*=c,Rs.elements[4]*=d,Rs.elements[5]*=d,Rs.elements[6]*=d,Rs.elements[8]*=h,Rs.elements[9]*=h,Rs.elements[10]*=h,t.setFromRotationMatrix(Rs),r.x=s,r.y=a,r.z=o,this}makePerspective(e,t,r,i,s,a,o=Ca,l=!1){const c=this.elements,d=2*s/(t-e),h=2*s/(r-i),p=(t+e)/(t-e),A=(r+i)/(r-i);let y,m;if(l)y=s/(a-s),m=a*s/(a-s);else if(o===Ca)y=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Og)y=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=h,c[9]=A,c[13]=0,c[2]=0,c[6]=0,c[10]=y,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,r,i,s,a,o=Ca,l=!1){const c=this.elements,d=2/(t-e),h=2/(r-i),p=-(t+e)/(t-e),A=-(r+i)/(r-i);let y,m;if(l)y=1/(a-s),m=a/(a-s);else if(o===Ca)y=-2/(a-s),m=-(a+s)/(a-s);else if(o===Og)y=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=h,c[9]=0,c[13]=A,c[2]=0,c[6]=0,c[10]=y,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const ld=new de,Rs=new Ft,HH=new de(0,0,0),jH=new de(1,1,1),xl=new de,ym=new de,zi=new de,MS=new Ft,TS=new In;class Hi{constructor(e=0,t=0,r=0,i=Hi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,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,r,i=this._order){return this._x=e,this._y=t,this._z=r,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,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],p=i[6],A=i[10];switch(t){case"XYZ":this._y=Math.asin(nn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,A),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-nn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,A),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(nn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,A),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-nn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,A),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(nn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,A));break;case"XZY":this._z=Math.asin(-nn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,A),this._y=0);break;default:Pt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return MS.makeRotationFromQuaternion(e),this.setFromRotationMatrix(MS,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return TS.setFromEuler(this),this.setFromQuaternion(TS,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Hi.DEFAULT_ORDER="XYZ";class _I{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let WH=0;const RS=new de,cd=new In,io=new Ft,xm=new de,Rf=new de,qH=new de,YH=new In,DS=new de(1,0,0),kS=new de(0,1,0),NS=new de(0,0,1),QS={type:"added"},XH={type:"removed"},ud={type:"childadded",child:null},ov={type:"childremoved",child:null};class zn extends ou{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:WH++}),this.uuid=Ys(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=zn.DEFAULT_UP.clone();const e=new de,t=new Hi,r=new In,i=new de(1,1,1);function s(){r.setFromEuler(t,!1)}function a(){t.setFromQuaternion(r,void 0,!1)}t._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ft},normalMatrix:{value:new Jt}}),this.matrix=new Ft,this.matrixWorld=new Ft,this.matrixAutoUpdate=zn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=zn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new _I,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 cd.setFromAxisAngle(e,t),this.quaternion.multiply(cd),this}rotateOnWorldAxis(e,t){return cd.setFromAxisAngle(e,t),this.quaternion.premultiply(cd),this}rotateX(e){return this.rotateOnAxis(DS,e)}rotateY(e){return this.rotateOnAxis(kS,e)}rotateZ(e){return this.rotateOnAxis(NS,e)}translateOnAxis(e,t){return RS.copy(e).applyQuaternion(this.quaternion),this.position.add(RS.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(DS,e)}translateY(e){return this.translateOnAxis(kS,e)}translateZ(e){return this.translateOnAxis(NS,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(io.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?xm.copy(e):xm.set(e,t,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Rf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?io.lookAt(Rf,xm,this.up):io.lookAt(xm,Rf,this.up),this.quaternion.setFromRotationMatrix(io),i&&(io.extractRotation(i.matrixWorld),cd.setFromRotationMatrix(io),this.quaternion.premultiply(cd.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(sn("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(QS),ud.child=e,this.dispatchEvent(ud),ud.child=null):sn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(XH),ov.child=e,this.dispatchEvent(ov),ov.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),io.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),io.multiply(e.parent.matrixWorld)),e.applyMatrix4(io),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(QS),ud.child=e,this.dispatchEvent(ud),ud.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 r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rf,e,qH),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rf,YH,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 r=0,i=t.length;r<i;r++)t[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].updateMatrixWorld(e)}updateWorldMatrix(e,t){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(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(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(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(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),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),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(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&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),p=a(e.skeletons),A=a(e.animations),y=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),d.length>0&&(r.images=d),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),A.length>0&&(r.animations=A),y.length>0&&(r.nodes=y)}return r.object=i,r;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}zn.DEFAULT_UP=new de(0,1,0);zn.DEFAULT_MATRIX_AUTO_UPDATE=!0;zn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ds=new de,so=new de,lv=new de,ao=new de,dd=new de,hd=new de,PS=new de,cv=new de,uv=new de,dv=new de,hv=new Kt,fv=new Kt,pv=new Kt;class Gs{constructor(e=new de,t=new de,r=new de){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),Ds.subVectors(e,t),i.cross(Ds);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){Ds.subVectors(i,t),so.subVectors(r,t),lv.subVectors(e,t);const a=Ds.dot(Ds),o=Ds.dot(so),l=Ds.dot(lv),c=so.dot(so),d=so.dot(lv),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const p=1/h,A=(c*l-o*d)*p,y=(a*d-o*l)*p;return s.set(1-A-y,y,A)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,ao)===null?!1:ao.x>=0&&ao.y>=0&&ao.x+ao.y<=1}static getInterpolation(e,t,r,i,s,a,o,l){return this.getBarycoord(e,t,r,i,ao)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,ao.x),l.addScaledVector(a,ao.y),l.addScaledVector(o,ao.z),l)}static getInterpolatedAttribute(e,t,r,i,s,a){return hv.setScalar(0),fv.setScalar(0),pv.setScalar(0),hv.fromBufferAttribute(e,t),fv.fromBufferAttribute(e,r),pv.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(hv,s.x),a.addScaledVector(fv,s.y),a.addScaledVector(pv,s.z),a}static isFrontFacing(e,t,r,i){return Ds.subVectors(r,t),so.subVectors(e,t),Ds.cross(so).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),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 Ds.subVectors(this.c,this.b),so.subVectors(this.a,this.b),Ds.cross(so).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Gs.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Gs.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,s){return Gs.getInterpolation(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return Gs.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Gs.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,s=this.c;let a,o;dd.subVectors(i,r),hd.subVectors(s,r),cv.subVectors(e,r);const l=dd.dot(cv),c=hd.dot(cv);if(l<=0&&c<=0)return t.copy(r);uv.subVectors(e,i);const d=dd.dot(uv),h=hd.dot(uv);if(d>=0&&h<=d)return t.copy(i);const p=l*h-d*c;if(p<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(r).addScaledVector(dd,a);dv.subVectors(e,s);const A=dd.dot(dv),y=hd.dot(dv);if(y>=0&&A<=y)return t.copy(s);const m=A*c-l*y;if(m<=0&&c>=0&&y<=0)return o=c/(c-y),t.copy(r).addScaledVector(hd,o);const x=d*y-A*h;if(x<=0&&h-d>=0&&A-y>=0)return PS.subVectors(s,i),o=(h-d)/(h-d+(A-y)),t.copy(i).addScaledVector(PS,o);const g=1/(x+m+p);return a=m*g,o=p*g,t.copy(r).addScaledVector(dd,a).addScaledVector(hd,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ZN={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},vl={h:0,s:0,l:0},vm={h:0,s:0,l:0};function Av(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class xt{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(t===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ar){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mn.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=mn.workingColorSpace){return this.r=e,this.g=t,this.b=r,mn.colorSpaceToWorking(this,i),this}setHSL(e,t,r,i=mn.workingColorSpace){if(e=xI(e,1),t=nn(t,0,1),r=nn(r,0,1),t===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,a=2*r-s;this.r=Av(a,s,e+1/3),this.g=Av(a,s,e),this.b=Av(a,s,e-1/3)}return mn.colorSpaceToWorking(this,i),this}setStyle(e,t=Ar){function r(s){s!==void 0&&parseFloat(s)<1&&Pt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Pt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Pt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ar){const r=ZN[e.toLowerCase()];return r!==void 0?this.setHex(r,t):Pt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=_o(e.r),this.g=_o(e.g),this.b=_o(e.b),this}copyLinearToSRGB(e){return this.r=Ld(e.r),this.g=Ld(e.g),this.b=Ld(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ar){return mn.workingToColorSpace(Yr.copy(this),e),Math.round(nn(Yr.r*255,0,255))*65536+Math.round(nn(Yr.g*255,0,255))*256+Math.round(nn(Yr.b*255,0,255))}getHexString(e=Ar){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mn.workingColorSpace){mn.workingToColorSpace(Yr.copy(this),t);const r=Yr.r,i=Yr.g,s=Yr.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case r:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-r)/h+2;break;case s:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,t=mn.workingColorSpace){return mn.workingToColorSpace(Yr.copy(this),t),e.r=Yr.r,e.g=Yr.g,e.b=Yr.b,e}getStyle(e=Ar){mn.workingToColorSpace(Yr.copy(this),e);const t=Yr.r,r=Yr.g,i=Yr.b;return e!==Ar?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,t,r){return this.getHSL(vl),this.setHSL(vl.h+e,vl.s+t,vl.l+r)}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,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(vl),e.getHSL(vm);const r=pp(vl.h,vm.h,t),i=pp(vl.s,vm.s,t),s=pp(vl.l,vm.l,t);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*r+s[6]*i,this.g=s[1]*t+s[4]*r+s[7]*i,this.b=s[2]*t+s[5]*r+s[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 Yr=new xt;xt.NAMES=ZN;let JH=0;class Xs extends ou{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:JH++}),this.uuid=Ys(),this.name="",this.type="Material",this.blending=Pd,this.side=Eo,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vb,this.blendDst=_b,this.blendEquation=Dc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xt(0,0,0),this.blendAlpha=0,this.depthFunc=Hd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wS,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=rd,this.stencilZFail=rd,this.stencilZPass=rd,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const r=e[t];if(r===void 0){Pt(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Pt(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Pd&&(r.blending=this.blending),this.side!==Eo&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==vb&&(r.blendSrc=this.blendSrc),this.blendDst!==_b&&(r.blendDst=this.blendDst),this.blendEquation!==Dc&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Hd&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wS&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rd&&(r.stencilFail=this.stencilFail),this.stencilZFail!==rd&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==rd&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}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 r=null;if(t!==null){const i=t.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,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){e===!0&&this.version++}}class Oc extends Xs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xt(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 Hi,this.combine=dI,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 rr=new de,_m=new Dt;let KH=0;class or{constructor(e,t,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:KH++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r,this.usage=aw,this.updateRanges=[],this.gpuType=js,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,r=this.count;t<r;t++)_m.fromBufferAttribute(this,t),_m.applyMatrix3(e),this.setXY(t,_m.x,_m.y);else if(this.itemSize===3)for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.applyMatrix3(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.applyMatrix4(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.applyNormalMatrix(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.transformDirection(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=$s(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=Sn(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=$s(t,this.array)),t}setX(e,t){return this.normalized&&(t=Sn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=$s(t,this.array)),t}setY(e,t){return this.normalized&&(t=Sn(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=$s(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Sn(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=$s(t,this.array)),t}setW(e,t){return this.normalized&&(t=Sn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e*=this.itemSize,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array),s=Sn(s,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==aw&&(e.usage=this.usage),e}}class eQ extends or{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class tQ extends or{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class Wn extends or{constructor(e,t,r){super(new Float32Array(e),t,r)}}let ZH=0;const Zi=new Ft,mv=new zn,fd=new de,Ui=new ms,Df=new ms,Sr=new de;class _r extends ou{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ZH++}),this.uuid=Ys(),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(YN(e)?tQ:eQ)(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 this.attributes[e]!==void 0}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Jt().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Zi.makeRotationFromQuaternion(e),this.applyMatrix4(Zi),this}rotateX(e){return Zi.makeRotationX(e),this.applyMatrix4(Zi),this}rotateY(e){return Zi.makeRotationY(e),this.applyMatrix4(Zi),this}rotateZ(e){return Zi.makeRotationZ(e),this.applyMatrix4(Zi),this}translate(e,t,r){return Zi.makeTranslation(e,t,r),this.applyMatrix4(Zi),this}scale(e,t,r){return Zi.makeScale(e,t,r),this.applyMatrix4(Zi),this}lookAt(e){return mv.lookAt(e),mv.updateMatrix(),this.applyMatrix4(mv.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fd).negate(),this.translate(fd.x,fd.y,fd.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Wn(r,3))}else{const r=Math.min(e.length,t.count);for(let i=0;i<r;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&Pt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ms);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new de(-1/0,-1/0,-1/0),new de(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let r=0,i=t.length;r<i;r++){const s=t[r];Ui.setFromBufferAttribute(s),this.morphTargetsRelative?(Sr.addVectors(this.boundingBox.min,Ui.min),this.boundingBox.expandByPoint(Sr),Sr.addVectors(this.boundingBox.max,Ui.max),this.boundingBox.expandByPoint(Sr)):(this.boundingBox.expandByPoint(Ui.min),this.boundingBox.expandByPoint(Ui.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&sn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Fa);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new de,1/0);return}if(e){const r=this.boundingSphere.center;if(Ui.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Df.setFromBufferAttribute(o),this.morphTargetsRelative?(Sr.addVectors(Ui.min,Df.min),Ui.expandByPoint(Sr),Sr.addVectors(Ui.max,Df.max),Ui.expandByPoint(Sr)):(Ui.expandByPoint(Df.min),Ui.expandByPoint(Df.max))}Ui.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Sr.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Sr));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)Sr.fromBufferAttribute(o,c),l&&(fd.fromBufferAttribute(e,c),Sr.add(fd)),i=Math.max(i,r.distanceToSquared(Sr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&sn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){sn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new or(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let T=0;T<r.count;T++)o[T]=new de,l[T]=new de;const c=new de,d=new de,h=new de,p=new Dt,A=new Dt,y=new Dt,m=new de,x=new de;function g(T,R,k){c.fromBufferAttribute(r,T),d.fromBufferAttribute(r,R),h.fromBufferAttribute(r,k),p.fromBufferAttribute(s,T),A.fromBufferAttribute(s,R),y.fromBufferAttribute(s,k),d.sub(c),h.sub(c),A.sub(p),y.sub(p);const H=1/(A.x*y.y-y.x*A.y);isFinite(H)&&(m.copy(d).multiplyScalar(y.y).addScaledVector(h,-A.y).multiplyScalar(H),x.copy(h).multiplyScalar(A.x).addScaledVector(d,-y.x).multiplyScalar(H),o[T].add(m),o[R].add(m),o[k].add(m),l[T].add(x),l[R].add(x),l[k].add(x))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let T=0,R=_.length;T<R;++T){const k=_[T],H=k.start,Q=k.count;for(let V=H,B=H+Q;V<B;V+=3)g(e.getX(V+0),e.getX(V+1),e.getX(V+2))}const b=new de,w=new de,I=new de,S=new de;function M(T){I.fromBufferAttribute(i,T),S.copy(I);const R=o[T];b.copy(R),b.sub(I.multiplyScalar(I.dot(R))).normalize(),w.crossVectors(S,R);const H=w.dot(l[T])<0?-1:1;a.setXYZW(T,b.x,b.y,b.z,H)}for(let T=0,R=_.length;T<R;++T){const k=_[T],H=k.start,Q=k.count;for(let V=H,B=H+Q;V<B;V+=3)M(e.getX(V+0)),M(e.getX(V+1)),M(e.getX(V+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new or(new Float32Array(t.count*3),3),this.setAttribute("normal",r);else for(let p=0,A=r.count;p<A;p++)r.setXYZ(p,0,0,0);const i=new de,s=new de,a=new de,o=new de,l=new de,c=new de,d=new de,h=new de;if(e)for(let p=0,A=e.count;p<A;p+=3){const y=e.getX(p+0),m=e.getX(p+1),x=e.getX(p+2);i.fromBufferAttribute(t,y),s.fromBufferAttribute(t,m),a.fromBufferAttribute(t,x),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(r,y),l.fromBufferAttribute(r,m),c.fromBufferAttribute(r,x),o.add(d),l.add(d),c.add(d),r.setXYZ(y,o.x,o.y,o.z),r.setXYZ(m,l.x,l.y,l.z),r.setXYZ(x,c.x,c.y,c.z)}else for(let p=0,A=t.count;p<A;p+=3)i.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),a.fromBufferAttribute(t,p+2),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)Sr.fromBufferAttribute(e,t),Sr.normalize(),e.setXYZ(t,Sr.x,Sr.y,Sr.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,p=new c.constructor(l.length*d);let A=0,y=0;for(let m=0,x=l.length;m<x;m++){o.isInterleavedBufferAttribute?A=l[m]*o.data.stride+o.offset:A=l[m]*d;for(let g=0;g<d;g++)p[y++]=c[A++]}return new or(p,d,h)}if(this.index===null)return Pt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new _r,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let d=0,h=c.length;d<h;d++){const p=c[d],A=e(p,r);l.push(A)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,p=c.length;h<p;h++){const A=c[h];d.push(A.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(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 o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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 r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const d=i[c];this.setAttribute(c,d.clone(t))}const s=e.morphAttributes;for(const c in s){const d=[],h=s[c];for(let p=0,A=h.length;p<A;p++)d.push(h[p].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const LS=new Ft,xc=new ph,bm=new Fa,FS=new de,wm=new de,Em=new de,Im=new de,gv=new de,Cm=new de,zS=new de,Sm=new de;class Jn extends zn{constructor(e=new _r,t=new Oc){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){Cm.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(gv.fromBufferAttribute(h,e),a?Cm.addScaledVector(gv,d):Cm.addScaledVector(gv.sub(t),d))}t.add(Cm)}return t}raycast(e,t){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),bm.copy(r.boundingSphere),bm.applyMatrix4(s),xc.copy(e.ray).recast(e.near),!(bm.containsPoint(xc.origin)===!1&&(xc.intersectSphere(bm,FS)===null||xc.origin.distanceToSquared(FS)>(e.far-e.near)**2))&&(LS.copy(s).invert(),xc.copy(e.ray).applyMatrix4(LS),!(r.boundingBox!==null&&xc.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,t,xc)))}_computeIntersections(e,t,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,p=s.groups,A=s.drawRange;if(o!==null)if(Array.isArray(a))for(let y=0,m=p.length;y<m;y++){const x=p[y],g=a[x.materialIndex],_=Math.max(x.start,A.start),b=Math.min(o.count,Math.min(x.start+x.count,A.start+A.count));for(let w=_,I=b;w<I;w+=3){const S=o.getX(w),M=o.getX(w+1),T=o.getX(w+2);i=Bm(this,g,e,r,c,d,h,S,M,T),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=x.materialIndex,t.push(i))}}else{const y=Math.max(0,A.start),m=Math.min(o.count,A.start+A.count);for(let x=y,g=m;x<g;x+=3){const _=o.getX(x),b=o.getX(x+1),w=o.getX(x+2);i=Bm(this,a,e,r,c,d,h,_,b,w),i&&(i.faceIndex=Math.floor(x/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let y=0,m=p.length;y<m;y++){const x=p[y],g=a[x.materialIndex],_=Math.max(x.start,A.start),b=Math.min(l.count,Math.min(x.start+x.count,A.start+A.count));for(let w=_,I=b;w<I;w+=3){const S=w,M=w+1,T=w+2;i=Bm(this,g,e,r,c,d,h,S,M,T),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=x.materialIndex,t.push(i))}}else{const y=Math.max(0,A.start),m=Math.min(l.count,A.start+A.count);for(let x=y,g=m;x<g;x+=3){const _=x,b=x+1,w=x+2;i=Bm(this,a,e,r,c,d,h,_,b,w),i&&(i.faceIndex=Math.floor(x/3),t.push(i))}}}}function e9(n,e,t,r,i,s,a,o){let l;if(e.side===Bi?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===Eo,o),l===null)return null;Sm.copy(o),Sm.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Sm);return c<t.near||c>t.far?null:{distance:c,point:Sm.clone(),object:n}}function Bm(n,e,t,r,i,s,a,o,l,c){n.getVertexPosition(o,wm),n.getVertexPosition(l,Em),n.getVertexPosition(c,Im);const d=e9(n,e,t,r,wm,Em,Im,zS);if(d){const h=new de;Gs.getBarycoord(zS,wm,Em,Im,h),i&&(d.uv=Gs.getInterpolatedAttribute(i,o,l,c,h,new Dt)),s&&(d.uv1=Gs.getInterpolatedAttribute(s,o,l,c,h,new Dt)),a&&(d.normal=Gs.getInterpolatedAttribute(a,o,l,c,h,new de),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new de,materialIndex:0};Gs.getNormal(wm,Em,Im,p.normal),d.face=p,d.barycoord=h}return d}class Ah extends _r{constructor(e=1,t=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],d=[],h=[];let p=0,A=0;y("z","y","x",-1,-1,r,t,e,a,s,0),y("z","y","x",1,-1,r,t,-e,a,s,1),y("x","z","y",1,1,e,r,t,i,a,2),y("x","z","y",1,-1,e,r,-t,i,a,3),y("x","y","z",1,-1,e,t,r,i,s,4),y("x","y","z",-1,-1,e,t,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Wn(c,3)),this.setAttribute("normal",new Wn(d,3)),this.setAttribute("uv",new Wn(h,2));function y(m,x,g,_,b,w,I,S,M,T,R){const k=w/M,H=I/T,Q=w/2,V=I/2,B=S/2,W=M+1,K=T+1;let X=0,$=0;const J=new de;for(let ne=0;ne<K;ne++){const L=ne*H-V;for(let G=0;G<W;G++){const oe=G*k-Q;J[m]=oe*_,J[x]=L*b,J[g]=B,c.push(J.x,J.y,J.z),J[m]=0,J[x]=0,J[g]=S>0?1:-1,d.push(J.x,J.y,J.z),h.push(G/M),h.push(1-ne/T),X+=1}}for(let ne=0;ne<T;ne++)for(let L=0;L<M;L++){const G=p+L+W*ne,oe=p+L+W*(ne+1),Ae=p+(L+1)+W*(ne+1),ye=p+(L+1)+W*ne;l.push(G,oe,ye),l.push(oe,Ae,ye),$+=6}o.addGroup(A,$,R),A+=$,p+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ah(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Yd(n){const e={};for(const t in n){e[t]={};for(const r in n[t]){const i=n[t][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Pt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][r]=null):e[t][r]=i.clone():Array.isArray(i)?e[t][r]=i.slice():e[t][r]=i}}return e}function di(n){const e={};for(let t=0;t<n.length;t++){const r=Yd(n[t]);for(const i in r)e[i]=r[i]}return e}function t9(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function nQ(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:mn.workingColorSpace}const n9={clone:Yd,merge:di};var r9=`void main() {
|
|
56
|
+
`);return i.startsWith("-")&&s&&(s=!1),Object.assign(Object.assign({},n),{allowNegative:s})}function eV(n){n=Z6(n),n.decimalSeparator,n.allowedDecimalSeparators,n.thousandsGroupStyle;var e=n.suffix,t=n.allowNegative,r=n.allowLeadingZeros,i=n.onKeyDown;i===void 0&&(i=Rl);var s=n.onBlur;s===void 0&&(s=Rl);var a=n.thousandSeparator,o=n.decimalScale,l=n.fixedDecimalScale,c=n.prefix;c===void 0&&(c="");var d=n.defaultValue,h=n.value,p=n.valueIsNumericString,A=n.onValueChange,y=vN(n,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),m=Q0(n),x=m.decimalSeparator,g=m.allowedDecimalSeparators,_=function(K){return oS(K,n)},b=function(K,X){return J6(K,X,n)},w=kl(h)?d:h,I=p??X6(w,c,e);kl(h)?kl(d)||(I=I||typeof d=="number"):I=I||typeof h=="number";var S=function(K){return _N(K)?K:(typeof K=="number"&&(K=EN(K)),I&&typeof o=="number"?sS(K,o,!!l):K)},M=CN(S(h),S(d),!!I,_,b,A),T=M[0],R=T.numAsString,k=T.formattedValue,H=M[1],Q=function(K){var X=K.target,$=K.key,J=X.selectionStart,ne=X.selectionEnd,L=X.value;if(L===void 0&&(L=""),($==="Backspace"||$==="Delete")&&ne<c.length&&L!=="-"){K.preventDefault();return}if(J!==ne){i(K);return}$==="Backspace"&&L[0]==="-"&&J===c.length+1&&t&&Rc(X,1),o&&l&&($==="Backspace"&&L[J-1]===x?(Rc(X,J-1),K.preventDefault()):$==="Delete"&&L[J]===x&&K.preventDefault()),g?.includes($)&&L[J]===x&&Rc(X,J+1);var G=a===!0?",":a;$==="Backspace"&&L[J-1]===G&&Rc(X,J-1),$==="Delete"&&L[J]===G&&Rc(X,J+1),i(K)},V=function(K){var X=R;if(X.match(/\d/g)||(X=""),r||(X=L6(X)),l&&o&&(X=sS(X,o,l)),X!==R){var $=oS(X,n);H({formattedValue:$,value:X,floatValue:parseFloat(X)},{event:K,source:Vd.event})}s(K)},B=function(K){return K===x?!0:Ep(K)},W=function(K){var X=K.currentValue,$=K.lastValue,J=K.formattedValue,ne=K.currentValueIndex,L=K.formattedValueIndex,G=X[ne],oe=J[L],Ae=IN($,X),ye=Ae.to,he=function(fe){return b(fe).indexOf(".")+c.length};return h===0&&l&&o&&X[ye.start]===x&&he(X)<ne&&he(J)>L?!1:ne>=ye.start&&ne<ye.end&&g&&g.includes(G)&&oe===x?!0:G===oe};return Object.assign(Object.assign({},y),{value:k,valueIsNumericString:!1,isValidInputCharacter:B,isCharacterSame:W,onValueChange:H,format:_,removeFormatting:b,getCaretBoundary:function(K){return K6(K,n)},onKeyDown:Q,onBlur:V})}function tV(n){var e=eV(n);return On.createElement(W6,Object.assign({},e))}var yb={root:"m_e2f5cd4e",controls:"m_95e17d22",control:"m_80b4b171"};function lS({direction:n,style:e,...t}){return j.jsx("svg",{style:{width:"var(--ni-chevron-size)",height:"var(--ni-chevron-size)",transform:n==="up"?"rotate(180deg)":void 0,...e},viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:j.jsx("path",{d:"M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}const nV=/^(0\.0*|-0(\.0*)?)$/,rV=/^-?0\d+(\.\d+)?\.?$/,iV=/\.\d*0$/,SN=/^-?\d+\.$/;function xb(n){return typeof n=="string"&&n!==""&&!Number.isNaN(Number(n))}function qx(n){return typeof n=="number"?n<Number.MAX_SAFE_INTEGER:n===""||xb(n)&&Number(n)<Number.MAX_SAFE_INTEGER}function sV(n){return n.toString().replace(".","").length}function aV(n,e){return(typeof n=="number"?n<Number.MAX_SAFE_INTEGER:!Number.isNaN(Number(n)))&&!Number.isNaN(n)&&sV(e)<14&&e!==""}function cS(n,e,t){if(n===void 0)return!0;const r=e===void 0||n>=e,i=t===void 0||n<=t;return r&&i}const oV={step:1,clampBehavior:"blur",allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0,allowedDecimalSeparators:[".",","]},lV=(n,{size:e})=>({controls:{"--ni-chevron-size":gn(e,"ni-chevron-size")}});function cV(n,e,t){const r=n.toString(),i=SN.test(r),s=r.replace(/^0+(?=\d)/,""),a=parseFloat(s);if(Number.isNaN(a))return s;if(a>Number.MAX_SAFE_INTEGER)return e!==void 0?e:s;const o=ss(a,t,e);return i?`${o.toString().replace(/^0+(?=\d)/,"")}.`:o}const sI=Tt((n,e)=>{const t=ct("NumberInput",oV,n),{className:r,classNames:i,styles:s,unstyled:a,vars:o,onChange:l,onValueChange:c,value:d,defaultValue:h,max:p,min:A,step:y,hideControls:m,rightSection:x,isAllowed:g,clampBehavior:_,onBlur:b,allowDecimal:w,decimalScale:I,onKeyDown:S,onKeyDownCapture:M,handlersRef:T,startValue:R,disabled:k,rightSectionPointerEvents:H,allowNegative:Q,readOnly:V,size:B,rightSectionWidth:W,stepHoldInterval:K,stepHoldDelay:X,allowLeadingZeros:$,withKeyboardEvents:J,trimLeadingZeroesOnBlur:ne,allowedDecimalSeparators:L,attributes:G,...oe}=t,Ae=en({name:"NumberInput",classes:yb,props:t,classNames:i,styles:s,unstyled:a,attributes:G,vars:o,varsResolver:lV}),{resolvedClassNames:ye,resolvedStyles:he}=ih({classNames:i,styles:s,props:t}),[fe,Ie]=Ks({value:d,defaultValue:h,finalValue:"",onChange:l}),Re=X!==void 0&&K!==void 0,ge=U.useRef(null),Ne=U.useRef(null),tt=U.useRef(0),Ge=(me,xe)=>{xe.source==="event"&&Ie(aV(me.floatValue,me.value)&&!nV.test(me.value)&&!($&&rV.test(me.value))&&!iV.test(me.value)&&!SN.test(me.value)?me.floatValue:me.value),c?.(me,xe)},F=me=>{const xe=String(me).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return xe?Math.max(0,(xe[1]?xe[1].length:0)-(xe[2]?+xe[2]:0)):0},re=me=>{ge.current&&typeof me<"u"&&ge.current.setSelectionRange(me,me)},Ee=U.useRef(eb);Ee.current=()=>{if(!qx(fe))return;let me;const xe=F(fe),st=F(y),He=Math.max(xe,st),Ke=10**He;if(!xb(fe)&&(typeof fe!="number"||Number.isNaN(fe)))me=ss(R,A,p);else if(p!==void 0){const ze=(Math.round(Number(fe)*Ke)+Math.round(y*Ke))/Ke;me=ze<=p?ze:p}else me=(Math.round(Number(fe)*Ke)+Math.round(y*Ke))/Ke;const nt=me.toFixed(He);Ie(parseFloat(nt)),c?.({floatValue:parseFloat(nt),formattedValue:nt,value:nt},{source:"increment"}),setTimeout(()=>re(ge.current?.value.length),0)};const q=U.useRef(eb);q.current=()=>{if(!qx(fe))return;let me;const xe=A!==void 0?A:Q?Number.MIN_SAFE_INTEGER:0,st=F(fe),He=F(y),Ke=Math.max(st,He),nt=10**Ke;if(!xb(fe)&&typeof fe!="number"||Number.isNaN(fe))me=ss(R,xe,p);else{const Ze=(Math.round(Number(fe)*nt)-Math.round(y*nt))/nt;me=xe!==void 0&&Ze<xe?xe:Ze}const ze=me.toFixed(Ke);Ie(parseFloat(ze)),c?.({floatValue:parseFloat(ze),formattedValue:ze,value:ze},{source:"decrement"}),setTimeout(()=>re(ge.current?.value.length),0)};const ee=me=>{const xe=me.clipboardData.getData("text"),st=oe.decimalSeparator||".",He=(L||[".",","]).filter(Ke=>Ke!==st);if(He.some(Ke=>xe.includes(Ke))){me.preventDefault();let Ke=xe;He.forEach(ze=>{Ke=Ke.split(ze).join(st)});const nt=ge.current;if(nt){const ze=nt.selectionStart??0,Ze=nt.selectionEnd??0,pt=nt.value,ft=pt.substring(0,ze)+Ke+pt.substring(Ze);Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(nt,ft),nt.dispatchEvent(new Event("change",{bubbles:!0}));const Mt=ze+Ke.length;setTimeout(()=>re(Mt),0)}}oe.onPaste?.(me)},ie=me=>{S?.(me),!(V||!J)&&(me.key==="ArrowUp"&&(me.preventDefault(),Ee.current?.()),me.key==="ArrowDown"&&(me.preventDefault(),q.current?.()))},be=me=>{if(M?.(me),me.key==="Backspace"){const xe=ge.current;xe&&xe.selectionStart===0&&xe.selectionStart===xe.selectionEnd&&(me.preventDefault(),window.setTimeout(()=>re(0),0))}},ve=me=>{let xe=fe;_==="blur"&&typeof xe=="number"&&(xe=ss(xe,A,p)),ne&&typeof xe=="string"&&F(xe)<15&&(xe=cV(xe,p,A)),fe!==xe&&Ie(xe),b?.(me)};Bg(T,{increment:Ee.current,decrement:q.current});const ce=me=>{me?Ee.current?.():q.current?.(),tt.current+=1},Z=me=>{if(ce(me),Re){const xe=typeof K=="number"?K:K(tt.current);Ne.current=window.setTimeout(()=>Z(me),xe)}},Y=(me,xe)=>{me.preventDefault(),ge.current?.focus(),ce(xe),Re&&(Ne.current=window.setTimeout(()=>Z(xe),X))},le=()=>{Ne.current&&window.clearTimeout(Ne.current),Ne.current=null,tt.current=0},Ce=j.jsxs("div",{...Ae("controls"),children:[j.jsx(ka,{...Ae("control"),tabIndex:-1,"aria-hidden":!0,disabled:k||typeof fe=="number"&&p!==void 0&&fe>=p,mod:{direction:"up"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{Y(me,!0)},onPointerUp:le,onPointerLeave:le,children:j.jsx(lS,{direction:"up"})}),j.jsx(ka,{...Ae("control"),tabIndex:-1,"aria-hidden":!0,disabled:k||typeof fe=="number"&&A!==void 0&&fe<=A,mod:{direction:"down"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{Y(me,!1)},onPointerUp:le,onPointerLeave:le,children:j.jsx(lS,{direction:"down"})})]});return j.jsx(na,{component:tV,allowNegative:Q,className:Rr(yb.root,r),size:B,inputMode:"decimal",...oe,readOnly:V,disabled:k,value:fe,getInputRef:er(e,ge),onValueChange:Ge,rightSection:m||V||!qx(fe)?x:x||Ce,classNames:ye,styles:he,unstyled:a,__staticSelector:"NumberInput",decimalScale:w?I:0,onPaste:ee,onKeyDown:ie,onKeyDownCapture:be,rightSectionPointerEvents:H??(k?"none":void 0),rightSectionWidth:W??`var(--ni-right-section-width-${B||"sm"})`,allowLeadingZeros:$,allowedDecimalSeparators:L,onBlur:ve,attributes:G,isAllowed:me=>_==="strict"?g?g(me)&&cS(me.floatValue,A,p):cS(me.floatValue,A,p):g?g(me):!0})});sI.classes={...na.classes,...yb};sI.displayName="@mantine/core/NumberInput";const uV={duration:100,transition:"fade"};function uS(n,e){return{...uV,...e,...n}}var P0={tooltip:"m_1b3c8819",arrow:"m_f898399f"};function dV({offset:n,position:e,defaultOpened:t}){const[r,i]=U.useState(t),s=U.useRef(null),{x:a,y:o,elements:l,refs:c,update:d,placement:h}=gE({placement:e,middleware:[fE({crossAxis:!0,padding:5,rootBoundary:"document"})]}),p=h.includes("right")?n:e.includes("left")?n*-1:0,A=h.includes("bottom")?n:e.includes("top")?n*-1:0,y=U.useCallback(({clientX:m,clientY:x})=>{c.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:m,y:x,left:m+p,top:x+A,right:m,bottom:x}}})},[l.reference]);return U.useEffect(()=>{if(c.floating.current){const m=s.current;m.addEventListener("mousemove",y);const x=yo(c.floating.current);return x.forEach(g=>{g.addEventListener("scroll",d)}),()=>{m.removeEventListener("mousemove",y),x.forEach(g=>{g.removeEventListener("scroll",d)})}}},[l.reference,c.floating.current,d,y,r]),{handleMouseMove:y,x:a,y:o,opened:r,setOpened:i,boundaryRef:s,floating:c.setFloating}}const hV={refProp:"ref",withinPortal:!0,offset:10,position:"right",zIndex:Bo("popover")},fV=(n,{radius:e,color:t})=>({tooltip:{"--tooltip-radius":e===void 0?void 0:Dr(e),"--tooltip-bg":t?cs(t,n):void 0,"--tooltip-color":t?"var(--mantine-color-white)":void 0}}),aI=Tt((n,e)=>{const t=ct("TooltipFloating",hV,n),{children:r,refProp:i,withinPortal:s,style:a,className:o,classNames:l,styles:c,unstyled:d,radius:h,color:p,label:A,offset:y,position:m,multiline:x,zIndex:g,disabled:_,defaultOpened:b,variant:w,vars:I,portalProps:S,attributes:M,...T}=t,R=Ri(),k=en({name:"TooltipFloating",props:t,classes:P0,className:o,style:a,classNames:l,styles:c,unstyled:d,attributes:M,rootSelector:"tooltip",vars:I,varsResolver:fV}),{handleMouseMove:H,x:Q,y:V,opened:B,boundaryRef:W,floating:K,setOpened:X}=dV({offset:y,position:m,defaultOpened:b}),$=ru(r);if(!$)throw new Error("[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const J=er(W,l0($),e),ne=$.props,L=oe=>{ne.onMouseEnter?.(oe),H(oe),X(!0)},G=oe=>{ne.onMouseLeave?.(oe),X(!1)};return j.jsxs(j.Fragment,{children:[j.jsx(Jc,{...S,withinPortal:s,children:j.jsx(Je,{...T,...k("tooltip",{style:{...aE(a,R),zIndex:g,display:!_&&B?"block":"none",top:(V&&Math.round(V))??"",left:(Q&&Math.round(Q))??""}}),variant:w,ref:K,mod:{multiline:x},children:A})}),U.cloneElement($,{...ne,[i]:J,onMouseEnter:L,onMouseLeave:G})]})});aI.classes=P0;aI.displayName="@mantine/core/TooltipFloating";const BN=U.createContext(!1),pV=BN.Provider,AV=()=>U.useContext(BN),mV={openDelay:0,closeDelay:0};function oI(n){const{openDelay:e,closeDelay:t,children:r}=ct("TooltipGroup",mV,n);return j.jsx(pV,{value:!0,children:j.jsx(j5,{delay:{open:e,close:t},children:r})})}oI.displayName="@mantine/core/TooltipGroup";oI.extend=n=>n;function gV(n){if(n===void 0)return{shift:!0,flip:!0};const e={...n};return n.shift===void 0&&(e.shift=!0),n.flip===void 0&&(e.flip=!0),e}function yV(n){const e=gV(n.middlewares),t=[YD(n.offset)];return e.shift&&t.push(fE(typeof e.shift=="boolean"?{padding:8}:{padding:8,...e.shift})),e.flip&&t.push(typeof e.flip=="boolean"?Ng():Ng(e.flip)),t.push(XD({element:n.arrowRef,padding:n.arrowOffset})),e.inline?t.push(typeof e.inline=="boolean"?dp():dp(e.inline)):n.inline&&t.push(dp()),t}function xV(n){const[e,t]=U.useState(n.defaultOpened),i=typeof n.opened=="boolean"?n.opened:e,s=AV(),a=Mo(),o=U.useCallback(I=>{t(I),I&&g(a)},[a]),{x:l,y:c,context:d,refs:h,placement:p,middlewareData:{arrow:{x:A,y}={}}}=gE({strategy:n.strategy,placement:n.position,open:i,onOpenChange:o,middleware:yV(n),whileElementsMounted:db}),{delay:m,currentId:x,setCurrentId:g}=W5(d,{id:a}),{getReferenceProps:_,getFloatingProps:b}=Z5([V5(d,{enabled:n.events?.hover,delay:s?m:{open:n.openDelay,close:n.closeDelay},mouseOnly:!n.events?.touch}),K5(d,{enabled:n.events?.focus,visibleOnly:!0}),t8(d,{role:"tooltip"}),X5(d,{enabled:typeof n.opened>"u"})]);Ra(()=>{n.onPositionChange?.(p)},[p]);const w=i&&x&&x!==a;return{x:l,y:c,arrowX:A,arrowY:y,reference:h.setReference,floating:h.setFloating,getFloatingProps:b,getReferenceProps:_,isGroupPhase:w,opened:i,placement:p}}const dS={position:"top",refProp:"ref",withinPortal:!0,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:Bo("popover"),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},vV=(n,{radius:e,color:t,variant:r,autoContrast:i})=>{const s=n.variantColorResolver({theme:n,color:t||n.primaryColor,autoContrast:i,variant:r||"filled"});return{tooltip:{"--tooltip-radius":e===void 0?void 0:Dr(e),"--tooltip-bg":t?s.background:void 0,"--tooltip-color":t?s.color:void 0}}},Ql=Tt((n,e)=>{const t=ct("Tooltip",dS,n),{children:r,position:i,refProp:s,label:a,openDelay:o,closeDelay:l,onPositionChange:c,opened:d,defaultOpened:h,withinPortal:p,radius:A,color:y,classNames:m,styles:x,unstyled:g,style:_,className:b,withArrow:w,arrowSize:I,arrowOffset:S,arrowRadius:M,arrowPosition:T,offset:R,transitionProps:k,multiline:H,events:Q,zIndex:V,disabled:B,positionDependencies:W,onClick:K,onMouseEnter:X,onMouseLeave:$,inline:J,variant:ne,keepMounted:L,vars:G,portalProps:oe,mod:Ae,floatingStrategy:ye,middlewares:he,autoContrast:fe,attributes:Ie,target:Re,...ge}=ct("Tooltip",dS,t),{dir:Ne}=iu(),tt=U.useRef(null),Ge=xV({position:Ak(Ne,i),closeDelay:l,openDelay:o,onPositionChange:c,opened:d,defaultOpened:h,events:Q,arrowRef:tt,arrowOffset:S,offset:typeof R=="number"?R+(w?I/2:0):R,positionDependencies:[...W,Re??r],inline:J,strategy:ye,middlewares:he});U.useEffect(()=>{const ie=Re instanceof HTMLElement?Re:typeof Re=="string"?document.querySelector(Re):Re?.current||null;ie&&Ge.reference(ie)},[Re,Ge]);const F=en({name:"Tooltip",props:t,classes:P0,className:b,style:_,classNames:m,styles:x,unstyled:g,attributes:Ie,rootSelector:"tooltip",vars:G,varsResolver:vV}),re=ru(r);if(!Re&&!re)throw new Error("[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");if(Re){const ie=uS(k,{duration:100,transition:"fade"});return j.jsx(j.Fragment,{children:j.jsx(Jc,{...oe,withinPortal:p,children:j.jsx(Na,{...ie,keepMounted:L,mounted:!B&&!!Ge.opened,duration:Ge.isGroupPhase?10:ie.duration,children:be=>j.jsxs(Je,{...ge,"data-fixed":ye==="fixed"||void 0,variant:ne,mod:[{multiline:H},Ae],...Ge.getFloatingProps({ref:Ge.floating,className:F("tooltip").className,style:{...F("tooltip").style,...be,zIndex:V,top:Ge.y??0,left:Ge.x??0}}),children:[a,j.jsx(Pg,{ref:tt,arrowX:Ge.arrowX,arrowY:Ge.arrowY,visible:w,position:Ge.placement,arrowSize:I,arrowOffset:S,arrowRadius:M,arrowPosition:T,...F("arrow")})]})})})})}const Ee=re.props,q=er(Ge.reference,l0(re),e),ee=uS(k,{duration:100,transition:"fade"});return j.jsxs(j.Fragment,{children:[j.jsx(Jc,{...oe,withinPortal:p,children:j.jsx(Na,{...ee,keepMounted:L,mounted:!B&&!!Ge.opened,duration:Ge.isGroupPhase?10:ee.duration,children:ie=>j.jsxs(Je,{...ge,"data-fixed":ye==="fixed"||void 0,variant:ne,mod:[{multiline:H},Ae],...Ge.getFloatingProps({ref:Ge.floating,className:F("tooltip").className,style:{...F("tooltip").style,...ie,zIndex:V,top:Ge.y??0,left:Ge.x??0}}),children:[a,j.jsx(Pg,{ref:tt,arrowX:Ge.arrowX,arrowY:Ge.arrowY,visible:w,position:Ge.placement,arrowSize:I,arrowOffset:S,arrowRadius:M,arrowPosition:T,...F("arrow")})]})})}),U.cloneElement(re,Ge.getReferenceProps({onClick:K,onMouseEnter:X,onMouseLeave:$,onMouseMove:t.onMouseMove,onPointerDown:t.onPointerDown,onPointerEnter:t.onPointerEnter,...Ee,className:Rr(b,Ee.className),[s]:q}))]})});Ql.classes=P0;Ql.displayName="@mantine/core/Tooltip";Ql.Floating=aI;Ql.Group=oI;const _V={withCheckIcon:!0,allowDeselect:!0,checkIconPosition:"left",openOnFocus:!0},Uc=Tt((n,e)=>{const t=ct("Select",_V,n),{classNames:r,styles:i,unstyled:s,vars:a,dropdownOpened:o,defaultDropdownOpened:l,onDropdownClose:c,onDropdownOpen:d,onFocus:h,onBlur:p,onClick:A,onChange:y,data:m,value:x,defaultValue:g,selectFirstOptionOnChange:_,selectFirstOptionOnDropdownOpen:b,onOptionSubmit:w,comboboxProps:I,readOnly:S,disabled:M,filter:T,limit:R,withScrollArea:k,maxDropdownHeight:H,size:Q,searchable:V,rightSection:B,checkIconPosition:W,withCheckIcon:K,withAlignedLabels:X,nothingFoundMessage:$,name:J,form:ne,searchValue:L,defaultSearchValue:G,onSearchChange:oe,allowDeselect:Ae,error:ye,rightSectionPointerEvents:he,id:fe,clearable:Ie,clearButtonProps:Re,hiddenInputProps:ge,renderOption:Ne,onClear:tt,autoComplete:Ge,scrollAreaProps:F,__defaultRightSection:re,__clearSection:Ee,__clearable:q,chevronColor:ee,autoSelectOnBlur:ie,openOnFocus:be,attributes:ve,...ce}=t,Z=U.useMemo(()=>cG(m),[m]),Y=U.useRef({}),le=U.useMemo(()=>Gk(Z),[Z]),Ce=Mo(fe),[me,xe,st]=Ks({value:x,defaultValue:g,finalValue:null,onChange:y}),He=typeof me=="string"?me in le?le[me]:Y.current[me]:void 0,Ke=nO(He),[nt,ze,Ze]=Ks({value:L,defaultValue:G,finalValue:He?He.label:"",onChange:oe}),pt=Yk({opened:o,defaultOpened:l,onDropdownOpen:()=>{d?.(),b?pt.selectFirstOption():pt.updateSelectedOptionIndex("active",{scrollIntoView:!0})},onDropdownClose:()=>{c?.(),setTimeout(pt.resetSelectedOption,0)}}),ft=je=>{ze(je),pt.resetSelectedOption()},{resolvedClassNames:dt,resolvedStyles:Mt}=ih({props:t,styles:i,classNames:r});U.useEffect(()=>{_&&pt.selectFirstOption()},[_,nt]),U.useEffect(()=>{x===null&&ft(""),typeof x=="string"&&He&&(Ke?.value!==He.value||Ke?.label!==He.label)&&ft(He.label)},[x,He]),U.useEffect(()=>{!st&&!Ze&&ft(typeof me=="string"?me in le?le[me]?.label:Y.current[me]?.label||"":"")},[le,me]),U.useEffect(()=>{me&&me in le&&(Y.current[me]=le[me])},[le,me]);const _e=j.jsx(Qn.ClearButton,{...Re,onClear:()=>{xe(null,null),ft(""),tt?.()}}),ut=Ie&&!!me&&!M&&!S;return j.jsxs(j.Fragment,{children:[j.jsxs(Qn,{store:pt,__staticSelector:"Select",classNames:dt,styles:Mt,unstyled:s,readOnly:S,size:Q,attributes:ve,keepMounted:ie,onOptionSubmit:je=>{w?.(je);const Ye=Ae&&le[je].value===me?null:le[je],We=Ye?Ye.value:null;We!==me&&xe(We,Ye),!st&&ft(typeof We=="string"&&Ye?.label||""),pt.closeDropdown()},...I,children:[j.jsx(Qn.Target,{targetType:V?"input":"button",autoComplete:Ge,children:j.jsx(na,{id:Ce,ref:e,__defaultRightSection:j.jsx(Qn.Chevron,{size:Q,error:ye,unstyled:s,color:ee}),__clearSection:_e,__clearable:ut,rightSection:B,rightSectionPointerEvents:he||"none",...ce,size:Q,__staticSelector:"Select",disabled:M,readOnly:S||!V,value:nt,onChange:je=>{ft(je.currentTarget.value),pt.openDropdown(),_&&pt.selectFirstOption()},onFocus:je=>{be&&V&&pt.openDropdown(),h?.(je)},onBlur:je=>{ie&&pt.clickSelectedOption(),V&&pt.closeDropdown();const Ye=typeof me=="string"&&(me in le?le[me]:Y.current[me]);ft(Ye&&Ye.label||""),p?.(je)},onClick:je=>{V?pt.openDropdown():pt.toggleDropdown(),A?.(je)},classNames:dt,styles:Mt,unstyled:s,pointer:!V,error:ye,attributes:ve})}),j.jsx(PG,{data:Z,hidden:S||M,filter:T,search:nt,limit:R,hiddenWhenEmpty:!$,withScrollArea:k,maxDropdownHeight:H,filterOptions:!!V&&He?.label!==nt,value:me,checkIconPosition:W,withCheckIcon:K,withAlignedLabels:X,nothingFoundMessage:$,unstyled:s,labelId:ce.label?`${Ce}-label`:void 0,"aria-label":ce.label?void 0:ce["aria-label"],renderOption:Ne,scrollAreaProps:F})]}),j.jsx(Qn.HiddenInput,{value:me,name:J,form:ne,disabled:M,...ge})]})});Uc.classes={...na.classes,...Qn.classes};Uc.displayName="@mantine/core/Select";const[bV,L0]=Ol("SliderProvider was not found in tree");var MN={root:"m_dd36362e",label:"m_c9357328",thumb:"m_c9a9a60a",trackContainer:"m_a8645c2",track:"m_c9ade57f",bar:"m_38aeed47",markWrapper:"m_b7b0423a",mark:"m_dd33bc19",markLabel:"m_68c77a5b"};const TN=U.forwardRef(({size:n,disabled:e,variant:t,color:r,thumbSize:i,radius:s,...a},o)=>{const{getStyles:l}=L0();return j.jsx(Je,{tabIndex:-1,variant:t,size:n,ref:o,...l("root"),...a})});TN.displayName="@mantine/core/SliderRoot";const RN=U.forwardRef(({max:n,min:e,value:t,position:r,label:i,dragging:s,onMouseDown:a,onKeyDownCapture:o,labelTransitionProps:l,labelAlwaysOn:c,thumbLabel:d,onFocus:h,onBlur:p,showLabelOnHover:A,isHovered:y,children:m=null,disabled:x},g)=>{const{getStyles:_}=L0(),[b,w]=U.useState(!1),I=c||s||b||A&&y;return j.jsxs(Je,{tabIndex:0,role:"slider","aria-label":d,"aria-valuemax":n,"aria-valuemin":e,"aria-valuenow":t,ref:g,__vars:{"--slider-thumb-offset":`${r}%`},..._("thumb",{focusable:!0}),mod:{dragging:s,disabled:x},onFocus:S=>{w(!0),typeof h=="function"&&h(S)},onBlur:S=>{w(!1),typeof p=="function"&&p(S)},onTouchStart:a,onMouseDown:a,onKeyDownCapture:o,onClick:S=>S.stopPropagation(),children:[m,j.jsx(Na,{mounted:i!=null&&!!I,transition:"fade",duration:0,...l,children:S=>j.jsx("div",{..._("label",{style:S}),children:i})})]})});RN.displayName="@mantine/core/SliderThumb";function DN({value:n,min:e,max:t}){const r=(n-e)/(t-e)*100;return Math.min(Math.max(r,0),100)}function wV({mark:n,offset:e,value:t,inverted:r=!1}){return r?typeof e=="number"&&n.value<=e||n.value>=t:typeof e=="number"?n.value>=e&&n.value<=t:n.value<=t}function kN({marks:n,min:e,max:t,disabled:r,value:i,offset:s,inverted:a}){const{getStyles:o}=L0();if(!n)return null;const l=n.map((c,d)=>U.createElement(Je,{...o("markWrapper"),__vars:{"--mark-offset":`${DN({value:c.value,min:e,max:t})}%`},key:d},j.jsx(Je,{...o("mark"),mod:{filled:wV({mark:c,value:i,offset:s,inverted:a}),disabled:r}}),c.label&&j.jsx("div",{...o("markLabel"),children:c.label})));return j.jsx("div",{children:l})}kN.displayName="@mantine/core/SliderMarks";function NN({filled:n,children:e,offset:t,disabled:r,marksOffset:i,inverted:s,containerProps:a,...o}){const{getStyles:l}=L0();return j.jsx(Je,{...l("trackContainer"),mod:{disabled:r},...a,children:j.jsxs(Je,{...l("track"),mod:{inverted:s,disabled:r},children:[j.jsx(Je,{mod:{inverted:s,disabled:r},__vars:{"--slider-bar-width":`calc(${n}% + 2 * var(--slider-size))`,"--slider-bar-offset":`calc(${t}% - var(--slider-size))`},...l("bar")}),e,j.jsx(kN,{...o,offset:i,disabled:r,inverted:s})]})})}NN.displayName="@mantine/core/SliderTrack";function EV({value:n,containerWidth:e,min:t,max:r,step:i,precision:s}){const o=(e?Math.min(Math.max(n,0),e)/e:n)*(r-t),l=(o!==0?Math.round(o/i)*i:0)+t,c=Math.max(l,t);return s!==void 0?Number(c.toFixed(s)):c}function hm(n,e){return parseFloat(n.toFixed(e))}function IV(n){if(!n)return 0;const e=n.toString().split(".");return e.length>1?e[1].length:0}function Yx(n,e){const r=[...e].sort((i,s)=>i.value-s.value).find(i=>i.value>n);return r?r.value:n}function Xx(n,e){const r=[...e].sort((i,s)=>s.value-i.value).find(i=>i.value<n);return r?r.value:n}function hS(n){const e=[...n].sort((t,r)=>t.value-r.value);return e.length>0?e[0].value:0}function fS(n){const e=[...n].sort((t,r)=>t.value-r.value);return e.length>0?e[e.length-1].value:100}const CV={radius:"xl",min:0,max:100,step:1,marks:[],label:n=>n,labelTransitionProps:{transition:"fade",duration:0},thumbLabel:"",showLabelOnHover:!0,scale:n=>n,size:"md"},SV=(n,{size:e,color:t,thumbSize:r,radius:i})=>({root:{"--slider-size":gn(e,"slider-size"),"--slider-color":t?cs(t,n):void 0,"--slider-radius":i===void 0?void 0:Dr(i),"--slider-thumb-size":r!==void 0?$e(r):"calc(var(--slider-size) * 2)"}}),F0=Tt((n,e)=>{const t=ct("Slider",CV,n),{classNames:r,styles:i,value:s,onChange:a,onChangeEnd:o,size:l,min:c,max:d,domain:h,step:p,precision:A,defaultValue:y,name:m,marks:x,label:g,labelTransitionProps:_,labelAlwaysOn:b,thumbLabel:w,showLabelOnHover:I,thumbChildren:S,disabled:M,unstyled:T,scale:R,inverted:k,className:H,style:Q,vars:V,hiddenInputProps:B,restrictToMarks:W,thumbProps:K,attributes:X,...$}=t,J=en({name:"Slider",props:t,classes:MN,classNames:r,className:H,styles:i,style:Q,attributes:X,vars:V,varsResolver:SV,unstyled:T}),{dir:ne}=iu(),[L,G]=U.useState(!1),[oe,Ae]=Ks({value:typeof s=="number"?ss(s,c,d):s,defaultValue:typeof y=="number"?ss(y,c,d):y,finalValue:ss(0,c,d),onChange:a}),ye=U.useRef(oe),he=U.useRef(o);U.useEffect(()=>{he.current=o},[o]);const fe=U.useRef(null),Ie=U.useRef(null),[Re,ge]=h||[c,d],Ne=DN({value:oe,min:Re,max:ge}),tt=R(oe),Ge=typeof g=="function"?g(tt):g,F=A??IV(p),re=U.useCallback(({x:ve})=>{if(!M){const ce=EV({value:ve,min:Re,max:ge,step:p,precision:F}),Z=ss(ce,c,d);Ae(W&&x?.length?c2(Z,x.map(Y=>Y.value)):Z),ye.current=Z}},[M,c,d,Re,ge,p,F,Ae,x,W]),Ee=U.useCallback(()=>{if(!M&&he.current){const ve=W&&x?.length?c2(ye.current,x.map(ce=>ce.value)):ye.current;he.current(ve)}},[M,x,W]),{ref:q,active:ee}=Zw(re,{onScrubEnd:Ee},ne),ie=U.useCallback(ve=>{!M&&he.current&&he.current(ve)},[M]),be=ve=>{if(!M)switch(ve.key){case"ArrowUp":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=Yx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(oe+p,c),d),F);Ae(ce),ie(ce);break}case"ArrowRight":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=ne==="rtl"?Xx(oe,x):Yx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(ne==="rtl"?oe-p:oe+p,c),d),F);Ae(ce),ie(ce);break}case"ArrowDown":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=Xx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(oe-p,c),d),F);Ae(ce),ie(ce);break}case"ArrowLeft":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){const Z=ne==="rtl"?Yx(oe,x):Xx(oe,x);Ae(Z),ie(Z);break}const ce=hm(Math.min(Math.max(ne==="rtl"?oe+p:oe-p,c),d),F);Ae(ce),ie(ce);break}case"Home":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){Ae(hS(x)),ie(hS(x));break}Ae(c),ie(c);break}case"End":{if(ve.preventDefault(),Ie.current?.focus(),W&&x){Ae(fS(x)),ie(fS(x));break}Ae(d),ie(d);break}}};return j.jsx(bV,{value:{getStyles:J},children:j.jsxs(TN,{...$,ref:er(e,fe),onKeyDownCapture:be,onMouseDownCapture:()=>fe.current?.focus(),size:l,disabled:M,children:[j.jsx(NN,{inverted:k,offset:0,filled:Ne,marks:x,min:Re,max:ge,value:tt,disabled:M,containerProps:{ref:q,onMouseEnter:I?()=>G(!0):void 0,onMouseLeave:I?()=>G(!1):void 0},children:j.jsx(RN,{max:ge,min:Re,value:tt,position:Ne,dragging:ee,label:Ge,ref:Ie,labelTransitionProps:_,labelAlwaysOn:b,thumbLabel:w,showLabelOnHover:I,isHovered:L,disabled:M,...K,children:S})}),j.jsx("input",{type:"hidden",name:m,value:tt,...B})]})})});F0.classes=MN;F0.displayName="@mantine/core/Slider";var QN={root:"m_6d731127"};const BV={gap:"md",align:"stretch",justify:"flex-start"},MV=(n,{gap:e,align:t,justify:r})=>({root:{"--stack-gap":Jw(e),"--stack-align":t,"--stack-justify":r}}),lI=Tt((n,e)=>{const t=ct("Stack",BV,n),{classNames:r,className:i,style:s,styles:a,unstyled:o,vars:l,align:c,justify:d,gap:h,variant:p,attributes:A,...y}=t,m=en({name:"Stack",props:t,classes:QN,className:i,style:s,classNames:r,styles:a,unstyled:o,attributes:A,vars:l,varsResolver:MV});return j.jsx(Je,{ref:e,...m("root"),variant:p,...y})});lI.classes=QN;lI.displayName="@mantine/core/Stack";const cI=Tt((n,e)=>{const t=ct("TextInput",null,n);return j.jsx(na,{component:"input",ref:e,...t,__staticSelector:"TextInput"})});cI.classes=na.classes;cI.displayName="@mantine/core/TextInput";const TV="modulepreload",RV=function(n){return"/"+n},pS={},DV=function(e,t,r){let i=Promise.resolve();if(t&&t.length>0){let l=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=a?.nonce||a?.getAttribute("nonce");i=l(t.map(c=>{if(c=RV(c),c in pS)return;pS[c]=!0;const d=c.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":TV,d||(p.as="script"),p.crossOrigin="",p.href=c,o&&p.setAttribute("nonce",o),document.head.appendChild(p),d)return new Promise((A,y)=>{p.addEventListener("load",A),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return e().catch(s)})};const uI="181",Qd={ROTATE:0,DOLLY:1,PAN:2},Bd={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},kV=0,AS=1,NV=2,PN=1,LN=2,uo=3,Eo=0,Bi=1,rs=2,xo=0,Pd=1,mS=2,gS=3,yS=4,QV=5,Dc=100,PV=101,LV=102,FV=103,zV=104,UV=200,OV=201,$V=202,GV=203,vb=204,_b=205,VV=206,HV=207,jV=208,WV=209,qV=210,YV=211,XV=212,JV=213,KV=214,bb=0,wb=1,Eb=2,Hd=3,Ib=4,Cb=5,Sb=6,Bb=7,dI=0,ZV=1,eH=2,Pl=0,tH=1,nH=2,rH=3,FN=4,iH=5,sH=6,aH=7,xS="attached",oH="detached",zN=300,jd=301,Wd=302,Mb=303,Tb=304,z0=306,Fl=1e3,os=1001,Fg=1002,mr=1003,UN=1004,tp=1005,ir=1006,mg=1007,Ia=1008,lH=1008,ni=1009,ON=1010,$N=1011,Ip=1012,hI=1013,Mi=1014,js=1015,fh=1016,fI=1017,pI=1018,Cp=1020,GN=35902,VN=35899,HN=1021,jN=1022,sr=1023,Sp=1026,Bp=1027,AI=1028,mI=1029,gI=1030,U0=1031,vo=1033,gg=33776,yg=33777,xg=33778,vg=33779,Rb=35840,Db=35841,kb=35842,Nb=35843,Qb=36196,Pb=37492,Lb=37496,Fb=37808,zb=37809,Ub=37810,Ob=37811,$b=37812,Gb=37813,Vb=37814,Hb=37815,jb=37816,Wb=37817,qb=37818,Yb=37819,Xb=37820,Jb=37821,Kb=36492,Zb=36494,ew=36495,tw=36283,nw=36284,rw=36285,iw=36286,Mp=2300,Tp=2301,Jx=2302,vS=2400,_S=2401,bS=2402,cH=2500,uH=0,WN=1,sw=2,dH=3200,hH=3201,yI=0,fH=1,Dl="",Ar="srgb",ri="srgb-linear",zg="linear",Dn="srgb",rd=7680,wS=519,pH=512,AH=513,mH=514,qN=515,gH=516,yH=517,xH=518,vH=519,aw=35044,ow=35048,Ug="300 es",Ca=2e3,Og=2001;function YN(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Rp(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function _H(){const n=Rp("canvas");return n.style.display="block",n}const ES={};function $g(...n){const e="THREE."+n.shift()}function Pt(...n){const e="THREE."+n.shift()}function sn(...n){const e="THREE."+n.shift()}function Dp(...n){const e=n.join(" ");e in ES||(ES[e]=!0,Pt(...n))}function bH(n,e,t){return new Promise(function(r,i){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:i();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:r()}}setTimeout(s,t)})}class ou{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const r=t[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const qr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let IS=1234567;const fp=Math.PI/180,qd=180/Math.PI;function Ys(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(qr[n&255]+qr[n>>8&255]+qr[n>>16&255]+qr[n>>24&255]+"-"+qr[e&255]+qr[e>>8&255]+"-"+qr[e>>16&15|64]+qr[e>>24&255]+"-"+qr[t&63|128]+qr[t>>8&255]+"-"+qr[t>>16&255]+qr[t>>24&255]+qr[r&255]+qr[r>>8&255]+qr[r>>16&255]+qr[r>>24&255]).toLowerCase()}function nn(n,e,t){return Math.max(e,Math.min(t,n))}function xI(n,e){return(n%e+e)%e}function wH(n,e,t,r,i){return r+(n-e)*(i-r)/(t-e)}function EH(n,e,t){return n!==e?(t-n)/(e-n):0}function pp(n,e,t){return(1-t)*n+t*e}function IH(n,e,t,r){return pp(n,e,1-Math.exp(-t*r))}function CH(n,e=1){return e-Math.abs(xI(n,e*2)-e)}function SH(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function BH(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function MH(n,e){return n+Math.floor(Math.random()*(e-n+1))}function TH(n,e){return n+Math.random()*(e-n)}function RH(n){return n*(.5-Math.random())}function DH(n){n!==void 0&&(IS=n);let e=IS+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function kH(n){return n*fp}function NH(n){return n*qd}function QH(n){return(n&n-1)===0&&n!==0}function PH(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function LH(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function FH(n,e,t,r,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+r)/2),d=a((e+r)/2),h=s((e-r)/2),p=a((e-r)/2),A=s((r-e)/2),y=a((r-e)/2);switch(i){case"XYX":n.set(o*d,l*h,l*p,o*c);break;case"YZY":n.set(l*p,o*d,l*h,o*c);break;case"ZXZ":n.set(l*h,l*p,o*d,o*c);break;case"XZX":n.set(o*d,l*y,l*A,o*c);break;case"YXY":n.set(l*A,o*d,l*y,o*c);break;case"ZYZ":n.set(l*y,l*A,o*d,o*c);break;default:Pt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function $s(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Sn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const XN={DEG2RAD:fp,RAD2DEG:qd,generateUUID:Ys,clamp:nn,euclideanModulo:xI,mapLinear:wH,inverseLerp:EH,lerp:pp,damp:IH,pingpong:CH,smoothstep:SH,smootherstep:BH,randInt:MH,randFloat:TH,randFloatSpread:RH,seededRandom:DH,degToRad:kH,radToDeg:NH,isPowerOfTwo:QH,ceilPowerOfTwo:PH,floorPowerOfTwo:LH,setQuaternionFromProperEuler:FH,normalize:Sn,denormalize:$s};class Dt{constructor(e=0,t=0){Dt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+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=nn(this.x,e.x,t.x),this.y=nn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=nn(this.x,e,t),this.y=nn(this.y,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(nn(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(nn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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 r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class In{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,a,o){let l=r[i+0],c=r[i+1],d=r[i+2],h=r[i+3],p=s[a+0],A=s[a+1],y=s[a+2],m=s[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h;return}if(o>=1){e[t+0]=p,e[t+1]=A,e[t+2]=y,e[t+3]=m;return}if(h!==m||l!==p||c!==A||d!==y){let x=l*p+c*A+d*y+h*m;x<0&&(p=-p,A=-A,y=-y,m=-m,x=-x);let g=1-o;if(x<.9995){const _=Math.acos(x),b=Math.sin(_);g=Math.sin(g*_)/b,o=Math.sin(o*_)/b,l=l*g+p*o,c=c*g+A*o,d=d*g+y*o,h=h*g+m*o}else{l=l*g+p*o,c=c*g+A*o,d=d*g+y*o,h=h*g+m*o;const _=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=_,c*=_,d*=_,h*=_}}e[t]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h}static multiplyQuaternionsFlat(e,t,r,i,s,a){const o=r[i],l=r[i+1],c=r[i+2],d=r[i+3],h=s[a],p=s[a+1],A=s[a+2],y=s[a+3];return e[t]=o*y+d*h+l*A-c*p,e[t+1]=l*y+d*p+c*h-o*A,e[t+2]=c*y+d*A+o*p-l*h,e[t+3]=d*y-o*h-l*p-c*A,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,r,i){return this._x=e,this._y=t,this._z=r,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 r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(r/2),d=o(i/2),h=o(s/2),p=l(r/2),A=l(i/2),y=l(s/2);switch(a){case"XYZ":this._x=p*d*h+c*A*y,this._y=c*A*h-p*d*y,this._z=c*d*y+p*A*h,this._w=c*d*h-p*A*y;break;case"YXZ":this._x=p*d*h+c*A*y,this._y=c*A*h-p*d*y,this._z=c*d*y-p*A*h,this._w=c*d*h+p*A*y;break;case"ZXY":this._x=p*d*h-c*A*y,this._y=c*A*h+p*d*y,this._z=c*d*y+p*A*h,this._w=c*d*h-p*A*y;break;case"ZYX":this._x=p*d*h-c*A*y,this._y=c*A*h+p*d*y,this._z=c*d*y-p*A*h,this._w=c*d*h+p*A*y;break;case"YZX":this._x=p*d*h+c*A*y,this._y=c*A*h+p*d*y,this._z=c*d*y-p*A*h,this._w=c*d*h-p*A*y;break;case"XZY":this._x=p*d*h-c*A*y,this._y=c*A*h-p*d*y,this._z=c*d*y+p*A*h,this._w=c*d*h+p*A*y;break;default:Pt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],d=t[6],h=t[10],p=r+o+h;if(p>0){const A=.5/Math.sqrt(p+1);this._w=.25/A,this._x=(d-l)*A,this._y=(s-c)*A,this._z=(a-i)*A}else if(r>o&&r>h){const A=2*Math.sqrt(1+r-o-h);this._w=(d-l)/A,this._x=.25*A,this._y=(i+a)/A,this._z=(s+c)/A}else if(o>h){const A=2*Math.sqrt(1+o-r-h);this._w=(s-c)/A,this._x=(i+a)/A,this._y=.25*A,this._z=(l+d)/A}else{const A=2*Math.sqrt(1+h-r-o);this._w=(a-i)/A,this._x=(s+c)/A,this._y=(l+d)/A,this._z=.25*A}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(nn(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,t/r);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 e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,d=t._w;return this._x=r*d+a*o+i*c-s*l,this._y=i*d+a*l+s*o-r*c,this._z=s*d+a*c+r*l-i*o,this._w=a*d-r*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let r=e._x,i=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),d=Math.sin(c);l=Math.sin(l*c)/d,t=Math.sin(t*c)/d,this._x=this._x*l+r*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+r*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class de{constructor(e=0,t=0,r=0){de.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,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(CS.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(CS.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*r),d=2*(o*t-s*i),h=2*(s*r-a*t);return this.x=t+l*c+a*h-o*d,this.y=r+l*d+o*c-s*h,this.z=i+l*h+s*d-a*c,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,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[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=nn(this.x,e.x,t.x),this.y=nn(this.y,e.y,t.y),this.z=nn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=nn(this.x,e,t),this.y=nn(this.y,e,t),this.z=nn(this.z,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(nn(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Kx.copy(this).projectOnVector(e),this.sub(Kx)}reflect(e){return this.sub(Kx.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(nn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+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,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,r=Math.sqrt(1-t*t);return this.x=r*Math.cos(e),this.y=t,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Kx=new de,CS=new In;class Jt{constructor(e,t,r,i,s,a,o,l,c){Jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,r,i,s,a,o,l,c)}set(e,t,r,i,s,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=t,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.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 r=e.elements,i=t.elements,s=this.elements,a=r[0],o=r[3],l=r[6],c=r[1],d=r[4],h=r[7],p=r[2],A=r[5],y=r[8],m=i[0],x=i[3],g=i[6],_=i[1],b=i[4],w=i[7],I=i[2],S=i[5],M=i[8];return s[0]=a*m+o*_+l*I,s[3]=a*x+o*b+l*S,s[6]=a*g+o*w+l*M,s[1]=c*m+d*_+h*I,s[4]=c*x+d*b+h*S,s[7]=c*g+d*w+h*M,s[2]=p*m+A*_+y*I,s[5]=p*x+A*b+y*S,s[8]=p*g+A*w+y*M,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],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return t*a*d-t*o*c-r*s*d+r*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,p=o*l-d*s,A=c*s-a*l,y=t*h+r*p+i*A;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/y;return e[0]=h*m,e[1]=(i*c-d*r)*m,e[2]=(o*r-i*a)*m,e[3]=p*m,e[4]=(d*t-i*l)*m,e[5]=(i*s-o*t)*m,e[6]=A*m,e[7]=(r*l-c*t)*m,e[8]=(a*t-r*s)*m,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,r,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Zx.makeScale(e,t)),this}rotate(e){return this.premultiply(Zx.makeRotation(-e)),this}translate(e,t){return this.premultiply(Zx.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),r=Math.sin(e);return this.set(t,-r,0,r,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,r=e.elements;for(let i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Zx=new Jt,SS=new Jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),BS=new Jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zH(){const n={enabled:!0,workingColorSpace:ri,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Dn&&(i.r=_o(i.r),i.g=_o(i.g),i.b=_o(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Dn&&(i.r=Ld(i.r),i.g=Ld(i.g),i.b=Ld(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Dl?zg:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return Dp("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return Dp("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[ri]:{primaries:e,whitePoint:r,transfer:zg,toXYZ:SS,fromXYZ:BS,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ar},outputColorSpaceConfig:{drawingBufferColorSpace:Ar}},[Ar]:{primaries:e,whitePoint:r,transfer:Dn,toXYZ:SS,fromXYZ:BS,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ar}}}),n}const mn=zH();function _o(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Ld(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let id;class UH{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{id===void 0&&(id=Rp("canvas")),id.width=e.width,id.height=e.height;const i=id.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=id}return r.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Rp("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=_o(s[a]/255)*255;return r.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let r=0;r<t.length;r++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[r]=Math.floor(_o(t[r]/255)*255):t[r]=_o(t[r]);return{data:t,width:e.width,height:e.height}}else return Pt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let OH=0;class vI{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:OH++}),this.uuid=Ys(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(ev(i[a].image)):s.push(ev(i[a]))}else s=ev(i);r.url=s}return t||(e.images[this.uuid]=r),r}}function ev(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?UH.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Pt("Texture: Unable to serialize Texture."),{})}let $H=0;const tv=new de;class ar extends ou{constructor(e=ar.DEFAULT_IMAGE,t=ar.DEFAULT_MAPPING,r=os,i=os,s=ir,a=Ia,o=sr,l=ni,c=ar.DEFAULT_ANISOTROPY,d=Dl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:$H++}),this.uuid=Ys(),this.name="",this.source=new vI(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Dt(0,0),this.repeat=new Dt(1,1),this.center=new Dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Jt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(tv).x}get height(){return this.source.getSize(tv).y}get depth(){return this.source.getSize(tv).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 r=e[t];if(r===void 0){Pt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Pt(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={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&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==zN)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Fl:e.x=e.x-Math.floor(e.x);break;case os:e.x=e.x<0?0:1;break;case Fg:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Fl:e.y=e.y-Math.floor(e.y);break;case os:e.y=e.y<0?0:1;break;case Fg:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ar.DEFAULT_IMAGE=null;ar.DEFAULT_MAPPING=zN;ar.DEFAULT_ANISOTROPY=1;class Kt{constructor(e=0,t=0,r=0,i=1){Kt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,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,r,i){return this.x=e,this.y=t,this.z=r,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=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*r+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,i,s;const l=e.elements,c=l[0],d=l[4],h=l[8],p=l[1],A=l[5],y=l[9],m=l[2],x=l[6],g=l[10];if(Math.abs(d-p)<.01&&Math.abs(h-m)<.01&&Math.abs(y-x)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+m)<.1&&Math.abs(y+x)<.1&&Math.abs(c+A+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,w=(A+1)/2,I=(g+1)/2,S=(d+p)/4,M=(h+m)/4,T=(y+x)/4;return b>w&&b>I?b<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(b),i=S/r,s=M/r):w>I?w<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),r=S/i,s=T/i):I<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(I),r=M/s,i=T/s),this.set(r,i,s,t),this}let _=Math.sqrt((x-y)*(x-y)+(h-m)*(h-m)+(p-d)*(p-d));return Math.abs(_)<.001&&(_=1),this.x=(x-y)/_,this.y=(h-m)/_,this.z=(p-d)/_,this.w=Math.acos((c+A+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=nn(this.x,e.x,t.x),this.y=nn(this.y,e.y,t.y),this.z=nn(this.z,e.z,t.z),this.w=nn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=nn(this.x,e,t),this.y=nn(this.y,e,t),this.z=nn(this.z,e,t),this.w=nn(this.w,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(nn(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,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 GH extends ou{constructor(e=1,t=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ir,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=r.depth,this.scissor=new Kt(0,0,e,t),this.scissorTest=!1,this.viewport=new Kt(0,0,e,t);const i={width:e,height:t,depth:r.depth},s=new ar(i);this.textures=[];const a=r.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const t={minFilter:ir,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,r=1){if(this.width!==e||this.height!==t||this.depth!==r){this.width=e,this.height=t,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(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,r=e.textures.length;t<r;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new vI(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Qa extends GH{constructor(e=1,t=1,r={}){super(e,t,r),this.isWebGLRenderTarget=!0}}class Ta extends ar{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=mr,this.minFilter=mr,this.wrapR=os,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class JN extends Qa{constructor(e=1,t=1,r=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=r,this.texture=new Ta(null,e,t,r),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class KN extends ar{constructor(e=null,t=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=mr,this.minFilter=mr,this.wrapR=os,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ms{constructor(e=new de(1/0,1/0,1/0),t=new de(-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,r=e.length;t<r;t+=3)this.expandByPoint(Ts.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(Ts.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const r=Ts.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),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 r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ts):Ts.fromBufferAttribute(s,a),Ts.applyMatrix4(e.matrixWorld),this.expandByPoint(Ts);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),fm.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),fm.copy(r.boundingBox)),fm.applyMatrix4(e.matrixWorld),this.union(fm)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ts),Ts.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Mf),pm.subVectors(this.max,Mf),sd.subVectors(e.a,Mf),ad.subVectors(e.b,Mf),od.subVectors(e.c,Mf),ml.subVectors(ad,sd),gl.subVectors(od,ad),gc.subVectors(sd,od);let t=[0,-ml.z,ml.y,0,-gl.z,gl.y,0,-gc.z,gc.y,ml.z,0,-ml.x,gl.z,0,-gl.x,gc.z,0,-gc.x,-ml.y,ml.x,0,-gl.y,gl.x,0,-gc.y,gc.x,0];return!nv(t,sd,ad,od,pm)||(t=[1,0,0,0,1,0,0,0,1],!nv(t,sd,ad,od,pm))?!1:(Am.crossVectors(ml,gl),t=[Am.x,Am.y,Am.z],nv(t,sd,ad,od,pm))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ts).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ts).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(no[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),no[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),no[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),no[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),no[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),no[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),no[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),no[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(no),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 no=[new de,new de,new de,new de,new de,new de,new de,new de],Ts=new de,fm=new ms,sd=new de,ad=new de,od=new de,ml=new de,gl=new de,gc=new de,Mf=new de,pm=new de,Am=new de,yc=new de;function nv(n,e,t,r,i){for(let s=0,a=n.length-3;s<=a;s+=3){yc.fromArray(n,s);const o=i.x*Math.abs(yc.x)+i.y*Math.abs(yc.y)+i.z*Math.abs(yc.z),l=e.dot(yc),c=t.dot(yc),d=r.dot(yc);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const VH=new ms,Tf=new de,rv=new de;class Fa{constructor(e=new de,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 r=this.center;t!==void 0?r.copy(t):VH.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));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 r=this.center.distanceToSquared(e);return t.copy(e),r>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;Tf.subVectors(e,this.center);const t=Tf.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),i=(r-this.radius)*.5;this.center.addScaledVector(Tf,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(rv.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Tf.copy(e.center).add(rv)),this.expandByPoint(Tf.copy(e.center).sub(rv))),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 ro=new de,iv=new de,mm=new de,yl=new de,sv=new de,gm=new de,av=new de;class ph{constructor(e=new de,t=new de(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,ro)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ro.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ro.copy(this.origin).addScaledVector(this.direction,t),ro.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){iv.copy(e).add(t).multiplyScalar(.5),mm.copy(t).sub(e).normalize(),yl.copy(this.origin).sub(iv);const s=e.distanceTo(t)*.5,a=-this.direction.dot(mm),o=yl.dot(this.direction),l=-yl.dot(mm),c=yl.lengthSq(),d=Math.abs(1-a*a);let h,p,A,y;if(d>0)if(h=a*l-o,p=a*o-l,y=s*d,h>=0)if(p>=-y)if(p<=y){const m=1/d;h*=m,p*=m,A=h*(h+a*p+2*o)+p*(a*h+p+2*l)+c}else p=s,h=Math.max(0,-(a*p+o)),A=-h*h+p*(p+2*l)+c;else p=-s,h=Math.max(0,-(a*p+o)),A=-h*h+p*(p+2*l)+c;else p<=-y?(h=Math.max(0,-(-a*s+o)),p=h>0?-s:Math.min(Math.max(-s,-l),s),A=-h*h+p*(p+2*l)+c):p<=y?(h=0,p=Math.min(Math.max(-s,-l),s),A=p*(p+2*l)+c):(h=Math.max(0,-(a*s+o)),p=h>0?s:Math.min(Math.max(-s,-l),s),A=-h*h+p*(p+2*l)+c);else p=a>0?-s:s,h=Math.max(0,-(a*p+o)),A=-h*h+p*(p+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(iv).addScaledVector(mm,p),A}intersectSphere(e,t){ro.subVectors(e.center,this.origin);const r=ro.dot(this.direction),i=ro.dot(ro)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,s,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,p=this.origin;return c>=0?(r=(e.min.x-p.x)*c,i=(e.max.x-p.x)*c):(r=(e.max.x-p.x)*c,i=(e.min.x-p.x)*c),d>=0?(s=(e.min.y-p.y)*d,a=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,a=(e.min.y-p.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-p.z)*h,l=(e.max.z-p.z)*h):(o=(e.max.z-p.z)*h,l=(e.min.z-p.z)*h),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,t)}intersectsBox(e){return this.intersectBox(e,ro)!==null}intersectTriangle(e,t,r,i,s){sv.subVectors(t,e),gm.subVectors(r,e),av.crossVectors(sv,gm);let a=this.direction.dot(av),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;yl.subVectors(this.origin,e);const l=o*this.direction.dot(gm.crossVectors(yl,gm));if(l<0)return null;const c=o*this.direction.dot(sv.cross(yl));if(c<0||l+c>a)return null;const d=-o*yl.dot(av);return d<0?null:this.at(d/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ft{constructor(e,t,r,i,s,a,o,l,c,d,h,p,A,y,m,x){Ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,r,i,s,a,o,l,c,d,h,p,A,y,m,x)}set(e,t,r,i,s,a,o,l,c,d,h,p,A,y,m,x){const g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=i,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=d,g[10]=h,g[14]=p,g[3]=A,g[7]=y,g[11]=m,g[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ft().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[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,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,i=1/ld.setFromMatrixColumn(e,0).length(),s=1/ld.setFromMatrixColumn(e,1).length(),a=1/ld.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*s,t[5]=r[5]*s,t[6]=r[6]*s,t[7]=0,t[8]=r[8]*a,t[9]=r[9]*a,t[10]=r[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=a*d,A=a*h,y=o*d,m=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=A+y*c,t[5]=p-m*c,t[9]=-o*l,t[2]=m-p*c,t[6]=y+A*c,t[10]=a*l}else if(e.order==="YXZ"){const p=l*d,A=l*h,y=c*d,m=c*h;t[0]=p+m*o,t[4]=y*o-A,t[8]=a*c,t[1]=a*h,t[5]=a*d,t[9]=-o,t[2]=A*o-y,t[6]=m+p*o,t[10]=a*l}else if(e.order==="ZXY"){const p=l*d,A=l*h,y=c*d,m=c*h;t[0]=p-m*o,t[4]=-a*h,t[8]=y+A*o,t[1]=A+y*o,t[5]=a*d,t[9]=m-p*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const p=a*d,A=a*h,y=o*d,m=o*h;t[0]=l*d,t[4]=y*c-A,t[8]=p*c+m,t[1]=l*h,t[5]=m*c+p,t[9]=A*c-y,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const p=a*l,A=a*c,y=o*l,m=o*c;t[0]=l*d,t[4]=m-p*h,t[8]=y*h+A,t[1]=h,t[5]=a*d,t[9]=-o*d,t[2]=-c*d,t[6]=A*h+y,t[10]=p-m*h}else if(e.order==="XZY"){const p=a*l,A=a*c,y=o*l,m=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=p*h+m,t[5]=a*d,t[9]=A*h-y,t[2]=y*h-A,t[6]=o*d,t[10]=m*h+p}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(HH,e,jH)}lookAt(e,t,r){const i=this.elements;return zi.subVectors(e,t),zi.lengthSq()===0&&(zi.z=1),zi.normalize(),xl.crossVectors(r,zi),xl.lengthSq()===0&&(Math.abs(r.z)===1?zi.x+=1e-4:zi.z+=1e-4,zi.normalize(),xl.crossVectors(r,zi)),xl.normalize(),ym.crossVectors(zi,xl),i[0]=xl.x,i[4]=ym.x,i[8]=zi.x,i[1]=xl.y,i[5]=ym.y,i[9]=zi.y,i[2]=xl.z,i[6]=ym.z,i[10]=zi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,a=r[0],o=r[4],l=r[8],c=r[12],d=r[1],h=r[5],p=r[9],A=r[13],y=r[2],m=r[6],x=r[10],g=r[14],_=r[3],b=r[7],w=r[11],I=r[15],S=i[0],M=i[4],T=i[8],R=i[12],k=i[1],H=i[5],Q=i[9],V=i[13],B=i[2],W=i[6],K=i[10],X=i[14],$=i[3],J=i[7],ne=i[11],L=i[15];return s[0]=a*S+o*k+l*B+c*$,s[4]=a*M+o*H+l*W+c*J,s[8]=a*T+o*Q+l*K+c*ne,s[12]=a*R+o*V+l*X+c*L,s[1]=d*S+h*k+p*B+A*$,s[5]=d*M+h*H+p*W+A*J,s[9]=d*T+h*Q+p*K+A*ne,s[13]=d*R+h*V+p*X+A*L,s[2]=y*S+m*k+x*B+g*$,s[6]=y*M+m*H+x*W+g*J,s[10]=y*T+m*Q+x*K+g*ne,s[14]=y*R+m*V+x*X+g*L,s[3]=_*S+b*k+w*B+I*$,s[7]=_*M+b*H+w*W+I*J,s[11]=_*T+b*Q+w*K+I*ne,s[15]=_*R+b*V+w*X+I*L,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],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],p=e[10],A=e[14],y=e[3],m=e[7],x=e[11],g=e[15];return y*(+s*l*h-i*c*h-s*o*p+r*c*p+i*o*A-r*l*A)+m*(+t*l*A-t*c*p+s*a*p-i*a*A+i*c*d-s*l*d)+x*(+t*c*h-t*o*A-s*a*h+r*a*A+s*o*d-r*c*d)+g*(-i*o*d-t*l*h+t*o*p+i*a*h-r*a*p+r*l*d)}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,r){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]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],p=e[10],A=e[11],y=e[12],m=e[13],x=e[14],g=e[15],_=h*x*c-m*p*c+m*l*A-o*x*A-h*l*g+o*p*g,b=y*p*c-d*x*c-y*l*A+a*x*A+d*l*g-a*p*g,w=d*m*c-y*h*c+y*o*A-a*m*A-d*o*g+a*h*g,I=y*h*l-d*m*l-y*o*p+a*m*p+d*o*x-a*h*x,S=t*_+r*b+i*w+s*I;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/S;return e[0]=_*M,e[1]=(m*p*s-h*x*s-m*i*A+r*x*A+h*i*g-r*p*g)*M,e[2]=(o*x*s-m*l*s+m*i*c-r*x*c-o*i*g+r*l*g)*M,e[3]=(h*l*s-o*p*s-h*i*c+r*p*c+o*i*A-r*l*A)*M,e[4]=b*M,e[5]=(d*x*s-y*p*s+y*i*A-t*x*A-d*i*g+t*p*g)*M,e[6]=(y*l*s-a*x*s-y*i*c+t*x*c+a*i*g-t*l*g)*M,e[7]=(a*p*s-d*l*s+d*i*c-t*p*c-a*i*A+t*l*A)*M,e[8]=w*M,e[9]=(y*h*s-d*m*s-y*r*A+t*m*A+d*r*g-t*h*g)*M,e[10]=(a*m*s-y*o*s+y*r*c-t*m*c-a*r*g+t*o*g)*M,e[11]=(d*o*s-a*h*s-d*r*c+t*h*c+a*r*A-t*o*A)*M,e[12]=I*M,e[13]=(d*m*i-y*h*i+y*r*p-t*m*p-d*r*x+t*h*x)*M,e[14]=(y*o*i-a*m*i-y*r*l+t*m*l+a*r*x-t*o*x)*M,e[15]=(a*h*i-d*o*i+d*r*l-t*h*l-a*r*p+t*o*p)*M,this}scale(e){const t=this.elements,r=e.x,i=e.y,s=e.z;return t[0]*=r,t[4]*=i,t[8]*=s,t[1]*=r,t[5]*=i,t[9]*=s,t[2]*=r,t[6]*=i,t[10]*=s,t[3]*=r,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=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,r,i))}makeTranslation(e,t,r){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,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),i=Math.sin(t),s=1-r,a=e.x,o=e.y,l=e.z,c=s*a,d=s*o;return this.set(c*a+r,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+r,d*l-i*a,0,c*l-i*o,d*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){const i=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,d=a+a,h=o+o,p=s*c,A=s*d,y=s*h,m=a*d,x=a*h,g=o*h,_=l*c,b=l*d,w=l*h,I=r.x,S=r.y,M=r.z;return i[0]=(1-(m+g))*I,i[1]=(A+w)*I,i[2]=(y-b)*I,i[3]=0,i[4]=(A-w)*S,i[5]=(1-(p+g))*S,i[6]=(x+_)*S,i[7]=0,i[8]=(y+b)*M,i[9]=(x-_)*M,i[10]=(1-(p+m))*M,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){const i=this.elements;let s=ld.set(i[0],i[1],i[2]).length();const a=ld.set(i[4],i[5],i[6]).length(),o=ld.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Rs.copy(this);const c=1/s,d=1/a,h=1/o;return Rs.elements[0]*=c,Rs.elements[1]*=c,Rs.elements[2]*=c,Rs.elements[4]*=d,Rs.elements[5]*=d,Rs.elements[6]*=d,Rs.elements[8]*=h,Rs.elements[9]*=h,Rs.elements[10]*=h,t.setFromRotationMatrix(Rs),r.x=s,r.y=a,r.z=o,this}makePerspective(e,t,r,i,s,a,o=Ca,l=!1){const c=this.elements,d=2*s/(t-e),h=2*s/(r-i),p=(t+e)/(t-e),A=(r+i)/(r-i);let y,m;if(l)y=s/(a-s),m=a*s/(a-s);else if(o===Ca)y=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Og)y=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=h,c[9]=A,c[13]=0,c[2]=0,c[6]=0,c[10]=y,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,r,i,s,a,o=Ca,l=!1){const c=this.elements,d=2/(t-e),h=2/(r-i),p=-(t+e)/(t-e),A=-(r+i)/(r-i);let y,m;if(l)y=1/(a-s),m=a/(a-s);else if(o===Ca)y=-2/(a-s),m=-(a+s)/(a-s);else if(o===Og)y=-1/(a-s),m=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=h,c[9]=0,c[13]=A,c[2]=0,c[6]=0,c[10]=y,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const ld=new de,Rs=new Ft,HH=new de(0,0,0),jH=new de(1,1,1),xl=new de,ym=new de,zi=new de,MS=new Ft,TS=new In;class Hi{constructor(e=0,t=0,r=0,i=Hi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,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,r,i=this._order){return this._x=e,this._y=t,this._z=r,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,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],p=i[6],A=i[10];switch(t){case"XYZ":this._y=Math.asin(nn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,A),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-nn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,A),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(nn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,A),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-nn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,A),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(nn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,A));break;case"XZY":this._z=Math.asin(-nn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,A),this._y=0);break;default:Pt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return MS.makeRotationFromQuaternion(e),this.setFromRotationMatrix(MS,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return TS.setFromEuler(this),this.setFromQuaternion(TS,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Hi.DEFAULT_ORDER="XYZ";class _I{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let WH=0;const RS=new de,cd=new In,io=new Ft,xm=new de,Rf=new de,qH=new de,YH=new In,DS=new de(1,0,0),kS=new de(0,1,0),NS=new de(0,0,1),QS={type:"added"},XH={type:"removed"},ud={type:"childadded",child:null},ov={type:"childremoved",child:null};class zn extends ou{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:WH++}),this.uuid=Ys(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=zn.DEFAULT_UP.clone();const e=new de,t=new Hi,r=new In,i=new de(1,1,1);function s(){r.setFromEuler(t,!1)}function a(){t.setFromQuaternion(r,void 0,!1)}t._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ft},normalMatrix:{value:new Jt}}),this.matrix=new Ft,this.matrixWorld=new Ft,this.matrixAutoUpdate=zn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=zn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new _I,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 cd.setFromAxisAngle(e,t),this.quaternion.multiply(cd),this}rotateOnWorldAxis(e,t){return cd.setFromAxisAngle(e,t),this.quaternion.premultiply(cd),this}rotateX(e){return this.rotateOnAxis(DS,e)}rotateY(e){return this.rotateOnAxis(kS,e)}rotateZ(e){return this.rotateOnAxis(NS,e)}translateOnAxis(e,t){return RS.copy(e).applyQuaternion(this.quaternion),this.position.add(RS.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(DS,e)}translateY(e){return this.translateOnAxis(kS,e)}translateZ(e){return this.translateOnAxis(NS,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(io.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?xm.copy(e):xm.set(e,t,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Rf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?io.lookAt(Rf,xm,this.up):io.lookAt(xm,Rf,this.up),this.quaternion.setFromRotationMatrix(io),i&&(io.extractRotation(i.matrixWorld),cd.setFromRotationMatrix(io),this.quaternion.premultiply(cd.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(sn("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(QS),ud.child=e,this.dispatchEvent(ud),ud.child=null):sn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(XH),ov.child=e,this.dispatchEvent(ov),ov.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),io.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),io.multiply(e.parent.matrixWorld)),e.applyMatrix4(io),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(QS),ud.child=e,this.dispatchEvent(ud),ud.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 r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rf,e,qH),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Rf,YH,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 r=0,i=t.length;r<i;r++)t[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].updateMatrixWorld(e)}updateWorldMatrix(e,t){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(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(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(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(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),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),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(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&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),p=a(e.skeletons),A=a(e.animations),y=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),d.length>0&&(r.images=d),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),A.length>0&&(r.animations=A),y.length>0&&(r.nodes=y)}return r.object=i,r;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}zn.DEFAULT_UP=new de(0,1,0);zn.DEFAULT_MATRIX_AUTO_UPDATE=!0;zn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ds=new de,so=new de,lv=new de,ao=new de,dd=new de,hd=new de,PS=new de,cv=new de,uv=new de,dv=new de,hv=new Kt,fv=new Kt,pv=new Kt;class Gs{constructor(e=new de,t=new de,r=new de){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),Ds.subVectors(e,t),i.cross(Ds);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){Ds.subVectors(i,t),so.subVectors(r,t),lv.subVectors(e,t);const a=Ds.dot(Ds),o=Ds.dot(so),l=Ds.dot(lv),c=so.dot(so),d=so.dot(lv),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const p=1/h,A=(c*l-o*d)*p,y=(a*d-o*l)*p;return s.set(1-A-y,y,A)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,ao)===null?!1:ao.x>=0&&ao.y>=0&&ao.x+ao.y<=1}static getInterpolation(e,t,r,i,s,a,o,l){return this.getBarycoord(e,t,r,i,ao)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,ao.x),l.addScaledVector(a,ao.y),l.addScaledVector(o,ao.z),l)}static getInterpolatedAttribute(e,t,r,i,s,a){return hv.setScalar(0),fv.setScalar(0),pv.setScalar(0),hv.fromBufferAttribute(e,t),fv.fromBufferAttribute(e,r),pv.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(hv,s.x),a.addScaledVector(fv,s.y),a.addScaledVector(pv,s.z),a}static isFrontFacing(e,t,r,i){return Ds.subVectors(r,t),so.subVectors(e,t),Ds.cross(so).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),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 Ds.subVectors(this.c,this.b),so.subVectors(this.a,this.b),Ds.cross(so).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Gs.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Gs.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,s){return Gs.getInterpolation(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return Gs.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Gs.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,s=this.c;let a,o;dd.subVectors(i,r),hd.subVectors(s,r),cv.subVectors(e,r);const l=dd.dot(cv),c=hd.dot(cv);if(l<=0&&c<=0)return t.copy(r);uv.subVectors(e,i);const d=dd.dot(uv),h=hd.dot(uv);if(d>=0&&h<=d)return t.copy(i);const p=l*h-d*c;if(p<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(r).addScaledVector(dd,a);dv.subVectors(e,s);const A=dd.dot(dv),y=hd.dot(dv);if(y>=0&&A<=y)return t.copy(s);const m=A*c-l*y;if(m<=0&&c>=0&&y<=0)return o=c/(c-y),t.copy(r).addScaledVector(hd,o);const x=d*y-A*h;if(x<=0&&h-d>=0&&A-y>=0)return PS.subVectors(s,i),o=(h-d)/(h-d+(A-y)),t.copy(i).addScaledVector(PS,o);const g=1/(x+m+p);return a=m*g,o=p*g,t.copy(r).addScaledVector(dd,a).addScaledVector(hd,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ZN={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},vl={h:0,s:0,l:0},vm={h:0,s:0,l:0};function Av(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class xt{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(t===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ar){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mn.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=mn.workingColorSpace){return this.r=e,this.g=t,this.b=r,mn.colorSpaceToWorking(this,i),this}setHSL(e,t,r,i=mn.workingColorSpace){if(e=xI(e,1),t=nn(t,0,1),r=nn(r,0,1),t===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,a=2*r-s;this.r=Av(a,s,e+1/3),this.g=Av(a,s,e),this.b=Av(a,s,e-1/3)}return mn.colorSpaceToWorking(this,i),this}setStyle(e,t=Ar){function r(s){s!==void 0&&parseFloat(s)<1&&Pt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Pt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Pt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ar){const r=ZN[e.toLowerCase()];return r!==void 0?this.setHex(r,t):Pt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=_o(e.r),this.g=_o(e.g),this.b=_o(e.b),this}copyLinearToSRGB(e){return this.r=Ld(e.r),this.g=Ld(e.g),this.b=Ld(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ar){return mn.workingToColorSpace(Yr.copy(this),e),Math.round(nn(Yr.r*255,0,255))*65536+Math.round(nn(Yr.g*255,0,255))*256+Math.round(nn(Yr.b*255,0,255))}getHexString(e=Ar){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mn.workingColorSpace){mn.workingToColorSpace(Yr.copy(this),t);const r=Yr.r,i=Yr.g,s=Yr.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case r:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-r)/h+2;break;case s:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,t=mn.workingColorSpace){return mn.workingToColorSpace(Yr.copy(this),t),e.r=Yr.r,e.g=Yr.g,e.b=Yr.b,e}getStyle(e=Ar){mn.workingToColorSpace(Yr.copy(this),e);const t=Yr.r,r=Yr.g,i=Yr.b;return e!==Ar?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,t,r){return this.getHSL(vl),this.setHSL(vl.h+e,vl.s+t,vl.l+r)}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,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(vl),e.getHSL(vm);const r=pp(vl.h,vm.h,t),i=pp(vl.s,vm.s,t),s=pp(vl.l,vm.l,t);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*r+s[6]*i,this.g=s[1]*t+s[4]*r+s[7]*i,this.b=s[2]*t+s[5]*r+s[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 Yr=new xt;xt.NAMES=ZN;let JH=0;class Xs extends ou{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:JH++}),this.uuid=Ys(),this.name="",this.type="Material",this.blending=Pd,this.side=Eo,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vb,this.blendDst=_b,this.blendEquation=Dc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xt(0,0,0),this.blendAlpha=0,this.depthFunc=Hd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wS,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=rd,this.stencilZFail=rd,this.stencilZPass=rd,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const r=e[t];if(r===void 0){Pt(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Pt(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Pd&&(r.blending=this.blending),this.side!==Eo&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==vb&&(r.blendSrc=this.blendSrc),this.blendDst!==_b&&(r.blendDst=this.blendDst),this.blendEquation!==Dc&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Hd&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wS&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rd&&(r.stencilFail=this.stencilFail),this.stencilZFail!==rd&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==rd&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}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 r=null;if(t!==null){const i=t.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,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){e===!0&&this.version++}}class Oc extends Xs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xt(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 Hi,this.combine=dI,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 rr=new de,_m=new Dt;let KH=0;class or{constructor(e,t,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:KH++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r,this.usage=aw,this.updateRanges=[],this.gpuType=js,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,r=this.count;t<r;t++)_m.fromBufferAttribute(this,t),_m.applyMatrix3(e),this.setXY(t,_m.x,_m.y);else if(this.itemSize===3)for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.applyMatrix3(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.applyMatrix4(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.applyNormalMatrix(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)rr.fromBufferAttribute(this,t),rr.transformDirection(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=$s(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=Sn(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=$s(t,this.array)),t}setX(e,t){return this.normalized&&(t=Sn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=$s(t,this.array)),t}setY(e,t){return this.normalized&&(t=Sn(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=$s(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Sn(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=$s(t,this.array)),t}setW(e,t){return this.normalized&&(t=Sn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e*=this.itemSize,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array),s=Sn(s,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==aw&&(e.usage=this.usage),e}}class eQ extends or{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class tQ extends or{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class Wn extends or{constructor(e,t,r){super(new Float32Array(e),t,r)}}let ZH=0;const Zi=new Ft,mv=new zn,fd=new de,Ui=new ms,Df=new ms,Sr=new de;class _r extends ou{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ZH++}),this.uuid=Ys(),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(YN(e)?tQ:eQ)(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 this.attributes[e]!==void 0}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Jt().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Zi.makeRotationFromQuaternion(e),this.applyMatrix4(Zi),this}rotateX(e){return Zi.makeRotationX(e),this.applyMatrix4(Zi),this}rotateY(e){return Zi.makeRotationY(e),this.applyMatrix4(Zi),this}rotateZ(e){return Zi.makeRotationZ(e),this.applyMatrix4(Zi),this}translate(e,t,r){return Zi.makeTranslation(e,t,r),this.applyMatrix4(Zi),this}scale(e,t,r){return Zi.makeScale(e,t,r),this.applyMatrix4(Zi),this}lookAt(e){return mv.lookAt(e),mv.updateMatrix(),this.applyMatrix4(mv.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fd).negate(),this.translate(fd.x,fd.y,fd.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Wn(r,3))}else{const r=Math.min(e.length,t.count);for(let i=0;i<r;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&Pt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ms);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new de(-1/0,-1/0,-1/0),new de(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let r=0,i=t.length;r<i;r++){const s=t[r];Ui.setFromBufferAttribute(s),this.morphTargetsRelative?(Sr.addVectors(this.boundingBox.min,Ui.min),this.boundingBox.expandByPoint(Sr),Sr.addVectors(this.boundingBox.max,Ui.max),this.boundingBox.expandByPoint(Sr)):(this.boundingBox.expandByPoint(Ui.min),this.boundingBox.expandByPoint(Ui.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&sn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Fa);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new de,1/0);return}if(e){const r=this.boundingSphere.center;if(Ui.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Df.setFromBufferAttribute(o),this.morphTargetsRelative?(Sr.addVectors(Ui.min,Df.min),Ui.expandByPoint(Sr),Sr.addVectors(Ui.max,Df.max),Ui.expandByPoint(Sr)):(Ui.expandByPoint(Df.min),Ui.expandByPoint(Df.max))}Ui.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Sr.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Sr));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)Sr.fromBufferAttribute(o,c),l&&(fd.fromBufferAttribute(e,c),Sr.add(fd)),i=Math.max(i,r.distanceToSquared(Sr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&sn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){sn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new or(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let T=0;T<r.count;T++)o[T]=new de,l[T]=new de;const c=new de,d=new de,h=new de,p=new Dt,A=new Dt,y=new Dt,m=new de,x=new de;function g(T,R,k){c.fromBufferAttribute(r,T),d.fromBufferAttribute(r,R),h.fromBufferAttribute(r,k),p.fromBufferAttribute(s,T),A.fromBufferAttribute(s,R),y.fromBufferAttribute(s,k),d.sub(c),h.sub(c),A.sub(p),y.sub(p);const H=1/(A.x*y.y-y.x*A.y);isFinite(H)&&(m.copy(d).multiplyScalar(y.y).addScaledVector(h,-A.y).multiplyScalar(H),x.copy(h).multiplyScalar(A.x).addScaledVector(d,-y.x).multiplyScalar(H),o[T].add(m),o[R].add(m),o[k].add(m),l[T].add(x),l[R].add(x),l[k].add(x))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let T=0,R=_.length;T<R;++T){const k=_[T],H=k.start,Q=k.count;for(let V=H,B=H+Q;V<B;V+=3)g(e.getX(V+0),e.getX(V+1),e.getX(V+2))}const b=new de,w=new de,I=new de,S=new de;function M(T){I.fromBufferAttribute(i,T),S.copy(I);const R=o[T];b.copy(R),b.sub(I.multiplyScalar(I.dot(R))).normalize(),w.crossVectors(S,R);const H=w.dot(l[T])<0?-1:1;a.setXYZW(T,b.x,b.y,b.z,H)}for(let T=0,R=_.length;T<R;++T){const k=_[T],H=k.start,Q=k.count;for(let V=H,B=H+Q;V<B;V+=3)M(e.getX(V+0)),M(e.getX(V+1)),M(e.getX(V+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new or(new Float32Array(t.count*3),3),this.setAttribute("normal",r);else for(let p=0,A=r.count;p<A;p++)r.setXYZ(p,0,0,0);const i=new de,s=new de,a=new de,o=new de,l=new de,c=new de,d=new de,h=new de;if(e)for(let p=0,A=e.count;p<A;p+=3){const y=e.getX(p+0),m=e.getX(p+1),x=e.getX(p+2);i.fromBufferAttribute(t,y),s.fromBufferAttribute(t,m),a.fromBufferAttribute(t,x),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(r,y),l.fromBufferAttribute(r,m),c.fromBufferAttribute(r,x),o.add(d),l.add(d),c.add(d),r.setXYZ(y,o.x,o.y,o.z),r.setXYZ(m,l.x,l.y,l.z),r.setXYZ(x,c.x,c.y,c.z)}else for(let p=0,A=t.count;p<A;p+=3)i.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),a.fromBufferAttribute(t,p+2),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)Sr.fromBufferAttribute(e,t),Sr.normalize(),e.setXYZ(t,Sr.x,Sr.y,Sr.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,p=new c.constructor(l.length*d);let A=0,y=0;for(let m=0,x=l.length;m<x;m++){o.isInterleavedBufferAttribute?A=l[m]*o.data.stride+o.offset:A=l[m]*d;for(let g=0;g<d;g++)p[y++]=c[A++]}return new or(p,d,h)}if(this.index===null)return Pt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new _r,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let d=0,h=c.length;d<h;d++){const p=c[d],A=e(p,r);l.push(A)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,p=c.length;h<p;h++){const A=c[h];d.push(A.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(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 o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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 r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const d=i[c];this.setAttribute(c,d.clone(t))}const s=e.morphAttributes;for(const c in s){const d=[],h=s[c];for(let p=0,A=h.length;p<A;p++)d.push(h[p].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const LS=new Ft,xc=new ph,bm=new Fa,FS=new de,wm=new de,Em=new de,Im=new de,gv=new de,Cm=new de,zS=new de,Sm=new de;class Jn extends zn{constructor(e=new _r,t=new Oc){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){Cm.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(gv.fromBufferAttribute(h,e),a?Cm.addScaledVector(gv,d):Cm.addScaledVector(gv.sub(t),d))}t.add(Cm)}return t}raycast(e,t){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),bm.copy(r.boundingSphere),bm.applyMatrix4(s),xc.copy(e.ray).recast(e.near),!(bm.containsPoint(xc.origin)===!1&&(xc.intersectSphere(bm,FS)===null||xc.origin.distanceToSquared(FS)>(e.far-e.near)**2))&&(LS.copy(s).invert(),xc.copy(e.ray).applyMatrix4(LS),!(r.boundingBox!==null&&xc.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,t,xc)))}_computeIntersections(e,t,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,p=s.groups,A=s.drawRange;if(o!==null)if(Array.isArray(a))for(let y=0,m=p.length;y<m;y++){const x=p[y],g=a[x.materialIndex],_=Math.max(x.start,A.start),b=Math.min(o.count,Math.min(x.start+x.count,A.start+A.count));for(let w=_,I=b;w<I;w+=3){const S=o.getX(w),M=o.getX(w+1),T=o.getX(w+2);i=Bm(this,g,e,r,c,d,h,S,M,T),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=x.materialIndex,t.push(i))}}else{const y=Math.max(0,A.start),m=Math.min(o.count,A.start+A.count);for(let x=y,g=m;x<g;x+=3){const _=o.getX(x),b=o.getX(x+1),w=o.getX(x+2);i=Bm(this,a,e,r,c,d,h,_,b,w),i&&(i.faceIndex=Math.floor(x/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let y=0,m=p.length;y<m;y++){const x=p[y],g=a[x.materialIndex],_=Math.max(x.start,A.start),b=Math.min(l.count,Math.min(x.start+x.count,A.start+A.count));for(let w=_,I=b;w<I;w+=3){const S=w,M=w+1,T=w+2;i=Bm(this,g,e,r,c,d,h,S,M,T),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=x.materialIndex,t.push(i))}}else{const y=Math.max(0,A.start),m=Math.min(l.count,A.start+A.count);for(let x=y,g=m;x<g;x+=3){const _=x,b=x+1,w=x+2;i=Bm(this,a,e,r,c,d,h,_,b,w),i&&(i.faceIndex=Math.floor(x/3),t.push(i))}}}}function e9(n,e,t,r,i,s,a,o){let l;if(e.side===Bi?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===Eo,o),l===null)return null;Sm.copy(o),Sm.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Sm);return c<t.near||c>t.far?null:{distance:c,point:Sm.clone(),object:n}}function Bm(n,e,t,r,i,s,a,o,l,c){n.getVertexPosition(o,wm),n.getVertexPosition(l,Em),n.getVertexPosition(c,Im);const d=e9(n,e,t,r,wm,Em,Im,zS);if(d){const h=new de;Gs.getBarycoord(zS,wm,Em,Im,h),i&&(d.uv=Gs.getInterpolatedAttribute(i,o,l,c,h,new Dt)),s&&(d.uv1=Gs.getInterpolatedAttribute(s,o,l,c,h,new Dt)),a&&(d.normal=Gs.getInterpolatedAttribute(a,o,l,c,h,new de),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new de,materialIndex:0};Gs.getNormal(wm,Em,Im,p.normal),d.face=p,d.barycoord=h}return d}class Ah extends _r{constructor(e=1,t=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],d=[],h=[];let p=0,A=0;y("z","y","x",-1,-1,r,t,e,a,s,0),y("z","y","x",1,-1,r,t,-e,a,s,1),y("x","z","y",1,1,e,r,t,i,a,2),y("x","z","y",1,-1,e,r,-t,i,a,3),y("x","y","z",1,-1,e,t,r,i,s,4),y("x","y","z",-1,-1,e,t,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Wn(c,3)),this.setAttribute("normal",new Wn(d,3)),this.setAttribute("uv",new Wn(h,2));function y(m,x,g,_,b,w,I,S,M,T,R){const k=w/M,H=I/T,Q=w/2,V=I/2,B=S/2,W=M+1,K=T+1;let X=0,$=0;const J=new de;for(let ne=0;ne<K;ne++){const L=ne*H-V;for(let G=0;G<W;G++){const oe=G*k-Q;J[m]=oe*_,J[x]=L*b,J[g]=B,c.push(J.x,J.y,J.z),J[m]=0,J[x]=0,J[g]=S>0?1:-1,d.push(J.x,J.y,J.z),h.push(G/M),h.push(1-ne/T),X+=1}}for(let ne=0;ne<T;ne++)for(let L=0;L<M;L++){const G=p+L+W*ne,oe=p+L+W*(ne+1),Ae=p+(L+1)+W*(ne+1),ye=p+(L+1)+W*ne;l.push(G,oe,ye),l.push(oe,Ae,ye),$+=6}o.addGroup(A,$,R),A+=$,p+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ah(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Yd(n){const e={};for(const t in n){e[t]={};for(const r in n[t]){const i=n[t][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Pt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][r]=null):e[t][r]=i.clone():Array.isArray(i)?e[t][r]=i.slice():e[t][r]=i}}return e}function di(n){const e={};for(let t=0;t<n.length;t++){const r=Yd(n[t]);for(const i in r)e[i]=r[i]}return e}function t9(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function nQ(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:mn.workingColorSpace}const n9={clone:Yd,merge:di};var r9=`void main() {
|
|
57
57
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
58
58
|
}`,i9=`void main() {
|
|
59
59
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -92,7 +92,7 @@ ${c}`}function iE({color:n,theme:e,autoContrast:t}){return(typeof t=="boolean"?t
|
|
|
92
92
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
93
93
|
|
|
94
94
|
}
|
|
95
|
-
`},i=new Ah(5,5,5),s=new ji({name:"CubemapFromEquirect",uniforms:Yd(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Bi,blending:xo});s.uniforms.tEquirect.value=t;const a=new Jn(i,s),o=t.minFilter;return t.minFilter===Ia&&(t.minFilter=ir),new iQ(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,r,i);e.setRenderTarget(s)}}class ls extends zn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const s9={type:"move"};class yv{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ls,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ls,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new de,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new de),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ls,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new de,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new de),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,r){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const m of e.hand.values()){const x=t.getJointPose(m,r),g=this._getHandJoint(c,m);x!==null&&(g.matrix.fromArray(x.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=x.radius),g.visible=x!==null}const d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],p=d.position.distanceTo(h.position),A=.02,y=.005;c.inputState.pinching&&p>A+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=A-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(s9)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const r=new ls;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class a9 extends zn{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 Hi,this.environmentIntensity=1,this.environmentRotation=new Hi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class o9{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=aw,this.updateRanges=[],this.version=0,this.uuid=Ys()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[r+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ys()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ys()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const li=new de;class bI{constructor(e,t,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,r=this.data.count;t<r;t++)li.fromBufferAttribute(this,t),li.applyMatrix4(e),this.setXYZ(t,li.x,li.y,li.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)li.fromBufferAttribute(this,t),li.applyNormalMatrix(e),this.setXYZ(t,li.x,li.y,li.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)li.fromBufferAttribute(this,t),li.transformDirection(e),this.setXYZ(t,li.x,li.y,li.z);return this}getComponent(e,t){let r=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(r=$s(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=Sn(r,this.array)),this.data.array[e*this.data.stride+this.offset+t]=r,this}setX(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=$s(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=$s(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=$s(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=$s(t,this.array)),t}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array),s=Sn(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){$g("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new or(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new bI(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){$g("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const $S=new de,GS=new Kt,VS=new Kt,l9=new de,HS=new Ft,Mm=new de,xv=new Fa,jS=new Ft,vv=new ph;class c9 extends Jn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=xS,this.bindMatrix=new Ft,this.bindMatrixInverse=new Ft,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ms),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let r=0;r<t.count;r++)this.getVertexPosition(r,Mm),this.boundingBox.expandByPoint(Mm)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Fa),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let r=0;r<t.count;r++)this.getVertexPosition(r,Mm),this.boundingSphere.expandByPoint(Mm)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const r=this.material,i=this.matrixWorld;r!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xv.copy(this.boundingSphere),xv.applyMatrix4(i),e.ray.intersectsSphere(xv)!==!1&&(jS.copy(i).invert(),vv.copy(e.ray).applyMatrix4(jS),!(this.boundingBox!==null&&vv.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,vv)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Kt,t=this.geometry.attributes.skinWeight;for(let r=0,i=t.count;r<i;r++){e.fromBufferAttribute(t,r);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(r,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===xS?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===oH?this.bindMatrixInverse.copy(this.bindMatrix).invert():Pt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const r=this.skeleton,i=this.geometry;GS.fromBufferAttribute(i.attributes.skinIndex,e),VS.fromBufferAttribute(i.attributes.skinWeight,e),$S.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=VS.getComponent(s);if(a!==0){const o=GS.getComponent(s);HS.multiplyMatrices(r.bones[o].matrixWorld,r.boneInverses[o]),t.addScaledVector(l9.copy($S).applyMatrix4(HS),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class aQ extends zn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class $p extends ar{constructor(e=null,t=1,r=1,i,s,a,o,l,c=mr,d=mr,h,p){super(null,a,o,l,c,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:t,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const WS=new Ft,u9=new Ft;class wI{constructor(e=[],t=[]){this.uuid=Ys(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Pt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,i=this.bones.length;r<i;r++)this.boneInverses.push(new Ft)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const r=new Ft;this.bones[e]&&r.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const r=this.bones[e];r&&r.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const r=this.bones[e];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){const e=this.bones,t=this.boneInverses,r=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:u9;WS.multiplyMatrices(o,t[s]),WS.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new wI(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const r=new $p(t,e,e,sr,js);return r.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=r,this}getBoneByName(e){for(let t=0,r=this.bones.length;t<r;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let r=0,i=e.bones.length;r<i;r++){const s=e.bones[r];let a=t[s];a===void 0&&(Pt("Skeleton: No bone found with UUID:",s),a=new aQ),this.bones.push(a),this.boneInverses.push(new Ft().fromArray(e.boneInverses[r]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,r=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=r[i];e.boneInverses.push(o.toArray())}return e}}class Gg extends or{constructor(e,t,r,i=1){super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const md=new Ft,qS=new Ft,Tm=[],YS=new ms,d9=new Ft,kf=new Jn,Nf=new Fa;class lw extends Jn{constructor(e,t,r){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Gg(new Float32Array(r*16),16),this.instanceColor=null,this.morphTexture=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<r;i++)this.setMatrixAt(i,d9)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ms),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,md),YS.copy(e.boundingBox).applyMatrix4(md),this.boundingBox.union(YS)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Fa),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,md),Nf.copy(e.boundingSphere).applyMatrix4(md),this.boundingSphere.union(Nf)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const r=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=r.length+1,a=e*s+1;for(let o=0;o<r.length;o++)r[o]=i[a+o]}raycast(e,t){const r=this.matrixWorld,i=this.count;if(kf.geometry=this.geometry,kf.material=this.material,kf.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nf.copy(this.boundingSphere),Nf.applyMatrix4(r),e.ray.intersectsSphere(Nf)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,md),qS.multiplyMatrices(r,md),kf.matrixWorld=qS,kf.raycast(e,Tm);for(let a=0,o=Tm.length;a<o;a++){const l=Tm[a];l.instanceId=s,l.object=this,t.push(l)}Tm.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Gg(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const r=t.morphTargetInfluences,i=r.length+1;this.morphTexture===null&&(this.morphTexture=new $p(new Float32Array(i*this.count),i,this.count,AI,js));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<r.length;c++)a+=r[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;s[l]=o,s.set(r,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const _v=new de,h9=new de,f9=new Jt;class Ml{constructor(e=new de(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,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const i=_v.subVectors(r,t).cross(h9.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 r=e.delta(_v),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<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 r=t||f9.getNormalMatrix(e),i=this.coplanarPoint(_v).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const vc=new Fa,p9=new Dt(.5,.5),Rm=new de;class EI{constructor(e=new Ml,t=new Ml,r=new Ml,i=new Ml,s=new Ml,a=new Ml){this.planes=[e,t,r,i,s,a]}set(e,t,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=Ca,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],d=s[4],h=s[5],p=s[6],A=s[7],y=s[8],m=s[9],x=s[10],g=s[11],_=s[12],b=s[13],w=s[14],I=s[15];if(i[0].setComponents(c-a,A-d,g-y,I-_).normalize(),i[1].setComponents(c+a,A+d,g+y,I+_).normalize(),i[2].setComponents(c+o,A+h,g+m,I+b).normalize(),i[3].setComponents(c-o,A-h,g-m,I-b).normalize(),r)i[4].setComponents(l,p,x,w).normalize(),i[5].setComponents(c-l,A-p,g-x,I-w).normalize();else if(i[4].setComponents(c-l,A-p,g-x,I-w).normalize(),t===Ca)i[5].setComponents(c+l,A+p,g+x,I+w).normalize();else if(t===Og)i[5].setComponents(l,p,x,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),vc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),vc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(vc)}intersectsSprite(e){vc.center.set(0,0,0);const t=p9.distanceTo(e.center);return vc.radius=.7071067811865476+t,vc.applyMatrix4(e.matrixWorld),this.intersectsSphere(vc)}intersectsSphere(e){const t=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let r=0;r<6;r++){const i=t[r];if(Rm.x=i.normal.x>0?e.max.x:e.min.x,Rm.y=i.normal.y>0?e.max.y:e.min.y,Rm.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Rm)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class oQ extends Xs{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xt(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 Vg=new de,Hg=new de,XS=new Ft,Qf=new ph,Dm=new Fa,bv=new de,JS=new de;class II extends zn{constructor(e=new _r,t=new oQ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,r=[0];for(let i=1,s=t.count;i<s;i++)Vg.fromBufferAttribute(t,i-1),Hg.fromBufferAttribute(t,i),r[i]=r[i-1],r[i]+=Vg.distanceTo(Hg);e.setAttribute("lineDistance",new Wn(r,1))}else Pt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Dm.copy(r.boundingSphere),Dm.applyMatrix4(i),Dm.radius+=s,e.ray.intersectsSphere(Dm)===!1)return;XS.copy(i).invert(),Qf.copy(e.ray).applyMatrix4(XS);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=r.index,p=r.attributes.position;if(d!==null){const A=Math.max(0,a.start),y=Math.min(d.count,a.start+a.count);for(let m=A,x=y-1;m<x;m+=c){const g=d.getX(m),_=d.getX(m+1),b=km(this,e,Qf,l,g,_,m);b&&t.push(b)}if(this.isLineLoop){const m=d.getX(y-1),x=d.getX(A),g=km(this,e,Qf,l,m,x,y-1);g&&t.push(g)}}else{const A=Math.max(0,a.start),y=Math.min(p.count,a.start+a.count);for(let m=A,x=y-1;m<x;m+=c){const g=km(this,e,Qf,l,m,m+1,m);g&&t.push(g)}if(this.isLineLoop){const m=km(this,e,Qf,l,y-1,A,y-1);m&&t.push(m)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function km(n,e,t,r,i,s,a){const o=n.geometry.attributes.position;if(Vg.fromBufferAttribute(o,i),Hg.fromBufferAttribute(o,s),t.distanceSqToSegment(Vg,Hg,bv,JS)>r)return;bv.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(bv);if(!(c<e.near||c>e.far))return{distance:c,point:JS.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const KS=new de,ZS=new de;class A9 extends II{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,r=[];for(let i=0,s=t.count;i<s;i+=2)KS.fromBufferAttribute(t,i),ZS.fromBufferAttribute(t,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+KS.distanceTo(ZS);e.setAttribute("lineDistance",new Wn(r,1))}else Pt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class m9 extends II{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class lQ extends Xs{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const e3=new Ft,cw=new ph,Nm=new Fa,Qm=new de;class g9 extends zn{constructor(e=new _r,t=new lQ){super(),this.isPoints=!0,this.type="Points",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}raycast(e,t){const r=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Nm.copy(r.boundingSphere),Nm.applyMatrix4(i),Nm.radius+=s,e.ray.intersectsSphere(Nm)===!1)return;e3.copy(i).invert(),cw.copy(e.ray).applyMatrix4(e3);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=r.index,h=r.attributes.position;if(c!==null){const p=Math.max(0,a.start),A=Math.min(c.count,a.start+a.count);for(let y=p,m=A;y<m;y++){const x=c.getX(y);Qm.fromBufferAttribute(h,x),t3(Qm,x,l,i,e,t,this)}}else{const p=Math.max(0,a.start),A=Math.min(h.count,a.start+a.count);for(let y=p,m=A;y<m;y++)Qm.fromBufferAttribute(h,y),t3(Qm,y,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function t3(n,e,t,r,i,s,a){const o=cw.distanceSqToPoint(n);if(o<t){const l=new de;cw.closestPointToPoint(n,l),l.applyMatrix4(r);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class y9 extends ar{constructor(e,t,r,i,s,a,o,l,c){super(e,t,r,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class cQ extends ar{constructor(e,t,r=Mi,i,s,a,o=mr,l=mr,c,d=Sp,h=1){if(d!==Sp&&d!==Bp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:h};super(p,i,s,a,o,l,d,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new vI(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class uQ extends ar{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class CI extends _r{constructor(e=1,t=1,r=4,i=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:r,radialSegments:i,heightSegments:s},t=Math.max(0,t),r=Math.max(1,Math.floor(r)),i=Math.max(3,Math.floor(i)),s=Math.max(1,Math.floor(s));const a=[],o=[],l=[],c=[],d=t/2,h=Math.PI/2*e,p=t,A=2*h+p,y=r*2+s,m=i+1,x=new de,g=new de;for(let _=0;_<=y;_++){let b=0,w=0,I=0,S=0;if(_<=r){const R=_/r,k=R*Math.PI/2;w=-d-e*Math.cos(k),I=e*Math.sin(k),S=-e*Math.cos(k),b=R*h}else if(_<=r+s){const R=(_-r)/s;w=-d+R*t,I=e,S=0,b=h+R*p}else{const R=(_-r-s)/r,k=R*Math.PI/2;w=d+e*Math.sin(k),I=e*Math.cos(k),S=e*Math.sin(k),b=h+p+R*h}const M=Math.max(0,Math.min(1,b/A));let T=0;_===0?T=.5/i:_===y&&(T=-.5/i);for(let R=0;R<=i;R++){const k=R/i,H=k*Math.PI*2,Q=Math.sin(H),V=Math.cos(H);g.x=-I*V,g.y=w,g.z=I*Q,o.push(g.x,g.y,g.z),x.set(-I*V,S,I*Q),x.normalize(),l.push(x.x,x.y,x.z),c.push(k+T,M)}if(_>0){const R=(_-1)*m;for(let k=0;k<i;k++){const H=R+k,Q=R+k+1,V=_*m+k,B=_*m+k+1;a.push(H,Q,V),a.push(Q,B,V)}}}this.setIndex(a),this.setAttribute("position",new Wn(o,3)),this.setAttribute("normal",new Wn(l,3)),this.setAttribute("uv",new Wn(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new CI(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class gh extends _r{constructor(e=1,t=1,r=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const d=[],h=[],p=[],A=[];let y=0;const m=[],x=r/2;let g=0;_(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(d),this.setAttribute("position",new Wn(h,3)),this.setAttribute("normal",new Wn(p,3)),this.setAttribute("uv",new Wn(A,2));function _(){const w=new de,I=new de;let S=0;const M=(t-e)/r;for(let T=0;T<=s;T++){const R=[],k=T/s,H=k*(t-e)+e;for(let Q=0;Q<=i;Q++){const V=Q/i,B=V*l+o,W=Math.sin(B),K=Math.cos(B);I.x=H*W,I.y=-k*r+x,I.z=H*K,h.push(I.x,I.y,I.z),w.set(W,M,K).normalize(),p.push(w.x,w.y,w.z),A.push(V,1-k),R.push(y++)}m.push(R)}for(let T=0;T<i;T++)for(let R=0;R<s;R++){const k=m[R][T],H=m[R+1][T],Q=m[R+1][T+1],V=m[R][T+1];(e>0||R!==0)&&(d.push(k,H,V),S+=3),(t>0||R!==s-1)&&(d.push(H,Q,V),S+=3)}c.addGroup(g,S,0),g+=S}function b(w){const I=y,S=new Dt,M=new de;let T=0;const R=w===!0?e:t,k=w===!0?1:-1;for(let Q=1;Q<=i;Q++)h.push(0,x*k,0),p.push(0,k,0),A.push(.5,.5),y++;const H=y;for(let Q=0;Q<=i;Q++){const B=Q/i*l+o,W=Math.cos(B),K=Math.sin(B);M.x=R*K,M.y=x*k,M.z=R*W,h.push(M.x,M.y,M.z),p.push(0,k,0),S.x=W*.5+.5,S.y=K*.5*k+.5,A.push(S.x,S.y),y++}for(let Q=0;Q<i;Q++){const V=I+Q,B=H+Q;w===!0?d.push(B,B+1,V):d.push(B+1,B,V),T+=3}c.addGroup(g,T,w===!0?1:2),g+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class SI extends gh{constructor(e=1,t=1,r=32,i=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,r,i,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new SI(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Xd extends _r{constructor(e=1,t=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(r),l=Math.floor(i),c=o+1,d=l+1,h=e/o,p=t/l,A=[],y=[],m=[],x=[];for(let g=0;g<d;g++){const _=g*p-a;for(let b=0;b<c;b++){const w=b*h-s;y.push(w,-_,0),m.push(0,0,1),x.push(b/o),x.push(1-g/l)}}for(let g=0;g<l;g++)for(let _=0;_<o;_++){const b=_+c*g,w=_+c*(g+1),I=_+1+c*(g+1),S=_+1+c*g;A.push(b,w,S),A.push(w,I,S)}this.setIndex(A),this.setAttribute("position",new Wn(y,3)),this.setAttribute("normal",new Wn(m,3)),this.setAttribute("uv",new Wn(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xd(e.width,e.height,e.widthSegments,e.heightSegments)}}class kp extends _r{constructor(e=1,t=32,r=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));const l=Math.min(a+o,Math.PI);let c=0;const d=[],h=new de,p=new de,A=[],y=[],m=[],x=[];for(let g=0;g<=r;g++){const _=[],b=g/r;let w=0;g===0&&a===0?w=.5/t:g===r&&l===Math.PI&&(w=-.5/t);for(let I=0;I<=t;I++){const S=I/t;h.x=-e*Math.cos(i+S*s)*Math.sin(a+b*o),h.y=e*Math.cos(a+b*o),h.z=e*Math.sin(i+S*s)*Math.sin(a+b*o),y.push(h.x,h.y,h.z),p.copy(h).normalize(),m.push(p.x,p.y,p.z),x.push(S+w,1-b),_.push(c++)}d.push(_)}for(let g=0;g<r;g++)for(let _=0;_<t;_++){const b=d[g][_+1],w=d[g][_],I=d[g+1][_],S=d[g+1][_+1];(g!==0||a>0)&&A.push(b,w,S),(g!==r-1||l<Math.PI)&&A.push(w,I,S)}this.setIndex(A),this.setAttribute("position",new Wn(y,3)),this.setAttribute("normal",new Wn(m,3)),this.setAttribute("uv",new Wn(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kp(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class BI extends ji{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Jd extends Xs{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new xt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yI,this.normalScale=new Dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Hi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ds extends Jd{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Dt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return nn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new xt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new xt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class x9 extends Xs{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xt(16777215),this.specular=new xt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yI,this.normalScale=new Dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Hi,this.combine=dI,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class v9 extends Xs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=dH,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 _9 extends Xs{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}}function Pm(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function b9(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function w9(n){function e(i,s){return n[i]-n[s]}const t=n.length,r=new Array(t);for(let i=0;i!==t;++i)r[i]=i;return r.sort(e),r}function n3(n,e,t){const r=n.length,i=new n.constructor(r);for(let s=0,a=0;a!==r;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=n[o+l]}return i}function dQ(n,e,t,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let a=s[r];if(a!==void 0)if(Array.isArray(a))do a=s[r],a!==void 0&&(e.push(s.time),t.push(...a)),s=n[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[r],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[i++];while(s!==void 0);else do a=s[r],a!==void 0&&(e.push(s.time),t.push(a)),s=n[i++];while(s!==void 0)}class Gp{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let r=this._cachedIndex,i=t[r],s=t[r-1];e:{t:{let a;n:{r:if(!(e<i)){for(let o=r+2;;){if(i===void 0){if(e<s)break r;return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===o)break;if(s=i,i=t[++r],e<i)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(r=2,s=o);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=t[--r-1],e>=s)break t}a=r,r=0;break n}break e}for(;r<a;){const o=r+a>>>1;e<t[o]?a=o:r=o+1}if(i=t[r],s=t[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=r[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class E9 extends Gp{constructor(e,t,r,i){super(e,t,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vS,endingEnd:vS}}intervalChanged_(e,t,r){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case _S:s=e,o=2*t-r;break;case bS:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=r}if(l===void 0)switch(this.getSettings_().endingEnd){case _S:a=e,l=2*r-t;break;case bS:a=1,l=r+i[1]-i[0];break;default:a=e-1,l=t}const c=(r-t)*.5,d=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-r),this._offsetPrev=s*d,this._offsetNext=a*d}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=this._offsetPrev,h=this._offsetNext,p=this._weightPrev,A=this._weightNext,y=(r-t)/(i-t),m=y*y,x=m*y,g=-p*x+2*p*m-p*y,_=(1+p)*x+(-1.5-2*p)*m+(-.5+p)*y+1,b=(-1-A)*x+(1.5+A)*m+.5*y,w=A*x-A*m;for(let I=0;I!==o;++I)s[I]=g*a[d+I]+_*a[c+I]+b*a[l+I]+w*a[h+I];return s}}class I9 extends Gp{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=(r-t)/(i-t),h=1-d;for(let p=0;p!==o;++p)s[p]=a[c+p]*h+a[l+p]*d;return s}}class C9 extends Gp{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ia{constructor(e,t,r,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Pm(t,this.TimeBufferType),this.values=Pm(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:Pm(e.times,Array),values:Pm(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(r.interpolation=i)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new C9(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new I9(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new E9(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Mp:t=this.InterpolantFactoryMethodDiscrete;break;case Tp:t=this.InterpolantFactoryMethodLinear;break;case Jx:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return Pt("KeyframeTrack:",r),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Mp;case this.InterpolantFactoryMethodLinear:return Tp;case this.InterpolantFactoryMethodSmooth:return Jx}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]*=e}return this}trim(e,t){const r=this.times,i=r.length;let s=0,a=i-1;for(;s!==i&&r[s]<e;)++s;for(;a!==-1&&r[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=r.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(sn("KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,i=this.values,s=r.length;s===0&&(sn("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=r[o];if(typeof l=="number"&&isNaN(l)){sn("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){sn("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&b9(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){sn("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),r=this.getValueSize(),i=this.getInterpolation()===Jx,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],d=e[o+1];if(c!==d&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*r,p=h-r,A=h+r;for(let y=0;y!==r;++y){const m=t[h+y];if(m!==t[p+y]||m!==t[A+y]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*r,p=a*r;for(let A=0;A!==r;++A)t[p+A]=t[h+A]}++a}}if(s>0){e[a]=e[s];for(let o=s*r,l=a*r,c=0;c!==r;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*r)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),r=this.constructor,i=new r(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ia.prototype.ValueTypeName="";ia.prototype.TimeBufferType=Float32Array;ia.prototype.ValueBufferType=Float32Array;ia.prototype.DefaultInterpolation=Tp;class yh extends ia{constructor(e,t,r){super(e,t,r)}}yh.prototype.ValueTypeName="bool";yh.prototype.ValueBufferType=Array;yh.prototype.DefaultInterpolation=Mp;yh.prototype.InterpolantFactoryMethodLinear=void 0;yh.prototype.InterpolantFactoryMethodSmooth=void 0;class hQ extends ia{constructor(e,t,r,i){super(e,t,r,i)}}hQ.prototype.ValueTypeName="color";class Kd extends ia{constructor(e,t,r,i){super(e,t,r,i)}}Kd.prototype.ValueTypeName="number";class S9 extends Gp{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(r-t)/(i-t);let c=e*o;for(let d=c+o;c!==d;c+=4)In.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Zd extends ia{constructor(e,t,r,i){super(e,t,r,i)}InterpolantFactoryMethodLinear(e){return new S9(this.times,this.values,this.getValueSize(),e)}}Zd.prototype.ValueTypeName="quaternion";Zd.prototype.InterpolantFactoryMethodSmooth=void 0;class xh extends ia{constructor(e,t,r){super(e,t,r)}}xh.prototype.ValueTypeName="string";xh.prototype.ValueBufferType=Array;xh.prototype.DefaultInterpolation=Mp;xh.prototype.InterpolantFactoryMethodLinear=void 0;xh.prototype.InterpolantFactoryMethodSmooth=void 0;class eh extends ia{constructor(e,t,r,i){super(e,t,r,i)}}eh.prototype.ValueTypeName="vector";class B9{constructor(e="",t=-1,r=[],i=cH){this.name=e,this.tracks=r,this.duration=t,this.blendMode=i,this.uuid=Ys(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,i=1/(e.fps||1);for(let a=0,o=r.length;a!==o;++a)t.push(T9(r[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],r=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=r.length;s!==a;++s)t.push(ia.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(e,t,r,i){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const d=w9(l);l=n3(l,1,d),c=n3(c,1,d),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Kd(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/r))}return new this(e,-1,a)}static findByName(e,t){let r=e;if(!Array.isArray(e)){const i=e;r=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<r.length;i++)if(r[i].name===t)return r[i];return null}static CreateClipsFromMorphTargetSequences(e,t,r){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],d=c.name.match(s);if(d&&d.length>1){const h=d[1];let p=i[h];p||(i[h]=p=[]),p.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,r));return a}static parseAnimation(e,t){if(Pt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return sn("AnimationClip: No animation in JSONLoader data."),null;const r=function(h,p,A,y,m){if(A.length!==0){const x=[],g=[];dQ(A,x,g,y),x.length!==0&&m.push(new h(p,x,g))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const p=c[h].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const A={};let y;for(y=0;y<p.length;y++)if(p[y].morphTargets)for(let m=0;m<p[y].morphTargets.length;m++)A[p[y].morphTargets[m]]=-1;for(const m in A){const x=[],g=[];for(let _=0;_!==p[y].morphTargets.length;++_){const b=p[y];x.push(b.time),g.push(b.morphTarget===m?1:0)}i.push(new Kd(".morphTargetInfluence["+m+"]",x,g))}l=A.length*a}else{const A=".bones["+t[h].name+"]";r(eh,A+".position",p,"pos",i),r(Zd,A+".quaternion",p,"rot",i),r(eh,A+".scale",p,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let r=0,i=e.length;r!==i;++r){const s=this.tracks[r];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let r=0;r<this.tracks.length;r++)e.push(this.tracks[r].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function M9(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Kd;case"vector":case"vector2":case"vector3":case"vector4":return eh;case"color":return hQ;case"quaternion":return Zd;case"bool":case"boolean":return yh;case"string":return xh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function T9(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=M9(n.type);if(n.times===void 0){const t=[],r=[];dQ(n.keys,t,r,"value"),n.times=t,n.values=r}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const po={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class R9{constructor(e,t,r){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this._abortController=null,this.itemStart=function(d){o++,s===!1&&i.onStart!==void 0&&i.onStart(d,a,o),s=!0},this.itemEnd=function(d){a++,i.onProgress!==void 0&&i.onProgress(d,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return l?l(d):d},this.setURLModifier=function(d){return l=d,this},this.addHandler=function(d,h){return c.push(d,h),this},this.removeHandler=function(d){const h=c.indexOf(d);return h!==-1&&c.splice(h,2),this},this.getHandler=function(d){for(let h=0,p=c.length;h<p;h+=2){const A=c[h],y=c[h+1];if(A.global&&(A.lastIndex=0),A.test(d))return y}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const D9=new R9;let lu=class{constructor(e){this.manager=e!==void 0?e:D9,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise(function(i,s){r.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};lu.DEFAULT_MATERIAL_NAME="__DEFAULT";const oo={};class k9 extends Error{constructor(e,t){super(e),this.response=t}}class MI extends lu{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=po.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(oo[e]!==void 0){oo[e].push({onLoad:t,onProgress:r,onError:i});return}oo[e]=[],oo[e].push({onLoad:t,onProgress:r,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Pt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const d=oo[e],h=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),A=p?parseInt(p):0,y=A!==0;let m=0;const x=new ReadableStream({start(g){_();function _(){h.read().then(({done:b,value:w})=>{if(b)g.close();else{m+=w.byteLength;const I=new ProgressEvent("progress",{lengthComputable:y,loaded:m,total:A});for(let S=0,M=d.length;S<M;S++){const T=d[S];T.onProgress&&T.onProgress(I)}g.enqueue(w),_()}},b=>{g.error(b)})}}});return new Response(x)}else throw new k9(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(d=>new DOMParser().parseFromString(d,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),p=h&&h[1]?h[1].toLowerCase():void 0,A=new TextDecoder(p);return c.arrayBuffer().then(y=>A.decode(y))}}}).then(c=>{po.add(`file:${e}`,c);const d=oo[e];delete oo[e];for(let h=0,p=d.length;h<p;h++){const A=d[h];A.onLoad&&A.onLoad(c)}}).catch(c=>{const d=oo[e];if(d===void 0)throw this.manager.itemError(e),c;delete oo[e];for(let h=0,p=d.length;h<p;h++){const A=d[h];A.onError&&A.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const gd=new WeakMap;class N9 extends lu{constructor(e){super(e)}load(e,t,r,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=po.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);else{let h=gd.get(a);h===void 0&&(h=[],gd.set(a,h)),h.push({onLoad:t,onError:i})}return a}const o=Rp("img");function l(){d(),t&&t(this);const h=gd.get(this)||[];for(let p=0;p<h.length;p++){const A=h[p];A.onLoad&&A.onLoad(this)}gd.delete(this),s.manager.itemEnd(e)}function c(h){d(),i&&i(h),po.remove(`image:${e}`);const p=gd.get(this)||[];for(let A=0;A<p.length;A++){const y=p[A];y.onError&&y.onError(h)}gd.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),po.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class Q9 extends lu{constructor(e){super(e)}load(e,t,r,i){const s=new ar,a=new N9(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},r,i),s}}class O0 extends zn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xt(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const wv=new Ft,r3=new de,i3=new de;class TI{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Dt(512,512),this.mapType=ni,this.map=null,this.mapPass=null,this.matrix=new Ft,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new EI,this._frameExtents=new Dt(1,1),this._viewportCount=1,this._viewports=[new Kt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;r3.setFromMatrixPosition(e.matrixWorld),t.position.copy(r3),i3.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(i3),t.updateMatrixWorld(),wv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(wv,t.coordinateSystem,t.reversedDepth),t.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(wv)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class P9 extends TI{constructor(){super(new Fr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,r=qd*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class fQ extends O0{constructor(e,t,r=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(zn.DEFAULT_UP),this.updateMatrix(),this.target=new zn,this.distance=r,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new P9}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const s3=new Ft,Pf=new de,Ev=new de;class L9 extends TI{constructor(){super(new Fr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Dt(4,2),this._viewportCount=6,this._viewports=[new Kt(2,1,1,1),new Kt(0,1,1,1),new Kt(3,1,1,1),new Kt(1,1,1,1),new Kt(3,0,1,1),new Kt(1,0,1,1)],this._cubeDirections=[new de(1,0,0),new de(-1,0,0),new de(0,0,1),new de(0,0,-1),new de(0,1,0),new de(0,-1,0)],this._cubeUps=[new de(0,1,0),new de(0,1,0),new de(0,1,0),new de(0,1,0),new de(0,0,1),new de(0,0,-1)]}updateMatrices(e,t=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Pf.setFromMatrixPosition(e.matrixWorld),r.position.copy(Pf),Ev.copy(r.position),Ev.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Ev),r.updateMatrixWorld(),i.makeTranslation(-Pf.x,-Pf.y,-Pf.z),s3.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(s3,r.coordinateSystem,r.reversedDepth)}}class pQ extends O0{constructor(e,t,r=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new L9}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class $0 extends rQ{constructor(e=-1,t=1,r=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=s,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=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,a=r+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class F9 extends TI{constructor(){super(new $0(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class uw extends O0{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(zn.DEFAULT_UP),this.updateMatrix(),this.target=new zn,this.shadow=new F9}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class z9 extends O0{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ap{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class U9 extends _r{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}const Iv=new WeakMap;class O9 extends lu{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Pt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Pt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=po.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{if(Iv.has(a)===!0)i&&i(Iv.get(a)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(c),s.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return po.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){i&&i(c),Iv.set(l,c),po.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});po.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class $9 extends Fr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class AQ{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const RI="\\[\\]\\.:\\/",G9=new RegExp("["+RI+"]","g"),DI="[^"+RI+"]",V9="[^"+RI.replace("\\.","")+"]",H9=/((?:WC+[\/:])*)/.source.replace("WC",DI),j9=/(WCOD+)?/.source.replace("WCOD",V9),W9=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",DI),q9=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",DI),Y9=new RegExp("^"+H9+j9+W9+q9+"$"),X9=["material","materials","bones","map"];class J9{constructor(e,t,r){const i=r||Bn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}class Bn{constructor(e,t,r){this.path=t,this.parsedPath=r||Bn.parseTrackName(t),this.node=Bn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new Bn.Composite(e,t,r):new Bn(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(G9,"")}static parseTrackName(e){const t=Y9.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=r.nodeName.substring(i+1);X9.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){const r=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=r(o.children);if(l)return l}return null},i=r(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)e[t++]=r[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,r=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=Bn.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Pt("PropertyBinding: No target node found for track: "+this.path+".");return}if(r){let c=t.objectIndex;switch(r){case"materials":if(!e.material){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){sn("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){sn("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===c){c=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){sn("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[r]===void 0){sn("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[r]}if(c!==void 0){if(e[c]===void 0){sn("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;sn("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){sn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){sn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Bn.Composite=J9;Bn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Bn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Bn.prototype.GetterByBindingType=[Bn.prototype._getValue_direct,Bn.prototype._getValue_array,Bn.prototype._getValue_arrayElement,Bn.prototype._getValue_toArray];Bn.prototype.SetterByBindingTypeAndVersioning=[[Bn.prototype._setValue_direct,Bn.prototype._setValue_direct_setNeedsUpdate,Bn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Bn.prototype._setValue_array,Bn.prototype._setValue_array_setNeedsUpdate,Bn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Bn.prototype._setValue_arrayElement,Bn.prototype._setValue_arrayElement_setNeedsUpdate,Bn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Bn.prototype._setValue_fromArray,Bn.prototype._setValue_fromArray_setNeedsUpdate,Bn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const a3=new Ft;class K9{constructor(e,t,r=0,i=1/0){this.ray=new ph(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new _I,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):sn("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return a3.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(a3),this}intersectObject(e,t=!0,r=[]){return dw(e,this,r,t),r.sort(o3),r}intersectObjects(e,t=!0,r=[]){for(let i=0,s=e.length;i<s;i++)dw(e[i],this,r,t);return r.sort(o3),r}}function o3(n,e){return n.distance-e.distance}function dw(n,e,t,r){let i=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(i=!1),i===!0&&r===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)dw(s[a],e,t,!0)}}class l3{constructor(e=1,t=0,r=0){this.radius=e,this.phi=t,this.theta=r}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=nn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(nn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class G0{constructor(e,t,r,i){G0.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let r=0;r<4;r++)this.elements[r]=e[r+t];return this}set(e,t,r,i){const s=this.elements;return s[0]=e,s[2]=t,s[1]=r,s[3]=i,this}}class Z9 extends ou{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Pt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function c3(n,e,t,r){const i=ej(r);switch(t){case HN:return n*e;case AI:return n*e/i.components*i.byteLength;case mI:return n*e/i.components*i.byteLength;case gI:return n*e*2/i.components*i.byteLength;case U0:return n*e*2/i.components*i.byteLength;case jN:return n*e*3/i.components*i.byteLength;case sr:return n*e*4/i.components*i.byteLength;case vo:return n*e*4/i.components*i.byteLength;case gg:case yg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case xg:case vg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Db:case Nb:return Math.max(n,16)*Math.max(e,8)/4;case Rb:case kb:return Math.max(n,8)*Math.max(e,8)/2;case Qb:case Pb:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Lb:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fb:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case zb:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ub:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Ob:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case $b:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Gb:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Vb:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Hb:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case jb:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Wb:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case qb:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Yb:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Xb:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Jb:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Kb:case Zb:case ew:return Math.ceil(n/4)*Math.ceil(e/4)*16;case tw:case nw:return Math.ceil(n/4)*Math.ceil(e/4)*8;case rw:case iw:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ej(n){switch(n){case ni:case ON:return{byteLength:1,components:1};case Ip:case $N:case fh:return{byteLength:2,components:1};case fI:case pI:return{byteLength:2,components:4};case Mi:case hI:case js:return{byteLength:4,components:1};case GN:case VN:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:uI}}));typeof window<"u"&&(window.__THREE__?Pt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=uI);function mQ(){let n=null,e=!1,t=null,r=null;function i(s,a){t(s,a),r=n.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(r=n.requestAnimationFrame(i),e=!0)},stop:function(){n.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function tj(n){const e=new WeakMap;function t(o,l){const c=o.array,d=o.usage,h=c.byteLength,p=n.createBuffer();n.bindBuffer(l,p),n.bufferData(l,c,d),o.onUploadCallback();let A;if(c instanceof Float32Array)A=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)A=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?A=n.HALF_FLOAT:A=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)A=n.SHORT;else if(c instanceof Uint32Array)A=n.UNSIGNED_INT;else if(c instanceof Int32Array)A=n.INT;else if(c instanceof Int8Array)A=n.BYTE;else if(c instanceof Uint8Array)A=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)A=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:A,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function r(o,l,c){const d=l.array,h=l.updateRanges;if(n.bindBuffer(c,o),h.length===0)n.bufferSubData(c,0,d);else{h.sort((A,y)=>A.start-y.start);let p=0;for(let A=1;A<h.length;A++){const y=h[p],m=h[A];m.start<=y.start+y.count+1?y.count=Math.max(y.count,m.start+m.count-y.start):(++p,h[p]=m)}h.length=p+1;for(let A=0,y=h.length;A<y;A++){const m=h[A];n.bufferSubData(c,m.start*d.BYTES_PER_ELEMENT,d,m.start,m.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.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.");r(c.buffer,o,l),c.version=o.version}}return{get:i,remove:s,update:a}}var nj=`#ifdef USE_ALPHAHASH
|
|
95
|
+
`},i=new Ah(5,5,5),s=new ji({name:"CubemapFromEquirect",uniforms:Yd(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Bi,blending:xo});s.uniforms.tEquirect.value=t;const a=new Jn(i,s),o=t.minFilter;return t.minFilter===Ia&&(t.minFilter=ir),new iQ(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,r,i);e.setRenderTarget(s)}}class ls extends zn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const s9={type:"move"};class yv{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ls,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ls,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new de,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new de),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ls,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new de,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new de),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,r){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const m of e.hand.values()){const x=t.getJointPose(m,r),g=this._getHandJoint(c,m);x!==null&&(g.matrix.fromArray(x.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=x.radius),g.visible=x!==null}const d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],p=d.position.distanceTo(h.position),A=.02,y=.005;c.inputState.pinching&&p>A+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=A-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(s9)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const r=new ls;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class a9 extends zn{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 Hi,this.environmentIntensity=1,this.environmentRotation=new Hi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class o9{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=aw,this.updateRanges=[],this.version=0,this.uuid=Ys()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[r+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ys()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ys()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const li=new de;class bI{constructor(e,t,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,r=this.data.count;t<r;t++)li.fromBufferAttribute(this,t),li.applyMatrix4(e),this.setXYZ(t,li.x,li.y,li.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)li.fromBufferAttribute(this,t),li.applyNormalMatrix(e),this.setXYZ(t,li.x,li.y,li.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)li.fromBufferAttribute(this,t),li.transformDirection(e),this.setXYZ(t,li.x,li.y,li.z);return this}getComponent(e,t){let r=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(r=$s(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=Sn(r,this.array)),this.data.array[e*this.data.stride+this.offset+t]=r,this}setX(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Sn(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=$s(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=$s(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=$s(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=$s(t,this.array)),t}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Sn(t,this.array),r=Sn(r,this.array),i=Sn(i,this.array),s=Sn(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){$g("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new or(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new bI(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){$g("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const $S=new de,GS=new Kt,VS=new Kt,l9=new de,HS=new Ft,Mm=new de,xv=new Fa,jS=new Ft,vv=new ph;class c9 extends Jn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=xS,this.bindMatrix=new Ft,this.bindMatrixInverse=new Ft,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ms),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let r=0;r<t.count;r++)this.getVertexPosition(r,Mm),this.boundingBox.expandByPoint(Mm)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Fa),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let r=0;r<t.count;r++)this.getVertexPosition(r,Mm),this.boundingSphere.expandByPoint(Mm)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const r=this.material,i=this.matrixWorld;r!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xv.copy(this.boundingSphere),xv.applyMatrix4(i),e.ray.intersectsSphere(xv)!==!1&&(jS.copy(i).invert(),vv.copy(e.ray).applyMatrix4(jS),!(this.boundingBox!==null&&vv.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,vv)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Kt,t=this.geometry.attributes.skinWeight;for(let r=0,i=t.count;r<i;r++){e.fromBufferAttribute(t,r);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(r,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===xS?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===oH?this.bindMatrixInverse.copy(this.bindMatrix).invert():Pt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const r=this.skeleton,i=this.geometry;GS.fromBufferAttribute(i.attributes.skinIndex,e),VS.fromBufferAttribute(i.attributes.skinWeight,e),$S.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=VS.getComponent(s);if(a!==0){const o=GS.getComponent(s);HS.multiplyMatrices(r.bones[o].matrixWorld,r.boneInverses[o]),t.addScaledVector(l9.copy($S).applyMatrix4(HS),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class aQ extends zn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class $p extends ar{constructor(e=null,t=1,r=1,i,s,a,o,l,c=mr,d=mr,h,p){super(null,a,o,l,c,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:t,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const WS=new Ft,u9=new Ft;class wI{constructor(e=[],t=[]){this.uuid=Ys(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Pt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,i=this.bones.length;r<i;r++)this.boneInverses.push(new Ft)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const r=new Ft;this.bones[e]&&r.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const r=this.bones[e];r&&r.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const r=this.bones[e];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){const e=this.bones,t=this.boneInverses,r=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:u9;WS.multiplyMatrices(o,t[s]),WS.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new wI(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const r=new $p(t,e,e,sr,js);return r.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=r,this}getBoneByName(e){for(let t=0,r=this.bones.length;t<r;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let r=0,i=e.bones.length;r<i;r++){const s=e.bones[r];let a=t[s];a===void 0&&(Pt("Skeleton: No bone found with UUID:",s),a=new aQ),this.bones.push(a),this.boneInverses.push(new Ft().fromArray(e.boneInverses[r]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,r=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=r[i];e.boneInverses.push(o.toArray())}return e}}class Gg extends or{constructor(e,t,r,i=1){super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const md=new Ft,qS=new Ft,Tm=[],YS=new ms,d9=new Ft,kf=new Jn,Nf=new Fa;class lw extends Jn{constructor(e,t,r){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Gg(new Float32Array(r*16),16),this.instanceColor=null,this.morphTexture=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<r;i++)this.setMatrixAt(i,d9)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ms),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,md),YS.copy(e.boundingBox).applyMatrix4(md),this.boundingBox.union(YS)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Fa),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,md),Nf.copy(e.boundingSphere).applyMatrix4(md),this.boundingSphere.union(Nf)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const r=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=r.length+1,a=e*s+1;for(let o=0;o<r.length;o++)r[o]=i[a+o]}raycast(e,t){const r=this.matrixWorld,i=this.count;if(kf.geometry=this.geometry,kf.material=this.material,kf.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nf.copy(this.boundingSphere),Nf.applyMatrix4(r),e.ray.intersectsSphere(Nf)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,md),qS.multiplyMatrices(r,md),kf.matrixWorld=qS,kf.raycast(e,Tm);for(let a=0,o=Tm.length;a<o;a++){const l=Tm[a];l.instanceId=s,l.object=this,t.push(l)}Tm.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Gg(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const r=t.morphTargetInfluences,i=r.length+1;this.morphTexture===null&&(this.morphTexture=new $p(new Float32Array(i*this.count),i,this.count,AI,js));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<r.length;c++)a+=r[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*e;s[l]=o,s.set(r,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const _v=new de,h9=new de,f9=new Jt;class Ml{constructor(e=new de(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,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const i=_v.subVectors(r,t).cross(h9.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 r=e.delta(_v),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<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 r=t||f9.getNormalMatrix(e),i=this.coplanarPoint(_v).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const vc=new Fa,p9=new Dt(.5,.5),Rm=new de;class EI{constructor(e=new Ml,t=new Ml,r=new Ml,i=new Ml,s=new Ml,a=new Ml){this.planes=[e,t,r,i,s,a]}set(e,t,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=Ca,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],d=s[4],h=s[5],p=s[6],A=s[7],y=s[8],m=s[9],x=s[10],g=s[11],_=s[12],b=s[13],w=s[14],I=s[15];if(i[0].setComponents(c-a,A-d,g-y,I-_).normalize(),i[1].setComponents(c+a,A+d,g+y,I+_).normalize(),i[2].setComponents(c+o,A+h,g+m,I+b).normalize(),i[3].setComponents(c-o,A-h,g-m,I-b).normalize(),r)i[4].setComponents(l,p,x,w).normalize(),i[5].setComponents(c-l,A-p,g-x,I-w).normalize();else if(i[4].setComponents(c-l,A-p,g-x,I-w).normalize(),t===Ca)i[5].setComponents(c+l,A+p,g+x,I+w).normalize();else if(t===Og)i[5].setComponents(l,p,x,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),vc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),vc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(vc)}intersectsSprite(e){vc.center.set(0,0,0);const t=p9.distanceTo(e.center);return vc.radius=.7071067811865476+t,vc.applyMatrix4(e.matrixWorld),this.intersectsSphere(vc)}intersectsSphere(e){const t=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let r=0;r<6;r++){const i=t[r];if(Rm.x=i.normal.x>0?e.max.x:e.min.x,Rm.y=i.normal.y>0?e.max.y:e.min.y,Rm.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Rm)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class oQ extends Xs{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xt(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 Vg=new de,Hg=new de,XS=new Ft,Qf=new ph,Dm=new Fa,bv=new de,JS=new de;class II extends zn{constructor(e=new _r,t=new oQ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,r=[0];for(let i=1,s=t.count;i<s;i++)Vg.fromBufferAttribute(t,i-1),Hg.fromBufferAttribute(t,i),r[i]=r[i-1],r[i]+=Vg.distanceTo(Hg);e.setAttribute("lineDistance",new Wn(r,1))}else Pt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Dm.copy(r.boundingSphere),Dm.applyMatrix4(i),Dm.radius+=s,e.ray.intersectsSphere(Dm)===!1)return;XS.copy(i).invert(),Qf.copy(e.ray).applyMatrix4(XS);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=r.index,p=r.attributes.position;if(d!==null){const A=Math.max(0,a.start),y=Math.min(d.count,a.start+a.count);for(let m=A,x=y-1;m<x;m+=c){const g=d.getX(m),_=d.getX(m+1),b=km(this,e,Qf,l,g,_,m);b&&t.push(b)}if(this.isLineLoop){const m=d.getX(y-1),x=d.getX(A),g=km(this,e,Qf,l,m,x,y-1);g&&t.push(g)}}else{const A=Math.max(0,a.start),y=Math.min(p.count,a.start+a.count);for(let m=A,x=y-1;m<x;m+=c){const g=km(this,e,Qf,l,m,m+1,m);g&&t.push(g)}if(this.isLineLoop){const m=km(this,e,Qf,l,y-1,A,y-1);m&&t.push(m)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function km(n,e,t,r,i,s,a){const o=n.geometry.attributes.position;if(Vg.fromBufferAttribute(o,i),Hg.fromBufferAttribute(o,s),t.distanceSqToSegment(Vg,Hg,bv,JS)>r)return;bv.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(bv);if(!(c<e.near||c>e.far))return{distance:c,point:JS.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const KS=new de,ZS=new de;class A9 extends II{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,r=[];for(let i=0,s=t.count;i<s;i+=2)KS.fromBufferAttribute(t,i),ZS.fromBufferAttribute(t,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+KS.distanceTo(ZS);e.setAttribute("lineDistance",new Wn(r,1))}else Pt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class m9 extends II{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class lQ extends Xs{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const e3=new Ft,cw=new ph,Nm=new Fa,Qm=new de;class g9 extends zn{constructor(e=new _r,t=new lQ){super(),this.isPoints=!0,this.type="Points",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}raycast(e,t){const r=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Nm.copy(r.boundingSphere),Nm.applyMatrix4(i),Nm.radius+=s,e.ray.intersectsSphere(Nm)===!1)return;e3.copy(i).invert(),cw.copy(e.ray).applyMatrix4(e3);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=r.index,h=r.attributes.position;if(c!==null){const p=Math.max(0,a.start),A=Math.min(c.count,a.start+a.count);for(let y=p,m=A;y<m;y++){const x=c.getX(y);Qm.fromBufferAttribute(h,x),t3(Qm,x,l,i,e,t,this)}}else{const p=Math.max(0,a.start),A=Math.min(h.count,a.start+a.count);for(let y=p,m=A;y<m;y++)Qm.fromBufferAttribute(h,y),t3(Qm,y,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function t3(n,e,t,r,i,s,a){const o=cw.distanceSqToPoint(n);if(o<t){const l=new de;cw.closestPointToPoint(n,l),l.applyMatrix4(r);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class y9 extends ar{constructor(e,t,r,i,s,a,o,l,c){super(e,t,r,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class cQ extends ar{constructor(e,t,r=Mi,i,s,a,o=mr,l=mr,c,d=Sp,h=1){if(d!==Sp&&d!==Bp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:h};super(p,i,s,a,o,l,d,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new vI(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class uQ extends ar{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class CI extends _r{constructor(e=1,t=1,r=4,i=8,s=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:r,radialSegments:i,heightSegments:s},t=Math.max(0,t),r=Math.max(1,Math.floor(r)),i=Math.max(3,Math.floor(i)),s=Math.max(1,Math.floor(s));const a=[],o=[],l=[],c=[],d=t/2,h=Math.PI/2*e,p=t,A=2*h+p,y=r*2+s,m=i+1,x=new de,g=new de;for(let _=0;_<=y;_++){let b=0,w=0,I=0,S=0;if(_<=r){const R=_/r,k=R*Math.PI/2;w=-d-e*Math.cos(k),I=e*Math.sin(k),S=-e*Math.cos(k),b=R*h}else if(_<=r+s){const R=(_-r)/s;w=-d+R*t,I=e,S=0,b=h+R*p}else{const R=(_-r-s)/r,k=R*Math.PI/2;w=d+e*Math.sin(k),I=e*Math.cos(k),S=e*Math.sin(k),b=h+p+R*h}const M=Math.max(0,Math.min(1,b/A));let T=0;_===0?T=.5/i:_===y&&(T=-.5/i);for(let R=0;R<=i;R++){const k=R/i,H=k*Math.PI*2,Q=Math.sin(H),V=Math.cos(H);g.x=-I*V,g.y=w,g.z=I*Q,o.push(g.x,g.y,g.z),x.set(-I*V,S,I*Q),x.normalize(),l.push(x.x,x.y,x.z),c.push(k+T,M)}if(_>0){const R=(_-1)*m;for(let k=0;k<i;k++){const H=R+k,Q=R+k+1,V=_*m+k,B=_*m+k+1;a.push(H,Q,V),a.push(Q,B,V)}}}this.setIndex(a),this.setAttribute("position",new Wn(o,3)),this.setAttribute("normal",new Wn(l,3)),this.setAttribute("uv",new Wn(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new CI(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class gh extends _r{constructor(e=1,t=1,r=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const d=[],h=[],p=[],A=[];let y=0;const m=[],x=r/2;let g=0;_(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(d),this.setAttribute("position",new Wn(h,3)),this.setAttribute("normal",new Wn(p,3)),this.setAttribute("uv",new Wn(A,2));function _(){const w=new de,I=new de;let S=0;const M=(t-e)/r;for(let T=0;T<=s;T++){const R=[],k=T/s,H=k*(t-e)+e;for(let Q=0;Q<=i;Q++){const V=Q/i,B=V*l+o,W=Math.sin(B),K=Math.cos(B);I.x=H*W,I.y=-k*r+x,I.z=H*K,h.push(I.x,I.y,I.z),w.set(W,M,K).normalize(),p.push(w.x,w.y,w.z),A.push(V,1-k),R.push(y++)}m.push(R)}for(let T=0;T<i;T++)for(let R=0;R<s;R++){const k=m[R][T],H=m[R+1][T],Q=m[R+1][T+1],V=m[R][T+1];(e>0||R!==0)&&(d.push(k,H,V),S+=3),(t>0||R!==s-1)&&(d.push(H,Q,V),S+=3)}c.addGroup(g,S,0),g+=S}function b(w){const I=y,S=new Dt,M=new de;let T=0;const R=w===!0?e:t,k=w===!0?1:-1;for(let Q=1;Q<=i;Q++)h.push(0,x*k,0),p.push(0,k,0),A.push(.5,.5),y++;const H=y;for(let Q=0;Q<=i;Q++){const B=Q/i*l+o,W=Math.cos(B),K=Math.sin(B);M.x=R*K,M.y=x*k,M.z=R*W,h.push(M.x,M.y,M.z),p.push(0,k,0),S.x=W*.5+.5,S.y=K*.5*k+.5,A.push(S.x,S.y),y++}for(let Q=0;Q<i;Q++){const V=I+Q,B=H+Q;w===!0?d.push(B,B+1,V):d.push(B+1,B,V),T+=3}c.addGroup(g,T,w===!0?1:2),g+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class SI extends gh{constructor(e=1,t=1,r=32,i=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,r,i,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new SI(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Xd extends _r{constructor(e=1,t=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(r),l=Math.floor(i),c=o+1,d=l+1,h=e/o,p=t/l,A=[],y=[],m=[],x=[];for(let g=0;g<d;g++){const _=g*p-a;for(let b=0;b<c;b++){const w=b*h-s;y.push(w,-_,0),m.push(0,0,1),x.push(b/o),x.push(1-g/l)}}for(let g=0;g<l;g++)for(let _=0;_<o;_++){const b=_+c*g,w=_+c*(g+1),I=_+1+c*(g+1),S=_+1+c*g;A.push(b,w,S),A.push(w,I,S)}this.setIndex(A),this.setAttribute("position",new Wn(y,3)),this.setAttribute("normal",new Wn(m,3)),this.setAttribute("uv",new Wn(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xd(e.width,e.height,e.widthSegments,e.heightSegments)}}class kp extends _r{constructor(e=1,t=32,r=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));const l=Math.min(a+o,Math.PI);let c=0;const d=[],h=new de,p=new de,A=[],y=[],m=[],x=[];for(let g=0;g<=r;g++){const _=[],b=g/r;let w=0;g===0&&a===0?w=.5/t:g===r&&l===Math.PI&&(w=-.5/t);for(let I=0;I<=t;I++){const S=I/t;h.x=-e*Math.cos(i+S*s)*Math.sin(a+b*o),h.y=e*Math.cos(a+b*o),h.z=e*Math.sin(i+S*s)*Math.sin(a+b*o),y.push(h.x,h.y,h.z),p.copy(h).normalize(),m.push(p.x,p.y,p.z),x.push(S+w,1-b),_.push(c++)}d.push(_)}for(let g=0;g<r;g++)for(let _=0;_<t;_++){const b=d[g][_+1],w=d[g][_],I=d[g+1][_],S=d[g+1][_+1];(g!==0||a>0)&&A.push(b,w,S),(g!==r-1||l<Math.PI)&&A.push(w,I,S)}this.setIndex(A),this.setAttribute("position",new Wn(y,3)),this.setAttribute("normal",new Wn(m,3)),this.setAttribute("uv",new Wn(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kp(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class BI extends ji{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Jd extends Xs{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new xt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yI,this.normalScale=new Dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Hi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ds extends Jd{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Dt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return nn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new xt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new xt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class x9 extends Xs{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xt(16777215),this.specular=new xt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yI,this.normalScale=new Dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Hi,this.combine=dI,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class v9 extends Xs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=dH,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 _9 extends Xs{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}}function Pm(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function b9(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function w9(n){function e(i,s){return n[i]-n[s]}const t=n.length,r=new Array(t);for(let i=0;i!==t;++i)r[i]=i;return r.sort(e),r}function n3(n,e,t){const r=n.length,i=new n.constructor(r);for(let s=0,a=0;a!==r;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=n[o+l]}return i}function dQ(n,e,t,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let a=s[r];if(a!==void 0)if(Array.isArray(a))do a=s[r],a!==void 0&&(e.push(s.time),t.push(...a)),s=n[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[r],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[i++];while(s!==void 0);else do a=s[r],a!==void 0&&(e.push(s.time),t.push(a)),s=n[i++];while(s!==void 0)}class Gp{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let r=this._cachedIndex,i=t[r],s=t[r-1];e:{t:{let a;n:{r:if(!(e<i)){for(let o=r+2;;){if(i===void 0){if(e<s)break r;return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===o)break;if(s=i,i=t[++r],e<i)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(r=2,s=o);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=t[--r-1],e>=s)break t}a=r,r=0;break n}break e}for(;r<a;){const o=r+a>>>1;e<t[o]?a=o:r=o+1}if(i=t[r],s=t[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=r[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class E9 extends Gp{constructor(e,t,r,i){super(e,t,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vS,endingEnd:vS}}intervalChanged_(e,t,r){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case _S:s=e,o=2*t-r;break;case bS:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=r}if(l===void 0)switch(this.getSettings_().endingEnd){case _S:a=e,l=2*r-t;break;case bS:a=1,l=r+i[1]-i[0];break;default:a=e-1,l=t}const c=(r-t)*.5,d=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-r),this._offsetPrev=s*d,this._offsetNext=a*d}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=this._offsetPrev,h=this._offsetNext,p=this._weightPrev,A=this._weightNext,y=(r-t)/(i-t),m=y*y,x=m*y,g=-p*x+2*p*m-p*y,_=(1+p)*x+(-1.5-2*p)*m+(-.5+p)*y+1,b=(-1-A)*x+(1.5+A)*m+.5*y,w=A*x-A*m;for(let I=0;I!==o;++I)s[I]=g*a[d+I]+_*a[c+I]+b*a[l+I]+w*a[h+I];return s}}class I9 extends Gp{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,d=(r-t)/(i-t),h=1-d;for(let p=0;p!==o;++p)s[p]=a[c+p]*h+a[l+p]*d;return s}}class C9 extends Gp{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ia{constructor(e,t,r,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Pm(t,this.TimeBufferType),this.values=Pm(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:Pm(e.times,Array),values:Pm(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(r.interpolation=i)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new C9(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new I9(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new E9(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Mp:t=this.InterpolantFactoryMethodDiscrete;break;case Tp:t=this.InterpolantFactoryMethodLinear;break;case Jx:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return Pt("KeyframeTrack:",r),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Mp;case this.InterpolantFactoryMethodLinear:return Tp;case this.InterpolantFactoryMethodSmooth:return Jx}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let r=0,i=t.length;r!==i;++r)t[r]*=e}return this}trim(e,t){const r=this.times,i=r.length;let s=0,a=i-1;for(;s!==i&&r[s]<e;)++s;for(;a!==-1&&r[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=r.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(sn("KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,i=this.values,s=r.length;s===0&&(sn("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=r[o];if(typeof l=="number"&&isNaN(l)){sn("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){sn("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&b9(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){sn("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),r=this.getValueSize(),i=this.getInterpolation()===Jx,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],d=e[o+1];if(c!==d&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*r,p=h-r,A=h+r;for(let y=0;y!==r;++y){const m=t[h+y];if(m!==t[p+y]||m!==t[A+y]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*r,p=a*r;for(let A=0;A!==r;++A)t[p+A]=t[h+A]}++a}}if(s>0){e[a]=e[s];for(let o=s*r,l=a*r,c=0;c!==r;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*r)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),r=this.constructor,i=new r(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ia.prototype.ValueTypeName="";ia.prototype.TimeBufferType=Float32Array;ia.prototype.ValueBufferType=Float32Array;ia.prototype.DefaultInterpolation=Tp;class yh extends ia{constructor(e,t,r){super(e,t,r)}}yh.prototype.ValueTypeName="bool";yh.prototype.ValueBufferType=Array;yh.prototype.DefaultInterpolation=Mp;yh.prototype.InterpolantFactoryMethodLinear=void 0;yh.prototype.InterpolantFactoryMethodSmooth=void 0;class hQ extends ia{constructor(e,t,r,i){super(e,t,r,i)}}hQ.prototype.ValueTypeName="color";class Kd extends ia{constructor(e,t,r,i){super(e,t,r,i)}}Kd.prototype.ValueTypeName="number";class S9 extends Gp{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(r-t)/(i-t);let c=e*o;for(let d=c+o;c!==d;c+=4)In.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Zd extends ia{constructor(e,t,r,i){super(e,t,r,i)}InterpolantFactoryMethodLinear(e){return new S9(this.times,this.values,this.getValueSize(),e)}}Zd.prototype.ValueTypeName="quaternion";Zd.prototype.InterpolantFactoryMethodSmooth=void 0;class xh extends ia{constructor(e,t,r){super(e,t,r)}}xh.prototype.ValueTypeName="string";xh.prototype.ValueBufferType=Array;xh.prototype.DefaultInterpolation=Mp;xh.prototype.InterpolantFactoryMethodLinear=void 0;xh.prototype.InterpolantFactoryMethodSmooth=void 0;class eh extends ia{constructor(e,t,r,i){super(e,t,r,i)}}eh.prototype.ValueTypeName="vector";class B9{constructor(e="",t=-1,r=[],i=cH){this.name=e,this.tracks=r,this.duration=t,this.blendMode=i,this.uuid=Ys(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,i=1/(e.fps||1);for(let a=0,o=r.length;a!==o;++a)t.push(T9(r[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],r=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=r.length;s!==a;++s)t.push(ia.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(e,t,r,i){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const d=w9(l);l=n3(l,1,d),c=n3(c,1,d),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Kd(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/r))}return new this(e,-1,a)}static findByName(e,t){let r=e;if(!Array.isArray(e)){const i=e;r=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<r.length;i++)if(r[i].name===t)return r[i];return null}static CreateClipsFromMorphTargetSequences(e,t,r){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],d=c.name.match(s);if(d&&d.length>1){const h=d[1];let p=i[h];p||(i[h]=p=[]),p.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,r));return a}static parseAnimation(e,t){if(Pt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return sn("AnimationClip: No animation in JSONLoader data."),null;const r=function(h,p,A,y,m){if(A.length!==0){const x=[],g=[];dQ(A,x,g,y),x.length!==0&&m.push(new h(p,x,g))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const p=c[h].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const A={};let y;for(y=0;y<p.length;y++)if(p[y].morphTargets)for(let m=0;m<p[y].morphTargets.length;m++)A[p[y].morphTargets[m]]=-1;for(const m in A){const x=[],g=[];for(let _=0;_!==p[y].morphTargets.length;++_){const b=p[y];x.push(b.time),g.push(b.morphTarget===m?1:0)}i.push(new Kd(".morphTargetInfluence["+m+"]",x,g))}l=A.length*a}else{const A=".bones["+t[h].name+"]";r(eh,A+".position",p,"pos",i),r(Zd,A+".quaternion",p,"rot",i),r(eh,A+".scale",p,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let r=0,i=e.length;r!==i;++r){const s=this.tracks[r];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let r=0;r<this.tracks.length;r++)e.push(this.tracks[r].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function M9(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Kd;case"vector":case"vector2":case"vector3":case"vector4":return eh;case"color":return hQ;case"quaternion":return Zd;case"bool":case"boolean":return yh;case"string":return xh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function T9(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=M9(n.type);if(n.times===void 0){const t=[],r=[];dQ(n.keys,t,r,"value"),n.times=t,n.values=r}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const po={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class R9{constructor(e,t,r){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this._abortController=null,this.itemStart=function(d){o++,s===!1&&i.onStart!==void 0&&i.onStart(d,a,o),s=!0},this.itemEnd=function(d){a++,i.onProgress!==void 0&&i.onProgress(d,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return l?l(d):d},this.setURLModifier=function(d){return l=d,this},this.addHandler=function(d,h){return c.push(d,h),this},this.removeHandler=function(d){const h=c.indexOf(d);return h!==-1&&c.splice(h,2),this},this.getHandler=function(d){for(let h=0,p=c.length;h<p;h+=2){const A=c[h],y=c[h+1];if(A.global&&(A.lastIndex=0),A.test(d))return y}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const D9=new R9;let lu=class{constructor(e){this.manager=e!==void 0?e:D9,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise(function(i,s){r.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};lu.DEFAULT_MATERIAL_NAME="__DEFAULT";const oo={};class k9 extends Error{constructor(e,t){super(e),this.response=t}}class MI extends lu{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=po.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(oo[e]!==void 0){oo[e].push({onLoad:t,onProgress:r,onError:i});return}oo[e]=[],oo[e].push({onLoad:t,onProgress:r,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Pt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const d=oo[e],h=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),A=p?parseInt(p):0,y=A!==0;let m=0;const x=new ReadableStream({start(g){_();function _(){h.read().then(({done:b,value:w})=>{if(b)g.close();else{m+=w.byteLength;const I=new ProgressEvent("progress",{lengthComputable:y,loaded:m,total:A});for(let S=0,M=d.length;S<M;S++){const T=d[S];T.onProgress&&T.onProgress(I)}g.enqueue(w),_()}},b=>{g.error(b)})}}});return new Response(x)}else throw new k9(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(d=>new DOMParser().parseFromString(d,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),p=h&&h[1]?h[1].toLowerCase():void 0,A=new TextDecoder(p);return c.arrayBuffer().then(y=>A.decode(y))}}}).then(c=>{po.add(`file:${e}`,c);const d=oo[e];delete oo[e];for(let h=0,p=d.length;h<p;h++){const A=d[h];A.onLoad&&A.onLoad(c)}}).catch(c=>{const d=oo[e];if(d===void 0)throw this.manager.itemError(e),c;delete oo[e];for(let h=0,p=d.length;h<p;h++){const A=d[h];A.onError&&A.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const gd=new WeakMap;class N9 extends lu{constructor(e){super(e)}load(e,t,r,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=po.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);else{let h=gd.get(a);h===void 0&&(h=[],gd.set(a,h)),h.push({onLoad:t,onError:i})}return a}const o=Rp("img");function l(){d(),t&&t(this);const h=gd.get(this)||[];for(let p=0;p<h.length;p++){const A=h[p];A.onLoad&&A.onLoad(this)}gd.delete(this),s.manager.itemEnd(e)}function c(h){d(),i&&i(h),po.remove(`image:${e}`);const p=gd.get(this)||[];for(let A=0;A<p.length;A++){const y=p[A];y.onError&&y.onError(h)}gd.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),po.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class Q9 extends lu{constructor(e){super(e)}load(e,t,r,i){const s=new ar,a=new N9(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},r,i),s}}class O0 extends zn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xt(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const wv=new Ft,r3=new de,i3=new de;class TI{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Dt(512,512),this.mapType=ni,this.map=null,this.mapPass=null,this.matrix=new Ft,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new EI,this._frameExtents=new Dt(1,1),this._viewportCount=1,this._viewports=[new Kt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;r3.setFromMatrixPosition(e.matrixWorld),t.position.copy(r3),i3.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(i3),t.updateMatrixWorld(),wv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(wv,t.coordinateSystem,t.reversedDepth),t.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(wv)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class P9 extends TI{constructor(){super(new Fr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,r=qd*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class fQ extends O0{constructor(e,t,r=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(zn.DEFAULT_UP),this.updateMatrix(),this.target=new zn,this.distance=r,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new P9}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const s3=new Ft,Pf=new de,Ev=new de;class L9 extends TI{constructor(){super(new Fr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Dt(4,2),this._viewportCount=6,this._viewports=[new Kt(2,1,1,1),new Kt(0,1,1,1),new Kt(3,1,1,1),new Kt(1,1,1,1),new Kt(3,0,1,1),new Kt(1,0,1,1)],this._cubeDirections=[new de(1,0,0),new de(-1,0,0),new de(0,0,1),new de(0,0,-1),new de(0,1,0),new de(0,-1,0)],this._cubeUps=[new de(0,1,0),new de(0,1,0),new de(0,1,0),new de(0,1,0),new de(0,0,1),new de(0,0,-1)]}updateMatrices(e,t=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Pf.setFromMatrixPosition(e.matrixWorld),r.position.copy(Pf),Ev.copy(r.position),Ev.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Ev),r.updateMatrixWorld(),i.makeTranslation(-Pf.x,-Pf.y,-Pf.z),s3.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(s3,r.coordinateSystem,r.reversedDepth)}}class pQ extends O0{constructor(e,t,r=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new L9}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class $0 extends rQ{constructor(e=-1,t=1,r=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=s,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=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,a=r+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class F9 extends TI{constructor(){super(new $0(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class uw extends O0{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(zn.DEFAULT_UP),this.updateMatrix(),this.target=new zn,this.shadow=new F9}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class z9 extends O0{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ap{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class U9 extends _r{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}const Iv=new WeakMap;class O9 extends lu{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Pt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Pt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=po.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{if(Iv.has(a)===!0)i&&i(Iv.get(a)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(c),s.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return po.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){i&&i(c),Iv.set(l,c),po.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});po.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class $9 extends Fr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class AQ{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const RI="\\[\\]\\.:\\/",G9=new RegExp("["+RI+"]","g"),DI="[^"+RI+"]",V9="[^"+RI.replace("\\.","")+"]",H9=/((?:WC+[\/:])*)/.source.replace("WC",DI),j9=/(WCOD+)?/.source.replace("WCOD",V9),W9=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",DI),q9=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",DI),Y9=new RegExp("^"+H9+j9+W9+q9+"$"),X9=["material","materials","bones","map"];class J9{constructor(e,t,r){const i=r||Mn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}class Mn{constructor(e,t,r){this.path=t,this.parsedPath=r||Mn.parseTrackName(t),this.node=Mn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new Mn.Composite(e,t,r):new Mn(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(G9,"")}static parseTrackName(e){const t=Y9.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=r.nodeName.substring(i+1);X9.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){const r=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=r(o.children);if(l)return l}return null},i=r(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)e[t++]=r[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,r=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=Mn.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Pt("PropertyBinding: No target node found for track: "+this.path+".");return}if(r){let c=t.objectIndex;switch(r){case"materials":if(!e.material){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){sn("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){sn("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===c){c=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){sn("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[r]===void 0){sn("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[r]}if(c!==void 0){if(e[c]===void 0){sn("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;sn("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){sn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){sn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Mn.Composite=J9;Mn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Mn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Mn.prototype.GetterByBindingType=[Mn.prototype._getValue_direct,Mn.prototype._getValue_array,Mn.prototype._getValue_arrayElement,Mn.prototype._getValue_toArray];Mn.prototype.SetterByBindingTypeAndVersioning=[[Mn.prototype._setValue_direct,Mn.prototype._setValue_direct_setNeedsUpdate,Mn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Mn.prototype._setValue_array,Mn.prototype._setValue_array_setNeedsUpdate,Mn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Mn.prototype._setValue_arrayElement,Mn.prototype._setValue_arrayElement_setNeedsUpdate,Mn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Mn.prototype._setValue_fromArray,Mn.prototype._setValue_fromArray_setNeedsUpdate,Mn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const a3=new Ft;class K9{constructor(e,t,r=0,i=1/0){this.ray=new ph(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new _I,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):sn("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return a3.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(a3),this}intersectObject(e,t=!0,r=[]){return dw(e,this,r,t),r.sort(o3),r}intersectObjects(e,t=!0,r=[]){for(let i=0,s=e.length;i<s;i++)dw(e[i],this,r,t);return r.sort(o3),r}}function o3(n,e){return n.distance-e.distance}function dw(n,e,t,r){let i=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(i=!1),i===!0&&r===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)dw(s[a],e,t,!0)}}class l3{constructor(e=1,t=0,r=0){this.radius=e,this.phi=t,this.theta=r}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=nn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(nn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class G0{constructor(e,t,r,i){G0.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let r=0;r<4;r++)this.elements[r]=e[r+t];return this}set(e,t,r,i){const s=this.elements;return s[0]=e,s[2]=t,s[1]=r,s[3]=i,this}}class Z9 extends ou{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Pt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function c3(n,e,t,r){const i=ej(r);switch(t){case HN:return n*e;case AI:return n*e/i.components*i.byteLength;case mI:return n*e/i.components*i.byteLength;case gI:return n*e*2/i.components*i.byteLength;case U0:return n*e*2/i.components*i.byteLength;case jN:return n*e*3/i.components*i.byteLength;case sr:return n*e*4/i.components*i.byteLength;case vo:return n*e*4/i.components*i.byteLength;case gg:case yg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case xg:case vg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Db:case Nb:return Math.max(n,16)*Math.max(e,8)/4;case Rb:case kb:return Math.max(n,8)*Math.max(e,8)/2;case Qb:case Pb:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Lb:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fb:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case zb:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ub:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Ob:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case $b:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Gb:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Vb:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Hb:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case jb:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Wb:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case qb:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Yb:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Xb:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Jb:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Kb:case Zb:case ew:return Math.ceil(n/4)*Math.ceil(e/4)*16;case tw:case nw:return Math.ceil(n/4)*Math.ceil(e/4)*8;case rw:case iw:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ej(n){switch(n){case ni:case ON:return{byteLength:1,components:1};case Ip:case $N:case fh:return{byteLength:2,components:1};case fI:case pI:return{byteLength:2,components:4};case Mi:case hI:case js:return{byteLength:4,components:1};case GN:case VN:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:uI}}));typeof window<"u"&&(window.__THREE__?Pt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=uI);function mQ(){let n=null,e=!1,t=null,r=null;function i(s,a){t(s,a),r=n.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(r=n.requestAnimationFrame(i),e=!0)},stop:function(){n.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function tj(n){const e=new WeakMap;function t(o,l){const c=o.array,d=o.usage,h=c.byteLength,p=n.createBuffer();n.bindBuffer(l,p),n.bufferData(l,c,d),o.onUploadCallback();let A;if(c instanceof Float32Array)A=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)A=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?A=n.HALF_FLOAT:A=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)A=n.SHORT;else if(c instanceof Uint32Array)A=n.UNSIGNED_INT;else if(c instanceof Int32Array)A=n.INT;else if(c instanceof Int8Array)A=n.BYTE;else if(c instanceof Uint8Array)A=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)A=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:A,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function r(o,l,c){const d=l.array,h=l.updateRanges;if(n.bindBuffer(c,o),h.length===0)n.bufferSubData(c,0,d);else{h.sort((A,y)=>A.start-y.start);let p=0;for(let A=1;A<h.length;A++){const y=h[p],m=h[A];m.start<=y.start+y.count+1?y.count=Math.max(y.count,m.start+m.count-y.start):(++p,h[p]=m)}h.length=p+1;for(let A=0,y=h.length;A<y;A++){const m=h[A];n.bufferSubData(c,m.start*d.BYTES_PER_ELEMENT,d,m.start,m.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.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.");r(c.buffer,o,l),c.version=o.version}}return{get:i,remove:s,update:a}}var nj=`#ifdef USE_ALPHAHASH
|
|
96
96
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
97
97
|
#endif`,rj=`#ifdef USE_ALPHAHASH
|
|
98
98
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
@@ -3638,7 +3638,7 @@ void main() {
|
|
|
3638
3638
|
#include <tonemapping_fragment>
|
|
3639
3639
|
#include <colorspace_fragment>
|
|
3640
3640
|
#include <fog_fragment>
|
|
3641
|
-
}`,Zt={alphahash_fragment:nj,alphahash_pars_fragment:rj,alphamap_fragment:ij,alphamap_pars_fragment:sj,alphatest_fragment:aj,alphatest_pars_fragment:oj,aomap_fragment:lj,aomap_pars_fragment:cj,batching_pars_vertex:uj,batching_vertex:dj,begin_vertex:hj,beginnormal_vertex:fj,bsdfs:pj,iridescence_fragment:Aj,bumpmap_pars_fragment:mj,clipping_planes_fragment:gj,clipping_planes_pars_fragment:yj,clipping_planes_pars_vertex:xj,clipping_planes_vertex:vj,color_fragment:_j,color_pars_fragment:bj,color_pars_vertex:wj,color_vertex:Ej,common:Ij,cube_uv_reflection_fragment:Cj,defaultnormal_vertex:Sj,displacementmap_pars_vertex:Bj,displacementmap_vertex:Mj,emissivemap_fragment:Tj,emissivemap_pars_fragment:Rj,colorspace_fragment:Dj,colorspace_pars_fragment:kj,envmap_fragment:Nj,envmap_common_pars_fragment:Qj,envmap_pars_fragment:Pj,envmap_pars_vertex:Lj,envmap_physical_pars_fragment:qj,envmap_vertex:Fj,fog_vertex:zj,fog_pars_vertex:Uj,fog_fragment:Oj,fog_pars_fragment:$j,gradientmap_pars_fragment:Gj,lightmap_pars_fragment:Vj,lights_lambert_fragment:Hj,lights_lambert_pars_fragment:jj,lights_pars_begin:Wj,lights_toon_fragment:Yj,lights_toon_pars_fragment:Xj,lights_phong_fragment:Jj,lights_phong_pars_fragment:Kj,lights_physical_fragment:Zj,lights_physical_pars_fragment:eW,lights_fragment_begin:tW,lights_fragment_maps:nW,lights_fragment_end:rW,logdepthbuf_fragment:iW,logdepthbuf_pars_fragment:sW,logdepthbuf_pars_vertex:aW,logdepthbuf_vertex:oW,map_fragment:lW,map_pars_fragment:cW,map_particle_fragment:uW,map_particle_pars_fragment:dW,metalnessmap_fragment:hW,metalnessmap_pars_fragment:fW,morphinstance_vertex:pW,morphcolor_vertex:AW,morphnormal_vertex:mW,morphtarget_pars_vertex:gW,morphtarget_vertex:yW,normal_fragment_begin:xW,normal_fragment_maps:vW,normal_pars_fragment:_W,normal_pars_vertex:bW,normal_vertex:wW,normalmap_pars_fragment:EW,clearcoat_normal_fragment_begin:IW,clearcoat_normal_fragment_maps:CW,clearcoat_pars_fragment:SW,iridescence_pars_fragment:BW,opaque_fragment:MW,packing:TW,premultiplied_alpha_fragment:RW,project_vertex:DW,dithering_fragment:kW,dithering_pars_fragment:NW,roughnessmap_fragment:QW,roughnessmap_pars_fragment:PW,shadowmap_pars_fragment:LW,shadowmap_pars_vertex:FW,shadowmap_vertex:zW,shadowmask_pars_fragment:UW,skinbase_vertex:OW,skinning_pars_vertex:$W,skinning_vertex:GW,skinnormal_vertex:VW,specularmap_fragment:HW,specularmap_pars_fragment:jW,tonemapping_fragment:WW,tonemapping_pars_fragment:qW,transmission_fragment:YW,transmission_pars_fragment:XW,uv_pars_fragment:JW,uv_pars_vertex:KW,uv_vertex:ZW,worldpos_vertex:eq,background_vert:tq,background_frag:nq,backgroundCube_vert:rq,backgroundCube_frag:iq,cube_vert:sq,cube_frag:aq,depth_vert:oq,depth_frag:lq,distanceRGBA_vert:cq,distanceRGBA_frag:uq,equirect_vert:dq,equirect_frag:hq,linedashed_vert:fq,linedashed_frag:pq,meshbasic_vert:Aq,meshbasic_frag:mq,meshlambert_vert:gq,meshlambert_frag:yq,meshmatcap_vert:xq,meshmatcap_frag:vq,meshnormal_vert:_q,meshnormal_frag:bq,meshphong_vert:wq,meshphong_frag:Eq,meshphysical_vert:Iq,meshphysical_frag:Cq,meshtoon_vert:Sq,meshtoon_frag:Bq,points_vert:Mq,points_frag:Tq,shadow_vert:Rq,shadow_frag:Dq,sprite_vert:kq,sprite_frag:Nq},mt={common:{diffuse:{value:new xt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Jt}},envmap:{envMap:{value:null},envMapRotation:{value:new Jt},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 Jt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Jt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Jt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Jt},normalScale:{value:new Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Jt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Jt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Jt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Jt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xt(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 xt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0},uvTransform:{value:new Jt}},sprite:{diffuse:{value:new xt(16777215)},opacity:{value:1},center:{value:new Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}}},_a={basic:{uniforms:di([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.fog]),vertexShader:Zt.meshbasic_vert,fragmentShader:Zt.meshbasic_frag},lambert:{uniforms:di([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,mt.lights,{emissive:{value:new xt(0)}}]),vertexShader:Zt.meshlambert_vert,fragmentShader:Zt.meshlambert_frag},phong:{uniforms:di([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,mt.lights,{emissive:{value:new xt(0)},specular:{value:new xt(1118481)},shininess:{value:30}}]),vertexShader:Zt.meshphong_vert,fragmentShader:Zt.meshphong_frag},standard:{uniforms:di([mt.common,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.roughnessmap,mt.metalnessmap,mt.fog,mt.lights,{emissive:{value:new xt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Zt.meshphysical_vert,fragmentShader:Zt.meshphysical_frag},toon:{uniforms:di([mt.common,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.gradientmap,mt.fog,mt.lights,{emissive:{value:new xt(0)}}]),vertexShader:Zt.meshtoon_vert,fragmentShader:Zt.meshtoon_frag},matcap:{uniforms:di([mt.common,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,{matcap:{value:null}}]),vertexShader:Zt.meshmatcap_vert,fragmentShader:Zt.meshmatcap_frag},points:{uniforms:di([mt.points,mt.fog]),vertexShader:Zt.points_vert,fragmentShader:Zt.points_frag},dashed:{uniforms:di([mt.common,mt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Zt.linedashed_vert,fragmentShader:Zt.linedashed_frag},depth:{uniforms:di([mt.common,mt.displacementmap]),vertexShader:Zt.depth_vert,fragmentShader:Zt.depth_frag},normal:{uniforms:di([mt.common,mt.bumpmap,mt.normalmap,mt.displacementmap,{opacity:{value:1}}]),vertexShader:Zt.meshnormal_vert,fragmentShader:Zt.meshnormal_frag},sprite:{uniforms:di([mt.sprite,mt.fog]),vertexShader:Zt.sprite_vert,fragmentShader:Zt.sprite_frag},background:{uniforms:{uvTransform:{value:new Jt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Zt.background_vert,fragmentShader:Zt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Jt}},vertexShader:Zt.backgroundCube_vert,fragmentShader:Zt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Zt.cube_vert,fragmentShader:Zt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Zt.equirect_vert,fragmentShader:Zt.equirect_frag},distanceRGBA:{uniforms:di([mt.common,mt.displacementmap,{referencePosition:{value:new de},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Zt.distanceRGBA_vert,fragmentShader:Zt.distanceRGBA_frag},shadow:{uniforms:di([mt.lights,mt.fog,{color:{value:new xt(0)},opacity:{value:1}}]),vertexShader:Zt.shadow_vert,fragmentShader:Zt.shadow_frag}};_a.physical={uniforms:di([_a.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Jt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Jt},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Jt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Jt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Jt},sheen:{value:0},sheenColor:{value:new xt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Jt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Jt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Jt},transmissionSamplerSize:{value:new Dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Jt},attenuationDistance:{value:0},attenuationColor:{value:new xt(0)},specularColor:{value:new xt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Jt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Jt},anisotropyVector:{value:new Dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Jt}}]),vertexShader:Zt.meshphysical_vert,fragmentShader:Zt.meshphysical_frag};const Lm={r:0,b:0,g:0},_c=new Hi,Qq=new Ft;function Pq(n,e,t,r,i,s,a){const o=new xt(0);let l=s===!0?0:1,c,d,h=null,p=0,A=null;function y(b){let w=b.isScene===!0?b.background:null;return w&&w.isTexture&&(w=(b.backgroundBlurriness>0?t:e).get(w)),w}function m(b){let w=!1;const I=y(b);I===null?g(o,l):I&&I.isColor&&(g(I,1),w=!0);const S=n.xr.getEnvironmentBlendMode();S==="additive"?r.buffers.color.setClear(0,0,0,1,a):S==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(n.autoClear||w)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function x(b,w){const I=y(w);I&&(I.isCubeTexture||I.mapping===z0)?(d===void 0&&(d=new Jn(new Ah(1,1,1),new ji({name:"BackgroundCubeMaterial",uniforms:Yd(_a.backgroundCube.uniforms),vertexShader:_a.backgroundCube.vertexShader,fragmentShader:_a.backgroundCube.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(S,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),_c.copy(w.backgroundRotation),_c.x*=-1,_c.y*=-1,_c.z*=-1,I.isCubeTexture&&I.isRenderTargetTexture===!1&&(_c.y*=-1,_c.z*=-1),d.material.uniforms.envMap.value=I,d.material.uniforms.flipEnvMap.value=I.isCubeTexture&&I.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(Qq.makeRotationFromEuler(_c)),d.material.toneMapped=mn.getTransfer(I.colorSpace)!==Rn,(h!==I||p!==I.version||A!==n.toneMapping)&&(d.material.needsUpdate=!0,h=I,p=I.version,A=n.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):I&&I.isTexture&&(c===void 0&&(c=new Jn(new Xd(2,2),new ji({name:"BackgroundMaterial",uniforms:Yd(_a.background.uniforms),vertexShader:_a.background.vertexShader,fragmentShader:_a.background.fragmentShader,side:Eo,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=I,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=mn.getTransfer(I.colorSpace)!==Rn,I.matrixAutoUpdate===!0&&I.updateMatrix(),c.material.uniforms.uvTransform.value.copy(I.matrix),(h!==I||p!==I.version||A!==n.toneMapping)&&(c.material.needsUpdate=!0,h=I,p=I.version,A=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function g(b,w){b.getRGB(Lm,nQ(n)),r.buffers.color.setClear(Lm.r,Lm.g,Lm.b,w,a)}function _(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,w=1){o.set(b),l=w,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(b){l=b,g(o,l)},render:m,addToRenderList:x,dispose:_}}function Lq(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),r={},i=p(null);let s=i,a=!1;function o(k,H,Q,V,B){let W=!1;const K=h(V,Q,H);s!==K&&(s=K,c(s.object)),W=A(k,V,Q,B),W&&y(k,V,Q,B),B!==null&&e.update(B,n.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,w(k,H,Q,V),B!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return n.createVertexArray()}function c(k){return n.bindVertexArray(k)}function d(k){return n.deleteVertexArray(k)}function h(k,H,Q){const V=Q.wireframe===!0;let B=r[k.id];B===void 0&&(B={},r[k.id]=B);let W=B[H.id];W===void 0&&(W={},B[H.id]=W);let K=W[V];return K===void 0&&(K=p(l()),W[V]=K),K}function p(k){const H=[],Q=[],V=[];for(let B=0;B<t;B++)H[B]=0,Q[B]=0,V[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:Q,attributeDivisors:V,object:k,attributes:{},index:null}}function A(k,H,Q,V){const B=s.attributes,W=H.attributes;let K=0;const X=Q.getAttributes();for(const $ in X)if(X[$].location>=0){const ne=B[$];let L=W[$];if(L===void 0&&($==="instanceMatrix"&&k.instanceMatrix&&(L=k.instanceMatrix),$==="instanceColor"&&k.instanceColor&&(L=k.instanceColor)),ne===void 0||ne.attribute!==L||L&&ne.data!==L.data)return!0;K++}return s.attributesNum!==K||s.index!==V}function y(k,H,Q,V){const B={},W=H.attributes;let K=0;const X=Q.getAttributes();for(const $ in X)if(X[$].location>=0){let ne=W[$];ne===void 0&&($==="instanceMatrix"&&k.instanceMatrix&&(ne=k.instanceMatrix),$==="instanceColor"&&k.instanceColor&&(ne=k.instanceColor));const L={};L.attribute=ne,ne&&ne.data&&(L.data=ne.data),B[$]=L,K++}s.attributes=B,s.attributesNum=K,s.index=V}function m(){const k=s.newAttributes;for(let H=0,Q=k.length;H<Q;H++)k[H]=0}function x(k){g(k,0)}function g(k,H){const Q=s.newAttributes,V=s.enabledAttributes,B=s.attributeDivisors;Q[k]=1,V[k]===0&&(n.enableVertexAttribArray(k),V[k]=1),B[k]!==H&&(n.vertexAttribDivisor(k,H),B[k]=H)}function _(){const k=s.newAttributes,H=s.enabledAttributes;for(let Q=0,V=H.length;Q<V;Q++)H[Q]!==k[Q]&&(n.disableVertexAttribArray(Q),H[Q]=0)}function b(k,H,Q,V,B,W,K){K===!0?n.vertexAttribIPointer(k,H,Q,B,W):n.vertexAttribPointer(k,H,Q,V,B,W)}function w(k,H,Q,V){m();const B=V.attributes,W=Q.getAttributes(),K=H.defaultAttributeValues;for(const X in W){const $=W[X];if($.location>=0){let J=B[X];if(J===void 0&&(X==="instanceMatrix"&&k.instanceMatrix&&(J=k.instanceMatrix),X==="instanceColor"&&k.instanceColor&&(J=k.instanceColor)),J!==void 0){const ne=J.normalized,L=J.itemSize,G=e.get(J);if(G===void 0)continue;const oe=G.buffer,Ae=G.type,ye=G.bytesPerElement,he=Ae===n.INT||Ae===n.UNSIGNED_INT||J.gpuType===hI;if(J.isInterleavedBufferAttribute){const fe=J.data,Ie=fe.stride,Re=J.offset;if(fe.isInstancedInterleavedBuffer){for(let ge=0;ge<$.locationSize;ge++)g($.location+ge,fe.meshPerAttribute);k.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let ge=0;ge<$.locationSize;ge++)x($.location+ge);n.bindBuffer(n.ARRAY_BUFFER,oe);for(let ge=0;ge<$.locationSize;ge++)b($.location+ge,L/$.locationSize,Ae,ne,Ie*ye,(Re+L/$.locationSize*ge)*ye,he)}else{if(J.isInstancedBufferAttribute){for(let fe=0;fe<$.locationSize;fe++)g($.location+fe,J.meshPerAttribute);k.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let fe=0;fe<$.locationSize;fe++)x($.location+fe);n.bindBuffer(n.ARRAY_BUFFER,oe);for(let fe=0;fe<$.locationSize;fe++)b($.location+fe,L/$.locationSize,Ae,ne,L*ye,L/$.locationSize*fe*ye,he)}}else if(K!==void 0){const ne=K[X];if(ne!==void 0)switch(ne.length){case 2:n.vertexAttrib2fv($.location,ne);break;case 3:n.vertexAttrib3fv($.location,ne);break;case 4:n.vertexAttrib4fv($.location,ne);break;default:n.vertexAttrib1fv($.location,ne)}}}}_()}function I(){T();for(const k in r){const H=r[k];for(const Q in H){const V=H[Q];for(const B in V)d(V[B].object),delete V[B];delete H[Q]}delete r[k]}}function S(k){if(r[k.id]===void 0)return;const H=r[k.id];for(const Q in H){const V=H[Q];for(const B in V)d(V[B].object),delete V[B];delete H[Q]}delete r[k.id]}function M(k){for(const H in r){const Q=r[H];if(Q[k.id]===void 0)continue;const V=Q[k.id];for(const B in V)d(V[B].object),delete V[B];delete Q[k.id]}}function T(){R(),a=!0,s!==i&&(s=i,c(s.object))}function R(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:T,resetDefaultState:R,dispose:I,releaseStatesOfGeometry:S,releaseStatesOfProgram:M,initAttributes:m,enableAttribute:x,disableUnusedAttributes:_}}function Fq(n,e,t){let r;function i(c){r=c}function s(c,d){n.drawArrays(r,c,d),t.update(d,r,1)}function a(c,d,h){h!==0&&(n.drawArraysInstanced(r,c,d,h),t.update(d,r,h))}function o(c,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,d,0,h);let A=0;for(let y=0;y<h;y++)A+=d[y];t.update(A,r,1)}function l(c,d,h,p){if(h===0)return;const A=e.get("WEBGL_multi_draw");if(A===null)for(let y=0;y<c.length;y++)a(c[y],d[y],p[y]);else{A.multiDrawArraysInstancedWEBGL(r,c,0,d,0,p,0,h);let y=0;for(let m=0;m<h;m++)y+=d[m]*p[m];t.update(y,r,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function zq(n,e,t,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const M=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(M){return!(M!==sr&&r.convert(M)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(M){const T=M===fh&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(M!==ni&&r.convert(M)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&M!==js&&!T)}function l(M){if(M==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const d=l(c);d!==c&&(Pt("WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const h=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),A=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_TEXTURE_SIZE),x=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),_=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),b=n.getParameter(n.MAX_VARYING_VECTORS),w=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),I=y>0,S=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:p,maxTextures:A,maxVertexTextures:y,maxTextureSize:m,maxCubemapSize:x,maxAttributes:g,maxVertexUniforms:_,maxVaryings:b,maxFragmentUniforms:w,vertexTextures:I,maxSamples:S}}function Uq(n){const e=this;let t=null,r=0,i=!1,s=!1;const a=new Ml,o=new Jt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const A=h.length!==0||p||r!==0||i;return i=p,r=h.length,A},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){t=d(h,p,0)},this.setState=function(h,p,A){const y=h.clippingPlanes,m=h.clipIntersection,x=h.clipShadows,g=n.get(h);if(!i||y===null||y.length===0||s&&!x)s?d(null):c();else{const _=s?0:r,b=_*4;let w=g.clippingState||null;l.value=w,w=d(y,p,b,A);for(let I=0;I!==b;++I)w[I]=t[I];g.clippingState=w,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=_}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,p,A,y){const m=h!==null?h.length:0;let x=null;if(m!==0){if(x=l.value,y!==!0||x===null){const g=A+m*4,_=p.matrixWorldInverse;o.getNormalMatrix(_),(x===null||x.length<g)&&(x=new Float32Array(g));for(let b=0,w=A;b!==m;++b,w+=4)a.copy(h[b]).applyMatrix4(_,o),a.normal.toArray(x,w),x[w+3]=a.constant}l.value=x,l.needsUpdate=!0}return e.numPlanes=m,e.numIntersection=0,x}}function Oq(n){let e=new WeakMap;function t(a,o){return o===Mb?a.mapping=jd:o===Tb&&(a.mapping=Wd),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===Mb||o===Tb)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new sQ(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const Nl=4,u3=[.125,.215,.35,.446,.526,.582],kc=20,$q=256,Lf=new $0,d3=new xt;let Cv=null,Sv=0,Bv=0,Mv=!1;const Gq=new de;class hw{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,r=.1,i=100,s={}){const{size:a=256,position:o=Gq}=s;Cv=this._renderer.getRenderTarget(),Sv=this._renderer.getActiveCubeFace(),Bv=this._renderer.getActiveMipmapLevel(),Mv=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=p3(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=f3(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Cv,Sv,Bv),this._renderer.xr.enabled=Mv,e.scissorTest=!1,yd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===jd||e.mapping===Wd?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Cv=this._renderer.getRenderTarget(),Sv=this._renderer.getActiveCubeFace(),Bv=this._renderer.getActiveMipmapLevel(),Mv=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=t||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,r={magFilter:ir,minFilter:ir,generateMipmaps:!1,type:fh,format:sr,colorSpace:ri,depthBuffer:!1},i=h3(e,t,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=h3(e,t,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Vq(s)),this._blurMaterial=jq(s,e,t),this._ggxMaterial=Hq(s,e,t)}return i}_compileMaterial(e){const t=new Jn(new _r,e);this._renderer.compile(t,Lf)}_sceneToCubeUV(e,t,r,i,s){const l=new Fr(90,1,t,r),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,p=h.autoClear,A=h.toneMapping;h.getClearColor(d3),h.toneMapping=Pl,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Jn(new Ah,new Oc({name:"PMREM.Background",side:Bi,depthWrite:!1,depthTest:!1})));const m=this._backgroundBox,x=m.material;let g=!1;const _=e.background;_?_.isColor&&(x.color.copy(_),e.background=null,g=!0):(x.color.copy(d3),g=!0);for(let b=0;b<6;b++){const w=b%3;w===0?(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+d[b],s.y,s.z)):w===1?(l.up.set(0,0,c[b]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+d[b],s.z)):(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+d[b]));const I=this._cubeSize;yd(i,w*I,b>2?I:0,I,I),h.setRenderTarget(i),g&&h.render(m,l),h.render(e,l)}h.toneMapping=A,h.autoClear=p,e.background=_}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===jd||e.mapping===Wd;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=p3()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=f3());const s=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;yd(t,0,0,3*l,2*l),r.setRenderTarget(t),r.render(a,Lf)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=r}_applyGGXFilter(e,t,r){const i=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[r];o.material=a;const l=a.uniforms,c=r/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-d*d),p=.05+c*.95,A=h*p,{_lodMax:y}=this,m=this._sizeLods[r],x=3*m*(r>y-Nl?r-y+Nl:0),g=4*(this._cubeSize-m);l.envMap.value=e.texture,l.roughness.value=A,l.mipInt.value=y-t,yd(s,x,g,3*m,2*m),i.setRenderTarget(s),i.render(o,Lf),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=y-r,yd(e,x,g,3*m,2*m),i.setRenderTarget(e),i.render(o,Lf)}_blur(e,t,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&sn("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=c;const p=c.uniforms,A=this._sizeLods[r]-1,y=isFinite(s)?Math.PI/(2*A):2*Math.PI/(2*kc-1),m=s/y,x=isFinite(s)?1+Math.floor(d*m):kc;x>kc&&Pt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${kc}`);const g=[];let _=0;for(let M=0;M<kc;++M){const T=M/m,R=Math.exp(-T*T/2);g.push(R),M===0?_+=R:M<x&&(_+=2*R)}for(let M=0;M<g.length;M++)g[M]=g[M]/_;p.envMap.value=e.texture,p.samples.value=x,p.weights.value=g,p.latitudinal.value=a==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:b}=this;p.dTheta.value=y,p.mipInt.value=b-r;const w=this._sizeLods[i],I=3*w*(i>b-Nl?i-b+Nl:0),S=4*(this._cubeSize-w);yd(t,I,S,3*w,2*w),l.setRenderTarget(t),l.render(h,Lf)}}function Vq(n){const e=[],t=[],r=[];let i=n;const s=n-Nl+1+u3.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>n-Nl?l=u3[a-n+Nl-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),d=-c,h=1+c,p=[d,d,h,d,h,h,d,d,h,h,d,h],A=6,y=6,m=3,x=2,g=1,_=new Float32Array(m*y*A),b=new Float32Array(x*y*A),w=new Float32Array(g*y*A);for(let S=0;S<A;S++){const M=S%3*2/3-1,T=S>2?0:-1,R=[M,T,0,M+2/3,T,0,M+2/3,T+1,0,M,T,0,M+2/3,T+1,0,M,T+1,0];_.set(R,m*y*S),b.set(p,x*y*S);const k=[S,S,S,S,S,S];w.set(k,g*y*S)}const I=new _r;I.setAttribute("position",new or(_,m)),I.setAttribute("uv",new or(b,x)),I.setAttribute("faceIndex",new or(w,g)),r.push(new Jn(I,null)),i>Nl&&i--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function h3(n,e,t){const r=new Qa(n,e,t);return r.texture.mapping=z0,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function yd(n,e,t,r,i){n.viewport.set(e,t,r,i),n.scissor.set(e,t,r,i)}function Hq(n,e,t){return new ji({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:$q,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:V0(),fragmentShader:`
|
|
3641
|
+
}`,Zt={alphahash_fragment:nj,alphahash_pars_fragment:rj,alphamap_fragment:ij,alphamap_pars_fragment:sj,alphatest_fragment:aj,alphatest_pars_fragment:oj,aomap_fragment:lj,aomap_pars_fragment:cj,batching_pars_vertex:uj,batching_vertex:dj,begin_vertex:hj,beginnormal_vertex:fj,bsdfs:pj,iridescence_fragment:Aj,bumpmap_pars_fragment:mj,clipping_planes_fragment:gj,clipping_planes_pars_fragment:yj,clipping_planes_pars_vertex:xj,clipping_planes_vertex:vj,color_fragment:_j,color_pars_fragment:bj,color_pars_vertex:wj,color_vertex:Ej,common:Ij,cube_uv_reflection_fragment:Cj,defaultnormal_vertex:Sj,displacementmap_pars_vertex:Bj,displacementmap_vertex:Mj,emissivemap_fragment:Tj,emissivemap_pars_fragment:Rj,colorspace_fragment:Dj,colorspace_pars_fragment:kj,envmap_fragment:Nj,envmap_common_pars_fragment:Qj,envmap_pars_fragment:Pj,envmap_pars_vertex:Lj,envmap_physical_pars_fragment:qj,envmap_vertex:Fj,fog_vertex:zj,fog_pars_vertex:Uj,fog_fragment:Oj,fog_pars_fragment:$j,gradientmap_pars_fragment:Gj,lightmap_pars_fragment:Vj,lights_lambert_fragment:Hj,lights_lambert_pars_fragment:jj,lights_pars_begin:Wj,lights_toon_fragment:Yj,lights_toon_pars_fragment:Xj,lights_phong_fragment:Jj,lights_phong_pars_fragment:Kj,lights_physical_fragment:Zj,lights_physical_pars_fragment:eW,lights_fragment_begin:tW,lights_fragment_maps:nW,lights_fragment_end:rW,logdepthbuf_fragment:iW,logdepthbuf_pars_fragment:sW,logdepthbuf_pars_vertex:aW,logdepthbuf_vertex:oW,map_fragment:lW,map_pars_fragment:cW,map_particle_fragment:uW,map_particle_pars_fragment:dW,metalnessmap_fragment:hW,metalnessmap_pars_fragment:fW,morphinstance_vertex:pW,morphcolor_vertex:AW,morphnormal_vertex:mW,morphtarget_pars_vertex:gW,morphtarget_vertex:yW,normal_fragment_begin:xW,normal_fragment_maps:vW,normal_pars_fragment:_W,normal_pars_vertex:bW,normal_vertex:wW,normalmap_pars_fragment:EW,clearcoat_normal_fragment_begin:IW,clearcoat_normal_fragment_maps:CW,clearcoat_pars_fragment:SW,iridescence_pars_fragment:BW,opaque_fragment:MW,packing:TW,premultiplied_alpha_fragment:RW,project_vertex:DW,dithering_fragment:kW,dithering_pars_fragment:NW,roughnessmap_fragment:QW,roughnessmap_pars_fragment:PW,shadowmap_pars_fragment:LW,shadowmap_pars_vertex:FW,shadowmap_vertex:zW,shadowmask_pars_fragment:UW,skinbase_vertex:OW,skinning_pars_vertex:$W,skinning_vertex:GW,skinnormal_vertex:VW,specularmap_fragment:HW,specularmap_pars_fragment:jW,tonemapping_fragment:WW,tonemapping_pars_fragment:qW,transmission_fragment:YW,transmission_pars_fragment:XW,uv_pars_fragment:JW,uv_pars_vertex:KW,uv_vertex:ZW,worldpos_vertex:eq,background_vert:tq,background_frag:nq,backgroundCube_vert:rq,backgroundCube_frag:iq,cube_vert:sq,cube_frag:aq,depth_vert:oq,depth_frag:lq,distanceRGBA_vert:cq,distanceRGBA_frag:uq,equirect_vert:dq,equirect_frag:hq,linedashed_vert:fq,linedashed_frag:pq,meshbasic_vert:Aq,meshbasic_frag:mq,meshlambert_vert:gq,meshlambert_frag:yq,meshmatcap_vert:xq,meshmatcap_frag:vq,meshnormal_vert:_q,meshnormal_frag:bq,meshphong_vert:wq,meshphong_frag:Eq,meshphysical_vert:Iq,meshphysical_frag:Cq,meshtoon_vert:Sq,meshtoon_frag:Bq,points_vert:Mq,points_frag:Tq,shadow_vert:Rq,shadow_frag:Dq,sprite_vert:kq,sprite_frag:Nq},mt={common:{diffuse:{value:new xt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Jt}},envmap:{envMap:{value:null},envMapRotation:{value:new Jt},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 Jt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Jt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Jt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Jt},normalScale:{value:new Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Jt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Jt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Jt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Jt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xt(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 xt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0},uvTransform:{value:new Jt}},sprite:{diffuse:{value:new xt(16777215)},opacity:{value:1},center:{value:new Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}}},_a={basic:{uniforms:di([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.fog]),vertexShader:Zt.meshbasic_vert,fragmentShader:Zt.meshbasic_frag},lambert:{uniforms:di([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,mt.lights,{emissive:{value:new xt(0)}}]),vertexShader:Zt.meshlambert_vert,fragmentShader:Zt.meshlambert_frag},phong:{uniforms:di([mt.common,mt.specularmap,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,mt.lights,{emissive:{value:new xt(0)},specular:{value:new xt(1118481)},shininess:{value:30}}]),vertexShader:Zt.meshphong_vert,fragmentShader:Zt.meshphong_frag},standard:{uniforms:di([mt.common,mt.envmap,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.roughnessmap,mt.metalnessmap,mt.fog,mt.lights,{emissive:{value:new xt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Zt.meshphysical_vert,fragmentShader:Zt.meshphysical_frag},toon:{uniforms:di([mt.common,mt.aomap,mt.lightmap,mt.emissivemap,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.gradientmap,mt.fog,mt.lights,{emissive:{value:new xt(0)}}]),vertexShader:Zt.meshtoon_vert,fragmentShader:Zt.meshtoon_frag},matcap:{uniforms:di([mt.common,mt.bumpmap,mt.normalmap,mt.displacementmap,mt.fog,{matcap:{value:null}}]),vertexShader:Zt.meshmatcap_vert,fragmentShader:Zt.meshmatcap_frag},points:{uniforms:di([mt.points,mt.fog]),vertexShader:Zt.points_vert,fragmentShader:Zt.points_frag},dashed:{uniforms:di([mt.common,mt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Zt.linedashed_vert,fragmentShader:Zt.linedashed_frag},depth:{uniforms:di([mt.common,mt.displacementmap]),vertexShader:Zt.depth_vert,fragmentShader:Zt.depth_frag},normal:{uniforms:di([mt.common,mt.bumpmap,mt.normalmap,mt.displacementmap,{opacity:{value:1}}]),vertexShader:Zt.meshnormal_vert,fragmentShader:Zt.meshnormal_frag},sprite:{uniforms:di([mt.sprite,mt.fog]),vertexShader:Zt.sprite_vert,fragmentShader:Zt.sprite_frag},background:{uniforms:{uvTransform:{value:new Jt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Zt.background_vert,fragmentShader:Zt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Jt}},vertexShader:Zt.backgroundCube_vert,fragmentShader:Zt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Zt.cube_vert,fragmentShader:Zt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Zt.equirect_vert,fragmentShader:Zt.equirect_frag},distanceRGBA:{uniforms:di([mt.common,mt.displacementmap,{referencePosition:{value:new de},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Zt.distanceRGBA_vert,fragmentShader:Zt.distanceRGBA_frag},shadow:{uniforms:di([mt.lights,mt.fog,{color:{value:new xt(0)},opacity:{value:1}}]),vertexShader:Zt.shadow_vert,fragmentShader:Zt.shadow_frag}};_a.physical={uniforms:di([_a.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Jt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Jt},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Jt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Jt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Jt},sheen:{value:0},sheenColor:{value:new xt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Jt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Jt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Jt},transmissionSamplerSize:{value:new Dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Jt},attenuationDistance:{value:0},attenuationColor:{value:new xt(0)},specularColor:{value:new xt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Jt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Jt},anisotropyVector:{value:new Dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Jt}}]),vertexShader:Zt.meshphysical_vert,fragmentShader:Zt.meshphysical_frag};const Lm={r:0,b:0,g:0},_c=new Hi,Qq=new Ft;function Pq(n,e,t,r,i,s,a){const o=new xt(0);let l=s===!0?0:1,c,d,h=null,p=0,A=null;function y(b){let w=b.isScene===!0?b.background:null;return w&&w.isTexture&&(w=(b.backgroundBlurriness>0?t:e).get(w)),w}function m(b){let w=!1;const I=y(b);I===null?g(o,l):I&&I.isColor&&(g(I,1),w=!0);const S=n.xr.getEnvironmentBlendMode();S==="additive"?r.buffers.color.setClear(0,0,0,1,a):S==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(n.autoClear||w)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function x(b,w){const I=y(w);I&&(I.isCubeTexture||I.mapping===z0)?(d===void 0&&(d=new Jn(new Ah(1,1,1),new ji({name:"BackgroundCubeMaterial",uniforms:Yd(_a.backgroundCube.uniforms),vertexShader:_a.backgroundCube.vertexShader,fragmentShader:_a.backgroundCube.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(S,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),_c.copy(w.backgroundRotation),_c.x*=-1,_c.y*=-1,_c.z*=-1,I.isCubeTexture&&I.isRenderTargetTexture===!1&&(_c.y*=-1,_c.z*=-1),d.material.uniforms.envMap.value=I,d.material.uniforms.flipEnvMap.value=I.isCubeTexture&&I.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(Qq.makeRotationFromEuler(_c)),d.material.toneMapped=mn.getTransfer(I.colorSpace)!==Dn,(h!==I||p!==I.version||A!==n.toneMapping)&&(d.material.needsUpdate=!0,h=I,p=I.version,A=n.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):I&&I.isTexture&&(c===void 0&&(c=new Jn(new Xd(2,2),new ji({name:"BackgroundMaterial",uniforms:Yd(_a.background.uniforms),vertexShader:_a.background.vertexShader,fragmentShader:_a.background.fragmentShader,side:Eo,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=I,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=mn.getTransfer(I.colorSpace)!==Dn,I.matrixAutoUpdate===!0&&I.updateMatrix(),c.material.uniforms.uvTransform.value.copy(I.matrix),(h!==I||p!==I.version||A!==n.toneMapping)&&(c.material.needsUpdate=!0,h=I,p=I.version,A=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function g(b,w){b.getRGB(Lm,nQ(n)),r.buffers.color.setClear(Lm.r,Lm.g,Lm.b,w,a)}function _(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,w=1){o.set(b),l=w,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(b){l=b,g(o,l)},render:m,addToRenderList:x,dispose:_}}function Lq(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),r={},i=p(null);let s=i,a=!1;function o(k,H,Q,V,B){let W=!1;const K=h(V,Q,H);s!==K&&(s=K,c(s.object)),W=A(k,V,Q,B),W&&y(k,V,Q,B),B!==null&&e.update(B,n.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,w(k,H,Q,V),B!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return n.createVertexArray()}function c(k){return n.bindVertexArray(k)}function d(k){return n.deleteVertexArray(k)}function h(k,H,Q){const V=Q.wireframe===!0;let B=r[k.id];B===void 0&&(B={},r[k.id]=B);let W=B[H.id];W===void 0&&(W={},B[H.id]=W);let K=W[V];return K===void 0&&(K=p(l()),W[V]=K),K}function p(k){const H=[],Q=[],V=[];for(let B=0;B<t;B++)H[B]=0,Q[B]=0,V[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:Q,attributeDivisors:V,object:k,attributes:{},index:null}}function A(k,H,Q,V){const B=s.attributes,W=H.attributes;let K=0;const X=Q.getAttributes();for(const $ in X)if(X[$].location>=0){const ne=B[$];let L=W[$];if(L===void 0&&($==="instanceMatrix"&&k.instanceMatrix&&(L=k.instanceMatrix),$==="instanceColor"&&k.instanceColor&&(L=k.instanceColor)),ne===void 0||ne.attribute!==L||L&&ne.data!==L.data)return!0;K++}return s.attributesNum!==K||s.index!==V}function y(k,H,Q,V){const B={},W=H.attributes;let K=0;const X=Q.getAttributes();for(const $ in X)if(X[$].location>=0){let ne=W[$];ne===void 0&&($==="instanceMatrix"&&k.instanceMatrix&&(ne=k.instanceMatrix),$==="instanceColor"&&k.instanceColor&&(ne=k.instanceColor));const L={};L.attribute=ne,ne&&ne.data&&(L.data=ne.data),B[$]=L,K++}s.attributes=B,s.attributesNum=K,s.index=V}function m(){const k=s.newAttributes;for(let H=0,Q=k.length;H<Q;H++)k[H]=0}function x(k){g(k,0)}function g(k,H){const Q=s.newAttributes,V=s.enabledAttributes,B=s.attributeDivisors;Q[k]=1,V[k]===0&&(n.enableVertexAttribArray(k),V[k]=1),B[k]!==H&&(n.vertexAttribDivisor(k,H),B[k]=H)}function _(){const k=s.newAttributes,H=s.enabledAttributes;for(let Q=0,V=H.length;Q<V;Q++)H[Q]!==k[Q]&&(n.disableVertexAttribArray(Q),H[Q]=0)}function b(k,H,Q,V,B,W,K){K===!0?n.vertexAttribIPointer(k,H,Q,B,W):n.vertexAttribPointer(k,H,Q,V,B,W)}function w(k,H,Q,V){m();const B=V.attributes,W=Q.getAttributes(),K=H.defaultAttributeValues;for(const X in W){const $=W[X];if($.location>=0){let J=B[X];if(J===void 0&&(X==="instanceMatrix"&&k.instanceMatrix&&(J=k.instanceMatrix),X==="instanceColor"&&k.instanceColor&&(J=k.instanceColor)),J!==void 0){const ne=J.normalized,L=J.itemSize,G=e.get(J);if(G===void 0)continue;const oe=G.buffer,Ae=G.type,ye=G.bytesPerElement,he=Ae===n.INT||Ae===n.UNSIGNED_INT||J.gpuType===hI;if(J.isInterleavedBufferAttribute){const fe=J.data,Ie=fe.stride,Re=J.offset;if(fe.isInstancedInterleavedBuffer){for(let ge=0;ge<$.locationSize;ge++)g($.location+ge,fe.meshPerAttribute);k.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let ge=0;ge<$.locationSize;ge++)x($.location+ge);n.bindBuffer(n.ARRAY_BUFFER,oe);for(let ge=0;ge<$.locationSize;ge++)b($.location+ge,L/$.locationSize,Ae,ne,Ie*ye,(Re+L/$.locationSize*ge)*ye,he)}else{if(J.isInstancedBufferAttribute){for(let fe=0;fe<$.locationSize;fe++)g($.location+fe,J.meshPerAttribute);k.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let fe=0;fe<$.locationSize;fe++)x($.location+fe);n.bindBuffer(n.ARRAY_BUFFER,oe);for(let fe=0;fe<$.locationSize;fe++)b($.location+fe,L/$.locationSize,Ae,ne,L*ye,L/$.locationSize*fe*ye,he)}}else if(K!==void 0){const ne=K[X];if(ne!==void 0)switch(ne.length){case 2:n.vertexAttrib2fv($.location,ne);break;case 3:n.vertexAttrib3fv($.location,ne);break;case 4:n.vertexAttrib4fv($.location,ne);break;default:n.vertexAttrib1fv($.location,ne)}}}}_()}function I(){T();for(const k in r){const H=r[k];for(const Q in H){const V=H[Q];for(const B in V)d(V[B].object),delete V[B];delete H[Q]}delete r[k]}}function S(k){if(r[k.id]===void 0)return;const H=r[k.id];for(const Q in H){const V=H[Q];for(const B in V)d(V[B].object),delete V[B];delete H[Q]}delete r[k.id]}function M(k){for(const H in r){const Q=r[H];if(Q[k.id]===void 0)continue;const V=Q[k.id];for(const B in V)d(V[B].object),delete V[B];delete Q[k.id]}}function T(){R(),a=!0,s!==i&&(s=i,c(s.object))}function R(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:T,resetDefaultState:R,dispose:I,releaseStatesOfGeometry:S,releaseStatesOfProgram:M,initAttributes:m,enableAttribute:x,disableUnusedAttributes:_}}function Fq(n,e,t){let r;function i(c){r=c}function s(c,d){n.drawArrays(r,c,d),t.update(d,r,1)}function a(c,d,h){h!==0&&(n.drawArraysInstanced(r,c,d,h),t.update(d,r,h))}function o(c,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,d,0,h);let A=0;for(let y=0;y<h;y++)A+=d[y];t.update(A,r,1)}function l(c,d,h,p){if(h===0)return;const A=e.get("WEBGL_multi_draw");if(A===null)for(let y=0;y<c.length;y++)a(c[y],d[y],p[y]);else{A.multiDrawArraysInstancedWEBGL(r,c,0,d,0,p,0,h);let y=0;for(let m=0;m<h;m++)y+=d[m]*p[m];t.update(y,r,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function zq(n,e,t,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const M=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(M){return!(M!==sr&&r.convert(M)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(M){const T=M===fh&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(M!==ni&&r.convert(M)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&M!==js&&!T)}function l(M){if(M==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const d=l(c);d!==c&&(Pt("WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const h=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),A=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_TEXTURE_SIZE),x=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),_=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),b=n.getParameter(n.MAX_VARYING_VECTORS),w=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),I=y>0,S=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:p,maxTextures:A,maxVertexTextures:y,maxTextureSize:m,maxCubemapSize:x,maxAttributes:g,maxVertexUniforms:_,maxVaryings:b,maxFragmentUniforms:w,vertexTextures:I,maxSamples:S}}function Uq(n){const e=this;let t=null,r=0,i=!1,s=!1;const a=new Ml,o=new Jt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const A=h.length!==0||p||r!==0||i;return i=p,r=h.length,A},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){t=d(h,p,0)},this.setState=function(h,p,A){const y=h.clippingPlanes,m=h.clipIntersection,x=h.clipShadows,g=n.get(h);if(!i||y===null||y.length===0||s&&!x)s?d(null):c();else{const _=s?0:r,b=_*4;let w=g.clippingState||null;l.value=w,w=d(y,p,b,A);for(let I=0;I!==b;++I)w[I]=t[I];g.clippingState=w,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=_}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,p,A,y){const m=h!==null?h.length:0;let x=null;if(m!==0){if(x=l.value,y!==!0||x===null){const g=A+m*4,_=p.matrixWorldInverse;o.getNormalMatrix(_),(x===null||x.length<g)&&(x=new Float32Array(g));for(let b=0,w=A;b!==m;++b,w+=4)a.copy(h[b]).applyMatrix4(_,o),a.normal.toArray(x,w),x[w+3]=a.constant}l.value=x,l.needsUpdate=!0}return e.numPlanes=m,e.numIntersection=0,x}}function Oq(n){let e=new WeakMap;function t(a,o){return o===Mb?a.mapping=jd:o===Tb&&(a.mapping=Wd),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===Mb||o===Tb)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new sQ(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const Nl=4,u3=[.125,.215,.35,.446,.526,.582],kc=20,$q=256,Lf=new $0,d3=new xt;let Cv=null,Sv=0,Bv=0,Mv=!1;const Gq=new de;class hw{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,r=.1,i=100,s={}){const{size:a=256,position:o=Gq}=s;Cv=this._renderer.getRenderTarget(),Sv=this._renderer.getActiveCubeFace(),Bv=this._renderer.getActiveMipmapLevel(),Mv=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=p3(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=f3(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Cv,Sv,Bv),this._renderer.xr.enabled=Mv,e.scissorTest=!1,yd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===jd||e.mapping===Wd?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Cv=this._renderer.getRenderTarget(),Sv=this._renderer.getActiveCubeFace(),Bv=this._renderer.getActiveMipmapLevel(),Mv=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=t||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,r={magFilter:ir,minFilter:ir,generateMipmaps:!1,type:fh,format:sr,colorSpace:ri,depthBuffer:!1},i=h3(e,t,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=h3(e,t,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Vq(s)),this._blurMaterial=jq(s,e,t),this._ggxMaterial=Hq(s,e,t)}return i}_compileMaterial(e){const t=new Jn(new _r,e);this._renderer.compile(t,Lf)}_sceneToCubeUV(e,t,r,i,s){const l=new Fr(90,1,t,r),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,p=h.autoClear,A=h.toneMapping;h.getClearColor(d3),h.toneMapping=Pl,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Jn(new Ah,new Oc({name:"PMREM.Background",side:Bi,depthWrite:!1,depthTest:!1})));const m=this._backgroundBox,x=m.material;let g=!1;const _=e.background;_?_.isColor&&(x.color.copy(_),e.background=null,g=!0):(x.color.copy(d3),g=!0);for(let b=0;b<6;b++){const w=b%3;w===0?(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+d[b],s.y,s.z)):w===1?(l.up.set(0,0,c[b]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+d[b],s.z)):(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+d[b]));const I=this._cubeSize;yd(i,w*I,b>2?I:0,I,I),h.setRenderTarget(i),g&&h.render(m,l),h.render(e,l)}h.toneMapping=A,h.autoClear=p,e.background=_}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===jd||e.mapping===Wd;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=p3()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=f3());const s=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;yd(t,0,0,3*l,2*l),r.setRenderTarget(t),r.render(a,Lf)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=r}_applyGGXFilter(e,t,r){const i=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[r];o.material=a;const l=a.uniforms,c=r/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-d*d),p=.05+c*.95,A=h*p,{_lodMax:y}=this,m=this._sizeLods[r],x=3*m*(r>y-Nl?r-y+Nl:0),g=4*(this._cubeSize-m);l.envMap.value=e.texture,l.roughness.value=A,l.mipInt.value=y-t,yd(s,x,g,3*m,2*m),i.setRenderTarget(s),i.render(o,Lf),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=y-r,yd(e,x,g,3*m,2*m),i.setRenderTarget(e),i.render(o,Lf)}_blur(e,t,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&sn("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=c;const p=c.uniforms,A=this._sizeLods[r]-1,y=isFinite(s)?Math.PI/(2*A):2*Math.PI/(2*kc-1),m=s/y,x=isFinite(s)?1+Math.floor(d*m):kc;x>kc&&Pt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${kc}`);const g=[];let _=0;for(let M=0;M<kc;++M){const T=M/m,R=Math.exp(-T*T/2);g.push(R),M===0?_+=R:M<x&&(_+=2*R)}for(let M=0;M<g.length;M++)g[M]=g[M]/_;p.envMap.value=e.texture,p.samples.value=x,p.weights.value=g,p.latitudinal.value=a==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:b}=this;p.dTheta.value=y,p.mipInt.value=b-r;const w=this._sizeLods[i],I=3*w*(i>b-Nl?i-b+Nl:0),S=4*(this._cubeSize-w);yd(t,I,S,3*w,2*w),l.setRenderTarget(t),l.render(h,Lf)}}function Vq(n){const e=[],t=[],r=[];let i=n;const s=n-Nl+1+u3.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>n-Nl?l=u3[a-n+Nl-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),d=-c,h=1+c,p=[d,d,h,d,h,h,d,d,h,h,d,h],A=6,y=6,m=3,x=2,g=1,_=new Float32Array(m*y*A),b=new Float32Array(x*y*A),w=new Float32Array(g*y*A);for(let S=0;S<A;S++){const M=S%3*2/3-1,T=S>2?0:-1,R=[M,T,0,M+2/3,T,0,M+2/3,T+1,0,M,T,0,M+2/3,T+1,0,M,T+1,0];_.set(R,m*y*S),b.set(p,x*y*S);const k=[S,S,S,S,S,S];w.set(k,g*y*S)}const I=new _r;I.setAttribute("position",new or(_,m)),I.setAttribute("uv",new or(b,x)),I.setAttribute("faceIndex",new or(w,g)),r.push(new Jn(I,null)),i>Nl&&i--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function h3(n,e,t){const r=new Qa(n,e,t);return r.texture.mapping=z0,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function yd(n,e,t,r,i){n.viewport.set(e,t,r,i),n.scissor.set(e,t,r,i)}function Hq(n,e,t){return new ji({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:$q,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:V0(),fragmentShader:`
|
|
3642
3642
|
|
|
3643
3643
|
precision highp float;
|
|
3644
3644
|
precision highp int;
|
|
@@ -3898,7 +3898,7 @@ void main() {
|
|
|
3898
3898
|
}
|
|
3899
3899
|
`}function Wq(n){let e=new WeakMap,t=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===Mb||l===Tb,d=l===jd||l===Wd;if(c||d){let h=e.get(o);const p=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==p)return t===null&&(t=new hw(n)),h=c?t.fromEquirectangular(o,h):t.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const A=o.image;return c&&A&&A.height>0||d&&A&&i(A)?(t===null&&(t=new hw(n)),h=c?t.fromEquirectangular(o):t.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function i(o){let l=0;const c=6;for(let d=0;d<c;d++)o[d]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:r,dispose:a}}function qq(n){const e={};function t(r){if(e[r]!==void 0)return e[r];const i=n.getExtension(r);return e[r]=i,i}return{has:function(r){return t(r)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(r){const i=t(r);return i===null&&Dp("WebGLRenderer: "+r+" extension not supported."),i}}}function Yq(n,e,t,r){const i={},s=new WeakMap;function a(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const y in p.attributes)e.remove(p.attributes[y]);p.removeEventListener("dispose",a),delete i[p.id];const A=s.get(p);A&&(e.remove(A),s.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function o(h,p){return i[p.id]===!0||(p.addEventListener("dispose",a),i[p.id]=!0,t.memory.geometries++),p}function l(h){const p=h.attributes;for(const A in p)e.update(p[A],n.ARRAY_BUFFER)}function c(h){const p=[],A=h.index,y=h.attributes.position;let m=0;if(A!==null){const _=A.array;m=A.version;for(let b=0,w=_.length;b<w;b+=3){const I=_[b+0],S=_[b+1],M=_[b+2];p.push(I,S,S,M,M,I)}}else if(y!==void 0){const _=y.array;m=y.version;for(let b=0,w=_.length/3-1;b<w;b+=3){const I=b+0,S=b+1,M=b+2;p.push(I,S,S,M,M,I)}}else return;const x=new(YN(p)?tQ:eQ)(p,1);x.version=m;const g=s.get(h);g&&e.remove(g),s.set(h,x)}function d(h){const p=s.get(h);if(p){const A=h.index;A!==null&&p.version<A.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:d}}function Xq(n,e,t){let r;function i(p){r=p}let s,a;function o(p){s=p.type,a=p.bytesPerElement}function l(p,A){n.drawElements(r,A,s,p*a),t.update(A,r,1)}function c(p,A,y){y!==0&&(n.drawElementsInstanced(r,A,s,p*a,y),t.update(A,r,y))}function d(p,A,y){if(y===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,A,0,s,p,0,y);let x=0;for(let g=0;g<y;g++)x+=A[g];t.update(x,r,1)}function h(p,A,y,m){if(y===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let g=0;g<p.length;g++)c(p[g]/a,A[g],m[g]);else{x.multiDrawElementsInstancedWEBGL(r,A,0,s,p,0,m,0,y);let g=0;for(let _=0;_<y;_++)g+=A[_]*m[_];t.update(g,r,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=d,this.renderMultiDrawInstances=h}function Jq(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:sn("WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:r}}function Kq(n,e,t){const r=new WeakMap,i=new Kt;function s(a,o,l){const c=a.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=d!==void 0?d.length:0;let p=r.get(o);if(p===void 0||p.count!==h){let R=function(){M.dispose(),r.delete(o),o.removeEventListener("dispose",R)};p!==void 0&&p.texture.dispose();const A=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],_=o.morphAttributes.color||[];let b=0;A===!0&&(b=1),y===!0&&(b=2),m===!0&&(b=3);let w=o.attributes.position.count*b,I=1;w>e.maxTextureSize&&(I=Math.ceil(w/e.maxTextureSize),w=e.maxTextureSize);const S=new Float32Array(w*I*4*h),M=new Ta(S,w,I,h);M.type=js,M.needsUpdate=!0;const T=b*4;for(let k=0;k<h;k++){const H=x[k],Q=g[k],V=_[k],B=w*I*4*k;for(let W=0;W<H.count;W++){const K=W*T;A===!0&&(i.fromBufferAttribute(H,W),S[B+K+0]=i.x,S[B+K+1]=i.y,S[B+K+2]=i.z,S[B+K+3]=0),y===!0&&(i.fromBufferAttribute(Q,W),S[B+K+4]=i.x,S[B+K+5]=i.y,S[B+K+6]=i.z,S[B+K+7]=0),m===!0&&(i.fromBufferAttribute(V,W),S[B+K+8]=i.x,S[B+K+9]=i.y,S[B+K+10]=i.z,S[B+K+11]=V.itemSize===4?i.w:1)}}p={count:h,texture:M,size:new Dt(w,I)},r.set(o,p),o.addEventListener("dispose",R)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let A=0;for(let m=0;m<c.length;m++)A+=c[m];const y=o.morphTargetsRelative?1:1-A;l.getUniforms().setValue(n,"morphTargetBaseInfluence",y),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",p.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",p.size)}return{update:s}}function Zq(n,e,t,r){let i=new WeakMap;function s(l){const c=r.render.frame,d=l.geometry,h=e.get(l,d);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;i.get(p)!==c&&(p.update(),i.set(p,c))}return h}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const gQ=new ar,A3=new cQ(1,1),yQ=new Ta,xQ=new KN,vQ=new mh,m3=[],g3=[],y3=new Float32Array(16),x3=new Float32Array(9),v3=new Float32Array(4);function vh(n,e,t){const r=n[0];if(r<=0||r>0)return n;const i=e*t;let s=m3[i];if(s===void 0&&(s=new Float32Array(i),m3[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function yr(n,e){if(n.length!==e.length)return!1;for(let t=0,r=n.length;t<r;t++)if(n[t]!==e[t])return!1;return!0}function xr(n,e){for(let t=0,r=e.length;t<r;t++)n[t]=e[t]}function H0(n,e){let t=g3[e];t===void 0&&(t=new Int32Array(e),g3[e]=t);for(let r=0;r!==e;++r)t[r]=n.allocateTextureUnit();return t}function eY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function tY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(yr(t,e))return;n.uniform2fv(this.addr,e),xr(t,e)}}function nY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(yr(t,e))return;n.uniform3fv(this.addr,e),xr(t,e)}}function rY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(yr(t,e))return;n.uniform4fv(this.addr,e),xr(t,e)}}function iY(n,e){const t=this.cache,r=e.elements;if(r===void 0){if(yr(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),xr(t,e)}else{if(yr(t,r))return;v3.set(r),n.uniformMatrix2fv(this.addr,!1,v3),xr(t,r)}}function sY(n,e){const t=this.cache,r=e.elements;if(r===void 0){if(yr(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),xr(t,e)}else{if(yr(t,r))return;x3.set(r),n.uniformMatrix3fv(this.addr,!1,x3),xr(t,r)}}function aY(n,e){const t=this.cache,r=e.elements;if(r===void 0){if(yr(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),xr(t,e)}else{if(yr(t,r))return;y3.set(r),n.uniformMatrix4fv(this.addr,!1,y3),xr(t,r)}}function oY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function lY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(yr(t,e))return;n.uniform2iv(this.addr,e),xr(t,e)}}function cY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(yr(t,e))return;n.uniform3iv(this.addr,e),xr(t,e)}}function uY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(yr(t,e))return;n.uniform4iv(this.addr,e),xr(t,e)}}function dY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function hY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(yr(t,e))return;n.uniform2uiv(this.addr,e),xr(t,e)}}function fY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(yr(t,e))return;n.uniform3uiv(this.addr,e),xr(t,e)}}function pY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(yr(t,e))return;n.uniform4uiv(this.addr,e),xr(t,e)}}function AY(n,e,t){const r=this.cache,i=t.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i);let s;this.type===n.SAMPLER_2D_SHADOW?(A3.compareFunction=qN,s=A3):s=gQ,t.setTexture2D(e||s,i)}function mY(n,e,t){const r=this.cache,i=t.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i),t.setTexture3D(e||xQ,i)}function gY(n,e,t){const r=this.cache,i=t.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i),t.setTextureCube(e||vQ,i)}function yY(n,e,t){const r=this.cache,i=t.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i),t.setTexture2DArray(e||yQ,i)}function xY(n){switch(n){case 5126:return eY;case 35664:return tY;case 35665:return nY;case 35666:return rY;case 35674:return iY;case 35675:return sY;case 35676:return aY;case 5124:case 35670:return oY;case 35667:case 35671:return lY;case 35668:case 35672:return cY;case 35669:case 35673:return uY;case 5125:return dY;case 36294:return hY;case 36295:return fY;case 36296:return pY;case 35678:case 36198:case 36298:case 36306:case 35682:return AY;case 35679:case 36299:case 36307:return mY;case 35680:case 36300:case 36308:case 36293:return gY;case 36289:case 36303:case 36311:case 36292:return yY}}function vY(n,e){n.uniform1fv(this.addr,e)}function _Y(n,e){const t=vh(e,this.size,2);n.uniform2fv(this.addr,t)}function bY(n,e){const t=vh(e,this.size,3);n.uniform3fv(this.addr,t)}function wY(n,e){const t=vh(e,this.size,4);n.uniform4fv(this.addr,t)}function EY(n,e){const t=vh(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function IY(n,e){const t=vh(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function CY(n,e){const t=vh(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function SY(n,e){n.uniform1iv(this.addr,e)}function BY(n,e){n.uniform2iv(this.addr,e)}function MY(n,e){n.uniform3iv(this.addr,e)}function TY(n,e){n.uniform4iv(this.addr,e)}function RY(n,e){n.uniform1uiv(this.addr,e)}function DY(n,e){n.uniform2uiv(this.addr,e)}function kY(n,e){n.uniform3uiv(this.addr,e)}function NY(n,e){n.uniform4uiv(this.addr,e)}function QY(n,e,t){const r=this.cache,i=e.length,s=H0(t,i);yr(r,s)||(n.uniform1iv(this.addr,s),xr(r,s));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||gQ,s[a])}function PY(n,e,t){const r=this.cache,i=e.length,s=H0(t,i);yr(r,s)||(n.uniform1iv(this.addr,s),xr(r,s));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||xQ,s[a])}function LY(n,e,t){const r=this.cache,i=e.length,s=H0(t,i);yr(r,s)||(n.uniform1iv(this.addr,s),xr(r,s));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||vQ,s[a])}function FY(n,e,t){const r=this.cache,i=e.length,s=H0(t,i);yr(r,s)||(n.uniform1iv(this.addr,s),xr(r,s));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||yQ,s[a])}function zY(n){switch(n){case 5126:return vY;case 35664:return _Y;case 35665:return bY;case 35666:return wY;case 35674:return EY;case 35675:return IY;case 35676:return CY;case 5124:case 35670:return SY;case 35667:case 35671:return BY;case 35668:case 35672:return MY;case 35669:case 35673:return TY;case 5125:return RY;case 36294:return DY;case 36295:return kY;case 36296:return NY;case 35678:case 36198:case 36298:case 36306:case 35682:return QY;case 35679:case 36299:case 36307:return PY;case 35680:case 36300:case 36308:case 36293:return LY;case 36289:case 36303:case 36311:case 36292:return FY}}class UY{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.setValue=xY(t.type)}}class OY{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=zY(t.type)}}class $Y{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,r){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,t[o.id],r)}}}const Tv=/(\w+)(\])?(\[|\.)?/g;function _3(n,e){n.seq.push(e),n.map[e.id]=e}function GY(n,e,t){const r=n.name,i=r.length;for(Tv.lastIndex=0;;){const s=Tv.exec(r),a=Tv.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){_3(t,c===void 0?new UY(o,n,e):new OY(o,n,e));break}else{let h=t.map[o];h===void 0&&(h=new $Y(o),_3(t,h)),t=h}}}class _g{constructor(e,t){this.seq=[],this.map={};const r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(t,i),a=e.getUniformLocation(t,s.name);GY(s,a,this)}}setValue(e,t,r,i){const s=this.map[t];s!==void 0&&s.setValue(e,r,i)}setOptional(e,t,r){const i=t[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,t,r,i){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in t&&r.push(a)}return r}}function b3(n,e,t){const r=n.createShader(e);return n.shaderSource(r,t),n.compileShader(r),r}const VY=37297;let HY=0;function jY(n,e){const t=n.split(`
|
|
3900
3900
|
`),r=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=i;a<s;a++){const o=a+1;r.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return r.join(`
|
|
3901
|
-
`)}const w3=new Jt;function WY(n){mn._getMatrix(w3,mn.workingColorSpace,n);const e=`mat3( ${w3.elements.map(t=>t.toFixed(4))} )`;switch(mn.getTransfer(n)){case zg:return[e,"LinearTransferOETF"];case
|
|
3901
|
+
`)}const w3=new Jt;function WY(n){mn._getMatrix(w3,mn.workingColorSpace,n);const e=`mat3( ${w3.elements.map(t=>t.toFixed(4))} )`;switch(mn.getTransfer(n)){case zg:return[e,"LinearTransferOETF"];case Dn:return[e,"sRGBTransferOETF"];default:return Pt("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function E3(n,e,t){const r=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
|
|
3902
3902
|
|
|
3903
3903
|
`+s+`
|
|
3904
3904
|
|
|
@@ -3947,7 +3947,7 @@ Material Type: `+H.type+`
|
|
|
3947
3947
|
|
|
3948
3948
|
Program Info Log: `+W+`
|
|
3949
3949
|
`+ne+`
|
|
3950
|
-
`+L)}else W!==""?Pt("WebGLProgram: Program Info Log:",W):(K===""||X==="")&&(J=!1);J&&(H.diagnostics={runnable:$,programLog:W,vertexShader:{log:K,prefix:x},fragmentShader:{log:X,prefix:g}})}i.deleteShader(I),i.deleteShader(S),T=new _g(i,m),R=ZY(i,m)}let T;this.getUniforms=function(){return T===void 0&&M(this),T};let R;this.getAttributes=function(){return R===void 0&&M(this),R};let k=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(m,VY)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=HY++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=I,this.fragmentShader=S,this}let d7=0;class h7{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.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 r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new f7(e),t.set(e,r)),r}}class f7{constructor(e){this.id=d7++,this.code=e,this.usedTimes=0}}function p7(n,e,t,r,i,s,a){const o=new _I,l=new h7,c=new Set,d=[],h=i.logarithmicDepthBuffer,p=i.vertexTextures;let A=i.precision;const y={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(R){return c.add(R),R===0?"uv":`uv${R}`}function x(R,k,H,Q,V){const B=Q.fog,W=V.geometry,K=R.isMeshStandardMaterial?Q.environment:null,X=(R.isMeshStandardMaterial?t:e).get(R.envMap||K),$=X&&X.mapping===z0?X.image.height:null,J=y[R.type];R.precision!==null&&(A=i.getMaxPrecision(R.precision),A!==R.precision&&Pt("WebGLProgram.getParameters:",R.precision,"not supported, using",A,"instead."));const ne=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,L=ne!==void 0?ne.length:0;let G=0;W.morphAttributes.position!==void 0&&(G=1),W.morphAttributes.normal!==void 0&&(G=2),W.morphAttributes.color!==void 0&&(G=3);let oe,Ae,ye,he;if(J){const dn=_a[J];oe=dn.vertexShader,Ae=dn.fragmentShader}else oe=R.vertexShader,Ae=R.fragmentShader,l.update(R),ye=l.getVertexShaderID(R),he=l.getFragmentShaderID(R);const fe=n.getRenderTarget(),Ie=n.state.buffers.depth.getReversed(),Re=V.isInstancedMesh===!0,ge=V.isBatchedMesh===!0,Ne=!!R.map,tt=!!R.matcap,Ge=!!X,F=!!R.aoMap,re=!!R.lightMap,Ee=!!R.bumpMap,q=!!R.normalMap,ee=!!R.displacementMap,ie=!!R.emissiveMap,be=!!R.metalnessMap,ve=!!R.roughnessMap,ce=R.anisotropy>0,Z=R.clearcoat>0,Y=R.dispersion>0,le=R.iridescence>0,Ce=R.sheen>0,me=R.transmission>0,xe=ce&&!!R.anisotropyMap,st=Z&&!!R.clearcoatMap,He=Z&&!!R.clearcoatNormalMap,Ke=Z&&!!R.clearcoatRoughnessMap,nt=le&&!!R.iridescenceMap,ze=le&&!!R.iridescenceThicknessMap,Ze=Ce&&!!R.sheenColorMap,pt=Ce&&!!R.sheenRoughnessMap,ft=!!R.specularMap,dt=!!R.specularColorMap,Mt=!!R.specularIntensityMap,_e=me&&!!R.transmissionMap,ut=me&&!!R.thicknessMap,je=!!R.gradientMap,Ye=!!R.alphaMap,We=R.alphaTest>0,Ve=!!R.alphaHash,_t=!!R.extensions;let Ot=Pl;R.toneMapped&&(fe===null||fe.isXRRenderTarget===!0)&&(Ot=n.toneMapping);const En={shaderID:J,shaderType:R.type,shaderName:R.name,vertexShader:oe,fragmentShader:Ae,defines:R.defines,customVertexShaderID:ye,customFragmentShaderID:he,isRawShaderMaterial:R.isRawShaderMaterial===!0,glslVersion:R.glslVersion,precision:A,batching:ge,batchingColor:ge&&V._colorsTexture!==null,instancing:Re,instancingColor:Re&&V.instanceColor!==null,instancingMorph:Re&&V.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:fe===null?n.outputColorSpace:fe.isXRRenderTarget===!0?fe.texture.colorSpace:ri,alphaToCoverage:!!R.alphaToCoverage,map:Ne,matcap:tt,envMap:Ge,envMapMode:Ge&&X.mapping,envMapCubeUVHeight:$,aoMap:F,lightMap:re,bumpMap:Ee,normalMap:q,displacementMap:p&&ee,emissiveMap:ie,normalMapObjectSpace:q&&R.normalMapType===fH,normalMapTangentSpace:q&&R.normalMapType===yI,metalnessMap:be,roughnessMap:ve,anisotropy:ce,anisotropyMap:xe,clearcoat:Z,clearcoatMap:st,clearcoatNormalMap:He,clearcoatRoughnessMap:Ke,dispersion:Y,iridescence:le,iridescenceMap:nt,iridescenceThicknessMap:ze,sheen:Ce,sheenColorMap:Ze,sheenRoughnessMap:pt,specularMap:ft,specularColorMap:dt,specularIntensityMap:Mt,transmission:me,transmissionMap:_e,thicknessMap:ut,gradientMap:je,opaque:R.transparent===!1&&R.blending===Pd&&R.alphaToCoverage===!1,alphaMap:Ye,alphaTest:We,alphaHash:Ve,combine:R.combine,mapUv:Ne&&m(R.map.channel),aoMapUv:F&&m(R.aoMap.channel),lightMapUv:re&&m(R.lightMap.channel),bumpMapUv:Ee&&m(R.bumpMap.channel),normalMapUv:q&&m(R.normalMap.channel),displacementMapUv:ee&&m(R.displacementMap.channel),emissiveMapUv:ie&&m(R.emissiveMap.channel),metalnessMapUv:be&&m(R.metalnessMap.channel),roughnessMapUv:ve&&m(R.roughnessMap.channel),anisotropyMapUv:xe&&m(R.anisotropyMap.channel),clearcoatMapUv:st&&m(R.clearcoatMap.channel),clearcoatNormalMapUv:He&&m(R.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&m(R.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&m(R.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&m(R.iridescenceThicknessMap.channel),sheenColorMapUv:Ze&&m(R.sheenColorMap.channel),sheenRoughnessMapUv:pt&&m(R.sheenRoughnessMap.channel),specularMapUv:ft&&m(R.specularMap.channel),specularColorMapUv:dt&&m(R.specularColorMap.channel),specularIntensityMapUv:Mt&&m(R.specularIntensityMap.channel),transmissionMapUv:_e&&m(R.transmissionMap.channel),thicknessMapUv:ut&&m(R.thicknessMap.channel),alphaMapUv:Ye&&m(R.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(q||ce),vertexColors:R.vertexColors,vertexAlphas:R.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!W.attributes.uv&&(Ne||Ye),fog:!!B,useFog:R.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:R.flatShading===!0&&R.wireframe===!1,sizeAttenuation:R.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Ie,skinning:V.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:L,morphTextureStride:G,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:R.dithering,shadowMapEnabled:n.shadowMap.enabled&&H.length>0,shadowMapType:n.shadowMap.type,toneMapping:Ot,decodeVideoTexture:Ne&&R.map.isVideoTexture===!0&&mn.getTransfer(R.map.colorSpace)===Rn,decodeVideoTextureEmissive:ie&&R.emissiveMap.isVideoTexture===!0&&mn.getTransfer(R.emissiveMap.colorSpace)===Rn,premultipliedAlpha:R.premultipliedAlpha,doubleSided:R.side===rs,flipSided:R.side===Bi,useDepthPacking:R.depthPacking>=0,depthPacking:R.depthPacking||0,index0AttributeName:R.index0AttributeName,extensionClipCullDistance:_t&&R.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(_t&&R.extensions.multiDraw===!0||ge)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:R.customProgramCacheKey()};return En.vertexUv1s=c.has(1),En.vertexUv2s=c.has(2),En.vertexUv3s=c.has(3),c.clear(),En}function g(R){const k=[];if(R.shaderID?k.push(R.shaderID):(k.push(R.customVertexShaderID),k.push(R.customFragmentShaderID)),R.defines!==void 0)for(const H in R.defines)k.push(H),k.push(R.defines[H]);return R.isRawShaderMaterial===!1&&(_(k,R),b(k,R),k.push(n.outputColorSpace)),k.push(R.customProgramCacheKey),k.join()}function _(R,k){R.push(k.precision),R.push(k.outputColorSpace),R.push(k.envMapMode),R.push(k.envMapCubeUVHeight),R.push(k.mapUv),R.push(k.alphaMapUv),R.push(k.lightMapUv),R.push(k.aoMapUv),R.push(k.bumpMapUv),R.push(k.normalMapUv),R.push(k.displacementMapUv),R.push(k.emissiveMapUv),R.push(k.metalnessMapUv),R.push(k.roughnessMapUv),R.push(k.anisotropyMapUv),R.push(k.clearcoatMapUv),R.push(k.clearcoatNormalMapUv),R.push(k.clearcoatRoughnessMapUv),R.push(k.iridescenceMapUv),R.push(k.iridescenceThicknessMapUv),R.push(k.sheenColorMapUv),R.push(k.sheenRoughnessMapUv),R.push(k.specularMapUv),R.push(k.specularColorMapUv),R.push(k.specularIntensityMapUv),R.push(k.transmissionMapUv),R.push(k.thicknessMapUv),R.push(k.combine),R.push(k.fogExp2),R.push(k.sizeAttenuation),R.push(k.morphTargetsCount),R.push(k.morphAttributeCount),R.push(k.numDirLights),R.push(k.numPointLights),R.push(k.numSpotLights),R.push(k.numSpotLightMaps),R.push(k.numHemiLights),R.push(k.numRectAreaLights),R.push(k.numDirLightShadows),R.push(k.numPointLightShadows),R.push(k.numSpotLightShadows),R.push(k.numSpotLightShadowsWithMaps),R.push(k.numLightProbes),R.push(k.shadowMapType),R.push(k.toneMapping),R.push(k.numClippingPlanes),R.push(k.numClipIntersection),R.push(k.depthPacking)}function b(R,k){o.disableAll(),k.supportsVertexTextures&&o.enable(0),k.instancing&&o.enable(1),k.instancingColor&&o.enable(2),k.instancingMorph&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),k.dispersion&&o.enable(20),k.batchingColor&&o.enable(21),k.gradientMap&&o.enable(22),R.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.reversedDepthBuffer&&o.enable(4),k.skinning&&o.enable(5),k.morphTargets&&o.enable(6),k.morphNormals&&o.enable(7),k.morphColors&&o.enable(8),k.premultipliedAlpha&&o.enable(9),k.shadowMapEnabled&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),k.decodeVideoTextureEmissive&&o.enable(20),k.alphaToCoverage&&o.enable(21),R.push(o.mask)}function w(R){const k=y[R.type];let H;if(k){const Q=_a[k];H=n9.clone(Q.uniforms)}else H=R.uniforms;return H}function I(R,k){let H;for(let Q=0,V=d.length;Q<V;Q++){const B=d[Q];if(B.cacheKey===k){H=B,++H.usedTimes;break}}return H===void 0&&(H=new u7(n,k,R,s),d.push(H)),H}function S(R){if(--R.usedTimes===0){const k=d.indexOf(R);d[k]=d[d.length-1],d.pop(),R.destroy()}}function M(R){l.remove(R)}function T(){l.dispose()}return{getParameters:x,getProgramCacheKey:g,getUniforms:w,acquireProgram:I,releaseProgram:S,releaseShaderCache:M,programs:d,dispose:T}}function A7(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function r(a){n.delete(a)}function i(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:r,update:i,dispose:s}}function m7(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function M3(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function T3(){const n=[];let e=0;const t=[],r=[],i=[];function s(){e=0,t.length=0,r.length=0,i.length=0}function a(h,p,A,y,m,x){let g=n[e];return g===void 0?(g={id:h.id,object:h,geometry:p,material:A,groupOrder:y,renderOrder:h.renderOrder,z:m,group:x},n[e]=g):(g.id=h.id,g.object=h,g.geometry=p,g.material=A,g.groupOrder=y,g.renderOrder=h.renderOrder,g.z=m,g.group=x),e++,g}function o(h,p,A,y,m,x){const g=a(h,p,A,y,m,x);A.transmission>0?r.push(g):A.transparent===!0?i.push(g):t.push(g)}function l(h,p,A,y,m,x){const g=a(h,p,A,y,m,x);A.transmission>0?r.unshift(g):A.transparent===!0?i.unshift(g):t.unshift(g)}function c(h,p){t.length>1&&t.sort(h||m7),r.length>1&&r.sort(p||M3),i.length>1&&i.sort(p||M3)}function d(){for(let h=e,p=n.length;h<p;h++){const A=n[h];if(A.id===null)break;A.id=null,A.object=null,A.geometry=null,A.material=null,A.group=null}}return{opaque:t,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:d,sort:c}}function g7(){let n=new WeakMap;function e(r,i){const s=n.get(r);let a;return s===void 0?(a=new T3,n.set(r,[a])):i>=s.length?(a=new T3,s.push(a)):a=s[i],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function y7(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new de,color:new xt};break;case"SpotLight":t={position:new de,direction:new de,color:new xt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new de,color:new xt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new de,skyColor:new xt,groundColor:new xt};break;case"RectAreaLight":t={color:new xt,position:new de,halfWidth:new de,halfHeight:new de};break}return n[e.id]=t,t}}}function x7(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let v7=0;function _7(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function b7(n){const e=new y7,t=x7(),r={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 c=0;c<9;c++)r.probe.push(new de);const i=new de,s=new Ft,a=new Ft;function o(c){let d=0,h=0,p=0;for(let R=0;R<9;R++)r.probe[R].set(0,0,0);let A=0,y=0,m=0,x=0,g=0,_=0,b=0,w=0,I=0,S=0,M=0;c.sort(_7);for(let R=0,k=c.length;R<k;R++){const H=c[R],Q=H.color,V=H.intensity,B=H.distance,W=H.shadow&&H.shadow.map?H.shadow.map.texture:null;if(H.isAmbientLight)d+=Q.r*V,h+=Q.g*V,p+=Q.b*V;else if(H.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(H.sh.coefficients[K],V);M++}else if(H.isDirectionalLight){const K=e.get(H);if(K.color.copy(H.color).multiplyScalar(H.intensity),H.castShadow){const X=H.shadow,$=t.get(H);$.shadowIntensity=X.intensity,$.shadowBias=X.bias,$.shadowNormalBias=X.normalBias,$.shadowRadius=X.radius,$.shadowMapSize=X.mapSize,r.directionalShadow[A]=$,r.directionalShadowMap[A]=W,r.directionalShadowMatrix[A]=H.shadow.matrix,_++}r.directional[A]=K,A++}else if(H.isSpotLight){const K=e.get(H);K.position.setFromMatrixPosition(H.matrixWorld),K.color.copy(Q).multiplyScalar(V),K.distance=B,K.coneCos=Math.cos(H.angle),K.penumbraCos=Math.cos(H.angle*(1-H.penumbra)),K.decay=H.decay,r.spot[m]=K;const X=H.shadow;if(H.map&&(r.spotLightMap[I]=H.map,I++,X.updateMatrices(H),H.castShadow&&S++),r.spotLightMatrix[m]=X.matrix,H.castShadow){const $=t.get(H);$.shadowIntensity=X.intensity,$.shadowBias=X.bias,$.shadowNormalBias=X.normalBias,$.shadowRadius=X.radius,$.shadowMapSize=X.mapSize,r.spotShadow[m]=$,r.spotShadowMap[m]=W,w++}m++}else if(H.isRectAreaLight){const K=e.get(H);K.color.copy(Q).multiplyScalar(V),K.halfWidth.set(H.width*.5,0,0),K.halfHeight.set(0,H.height*.5,0),r.rectArea[x]=K,x++}else if(H.isPointLight){const K=e.get(H);if(K.color.copy(H.color).multiplyScalar(H.intensity),K.distance=H.distance,K.decay=H.decay,H.castShadow){const X=H.shadow,$=t.get(H);$.shadowIntensity=X.intensity,$.shadowBias=X.bias,$.shadowNormalBias=X.normalBias,$.shadowRadius=X.radius,$.shadowMapSize=X.mapSize,$.shadowCameraNear=X.camera.near,$.shadowCameraFar=X.camera.far,r.pointShadow[y]=$,r.pointShadowMap[y]=W,r.pointShadowMatrix[y]=H.shadow.matrix,b++}r.point[y]=K,y++}else if(H.isHemisphereLight){const K=e.get(H);K.skyColor.copy(H.color).multiplyScalar(V),K.groundColor.copy(H.groundColor).multiplyScalar(V),r.hemi[g]=K,g++}}x>0&&(n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=mt.LTC_FLOAT_1,r.rectAreaLTC2=mt.LTC_FLOAT_2):(r.rectAreaLTC1=mt.LTC_HALF_1,r.rectAreaLTC2=mt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=h,r.ambient[2]=p;const T=r.hash;(T.directionalLength!==A||T.pointLength!==y||T.spotLength!==m||T.rectAreaLength!==x||T.hemiLength!==g||T.numDirectionalShadows!==_||T.numPointShadows!==b||T.numSpotShadows!==w||T.numSpotMaps!==I||T.numLightProbes!==M)&&(r.directional.length=A,r.spot.length=m,r.rectArea.length=x,r.point.length=y,r.hemi.length=g,r.directionalShadow.length=_,r.directionalShadowMap.length=_,r.pointShadow.length=b,r.pointShadowMap.length=b,r.spotShadow.length=w,r.spotShadowMap.length=w,r.directionalShadowMatrix.length=_,r.pointShadowMatrix.length=b,r.spotLightMatrix.length=w+I-S,r.spotLightMap.length=I,r.numSpotLightShadowsWithMaps=S,r.numLightProbes=M,T.directionalLength=A,T.pointLength=y,T.spotLength=m,T.rectAreaLength=x,T.hemiLength=g,T.numDirectionalShadows=_,T.numPointShadows=b,T.numSpotShadows=w,T.numSpotMaps=I,T.numLightProbes=M,r.version=v7++)}function l(c,d){let h=0,p=0,A=0,y=0,m=0;const x=d.matrixWorldInverse;for(let g=0,_=c.length;g<_;g++){const b=c[g];if(b.isDirectionalLight){const w=r.directional[h];w.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(x),h++}else if(b.isSpotLight){const w=r.spot[A];w.position.setFromMatrixPosition(b.matrixWorld),w.position.applyMatrix4(x),w.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(x),A++}else if(b.isRectAreaLight){const w=r.rectArea[y];w.position.setFromMatrixPosition(b.matrixWorld),w.position.applyMatrix4(x),a.identity(),s.copy(b.matrixWorld),s.premultiply(x),a.extractRotation(s),w.halfWidth.set(b.width*.5,0,0),w.halfHeight.set(0,b.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),y++}else if(b.isPointLight){const w=r.point[p];w.position.setFromMatrixPosition(b.matrixWorld),w.position.applyMatrix4(x),p++}else if(b.isHemisphereLight){const w=r.hemi[m];w.direction.setFromMatrixPosition(b.matrixWorld),w.direction.transformDirection(x),m++}}}return{setup:o,setupView:l,state:r}}function R3(n){const e=new b7(n),t=[],r=[];function i(d){c.camera=d,t.length=0,r.length=0}function s(d){t.push(d)}function a(d){r.push(d)}function o(){e.setup(t)}function l(d){e.setupView(t,d)}const c={lightsArray:t,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function w7(n){let e=new WeakMap;function t(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new R3(n),e.set(i,[o])):s>=a.length?(o=new R3(n),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:t,dispose:r}}const E7=`void main() {
|
|
3950
|
+
`+L)}else W!==""?Pt("WebGLProgram: Program Info Log:",W):(K===""||X==="")&&(J=!1);J&&(H.diagnostics={runnable:$,programLog:W,vertexShader:{log:K,prefix:x},fragmentShader:{log:X,prefix:g}})}i.deleteShader(I),i.deleteShader(S),T=new _g(i,m),R=ZY(i,m)}let T;this.getUniforms=function(){return T===void 0&&M(this),T};let R;this.getAttributes=function(){return R===void 0&&M(this),R};let k=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(m,VY)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=HY++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=I,this.fragmentShader=S,this}let d7=0;class h7{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.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 r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new f7(e),t.set(e,r)),r}}class f7{constructor(e){this.id=d7++,this.code=e,this.usedTimes=0}}function p7(n,e,t,r,i,s,a){const o=new _I,l=new h7,c=new Set,d=[],h=i.logarithmicDepthBuffer,p=i.vertexTextures;let A=i.precision;const y={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(R){return c.add(R),R===0?"uv":`uv${R}`}function x(R,k,H,Q,V){const B=Q.fog,W=V.geometry,K=R.isMeshStandardMaterial?Q.environment:null,X=(R.isMeshStandardMaterial?t:e).get(R.envMap||K),$=X&&X.mapping===z0?X.image.height:null,J=y[R.type];R.precision!==null&&(A=i.getMaxPrecision(R.precision),A!==R.precision&&Pt("WebGLProgram.getParameters:",R.precision,"not supported, using",A,"instead."));const ne=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,L=ne!==void 0?ne.length:0;let G=0;W.morphAttributes.position!==void 0&&(G=1),W.morphAttributes.normal!==void 0&&(G=2),W.morphAttributes.color!==void 0&&(G=3);let oe,Ae,ye,he;if(J){const dn=_a[J];oe=dn.vertexShader,Ae=dn.fragmentShader}else oe=R.vertexShader,Ae=R.fragmentShader,l.update(R),ye=l.getVertexShaderID(R),he=l.getFragmentShaderID(R);const fe=n.getRenderTarget(),Ie=n.state.buffers.depth.getReversed(),Re=V.isInstancedMesh===!0,ge=V.isBatchedMesh===!0,Ne=!!R.map,tt=!!R.matcap,Ge=!!X,F=!!R.aoMap,re=!!R.lightMap,Ee=!!R.bumpMap,q=!!R.normalMap,ee=!!R.displacementMap,ie=!!R.emissiveMap,be=!!R.metalnessMap,ve=!!R.roughnessMap,ce=R.anisotropy>0,Z=R.clearcoat>0,Y=R.dispersion>0,le=R.iridescence>0,Ce=R.sheen>0,me=R.transmission>0,xe=ce&&!!R.anisotropyMap,st=Z&&!!R.clearcoatMap,He=Z&&!!R.clearcoatNormalMap,Ke=Z&&!!R.clearcoatRoughnessMap,nt=le&&!!R.iridescenceMap,ze=le&&!!R.iridescenceThicknessMap,Ze=Ce&&!!R.sheenColorMap,pt=Ce&&!!R.sheenRoughnessMap,ft=!!R.specularMap,dt=!!R.specularColorMap,Mt=!!R.specularIntensityMap,_e=me&&!!R.transmissionMap,ut=me&&!!R.thicknessMap,je=!!R.gradientMap,Ye=!!R.alphaMap,We=R.alphaTest>0,Ve=!!R.alphaHash,_t=!!R.extensions;let Ot=Pl;R.toneMapped&&(fe===null||fe.isXRRenderTarget===!0)&&(Ot=n.toneMapping);const En={shaderID:J,shaderType:R.type,shaderName:R.name,vertexShader:oe,fragmentShader:Ae,defines:R.defines,customVertexShaderID:ye,customFragmentShaderID:he,isRawShaderMaterial:R.isRawShaderMaterial===!0,glslVersion:R.glslVersion,precision:A,batching:ge,batchingColor:ge&&V._colorsTexture!==null,instancing:Re,instancingColor:Re&&V.instanceColor!==null,instancingMorph:Re&&V.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:fe===null?n.outputColorSpace:fe.isXRRenderTarget===!0?fe.texture.colorSpace:ri,alphaToCoverage:!!R.alphaToCoverage,map:Ne,matcap:tt,envMap:Ge,envMapMode:Ge&&X.mapping,envMapCubeUVHeight:$,aoMap:F,lightMap:re,bumpMap:Ee,normalMap:q,displacementMap:p&&ee,emissiveMap:ie,normalMapObjectSpace:q&&R.normalMapType===fH,normalMapTangentSpace:q&&R.normalMapType===yI,metalnessMap:be,roughnessMap:ve,anisotropy:ce,anisotropyMap:xe,clearcoat:Z,clearcoatMap:st,clearcoatNormalMap:He,clearcoatRoughnessMap:Ke,dispersion:Y,iridescence:le,iridescenceMap:nt,iridescenceThicknessMap:ze,sheen:Ce,sheenColorMap:Ze,sheenRoughnessMap:pt,specularMap:ft,specularColorMap:dt,specularIntensityMap:Mt,transmission:me,transmissionMap:_e,thicknessMap:ut,gradientMap:je,opaque:R.transparent===!1&&R.blending===Pd&&R.alphaToCoverage===!1,alphaMap:Ye,alphaTest:We,alphaHash:Ve,combine:R.combine,mapUv:Ne&&m(R.map.channel),aoMapUv:F&&m(R.aoMap.channel),lightMapUv:re&&m(R.lightMap.channel),bumpMapUv:Ee&&m(R.bumpMap.channel),normalMapUv:q&&m(R.normalMap.channel),displacementMapUv:ee&&m(R.displacementMap.channel),emissiveMapUv:ie&&m(R.emissiveMap.channel),metalnessMapUv:be&&m(R.metalnessMap.channel),roughnessMapUv:ve&&m(R.roughnessMap.channel),anisotropyMapUv:xe&&m(R.anisotropyMap.channel),clearcoatMapUv:st&&m(R.clearcoatMap.channel),clearcoatNormalMapUv:He&&m(R.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&m(R.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&m(R.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&m(R.iridescenceThicknessMap.channel),sheenColorMapUv:Ze&&m(R.sheenColorMap.channel),sheenRoughnessMapUv:pt&&m(R.sheenRoughnessMap.channel),specularMapUv:ft&&m(R.specularMap.channel),specularColorMapUv:dt&&m(R.specularColorMap.channel),specularIntensityMapUv:Mt&&m(R.specularIntensityMap.channel),transmissionMapUv:_e&&m(R.transmissionMap.channel),thicknessMapUv:ut&&m(R.thicknessMap.channel),alphaMapUv:Ye&&m(R.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(q||ce),vertexColors:R.vertexColors,vertexAlphas:R.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!W.attributes.uv&&(Ne||Ye),fog:!!B,useFog:R.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:R.flatShading===!0&&R.wireframe===!1,sizeAttenuation:R.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Ie,skinning:V.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:L,morphTextureStride:G,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:R.dithering,shadowMapEnabled:n.shadowMap.enabled&&H.length>0,shadowMapType:n.shadowMap.type,toneMapping:Ot,decodeVideoTexture:Ne&&R.map.isVideoTexture===!0&&mn.getTransfer(R.map.colorSpace)===Dn,decodeVideoTextureEmissive:ie&&R.emissiveMap.isVideoTexture===!0&&mn.getTransfer(R.emissiveMap.colorSpace)===Dn,premultipliedAlpha:R.premultipliedAlpha,doubleSided:R.side===rs,flipSided:R.side===Bi,useDepthPacking:R.depthPacking>=0,depthPacking:R.depthPacking||0,index0AttributeName:R.index0AttributeName,extensionClipCullDistance:_t&&R.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(_t&&R.extensions.multiDraw===!0||ge)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:R.customProgramCacheKey()};return En.vertexUv1s=c.has(1),En.vertexUv2s=c.has(2),En.vertexUv3s=c.has(3),c.clear(),En}function g(R){const k=[];if(R.shaderID?k.push(R.shaderID):(k.push(R.customVertexShaderID),k.push(R.customFragmentShaderID)),R.defines!==void 0)for(const H in R.defines)k.push(H),k.push(R.defines[H]);return R.isRawShaderMaterial===!1&&(_(k,R),b(k,R),k.push(n.outputColorSpace)),k.push(R.customProgramCacheKey),k.join()}function _(R,k){R.push(k.precision),R.push(k.outputColorSpace),R.push(k.envMapMode),R.push(k.envMapCubeUVHeight),R.push(k.mapUv),R.push(k.alphaMapUv),R.push(k.lightMapUv),R.push(k.aoMapUv),R.push(k.bumpMapUv),R.push(k.normalMapUv),R.push(k.displacementMapUv),R.push(k.emissiveMapUv),R.push(k.metalnessMapUv),R.push(k.roughnessMapUv),R.push(k.anisotropyMapUv),R.push(k.clearcoatMapUv),R.push(k.clearcoatNormalMapUv),R.push(k.clearcoatRoughnessMapUv),R.push(k.iridescenceMapUv),R.push(k.iridescenceThicknessMapUv),R.push(k.sheenColorMapUv),R.push(k.sheenRoughnessMapUv),R.push(k.specularMapUv),R.push(k.specularColorMapUv),R.push(k.specularIntensityMapUv),R.push(k.transmissionMapUv),R.push(k.thicknessMapUv),R.push(k.combine),R.push(k.fogExp2),R.push(k.sizeAttenuation),R.push(k.morphTargetsCount),R.push(k.morphAttributeCount),R.push(k.numDirLights),R.push(k.numPointLights),R.push(k.numSpotLights),R.push(k.numSpotLightMaps),R.push(k.numHemiLights),R.push(k.numRectAreaLights),R.push(k.numDirLightShadows),R.push(k.numPointLightShadows),R.push(k.numSpotLightShadows),R.push(k.numSpotLightShadowsWithMaps),R.push(k.numLightProbes),R.push(k.shadowMapType),R.push(k.toneMapping),R.push(k.numClippingPlanes),R.push(k.numClipIntersection),R.push(k.depthPacking)}function b(R,k){o.disableAll(),k.supportsVertexTextures&&o.enable(0),k.instancing&&o.enable(1),k.instancingColor&&o.enable(2),k.instancingMorph&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),k.dispersion&&o.enable(20),k.batchingColor&&o.enable(21),k.gradientMap&&o.enable(22),R.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.reversedDepthBuffer&&o.enable(4),k.skinning&&o.enable(5),k.morphTargets&&o.enable(6),k.morphNormals&&o.enable(7),k.morphColors&&o.enable(8),k.premultipliedAlpha&&o.enable(9),k.shadowMapEnabled&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),k.decodeVideoTextureEmissive&&o.enable(20),k.alphaToCoverage&&o.enable(21),R.push(o.mask)}function w(R){const k=y[R.type];let H;if(k){const Q=_a[k];H=n9.clone(Q.uniforms)}else H=R.uniforms;return H}function I(R,k){let H;for(let Q=0,V=d.length;Q<V;Q++){const B=d[Q];if(B.cacheKey===k){H=B,++H.usedTimes;break}}return H===void 0&&(H=new u7(n,k,R,s),d.push(H)),H}function S(R){if(--R.usedTimes===0){const k=d.indexOf(R);d[k]=d[d.length-1],d.pop(),R.destroy()}}function M(R){l.remove(R)}function T(){l.dispose()}return{getParameters:x,getProgramCacheKey:g,getUniforms:w,acquireProgram:I,releaseProgram:S,releaseShaderCache:M,programs:d,dispose:T}}function A7(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function r(a){n.delete(a)}function i(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:r,update:i,dispose:s}}function m7(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function M3(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function T3(){const n=[];let e=0;const t=[],r=[],i=[];function s(){e=0,t.length=0,r.length=0,i.length=0}function a(h,p,A,y,m,x){let g=n[e];return g===void 0?(g={id:h.id,object:h,geometry:p,material:A,groupOrder:y,renderOrder:h.renderOrder,z:m,group:x},n[e]=g):(g.id=h.id,g.object=h,g.geometry=p,g.material=A,g.groupOrder=y,g.renderOrder=h.renderOrder,g.z=m,g.group=x),e++,g}function o(h,p,A,y,m,x){const g=a(h,p,A,y,m,x);A.transmission>0?r.push(g):A.transparent===!0?i.push(g):t.push(g)}function l(h,p,A,y,m,x){const g=a(h,p,A,y,m,x);A.transmission>0?r.unshift(g):A.transparent===!0?i.unshift(g):t.unshift(g)}function c(h,p){t.length>1&&t.sort(h||m7),r.length>1&&r.sort(p||M3),i.length>1&&i.sort(p||M3)}function d(){for(let h=e,p=n.length;h<p;h++){const A=n[h];if(A.id===null)break;A.id=null,A.object=null,A.geometry=null,A.material=null,A.group=null}}return{opaque:t,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:d,sort:c}}function g7(){let n=new WeakMap;function e(r,i){const s=n.get(r);let a;return s===void 0?(a=new T3,n.set(r,[a])):i>=s.length?(a=new T3,s.push(a)):a=s[i],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function y7(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new de,color:new xt};break;case"SpotLight":t={position:new de,direction:new de,color:new xt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new de,color:new xt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new de,skyColor:new xt,groundColor:new xt};break;case"RectAreaLight":t={color:new xt,position:new de,halfWidth:new de,halfHeight:new de};break}return n[e.id]=t,t}}}function x7(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let v7=0;function _7(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function b7(n){const e=new y7,t=x7(),r={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 c=0;c<9;c++)r.probe.push(new de);const i=new de,s=new Ft,a=new Ft;function o(c){let d=0,h=0,p=0;for(let R=0;R<9;R++)r.probe[R].set(0,0,0);let A=0,y=0,m=0,x=0,g=0,_=0,b=0,w=0,I=0,S=0,M=0;c.sort(_7);for(let R=0,k=c.length;R<k;R++){const H=c[R],Q=H.color,V=H.intensity,B=H.distance,W=H.shadow&&H.shadow.map?H.shadow.map.texture:null;if(H.isAmbientLight)d+=Q.r*V,h+=Q.g*V,p+=Q.b*V;else if(H.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(H.sh.coefficients[K],V);M++}else if(H.isDirectionalLight){const K=e.get(H);if(K.color.copy(H.color).multiplyScalar(H.intensity),H.castShadow){const X=H.shadow,$=t.get(H);$.shadowIntensity=X.intensity,$.shadowBias=X.bias,$.shadowNormalBias=X.normalBias,$.shadowRadius=X.radius,$.shadowMapSize=X.mapSize,r.directionalShadow[A]=$,r.directionalShadowMap[A]=W,r.directionalShadowMatrix[A]=H.shadow.matrix,_++}r.directional[A]=K,A++}else if(H.isSpotLight){const K=e.get(H);K.position.setFromMatrixPosition(H.matrixWorld),K.color.copy(Q).multiplyScalar(V),K.distance=B,K.coneCos=Math.cos(H.angle),K.penumbraCos=Math.cos(H.angle*(1-H.penumbra)),K.decay=H.decay,r.spot[m]=K;const X=H.shadow;if(H.map&&(r.spotLightMap[I]=H.map,I++,X.updateMatrices(H),H.castShadow&&S++),r.spotLightMatrix[m]=X.matrix,H.castShadow){const $=t.get(H);$.shadowIntensity=X.intensity,$.shadowBias=X.bias,$.shadowNormalBias=X.normalBias,$.shadowRadius=X.radius,$.shadowMapSize=X.mapSize,r.spotShadow[m]=$,r.spotShadowMap[m]=W,w++}m++}else if(H.isRectAreaLight){const K=e.get(H);K.color.copy(Q).multiplyScalar(V),K.halfWidth.set(H.width*.5,0,0),K.halfHeight.set(0,H.height*.5,0),r.rectArea[x]=K,x++}else if(H.isPointLight){const K=e.get(H);if(K.color.copy(H.color).multiplyScalar(H.intensity),K.distance=H.distance,K.decay=H.decay,H.castShadow){const X=H.shadow,$=t.get(H);$.shadowIntensity=X.intensity,$.shadowBias=X.bias,$.shadowNormalBias=X.normalBias,$.shadowRadius=X.radius,$.shadowMapSize=X.mapSize,$.shadowCameraNear=X.camera.near,$.shadowCameraFar=X.camera.far,r.pointShadow[y]=$,r.pointShadowMap[y]=W,r.pointShadowMatrix[y]=H.shadow.matrix,b++}r.point[y]=K,y++}else if(H.isHemisphereLight){const K=e.get(H);K.skyColor.copy(H.color).multiplyScalar(V),K.groundColor.copy(H.groundColor).multiplyScalar(V),r.hemi[g]=K,g++}}x>0&&(n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=mt.LTC_FLOAT_1,r.rectAreaLTC2=mt.LTC_FLOAT_2):(r.rectAreaLTC1=mt.LTC_HALF_1,r.rectAreaLTC2=mt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=h,r.ambient[2]=p;const T=r.hash;(T.directionalLength!==A||T.pointLength!==y||T.spotLength!==m||T.rectAreaLength!==x||T.hemiLength!==g||T.numDirectionalShadows!==_||T.numPointShadows!==b||T.numSpotShadows!==w||T.numSpotMaps!==I||T.numLightProbes!==M)&&(r.directional.length=A,r.spot.length=m,r.rectArea.length=x,r.point.length=y,r.hemi.length=g,r.directionalShadow.length=_,r.directionalShadowMap.length=_,r.pointShadow.length=b,r.pointShadowMap.length=b,r.spotShadow.length=w,r.spotShadowMap.length=w,r.directionalShadowMatrix.length=_,r.pointShadowMatrix.length=b,r.spotLightMatrix.length=w+I-S,r.spotLightMap.length=I,r.numSpotLightShadowsWithMaps=S,r.numLightProbes=M,T.directionalLength=A,T.pointLength=y,T.spotLength=m,T.rectAreaLength=x,T.hemiLength=g,T.numDirectionalShadows=_,T.numPointShadows=b,T.numSpotShadows=w,T.numSpotMaps=I,T.numLightProbes=M,r.version=v7++)}function l(c,d){let h=0,p=0,A=0,y=0,m=0;const x=d.matrixWorldInverse;for(let g=0,_=c.length;g<_;g++){const b=c[g];if(b.isDirectionalLight){const w=r.directional[h];w.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(x),h++}else if(b.isSpotLight){const w=r.spot[A];w.position.setFromMatrixPosition(b.matrixWorld),w.position.applyMatrix4(x),w.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(x),A++}else if(b.isRectAreaLight){const w=r.rectArea[y];w.position.setFromMatrixPosition(b.matrixWorld),w.position.applyMatrix4(x),a.identity(),s.copy(b.matrixWorld),s.premultiply(x),a.extractRotation(s),w.halfWidth.set(b.width*.5,0,0),w.halfHeight.set(0,b.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),y++}else if(b.isPointLight){const w=r.point[p];w.position.setFromMatrixPosition(b.matrixWorld),w.position.applyMatrix4(x),p++}else if(b.isHemisphereLight){const w=r.hemi[m];w.direction.setFromMatrixPosition(b.matrixWorld),w.direction.transformDirection(x),m++}}}return{setup:o,setupView:l,state:r}}function R3(n){const e=new b7(n),t=[],r=[];function i(d){c.camera=d,t.length=0,r.length=0}function s(d){t.push(d)}function a(d){r.push(d)}function o(){e.setup(t)}function l(d){e.setupView(t,d)}const c={lightsArray:t,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function w7(n){let e=new WeakMap;function t(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new R3(n),e.set(i,[o])):s>=a.length?(o=new R3(n),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:t,dispose:r}}const E7=`void main() {
|
|
3951
3951
|
gl_Position = vec4( position, 1.0 );
|
|
3952
3952
|
}`,I7=`uniform sampler2D shadow_pass;
|
|
3953
3953
|
uniform vec2 resolution;
|
|
@@ -3975,7 +3975,7 @@ void main() {
|
|
|
3975
3975
|
squared_mean = squared_mean / samples;
|
|
3976
3976
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3977
3977
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3978
|
-
}`;function C7(n,e,t){let r=new EI;const i=new Dt,s=new Dt,a=new Kt,o=new v9({depthPacking:hH}),l=new _9,c={},d=t.maxTextureSize,h={[Eo]:Bi,[Bi]:Eo,[rs]:rs},p=new ji({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:E7,fragmentShader:I7}),A=p.clone();A.defines.HORIZONTAL_PASS=1;const y=new _r;y.setAttribute("position",new or(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Jn(y,p),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=PN;let g=this.type;this.render=function(S,M,T){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||S.length===0)return;const R=n.getRenderTarget(),k=n.getActiveCubeFace(),H=n.getActiveMipmapLevel(),Q=n.state;Q.setBlending(xo),Q.buffers.depth.getReversed()===!0?Q.buffers.color.setClear(0,0,0,0):Q.buffers.color.setClear(1,1,1,1),Q.buffers.depth.setTest(!0),Q.setScissorTest(!1);const V=g!==uo&&this.type===uo,B=g===uo&&this.type!==uo;for(let W=0,K=S.length;W<K;W++){const X=S[W],$=X.shadow;if($===void 0){Pt("WebGLShadowMap:",X,"has no shadow.");continue}if($.autoUpdate===!1&&$.needsUpdate===!1)continue;i.copy($.mapSize);const J=$.getFrameExtents();if(i.multiply(J),s.copy($.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/J.x),i.x=s.x*J.x,$.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/J.y),i.y=s.y*J.y,$.mapSize.y=s.y)),$.map===null||V===!0||B===!0){const L=this.type!==uo?{minFilter:mr,magFilter:mr}:{};$.map!==null&&$.map.dispose(),$.map=new Qa(i.x,i.y,L),$.map.texture.name=X.name+".shadowMap",$.camera.updateProjectionMatrix()}n.setRenderTarget($.map),n.clear();const ne=$.getViewportCount();for(let L=0;L<ne;L++){const G=$.getViewport(L);a.set(s.x*G.x,s.y*G.y,s.x*G.z,s.y*G.w),Q.viewport(a),$.updateMatrices(X,L),r=$.getFrustum(),w(M,T,$.camera,X,this.type)}$.isPointLightShadow!==!0&&this.type===uo&&_($,T),$.needsUpdate=!1}g=this.type,x.needsUpdate=!1,n.setRenderTarget(R,k,H)};function _(S,M){const T=e.update(m);p.defines.VSM_SAMPLES!==S.blurSamples&&(p.defines.VSM_SAMPLES=S.blurSamples,A.defines.VSM_SAMPLES=S.blurSamples,p.needsUpdate=!0,A.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new Qa(i.x,i.y)),p.uniforms.shadow_pass.value=S.map.texture,p.uniforms.resolution.value=S.mapSize,p.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(M,null,T,p,m,null),A.uniforms.shadow_pass.value=S.mapPass.texture,A.uniforms.resolution.value=S.mapSize,A.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(M,null,T,A,m,null)}function b(S,M,T,R){let k=null;const H=T.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(H!==void 0)k=H;else if(k=T.isPointLight===!0?l:o,n.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const Q=k.uuid,V=M.uuid;let B=c[Q];B===void 0&&(B={},c[Q]=B);let W=B[V];W===void 0&&(W=k.clone(),B[V]=W,M.addEventListener("dispose",I)),k=W}if(k.visible=M.visible,k.wireframe=M.wireframe,R===uo?k.side=M.shadowSide!==null?M.shadowSide:M.side:k.side=M.shadowSide!==null?M.shadowSide:h[M.side],k.alphaMap=M.alphaMap,k.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,k.map=M.map,k.clipShadows=M.clipShadows,k.clippingPlanes=M.clippingPlanes,k.clipIntersection=M.clipIntersection,k.displacementMap=M.displacementMap,k.displacementScale=M.displacementScale,k.displacementBias=M.displacementBias,k.wireframeLinewidth=M.wireframeLinewidth,k.linewidth=M.linewidth,T.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const Q=n.properties.get(k);Q.light=T}return k}function w(S,M,T,R,k){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&k===uo)&&(!S.frustumCulled||r.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,S.matrixWorld);const V=e.update(S),B=S.material;if(Array.isArray(B)){const W=V.groups;for(let K=0,X=W.length;K<X;K++){const $=W[K],J=B[$.materialIndex];if(J&&J.visible){const ne=b(S,J,R,k);S.onBeforeShadow(n,S,M,T,V,ne,$),n.renderBufferDirect(T,null,V,ne,S,$),S.onAfterShadow(n,S,M,T,V,ne,$)}}}else if(B.visible){const W=b(S,B,R,k);S.onBeforeShadow(n,S,M,T,V,W,null),n.renderBufferDirect(T,null,V,W,S,null),S.onAfterShadow(n,S,M,T,V,W,null)}}const Q=S.children;for(let V=0,B=Q.length;V<B;V++)w(Q[V],M,T,R,k)}function I(S){S.target.removeEventListener("dispose",I);for(const T in c){const R=c[T],k=S.target.uuid;k in R&&(R[k].dispose(),delete R[k])}}}const S7={[bb]:wb,[Eb]:Sb,[Ib]:Bb,[Hd]:Cb,[wb]:bb,[Sb]:Eb,[Bb]:Ib,[Cb]:Hd};function B7(n,e){function t(){let _e=!1;const ut=new Kt;let je=null;const Ye=new Kt(0,0,0,0);return{setMask:function(We){je!==We&&!_e&&(n.colorMask(We,We,We,We),je=We)},setLocked:function(We){_e=We},setClear:function(We,Ve,_t,Ot,En){En===!0&&(We*=Ot,Ve*=Ot,_t*=Ot),ut.set(We,Ve,_t,Ot),Ye.equals(ut)===!1&&(n.clearColor(We,Ve,_t,Ot),Ye.copy(ut))},reset:function(){_e=!1,je=null,Ye.set(-1,0,0,0)}}}function r(){let _e=!1,ut=!1,je=null,Ye=null,We=null;return{setReversed:function(Ve){if(ut!==Ve){const _t=e.get("EXT_clip_control");Ve?_t.clipControlEXT(_t.LOWER_LEFT_EXT,_t.ZERO_TO_ONE_EXT):_t.clipControlEXT(_t.LOWER_LEFT_EXT,_t.NEGATIVE_ONE_TO_ONE_EXT),ut=Ve;const Ot=We;We=null,this.setClear(Ot)}},getReversed:function(){return ut},setTest:function(Ve){Ve?fe(n.DEPTH_TEST):Ie(n.DEPTH_TEST)},setMask:function(Ve){je!==Ve&&!_e&&(n.depthMask(Ve),je=Ve)},setFunc:function(Ve){if(ut&&(Ve=S7[Ve]),Ye!==Ve){switch(Ve){case bb:n.depthFunc(n.NEVER);break;case wb:n.depthFunc(n.ALWAYS);break;case Eb:n.depthFunc(n.LESS);break;case Hd:n.depthFunc(n.LEQUAL);break;case Ib:n.depthFunc(n.EQUAL);break;case Cb:n.depthFunc(n.GEQUAL);break;case Sb:n.depthFunc(n.GREATER);break;case Bb:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Ye=Ve}},setLocked:function(Ve){_e=Ve},setClear:function(Ve){We!==Ve&&(ut&&(Ve=1-Ve),n.clearDepth(Ve),We=Ve)},reset:function(){_e=!1,je=null,Ye=null,We=null,ut=!1}}}function i(){let _e=!1,ut=null,je=null,Ye=null,We=null,Ve=null,_t=null,Ot=null,En=null;return{setTest:function(dn){_e||(dn?fe(n.STENCIL_TEST):Ie(n.STENCIL_TEST))},setMask:function(dn){ut!==dn&&!_e&&(n.stencilMask(dn),ut=dn)},setFunc:function(dn,hn,tr){(je!==dn||Ye!==hn||We!==tr)&&(n.stencilFunc(dn,hn,tr),je=dn,Ye=hn,We=tr)},setOp:function(dn,hn,tr){(Ve!==dn||_t!==hn||Ot!==tr)&&(n.stencilOp(dn,hn,tr),Ve=dn,_t=hn,Ot=tr)},setLocked:function(dn){_e=dn},setClear:function(dn){En!==dn&&(n.clearStencil(dn),En=dn)},reset:function(){_e=!1,ut=null,je=null,Ye=null,We=null,Ve=null,_t=null,Ot=null,En=null}}}const s=new t,a=new r,o=new i,l=new WeakMap,c=new WeakMap;let d={},h={},p=new WeakMap,A=[],y=null,m=!1,x=null,g=null,_=null,b=null,w=null,I=null,S=null,M=new xt(0,0,0),T=0,R=!1,k=null,H=null,Q=null,V=null,B=null;const W=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,X=0;const $=n.getParameter(n.VERSION);$.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec($)[1]),K=X>=1):$.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec($)[1]),K=X>=2);let J=null,ne={};const L=n.getParameter(n.SCISSOR_BOX),G=n.getParameter(n.VIEWPORT),oe=new Kt().fromArray(L),Ae=new Kt().fromArray(G);function ye(_e,ut,je,Ye){const We=new Uint8Array(4),Ve=n.createTexture();n.bindTexture(_e,Ve),n.texParameteri(_e,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(_e,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let _t=0;_t<je;_t++)_e===n.TEXTURE_3D||_e===n.TEXTURE_2D_ARRAY?n.texImage3D(ut,0,n.RGBA,1,1,Ye,0,n.RGBA,n.UNSIGNED_BYTE,We):n.texImage2D(ut+_t,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,We);return Ve}const he={};he[n.TEXTURE_2D]=ye(n.TEXTURE_2D,n.TEXTURE_2D,1),he[n.TEXTURE_CUBE_MAP]=ye(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),he[n.TEXTURE_2D_ARRAY]=ye(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),he[n.TEXTURE_3D]=ye(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),fe(n.DEPTH_TEST),a.setFunc(Hd),Ee(!1),q(AS),fe(n.CULL_FACE),F(xo);function fe(_e){d[_e]!==!0&&(n.enable(_e),d[_e]=!0)}function Ie(_e){d[_e]!==!1&&(n.disable(_e),d[_e]=!1)}function Re(_e,ut){return h[_e]!==ut?(n.bindFramebuffer(_e,ut),h[_e]=ut,_e===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=ut),_e===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=ut),!0):!1}function ge(_e,ut){let je=A,Ye=!1;if(_e){je=p.get(ut),je===void 0&&(je=[],p.set(ut,je));const We=_e.textures;if(je.length!==We.length||je[0]!==n.COLOR_ATTACHMENT0){for(let Ve=0,_t=We.length;Ve<_t;Ve++)je[Ve]=n.COLOR_ATTACHMENT0+Ve;je.length=We.length,Ye=!0}}else je[0]!==n.BACK&&(je[0]=n.BACK,Ye=!0);Ye&&n.drawBuffers(je)}function Ne(_e){return y!==_e?(n.useProgram(_e),y=_e,!0):!1}const tt={[Dc]:n.FUNC_ADD,[PV]:n.FUNC_SUBTRACT,[LV]:n.FUNC_REVERSE_SUBTRACT};tt[FV]=n.MIN,tt[zV]=n.MAX;const Ge={[UV]:n.ZERO,[OV]:n.ONE,[$V]:n.SRC_COLOR,[vb]:n.SRC_ALPHA,[qV]:n.SRC_ALPHA_SATURATE,[jV]:n.DST_COLOR,[VV]:n.DST_ALPHA,[GV]:n.ONE_MINUS_SRC_COLOR,[_b]:n.ONE_MINUS_SRC_ALPHA,[WV]:n.ONE_MINUS_DST_COLOR,[HV]:n.ONE_MINUS_DST_ALPHA,[YV]:n.CONSTANT_COLOR,[XV]:n.ONE_MINUS_CONSTANT_COLOR,[JV]:n.CONSTANT_ALPHA,[KV]:n.ONE_MINUS_CONSTANT_ALPHA};function F(_e,ut,je,Ye,We,Ve,_t,Ot,En,dn){if(_e===xo){m===!0&&(Ie(n.BLEND),m=!1);return}if(m===!1&&(fe(n.BLEND),m=!0),_e!==QV){if(_e!==x||dn!==R){if((g!==Dc||w!==Dc)&&(n.blendEquation(n.FUNC_ADD),g=Dc,w=Dc),dn)switch(_e){case Pd:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case mS:n.blendFunc(n.ONE,n.ONE);break;case gS:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case yS:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:sn("WebGLState: Invalid blending: ",_e);break}else switch(_e){case Pd:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case mS:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case gS:sn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case yS:sn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:sn("WebGLState: Invalid blending: ",_e);break}_=null,b=null,I=null,S=null,M.set(0,0,0),T=0,x=_e,R=dn}return}We=We||ut,Ve=Ve||je,_t=_t||Ye,(ut!==g||We!==w)&&(n.blendEquationSeparate(tt[ut],tt[We]),g=ut,w=We),(je!==_||Ye!==b||Ve!==I||_t!==S)&&(n.blendFuncSeparate(Ge[je],Ge[Ye],Ge[Ve],Ge[_t]),_=je,b=Ye,I=Ve,S=_t),(Ot.equals(M)===!1||En!==T)&&(n.blendColor(Ot.r,Ot.g,Ot.b,En),M.copy(Ot),T=En),x=_e,R=!1}function re(_e,ut){_e.side===rs?Ie(n.CULL_FACE):fe(n.CULL_FACE);let je=_e.side===Bi;ut&&(je=!je),Ee(je),_e.blending===Pd&&_e.transparent===!1?F(xo):F(_e.blending,_e.blendEquation,_e.blendSrc,_e.blendDst,_e.blendEquationAlpha,_e.blendSrcAlpha,_e.blendDstAlpha,_e.blendColor,_e.blendAlpha,_e.premultipliedAlpha),a.setFunc(_e.depthFunc),a.setTest(_e.depthTest),a.setMask(_e.depthWrite),s.setMask(_e.colorWrite);const Ye=_e.stencilWrite;o.setTest(Ye),Ye&&(o.setMask(_e.stencilWriteMask),o.setFunc(_e.stencilFunc,_e.stencilRef,_e.stencilFuncMask),o.setOp(_e.stencilFail,_e.stencilZFail,_e.stencilZPass)),ie(_e.polygonOffset,_e.polygonOffsetFactor,_e.polygonOffsetUnits),_e.alphaToCoverage===!0?fe(n.SAMPLE_ALPHA_TO_COVERAGE):Ie(n.SAMPLE_ALPHA_TO_COVERAGE)}function Ee(_e){k!==_e&&(_e?n.frontFace(n.CW):n.frontFace(n.CCW),k=_e)}function q(_e){_e!==kV?(fe(n.CULL_FACE),_e!==H&&(_e===AS?n.cullFace(n.BACK):_e===NV?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Ie(n.CULL_FACE),H=_e}function ee(_e){_e!==Q&&(K&&n.lineWidth(_e),Q=_e)}function ie(_e,ut,je){_e?(fe(n.POLYGON_OFFSET_FILL),(V!==ut||B!==je)&&(n.polygonOffset(ut,je),V=ut,B=je)):Ie(n.POLYGON_OFFSET_FILL)}function be(_e){_e?fe(n.SCISSOR_TEST):Ie(n.SCISSOR_TEST)}function ve(_e){_e===void 0&&(_e=n.TEXTURE0+W-1),J!==_e&&(n.activeTexture(_e),J=_e)}function ce(_e,ut,je){je===void 0&&(J===null?je=n.TEXTURE0+W-1:je=J);let Ye=ne[je];Ye===void 0&&(Ye={type:void 0,texture:void 0},ne[je]=Ye),(Ye.type!==_e||Ye.texture!==ut)&&(J!==je&&(n.activeTexture(je),J=je),n.bindTexture(_e,ut||he[_e]),Ye.type=_e,Ye.texture=ut)}function Z(){const _e=ne[J];_e!==void 0&&_e.type!==void 0&&(n.bindTexture(_e.type,null),_e.type=void 0,_e.texture=void 0)}function Y(){try{n.compressedTexImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function le(){try{n.compressedTexImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ce(){try{n.texSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function me(){try{n.texSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function xe(){try{n.compressedTexSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function st(){try{n.compressedTexSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function He(){try{n.texStorage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ke(){try{n.texStorage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function nt(){try{n.texImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function ze(){try{n.texImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ze(_e){oe.equals(_e)===!1&&(n.scissor(_e.x,_e.y,_e.z,_e.w),oe.copy(_e))}function pt(_e){Ae.equals(_e)===!1&&(n.viewport(_e.x,_e.y,_e.z,_e.w),Ae.copy(_e))}function ft(_e,ut){let je=c.get(ut);je===void 0&&(je=new WeakMap,c.set(ut,je));let Ye=je.get(_e);Ye===void 0&&(Ye=n.getUniformBlockIndex(ut,_e.name),je.set(_e,Ye))}function dt(_e,ut){const Ye=c.get(ut).get(_e);l.get(ut)!==Ye&&(n.uniformBlockBinding(ut,Ye,_e.__bindingPointIndex),l.set(ut,Ye))}function Mt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),d={},J=null,ne={},h={},p=new WeakMap,A=[],y=null,m=!1,x=null,g=null,_=null,b=null,w=null,I=null,S=null,M=new xt(0,0,0),T=0,R=!1,k=null,H=null,Q=null,V=null,B=null,oe.set(0,0,n.canvas.width,n.canvas.height),Ae.set(0,0,n.canvas.width,n.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:fe,disable:Ie,bindFramebuffer:Re,drawBuffers:ge,useProgram:Ne,setBlending:F,setMaterial:re,setFlipSided:Ee,setCullFace:q,setLineWidth:ee,setPolygonOffset:ie,setScissorTest:be,activeTexture:ve,bindTexture:ce,unbindTexture:Z,compressedTexImage2D:Y,compressedTexImage3D:le,texImage2D:nt,texImage3D:ze,updateUBOMapping:ft,uniformBlockBinding:dt,texStorage2D:He,texStorage3D:Ke,texSubImage2D:Ce,texSubImage3D:me,compressedTexSubImage2D:xe,compressedTexSubImage3D:st,scissor:Ze,viewport:pt,reset:Mt}}function M7(n,e,t,r,i,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Dt,d=new WeakMap;let h;const p=new WeakMap;let A=!1;try{A=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(Z,Y){return A?new OffscreenCanvas(Z,Y):Rp("canvas")}function m(Z,Y,le){let Ce=1;const me=ce(Z);if((me.width>le||me.height>le)&&(Ce=le/Math.max(me.width,me.height)),Ce<1)if(typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Z instanceof ImageBitmap||typeof VideoFrame<"u"&&Z instanceof VideoFrame){const xe=Math.floor(Ce*me.width),st=Math.floor(Ce*me.height);h===void 0&&(h=y(xe,st));const He=Y?y(xe,st):h;return He.width=xe,He.height=st,He.getContext("2d").drawImage(Z,0,0,xe,st),Pt("WebGLRenderer: Texture has been resized from ("+me.width+"x"+me.height+") to ("+xe+"x"+st+")."),He}else return"data"in Z&&Pt("WebGLRenderer: Image in DataTexture is too big ("+me.width+"x"+me.height+")."),Z;return Z}function x(Z){return Z.generateMipmaps}function g(Z){n.generateMipmap(Z)}function _(Z){return Z.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:Z.isWebGL3DRenderTarget?n.TEXTURE_3D:Z.isWebGLArrayRenderTarget||Z.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function b(Z,Y,le,Ce,me=!1){if(Z!==null){if(n[Z]!==void 0)return n[Z];Pt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Z+"'")}let xe=Y;if(Y===n.RED&&(le===n.FLOAT&&(xe=n.R32F),le===n.HALF_FLOAT&&(xe=n.R16F),le===n.UNSIGNED_BYTE&&(xe=n.R8)),Y===n.RED_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.R8UI),le===n.UNSIGNED_SHORT&&(xe=n.R16UI),le===n.UNSIGNED_INT&&(xe=n.R32UI),le===n.BYTE&&(xe=n.R8I),le===n.SHORT&&(xe=n.R16I),le===n.INT&&(xe=n.R32I)),Y===n.RG&&(le===n.FLOAT&&(xe=n.RG32F),le===n.HALF_FLOAT&&(xe=n.RG16F),le===n.UNSIGNED_BYTE&&(xe=n.RG8)),Y===n.RG_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.RG8UI),le===n.UNSIGNED_SHORT&&(xe=n.RG16UI),le===n.UNSIGNED_INT&&(xe=n.RG32UI),le===n.BYTE&&(xe=n.RG8I),le===n.SHORT&&(xe=n.RG16I),le===n.INT&&(xe=n.RG32I)),Y===n.RGB_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.RGB8UI),le===n.UNSIGNED_SHORT&&(xe=n.RGB16UI),le===n.UNSIGNED_INT&&(xe=n.RGB32UI),le===n.BYTE&&(xe=n.RGB8I),le===n.SHORT&&(xe=n.RGB16I),le===n.INT&&(xe=n.RGB32I)),Y===n.RGBA_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.RGBA8UI),le===n.UNSIGNED_SHORT&&(xe=n.RGBA16UI),le===n.UNSIGNED_INT&&(xe=n.RGBA32UI),le===n.BYTE&&(xe=n.RGBA8I),le===n.SHORT&&(xe=n.RGBA16I),le===n.INT&&(xe=n.RGBA32I)),Y===n.RGB&&(le===n.UNSIGNED_INT_5_9_9_9_REV&&(xe=n.RGB9_E5),le===n.UNSIGNED_INT_10F_11F_11F_REV&&(xe=n.R11F_G11F_B10F)),Y===n.RGBA){const st=me?zg:mn.getTransfer(Ce);le===n.FLOAT&&(xe=n.RGBA32F),le===n.HALF_FLOAT&&(xe=n.RGBA16F),le===n.UNSIGNED_BYTE&&(xe=st===Rn?n.SRGB8_ALPHA8:n.RGBA8),le===n.UNSIGNED_SHORT_4_4_4_4&&(xe=n.RGBA4),le===n.UNSIGNED_SHORT_5_5_5_1&&(xe=n.RGB5_A1)}return(xe===n.R16F||xe===n.R32F||xe===n.RG16F||xe===n.RG32F||xe===n.RGBA16F||xe===n.RGBA32F)&&e.get("EXT_color_buffer_float"),xe}function w(Z,Y){let le;return Z?Y===null||Y===Mi||Y===Cp?le=n.DEPTH24_STENCIL8:Y===js?le=n.DEPTH32F_STENCIL8:Y===Ip&&(le=n.DEPTH24_STENCIL8,Pt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):Y===null||Y===Mi||Y===Cp?le=n.DEPTH_COMPONENT24:Y===js?le=n.DEPTH_COMPONENT32F:Y===Ip&&(le=n.DEPTH_COMPONENT16),le}function I(Z,Y){return x(Z)===!0||Z.isFramebufferTexture&&Z.minFilter!==mr&&Z.minFilter!==ir?Math.log2(Math.max(Y.width,Y.height))+1:Z.mipmaps!==void 0&&Z.mipmaps.length>0?Z.mipmaps.length:Z.isCompressedTexture&&Array.isArray(Z.image)?Y.mipmaps.length:1}function S(Z){const Y=Z.target;Y.removeEventListener("dispose",S),T(Y),Y.isVideoTexture&&d.delete(Y)}function M(Z){const Y=Z.target;Y.removeEventListener("dispose",M),k(Y)}function T(Z){const Y=r.get(Z);if(Y.__webglInit===void 0)return;const le=Z.source,Ce=p.get(le);if(Ce){const me=Ce[Y.__cacheKey];me.usedTimes--,me.usedTimes===0&&R(Z),Object.keys(Ce).length===0&&p.delete(le)}r.remove(Z)}function R(Z){const Y=r.get(Z);n.deleteTexture(Y.__webglTexture);const le=Z.source,Ce=p.get(le);delete Ce[Y.__cacheKey],a.memory.textures--}function k(Z){const Y=r.get(Z);if(Z.depthTexture&&(Z.depthTexture.dispose(),r.remove(Z.depthTexture)),Z.isWebGLCubeRenderTarget)for(let Ce=0;Ce<6;Ce++){if(Array.isArray(Y.__webglFramebuffer[Ce]))for(let me=0;me<Y.__webglFramebuffer[Ce].length;me++)n.deleteFramebuffer(Y.__webglFramebuffer[Ce][me]);else n.deleteFramebuffer(Y.__webglFramebuffer[Ce]);Y.__webglDepthbuffer&&n.deleteRenderbuffer(Y.__webglDepthbuffer[Ce])}else{if(Array.isArray(Y.__webglFramebuffer))for(let Ce=0;Ce<Y.__webglFramebuffer.length;Ce++)n.deleteFramebuffer(Y.__webglFramebuffer[Ce]);else n.deleteFramebuffer(Y.__webglFramebuffer);if(Y.__webglDepthbuffer&&n.deleteRenderbuffer(Y.__webglDepthbuffer),Y.__webglMultisampledFramebuffer&&n.deleteFramebuffer(Y.__webglMultisampledFramebuffer),Y.__webglColorRenderbuffer)for(let Ce=0;Ce<Y.__webglColorRenderbuffer.length;Ce++)Y.__webglColorRenderbuffer[Ce]&&n.deleteRenderbuffer(Y.__webglColorRenderbuffer[Ce]);Y.__webglDepthRenderbuffer&&n.deleteRenderbuffer(Y.__webglDepthRenderbuffer)}const le=Z.textures;for(let Ce=0,me=le.length;Ce<me;Ce++){const xe=r.get(le[Ce]);xe.__webglTexture&&(n.deleteTexture(xe.__webglTexture),a.memory.textures--),r.remove(le[Ce])}r.remove(Z)}let H=0;function Q(){H=0}function V(){const Z=H;return Z>=i.maxTextures&&Pt("WebGLTextures: Trying to use "+Z+" texture units while this GPU supports only "+i.maxTextures),H+=1,Z}function B(Z){const Y=[];return Y.push(Z.wrapS),Y.push(Z.wrapT),Y.push(Z.wrapR||0),Y.push(Z.magFilter),Y.push(Z.minFilter),Y.push(Z.anisotropy),Y.push(Z.internalFormat),Y.push(Z.format),Y.push(Z.type),Y.push(Z.generateMipmaps),Y.push(Z.premultiplyAlpha),Y.push(Z.flipY),Y.push(Z.unpackAlignment),Y.push(Z.colorSpace),Y.join()}function W(Z,Y){const le=r.get(Z);if(Z.isVideoTexture&&be(Z),Z.isRenderTargetTexture===!1&&Z.isExternalTexture!==!0&&Z.version>0&&le.__version!==Z.version){const Ce=Z.image;if(Ce===null)Pt("WebGLRenderer: Texture marked for update but no image data found.");else if(Ce.complete===!1)Pt("WebGLRenderer: Texture marked for update but image is incomplete");else{he(le,Z,Y);return}}else Z.isExternalTexture&&(le.__webglTexture=Z.sourceTexture?Z.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,le.__webglTexture,n.TEXTURE0+Y)}function K(Z,Y){const le=r.get(Z);if(Z.isRenderTargetTexture===!1&&Z.version>0&&le.__version!==Z.version){he(le,Z,Y);return}else Z.isExternalTexture&&(le.__webglTexture=Z.sourceTexture?Z.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,le.__webglTexture,n.TEXTURE0+Y)}function X(Z,Y){const le=r.get(Z);if(Z.isRenderTargetTexture===!1&&Z.version>0&&le.__version!==Z.version){he(le,Z,Y);return}t.bindTexture(n.TEXTURE_3D,le.__webglTexture,n.TEXTURE0+Y)}function $(Z,Y){const le=r.get(Z);if(Z.version>0&&le.__version!==Z.version){fe(le,Z,Y);return}t.bindTexture(n.TEXTURE_CUBE_MAP,le.__webglTexture,n.TEXTURE0+Y)}const J={[Fl]:n.REPEAT,[os]:n.CLAMP_TO_EDGE,[Fg]:n.MIRRORED_REPEAT},ne={[mr]:n.NEAREST,[UN]:n.NEAREST_MIPMAP_NEAREST,[tp]:n.NEAREST_MIPMAP_LINEAR,[ir]:n.LINEAR,[mg]:n.LINEAR_MIPMAP_NEAREST,[Ia]:n.LINEAR_MIPMAP_LINEAR},L={[pH]:n.NEVER,[vH]:n.ALWAYS,[AH]:n.LESS,[qN]:n.LEQUAL,[mH]:n.EQUAL,[xH]:n.GEQUAL,[gH]:n.GREATER,[yH]:n.NOTEQUAL};function G(Z,Y){if(Y.type===js&&e.has("OES_texture_float_linear")===!1&&(Y.magFilter===ir||Y.magFilter===mg||Y.magFilter===tp||Y.magFilter===Ia||Y.minFilter===ir||Y.minFilter===mg||Y.minFilter===tp||Y.minFilter===Ia)&&Pt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(Z,n.TEXTURE_WRAP_S,J[Y.wrapS]),n.texParameteri(Z,n.TEXTURE_WRAP_T,J[Y.wrapT]),(Z===n.TEXTURE_3D||Z===n.TEXTURE_2D_ARRAY)&&n.texParameteri(Z,n.TEXTURE_WRAP_R,J[Y.wrapR]),n.texParameteri(Z,n.TEXTURE_MAG_FILTER,ne[Y.magFilter]),n.texParameteri(Z,n.TEXTURE_MIN_FILTER,ne[Y.minFilter]),Y.compareFunction&&(n.texParameteri(Z,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(Z,n.TEXTURE_COMPARE_FUNC,L[Y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(Y.magFilter===mr||Y.minFilter!==tp&&Y.minFilter!==Ia||Y.type===js&&e.has("OES_texture_float_linear")===!1)return;if(Y.anisotropy>1||r.get(Y).__currentAnisotropy){const le=e.get("EXT_texture_filter_anisotropic");n.texParameterf(Z,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Y.anisotropy,i.getMaxAnisotropy())),r.get(Y).__currentAnisotropy=Y.anisotropy}}}function oe(Z,Y){let le=!1;Z.__webglInit===void 0&&(Z.__webglInit=!0,Y.addEventListener("dispose",S));const Ce=Y.source;let me=p.get(Ce);me===void 0&&(me={},p.set(Ce,me));const xe=B(Y);if(xe!==Z.__cacheKey){me[xe]===void 0&&(me[xe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,le=!0),me[xe].usedTimes++;const st=me[Z.__cacheKey];st!==void 0&&(me[Z.__cacheKey].usedTimes--,st.usedTimes===0&&R(Y)),Z.__cacheKey=xe,Z.__webglTexture=me[xe].texture}return le}function Ae(Z,Y,le){return Math.floor(Math.floor(Z/le)/Y)}function ye(Z,Y,le,Ce){const xe=Z.updateRanges;if(xe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,Y.width,Y.height,le,Ce,Y.data);else{xe.sort((ze,Ze)=>ze.start-Ze.start);let st=0;for(let ze=1;ze<xe.length;ze++){const Ze=xe[st],pt=xe[ze],ft=Ze.start+Ze.count,dt=Ae(pt.start,Y.width,4),Mt=Ae(Ze.start,Y.width,4);pt.start<=ft+1&&dt===Mt&&Ae(pt.start+pt.count-1,Y.width,4)===dt?Ze.count=Math.max(Ze.count,pt.start+pt.count-Ze.start):(++st,xe[st]=pt)}xe.length=st+1;const He=n.getParameter(n.UNPACK_ROW_LENGTH),Ke=n.getParameter(n.UNPACK_SKIP_PIXELS),nt=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,Y.width);for(let ze=0,Ze=xe.length;ze<Ze;ze++){const pt=xe[ze],ft=Math.floor(pt.start/4),dt=Math.ceil(pt.count/4),Mt=ft%Y.width,_e=Math.floor(ft/Y.width),ut=dt,je=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,Mt),n.pixelStorei(n.UNPACK_SKIP_ROWS,_e),t.texSubImage2D(n.TEXTURE_2D,0,Mt,_e,ut,je,le,Ce,Y.data)}Z.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,He),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Ke),n.pixelStorei(n.UNPACK_SKIP_ROWS,nt)}}function he(Z,Y,le){let Ce=n.TEXTURE_2D;(Y.isDataArrayTexture||Y.isCompressedArrayTexture)&&(Ce=n.TEXTURE_2D_ARRAY),Y.isData3DTexture&&(Ce=n.TEXTURE_3D);const me=oe(Z,Y),xe=Y.source;t.bindTexture(Ce,Z.__webglTexture,n.TEXTURE0+le);const st=r.get(xe);if(xe.version!==st.__version||me===!0){t.activeTexture(n.TEXTURE0+le);const He=mn.getPrimaries(mn.workingColorSpace),Ke=Y.colorSpace===Dl?null:mn.getPrimaries(Y.colorSpace),nt=Y.colorSpace===Dl||He===Ke?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,Y.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Y.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,Y.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,nt);let ze=m(Y.image,!1,i.maxTextureSize);ze=ve(Y,ze);const Ze=s.convert(Y.format,Y.colorSpace),pt=s.convert(Y.type);let ft=b(Y.internalFormat,Ze,pt,Y.colorSpace,Y.isVideoTexture);G(Ce,Y);let dt;const Mt=Y.mipmaps,_e=Y.isVideoTexture!==!0,ut=st.__version===void 0||me===!0,je=xe.dataReady,Ye=I(Y,ze);if(Y.isDepthTexture)ft=w(Y.format===Bp,Y.type),ut&&(_e?t.texStorage2D(n.TEXTURE_2D,1,ft,ze.width,ze.height):t.texImage2D(n.TEXTURE_2D,0,ft,ze.width,ze.height,0,Ze,pt,null));else if(Y.isDataTexture)if(Mt.length>0){_e&&ut&&t.texStorage2D(n.TEXTURE_2D,Ye,ft,Mt[0].width,Mt[0].height);for(let We=0,Ve=Mt.length;We<Ve;We++)dt=Mt[We],_e?je&&t.texSubImage2D(n.TEXTURE_2D,We,0,0,dt.width,dt.height,Ze,pt,dt.data):t.texImage2D(n.TEXTURE_2D,We,ft,dt.width,dt.height,0,Ze,pt,dt.data);Y.generateMipmaps=!1}else _e?(ut&&t.texStorage2D(n.TEXTURE_2D,Ye,ft,ze.width,ze.height),je&&ye(Y,ze,Ze,pt)):t.texImage2D(n.TEXTURE_2D,0,ft,ze.width,ze.height,0,Ze,pt,ze.data);else if(Y.isCompressedTexture)if(Y.isCompressedArrayTexture){_e&&ut&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ye,ft,Mt[0].width,Mt[0].height,ze.depth);for(let We=0,Ve=Mt.length;We<Ve;We++)if(dt=Mt[We],Y.format!==sr)if(Ze!==null)if(_e){if(je)if(Y.layerUpdates.size>0){const _t=c3(dt.width,dt.height,Y.format,Y.type);for(const Ot of Y.layerUpdates){const En=dt.data.subarray(Ot*_t/dt.data.BYTES_PER_ELEMENT,(Ot+1)*_t/dt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,We,0,0,Ot,dt.width,dt.height,1,Ze,En)}Y.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,We,0,0,0,dt.width,dt.height,ze.depth,Ze,dt.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,We,ft,dt.width,dt.height,ze.depth,0,dt.data,0,0);else Pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else _e?je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,We,0,0,0,dt.width,dt.height,ze.depth,Ze,pt,dt.data):t.texImage3D(n.TEXTURE_2D_ARRAY,We,ft,dt.width,dt.height,ze.depth,0,Ze,pt,dt.data)}else{_e&&ut&&t.texStorage2D(n.TEXTURE_2D,Ye,ft,Mt[0].width,Mt[0].height);for(let We=0,Ve=Mt.length;We<Ve;We++)dt=Mt[We],Y.format!==sr?Ze!==null?_e?je&&t.compressedTexSubImage2D(n.TEXTURE_2D,We,0,0,dt.width,dt.height,Ze,dt.data):t.compressedTexImage2D(n.TEXTURE_2D,We,ft,dt.width,dt.height,0,dt.data):Pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):_e?je&&t.texSubImage2D(n.TEXTURE_2D,We,0,0,dt.width,dt.height,Ze,pt,dt.data):t.texImage2D(n.TEXTURE_2D,We,ft,dt.width,dt.height,0,Ze,pt,dt.data)}else if(Y.isDataArrayTexture)if(_e){if(ut&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ye,ft,ze.width,ze.height,ze.depth),je)if(Y.layerUpdates.size>0){const We=c3(ze.width,ze.height,Y.format,Y.type);for(const Ve of Y.layerUpdates){const _t=ze.data.subarray(Ve*We/ze.data.BYTES_PER_ELEMENT,(Ve+1)*We/ze.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Ve,ze.width,ze.height,1,Ze,pt,_t)}Y.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ze.width,ze.height,ze.depth,Ze,pt,ze.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ft,ze.width,ze.height,ze.depth,0,Ze,pt,ze.data);else if(Y.isData3DTexture)_e?(ut&&t.texStorage3D(n.TEXTURE_3D,Ye,ft,ze.width,ze.height,ze.depth),je&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ze.width,ze.height,ze.depth,Ze,pt,ze.data)):t.texImage3D(n.TEXTURE_3D,0,ft,ze.width,ze.height,ze.depth,0,Ze,pt,ze.data);else if(Y.isFramebufferTexture){if(ut)if(_e)t.texStorage2D(n.TEXTURE_2D,Ye,ft,ze.width,ze.height);else{let We=ze.width,Ve=ze.height;for(let _t=0;_t<Ye;_t++)t.texImage2D(n.TEXTURE_2D,_t,ft,We,Ve,0,Ze,pt,null),We>>=1,Ve>>=1}}else if(Mt.length>0){if(_e&&ut){const We=ce(Mt[0]);t.texStorage2D(n.TEXTURE_2D,Ye,ft,We.width,We.height)}for(let We=0,Ve=Mt.length;We<Ve;We++)dt=Mt[We],_e?je&&t.texSubImage2D(n.TEXTURE_2D,We,0,0,Ze,pt,dt):t.texImage2D(n.TEXTURE_2D,We,ft,Ze,pt,dt);Y.generateMipmaps=!1}else if(_e){if(ut){const We=ce(ze);t.texStorage2D(n.TEXTURE_2D,Ye,ft,We.width,We.height)}je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ze,pt,ze)}else t.texImage2D(n.TEXTURE_2D,0,ft,Ze,pt,ze);x(Y)&&g(Ce),st.__version=xe.version,Y.onUpdate&&Y.onUpdate(Y)}Z.__version=Y.version}function fe(Z,Y,le){if(Y.image.length!==6)return;const Ce=oe(Z,Y),me=Y.source;t.bindTexture(n.TEXTURE_CUBE_MAP,Z.__webglTexture,n.TEXTURE0+le);const xe=r.get(me);if(me.version!==xe.__version||Ce===!0){t.activeTexture(n.TEXTURE0+le);const st=mn.getPrimaries(mn.workingColorSpace),He=Y.colorSpace===Dl?null:mn.getPrimaries(Y.colorSpace),Ke=Y.colorSpace===Dl||st===He?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,Y.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Y.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,Y.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const nt=Y.isCompressedTexture||Y.image[0].isCompressedTexture,ze=Y.image[0]&&Y.image[0].isDataTexture,Ze=[];for(let Ve=0;Ve<6;Ve++)!nt&&!ze?Ze[Ve]=m(Y.image[Ve],!0,i.maxCubemapSize):Ze[Ve]=ze?Y.image[Ve].image:Y.image[Ve],Ze[Ve]=ve(Y,Ze[Ve]);const pt=Ze[0],ft=s.convert(Y.format,Y.colorSpace),dt=s.convert(Y.type),Mt=b(Y.internalFormat,ft,dt,Y.colorSpace),_e=Y.isVideoTexture!==!0,ut=xe.__version===void 0||Ce===!0,je=me.dataReady;let Ye=I(Y,pt);G(n.TEXTURE_CUBE_MAP,Y);let We;if(nt){_e&&ut&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ye,Mt,pt.width,pt.height);for(let Ve=0;Ve<6;Ve++){We=Ze[Ve].mipmaps;for(let _t=0;_t<We.length;_t++){const Ot=We[_t];Y.format!==sr?ft!==null?_e?je&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,0,0,Ot.width,Ot.height,ft,Ot.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,Mt,Ot.width,Ot.height,0,Ot.data):Pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,0,0,Ot.width,Ot.height,ft,dt,Ot.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,Mt,Ot.width,Ot.height,0,ft,dt,Ot.data)}}}else{if(We=Y.mipmaps,_e&&ut){We.length>0&&Ye++;const Ve=ce(Ze[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ye,Mt,Ve.width,Ve.height)}for(let Ve=0;Ve<6;Ve++)if(ze){_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,0,0,Ze[Ve].width,Ze[Ve].height,ft,dt,Ze[Ve].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,Mt,Ze[Ve].width,Ze[Ve].height,0,ft,dt,Ze[Ve].data);for(let _t=0;_t<We.length;_t++){const En=We[_t].image[Ve].image;_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,0,0,En.width,En.height,ft,dt,En.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,Mt,En.width,En.height,0,ft,dt,En.data)}}else{_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,0,0,ft,dt,Ze[Ve]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,Mt,ft,dt,Ze[Ve]);for(let _t=0;_t<We.length;_t++){const Ot=We[_t];_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,0,0,ft,dt,Ot.image[Ve]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,Mt,ft,dt,Ot.image[Ve])}}}x(Y)&&g(n.TEXTURE_CUBE_MAP),xe.__version=me.version,Y.onUpdate&&Y.onUpdate(Y)}Z.__version=Y.version}function Ie(Z,Y,le,Ce,me,xe){const st=s.convert(le.format,le.colorSpace),He=s.convert(le.type),Ke=b(le.internalFormat,st,He,le.colorSpace),nt=r.get(Y),ze=r.get(le);if(ze.__renderTarget=Y,!nt.__hasExternalTextures){const Ze=Math.max(1,Y.width>>xe),pt=Math.max(1,Y.height>>xe);me===n.TEXTURE_3D||me===n.TEXTURE_2D_ARRAY?t.texImage3D(me,xe,Ke,Ze,pt,Y.depth,0,st,He,null):t.texImage2D(me,xe,Ke,Ze,pt,0,st,He,null)}t.bindFramebuffer(n.FRAMEBUFFER,Z),ie(Y)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ce,me,ze.__webglTexture,0,ee(Y)):(me===n.TEXTURE_2D||me>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&me<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Ce,me,ze.__webglTexture,xe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Re(Z,Y,le){if(n.bindRenderbuffer(n.RENDERBUFFER,Z),Y.depthBuffer){const Ce=Y.depthTexture,me=Ce&&Ce.isDepthTexture?Ce.type:null,xe=w(Y.stencilBuffer,me),st=Y.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,He=ee(Y);ie(Y)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,He,xe,Y.width,Y.height):le?n.renderbufferStorageMultisample(n.RENDERBUFFER,He,xe,Y.width,Y.height):n.renderbufferStorage(n.RENDERBUFFER,xe,Y.width,Y.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,st,n.RENDERBUFFER,Z)}else{const Ce=Y.textures;for(let me=0;me<Ce.length;me++){const xe=Ce[me],st=s.convert(xe.format,xe.colorSpace),He=s.convert(xe.type),Ke=b(xe.internalFormat,st,He,xe.colorSpace),nt=ee(Y);le&&ie(Y)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,nt,Ke,Y.width,Y.height):ie(Y)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,nt,Ke,Y.width,Y.height):n.renderbufferStorage(n.RENDERBUFFER,Ke,Y.width,Y.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ge(Z,Y){if(Y&&Y.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,Z),!(Y.depthTexture&&Y.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Ce=r.get(Y.depthTexture);Ce.__renderTarget=Y,(!Ce.__webglTexture||Y.depthTexture.image.width!==Y.width||Y.depthTexture.image.height!==Y.height)&&(Y.depthTexture.image.width=Y.width,Y.depthTexture.image.height=Y.height,Y.depthTexture.needsUpdate=!0),W(Y.depthTexture,0);const me=Ce.__webglTexture,xe=ee(Y);if(Y.depthTexture.format===Sp)ie(Y)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,me,0,xe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,me,0);else if(Y.depthTexture.format===Bp)ie(Y)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,me,0,xe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,me,0);else throw new Error("Unknown depthTexture format")}function Ne(Z){const Y=r.get(Z),le=Z.isWebGLCubeRenderTarget===!0;if(Y.__boundDepthTexture!==Z.depthTexture){const Ce=Z.depthTexture;if(Y.__depthDisposeCallback&&Y.__depthDisposeCallback(),Ce){const me=()=>{delete Y.__boundDepthTexture,delete Y.__depthDisposeCallback,Ce.removeEventListener("dispose",me)};Ce.addEventListener("dispose",me),Y.__depthDisposeCallback=me}Y.__boundDepthTexture=Ce}if(Z.depthTexture&&!Y.__autoAllocateDepthBuffer){if(le)throw new Error("target.depthTexture not supported in Cube render targets");const Ce=Z.texture.mipmaps;Ce&&Ce.length>0?ge(Y.__webglFramebuffer[0],Z):ge(Y.__webglFramebuffer,Z)}else if(le){Y.__webglDepthbuffer=[];for(let Ce=0;Ce<6;Ce++)if(t.bindFramebuffer(n.FRAMEBUFFER,Y.__webglFramebuffer[Ce]),Y.__webglDepthbuffer[Ce]===void 0)Y.__webglDepthbuffer[Ce]=n.createRenderbuffer(),Re(Y.__webglDepthbuffer[Ce],Z,!1);else{const me=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,xe=Y.__webglDepthbuffer[Ce];n.bindRenderbuffer(n.RENDERBUFFER,xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,me,n.RENDERBUFFER,xe)}}else{const Ce=Z.texture.mipmaps;if(Ce&&Ce.length>0?t.bindFramebuffer(n.FRAMEBUFFER,Y.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,Y.__webglFramebuffer),Y.__webglDepthbuffer===void 0)Y.__webglDepthbuffer=n.createRenderbuffer(),Re(Y.__webglDepthbuffer,Z,!1);else{const me=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,xe=Y.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,me,n.RENDERBUFFER,xe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function tt(Z,Y,le){const Ce=r.get(Z);Y!==void 0&&Ie(Ce.__webglFramebuffer,Z,Z.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),le!==void 0&&Ne(Z)}function Ge(Z){const Y=Z.texture,le=r.get(Z),Ce=r.get(Y);Z.addEventListener("dispose",M);const me=Z.textures,xe=Z.isWebGLCubeRenderTarget===!0,st=me.length>1;if(st||(Ce.__webglTexture===void 0&&(Ce.__webglTexture=n.createTexture()),Ce.__version=Y.version,a.memory.textures++),xe){le.__webglFramebuffer=[];for(let He=0;He<6;He++)if(Y.mipmaps&&Y.mipmaps.length>0){le.__webglFramebuffer[He]=[];for(let Ke=0;Ke<Y.mipmaps.length;Ke++)le.__webglFramebuffer[He][Ke]=n.createFramebuffer()}else le.__webglFramebuffer[He]=n.createFramebuffer()}else{if(Y.mipmaps&&Y.mipmaps.length>0){le.__webglFramebuffer=[];for(let He=0;He<Y.mipmaps.length;He++)le.__webglFramebuffer[He]=n.createFramebuffer()}else le.__webglFramebuffer=n.createFramebuffer();if(st)for(let He=0,Ke=me.length;He<Ke;He++){const nt=r.get(me[He]);nt.__webglTexture===void 0&&(nt.__webglTexture=n.createTexture(),a.memory.textures++)}if(Z.samples>0&&ie(Z)===!1){le.__webglMultisampledFramebuffer=n.createFramebuffer(),le.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,le.__webglMultisampledFramebuffer);for(let He=0;He<me.length;He++){const Ke=me[He];le.__webglColorRenderbuffer[He]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,le.__webglColorRenderbuffer[He]);const nt=s.convert(Ke.format,Ke.colorSpace),ze=s.convert(Ke.type),Ze=b(Ke.internalFormat,nt,ze,Ke.colorSpace,Z.isXRRenderTarget===!0),pt=ee(Z);n.renderbufferStorageMultisample(n.RENDERBUFFER,pt,Ze,Z.width,Z.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+He,n.RENDERBUFFER,le.__webglColorRenderbuffer[He])}n.bindRenderbuffer(n.RENDERBUFFER,null),Z.depthBuffer&&(le.__webglDepthRenderbuffer=n.createRenderbuffer(),Re(le.__webglDepthRenderbuffer,Z,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(xe){t.bindTexture(n.TEXTURE_CUBE_MAP,Ce.__webglTexture),G(n.TEXTURE_CUBE_MAP,Y);for(let He=0;He<6;He++)if(Y.mipmaps&&Y.mipmaps.length>0)for(let Ke=0;Ke<Y.mipmaps.length;Ke++)Ie(le.__webglFramebuffer[He][Ke],Z,Y,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Ke);else Ie(le.__webglFramebuffer[He],Z,Y,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0);x(Y)&&g(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(st){for(let He=0,Ke=me.length;He<Ke;He++){const nt=me[He],ze=r.get(nt);let Ze=n.TEXTURE_2D;(Z.isWebGL3DRenderTarget||Z.isWebGLArrayRenderTarget)&&(Ze=Z.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ze,ze.__webglTexture),G(Ze,nt),Ie(le.__webglFramebuffer,Z,nt,n.COLOR_ATTACHMENT0+He,Ze,0),x(nt)&&g(Ze)}t.unbindTexture()}else{let He=n.TEXTURE_2D;if((Z.isWebGL3DRenderTarget||Z.isWebGLArrayRenderTarget)&&(He=Z.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(He,Ce.__webglTexture),G(He,Y),Y.mipmaps&&Y.mipmaps.length>0)for(let Ke=0;Ke<Y.mipmaps.length;Ke++)Ie(le.__webglFramebuffer[Ke],Z,Y,n.COLOR_ATTACHMENT0,He,Ke);else Ie(le.__webglFramebuffer,Z,Y,n.COLOR_ATTACHMENT0,He,0);x(Y)&&g(He),t.unbindTexture()}Z.depthBuffer&&Ne(Z)}function F(Z){const Y=Z.textures;for(let le=0,Ce=Y.length;le<Ce;le++){const me=Y[le];if(x(me)){const xe=_(Z),st=r.get(me).__webglTexture;t.bindTexture(xe,st),g(xe),t.unbindTexture()}}}const re=[],Ee=[];function q(Z){if(Z.samples>0){if(ie(Z)===!1){const Y=Z.textures,le=Z.width,Ce=Z.height;let me=n.COLOR_BUFFER_BIT;const xe=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,st=r.get(Z),He=Y.length>1;if(He)for(let nt=0;nt<Y.length;nt++)t.bindFramebuffer(n.FRAMEBUFFER,st.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,st.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,st.__webglMultisampledFramebuffer);const Ke=Z.texture.mipmaps;Ke&&Ke.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,st.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,st.__webglFramebuffer);for(let nt=0;nt<Y.length;nt++){if(Z.resolveDepthBuffer&&(Z.depthBuffer&&(me|=n.DEPTH_BUFFER_BIT),Z.stencilBuffer&&Z.resolveStencilBuffer&&(me|=n.STENCIL_BUFFER_BIT)),He){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,st.__webglColorRenderbuffer[nt]);const ze=r.get(Y[nt]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ze,0)}n.blitFramebuffer(0,0,le,Ce,0,0,le,Ce,me,n.NEAREST),l===!0&&(re.length=0,Ee.length=0,re.push(n.COLOR_ATTACHMENT0+nt),Z.depthBuffer&&Z.resolveDepthBuffer===!1&&(re.push(xe),Ee.push(xe),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ee)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,re))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),He)for(let nt=0;nt<Y.length;nt++){t.bindFramebuffer(n.FRAMEBUFFER,st.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.RENDERBUFFER,st.__webglColorRenderbuffer[nt]);const ze=r.get(Y[nt]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,st.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.TEXTURE_2D,ze,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,st.__webglMultisampledFramebuffer)}else if(Z.depthBuffer&&Z.resolveDepthBuffer===!1&&l){const Y=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[Y])}}}function ee(Z){return Math.min(i.maxSamples,Z.samples)}function ie(Z){const Y=r.get(Z);return Z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Y.__useRenderToTexture!==!1}function be(Z){const Y=a.render.frame;d.get(Z)!==Y&&(d.set(Z,Y),Z.update())}function ve(Z,Y){const le=Z.colorSpace,Ce=Z.format,me=Z.type;return Z.isCompressedTexture===!0||Z.isVideoTexture===!0||le!==ri&&le!==Dl&&(mn.getTransfer(le)===Rn?(Ce!==sr||me!==ni)&&Pt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):sn("WebGLTextures: Unsupported texture color space:",le)),Y}function ce(Z){return typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement?(c.width=Z.naturalWidth||Z.width,c.height=Z.naturalHeight||Z.height):typeof VideoFrame<"u"&&Z instanceof VideoFrame?(c.width=Z.displayWidth,c.height=Z.displayHeight):(c.width=Z.width,c.height=Z.height),c}this.allocateTextureUnit=V,this.resetTextureUnits=Q,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=X,this.setTextureCube=$,this.rebindTextures=tt,this.setupRenderTarget=Ge,this.updateRenderTargetMipmap=F,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Ie,this.useMultisampledRTT=ie}function T7(n,e){function t(r,i=Dl){let s;const a=mn.getTransfer(i);if(r===ni)return n.UNSIGNED_BYTE;if(r===fI)return n.UNSIGNED_SHORT_4_4_4_4;if(r===pI)return n.UNSIGNED_SHORT_5_5_5_1;if(r===GN)return n.UNSIGNED_INT_5_9_9_9_REV;if(r===VN)return n.UNSIGNED_INT_10F_11F_11F_REV;if(r===ON)return n.BYTE;if(r===$N)return n.SHORT;if(r===Ip)return n.UNSIGNED_SHORT;if(r===hI)return n.INT;if(r===Mi)return n.UNSIGNED_INT;if(r===js)return n.FLOAT;if(r===fh)return n.HALF_FLOAT;if(r===HN)return n.ALPHA;if(r===jN)return n.RGB;if(r===sr)return n.RGBA;if(r===Sp)return n.DEPTH_COMPONENT;if(r===Bp)return n.DEPTH_STENCIL;if(r===AI)return n.RED;if(r===mI)return n.RED_INTEGER;if(r===gI)return n.RG;if(r===U0)return n.RG_INTEGER;if(r===vo)return n.RGBA_INTEGER;if(r===gg||r===yg||r===xg||r===vg)if(a===Rn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===gg)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===yg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===xg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===vg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===gg)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===yg)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===xg)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===vg)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Rb||r===Db||r===kb||r===Nb)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===Rb)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Db)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===kb)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Nb)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Qb||r===Pb||r===Lb)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===Qb||r===Pb)return a===Rn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===Lb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Fb||r===zb||r===Ub||r===Ob||r===$b||r===Gb||r===Vb||r===Hb||r===jb||r===Wb||r===qb||r===Yb||r===Xb||r===Jb)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===Fb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===zb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Ub)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Ob)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===$b)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Gb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Vb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Hb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===jb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Wb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===qb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Yb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Xb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Jb)return a===Rn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Kb||r===Zb||r===ew)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===Kb)return a===Rn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Zb)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===ew)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===tw||r===nw||r===rw||r===iw)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===tw)return s.COMPRESSED_RED_RGTC1_EXT;if(r===nw)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===rw)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===iw)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Cp?n.UNSIGNED_INT_24_8:n[r]!==void 0?n[r]:null}return{convert:t}}const R7=`
|
|
3978
|
+
}`;function C7(n,e,t){let r=new EI;const i=new Dt,s=new Dt,a=new Kt,o=new v9({depthPacking:hH}),l=new _9,c={},d=t.maxTextureSize,h={[Eo]:Bi,[Bi]:Eo,[rs]:rs},p=new ji({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:E7,fragmentShader:I7}),A=p.clone();A.defines.HORIZONTAL_PASS=1;const y=new _r;y.setAttribute("position",new or(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Jn(y,p),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=PN;let g=this.type;this.render=function(S,M,T){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||S.length===0)return;const R=n.getRenderTarget(),k=n.getActiveCubeFace(),H=n.getActiveMipmapLevel(),Q=n.state;Q.setBlending(xo),Q.buffers.depth.getReversed()===!0?Q.buffers.color.setClear(0,0,0,0):Q.buffers.color.setClear(1,1,1,1),Q.buffers.depth.setTest(!0),Q.setScissorTest(!1);const V=g!==uo&&this.type===uo,B=g===uo&&this.type!==uo;for(let W=0,K=S.length;W<K;W++){const X=S[W],$=X.shadow;if($===void 0){Pt("WebGLShadowMap:",X,"has no shadow.");continue}if($.autoUpdate===!1&&$.needsUpdate===!1)continue;i.copy($.mapSize);const J=$.getFrameExtents();if(i.multiply(J),s.copy($.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/J.x),i.x=s.x*J.x,$.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/J.y),i.y=s.y*J.y,$.mapSize.y=s.y)),$.map===null||V===!0||B===!0){const L=this.type!==uo?{minFilter:mr,magFilter:mr}:{};$.map!==null&&$.map.dispose(),$.map=new Qa(i.x,i.y,L),$.map.texture.name=X.name+".shadowMap",$.camera.updateProjectionMatrix()}n.setRenderTarget($.map),n.clear();const ne=$.getViewportCount();for(let L=0;L<ne;L++){const G=$.getViewport(L);a.set(s.x*G.x,s.y*G.y,s.x*G.z,s.y*G.w),Q.viewport(a),$.updateMatrices(X,L),r=$.getFrustum(),w(M,T,$.camera,X,this.type)}$.isPointLightShadow!==!0&&this.type===uo&&_($,T),$.needsUpdate=!1}g=this.type,x.needsUpdate=!1,n.setRenderTarget(R,k,H)};function _(S,M){const T=e.update(m);p.defines.VSM_SAMPLES!==S.blurSamples&&(p.defines.VSM_SAMPLES=S.blurSamples,A.defines.VSM_SAMPLES=S.blurSamples,p.needsUpdate=!0,A.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new Qa(i.x,i.y)),p.uniforms.shadow_pass.value=S.map.texture,p.uniforms.resolution.value=S.mapSize,p.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(M,null,T,p,m,null),A.uniforms.shadow_pass.value=S.mapPass.texture,A.uniforms.resolution.value=S.mapSize,A.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(M,null,T,A,m,null)}function b(S,M,T,R){let k=null;const H=T.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(H!==void 0)k=H;else if(k=T.isPointLight===!0?l:o,n.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const Q=k.uuid,V=M.uuid;let B=c[Q];B===void 0&&(B={},c[Q]=B);let W=B[V];W===void 0&&(W=k.clone(),B[V]=W,M.addEventListener("dispose",I)),k=W}if(k.visible=M.visible,k.wireframe=M.wireframe,R===uo?k.side=M.shadowSide!==null?M.shadowSide:M.side:k.side=M.shadowSide!==null?M.shadowSide:h[M.side],k.alphaMap=M.alphaMap,k.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,k.map=M.map,k.clipShadows=M.clipShadows,k.clippingPlanes=M.clippingPlanes,k.clipIntersection=M.clipIntersection,k.displacementMap=M.displacementMap,k.displacementScale=M.displacementScale,k.displacementBias=M.displacementBias,k.wireframeLinewidth=M.wireframeLinewidth,k.linewidth=M.linewidth,T.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const Q=n.properties.get(k);Q.light=T}return k}function w(S,M,T,R,k){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&k===uo)&&(!S.frustumCulled||r.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,S.matrixWorld);const V=e.update(S),B=S.material;if(Array.isArray(B)){const W=V.groups;for(let K=0,X=W.length;K<X;K++){const $=W[K],J=B[$.materialIndex];if(J&&J.visible){const ne=b(S,J,R,k);S.onBeforeShadow(n,S,M,T,V,ne,$),n.renderBufferDirect(T,null,V,ne,S,$),S.onAfterShadow(n,S,M,T,V,ne,$)}}}else if(B.visible){const W=b(S,B,R,k);S.onBeforeShadow(n,S,M,T,V,W,null),n.renderBufferDirect(T,null,V,W,S,null),S.onAfterShadow(n,S,M,T,V,W,null)}}const Q=S.children;for(let V=0,B=Q.length;V<B;V++)w(Q[V],M,T,R,k)}function I(S){S.target.removeEventListener("dispose",I);for(const T in c){const R=c[T],k=S.target.uuid;k in R&&(R[k].dispose(),delete R[k])}}}const S7={[bb]:wb,[Eb]:Sb,[Ib]:Bb,[Hd]:Cb,[wb]:bb,[Sb]:Eb,[Bb]:Ib,[Cb]:Hd};function B7(n,e){function t(){let _e=!1;const ut=new Kt;let je=null;const Ye=new Kt(0,0,0,0);return{setMask:function(We){je!==We&&!_e&&(n.colorMask(We,We,We,We),je=We)},setLocked:function(We){_e=We},setClear:function(We,Ve,_t,Ot,En){En===!0&&(We*=Ot,Ve*=Ot,_t*=Ot),ut.set(We,Ve,_t,Ot),Ye.equals(ut)===!1&&(n.clearColor(We,Ve,_t,Ot),Ye.copy(ut))},reset:function(){_e=!1,je=null,Ye.set(-1,0,0,0)}}}function r(){let _e=!1,ut=!1,je=null,Ye=null,We=null;return{setReversed:function(Ve){if(ut!==Ve){const _t=e.get("EXT_clip_control");Ve?_t.clipControlEXT(_t.LOWER_LEFT_EXT,_t.ZERO_TO_ONE_EXT):_t.clipControlEXT(_t.LOWER_LEFT_EXT,_t.NEGATIVE_ONE_TO_ONE_EXT),ut=Ve;const Ot=We;We=null,this.setClear(Ot)}},getReversed:function(){return ut},setTest:function(Ve){Ve?fe(n.DEPTH_TEST):Ie(n.DEPTH_TEST)},setMask:function(Ve){je!==Ve&&!_e&&(n.depthMask(Ve),je=Ve)},setFunc:function(Ve){if(ut&&(Ve=S7[Ve]),Ye!==Ve){switch(Ve){case bb:n.depthFunc(n.NEVER);break;case wb:n.depthFunc(n.ALWAYS);break;case Eb:n.depthFunc(n.LESS);break;case Hd:n.depthFunc(n.LEQUAL);break;case Ib:n.depthFunc(n.EQUAL);break;case Cb:n.depthFunc(n.GEQUAL);break;case Sb:n.depthFunc(n.GREATER);break;case Bb:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Ye=Ve}},setLocked:function(Ve){_e=Ve},setClear:function(Ve){We!==Ve&&(ut&&(Ve=1-Ve),n.clearDepth(Ve),We=Ve)},reset:function(){_e=!1,je=null,Ye=null,We=null,ut=!1}}}function i(){let _e=!1,ut=null,je=null,Ye=null,We=null,Ve=null,_t=null,Ot=null,En=null;return{setTest:function(dn){_e||(dn?fe(n.STENCIL_TEST):Ie(n.STENCIL_TEST))},setMask:function(dn){ut!==dn&&!_e&&(n.stencilMask(dn),ut=dn)},setFunc:function(dn,hn,tr){(je!==dn||Ye!==hn||We!==tr)&&(n.stencilFunc(dn,hn,tr),je=dn,Ye=hn,We=tr)},setOp:function(dn,hn,tr){(Ve!==dn||_t!==hn||Ot!==tr)&&(n.stencilOp(dn,hn,tr),Ve=dn,_t=hn,Ot=tr)},setLocked:function(dn){_e=dn},setClear:function(dn){En!==dn&&(n.clearStencil(dn),En=dn)},reset:function(){_e=!1,ut=null,je=null,Ye=null,We=null,Ve=null,_t=null,Ot=null,En=null}}}const s=new t,a=new r,o=new i,l=new WeakMap,c=new WeakMap;let d={},h={},p=new WeakMap,A=[],y=null,m=!1,x=null,g=null,_=null,b=null,w=null,I=null,S=null,M=new xt(0,0,0),T=0,R=!1,k=null,H=null,Q=null,V=null,B=null;const W=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,X=0;const $=n.getParameter(n.VERSION);$.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec($)[1]),K=X>=1):$.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec($)[1]),K=X>=2);let J=null,ne={};const L=n.getParameter(n.SCISSOR_BOX),G=n.getParameter(n.VIEWPORT),oe=new Kt().fromArray(L),Ae=new Kt().fromArray(G);function ye(_e,ut,je,Ye){const We=new Uint8Array(4),Ve=n.createTexture();n.bindTexture(_e,Ve),n.texParameteri(_e,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(_e,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let _t=0;_t<je;_t++)_e===n.TEXTURE_3D||_e===n.TEXTURE_2D_ARRAY?n.texImage3D(ut,0,n.RGBA,1,1,Ye,0,n.RGBA,n.UNSIGNED_BYTE,We):n.texImage2D(ut+_t,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,We);return Ve}const he={};he[n.TEXTURE_2D]=ye(n.TEXTURE_2D,n.TEXTURE_2D,1),he[n.TEXTURE_CUBE_MAP]=ye(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),he[n.TEXTURE_2D_ARRAY]=ye(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),he[n.TEXTURE_3D]=ye(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),fe(n.DEPTH_TEST),a.setFunc(Hd),Ee(!1),q(AS),fe(n.CULL_FACE),F(xo);function fe(_e){d[_e]!==!0&&(n.enable(_e),d[_e]=!0)}function Ie(_e){d[_e]!==!1&&(n.disable(_e),d[_e]=!1)}function Re(_e,ut){return h[_e]!==ut?(n.bindFramebuffer(_e,ut),h[_e]=ut,_e===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=ut),_e===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=ut),!0):!1}function ge(_e,ut){let je=A,Ye=!1;if(_e){je=p.get(ut),je===void 0&&(je=[],p.set(ut,je));const We=_e.textures;if(je.length!==We.length||je[0]!==n.COLOR_ATTACHMENT0){for(let Ve=0,_t=We.length;Ve<_t;Ve++)je[Ve]=n.COLOR_ATTACHMENT0+Ve;je.length=We.length,Ye=!0}}else je[0]!==n.BACK&&(je[0]=n.BACK,Ye=!0);Ye&&n.drawBuffers(je)}function Ne(_e){return y!==_e?(n.useProgram(_e),y=_e,!0):!1}const tt={[Dc]:n.FUNC_ADD,[PV]:n.FUNC_SUBTRACT,[LV]:n.FUNC_REVERSE_SUBTRACT};tt[FV]=n.MIN,tt[zV]=n.MAX;const Ge={[UV]:n.ZERO,[OV]:n.ONE,[$V]:n.SRC_COLOR,[vb]:n.SRC_ALPHA,[qV]:n.SRC_ALPHA_SATURATE,[jV]:n.DST_COLOR,[VV]:n.DST_ALPHA,[GV]:n.ONE_MINUS_SRC_COLOR,[_b]:n.ONE_MINUS_SRC_ALPHA,[WV]:n.ONE_MINUS_DST_COLOR,[HV]:n.ONE_MINUS_DST_ALPHA,[YV]:n.CONSTANT_COLOR,[XV]:n.ONE_MINUS_CONSTANT_COLOR,[JV]:n.CONSTANT_ALPHA,[KV]:n.ONE_MINUS_CONSTANT_ALPHA};function F(_e,ut,je,Ye,We,Ve,_t,Ot,En,dn){if(_e===xo){m===!0&&(Ie(n.BLEND),m=!1);return}if(m===!1&&(fe(n.BLEND),m=!0),_e!==QV){if(_e!==x||dn!==R){if((g!==Dc||w!==Dc)&&(n.blendEquation(n.FUNC_ADD),g=Dc,w=Dc),dn)switch(_e){case Pd:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case mS:n.blendFunc(n.ONE,n.ONE);break;case gS:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case yS:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:sn("WebGLState: Invalid blending: ",_e);break}else switch(_e){case Pd:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case mS:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case gS:sn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case yS:sn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:sn("WebGLState: Invalid blending: ",_e);break}_=null,b=null,I=null,S=null,M.set(0,0,0),T=0,x=_e,R=dn}return}We=We||ut,Ve=Ve||je,_t=_t||Ye,(ut!==g||We!==w)&&(n.blendEquationSeparate(tt[ut],tt[We]),g=ut,w=We),(je!==_||Ye!==b||Ve!==I||_t!==S)&&(n.blendFuncSeparate(Ge[je],Ge[Ye],Ge[Ve],Ge[_t]),_=je,b=Ye,I=Ve,S=_t),(Ot.equals(M)===!1||En!==T)&&(n.blendColor(Ot.r,Ot.g,Ot.b,En),M.copy(Ot),T=En),x=_e,R=!1}function re(_e,ut){_e.side===rs?Ie(n.CULL_FACE):fe(n.CULL_FACE);let je=_e.side===Bi;ut&&(je=!je),Ee(je),_e.blending===Pd&&_e.transparent===!1?F(xo):F(_e.blending,_e.blendEquation,_e.blendSrc,_e.blendDst,_e.blendEquationAlpha,_e.blendSrcAlpha,_e.blendDstAlpha,_e.blendColor,_e.blendAlpha,_e.premultipliedAlpha),a.setFunc(_e.depthFunc),a.setTest(_e.depthTest),a.setMask(_e.depthWrite),s.setMask(_e.colorWrite);const Ye=_e.stencilWrite;o.setTest(Ye),Ye&&(o.setMask(_e.stencilWriteMask),o.setFunc(_e.stencilFunc,_e.stencilRef,_e.stencilFuncMask),o.setOp(_e.stencilFail,_e.stencilZFail,_e.stencilZPass)),ie(_e.polygonOffset,_e.polygonOffsetFactor,_e.polygonOffsetUnits),_e.alphaToCoverage===!0?fe(n.SAMPLE_ALPHA_TO_COVERAGE):Ie(n.SAMPLE_ALPHA_TO_COVERAGE)}function Ee(_e){k!==_e&&(_e?n.frontFace(n.CW):n.frontFace(n.CCW),k=_e)}function q(_e){_e!==kV?(fe(n.CULL_FACE),_e!==H&&(_e===AS?n.cullFace(n.BACK):_e===NV?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Ie(n.CULL_FACE),H=_e}function ee(_e){_e!==Q&&(K&&n.lineWidth(_e),Q=_e)}function ie(_e,ut,je){_e?(fe(n.POLYGON_OFFSET_FILL),(V!==ut||B!==je)&&(n.polygonOffset(ut,je),V=ut,B=je)):Ie(n.POLYGON_OFFSET_FILL)}function be(_e){_e?fe(n.SCISSOR_TEST):Ie(n.SCISSOR_TEST)}function ve(_e){_e===void 0&&(_e=n.TEXTURE0+W-1),J!==_e&&(n.activeTexture(_e),J=_e)}function ce(_e,ut,je){je===void 0&&(J===null?je=n.TEXTURE0+W-1:je=J);let Ye=ne[je];Ye===void 0&&(Ye={type:void 0,texture:void 0},ne[je]=Ye),(Ye.type!==_e||Ye.texture!==ut)&&(J!==je&&(n.activeTexture(je),J=je),n.bindTexture(_e,ut||he[_e]),Ye.type=_e,Ye.texture=ut)}function Z(){const _e=ne[J];_e!==void 0&&_e.type!==void 0&&(n.bindTexture(_e.type,null),_e.type=void 0,_e.texture=void 0)}function Y(){try{n.compressedTexImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function le(){try{n.compressedTexImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ce(){try{n.texSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function me(){try{n.texSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function xe(){try{n.compressedTexSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function st(){try{n.compressedTexSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function He(){try{n.texStorage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ke(){try{n.texStorage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function nt(){try{n.texImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function ze(){try{n.texImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ze(_e){oe.equals(_e)===!1&&(n.scissor(_e.x,_e.y,_e.z,_e.w),oe.copy(_e))}function pt(_e){Ae.equals(_e)===!1&&(n.viewport(_e.x,_e.y,_e.z,_e.w),Ae.copy(_e))}function ft(_e,ut){let je=c.get(ut);je===void 0&&(je=new WeakMap,c.set(ut,je));let Ye=je.get(_e);Ye===void 0&&(Ye=n.getUniformBlockIndex(ut,_e.name),je.set(_e,Ye))}function dt(_e,ut){const Ye=c.get(ut).get(_e);l.get(ut)!==Ye&&(n.uniformBlockBinding(ut,Ye,_e.__bindingPointIndex),l.set(ut,Ye))}function Mt(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),d={},J=null,ne={},h={},p=new WeakMap,A=[],y=null,m=!1,x=null,g=null,_=null,b=null,w=null,I=null,S=null,M=new xt(0,0,0),T=0,R=!1,k=null,H=null,Q=null,V=null,B=null,oe.set(0,0,n.canvas.width,n.canvas.height),Ae.set(0,0,n.canvas.width,n.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:fe,disable:Ie,bindFramebuffer:Re,drawBuffers:ge,useProgram:Ne,setBlending:F,setMaterial:re,setFlipSided:Ee,setCullFace:q,setLineWidth:ee,setPolygonOffset:ie,setScissorTest:be,activeTexture:ve,bindTexture:ce,unbindTexture:Z,compressedTexImage2D:Y,compressedTexImage3D:le,texImage2D:nt,texImage3D:ze,updateUBOMapping:ft,uniformBlockBinding:dt,texStorage2D:He,texStorage3D:Ke,texSubImage2D:Ce,texSubImage3D:me,compressedTexSubImage2D:xe,compressedTexSubImage3D:st,scissor:Ze,viewport:pt,reset:Mt}}function M7(n,e,t,r,i,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Dt,d=new WeakMap;let h;const p=new WeakMap;let A=!1;try{A=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(Z,Y){return A?new OffscreenCanvas(Z,Y):Rp("canvas")}function m(Z,Y,le){let Ce=1;const me=ce(Z);if((me.width>le||me.height>le)&&(Ce=le/Math.max(me.width,me.height)),Ce<1)if(typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Z instanceof ImageBitmap||typeof VideoFrame<"u"&&Z instanceof VideoFrame){const xe=Math.floor(Ce*me.width),st=Math.floor(Ce*me.height);h===void 0&&(h=y(xe,st));const He=Y?y(xe,st):h;return He.width=xe,He.height=st,He.getContext("2d").drawImage(Z,0,0,xe,st),Pt("WebGLRenderer: Texture has been resized from ("+me.width+"x"+me.height+") to ("+xe+"x"+st+")."),He}else return"data"in Z&&Pt("WebGLRenderer: Image in DataTexture is too big ("+me.width+"x"+me.height+")."),Z;return Z}function x(Z){return Z.generateMipmaps}function g(Z){n.generateMipmap(Z)}function _(Z){return Z.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:Z.isWebGL3DRenderTarget?n.TEXTURE_3D:Z.isWebGLArrayRenderTarget||Z.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function b(Z,Y,le,Ce,me=!1){if(Z!==null){if(n[Z]!==void 0)return n[Z];Pt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Z+"'")}let xe=Y;if(Y===n.RED&&(le===n.FLOAT&&(xe=n.R32F),le===n.HALF_FLOAT&&(xe=n.R16F),le===n.UNSIGNED_BYTE&&(xe=n.R8)),Y===n.RED_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.R8UI),le===n.UNSIGNED_SHORT&&(xe=n.R16UI),le===n.UNSIGNED_INT&&(xe=n.R32UI),le===n.BYTE&&(xe=n.R8I),le===n.SHORT&&(xe=n.R16I),le===n.INT&&(xe=n.R32I)),Y===n.RG&&(le===n.FLOAT&&(xe=n.RG32F),le===n.HALF_FLOAT&&(xe=n.RG16F),le===n.UNSIGNED_BYTE&&(xe=n.RG8)),Y===n.RG_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.RG8UI),le===n.UNSIGNED_SHORT&&(xe=n.RG16UI),le===n.UNSIGNED_INT&&(xe=n.RG32UI),le===n.BYTE&&(xe=n.RG8I),le===n.SHORT&&(xe=n.RG16I),le===n.INT&&(xe=n.RG32I)),Y===n.RGB_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.RGB8UI),le===n.UNSIGNED_SHORT&&(xe=n.RGB16UI),le===n.UNSIGNED_INT&&(xe=n.RGB32UI),le===n.BYTE&&(xe=n.RGB8I),le===n.SHORT&&(xe=n.RGB16I),le===n.INT&&(xe=n.RGB32I)),Y===n.RGBA_INTEGER&&(le===n.UNSIGNED_BYTE&&(xe=n.RGBA8UI),le===n.UNSIGNED_SHORT&&(xe=n.RGBA16UI),le===n.UNSIGNED_INT&&(xe=n.RGBA32UI),le===n.BYTE&&(xe=n.RGBA8I),le===n.SHORT&&(xe=n.RGBA16I),le===n.INT&&(xe=n.RGBA32I)),Y===n.RGB&&(le===n.UNSIGNED_INT_5_9_9_9_REV&&(xe=n.RGB9_E5),le===n.UNSIGNED_INT_10F_11F_11F_REV&&(xe=n.R11F_G11F_B10F)),Y===n.RGBA){const st=me?zg:mn.getTransfer(Ce);le===n.FLOAT&&(xe=n.RGBA32F),le===n.HALF_FLOAT&&(xe=n.RGBA16F),le===n.UNSIGNED_BYTE&&(xe=st===Dn?n.SRGB8_ALPHA8:n.RGBA8),le===n.UNSIGNED_SHORT_4_4_4_4&&(xe=n.RGBA4),le===n.UNSIGNED_SHORT_5_5_5_1&&(xe=n.RGB5_A1)}return(xe===n.R16F||xe===n.R32F||xe===n.RG16F||xe===n.RG32F||xe===n.RGBA16F||xe===n.RGBA32F)&&e.get("EXT_color_buffer_float"),xe}function w(Z,Y){let le;return Z?Y===null||Y===Mi||Y===Cp?le=n.DEPTH24_STENCIL8:Y===js?le=n.DEPTH32F_STENCIL8:Y===Ip&&(le=n.DEPTH24_STENCIL8,Pt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):Y===null||Y===Mi||Y===Cp?le=n.DEPTH_COMPONENT24:Y===js?le=n.DEPTH_COMPONENT32F:Y===Ip&&(le=n.DEPTH_COMPONENT16),le}function I(Z,Y){return x(Z)===!0||Z.isFramebufferTexture&&Z.minFilter!==mr&&Z.minFilter!==ir?Math.log2(Math.max(Y.width,Y.height))+1:Z.mipmaps!==void 0&&Z.mipmaps.length>0?Z.mipmaps.length:Z.isCompressedTexture&&Array.isArray(Z.image)?Y.mipmaps.length:1}function S(Z){const Y=Z.target;Y.removeEventListener("dispose",S),T(Y),Y.isVideoTexture&&d.delete(Y)}function M(Z){const Y=Z.target;Y.removeEventListener("dispose",M),k(Y)}function T(Z){const Y=r.get(Z);if(Y.__webglInit===void 0)return;const le=Z.source,Ce=p.get(le);if(Ce){const me=Ce[Y.__cacheKey];me.usedTimes--,me.usedTimes===0&&R(Z),Object.keys(Ce).length===0&&p.delete(le)}r.remove(Z)}function R(Z){const Y=r.get(Z);n.deleteTexture(Y.__webglTexture);const le=Z.source,Ce=p.get(le);delete Ce[Y.__cacheKey],a.memory.textures--}function k(Z){const Y=r.get(Z);if(Z.depthTexture&&(Z.depthTexture.dispose(),r.remove(Z.depthTexture)),Z.isWebGLCubeRenderTarget)for(let Ce=0;Ce<6;Ce++){if(Array.isArray(Y.__webglFramebuffer[Ce]))for(let me=0;me<Y.__webglFramebuffer[Ce].length;me++)n.deleteFramebuffer(Y.__webglFramebuffer[Ce][me]);else n.deleteFramebuffer(Y.__webglFramebuffer[Ce]);Y.__webglDepthbuffer&&n.deleteRenderbuffer(Y.__webglDepthbuffer[Ce])}else{if(Array.isArray(Y.__webglFramebuffer))for(let Ce=0;Ce<Y.__webglFramebuffer.length;Ce++)n.deleteFramebuffer(Y.__webglFramebuffer[Ce]);else n.deleteFramebuffer(Y.__webglFramebuffer);if(Y.__webglDepthbuffer&&n.deleteRenderbuffer(Y.__webglDepthbuffer),Y.__webglMultisampledFramebuffer&&n.deleteFramebuffer(Y.__webglMultisampledFramebuffer),Y.__webglColorRenderbuffer)for(let Ce=0;Ce<Y.__webglColorRenderbuffer.length;Ce++)Y.__webglColorRenderbuffer[Ce]&&n.deleteRenderbuffer(Y.__webglColorRenderbuffer[Ce]);Y.__webglDepthRenderbuffer&&n.deleteRenderbuffer(Y.__webglDepthRenderbuffer)}const le=Z.textures;for(let Ce=0,me=le.length;Ce<me;Ce++){const xe=r.get(le[Ce]);xe.__webglTexture&&(n.deleteTexture(xe.__webglTexture),a.memory.textures--),r.remove(le[Ce])}r.remove(Z)}let H=0;function Q(){H=0}function V(){const Z=H;return Z>=i.maxTextures&&Pt("WebGLTextures: Trying to use "+Z+" texture units while this GPU supports only "+i.maxTextures),H+=1,Z}function B(Z){const Y=[];return Y.push(Z.wrapS),Y.push(Z.wrapT),Y.push(Z.wrapR||0),Y.push(Z.magFilter),Y.push(Z.minFilter),Y.push(Z.anisotropy),Y.push(Z.internalFormat),Y.push(Z.format),Y.push(Z.type),Y.push(Z.generateMipmaps),Y.push(Z.premultiplyAlpha),Y.push(Z.flipY),Y.push(Z.unpackAlignment),Y.push(Z.colorSpace),Y.join()}function W(Z,Y){const le=r.get(Z);if(Z.isVideoTexture&&be(Z),Z.isRenderTargetTexture===!1&&Z.isExternalTexture!==!0&&Z.version>0&&le.__version!==Z.version){const Ce=Z.image;if(Ce===null)Pt("WebGLRenderer: Texture marked for update but no image data found.");else if(Ce.complete===!1)Pt("WebGLRenderer: Texture marked for update but image is incomplete");else{he(le,Z,Y);return}}else Z.isExternalTexture&&(le.__webglTexture=Z.sourceTexture?Z.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,le.__webglTexture,n.TEXTURE0+Y)}function K(Z,Y){const le=r.get(Z);if(Z.isRenderTargetTexture===!1&&Z.version>0&&le.__version!==Z.version){he(le,Z,Y);return}else Z.isExternalTexture&&(le.__webglTexture=Z.sourceTexture?Z.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,le.__webglTexture,n.TEXTURE0+Y)}function X(Z,Y){const le=r.get(Z);if(Z.isRenderTargetTexture===!1&&Z.version>0&&le.__version!==Z.version){he(le,Z,Y);return}t.bindTexture(n.TEXTURE_3D,le.__webglTexture,n.TEXTURE0+Y)}function $(Z,Y){const le=r.get(Z);if(Z.version>0&&le.__version!==Z.version){fe(le,Z,Y);return}t.bindTexture(n.TEXTURE_CUBE_MAP,le.__webglTexture,n.TEXTURE0+Y)}const J={[Fl]:n.REPEAT,[os]:n.CLAMP_TO_EDGE,[Fg]:n.MIRRORED_REPEAT},ne={[mr]:n.NEAREST,[UN]:n.NEAREST_MIPMAP_NEAREST,[tp]:n.NEAREST_MIPMAP_LINEAR,[ir]:n.LINEAR,[mg]:n.LINEAR_MIPMAP_NEAREST,[Ia]:n.LINEAR_MIPMAP_LINEAR},L={[pH]:n.NEVER,[vH]:n.ALWAYS,[AH]:n.LESS,[qN]:n.LEQUAL,[mH]:n.EQUAL,[xH]:n.GEQUAL,[gH]:n.GREATER,[yH]:n.NOTEQUAL};function G(Z,Y){if(Y.type===js&&e.has("OES_texture_float_linear")===!1&&(Y.magFilter===ir||Y.magFilter===mg||Y.magFilter===tp||Y.magFilter===Ia||Y.minFilter===ir||Y.minFilter===mg||Y.minFilter===tp||Y.minFilter===Ia)&&Pt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(Z,n.TEXTURE_WRAP_S,J[Y.wrapS]),n.texParameteri(Z,n.TEXTURE_WRAP_T,J[Y.wrapT]),(Z===n.TEXTURE_3D||Z===n.TEXTURE_2D_ARRAY)&&n.texParameteri(Z,n.TEXTURE_WRAP_R,J[Y.wrapR]),n.texParameteri(Z,n.TEXTURE_MAG_FILTER,ne[Y.magFilter]),n.texParameteri(Z,n.TEXTURE_MIN_FILTER,ne[Y.minFilter]),Y.compareFunction&&(n.texParameteri(Z,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(Z,n.TEXTURE_COMPARE_FUNC,L[Y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(Y.magFilter===mr||Y.minFilter!==tp&&Y.minFilter!==Ia||Y.type===js&&e.has("OES_texture_float_linear")===!1)return;if(Y.anisotropy>1||r.get(Y).__currentAnisotropy){const le=e.get("EXT_texture_filter_anisotropic");n.texParameterf(Z,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Y.anisotropy,i.getMaxAnisotropy())),r.get(Y).__currentAnisotropy=Y.anisotropy}}}function oe(Z,Y){let le=!1;Z.__webglInit===void 0&&(Z.__webglInit=!0,Y.addEventListener("dispose",S));const Ce=Y.source;let me=p.get(Ce);me===void 0&&(me={},p.set(Ce,me));const xe=B(Y);if(xe!==Z.__cacheKey){me[xe]===void 0&&(me[xe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,le=!0),me[xe].usedTimes++;const st=me[Z.__cacheKey];st!==void 0&&(me[Z.__cacheKey].usedTimes--,st.usedTimes===0&&R(Y)),Z.__cacheKey=xe,Z.__webglTexture=me[xe].texture}return le}function Ae(Z,Y,le){return Math.floor(Math.floor(Z/le)/Y)}function ye(Z,Y,le,Ce){const xe=Z.updateRanges;if(xe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,Y.width,Y.height,le,Ce,Y.data);else{xe.sort((ze,Ze)=>ze.start-Ze.start);let st=0;for(let ze=1;ze<xe.length;ze++){const Ze=xe[st],pt=xe[ze],ft=Ze.start+Ze.count,dt=Ae(pt.start,Y.width,4),Mt=Ae(Ze.start,Y.width,4);pt.start<=ft+1&&dt===Mt&&Ae(pt.start+pt.count-1,Y.width,4)===dt?Ze.count=Math.max(Ze.count,pt.start+pt.count-Ze.start):(++st,xe[st]=pt)}xe.length=st+1;const He=n.getParameter(n.UNPACK_ROW_LENGTH),Ke=n.getParameter(n.UNPACK_SKIP_PIXELS),nt=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,Y.width);for(let ze=0,Ze=xe.length;ze<Ze;ze++){const pt=xe[ze],ft=Math.floor(pt.start/4),dt=Math.ceil(pt.count/4),Mt=ft%Y.width,_e=Math.floor(ft/Y.width),ut=dt,je=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,Mt),n.pixelStorei(n.UNPACK_SKIP_ROWS,_e),t.texSubImage2D(n.TEXTURE_2D,0,Mt,_e,ut,je,le,Ce,Y.data)}Z.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,He),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Ke),n.pixelStorei(n.UNPACK_SKIP_ROWS,nt)}}function he(Z,Y,le){let Ce=n.TEXTURE_2D;(Y.isDataArrayTexture||Y.isCompressedArrayTexture)&&(Ce=n.TEXTURE_2D_ARRAY),Y.isData3DTexture&&(Ce=n.TEXTURE_3D);const me=oe(Z,Y),xe=Y.source;t.bindTexture(Ce,Z.__webglTexture,n.TEXTURE0+le);const st=r.get(xe);if(xe.version!==st.__version||me===!0){t.activeTexture(n.TEXTURE0+le);const He=mn.getPrimaries(mn.workingColorSpace),Ke=Y.colorSpace===Dl?null:mn.getPrimaries(Y.colorSpace),nt=Y.colorSpace===Dl||He===Ke?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,Y.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Y.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,Y.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,nt);let ze=m(Y.image,!1,i.maxTextureSize);ze=ve(Y,ze);const Ze=s.convert(Y.format,Y.colorSpace),pt=s.convert(Y.type);let ft=b(Y.internalFormat,Ze,pt,Y.colorSpace,Y.isVideoTexture);G(Ce,Y);let dt;const Mt=Y.mipmaps,_e=Y.isVideoTexture!==!0,ut=st.__version===void 0||me===!0,je=xe.dataReady,Ye=I(Y,ze);if(Y.isDepthTexture)ft=w(Y.format===Bp,Y.type),ut&&(_e?t.texStorage2D(n.TEXTURE_2D,1,ft,ze.width,ze.height):t.texImage2D(n.TEXTURE_2D,0,ft,ze.width,ze.height,0,Ze,pt,null));else if(Y.isDataTexture)if(Mt.length>0){_e&&ut&&t.texStorage2D(n.TEXTURE_2D,Ye,ft,Mt[0].width,Mt[0].height);for(let We=0,Ve=Mt.length;We<Ve;We++)dt=Mt[We],_e?je&&t.texSubImage2D(n.TEXTURE_2D,We,0,0,dt.width,dt.height,Ze,pt,dt.data):t.texImage2D(n.TEXTURE_2D,We,ft,dt.width,dt.height,0,Ze,pt,dt.data);Y.generateMipmaps=!1}else _e?(ut&&t.texStorage2D(n.TEXTURE_2D,Ye,ft,ze.width,ze.height),je&&ye(Y,ze,Ze,pt)):t.texImage2D(n.TEXTURE_2D,0,ft,ze.width,ze.height,0,Ze,pt,ze.data);else if(Y.isCompressedTexture)if(Y.isCompressedArrayTexture){_e&&ut&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ye,ft,Mt[0].width,Mt[0].height,ze.depth);for(let We=0,Ve=Mt.length;We<Ve;We++)if(dt=Mt[We],Y.format!==sr)if(Ze!==null)if(_e){if(je)if(Y.layerUpdates.size>0){const _t=c3(dt.width,dt.height,Y.format,Y.type);for(const Ot of Y.layerUpdates){const En=dt.data.subarray(Ot*_t/dt.data.BYTES_PER_ELEMENT,(Ot+1)*_t/dt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,We,0,0,Ot,dt.width,dt.height,1,Ze,En)}Y.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,We,0,0,0,dt.width,dt.height,ze.depth,Ze,dt.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,We,ft,dt.width,dt.height,ze.depth,0,dt.data,0,0);else Pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else _e?je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,We,0,0,0,dt.width,dt.height,ze.depth,Ze,pt,dt.data):t.texImage3D(n.TEXTURE_2D_ARRAY,We,ft,dt.width,dt.height,ze.depth,0,Ze,pt,dt.data)}else{_e&&ut&&t.texStorage2D(n.TEXTURE_2D,Ye,ft,Mt[0].width,Mt[0].height);for(let We=0,Ve=Mt.length;We<Ve;We++)dt=Mt[We],Y.format!==sr?Ze!==null?_e?je&&t.compressedTexSubImage2D(n.TEXTURE_2D,We,0,0,dt.width,dt.height,Ze,dt.data):t.compressedTexImage2D(n.TEXTURE_2D,We,ft,dt.width,dt.height,0,dt.data):Pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):_e?je&&t.texSubImage2D(n.TEXTURE_2D,We,0,0,dt.width,dt.height,Ze,pt,dt.data):t.texImage2D(n.TEXTURE_2D,We,ft,dt.width,dt.height,0,Ze,pt,dt.data)}else if(Y.isDataArrayTexture)if(_e){if(ut&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Ye,ft,ze.width,ze.height,ze.depth),je)if(Y.layerUpdates.size>0){const We=c3(ze.width,ze.height,Y.format,Y.type);for(const Ve of Y.layerUpdates){const _t=ze.data.subarray(Ve*We/ze.data.BYTES_PER_ELEMENT,(Ve+1)*We/ze.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Ve,ze.width,ze.height,1,Ze,pt,_t)}Y.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ze.width,ze.height,ze.depth,Ze,pt,ze.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ft,ze.width,ze.height,ze.depth,0,Ze,pt,ze.data);else if(Y.isData3DTexture)_e?(ut&&t.texStorage3D(n.TEXTURE_3D,Ye,ft,ze.width,ze.height,ze.depth),je&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ze.width,ze.height,ze.depth,Ze,pt,ze.data)):t.texImage3D(n.TEXTURE_3D,0,ft,ze.width,ze.height,ze.depth,0,Ze,pt,ze.data);else if(Y.isFramebufferTexture){if(ut)if(_e)t.texStorage2D(n.TEXTURE_2D,Ye,ft,ze.width,ze.height);else{let We=ze.width,Ve=ze.height;for(let _t=0;_t<Ye;_t++)t.texImage2D(n.TEXTURE_2D,_t,ft,We,Ve,0,Ze,pt,null),We>>=1,Ve>>=1}}else if(Mt.length>0){if(_e&&ut){const We=ce(Mt[0]);t.texStorage2D(n.TEXTURE_2D,Ye,ft,We.width,We.height)}for(let We=0,Ve=Mt.length;We<Ve;We++)dt=Mt[We],_e?je&&t.texSubImage2D(n.TEXTURE_2D,We,0,0,Ze,pt,dt):t.texImage2D(n.TEXTURE_2D,We,ft,Ze,pt,dt);Y.generateMipmaps=!1}else if(_e){if(ut){const We=ce(ze);t.texStorage2D(n.TEXTURE_2D,Ye,ft,We.width,We.height)}je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ze,pt,ze)}else t.texImage2D(n.TEXTURE_2D,0,ft,Ze,pt,ze);x(Y)&&g(Ce),st.__version=xe.version,Y.onUpdate&&Y.onUpdate(Y)}Z.__version=Y.version}function fe(Z,Y,le){if(Y.image.length!==6)return;const Ce=oe(Z,Y),me=Y.source;t.bindTexture(n.TEXTURE_CUBE_MAP,Z.__webglTexture,n.TEXTURE0+le);const xe=r.get(me);if(me.version!==xe.__version||Ce===!0){t.activeTexture(n.TEXTURE0+le);const st=mn.getPrimaries(mn.workingColorSpace),He=Y.colorSpace===Dl?null:mn.getPrimaries(Y.colorSpace),Ke=Y.colorSpace===Dl||st===He?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,Y.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Y.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,Y.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const nt=Y.isCompressedTexture||Y.image[0].isCompressedTexture,ze=Y.image[0]&&Y.image[0].isDataTexture,Ze=[];for(let Ve=0;Ve<6;Ve++)!nt&&!ze?Ze[Ve]=m(Y.image[Ve],!0,i.maxCubemapSize):Ze[Ve]=ze?Y.image[Ve].image:Y.image[Ve],Ze[Ve]=ve(Y,Ze[Ve]);const pt=Ze[0],ft=s.convert(Y.format,Y.colorSpace),dt=s.convert(Y.type),Mt=b(Y.internalFormat,ft,dt,Y.colorSpace),_e=Y.isVideoTexture!==!0,ut=xe.__version===void 0||Ce===!0,je=me.dataReady;let Ye=I(Y,pt);G(n.TEXTURE_CUBE_MAP,Y);let We;if(nt){_e&&ut&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Ye,Mt,pt.width,pt.height);for(let Ve=0;Ve<6;Ve++){We=Ze[Ve].mipmaps;for(let _t=0;_t<We.length;_t++){const Ot=We[_t];Y.format!==sr?ft!==null?_e?je&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,0,0,Ot.width,Ot.height,ft,Ot.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,Mt,Ot.width,Ot.height,0,Ot.data):Pt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,0,0,Ot.width,Ot.height,ft,dt,Ot.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t,Mt,Ot.width,Ot.height,0,ft,dt,Ot.data)}}}else{if(We=Y.mipmaps,_e&&ut){We.length>0&&Ye++;const Ve=ce(Ze[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,Ye,Mt,Ve.width,Ve.height)}for(let Ve=0;Ve<6;Ve++)if(ze){_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,0,0,Ze[Ve].width,Ze[Ve].height,ft,dt,Ze[Ve].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,Mt,Ze[Ve].width,Ze[Ve].height,0,ft,dt,Ze[Ve].data);for(let _t=0;_t<We.length;_t++){const En=We[_t].image[Ve].image;_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,0,0,En.width,En.height,ft,dt,En.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,Mt,En.width,En.height,0,ft,dt,En.data)}}else{_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,0,0,ft,dt,Ze[Ve]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0,Mt,ft,dt,Ze[Ve]);for(let _t=0;_t<We.length;_t++){const Ot=We[_t];_e?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,0,0,ft,dt,Ot.image[Ve]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,_t+1,Mt,ft,dt,Ot.image[Ve])}}}x(Y)&&g(n.TEXTURE_CUBE_MAP),xe.__version=me.version,Y.onUpdate&&Y.onUpdate(Y)}Z.__version=Y.version}function Ie(Z,Y,le,Ce,me,xe){const st=s.convert(le.format,le.colorSpace),He=s.convert(le.type),Ke=b(le.internalFormat,st,He,le.colorSpace),nt=r.get(Y),ze=r.get(le);if(ze.__renderTarget=Y,!nt.__hasExternalTextures){const Ze=Math.max(1,Y.width>>xe),pt=Math.max(1,Y.height>>xe);me===n.TEXTURE_3D||me===n.TEXTURE_2D_ARRAY?t.texImage3D(me,xe,Ke,Ze,pt,Y.depth,0,st,He,null):t.texImage2D(me,xe,Ke,Ze,pt,0,st,He,null)}t.bindFramebuffer(n.FRAMEBUFFER,Z),ie(Y)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ce,me,ze.__webglTexture,0,ee(Y)):(me===n.TEXTURE_2D||me>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&me<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Ce,me,ze.__webglTexture,xe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Re(Z,Y,le){if(n.bindRenderbuffer(n.RENDERBUFFER,Z),Y.depthBuffer){const Ce=Y.depthTexture,me=Ce&&Ce.isDepthTexture?Ce.type:null,xe=w(Y.stencilBuffer,me),st=Y.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,He=ee(Y);ie(Y)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,He,xe,Y.width,Y.height):le?n.renderbufferStorageMultisample(n.RENDERBUFFER,He,xe,Y.width,Y.height):n.renderbufferStorage(n.RENDERBUFFER,xe,Y.width,Y.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,st,n.RENDERBUFFER,Z)}else{const Ce=Y.textures;for(let me=0;me<Ce.length;me++){const xe=Ce[me],st=s.convert(xe.format,xe.colorSpace),He=s.convert(xe.type),Ke=b(xe.internalFormat,st,He,xe.colorSpace),nt=ee(Y);le&&ie(Y)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,nt,Ke,Y.width,Y.height):ie(Y)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,nt,Ke,Y.width,Y.height):n.renderbufferStorage(n.RENDERBUFFER,Ke,Y.width,Y.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ge(Z,Y){if(Y&&Y.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,Z),!(Y.depthTexture&&Y.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Ce=r.get(Y.depthTexture);Ce.__renderTarget=Y,(!Ce.__webglTexture||Y.depthTexture.image.width!==Y.width||Y.depthTexture.image.height!==Y.height)&&(Y.depthTexture.image.width=Y.width,Y.depthTexture.image.height=Y.height,Y.depthTexture.needsUpdate=!0),W(Y.depthTexture,0);const me=Ce.__webglTexture,xe=ee(Y);if(Y.depthTexture.format===Sp)ie(Y)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,me,0,xe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,me,0);else if(Y.depthTexture.format===Bp)ie(Y)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,me,0,xe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,me,0);else throw new Error("Unknown depthTexture format")}function Ne(Z){const Y=r.get(Z),le=Z.isWebGLCubeRenderTarget===!0;if(Y.__boundDepthTexture!==Z.depthTexture){const Ce=Z.depthTexture;if(Y.__depthDisposeCallback&&Y.__depthDisposeCallback(),Ce){const me=()=>{delete Y.__boundDepthTexture,delete Y.__depthDisposeCallback,Ce.removeEventListener("dispose",me)};Ce.addEventListener("dispose",me),Y.__depthDisposeCallback=me}Y.__boundDepthTexture=Ce}if(Z.depthTexture&&!Y.__autoAllocateDepthBuffer){if(le)throw new Error("target.depthTexture not supported in Cube render targets");const Ce=Z.texture.mipmaps;Ce&&Ce.length>0?ge(Y.__webglFramebuffer[0],Z):ge(Y.__webglFramebuffer,Z)}else if(le){Y.__webglDepthbuffer=[];for(let Ce=0;Ce<6;Ce++)if(t.bindFramebuffer(n.FRAMEBUFFER,Y.__webglFramebuffer[Ce]),Y.__webglDepthbuffer[Ce]===void 0)Y.__webglDepthbuffer[Ce]=n.createRenderbuffer(),Re(Y.__webglDepthbuffer[Ce],Z,!1);else{const me=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,xe=Y.__webglDepthbuffer[Ce];n.bindRenderbuffer(n.RENDERBUFFER,xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,me,n.RENDERBUFFER,xe)}}else{const Ce=Z.texture.mipmaps;if(Ce&&Ce.length>0?t.bindFramebuffer(n.FRAMEBUFFER,Y.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,Y.__webglFramebuffer),Y.__webglDepthbuffer===void 0)Y.__webglDepthbuffer=n.createRenderbuffer(),Re(Y.__webglDepthbuffer,Z,!1);else{const me=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,xe=Y.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,xe),n.framebufferRenderbuffer(n.FRAMEBUFFER,me,n.RENDERBUFFER,xe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function tt(Z,Y,le){const Ce=r.get(Z);Y!==void 0&&Ie(Ce.__webglFramebuffer,Z,Z.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),le!==void 0&&Ne(Z)}function Ge(Z){const Y=Z.texture,le=r.get(Z),Ce=r.get(Y);Z.addEventListener("dispose",M);const me=Z.textures,xe=Z.isWebGLCubeRenderTarget===!0,st=me.length>1;if(st||(Ce.__webglTexture===void 0&&(Ce.__webglTexture=n.createTexture()),Ce.__version=Y.version,a.memory.textures++),xe){le.__webglFramebuffer=[];for(let He=0;He<6;He++)if(Y.mipmaps&&Y.mipmaps.length>0){le.__webglFramebuffer[He]=[];for(let Ke=0;Ke<Y.mipmaps.length;Ke++)le.__webglFramebuffer[He][Ke]=n.createFramebuffer()}else le.__webglFramebuffer[He]=n.createFramebuffer()}else{if(Y.mipmaps&&Y.mipmaps.length>0){le.__webglFramebuffer=[];for(let He=0;He<Y.mipmaps.length;He++)le.__webglFramebuffer[He]=n.createFramebuffer()}else le.__webglFramebuffer=n.createFramebuffer();if(st)for(let He=0,Ke=me.length;He<Ke;He++){const nt=r.get(me[He]);nt.__webglTexture===void 0&&(nt.__webglTexture=n.createTexture(),a.memory.textures++)}if(Z.samples>0&&ie(Z)===!1){le.__webglMultisampledFramebuffer=n.createFramebuffer(),le.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,le.__webglMultisampledFramebuffer);for(let He=0;He<me.length;He++){const Ke=me[He];le.__webglColorRenderbuffer[He]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,le.__webglColorRenderbuffer[He]);const nt=s.convert(Ke.format,Ke.colorSpace),ze=s.convert(Ke.type),Ze=b(Ke.internalFormat,nt,ze,Ke.colorSpace,Z.isXRRenderTarget===!0),pt=ee(Z);n.renderbufferStorageMultisample(n.RENDERBUFFER,pt,Ze,Z.width,Z.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+He,n.RENDERBUFFER,le.__webglColorRenderbuffer[He])}n.bindRenderbuffer(n.RENDERBUFFER,null),Z.depthBuffer&&(le.__webglDepthRenderbuffer=n.createRenderbuffer(),Re(le.__webglDepthRenderbuffer,Z,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(xe){t.bindTexture(n.TEXTURE_CUBE_MAP,Ce.__webglTexture),G(n.TEXTURE_CUBE_MAP,Y);for(let He=0;He<6;He++)if(Y.mipmaps&&Y.mipmaps.length>0)for(let Ke=0;Ke<Y.mipmaps.length;Ke++)Ie(le.__webglFramebuffer[He][Ke],Z,Y,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+He,Ke);else Ie(le.__webglFramebuffer[He],Z,Y,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0);x(Y)&&g(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(st){for(let He=0,Ke=me.length;He<Ke;He++){const nt=me[He],ze=r.get(nt);let Ze=n.TEXTURE_2D;(Z.isWebGL3DRenderTarget||Z.isWebGLArrayRenderTarget)&&(Ze=Z.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ze,ze.__webglTexture),G(Ze,nt),Ie(le.__webglFramebuffer,Z,nt,n.COLOR_ATTACHMENT0+He,Ze,0),x(nt)&&g(Ze)}t.unbindTexture()}else{let He=n.TEXTURE_2D;if((Z.isWebGL3DRenderTarget||Z.isWebGLArrayRenderTarget)&&(He=Z.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(He,Ce.__webglTexture),G(He,Y),Y.mipmaps&&Y.mipmaps.length>0)for(let Ke=0;Ke<Y.mipmaps.length;Ke++)Ie(le.__webglFramebuffer[Ke],Z,Y,n.COLOR_ATTACHMENT0,He,Ke);else Ie(le.__webglFramebuffer,Z,Y,n.COLOR_ATTACHMENT0,He,0);x(Y)&&g(He),t.unbindTexture()}Z.depthBuffer&&Ne(Z)}function F(Z){const Y=Z.textures;for(let le=0,Ce=Y.length;le<Ce;le++){const me=Y[le];if(x(me)){const xe=_(Z),st=r.get(me).__webglTexture;t.bindTexture(xe,st),g(xe),t.unbindTexture()}}}const re=[],Ee=[];function q(Z){if(Z.samples>0){if(ie(Z)===!1){const Y=Z.textures,le=Z.width,Ce=Z.height;let me=n.COLOR_BUFFER_BIT;const xe=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,st=r.get(Z),He=Y.length>1;if(He)for(let nt=0;nt<Y.length;nt++)t.bindFramebuffer(n.FRAMEBUFFER,st.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,st.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,st.__webglMultisampledFramebuffer);const Ke=Z.texture.mipmaps;Ke&&Ke.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,st.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,st.__webglFramebuffer);for(let nt=0;nt<Y.length;nt++){if(Z.resolveDepthBuffer&&(Z.depthBuffer&&(me|=n.DEPTH_BUFFER_BIT),Z.stencilBuffer&&Z.resolveStencilBuffer&&(me|=n.STENCIL_BUFFER_BIT)),He){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,st.__webglColorRenderbuffer[nt]);const ze=r.get(Y[nt]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ze,0)}n.blitFramebuffer(0,0,le,Ce,0,0,le,Ce,me,n.NEAREST),l===!0&&(re.length=0,Ee.length=0,re.push(n.COLOR_ATTACHMENT0+nt),Z.depthBuffer&&Z.resolveDepthBuffer===!1&&(re.push(xe),Ee.push(xe),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ee)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,re))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),He)for(let nt=0;nt<Y.length;nt++){t.bindFramebuffer(n.FRAMEBUFFER,st.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.RENDERBUFFER,st.__webglColorRenderbuffer[nt]);const ze=r.get(Y[nt]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,st.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+nt,n.TEXTURE_2D,ze,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,st.__webglMultisampledFramebuffer)}else if(Z.depthBuffer&&Z.resolveDepthBuffer===!1&&l){const Y=Z.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[Y])}}}function ee(Z){return Math.min(i.maxSamples,Z.samples)}function ie(Z){const Y=r.get(Z);return Z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Y.__useRenderToTexture!==!1}function be(Z){const Y=a.render.frame;d.get(Z)!==Y&&(d.set(Z,Y),Z.update())}function ve(Z,Y){const le=Z.colorSpace,Ce=Z.format,me=Z.type;return Z.isCompressedTexture===!0||Z.isVideoTexture===!0||le!==ri&&le!==Dl&&(mn.getTransfer(le)===Dn?(Ce!==sr||me!==ni)&&Pt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):sn("WebGLTextures: Unsupported texture color space:",le)),Y}function ce(Z){return typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement?(c.width=Z.naturalWidth||Z.width,c.height=Z.naturalHeight||Z.height):typeof VideoFrame<"u"&&Z instanceof VideoFrame?(c.width=Z.displayWidth,c.height=Z.displayHeight):(c.width=Z.width,c.height=Z.height),c}this.allocateTextureUnit=V,this.resetTextureUnits=Q,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=X,this.setTextureCube=$,this.rebindTextures=tt,this.setupRenderTarget=Ge,this.updateRenderTargetMipmap=F,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Ie,this.useMultisampledRTT=ie}function T7(n,e){function t(r,i=Dl){let s;const a=mn.getTransfer(i);if(r===ni)return n.UNSIGNED_BYTE;if(r===fI)return n.UNSIGNED_SHORT_4_4_4_4;if(r===pI)return n.UNSIGNED_SHORT_5_5_5_1;if(r===GN)return n.UNSIGNED_INT_5_9_9_9_REV;if(r===VN)return n.UNSIGNED_INT_10F_11F_11F_REV;if(r===ON)return n.BYTE;if(r===$N)return n.SHORT;if(r===Ip)return n.UNSIGNED_SHORT;if(r===hI)return n.INT;if(r===Mi)return n.UNSIGNED_INT;if(r===js)return n.FLOAT;if(r===fh)return n.HALF_FLOAT;if(r===HN)return n.ALPHA;if(r===jN)return n.RGB;if(r===sr)return n.RGBA;if(r===Sp)return n.DEPTH_COMPONENT;if(r===Bp)return n.DEPTH_STENCIL;if(r===AI)return n.RED;if(r===mI)return n.RED_INTEGER;if(r===gI)return n.RG;if(r===U0)return n.RG_INTEGER;if(r===vo)return n.RGBA_INTEGER;if(r===gg||r===yg||r===xg||r===vg)if(a===Dn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===gg)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===yg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===xg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===vg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===gg)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===yg)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===xg)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===vg)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Rb||r===Db||r===kb||r===Nb)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===Rb)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Db)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===kb)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Nb)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Qb||r===Pb||r===Lb)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===Qb||r===Pb)return a===Dn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===Lb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Fb||r===zb||r===Ub||r===Ob||r===$b||r===Gb||r===Vb||r===Hb||r===jb||r===Wb||r===qb||r===Yb||r===Xb||r===Jb)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===Fb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===zb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Ub)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Ob)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===$b)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Gb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Vb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Hb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===jb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Wb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===qb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Yb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Xb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Jb)return a===Dn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Kb||r===Zb||r===ew)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===Kb)return a===Dn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Zb)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===ew)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===tw||r===nw||r===rw||r===iw)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===tw)return s.COMPRESSED_RED_RGTC1_EXT;if(r===nw)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===rw)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===iw)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Cp?n.UNSIGNED_INT_24_8:n[r]!==void 0?n[r]:null}return{convert:t}}const R7=`
|
|
3979
3979
|
void main() {
|
|
3980
3980
|
|
|
3981
3981
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -12818,12 +12818,12 @@ void main() {
|
|
|
12818
12818
|
center = quatVec(quat, center) + translate;
|
|
12819
12819
|
quaternion = quatQuat(quat, quaternion);
|
|
12820
12820
|
}
|
|
12821
|
-
`);new ms(new de(-1,-1,-1),new de(1,1,1)),new de(-1,-3,1).normalize(),new xt(1,1,1),new xt(.5,.5,1),new de(1,1,1);new ms(new de(-2,-1,-2),new de(2,5,2)),new de(0,-1,0),new xt(1,1,1),new xt(.25,.25,.5),new de(.1,1,.1);const oP=class ww{static createButton(e,t={}){const r=navigator.xr;if(!r)return null;const i=r,s=document.createElement("button");e.xr.enabled=!0,e.xr.setReferenceSpaceType("local");function a(){let h=null;async function p(m){m.addEventListener("end",A),await e.xr.setSession(m),s.textContent="EXIT VR",h=m}function A(){h?.removeEventListener("end",A),s.textContent="ENTER VR",h=null}s.style.display="",s.style.cursor="pointer",s.style.left="calc(50% - 100px)",s.style.width="200px",s.style.height="100px",s.textContent="ENTER VR";const y={...t,optionalFeatures:[...t.optionalFeatures||[]]};s.onmouseenter=()=>{s.style.opacity="1.0"},s.onmouseleave=()=>{s.style.opacity="0.5"},s.onclick=()=>{h===null?i.requestSession("immersive-vr",y).then(p):h.end()}}function o(){s.style.display="none",s.style.cursor="auto",s.style.left="calc(50% - 75px)",s.style.width="150px",s.onmouseenter=null,s.onmouseleave=null,s.onclick=null}function l(){o(),s.textContent="VR NOT SUPPORTED"}function c(h){o(),s.textContent="VR NOT ALLOWED"}function d(h){h.style.position="absolute",h.style.bottom="20px",h.style.padding="12px 6px",h.style.border="1px solid #fff",h.style.borderRadius="4px",h.style.background="rgba(0,0,0,0.1)",h.style.color="#fff",h.style.font="normal 13px sans-serif",h.style.textAlign="center",h.style.opacity="0.5",h.style.outline="none",h.style.zIndex="999"}return s.id="VRButton",s.style.display="none",d(s),i.isSessionSupported("immersive-vr").then(h=>{h?a():l(),h&&ww.xrSessionIsGranted&&s.click()}).catch(c),s}static registerSessionGrantedListener(){const e=navigator.xr;if(!e)return null;const t=e;/WebXRViewer\//i.test(navigator.userAgent)||t.addEventListener("sessiongranted",()=>{ww.xrSessionIsGranted=!0})}};oP.xrSessionIsGranted=!1;let rZ=oP;rZ.registerSessionGrantedListener();var lP=(n=>(n.w="wrist",n.t0="thumb-metacarpal",n.t1="thumb-phalanx-proximal",n.t2="thumb-phalanx-distal",n.t3="thumb-tip",n.i0="index-finger-metacarpal",n.i1="index-finger-phalanx-proximal",n.i2="index-finger-phalanx-intermediate",n.i3="index-finger-phalanx-distal",n.i4="index-finger-tip",n.m0="middle-finger-metacarpal",n.m1="middle-finger-phalanx-proximal",n.m2="middle-finger-phalanx-intermediate",n.m3="middle-finger-phalanx-distal",n.m4="middle-finger-tip",n.r0="ring-finger-metacarpal",n.r1="ring-finger-phalanx-proximal",n.r2="ring-finger-phalanx-intermediate",n.r3="ring-finger-phalanx-distal",n.r4="ring-finger-tip",n.p0="pinky-finger-metacarpal",n.p1="pinky-finger-phalanx-proximal",n.p2="pinky-finger-phalanx-intermediate",n.p3="pinky-finger-phalanx-distal",n.p4="pinky-finger-tip",n))(lP||{});const iZ=Object.keys(lP);iZ.length;new de(0,0,-1),new de(0,0,1),new de(-1,0,0),new de(1,0,0),new de(0,1,0),new de(0,-1,0);new de(0,0,-1),new de(0,0,1),new de(-1,0,0),new de(1,0,0),new de(0,1,0),new de(0,-1,0);new de(0,0,1),new de(0,0,-1);new de(0,-1,0),new de(0,1,0),new de(-1,0,0),new de(1,0,0);const jv=Math.PI/180,sZ=new In().setFromEuler(new Hi(Math.PI,0,0));function cP(n,e){const t=e.scale??1,r=e.xOffset??0,i=e.yOffset??0,s=e.zOffset??0,a=(e.roll??0)*jv,o=(e.pitch??0)*jv,l=(e.yaw??0)*jv;n.scale.setScalar(t);const c=new In().setFromEuler(new Hi(o,l,a));n.quaternion.copy(sZ.clone().multiply(c)),n.position.set(r*t,s*t,i*t)}function eB(n,e){const t=n.url;if(!t)throw new Error("SplatConfig.url must be resolved before calling loadSplat. Use App.tsx resolvedSplatConfig.");const r=new UI({url:t});return cP(r,n),e.add(r),r}function tB(n,e){e.remove(n),n.dispose?.()}function nB(n,e){if(e===uH)return n;if(e===sw||e===WN){let t=n.getIndex();if(t===null){const a=[],o=n.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);n.setIndex(a),t=n.getIndex()}else return n}const r=t.count-2,i=[];if(e===sw)for(let a=1;a<=r;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<r;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3;const s=n.clone();return s.setIndex(i),s.clearGroups(),s}else return n}class aZ extends lu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new dZ(t)}),this.register(function(t){return new hZ(t)}),this.register(function(t){return new _Z(t)}),this.register(function(t){return new bZ(t)}),this.register(function(t){return new wZ(t)}),this.register(function(t){return new pZ(t)}),this.register(function(t){return new AZ(t)}),this.register(function(t){return new mZ(t)}),this.register(function(t){return new gZ(t)}),this.register(function(t){return new uZ(t)}),this.register(function(t){return new yZ(t)}),this.register(function(t){return new fZ(t)}),this.register(function(t){return new vZ(t)}),this.register(function(t){return new xZ(t)}),this.register(function(t){return new lZ(t)}),this.register(function(t){return new EZ(t)}),this.register(function(t){return new IZ(t)})}load(e,t,r,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Ap.extractUrlBase(e);a=Ap.resolveURL(c,this.path)}else a=Ap.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i&&i(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new MI(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,a,function(d){t(d),s.manager.itemEnd(e)},o)}catch(d){o(d)}},r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,i){let s;const a={},o={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===uP){try{a[cn.KHR_BINARY_GLTF]=new CZ(e)}catch(h){i&&i(h);return}s=JSON.parse(a[cn.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new zZ(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const h=this.pluginCallbacks[d](c);h.name,o[h.name]=h,a[h.name]=!0}if(s.extensionsUsed)for(let d=0;d<s.extensionsUsed.length;++d){const h=s.extensionsUsed[d],p=s.extensionsRequired||[];switch(h){case cn.KHR_MATERIALS_UNLIT:a[h]=new cZ;break;case cn.KHR_DRACO_MESH_COMPRESSION:a[h]=new SZ(s,this.dracoLoader);break;case cn.KHR_TEXTURE_TRANSFORM:a[h]=new BZ;break;case cn.KHR_MESH_QUANTIZATION:a[h]=new MZ;break;default:p.indexOf(h)>=0&&o[h]}}c.setExtensions(a),c.setPlugins(o),c.parse(r,i)}parseAsync(e,t){const r=this;return new Promise(function(i,s){r.parse(e,t,i,s)})}}function oZ(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const cn={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class lZ{constructor(e){this.parser=e,this.name=cn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,i=t.length;r<i;r++){const s=t[r];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let i=t.cache.get(r);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const d=new xt(16777215);l.color!==void 0&&d.setRGB(l.color[0],l.color[1],l.color[2],ri);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new uw(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new pQ(d),c.distance=h;break;case"spot":c=new fQ(d),c.distance=h,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),va(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(r,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,s=r.json.nodes[e],o=(s.extensions&&s.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return r._getNodeRef(t.cache,o,l)})}}class cZ{constructor(){this.name=cn.KHR_MATERIALS_UNLIT}getMaterialType(){return Oc}extendParams(e,t,r){const i=[];e.color=new xt(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],ri),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(r.assignTexture(e,"map",s.baseColorTexture,Ar))}return Promise.all(i)}}class uZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class dZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(r.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Dt(o,o)}return Promise.all(s)}}class hZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_DISPERSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class fZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(s)}}class pZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new xt(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],ri)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(r.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Ar)),a.sheenRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(s)}}class AZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(r.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(s)}}class mZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(r.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new xt().setRGB(o[0],o[1],o[2],ri),Promise.all(s)}}class gZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class yZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(r.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new xt().setRGB(o[0],o[1],o[2],ri),a.specularColorTexture!==void 0&&s.push(r.assignTexture(t,"specularColorMap",a.specularColorTexture,Ar)),Promise.all(s)}}class xZ{constructor(e){this.parser=e,this.name=cn.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(r.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(s)}}class vZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(r.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(s)}}class _Z{constructor(e){this.parser=e,this.name=cn.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,i=r.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,a)}}class bZ{constructor(e){this.parser=e,this.name=cn.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let l=r.textureLoader;if(o.uri){const c=r.options.manager.getHandler(o.uri);c!==null&&(l=c)}return r.loadTextureImage(e,a.source,l)}}class wZ{constructor(e){this.parser=e,this.name=cn.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let l=r.textureLoader;if(o.uri){const c=r.options.manager.getHandler(o.uri);c!==null&&(l=c)}return r.loadTextureImage(e,a.source,l)}}class EZ{constructor(e){this.name=cn.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const i=r.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(o){const l=i.byteOffset||0,c=i.byteLength||0,d=i.count,h=i.byteStride,p=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(d,h,p,i.mode,i.filter).then(function(A){return A.buffer}):a.ready.then(function(){const A=new ArrayBuffer(d*h);return a.decodeGltfBuffer(new Uint8Array(A),d,h,p,i.mode,i.filter),A})})}else return null}}class IZ{constructor(e){this.name=cn.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const i=t.meshes[r.mesh];for(const c of i.primitives)if(c.mode!==ns.TRIANGLES&&c.mode!==ns.TRIANGLE_STRIP&&c.mode!==ns.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=r.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(d=>(l[c]=d,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const d=c.pop(),h=d.isGroup?d.children:[d],p=c[0].count,A=[];for(const y of h){const m=new Ft,x=new de,g=new In,_=new de(1,1,1),b=new lw(y.geometry,y.material,p);for(let w=0;w<p;w++)l.TRANSLATION&&x.fromBufferAttribute(l.TRANSLATION,w),l.ROTATION&&g.fromBufferAttribute(l.ROTATION,w),l.SCALE&&_.fromBufferAttribute(l.SCALE,w),b.setMatrixAt(w,m.compose(x,g,_));for(const w in l)if(w==="_COLOR_0"){const I=l[w];b.instanceColor=new Gg(I.array,I.itemSize,I.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&y.geometry.setAttribute(w,l[w]);zn.prototype.copy.call(b,y),this.parser.assignFinalMaterial(b),A.push(b)}return d.isGroup?(d.clear(),d.add(...A),d):A[0]}))}}const uP="glTF",Ff=12,rB={JSON:1313821514,BIN:5130562};class CZ{constructor(e){this.name=cn.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ff),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==uP)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Ff,s=new DataView(e,Ff);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===rB.JSON){const c=new Uint8Array(e,Ff+a,o);this.content=r.decode(c)}else if(l===rB.BIN){const c=Ff+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class SZ{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=cn.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const d in a){const h=Ew[d]||d.toLowerCase();o[h]=a[d]}for(const d in e.attributes){const h=Ew[d]||d.toLowerCase();if(a[d]!==void 0){const p=r.accessors[e.attributes[d]],A=Ud[p.componentType];c[h]=A.name,l[h]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(d){return new Promise(function(h,p){i.decodeDracoFile(d,function(A){for(const y in A.attributes){const m=A.attributes[y],x=l[y];x!==void 0&&(m.normalized=x)}h(A)},o,c,ri,p)})})}}class BZ{constructor(){this.name=cn.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class MZ{constructor(){this.name=cn.KHR_MESH_QUANTIZATION}}class dP extends Gp{constructor(e,t,r,i){super(e,t,r,i)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let a=0;a!==i;a++)t[a]=r[s+a];return t}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,d=i-t,h=(r-t)/d,p=h*h,A=p*h,y=e*c,m=y-c,x=-2*A+3*p,g=A-p,_=1-x,b=g-p+h;for(let w=0;w!==o;w++){const I=a[m+w+o],S=a[m+w+l]*d,M=a[y+w+o],T=a[y+w]*d;s[w]=_*I+b*S+x*M+g*T}return s}}const TZ=new In;class RZ extends dP{interpolate_(e,t,r,i){const s=super.interpolate_(e,t,r,i);return TZ.fromArray(s).normalize().toArray(s),s}}const ns={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ud={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},iB={9728:mr,9729:ir,9984:UN,9985:mg,9986:tp,9987:Ia},sB={33071:os,33648:Fg,10497:Fl},Wv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ew={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},wl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},DZ={CUBICSPLINE:void 0,LINEAR:Tp,STEP:Mp},qv={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kZ(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new Jd({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Eo})),n.DefaultMaterial}function wc(n,e,t){for(const r in t.extensions)n[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function va(n,e){e.extras!==void 0&&typeof e.extras=="object"&&Object.assign(n.userData,e.extras)}function NZ(n,e,t){let r=!1,i=!1,s=!1;for(let c=0,d=e.length;c<d;c++){const h=e[c];if(h.POSITION!==void 0&&(r=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(n);const a=[],o=[],l=[];for(let c=0,d=e.length;c<d;c++){const h=e[c];if(r){const p=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):n.attributes.position;a.push(p)}if(i){const p=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):n.attributes.normal;o.push(p)}if(s){const p=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):n.attributes.color;l.push(p)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const d=c[0],h=c[1],p=c[2];return r&&(n.morphAttributes.position=d),i&&(n.morphAttributes.normal=h),s&&(n.morphAttributes.color=p),n.morphTargetsRelative=!0,n})}function QZ(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let r=0,i=t.length;r<i;r++)n.morphTargetDictionary[t[r]]=r}}}function PZ(n){let e;const t=n.extensions&&n.extensions[cn.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Yv(t.attributes):e=n.indices+":"+Yv(n.attributes)+":"+n.mode,n.targets!==void 0)for(let r=0,i=n.targets.length;r<i;r++)e+=":"+Yv(n.targets[r]);return e}function Yv(n){let e="";const t=Object.keys(n).sort();for(let r=0,i=t.length;r<i;r++)e+=t[r]+":"+n[t[r]]+";";return e}function Iw(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function LZ(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const FZ=new Ft;class zZ{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new oZ,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,i=-1,s=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=r&&l?parseInt(l[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&i<17||s&&a<98?this.textureLoader=new Q9(this.options.manager):this.textureLoader=new O9(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new MI(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:r,userData:{}};return wc(s,o,i),va(o,i),Promise.all(r._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(r[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const i=r.clone(),s=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,d]of a.children.entries())s(d,o.children[c])};return s(r,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const i=e(t[r]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&r.push(s)}return r}getDependency(e,t){const r=e+":"+t;let i=this.cache.get(r);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(r,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,a){return r.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[cn.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,a){r.load(Ap.resolveURL(t.uri,i.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(r){const i=t.byteLength||0,s=t.byteOffset||0;return r.slice(s,s+i)})}loadAccessor(e){const t=this,r=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Wv[i.type],o=Ud[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new or(c,a,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],l=Wv[i.type],c=Ud[i.componentType],d=c.BYTES_PER_ELEMENT,h=d*l,p=i.byteOffset||0,A=i.bufferView!==void 0?r.bufferViews[i.bufferView].byteStride:void 0,y=i.normalized===!0;let m,x;if(A&&A!==h){const g=Math.floor(p/A),_="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+g+":"+i.count;let b=t.cache.get(_);b||(m=new c(o,g*A,i.count*A/d),b=new o9(m,A/d),t.cache.add(_,b)),x=new bI(b,l,p%A/d,y)}else o===null?m=new c(i.count*l):m=new c(o,p,i.count*l),x=new or(m,l,y);if(i.sparse!==void 0){const g=Wv.SCALAR,_=Ud[i.sparse.indices.componentType],b=i.sparse.indices.byteOffset||0,w=i.sparse.values.byteOffset||0,I=new _(a[1],b,i.sparse.count*g),S=new c(a[2],w,i.sparse.count*l);o!==null&&(x=new or(x.array.slice(),x.itemSize,x.normalized)),x.normalized=!1;for(let M=0,T=I.length;M<T;M++){const R=I[M];if(x.setX(R,S[M*l]),l>=2&&x.setY(R,S[M*l+1]),l>=3&&x.setZ(R,S[M*l+2]),l>=4&&x.setW(R,S[M*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=y}return x})}loadTexture(e){const t=this.json,r=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const l=r.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,r){const i=this,s=this.json,a=s.textures[e],o=s.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,r).then(function(d){d.flipY=!1,d.name=a.name||o.name||"",d.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(d.name=o.uri);const p=(s.samplers||{})[a.sampler]||{};return d.magFilter=iB[p.magFilter]||ir,d.minFilter=iB[p.minFilter]||Ia,d.wrapS=sB[p.wrapS]||Fl,d.wrapT=sB[p.wrapT]||Fl,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==mr&&d.minFilter!==ir,i.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const r=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=r.getDependency("bufferView",a.bufferView).then(function(h){c=!0;const p=new Blob([h],{type:a.mimeType});return l=o.createObjectURL(p),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(l).then(function(h){return new Promise(function(p,A){let y=p;t.isImageBitmapLoader===!0&&(y=function(m){const x=new ar(m);x.needsUpdate=!0,p(x)}),t.load(Ap.resolveURL(h,s.path),y,void 0,A)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),va(h,a),h.userData.mimeType=a.mimeType||LZ(a.uri),h}).catch(function(h){throw h});return this.sourceCache[e]=d,d}assignTexture(e,t,r,i){const s=this;return this.getDependency("texture",r.index).then(function(a){if(!a)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(a=a.clone(),a.channel=r.texCoord),s.extensions[cn.KHR_TEXTURE_TRANSFORM]){const o=r.extensions!==void 0?r.extensions[cn.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=s.associations.get(a);a=s.extensions[cn.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+r.uuid;let l=this.cache.get(o);l||(l=new lQ,Xs.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,l.sizeAttenuation=!1,this.cache.add(o,l)),r=l}else if(e.isLine){const o="LineBasicMaterial:"+r.uuid;let l=this.cache.get(o);l||(l=new oQ,Xs.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,this.cache.add(o,l)),r=l}if(i||s||a){let o="ClonedMaterial:"+r.uuid+":";i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=r.clone(),s&&(l.vertexColors=!0),a&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(r))),r=l}e.material=r}getMaterialType(){return Jd}loadMaterial(e){const t=this,r=this.json,i=this.extensions,s=r.materials[e];let a;const o={},l=s.extensions||{},c=[];if(l[cn.KHR_MATERIALS_UNLIT]){const h=i[cn.KHR_MATERIALS_UNLIT];a=h.getMaterialType(),c.push(h.extendParams(o,s,t))}else{const h=s.pbrMetallicRoughness||{};if(o.color=new xt(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const p=h.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],ri),o.opacity=p[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",h.baseColorTexture,Ar)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),a=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=rs);const d=s.alphaMode||qv.OPAQUE;if(d===qv.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,d===qv.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Oc&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new Dt(1,1),s.normalTexture.scale!==void 0)){const h=s.normalTexture.scale;o.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&a!==Oc&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Oc){const h=s.emissiveFactor;o.emissive=new xt().setRGB(h[0],h[1],h[2],ri)}return s.emissiveTexture!==void 0&&a!==Oc&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Ar)),Promise.all(c).then(function(){const h=new a(o);return s.name&&(h.name=s.name),va(h,s),t.associations.set(h,{materials:e}),s.extensions&&wc(i,h,s),h})}createUniqueName(e){const t=Bn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,i=this.primitiveCache;function s(o){return r[cn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return aB(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],d=PZ(c),h=i[d];if(h)a.push(h.promise);else{let p;c.extensions&&c.extensions[cn.KHR_DRACO_MESH_COMPRESSION]?p=s(c):p=aB(new _r,c,t),i[d]={primitive:c,promise:p},a.push(p)}}return Promise.all(a)}loadMesh(e){const t=this,r=this.json,i=this.extensions,s=r.meshes[e],a=s.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const d=a[l].material===void 0?kZ(this.cache):this.getDependency("material",a[l].material);o.push(d)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),d=l[l.length-1],h=[];for(let A=0,y=d.length;A<y;A++){const m=d[A],x=a[A];let g;const _=c[A];if(x.mode===ns.TRIANGLES||x.mode===ns.TRIANGLE_STRIP||x.mode===ns.TRIANGLE_FAN||x.mode===void 0)g=s.isSkinnedMesh===!0?new c9(m,_):new Jn(m,_),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),x.mode===ns.TRIANGLE_STRIP?g.geometry=nB(g.geometry,WN):x.mode===ns.TRIANGLE_FAN&&(g.geometry=nB(g.geometry,sw));else if(x.mode===ns.LINES)g=new A9(m,_);else if(x.mode===ns.LINE_STRIP)g=new II(m,_);else if(x.mode===ns.LINE_LOOP)g=new m9(m,_);else if(x.mode===ns.POINTS)g=new g9(m,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(g.geometry.morphAttributes).length>0&&QZ(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),va(g,s),x.extensions&&wc(i,g,x),t.assignFinalMaterial(g),h.push(g)}for(let A=0,y=h.length;A<y;A++)t.associations.set(h[A],{meshes:e,primitives:A});if(h.length===1)return s.extensions&&wc(i,h[0],s),h[0];const p=new ls;s.extensions&&wc(i,p,s),t.associations.set(p,{meshes:e});for(let A=0,y=h.length;A<y;A++)p.add(h[A]);return p})}loadCamera(e){let t;const r=this.json.cameras[e],i=r[r.type];if(i)return r.type==="perspective"?t=new Fr(XN.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):r.type==="orthographic"&&(t=new $0(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),va(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let i=0,s=t.joints.length;i<s;i++)r.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(i){const s=i.pop(),a=i,o=[],l=[];for(let c=0,d=a.length;c<d;c++){const h=a[c];if(h){o.push(h);const p=new Ft;s!==null&&p.fromArray(s.array,c*16),l.push(p)}}return new wI(o,l)})}loadAnimation(e){const t=this.json,r=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],d=[];for(let h=0,p=i.channels.length;h<p;h++){const A=i.channels[h],y=i.samplers[A.sampler],m=A.target,x=m.node,g=i.parameters!==void 0?i.parameters[y.input]:y.input,_=i.parameters!==void 0?i.parameters[y.output]:y.output;m.node!==void 0&&(a.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",g)),l.push(this.getDependency("accessor",_)),c.push(y),d.push(m))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(d)]).then(function(h){const p=h[0],A=h[1],y=h[2],m=h[3],x=h[4],g=[];for(let b=0,w=p.length;b<w;b++){const I=p[b],S=A[b],M=y[b],T=m[b],R=x[b];if(I===void 0)continue;I.updateMatrix&&I.updateMatrix();const k=r._createAnimationTracks(I,S,M,T,R);if(k)for(let H=0;H<k.length;H++)g.push(k[H])}const _=new B9(s,void 0,g);return va(_,i),_})}createNodeMesh(e){const t=this.json,r=this,i=t.nodes[e];return i.mesh===void 0?null:r.getDependency("mesh",i.mesh).then(function(s){const a=r._getNodeRef(r.meshCache,i.mesh,s);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,r=this,i=t.nodes[e],s=r._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,d=o.length;c<d;c++)a.push(r.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):r.getDependency("skin",i.skin);return Promise.all([s,Promise.all(a),l]).then(function(c){const d=c[0],h=c[1],p=c[2];p!==null&&d.traverse(function(A){A.isSkinnedMesh&&A.bind(p,FZ)});for(let A=0,y=h.length;A<y;A++)d.add(h[A]);return d})}_loadNodeShallow(e){const t=this.json,r=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?i.createUniqueName(s.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),s.camera!==void 0&&o.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let d;if(s.isBone===!0?d=new aQ:c.length>1?d=new ls:c.length===1?d=c[0]:d=new zn,d!==c[0])for(let h=0,p=c.length;h<p;h++)d.add(c[h]);if(s.name&&(d.userData.name=s.name,d.name=a),va(d,s),s.extensions&&wc(r,d,s),s.matrix!==void 0){const h=new Ft;h.fromArray(s.matrix),d.applyMatrix4(h)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);if(!i.associations.has(d))i.associations.set(d,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const h=i.associations.get(d);i.associations.set(d,{...h})}return i.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],i=this,s=new ls;r.name&&(s.name=i.createUniqueName(r.name)),va(s,r),r.extensions&&wc(t,s,r);const a=r.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let d=0,h=l.length;d<h;d++)s.add(l[d]);const c=d=>{const h=new Map;for(const[p,A]of i.associations)(p instanceof Xs||p instanceof ar)&&h.set(p,A);return d.traverse(p=>{const A=i.associations.get(p);A!=null&&h.set(p,A)}),h};return i.associations=c(s),s})}_createAnimationTracks(e,t,r,i,s){const a=[],o=e.name?e.name:e.uuid,l=[];wl[s.path]===wl.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let c;switch(wl[s.path]){case wl.weights:c=Kd;break;case wl.rotation:c=Zd;break;case wl.translation:case wl.scale:c=eh;break;default:r.itemSize===1?c=Kd:c=eh;break}const d=i.interpolation!==void 0?DZ[i.interpolation]:Tp,h=this._getArrayFromAccessor(r);for(let p=0,A=l.length;p<A;p++){const y=new c(l[p]+"."+wl[s.path],t.array,h,d);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),a.push(y)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=Iw(t.constructor),i=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)i[s]=t[s]*r;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const i=this instanceof Zd?RZ:dP;return new i(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function UZ(n,e,t){const r=e.attributes,i=new ms;if(r.POSITION!==void 0){const o=t.json.accessors[r.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new de(l[0],l[1],l[2]),new de(c[0],c[1],c[2])),o.normalized){const d=Iw(Ud[o.componentType]);i.min.multiplyScalar(d),i.max.multiplyScalar(d)}}else return}else return;const s=e.targets;if(s!==void 0){const o=new de,l=new de;for(let c=0,d=s.length;c<d;c++){const h=s[c];if(h.POSITION!==void 0){const p=t.json.accessors[h.POSITION],A=p.min,y=p.max;if(A!==void 0&&y!==void 0){if(l.setX(Math.max(Math.abs(A[0]),Math.abs(y[0]))),l.setY(Math.max(Math.abs(A[1]),Math.abs(y[1]))),l.setZ(Math.max(Math.abs(A[2]),Math.abs(y[2]))),p.normalized){const m=Iw(Ud[p.componentType]);l.multiplyScalar(m)}o.max(l)}}}i.expandByVector(o)}n.boundingBox=i;const a=new Fa;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,n.boundingSphere=a}function aB(n,e,t){const r=e.attributes,i=[];function s(a,o){return t.getDependency("accessor",a).then(function(l){n.setAttribute(o,l)})}for(const a in r){const o=Ew[a]||a.toLowerCase();o in n.attributes||i.push(s(r[a],o))}if(e.indices!==void 0&&!n.index){const a=t.getDependency("accessor",e.indices).then(function(o){n.setIndex(o)});i.push(a)}return mn.workingColorSpace!==ri&&"COLOR_0"in r,va(n,e),UZ(n,e,t),Promise.all(i).then(function(){return e.targets!==void 0?NZ(n,e.targets,t):n})}async function oB(n,e){const i=(await new aZ().loadAsync(n)).scene;return i.traverse(s=>{s.visible=!1}),e.add(i),i}function lB(n,e){e.remove(n),n.traverse(t=>{const r=t;r.geometry?.dispose(),Array.isArray(r.material)?r.material.forEach(i=>i.dispose()):r.material?.dispose()})}class cB{constructor(e){this.onPointer=s=>{s.type==="pointerdown"?(this.start(s.clientX,s.clientY),this.mouseDown=!0):s.type==="pointermove"&&this.mouseDown?this.move(s.clientX,s.clientY):s.type==="pointerup"&&this.end()},this.scene=e.scene,this.renderer=e.renderer,this.camera=e.camera,this.container=e.container,this.controls=e.controls,this.draggableBodyIds=e.draggableBodyIds??null,this.mousePos=new Dt,this.raycaster=new K9,this.raycaster.params.Line.threshold=.1,this.grabDistance=0,this.active=!1,this.mouseDown=!1,this.physicsObject=null,this.localHit=new de,this.worldHit=new de,this.currentWorld=new de,this.offset=new de,this.arrow=new ls;const t=new gh(.008,.008,1),r=new Jd({color:16737095,transparent:!0,opacity:.5,metalness:0,roughness:.2});this.arrowShaft=new Jn(t,r),this.arrowShaft.position.y=.5;const i=new SI(.03,.1);this.arrowHead=new Jn(i,r),this.arrowHead.position.y=1,this.arrow.add(this.arrowShaft),this.arrow.add(this.arrowHead),this.arrow.visible=!1,this.scene.add(this.arrow),this.container.addEventListener("pointerdown",this.onPointer,!0),document.addEventListener("pointermove",this.onPointer,!0),document.addEventListener("pointerup",this.onPointer,!0)}updateRaycaster(e,t){const r=this.renderer.domElement.getBoundingClientRect();this.mousePos.x=(e-r.left)/r.width*2-1,this.mousePos.y=-((t-r.top)/r.height)*2+1,this.raycaster.setFromCamera(this.mousePos,this.camera)}start(e,t){this.physicsObject=null,this.updateRaycaster(e,t);const r=this.raycaster.intersectObjects(this.scene.children,!0);for(const i of r){const s=i.object;if(!this.shouldIgnoreForDrag(s)&&this.isDraggableObject(s)){this.physicsObject=s,this.grabDistance=i.distance;const a=this.raycaster.ray.origin.clone().addScaledVector(this.raycaster.ray.direction,this.grabDistance);this.localHit.copy(s.worldToLocal(a.clone())),this.worldHit.copy(a),this.currentWorld.copy(a),this.offset.set(0,0,0),this.arrow.position.copy(a),this.arrow.visible=!1,this.active=!0,this.controls.enabled=!1;break}}}setDraggableBodyIds(e){this.draggableBodyIds=e}isDraggableObject(e){if(!("bodyID"in e)||typeof e.bodyID!="number")return!1;const t=e.bodyID;return!(t<=0||this.draggableBodyIds&&!this.draggableBodyIds.has(t))}shouldIgnoreForDrag(e){let t=e;for(;t;){if(t.userData?.ignoreDragForce===!0)return!0;t=t.parent}return!1}move(e,t){this.active&&this.updateRaycaster(e,t)}update(){if(!this.physicsObject||!this.active)return;this.raycaster.setFromCamera(this.mousePos,this.camera),this.currentWorld.copy(this.raycaster.ray.origin.clone().addScaledVector(this.raycaster.ray.direction,this.grabDistance)),this.worldHit.copy(this.localHit),this.physicsObject.localToWorld(this.worldHit),this.offset.copy(this.currentWorld).sub(this.worldHit),this.arrow.position.copy(this.worldHit);const e=this.offset.length();if(e>.001){this.arrow.visible=!0;const t=this.offset.clone().normalize();this.arrow.quaternion.setFromUnitVectors(new de(0,1,0),t);const r=.1,i=Math.max(.01,e-r);this.arrowShaft.scale.y=i,this.arrowShaft.position.y=i/2,this.arrowHead.position.y=i+r/2}else this.arrow.visible=!1}end(){this.physicsObject=null,this.active=!1,this.controls.enabled=!0,this.arrow.visible=!1,this.mouseDown=!1}dispose(){this.container.removeEventListener("pointerdown",this.onPointer,!0),document.removeEventListener("pointermove",this.onPointer,!0),document.removeEventListener("pointerup",this.onPointer,!0),this.arrow.parent&&this.scene.remove(this.arrow),this.arrowShaft.geometry.dispose(),this.arrowHead.geometry.dispose(),this.arrowShaft.material&&this.arrowShaft.material.dispose()}}const zf={lookat:[0,0,0],distance:4,elevation:-30,azimuth:45,fovy:45};function OZ(n,e,t,r){const i=t*Math.PI/180,s=r*Math.PI/180,a=n[0]+e*Math.cos(i)*Math.cos(s),o=n[1]+e*Math.cos(i)*Math.sin(s),l=n[2]-e*Math.sin(i);return zl([a,o,l])}function $Z(n,e,t,r,i){const s={trackBodyId:null,prevBodyPos:null};t.enabled=!0;const a=n?.lookat??zf.lookat,o=n?.distance??zf.distance,l=n?.elevation??zf.elevation,c=n?.azimuth??zf.azimuth;if(e.fov=n?.fovy??zf.fovy,e.updateProjectionMatrix(),e.position.copy(OZ(a,o,l,c)),t.target.copy(zl(a)),t.update(),!n)return s;const d=n.originType??"AUTO";if(d==="ASSET_BODY"&&n.bodyName&&r){const h=n.bodyName,p=n.entityName,A=p?`${p}/${h}`:null;for(let y=0;y<r.nbody;y++){const m=r.body(y).name;if(m===h||m===A||m.endsWith(`/${h}`)){s.trackBodyId=y;break}}s.trackBodyId}else(d==="AUTO"||d==="ASSET_ROOT")&&r&&r.nbody>1&&(s.trackBodyId=1);if(s.trackBodyId!==null&&i){const h=zl(i.xpos.slice(s.trackBodyId*3,s.trackBodyId*3+3));e.position.add(h),t.target.add(h),s.prevBodyPos=h,t.update()}return s}function GZ(n,e,t,r){if(r.trackBodyId!==null){const i=r.trackBodyId,s=zl(n.xpos.slice(i*3,i*3+3));if(r.prevBodyPos!==null){const a=s.clone().sub(r.prevBodyPos);e.position.add(a),t.target.add(a)}r.prevBodyPos=s}}const Tl=class Tl{constructor(e){this.MAX_CACHE_SIZE=5,this.mujoco=e,this.cache=new Map,this.metrics={totalScenes:0,totalMemoryBytes:0,oldestAccessTime:Date.now(),newestAccessTime:Date.now(),cacheHits:0,cacheMisses:0,evictions:0}}static getInstance(e){return Tl.instance||(Tl.instance=new Tl(e)),Tl.instance}static resetInstance(){Tl.instance=null}normalizeScenePath(e){return e?QI(e):""}has(e){const t=this.normalizeScenePath(e);return this.cache.has(t)}get(e){const t=this.normalizeScenePath(e),r=this.cache.get(t);return r?(r.lastAccessed=Date.now(),this.metrics.cacheHits++,this.updateMetricsTimestamps(),r):(this.metrics.cacheMisses++,null)}async set(e,t){const r=this.normalizeScenePath(e);!this.cache.has(r)&&this.cache.size>=this.MAX_CACHE_SIZE&&await this.maybeEvict(),t.scenePath=r,t.lastAccessed=Date.now(),this.cache.set(r,t),this.updateMetrics()}async evict(e){const t=this.normalizeScenePath(e),r=this.cache.get(t);r&&(await this.disposeSceneResources(r),this.cache.delete(t),this.metrics.evictions++,this.updateMetrics())}async clear(){const e=Array.from(this.cache.keys());for(const t of e)await this.evict(t)}getMetrics(){return{...this.metrics}}async prepareForNewScene(){this.cache.size>=this.MAX_CACHE_SIZE&&await this.maybeEvict()}findLRUScene(){let e=null,t=1/0;for(const[r,i]of this.cache.entries())i.lastAccessed<t&&(t=i.lastAccessed,e=r);return e}async maybeEvict(){const e=this.findLRUScene();e&&await this.evict(e)}async disposeSceneResources(e){const t=performance.now();if(e.skybox&&e.skybox.dispose(),e.mujocoRoot&&this.disposeThreeJSObject(e.mujocoRoot),e.mjData)try{e.mjData.delete()}catch{}if(e.mjModel)try{e.mjModel.delete()}catch{}for(const r of e.fsFiles)try{const i=`/working/${r}`;this.mujoco.FS.analyzePath(i,!1).exists&&this.mujoco.FS.unlink(i)}catch{}gX(e.scenePath),performance.now()-t,(e.estimatedMemoryBytes/1048576).toFixed(1)}disposeThreeJSObject(e){e.traverse(t=>{"geometry"in t&&t.geometry&&t.geometry.dispose(),"material"in t&&t.material&&(Array.isArray(t.material)?t.material.forEach(r=>this.disposeMaterial(r)):this.disposeMaterial(t.material))}),e.parent&&e.parent.remove(e)}disposeMaterial(e){const t=e;t.map&&t.map.dispose(),t.aoMap&&t.aoMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.envMap&&t.envMap.dispose(),t.alphaMap&&t.alphaMap.dispose(),t.lightMap&&t.lightMap.dispose(),t.displacementMap&&t.displacementMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),e.dispose()}updateMetrics(){this.metrics.totalScenes=this.cache.size,this.metrics.totalMemoryBytes=0;for(const e of this.cache.values())this.metrics.totalMemoryBytes+=e.estimatedMemoryBytes;this.updateMetricsTimestamps()}updateMetricsTimestamps(){let e=Date.now(),t=0;for(const r of this.cache.values())r.lastAccessed<e&&(e=r.lastAccessed),r.lastAccessed>t&&(t=r.lastAccessed);this.metrics.oldestAccessTime=e,this.metrics.newestAccessTime=t}};Tl.instance=null;let Cw=Tl;class VZ{constructor(){this.fsWriteLog=[],this.isTracking=!1}startTracking(e){if(this.isTracking)return;this.fsWriteLog=[],this.isTracking=!0,this.originalWriteFile=e.FS.writeFile;const t=this.fsWriteLog,r=this.originalWriteFile;e.FS.writeFile=function(i,s,a){if(i.startsWith("/working/")){const o=i.replace(/^\/working\//,"");t.includes(o)||t.push(o)}if(r)return r.call(e.FS,i,s,a)}}stopTracking(e){return this.isTracking?(this.originalWriteFile&&(e.FS.writeFile=this.originalWriteFile,this.originalWriteFile=void 0),this.isTracking=!1,[...this.fsWriteLog]):[]}estimateSceneMemory(e){let t=0;t+=this.estimateMuJoCoMemory(e.mjModel),t+=this.estimateMjDataMemory(e.mjData);const r=new Set,i=new Set,s=new Set;for(const a of Object.values(e.meshes))r.has(a)||(t+=this.estimateGeometryMemory(a),r.add(a));return e.mujocoRoot.traverse(a=>{if("geometry"in a&&a.geometry){const o=a.geometry;r.has(o)||(t+=this.estimateGeometryMemory(o),r.add(o))}if("material"in a&&a.material){const o=Array.isArray(a.material)?a.material:[a.material];for(const l of o)i.has(l)||(t+=1024,i.add(l),this.collectMaterialTextures(l).forEach(c=>{s.has(c)||(t+=this.estimateTextureMemory(c),s.add(c))}))}}),t}collectMaterialTextures(e){const t=[],r=e;return r.map&&t.push(r.map),r.aoMap&&t.push(r.aoMap),r.emissiveMap&&t.push(r.emissiveMap),r.metalnessMap&&t.push(r.metalnessMap),r.normalMap&&t.push(r.normalMap),r.roughnessMap&&t.push(r.roughnessMap),r.envMap&&t.push(r.envMap),r.alphaMap&&t.push(r.alphaMap),r.lightMap&&t.push(r.lightMap),r.displacementMap&&t.push(r.displacementMap),r.bumpMap&&t.push(r.bumpMap),t}estimateMuJoCoMemory(e){let t=0;return e.nq&&(t+=e.nq*8),e.nv&&(t+=e.nv*8),e.nbody&&(t+=e.nbody*256),e.mesh_vert&&(t+=e.mesh_vert.length*4),e.mesh_normal&&(t+=e.mesh_normal.length*4),e.mesh_texcoord&&(t+=e.mesh_texcoord.length*4),e.mesh_face&&(t+=e.mesh_face.length*4),e.tex_data&&(t+=e.tex_data.length),t}estimateMjDataMemory(e){let t=0;return e.qpos&&(t+=e.qpos.length*8),e.qvel&&(t+=e.qvel.length*8),e.qacc&&(t+=e.qacc.length*8),e.qacc_warmstart&&(t+=e.qacc_warmstart.length*8),e.ctrl&&(t+=e.ctrl.length*8),e.qfrc_applied&&(t+=e.qfrc_applied.length*8),e.xfrc_applied&&(t+=e.xfrc_applied.length*8),e.xpos&&(t+=e.xpos.length*8),e.xquat&&(t+=e.xquat.length*8),e.xmat&&(t+=e.xmat.length*8),e.xipos&&(t+=e.xipos.length*8),e.ximat&&(t+=e.ximat.length*8),e.ncon&&(t+=e.ncon*256),e.efc_force&&(t+=e.efc_force.length*8),e.sensordata&&(t+=e.sensordata.length*8),t}estimateGeometryMemory(e){let t=0;const r=e.attributes;for(const i in r){const s=r[i];s&&"array"in s&&(t+=s.array.byteLength)}return e.index&&(t+=e.index.array.byteLength),t}estimateTextureMemory(e){if(!e.image)return 1024;if(e instanceof mh&&Array.isArray(e.image)&&e.image.length===6){let r=0;for(const i of e.image){const s=i;s&&typeof s=="object"&&"width"in s&&"height"in s&&(r+=s.width*s.height*4)}return r}const t=e.image;return t&&typeof t=="object"&&"width"in t&&"height"in t?t.width*t.height*4:1024}}class HZ{getStats(e,t){const r=this.getJSHeapStats(),i={jsHeapUsedMB:r.used,jsHeapTotalMB:r.total,jsHeapLimitMB:r.limit,cachedScenesCount:e.totalScenes,estimatedCacheMemoryMB:e.totalMemoryBytes/1048576,estimatedGPUMemoryMB:0,sceneBreakdown:[]};if(t)for(const[s,a]of t.entries())i.sceneBreakdown.push({scenePath:s,memoryMB:a.memoryBytes/1048576,lastAccessed:new Date(a.lastAccessed)});return i}logCacheOperation(e,t,r){switch(e){case"load":{r?.memoryMB&&`${r.memoryMB.toFixed(1)}`,r?.totalScenes!==void 0&&r?.totalMemoryMB!==void 0&&`${r.totalScenes}${r.totalMemoryMB.toFixed(1)}`;break}case"hit":{r?.elapsedMs!==void 0&&`${r.elapsedMs.toFixed(0)}`;break}case"miss":break;case"evict":{r?.memoryMB&&`${r.memoryMB.toFixed(1)}`;break}}}logStats(e){if(e.sceneBreakdown.length>0)for(const t of e.sceneBreakdown);}getJSHeapStats(){const e=performance;return e.memory?{used:e.memory.usedJSHeapSize/1048576,total:e.memory.totalJSHeapSize/1048576,limit:e.memory.jsHeapSizeLimit/1048576}:{used:0,total:0,limit:0}}estimateGPUMemory(e){const t=e.info,r=t.memory.geometries,i=t.memory.textures;return r*1+i*2}}const jZ={},WZ=jZ;class qZ{constructor(e){this.config=e}}const YZ={};async function XZ(n){const e=new DecompressionStream("deflate-raw"),t=e.writable.getWriter(),r=e.readable.getReader();t.write(n),t.close();const i=[];let s=0;for(;;){const{done:l,value:c}=await r.read();if(l)break;i.push(c),s+=c.byteLength}const a=new Uint8Array(s);let o=0;for(const l of i)a.set(l,o),o+=l.byteLength;return a}function JZ(n){const e=[147,78,85,77,80,89];for(let w=0;w<e.length;w++)if(n[w]!==e[w])throw new Error("Invalid .npy magic number");const t=n[6];let r,i;t===1?(r=n[8]|n[9]<<8,i=10):(r=n[8]|n[9]<<8|n[10]<<16|n[11]<<24,i=12);const s=n.slice(i,i+r),a=new TextDecoder().decode(s),o=a.match(/'descr'\s*:\s*'([^']+)'/),l=a.match(/'shape'\s*:\s*\(([^)]*)\)/),c=a.match(/'fortran_order'\s*:\s*(True|False)/);if(!o||!l)throw new Error(`Cannot parse .npy header: ${a}`);const d=o[1];if(c?c[1]==="True":!1)throw new Error("Fortran-ordered arrays not supported");const A=l[1].split(",").map(w=>w.trim()).filter(w=>w.length>0).map(w=>parseInt(w,10)),y=i+r,m=n.slice(y),x=d[0],g=d.slice(1),_=x===">"||x==="="&&!ZZ();let b;if(g==="f4")b=new Float32Array(m.buffer,m.byteOffset,m.byteLength/4),_&&(b=eee(b));else if(g==="f8"){let w=new Float64Array(m.buffer,m.byteOffset,m.byteLength/8);_&&(w=tee(w)),b=new Float32Array(w.length);for(let I=0;I<w.length;I++)b[I]=w[I]}else if(g==="i4"){let w=new Int32Array(m.buffer,m.byteOffset,m.byteLength/4);_&&(w=nee(w)),b=new Float32Array(w.length);for(let I=0;I<w.length;I++)b[I]=w[I]}else if(g==="i8"){let w=new BigInt64Array(m.buffer,m.byteOffset,m.byteLength/8);_&&(w=ree(w)),b=new Float32Array(w.length);for(let I=0;I<w.length;I++)b[I]=Number(w[I])}else{const w=d.match(/^S(\d+)$/);if(w){const S=parseInt(w[1],10),M=m.length/S,T=A.reduce((H,Q)=>H*Q,1);if(M!==T)throw new Error(`npz: byte-string array size mismatch (shape ${A} expects ${T} elements, got ${M})`);const R=new TextDecoder("utf-8"),k=[];for(let H=0;H<M;H++){const Q=m.slice(H*S,(H+1)*S),V=Q.indexOf(0);k.push(R.decode(V>=0?Q.slice(0,V):Q))}return{shape:A,data:new Float32Array(0),strings:k}}const I=g.match(/^U(\d+)$/);if(I){const S=parseInt(I[1],10),M=S*4,T=m.length/M,R=A.reduce((V,B)=>V*B,1);if(T!==R)throw new Error(`npz: unicode array size mismatch (shape ${A} expects ${R} elements, got ${T})`);const k=new DataView(m.buffer,m.byteOffset,m.byteLength),H=!_,Q=[];for(let V=0;V<T;V++){const B=[];for(let W=0;W<S;W++){const K=k.getUint32(V*M+W*4,H);if(K===0)break;B.push(K)}Q.push(String.fromCodePoint(...B))}return{shape:A,data:new Float32Array(0),strings:Q}}throw g==="O"?new Error(KZ):new Error(`Unsupported numpy dtype: ${d}`)}return{shape:A,data:b}}const KZ="npz: pickled python objects (|O dtype) cannot be loaded in the browser";function ZZ(){const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,1,!0),new Int16Array(n)[0]===1}function eee(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new Float32Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getFloat32(r*4,!0);return t}function tee(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new Float64Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getFloat64(r*8,!0);return t}function nee(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new Int32Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getInt32(r*4,!0);return t}function ree(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new BigInt64Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getBigInt64(r*8,!0);return t}async function iee(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch NPZ: ${e.status} ${n}`);const t=await e.arrayBuffer(),r=new Uint8Array(t),i={};let s=0;for(;s+30<=r.length&&!(r[s]!==80||r[s+1]!==75||r[s+2]!==3||r[s+3]!==4);){const a=r[s+8]|r[s+9]<<8,o=(r[s+22]|r[s+23]<<8|r[s+24]<<16|r[s+25]<<24)>>>0;let l=(r[s+18]|r[s+19]<<8|r[s+20]<<16|r[s+21]<<24)>>>0;const c=r[s+26]|r[s+27]<<8,d=r[s+28]|r[s+29]<<8,h=r.slice(s+30,s+30+c);let p=new TextDecoder().decode(h);if(l===4294967295||o===4294967295){const x=s+30+c;let g=x;for(;g+4<=x+d;){const _=r[g]|r[g+1]<<8,b=r[g+2]|r[g+3]<<8;if(_===1){let w=g+4;if(o===4294967295&&w+8<=g+4+b&&(w+=8),l===4294967295&&w+8<=g+4+b){const I=(r[w]|r[w+1]<<8|r[w+2]<<16|r[w+3]<<24)>>>0;l=((r[w+4]|r[w+5]<<8|r[w+6]<<16|r[w+7]<<24)>>>0)*4294967296+I}break}g+=4+b}}const A=s+30+c+d,y=r.slice(A,A+l);if(s=A+l,p.endsWith("/"))continue;p.endsWith(".npy")&&(p=p.slice(0,-4));let m;if(a===0)m=y;else if(a===8)m=await XZ(y);else continue;try{i[p]=JZ(m)}catch(x){x instanceof Error?x.message:String(x)}}return i}function Xv(n){const e=Math.hypot(n[0]??1,n[1]??0,n[2]??0,n[3]??0)||1;return new Float32Array([(n[0]??1)/e,(n[1]??0)/e,(n[2]??0)/e,(n[3]??0)/e])}function Ec(n){const e=n.shape[0]??0,t=n.shape.length<=1?1:n.shape.slice(1).reduce((i,s)=>i*s,1),r=[];for(let i=0;i<e;i++){const s=new Float32Array(t),a=i*t;for(let o=0;o<t;o++)s[o]=n.data[a+o]??0;r.push(s)}return r}function hP(n,e){if(!Array.isArray(n)||n.length<2)return e;const t=Number(n[0]),r=Number(n[1]);return!Number.isFinite(t)||!Number.isFinite(r)?e:[t,r]}function uB(n){if(n===null||typeof n!="object"||Array.isArray(n))return{};const e={};for(const t of["x","y","z","roll","pitch","yaw"]){const r=hP(n[t],[0,0]);(r[0]!==0||r[1]!==0)&&(e[t]=r)}return e}function Oi(n){return n?n[0]+Math.random()*(n[1]-n[0]):0}function see(n,e){const t=n[0]??1,r=n[1]??0,i=n[2]??0,s=n[3]??0,a=e[0]??1,o=e[1]??0,l=e[2]??0,c=e[3]??0;return new Float32Array([t*a-r*o-i*l-s*c,t*o+r*a+i*c-s*l,t*l-r*c+i*a+s*o,t*c+r*l-i*o+s*a])}function aee(n,e,t){const r=Math.cos(n*.5),i=Math.sin(n*.5),s=Math.cos(e*.5),a=Math.sin(e*.5),o=Math.cos(t*.5),l=Math.sin(t*.5);return new Float32Array([r*s*o+i*a*l,i*s*o-r*a*l,r*a*o+i*s*l,r*s*l-i*a*o])}function dB(n){const e=n.clone();return"transparent"in e&&(e.transparent=!0),"opacity"in e&&(e.opacity=.5),"depthWrite"in e&&(e.depthWrite=!1),"color"in e&&e.color instanceof xt&&(e.color=new xt(.5,.7,.5)),e}function oee(n){let e=!1;return n.traverse(t=>{t instanceof Jn&&(e=!0)}),e}class lee{constructor(e,t,r){this.context=r,this.motions=Array.isArray(t.motions)?t.motions:[],this.loadedMotions=new Map,this.sampleHz=50,this.selectedMotionName=this.motions.find(i=>i.default)?.name??this.motions[0]?.name??null,this.selectedMotion=null,this.selectedAnchorBodyIndex=0,this.selectedRootBodyIndex=0,this.datasetQposAdr=[],this.frameAccumulator=0,this.justReset=!0,this.referenceVisible=!0,this.samplingMode=typeof t.sampling_mode=="string"?t.sampling_mode:"start",this.poseRange=uB(t.pose_range),this.velocityRange=uB(t.velocity_range),this.jointPositionRange=hP(t.joint_position_range,[0,0]),this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refIdx=0,this.refLen=0,this.nJoints=this.motions.find(i=>i.name===this.selectedMotionName)?.dataset_joint_names?.length??0,this.ghostBodies=new Map,this.ghostData=r.mjModel?new r.mujoco.MjData(r.mjModel):null,this.ghostRoot=this.createGhostRoot(),this.refBodyPosW=[],this.refBodyQuatW=[],this.refBodyLinVelW=[],this.refBodyAngVelW=[]}getCommand(){if(!this.selectedMotion||this.refLen===0)return new Float32Array(this.nJoints*2);if(this.selectedMotion.clip_format==="qpos")return new Float32Array(0);const e=this.refJointPos[this.refIdx]??new Float32Array(this.nJoints),t=this.selectedMotion.jointVel[this.refIdx]??new Float32Array(this.nJoints),r=new Float32Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r}getUiConfig(){return null}async setSelectedMotion(e){if(e===null)return this.selectedMotionName=null,this.selectedMotion=null,this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refBodyPosW=[],this.refBodyQuatW=[],this.refBodyLinVelW=[],this.refBodyAngVelW=[],this.refLen=0,this.nJoints=0,this.updateGhostPose(),!1;const t=this.motions.find(i=>i.name===e);if(!t)return!1;const r=this.loadedMotions.get(e)??await this.loadMotion(t);return this.loadedMotions.set(e,r),this.selectedMotionName=e,this.selectedMotion=r,this.selectedAnchorBodyIndex=Math.max(0,r.body_names.indexOf(r.anchor_body_name)),this.selectedRootBodyIndex=0,this.datasetQposAdr=this.resolveQposAdr(r.dataset_joint_names??[]),this.refLen=r.frameCount,this.refJointPos=r.jointPos,this.refIdx=this.sampleInitialFrame(this.refLen),this.nJoints=r.jointPos[0]?.length??0,this.frameAccumulator=0,this.justReset=!0,this.updateReferenceState(),this.applyReferenceStateToSim(),this.updateGhostPose(),!0}setReferenceVisible(e){this.referenceVisible=e,this.ghostRoot&&(this.ghostRoot.visible=e&&this.selectedMotion!==null)}reset(){this.refIdx=this.sampleInitialFrame(this.refLen),this.frameAccumulator=0,this.justReset=!0,this.updateReferenceState(),this.applyReferenceStateToSim(),this.updateGhostPose()}update(e){if(!this.selectedMotion||this.refLen<=1)return;if(this.justReset){this.justReset=!1,this.updateGhostPose();return}if(this.selectedMotion.time_source==="sim"){const i=this.context.mjData?.time??0;this.refIdx=this.sampleHz>0?Math.floor(i*this.sampleHz)%this.refLen:0,this.updateGhostPose();return}const t=this.selectedMotion?.loop!==!1;this.frameAccumulator+=e*this.sampleHz;let r=!1;for(;this.frameAccumulator>=1;){if(this.refIdx+=1,this.refIdx>=this.refLen){if(!t){this.refIdx=this.refLen-1,this.frameAccumulator=0;break}this.refIdx=0,r=!0}this.frameAccumulator-=1}r&&this.context.requestReset?.(),this.updateGhostPose()}updateDebugVisuals(){this.ghostRoot&&(this.ghostRoot.visible=this.referenceVisible&&this.selectedMotion!==null)}dispose(){this.ghostRoot&&(this.ghostRoot.parent?.remove(this.ghostRoot),this.ghostRoot.traverse(e=>{if(e instanceof Jn)if(Array.isArray(e.material))for(const t of e.material)t.dispose?.();else e.material?.dispose?.()})),this.ghostData?.delete?.()}isReady(){return this.selectedMotion!==null&&this.refLen>0}getSelectedMotion(){return this.selectedMotion}getSelectedMotionName(){return this.selectedMotionName}getClipUrl(){return this.selectedMotion?.path??this.motions[0]?.path??null}getAnchorBodyName(){return this.selectedMotion?.anchor_body_name??this.motions.find(e=>e.name===this.selectedMotionName)?.anchor_body_name??null}getBodyNames(){return this.selectedMotion?.body_names??this.motions.find(e=>e.name===this.selectedMotionName)?.body_names??[]}getAnchorBodyIndex(){return this.selectedAnchorBodyIndex}getAnchorPos(e=this.refIdx){if(!this.selectedMotion)return null;const r=this.refBodyPosW[e];if(!r)return null;const i=this.selectedAnchorBodyIndex*3;return r.slice(i,i+3)}getAnchorQuat(e=this.refIdx){if(!this.selectedMotion)return null;const r=this.refBodyQuatW[e];if(!r)return null;const i=this.selectedAnchorBodyIndex*4;return Xv(r.slice(i,i+4))}getBodyPosW(e=this.refIdx){if(!this.selectedMotion)return null;const r=this.refBodyPosW[e];return r?r.slice():null}createGhostRoot(){const e=this.context.bodies??null,t=this.context.mjModel;if(!e||!t)return null;const r=new ls;r.name="Tracking Ghost",r.visible=!1;for(const[i,s]of Object.entries(e)){const a=Number(i);if(!this.isDynamicBody(a))continue;const o=s.clone(!0);o.traverse(l=>{l instanceof Jn&&(Array.isArray(l.material)?l.material=l.material.map(dB):l.material=dB(l.material),l.renderOrder=2)}),oee(o)&&(this.ghostBodies.set(a,o),r.add(o))}return(this.context.mujocoRoot??this.context.scene).add(r),r}isDynamicBody(e){const t=this.context.mjModel;if(!t||e<=0||e>=t.nbody)return!1;let r=e;for(;r>0;){if(t.body_jntnum[r]>0)return!0;r=t.body_parentid[r]}return!1}async loadMotion(e){this.sampleHz=e.fps;const t=await iee(e.path),r=[];if(e.clip_format==="qpos"){if(!t.qpos)throw new Error("Motion asset with clip_format='qpos' is missing 'qpos'");const p=Ec(t.qpos);return{...e,jointPos:r,jointVel:r,bodyPosW:r,bodyQuatW:r,bodyLinVelW:r,bodyAngVelW:r,qposFrames:p,frameCount:p.length}}const i=["joint_pos","joint_vel","body_pos_w","body_quat_w","body_lin_vel_w","body_ang_vel_w"];for(const p of i)if(!t[p])throw new Error(`Motion asset is missing '${p}'`);const s=Ec(t.joint_pos),a=Ec(t.joint_vel),o=t.body_names?.strings??null,l=this.selectMotionBodyFrames(Ec(t.body_pos_w),e.body_names,3,o),c=this.selectMotionBodyFrames(Ec(t.body_quat_w),e.body_names,4,o),d=this.selectMotionBodyFrames(Ec(t.body_lin_vel_w),e.body_names,3,o),h=this.selectMotionBodyFrames(Ec(t.body_ang_vel_w),e.body_names,3,o);return{...e,jointPos:s,jointVel:a,bodyPosW:l,bodyQuatW:c,bodyLinVelW:d,bodyAngVelW:h,frameCount:s.length}}selectMotionBodyFrames(e,t,r,i=null){const s=this.context.mjModel,a=e[0];if(!s||!a||t.length===0)return e;const o=Math.floor(a.length/r);if(o===t.length)return e;let l;if(i!==null)l=t.map(c=>i.indexOf(c));else{const c=this.findBodyIdByName(t[0]);l=t.map(h=>this.findBodyIdByName(h)).map(h=>h-c)}return l.some(c=>c<0||c>=o)?e:e.map(c=>{const d=new Float32Array(t.length*r);for(let h=0;h<l.length;h++){const p=l[h]*r,A=h*r;for(let y=0;y<r;y++)d[A+y]=c[p+y]??0}return d})}updateReferenceState(){const e=this.selectedMotion;if(!e||e.frameCount===0||e.clip_format==="qpos"){this.refRootPos=[],this.refRootQuat=[],this.refBodyPosW=[],this.refBodyQuatW=[],this.refBodyLinVelW=[],this.refBodyAngVelW=[];return}this.refBodyPosW=e.bodyPosW.map(t=>t.slice()),this.refBodyQuatW=e.bodyQuatW.map(t=>t.slice()),this.refBodyLinVelW=e.bodyLinVelW.map(t=>t.slice()),this.refBodyAngVelW=e.bodyAngVelW.map(t=>t.slice()),this.refRootPos=this.refBodyPosW.map(t=>t.slice(this.selectedRootBodyIndex*3,this.selectedRootBodyIndex*3+3)),this.refRootQuat=this.refBodyQuatW.map(t=>Xv(t.slice(this.selectedRootBodyIndex*4,this.selectedRootBodyIndex*4+4)))}applyReferenceStateToSim(){const e=this.context.mjModel,t=this.context.mjData,r=this.selectedMotion;if(!e||!t||!r||this.refLen===0||r.clip_format==="qpos")return;const i=this.sampleRootPos(this.refIdx),s=this.sampleRootQuat(this.refIdx),a=this.findFreeJointIndex();if(i&&s&&a>=0){const c=e.jnt_qposadr[a],d=e.jnt_dofadr[a];t.qpos[c+0]=i[0]??0,t.qpos[c+1]=i[1]??0,t.qpos[c+2]=i[2]??0,t.qpos[c+3]=s[0]??1,t.qpos[c+4]=s[1]??0,t.qpos[c+5]=s[2]??0,t.qpos[c+6]=s[3]??0;const h=this.sampleRootVelocity(this.refIdx,this.refBodyLinVelW),p=this.sampleRootAngularVelocity(this.refIdx);h&&p&&(t.qvel[d+0]=h[0]??0,t.qvel[d+1]=h[1]??0,t.qvel[d+2]=h[2]??0,t.qvel[d+3]=p[0]??0,t.qvel[d+4]=p[1]??0,t.qvel[d+5]=p[2]??0)}const o=this.sampleJointPos(this.refIdx),l=r.jointVel[this.refIdx]??new Float32Array(0);for(let c=0;c<this.datasetQposAdr.length&&c<o.length;c++)t.qpos[this.datasetQposAdr[c]]=o[c]??0;for(let c=0;c<this.datasetQposAdr.length&&c<l.length;c++){const d=this.resolveQvelAdrForQposAdr(this.datasetQposAdr[c]);d>=0&&(t.qvel[d]=l[c]??0)}this.context.mujoco.mj_forward(e,t)}sampleRootPos(e){const t=this.refRootPos[e];if(!t)return null;const r=t.slice();return r[0]+=Oi(this.poseRange.x),r[1]+=Oi(this.poseRange.y),r[2]+=Oi(this.poseRange.z),r}sampleRootQuat(e){const t=this.refRootQuat[e];if(!t)return null;const r=Oi(this.poseRange.roll),i=Oi(this.poseRange.pitch),s=Oi(this.poseRange.yaw);return r===0&&i===0&&s===0?t:Xv(see(aee(r,i,s),t))}sampleRootVelocity(e,t){const r=t[e]?.slice(this.selectedRootBodyIndex*3,this.selectedRootBodyIndex*3+3);return r?(r[0]+=Oi(this.velocityRange.x),r[1]+=Oi(this.velocityRange.y),r[2]+=Oi(this.velocityRange.z),r):null}sampleRootAngularVelocity(e){const t=this.refBodyAngVelW[e]?.slice(this.selectedRootBodyIndex*3,this.selectedRootBodyIndex*3+3);return t?(t[0]+=Oi(this.velocityRange.roll),t[1]+=Oi(this.velocityRange.pitch),t[2]+=Oi(this.velocityRange.yaw),t):null}sampleInitialFrame(e){return e<=1||this.samplingMode==="start"?0:this.samplingMode==="uniform"?Math.floor(Math.random()*e):0}sampleJointPos(e){const t=this.refJointPos[e]??new Float32Array(0);if(this.jointPositionRange[0]===0&&this.jointPositionRange[1]===0)return t;const r=t.slice();for(let i=0;i<r.length;i++)r[i]+=Oi(this.jointPositionRange);return r}resolveQposAdr(e){const t=this.context.mjModel;if(!t||e.length===0)return[];const r=[];for(const i of e){let s=-1;for(let a=0;a<t.njnt;a++){const o=t.jnt(a).name;if(o===i||o.endsWith(`/${i}`)){s=t.jnt_qposadr[a];break}}s>=0&&r.push(s)}return r}resolveQvelAdrForQposAdr(e){const t=this.context.mjModel;if(!t)return-1;for(let r=0;r<t.njnt;r++)if(t.jnt_qposadr[r]===e)return t.jnt_dofadr[r];return-1}findBodyIdByName(e){const t=this.context.mjModel;if(!t)return-1;for(let r=0;r<t.nbody;r++){const i=t.body(r).name;if(i===e||i.endsWith(`/${e}`))return r}return-1}updateGhostPose(){if(!this.ghostRoot||!this.ghostData||!this.context.mjModel||!this.selectedMotion||!this.refLen){this.ghostRoot&&(this.ghostRoot.visible=!1);return}if(this.selectedMotion.clip_format==="qpos"&&this.selectedMotion.qposFrames){const a=this.selectedMotion.qposFrames[this.refIdx];a&&this.ghostData.qpos.set(a),this.context.mujoco.mj_forward(this.context.mjModel,this.ghostData);for(const[o,l]of this.ghostBodies)Ll(this.ghostData.xpos,o,l.position),Fd(this.ghostData.xquat,o,l.quaternion);this.ghostRoot.visible=this.referenceVisible;return}const e=this.ghostData.qpos;e.set(this.context.mjModel.qpos0);const t=this.refRootPos[this.refIdx],r=this.refRootQuat[this.refIdx],i=this.findFreeJointIndex();if(i>=0&&t&&r){const a=this.context.mjModel.jnt_qposadr[i];e[a+0]=t[0]??0,e[a+1]=t[1]??0,e[a+2]=t[2]??0,e[a+3]=r[0]??1,e[a+4]=r[1]??0,e[a+5]=r[2]??0,e[a+6]=r[3]??0}const s=this.refJointPos[this.refIdx]??new Float32Array(0);for(let a=0;a<this.datasetQposAdr.length&&a<s.length;a++)e[this.datasetQposAdr[a]]=s[a]??0;this.context.mujoco.mj_forward(this.context.mjModel,this.ghostData);for(const[a,o]of this.ghostBodies)Ll(this.ghostData.xpos,a,o.position),Fd(this.ghostData.xquat,a,o.quaternion);this.ghostRoot.visible=this.referenceVisible}findFreeJointIndex(){const e=this.context.mjModel;if(!e)return-1;for(let t=0;t<e.njnt;t++)if(e.jnt_type[t]===0)return t;return-1}}function Sw(n,e){return`${n}:${e}`}function cee(n){return typeof n=="object"&&n!==null&&"isReady"in n&&"getAnchorBodyName"in n&&"getBodyNames"in n}class uee{constructor(e,t){this.inputs=Array.isArray(t.ui?.inputs)?t.ui.inputs:[],this.values=new Map;for(const r of this.inputs)r.type==="slider"?this.values.set(r.name,r.default):r.type==="checkbox"&&this.values.set(r.name,r.default?1:0)}getCommand(){const e=this.inputs.filter(r=>r.type==="slider"||r.type==="checkbox"),t=new Float32Array(e.length);for(let r=0;r<e.length;r++){const i=e[r],s=i.type==="checkbox"?i.default?1:0:i.default;t[r]=this.values.get(i.name)??s??0}return t}getUiConfig(){return{inputs:this.inputs}}reset(){for(const e of this.inputs)e.type==="slider"?this.values.set(e.name,e.default):e.type==="checkbox"&&this.values.set(e.name,e.default?1:0)}setValue(e,t){const r=this.inputs.find(s=>(s.type==="slider"||s.type==="checkbox")&&s.name===e);if(!r)return 0;if(r.type==="checkbox"){const s=t>=.5?1:0;return this.values.set(r.name,s),s}const i=Math.max(r.min,Math.min(r.max,t));return this.values.set(r.name,i),i}}const dee={UiCommand:uee,TrackingCommand:lee};class hee{constructor(){this.terms=new Map,this.commands=new Map,this.commandGroups=new Map,this.values=new Map,this.listeners=new Set,this.resetCallback=null,this.context=null,this.registerSystemReset()}initialize(e,t){this.clear(),this.context=t;const r={...dee,...YZ};for(const[i,s]of Object.entries(e)){const a=r[s.name];if(!a)throw new Error(`Unknown command term: ${s.name}`);const o=new a(i,s,t);this.terms.set(i,o),this.registerUi(i,o)}}update(e){for(const t of this.terms.values())t.update?.(e)}updateDebugVisuals(){for(const e of this.terms.values())e.updateDebugVisuals?.()}resetTerms(){for(const e of this.terms.values())e.reset?.();this.syncValuesFromTerms(),this.emit({type:"reset",commandId:"*"})}getCommandGroups(){return Array.from(this.commandGroups.keys()).filter(e=>e!=="_system")}getCommandsInGroup(e){return(this.commandGroups.get(e)??[]).map(r=>this.commands.get(r)).filter(Boolean)}getCommands(){return Array.from(this.commands.values()).filter(e=>e.groupName!=="_system")}getAllCommands(){return Array.from(this.commands.values())}getResetCommand(){return this.commands.get("_system:reset")}getCommandById(e){return this.commands.get(e)}getValue(e){return this.values.get(e)??0}getValues(){const e={};for(const[t,r]of this.values)e[t]=r;return e}getCommand(e){const t=this.terms.get(e);return t?t.getCommand():new Float32Array(0)}getTerm(e){return this.terms.get(e)}getContext(){return this.context}getVelocityCommand(){return this.terms.has("velocity")?this.getCommand("velocity"):this.terms.has("twist")?this.getCommand("twist"):new Float32Array([.5,0,0])}setValue(e,t){const r=this.commands.get(e);if(!r||r.config.type!=="slider"&&r.config.type!=="checkbox")return;const i=this.terms.get(r.groupName),s=r.config.name,a=i?.setValue?i.setValue(s,t):void 0,o=typeof a=="number"?a:t;this.values.set(e,o),this.emit({type:"change",commandId:e,groupName:r.groupName,value:o})}triggerButton(e){const t=this.commands.get(e);!t||t.config.type!=="button"||(e==="_system:reset"&&this.resetCallback?this.resetCallback():this.terms.get(t.groupName)?.triggerButton?.(t.config.name),this.emit({type:"button",commandId:e,groupName:t.groupName}))}resetToDefaults(){this.resetTerms()}setResetCallback(e){this.resetCallback=e}addEventListener(e){this.listeners.add(e)}removeEventListener(e){this.listeners.delete(e)}clear(){for(const e of this.terms.values())e.dispose?.();this.terms.clear(),this.commands.clear(),this.commandGroups.clear(),this.values.clear(),this.context=null,this.registerSystemReset(),this.emit({type:"clear",commandId:""})}hasCommands(){return this.commands.size>1}dispose(){for(const e of this.terms.values())e.dispose?.();this.terms.clear(),this.commands.clear(),this.commandGroups.clear(),this.values.clear(),this.listeners.clear(),this.resetCallback=null,this.context=null}registerSystemReset(){const e=Sw("_system","reset");this.commands.set(e,{id:e,groupName:"_system",config:{type:"button",name:"reset",label:"Reset Simulation"}}),this.commandGroups.set("_system",[e])}registerUi(e,t){const r=t.getUiConfig?.(),i=Array.isArray(r?.inputs)?r.inputs:[];if(i.length!==0){this.commandGroups.set(e,[]);for(const s of i){const a=Sw(e,s.name);if(this.commands.set(a,{id:a,groupName:e,config:s}),this.commandGroups.get(e).push(a),s.type==="slider"||s.type==="checkbox"){const o=t.getCommand(),l=i.filter(d=>d.type==="slider"||d.type==="checkbox").findIndex(d=>d.name===s.name),c=s.type==="checkbox"?s.default?1:0:s.default;this.values.set(a,o[l]??c)}}this.emit({type:"group_registered",commandId:e,groupName:e})}}syncValuesFromTerms(){for(const[e,t]of this.commands){if(t.config.type!=="slider"&&t.config.type!=="checkbox")continue;const r=this.terms.get(t.groupName);if(!r)continue;const a=(r.getUiConfig?.()?.inputs??[]).filter(o=>o.type==="slider"||o.type==="checkbox").findIndex(o=>o.name===t.config.name);if(a>=0){const o=r.getCommand();this.values.set(e,o[a]??this.values.get(e)??0)}}}emit(e){for(const t of this.listeners)try{t(e)}catch{}}}let Jv=null;function Lr(){return Jv||(Jv=new hee),Jv}function fee(n){const e=n[0]??1,t=n[1]??0,r=n[2]??0,i=n[3]??0,s=Math.hypot(e,t,r,i);if(s<1e-9)return[1,0,0,0];const a=1/s;return[e*a,t*a,r*a,i*a]}function pee(n,e){const t=n[0]??1,r=n[1]??0,i=n[2]??0,s=n[3]??0,a=e[0]??1,o=e[1]??0,l=e[2]??0,c=e[3]??0;return[t*a-r*o-i*l-s*c,t*o+r*a+i*c-s*l,t*l-r*c+i*a+s*o,t*c+r*l-i*o+s*a]}function Aee(n){const e=n[0]??1,t=n[1]??0,r=n[2]??0,i=n[3]??0,s=e*e+t*t+r*r+i*i;if(s<1e-9)return[1,0,0,0];const a=1/s;return[e*a,-t*a,-r*a,-i*a]}function mee(n,e){const t=n[0]??1,r=n[1]??0,i=n[2]??0,s=n[3]??0,a=e[0]??0,o=e[1]??0,l=e[2]??0,c=2*(i*l-s*o),d=2*(s*a-r*l),h=2*(r*o-i*a),p=i*h-s*d,A=s*c-r*h,y=r*d-i*c;return[a-t*c+p,o-t*d+A,l-t*h+y]}function gee(n){const[e,t,r,i]=fee(n),s=t*t,a=r*r,o=i*i,l=t*r,c=t*i,d=r*i,h=e*t,p=e*r,A=e*i,y=1-2*(a+o),m=2*(l-A),x=2*(l+A),g=1-2*(s+o),_=2*(c-p),b=2*(d+h);return[y,m,x,g,_,b]}function mo(n,e=0){return typeof n=="number"?n:n instanceof Float32Array?n[e]??0:typeof n=="boolean"&&n?1:0}function ga(n){return n instanceof Float32Array?n:typeof n=="number"?new Float32Array([n]):new Float32Array(0)}function Uf(n,e){const t=n.getContext()?.mjModel??null;if(!t)return-1;for(let r=0;r<t.nbody;r++){const i=t.body(r).name;if(i===e||i.endsWith(`/${e}`))return r}return-1}function wd(){const n=Lr().getTerm("motion");return cee(n)&&n.isReady()?n:null}function VI(n,e,t){const r=new Uint8Array(n.names),i=new TextDecoder,s=[];for(let a=0;a<e;a++){let o=t[a],l=o;for(;l<r.length&&r[l]!==0;)l++;s.push(i.decode(r.subarray(o,l)))}return s}function fP(n){return VI(n,n.njnt,n.name_jntadr)}function hB(n,e){const t=n.getContext()?.mjModel??null;if(!t)return e.map(()=>-1);const r=fP(t);return e.map(i=>{const s=r.indexOf(i);return s<0?-1:t.jnt_qposadr[s]})}function yee(n,e){const t=n.getContext()?.mjModel??null;if(!t)return e.map(()=>-1);const r=fP(t);return e.map(i=>{const s=r.indexOf(i);return s<0?-1:t.jnt_dofadr[s]})}function xee(n,e){const t=n.getContext()?.mjModel??null;return t?VI(t,t.nsite,t.name_siteadr).indexOf(e):-1}function vee(n,e){const t=n.getContext()?.mjModel??null;if(!t)return{adr:0,dim:0};const i=VI(t,t.nsensor,t.name_sensoradr).indexOf(e);return i<0?{adr:0,dim:0}:{adr:t.sensor_adr[i],dim:t.sensor_dim[i]}}function Kv(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")?n:null}const _ee={Const:(n,e)=>Number(e.value??0),StepCount:(n,e,t,r)=>{const i=(r.count??0)+1;return r.count=i,i},Param:(n,e,t)=>{const r=t.params[String(e.name)];return typeof r=="number"?r:Array.isArray(r)?Float32Array.from(r):0},RootAngVelB:(n,e,t)=>t.state.rootAngVel?new Float32Array(t.state.rootAngVel):new Float32Array(3),RootLinkLinVelB:(n,e,t)=>t.state.rootLinVel?new Float32Array(t.state.rootLinVel):new Float32Array(3),RootLinkPosW:(n,e,t)=>t.state.rootPos?new Float32Array(t.state.rootPos):new Float32Array(3),RootLinkQuatW:(n,e,t)=>t.state.rootQuat?new Float32Array(t.state.rootQuat):new Float32Array([1,0,0,0]),ProjectedGravityB:(n,e,t)=>{const r=t.state.rootQuat??new Float32Array([1,0,0,0]),i=r[0],s=r[1],a=r[2],o=r[3],l=0,c=0,d=-1,h=2*(a*d-o*c),p=2*(o*l-s*d),A=2*(s*c-a*l),y=a*A-o*p,m=o*h-s*A,x=s*p-a*h;return new Float32Array([l-i*h+y,c-i*p+m,d-i*A+x])},Add:n=>Zv(n[0],n[1],(e,t)=>e+t),Sub:n=>Zv(n[0],n[1],(e,t)=>e-t),Mul:n=>Zv(n[0],n[1],(e,t)=>e*t),Neg:n=>Ed(n[0],e=>-e),Abs:n=>Ed(n[0],Math.abs),Acos:n=>Ed(n[0],e=>Math.acos(Math.max(-1,Math.min(1,e)))),Index:(n,e)=>{const t=ga(n[0]),r=Number(e.i??0);return t[r]??0},Gt:n=>jm(n[0],n[1],(e,t)=>e>t),Lt:n=>jm(n[0],n[1],(e,t)=>e<t),Ge:n=>jm(n[0],n[1],(e,t)=>e>=t),Le:n=>jm(n[0],n[1],(e,t)=>e<=t),Any:n=>pB(n[0],(e,t)=>e||t,!1),All:n=>pB(n[0],(e,t)=>e&&t,!0),Or:n=>fB(n[0],n[1],(e,t)=>e||t),And:n=>fB(n[0],n[1],(e,t)=>e&&t),Not:n=>{const e=n[0];if(typeof e=="boolean")return!e;if(typeof e=="number")return e===0;if(e instanceof Uint8Array){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r]?0:1;return t}return!1},ConstVec:(n,e)=>{const t=Array.isArray(e.values)?e.values:[];return Float32Array.from(t)},SpawnCapture:(n,e,t,r)=>(r.captured===void 0&&(r.captured=ga(n[0]).slice()),r.captured),QuatApplyInv:n=>Float32Array.from(mee(ga(n[0]),ga(n[1]))),TrackingAnchorPos:()=>{const n=wd()?.getAnchorPos()??null;return n?new Float32Array(n):new Float32Array(3)},TrackingAnchorQuat:()=>{const n=wd()?.getAnchorQuat()??null;return n?new Float32Array(n):new Float32Array([1,0,0,0])},TrackingCurrentAnchorPos:(n,e,t)=>{const i=wd()?.getAnchorBodyName()??null,s=t.runner.getContext()?.mjData??null;if(!i||!s)return new Float32Array(3);const a=Uf(t.runner,i);return a<0?new Float32Array(3):new Float32Array([s.xpos[a*3],s.xpos[a*3+1],s.xpos[a*3+2]])},TrackingCurrentAnchorQuat:(n,e,t)=>{const i=wd()?.getAnchorBodyName()??null,s=t.runner.getContext()?.mjData??null;if(!i||!s)return new Float32Array([1,0,0,0]);const a=Uf(t.runner,i);return a<0?new Float32Array([1,0,0,0]):new Float32Array(s.xquat.slice(a*4,a*4+4))},TrackingBodyPosZDeviationMax:(n,e,t)=>{const r=wd(),i=t.runner.getContext()?.mjData??null;if(!r||!i)return 0;const s=r.getBodyPosW();if(!s)return 0;const a=r.getBodyNames(),o=Array.isArray(e.body_names)&&e.body_names.length>0?e.body_names:a;let l=0;for(const c of o){const d=a.indexOf(c),h=Uf(t.runner,c);if(d<0||h<0)continue;const p=s[d*3+2]??0,A=i.xpos[h*3+2]??0,y=Math.abs(p-A);y>l&&(l=y)}return l},Clip:(n,e)=>{const t=Number(e.min??-1/0),r=Number(e.max??1/0);return Ed(n[0],i=>Math.min(r,Math.max(t,i)))},History:(n,e,t,r)=>{const i=Math.max(1,Math.floor(Number(e.steps??1))),s=ga(n[0]);let a=r.buffer;if(a===void 0||a.length!==i||a[0].length!==s.length)a=Array.from({length:i},()=>s.slice()),r.buffer=a;else{for(let c=a.length-1;c>0;c--)a[c].set(a[c-1]);a[0].set(s)}if(i===1)return new Float32Array(a[0]);const o=s.length,l=new Float32Array(o*i);if(e.interleaved)for(let c=0;c<o;c++)for(let d=0;d<i;d++)l[c*i+d]=a[d][c];else for(let c=0;c<i;c++)l.set(a[c],c*o);return l},Concat:n=>{let e=0;const t=n.map(s=>ga(s));for(const s of t)e+=s.length;const r=new Float32Array(e);let i=0;for(const s of t)r.set(s,i),i+=s.length;return r},Cos:n=>Ed(n[0],Math.cos),Sin:n=>Ed(n[0],Math.sin),QuatMul:n=>Float32Array.from(pee(ga(n[0]),ga(n[1]))),QuatInv:n=>Float32Array.from(Aee(ga(n[0]))),QuatToRot6d:n=>Float32Array.from(gee(ga(n[0]))),JointPos:(n,e,t)=>{const r=Kv(e.joint_names);if(r===null){const o=t.state.jointPos;return o?new Float32Array(o):new Float32Array(t.runner.getNumActions())}const i=hB(t.runner,r),s=t.runner.getContext()?.mjData?.qpos,a=new Float32Array(i.length);for(let o=0;o<i.length;o++)a[o]=i[o]>=0&&s!==void 0?s[i[o]]:0;return a},DefaultJointPos:(n,e,t)=>{const r=Kv(e.joint_names);if(r===null)return new Float32Array(t.runner.getDefaultJointPos());const i=hB(t.runner,r),s=t.runner.getContext()?.mjModel?.qpos0,a=new Float32Array(i.length);for(let o=0;o<i.length;o++)a[o]=i[o]>=0&&s!==void 0?s[i[o]]:0;return a},JointVel:(n,e,t)=>{const r=Kv(e.joint_names);if(r===null){const o=t.state.jointVel;return o?new Float32Array(o):new Float32Array(t.runner.getNumActions())}const i=yee(t.runner,r),s=t.runner.getContext()?.mjData?.qvel,a=new Float32Array(i.length);for(let o=0;o<i.length;o++)a[o]=i[o]>=0&&s!==void 0?s[i[o]]:0;return a},PrevAction:(n,e,t)=>new Float32Array(t.runner.getLastActions()),CommandValue:(n,e)=>{const t=String(e.command??""),r=t?Lr().getCommand(t):null;return r?new Float32Array(r):new Float32Array(0)},Sensor:(n,e,t)=>{const{adr:r,dim:i}=vee(t.runner,String(e.sensor??"")),s=t.runner.getContext()?.mjData?.sensordata,a=new Float32Array(i);if(s!==void 0)for(let o=0;o<i;o++)a[o]=s[r+o]??0;return a},SitePos:(n,e,t)=>{const r=xee(t.runner,String(e.site??"")),i=t.runner.getContext()?.mjData?.site_xpos;return r<0||i===void 0?new Float32Array(3):new Float32Array([i[r*3],i[r*3+1],i[r*3+2]])},BodyPos:(n,e,t)=>{const r=Uf(t.runner,String(e.body??"")),i=t.runner.getContext()?.mjData?.xpos;return r<0||i===void 0?new Float32Array(3):new Float32Array([i[r*3],i[r*3+1],i[r*3+2]])},BodyQuat:(n,e,t)=>{const r=Uf(t.runner,String(e.body??"")),i=t.runner.getContext()?.mjData?.xquat;return r<0||i===void 0?new Float32Array([1,0,0,0]):new Float32Array(i.slice(r*4,r*4+4))},TrackingRefBodyPos:(n,e)=>{const t=wd();if(!t)return new Float32Array(3);const r=t.getBodyPosW();if(!r)return new Float32Array(3);const i=t.getBodyNames().indexOf(String(e.body??""));return i<0?new Float32Array(3):new Float32Array([r[i*3],r[i*3+1],r[i*3+2]])}};function fB(n,e,t){const r=(d,h)=>typeof d=="boolean"?d:typeof d=="number"?d!==0:d instanceof Uint8Array||d instanceof Float32Array?(d[h]??0)!==0:!1,i=n instanceof Uint8Array||n instanceof Float32Array,s=e instanceof Uint8Array||e instanceof Float32Array;if(!i&&!s)return t(r(n,0),r(e,0));const a=i?n.length:1,o=s?e.length:1,l=Math.max(a,o),c=new Uint8Array(l);for(let d=0;d<l;d++)c[d]=t(r(n,d),r(e,d))?1:0;return c}function Ed(n,e){if(typeof n=="number")return e(n);if(n instanceof Float32Array){const t=new Float32Array(n.length);for(let r=0;r<n.length;r++)t[r]=e(n[r]);return t}return e(mo(n))}function Zv(n,e,t){const r=n instanceof Float32Array,i=e instanceof Float32Array;if(!r&&!i)return t(mo(n),mo(e));const s=Math.max(r?n.length:1,i?e.length:1),a=new Float32Array(s);for(let o=0;o<s;o++){const l=r?n[o]??0:mo(n),c=i?e[o]??0:mo(e);a[o]=t(l,c)}return a}function jm(n,e,t){const r=n instanceof Float32Array,i=e instanceof Float32Array;if(!r&&!i)return t(mo(n),mo(e));const s=Math.max(r?n.length:1,i?e.length:1),a=new Uint8Array(s);for(let o=0;o<s;o++){const l=r?n[o]??0:mo(n),c=i?e[o]??0:mo(e);a[o]=t(l,c)?1:0}return a}function pB(n,e,t){if(typeof n=="boolean")return n;if(typeof n=="number")return n!==0;let r=t;if(n instanceof Uint8Array){for(let i=0;i<n.length;i++)r=e(r,n[i]!==0);return r}if(n instanceof Float32Array){for(let i=0;i<n.length;i++)r=e(r,n[i]!==0);return r}return r}class pP{constructor(){this.states=new Map}get(e){let t=this.states.get(e);return t===void 0&&(t={},this.states.set(e,t)),t}reset(){this.states.clear()}}function AP(n,e,t){const r={};for(const s of n.nodes){const a=_ee[s.op];if(a===void 0)throw new Error(`DSL interpreter: unknown primitive op "${s.op}". Add it to the engine's primitive registry, or fix the build's serializer.`);const o=(s.in??[]).map(l=>{if(!(l in r))throw new Error(`DSL interpreter: node "${s.out}" references unresolved input "${l}". Graph nodes must appear in topological order.`);return r[l]});r[s.out]=a(o,s.attrs??{},e,t.get(s.out))}const i=r[n.output];if(i===void 0)throw new Error(`DSL interpreter: graph output "${n.output}" was not produced by any node.`);return i}class bee extends qZ{constructor(e,t){super(t),this.store=new pP,this.runner=e,this.graph=t.graph,this.params=t.params??{}}evaluate(e){const t=AP(this.graph,{runner:this.runner,state:e,params:this.params},this.store);return typeof t=="boolean"?t:typeof t=="number"?t!==0:!1}reset(){this.store.reset()}}function wee(n){return"kind"in n&&n.kind==="termination"}class Eee{constructor(e,t,r){this.terms=[];for(const[i,s]of Object.entries(e)){if(wee(s)){const l={name:i,params:s.params,time_out:s.time_out,graph:{kind:"termination",nodes:s.nodes,output:s.output}};this.terms.push({name:i,term:new bee(r,l),isTimeOut:s.time_out??!1});continue}const a=t[s.name];if(!a)continue;const o={name:s.name,params:s.params,time_out:s.time_out};this.terms.push({name:i,term:new a(o),isTimeOut:s.time_out??!1})}}evaluate(e){let t=!1,r=!1;const i=[];for(const{name:s,term:a,isTimeOut:o}of this.terms)a.evaluate(e)&&(i.push(s),o?r=!0:t=!0);return{done:t||r,terminated:t,truncated:r,reasons:i}}reset(){for(const{term:e}of this.terms)e.reset?.()}get size(){return this.terms.length}}const Iee={},Cee={...Iee};var HI=Object.defineProperty,See=Object.getOwnPropertyDescriptor,Bee=Object.getOwnPropertyNames,Mee=Object.prototype.hasOwnProperty,Tee=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')}),et=(n,e)=>()=>(n&&(e=n(n=0)),e),_h=(n,e)=>{for(var t in e)HI(n,t,{get:e[t],enumerable:!0})},Ree=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Bee(e))!Mee.call(n,i)&&i!==t&&HI(n,i,{get:()=>e[i],enumerable:!(r=See(e,i))||r.enumerable});return n},Lp=n=>Ree(HI({},"__esModule",{value:!0}),n),Of,El,Td,AB,mP,gP=et(()=>{Of=new Map,El=[],Td=(n,e,t)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let r=Of.get(n);if(r===void 0)Of.set(n,{backend:e,priority:t});else{if(r.priority>t)return;if(r.priority===t&&r.backend!==e)throw new Error(`cannot register backend "${n}" using priority ${t}`)}if(t>=0){let i=El.indexOf(n);i!==-1&&El.splice(i,1);for(let s=0;s<El.length;s++)if(Of.get(El[s]).priority<=t){El.splice(s,0,n);return}El.push(n)}return}throw new TypeError("not a valid backend")},AB=async n=>{let e=Of.get(n);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let t=!!e.initPromise;try{return t||(e.initPromise=e.backend.init(n)),await e.initPromise,e.initialized=!0,e.backend}catch(r){return t||(e.error=`${r}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},mP=async n=>{let e=n.executionProviders||[],t=e.map(l=>typeof l=="string"?l:l.name),r=t.length===0?El:t,i,s=[],a=new Set;for(let l of r){let c=await AB(l);typeof c=="string"?s.push({name:l,err:c}):(i||(i=c),i===c&&a.add(l))}if(!i)throw new Error(`no available backend found. ERR: ${s.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(let{name:l,err:c}of s)t.includes(l);let o=e.filter(l=>a.has(typeof l=="string"?l:l.name));return[i,new Proxy(n,{get:(l,c)=>c==="executionProviders"?o:Reflect.get(l,c)})]}}),Dee=et(()=>{gP()}),yP,kee=et(()=>{yP="1.24.3"}),e_,Br,xP=et(()=>{kee(),e_="warning",Br={wasm:{},webgl:{},webgpu:{},versions:{common:yP},set logLevel(n){if(n!==void 0){if(typeof n!="string"||["verbose","info","warning","error","fatal"].indexOf(n)===-1)throw new Error(`Unsupported logging level: ${n}`);e_=n}},get logLevel(){return e_}},Object.defineProperty(Br,"logLevel",{enumerable:!0})}),Dn,Nee=et(()=>{xP(),Dn=Br}),vP,_P,Qee=et(()=>{vP=(n,e)=>{let t=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);t.width=n.dims[3],t.height=n.dims[2];let r=t.getContext("2d");if(r!=null){let i,s;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(i=n.dims[2],s=n.dims[3]):(i=n.dims[3],s=n.dims[2]);let a=e?.format!==void 0?e.format:"RGB",o=e?.norm,l,c;o===void 0||o.mean===void 0?l=[255,255,255,255]:typeof o.mean=="number"?l=[o.mean,o.mean,o.mean,o.mean]:(l=[o.mean[0],o.mean[1],o.mean[2],0],o.mean[3]!==void 0&&(l[3]=o.mean[3])),o===void 0||o.bias===void 0?c=[0,0,0,0]:typeof o.bias=="number"?c=[o.bias,o.bias,o.bias,o.bias]:(c=[o.bias[0],o.bias[1],o.bias[2],0],o.bias[3]!==void 0&&(c[3]=o.bias[3]));let d=s*i,h=0,p=d,A=d*2,y=-1;a==="RGBA"?(h=0,p=d,A=d*2,y=d*3):a==="RGB"?(h=0,p=d,A=d*2):a==="RBG"&&(h=0,A=d,p=d*2);for(let m=0;m<s;m++)for(let x=0;x<i;x++){let g=(n.data[h++]-c[0])*l[0],_=(n.data[p++]-c[1])*l[1],b=(n.data[A++]-c[2])*l[2],w=y===-1?255:(n.data[y++]-c[3])*l[3];r.fillStyle="rgba("+g+","+_+","+b+","+w+")",r.fillRect(x,m,1,1)}if("toDataURL"in t)return t.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},_P=(n,e)=>{let t=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),r;if(t!=null){let i,s,a;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(i=n.dims[2],s=n.dims[1],a=n.dims[3]):(i=n.dims[3],s=n.dims[2],a=n.dims[1]);let o=e!==void 0&&e.format!==void 0?e.format:"RGB",l=e?.norm,c,d;l===void 0||l.mean===void 0?c=[255,255,255,255]:typeof l.mean=="number"?c=[l.mean,l.mean,l.mean,l.mean]:(c=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(c[3]=l.mean[3])),l===void 0||l.bias===void 0?d=[0,0,0,0]:typeof l.bias=="number"?d=[l.bias,l.bias,l.bias,l.bias]:(d=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(d[3]=l.bias[3]));let h=s*i;if(e!==void 0&&(e.format!==void 0&&a===4&&e.format!=="RGBA"||a===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let p=4,A=0,y=1,m=2,x=3,g=0,_=h,b=h*2,w=-1;o==="RGBA"?(g=0,_=h,b=h*2,w=h*3):o==="RGB"?(g=0,_=h,b=h*2):o==="RBG"&&(g=0,b=h,_=h*2),r=t.createImageData(i,s);for(let I=0;I<s*i;A+=p,y+=p,m+=p,x+=p,I++)r.data[A]=(n.data[g++]-d[0])*c[0],r.data[y]=(n.data[_++]-d[1])*c[1],r.data[m]=(n.data[b++]-d[2])*c[2],r.data[x]=w===-1?255:(n.data[w++]-d[3])*c[3]}else throw new Error("Can not access image data");return r}}),Wm,bP,wP,EP,IP,CP,Pee=et(()=>{jI(),Wm=(n,e)=>{if(n===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:t,width:r}=e,i=e.norm??{mean:255,bias:0},s,a;typeof i.mean=="number"?s=[i.mean,i.mean,i.mean,i.mean]:s=[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],typeof i.bias=="number"?a=[i.bias,i.bias,i.bias,i.bias]:a=[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let o=e.format!==void 0?e.format:"RGBA",l=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",c=t*r,d=l==="RGBA"?new Float32Array(c*4):new Float32Array(c*3),h=4,p=0,A=1,y=2,m=3,x=0,g=c,_=c*2,b=-1;o==="RGB"&&(h=3,p=0,A=1,y=2,m=-1),l==="RGBA"?b=c*3:l==="RBG"?(x=0,_=c,g=c*2):l==="BGR"&&(_=0,g=c,x=c*2);for(let w=0;w<c;w++,p+=h,y+=h,A+=h,m+=h)d[x++]=(n[p]+a[0])/s[0],d[g++]=(n[A]+a[1])/s[1],d[_++]=(n[y]+a[2])/s[2],b!==-1&&m!==-1&&(d[b++]=(n[m]+a[3])/s[3]);return l==="RGBA"?new Gi("float32",d,[1,4,t,r]):new Gi("float32",d,[1,3,t,r])},bP=async(n,e)=>{let t=typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement,r=typeof ImageData<"u"&&n instanceof ImageData,i=typeof ImageBitmap<"u"&&n instanceof ImageBitmap,s=typeof n=="string",a,o=e??{},l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},c=d=>typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement||d instanceof OffscreenCanvas?d.getContext("2d"):null;if(t){let d=l();d.width=n.width,d.height=n.height;let h=c(d);if(h!=null){let p=n.height,A=n.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(p=e.resizedHeight,A=e.resizedWidth),e!==void 0){if(o=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");o.tensorFormat="RGBA",o.height=p,o.width=A}else o.tensorFormat="RGBA",o.height=p,o.width=A;h.drawImage(n,0,0),a=h.getImageData(0,0,A,p).data}else throw new Error("Can not access image data")}else if(r){let d,h;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(d=e.resizedHeight,h=e.resizedWidth):(d=n.height,h=n.width),e!==void 0&&(o=e),o.format="RGBA",o.height=d,o.width=h,e!==void 0){let p=l();p.width=h,p.height=d;let A=c(p);if(A!=null)A.putImageData(n,0,0),a=A.getImageData(0,0,h,d).data;else throw new Error("Can not access image data")}else a=n.data}else if(i){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let d=l();d.width=n.width,d.height=n.height;let h=c(d);if(h!=null){let p=n.height,A=n.width;return h.drawImage(n,0,0,A,p),a=h.getImageData(0,0,A,p).data,o.height=p,o.width=A,Wm(a,o)}else throw new Error("Can not access image data")}else{if(s)return new Promise((d,h)=>{let p=l(),A=c(p);if(!n||!A)return h();let y=new Image;y.crossOrigin="Anonymous",y.src=n,y.onload=()=>{p.width=y.width,p.height=y.height,A.drawImage(y,0,0,p.width,p.height);let m=A.getImageData(0,0,p.width,p.height);o.height=p.height,o.width=p.width,d(Wm(m.data,o))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Wm(a,o);throw new Error("Input data provided is not supported - aborted tensor creation")},wP=(n,e)=>{let{width:t,height:r,download:i,dispose:s}=e,a=[1,r,t,4];return new Gi({location:"texture",type:"float32",texture:n,dims:a,download:i,dispose:s})},EP=(n,e)=>{let{dataType:t,dims:r,download:i,dispose:s}=e;return new Gi({location:"gpu-buffer",type:t??"float32",gpuBuffer:n,dims:r,download:i,dispose:s})},IP=(n,e)=>{let{dataType:t,dims:r,download:i,dispose:s}=e;return new Gi({location:"ml-tensor",type:t??"float32",mlTensor:n,dims:r,download:i,dispose:s})},CP=(n,e,t)=>new Gi({location:"cpu-pinned",type:n,data:e,dims:t??[e.length]})}),Qc,op,t_,SP,Lee=et(()=>{Qc=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),op=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),t_=!1,SP=()=>{if(!t_){t_=!0;let n=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,t=globalThis.Float16Array,r=typeof t<"u"&&t.from;n&&(Qc.set("int64",BigInt64Array),op.set(BigInt64Array,"int64")),e&&(Qc.set("uint64",BigUint64Array),op.set(BigUint64Array,"uint64")),r?(Qc.set("float16",t),op.set(t,"float16")):Qc.set("float16",Uint16Array)}}}),BP,MP,Fee=et(()=>{jI(),BP=n=>{let e=1;for(let t=0;t<n.length;t++){let r=n[t];if(typeof r!="number"||!Number.isSafeInteger(r))throw new TypeError(`dims[${t}] must be an integer, got: ${r}`);if(r<0)throw new RangeError(`dims[${t}] must be a non-negative integer, got: ${r}`);e*=r}return e},MP=(n,e)=>{switch(n.location){case"cpu":return new Gi(n.type,n.data,e);case"cpu-pinned":return new Gi({location:"cpu-pinned",data:n.data,type:n.type,dims:e});case"texture":return new Gi({location:"texture",texture:n.texture,type:n.type,dims:e});case"gpu-buffer":return new Gi({location:"gpu-buffer",gpuBuffer:n.gpuBuffer,type:n.type,dims:e});case"ml-tensor":return new Gi({location:"ml-tensor",mlTensor:n.mlTensor,type:n.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${n.location} is not supported`)}}}),Gi,jI=et(()=>{Qee(),Pee(),Lee(),Fee(),Gi=class{constructor(n,e,t){SP();let r,i;if(typeof n=="object"&&"location"in n)switch(this.dataLocation=n.location,r=n.type,i=n.dims,n.location){case"cpu-pinned":{let a=Qc.get(r);if(!a)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(n.data instanceof a))throw new TypeError(`buffer should be of type ${a.name}`);this.cpuData=n.data;break}case"texture":{if(r!=="float32")throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=n.texture,this.downloader=n.download,this.disposer=n.dispose;break}case"gpu-buffer":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint8"&&r!=="bool"&&r!=="uint4"&&r!=="int4")throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=n.gpuBuffer,this.downloader=n.download,this.disposer=n.dispose;break}case"ml-tensor":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint64"&&r!=="int8"&&r!=="uint8"&&r!=="bool"&&r!=="uint4"&&r!=="int4")throw new TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=n.mlTensor,this.downloader=n.download,this.disposer=n.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof n=="string")if(r=n,o=t,n==="string"){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");a=e}else{let l=Qc.get(n);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${n}.`);if(Array.isArray(e)){if(n==="float16"&&l===Uint16Array||n==="uint4"||n==="int4")throw new TypeError(`Creating a ${n} tensor from number array is not supported. Please use ${l.name} as data.`);n==="uint64"||n==="int64"?a=l.from(e,BigInt):a=l.from(e)}else if(e instanceof l)a=e;else if(e instanceof Uint8ClampedArray)if(n==="uint8")a=Uint8Array.from(e);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(n==="float16"&&e instanceof Uint16Array&&l!==Uint16Array)a=new globalThis.Float16Array(e.buffer,e.byteOffset,e.length);else throw new TypeError(`A ${r} tensor's data must be type of ${l}`)}else if(o=e,Array.isArray(n)){if(n.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof n[0];if(l==="string")r="string",a=n;else if(l==="boolean")r="bool",a=Uint8Array.from(n);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(n instanceof Uint8ClampedArray)r="uint8",a=Uint8Array.from(n);else{let l=op.get(n.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${n.constructor}.`);r=l,a=n}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");i=o,this.cpuData=a,this.dataLocation="cpu"}let s=BP(i);if(this.cpuData&&s!==this.cpuData.length&&!((r==="uint4"||r==="int4")&&Math.ceil(s/2)===this.cpuData.length))throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=s}static async fromImage(n,e){return bP(n,e)}static fromTexture(n,e){return wP(n,e)}static fromGpuBuffer(n,e){return EP(n,e)}static fromMLTensor(n,e){return IP(n,e)}static fromPinnedBuffer(n,e,t){return CP(n,e,t)}toDataURL(n){return vP(this,n)}toImageData(n){return _P(this,n)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(n){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,n&&this.disposer&&(this.disposer(),this.disposer=void 0),e}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(n){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return MP(this,n)}}}),ei,TP=et(()=>{jI(),ei=Gi}),Xg,n_,Pa,Js,Wc,qc,RP=et(()=>{xP(),Xg=(n,e)=>{typeof Br.trace>"u"?Br.wasm.trace:Br.trace},n_=(n,e)=>{let t=new Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<t.length;i++){if(r&&!t[i].includes("TRACE_FUNC")){let s=`FUNC_${n}::${t[i].trim().split(" ")[1]}`;e&&(s+=`::${e}`),Xg("CPU",s);return}t[i].includes("TRACE_FUNC")&&(r=!0)}},Pa=n=>{(typeof Br.trace>"u"?!Br.wasm.trace:!Br.trace)||n_("BEGIN",n)},Js=n=>{(typeof Br.trace>"u"?!Br.wasm.trace:!Br.trace)||n_("END",n)},Wc=n=>{typeof Br.trace>"u"?Br.wasm.trace:Br.trace},qc=n=>{typeof Br.trace>"u"?Br.wasm.trace:Br.trace}}),DP,zee=et(()=>{gP(),TP(),RP(),DP=class kP{constructor(e){this.handler=e}async run(e,t,r){Pa(),Wc("InferenceSession.run");let i={},s={};if(typeof e!="object"||e===null||e instanceof ei||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof t=="object"){if(t===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof ei)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(t.length===0)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let c of t){if(typeof c!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(c)===-1)throw new RangeError(`'fetches' contains invalid output name: ${c}.`);i[c]=null}if(typeof r=="object"&&r!==null)s=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else{let c=!1,d=Object.getOwnPropertyNames(t);for(let h of this.outputNames)if(d.indexOf(h)!==-1){let p=t[h];(p===null||p instanceof ei)&&(c=!0,a=!1,i[h]=p)}if(c){if(typeof r=="object"&&r!==null)s=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else s=t}}else if(typeof t<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let c of this.inputNames)if(typeof e[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(a)for(let c of this.outputNames)i[c]=null;let o=await this.handler.run(e,i,s),l={};for(let c in o)if(Object.hasOwnProperty.call(o,c)){let d=o[c];d instanceof ei?l[c]=d:l[c]=new ei(d.type,d.data,d.dims)}return qc("InferenceSession.run"),Js(),l}async release(){return this.handler.dispose()}static async create(e,t,r,i){Pa(),Wc("InferenceSession.create");let s,a={};if(typeof e=="string"){if(s=e,typeof t=="object"&&t!==null)a=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(s=e,typeof t=="object"&&t!==null)a=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let d=e,h=0,p=e.byteLength;if(typeof t=="object"&&t!==null)a=t;else if(typeof t=="number"){if(h=t,!Number.isSafeInteger(h))throw new RangeError("'byteOffset' must be an integer.");if(h<0||h>=d.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${d.byteLength}).`);if(p=e.byteLength-h,typeof r=="number"){if(p=r,!Number.isSafeInteger(p))throw new RangeError("'byteLength' must be an integer.");if(p<=0||h+p>d.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${d.byteLength-h}].`);if(typeof i=="object"&&i!==null)a=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(typeof r<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof t<"u")throw new TypeError("'options' must be an object.");s=new Uint8Array(d,h,p)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[o,l]=await mP(a),c=await o.createInferenceSessionHandler(s,l);return qc("InferenceSession.create"),Js(),new kP(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),WI,Uee=et(()=>{zee(),WI=DP}),Oee=et(()=>{}),$ee=et(()=>{}),Gee=et(()=>{}),Vee=et(()=>{}),Hee={};_h(Hee,{InferenceSession:()=>WI,TRACE:()=>Xg,TRACE_EVENT_BEGIN:()=>Wc,TRACE_EVENT_END:()=>qc,TRACE_FUNC_BEGIN:()=>Pa,TRACE_FUNC_END:()=>Js,Tensor:()=>ei,env:()=>Dn,registerBackend:()=>Td});var gs=et(()=>{Dee(),Nee(),Uee(),TP(),Oee(),$ee(),RP(),Gee(),Vee()}),qI=et(()=>{}),NP={};_h(NP,{default:()=>QP});var r_,i_,QP,jee=et(()=>{U4(),cu(),YI(),r_="ort-wasm-proxy-worker",i_=globalThis.self?.name===r_,i_&&(self.onmessage=n=>{let{type:e,in:t}=n.data;try{switch(e){case"init-wasm":XI(t.wasm).then(()=>{fC(t).then(()=>{postMessage({type:e})},r=>{postMessage({type:e,err:r})})},r=>{postMessage({type:e,err:r})});break;case"init-ep":{let{epName:r,env:i}=t;pC(i,r).then(()=>{postMessage({type:e})},s=>{postMessage({type:e,err:s})});break}case"copy-from":{let{buffer:r}=t,i=r0(r);postMessage({type:e,out:i});break}case"create":{let{model:r,options:i}=t;AC(r,i).then(s=>{postMessage({type:e,out:s})},s=>{postMessage({type:e,err:s})});break}case"release":mC(t),postMessage({type:e});break;case"run":{let{sessionId:r,inputIndices:i,inputs:s,outputIndices:a,options:o}=t;gC(r,i,s,a,new Array(a.length).fill(null),o).then(l=>{l.some(c=>c[3]!=="cpu")?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:l},xC([...s,...l]))},l=>{postMessage({type:e,err:l})});break}case"end-profiling":yC(t),postMessage({type:e});break;default:}}catch(r){postMessage({type:e,err:r})}}),QP=i_?null:n=>new Worker(n??$i,{type:"module",name:r_})}),PP={};_h(PP,{default:()=>LP});async function mB(n={}){var e=n,t=!!globalThis.window,r=!!globalThis.WorkerGlobalScope,i=r&&self.name?.startsWith("em-pthread");e.mountExternalData=(C,N)=>{C.startsWith("./")&&(C=C.substring(2)),(e.Zc||(e.Zc=new Map)).set(C,N)},e.unmountExternalData=()=>{delete e.Zc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,ae:!0}).buffer.constructor;let s=C=>async(...N)=>{try{if(e.$c)throw Error("Session already started");let O=e.$c={Nd:N[0],errors:[]},z=await C(...N);if(e.$c!==O)throw Error("Session mismatch");e.gd?.flush();let se=O.errors;if(0<se.length){let ue=await Promise.all(se);if(ue=ue.filter(Se=>Se),0<ue.length)throw Error(ue.join(`
|
|
12822
|
-
`))}return z}finally{e.$c=null}};e.jsepInit=(C,N)=>{if(C==="webgpu"){[e.gd,e.Dd,e.Hd,e.jd,e.Gd,e.ac,e.Id,e.Kd,e.Ed,e.Fd,e.Jd]=N;let O=e.gd;e.jsepRegisterBuffer=(z,se,ue,Se)=>O.registerBuffer(z,se,ue,Se),e.jsepGetBuffer=z=>O.getBuffer(z),e.jsepCreateDownloader=(z,se,ue)=>O.createDownloader(z,se,ue),e.jsepOnCreateSession=z=>{O.onCreateSession(z)},e.jsepOnReleaseSession=z=>{O.onReleaseSession(z)},e.jsepOnRunStart=z=>O.onRunStart(z),e.Ld=(z,se)=>{O.upload(z,se)}}else if(C==="webnn"){let O=N[0];[e.Zd,e.vd,e.webnnEnsureTensor,e.xd,e.webnnDownloadTensor,e.Yd,e.webnnEnableTraceEvent]=N.slice(1),e.webnnReleaseTensorId=e.vd,e.webnnUploadTensor=e.xd,e.webnnRegisterMLContext=e.Yd,e.webnnOnRunStart=z=>O.onRunStart(z),e.webnnOnRunEnd=O.onRunEnd.bind(O),e.webnnOnReleaseSession=z=>{O.onReleaseSession(z)},e.webnnCreateMLTensorDownloader=(z,se)=>O.createMLTensorDownloader(z,se),e.webnnRegisterMLTensor=(z,se,ue,Se)=>O.registerMLTensor(z,se,ue,Se),e.webnnCreateMLContext=z=>O.createMLContext(z),e.webnnRegisterMLConstant=(z,se,ue,Se,Ue,it)=>O.registerMLConstant(z,se,ue,Se,Ue,e.Zc,it),e.webnnRegisterGraphInput=O.registerGraphInput.bind(O),e.webnnIsGraphInput=O.isGraphInput.bind(O),e.webnnRegisterGraphOutput=O.registerGraphOutput.bind(O),e.webnnIsGraphOutput=O.isGraphOutput.bind(O),e.webnnCreateTemporaryTensor=O.createTemporaryTensor.bind(O),e.webnnIsGraphInputOutputTypeSupported=O.isGraphInputOutputTypeSupported.bind(O)}};let a=()=>{let C=N=>(...O)=>{let z=$r;return O=N(...O),$r!=z?new Promise((se,ue)=>{Oo={resolve:se,reject:ue}}):O};(()=>{for(let N of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])e[N]=C(e[N])})(),s!==void 0&&(e._OrtRun=s(e._OrtRun),e._OrtRunWithBinding=s(e._OrtRunWithBinding)),a=void 0};e.asyncInit=()=>{a?.()};var o,l,c=(C,N)=>{throw N},d=import.meta.url,h="";if(t||r){try{h=new URL(".",d).href}catch{}r&&(l=C=>{var N=new XMLHttpRequest;return N.open("GET",C,!1),N.responseType="arraybuffer",N.send(null),new Uint8Array(N.response)}),o=async C=>{if(M(C))return new Promise((O,z)=>{var se=new XMLHttpRequest;se.open("GET",C,!0),se.responseType="arraybuffer",se.onload=()=>{se.status==200||se.status==0&&se.response?O(se.response):z(se.status)},se.onerror=z,se.send(null)});var N=await fetch(C,{credentials:"same-origin"});if(N.ok)return N.arrayBuffer();throw Error(N.status+" : "+N.url)}}var p,A,y,m,x,g,_=(()=>{}).bind(console),b=(()=>{}).bind(console),w=_,I=b,S=!1,M=C=>C.startsWith("file://");function T(){Ce.buffer!=k.buffer&&G()}if(i){let C=function(N){try{var O=N.data,z=O.Uc;if(z==="load"){let se=[];self.onmessage=ue=>se.push(ue),g=()=>{postMessage({Uc:"loaded"});for(let ue of se)C(ue);self.onmessage=C};for(let ue of O.Ad)e[ue]&&!e[ue].proxy||(e[ue]=(...Se)=>{postMessage({Uc:"callHandler",zd:ue,args:Se})},ue=="print"&&(w=e[ue]),ue=="printErr"&&(I=e[ue]));Ce=O.Vd,G(),A=O.Wd,he(),ac()}else if(z==="run"){(function(se){var ue=(T(),W)[se+52>>>2>>>0];se=(T(),W)[se+56>>>2>>>0],zh(ue,ue-se),qt(ue)})(O.Tc),ja(O.Tc,0,0,1,0,0),Z(),yi(O.Tc),R||(cA(),R=!0);try{me(O.Pd,O.dd)}catch(se){if(se!="unwind")throw se}}else O.target!=="setimmediate"&&(z==="checkMailbox"?R&&zo():z&&(I(`worker: received unknown command ${z}`),I(O)))}catch(se){throw Yo(),se}};var R=!1;self.onunhandledrejection=N=>{throw N.reason||N},self.onmessage=C}var k,H,Q,V,B,W,K,X,$,J,ne,L=!1;function G(){var C=Ce.buffer;e.HEAP8=k=new Int8Array(C),Q=new Int16Array(C),e.HEAPU8=H=new Uint8Array(C),V=new Uint16Array(C),e.HEAP32=B=new Int32Array(C),e.HEAPU32=W=new Uint32Array(C),K=new Float32Array(C),X=new Float64Array(C),$=new BigInt64Array(C),J=new BigUint64Array(C)}function oe(){L=!0,i?g():Wi.tb()}function Ae(C){throw I(C="Aborted("+C+")"),S=!0,C=new WebAssembly.RuntimeError(C+". Build with -sASSERTIONS for more info."),x?.(C),C}function ye(){return{a:{ma:Lu,hb:yA,g:He,J:nt,f:dt,o:Mt,h:_e,ha:ut,b:je,T:Ye,Ia:Ve,n:_t,_:tr,Ya:No,Ea:ys,Ga:Wl,Za:Ur,Wa:xs,Pa:sa,Va:Oa,ka:$a,Fa:ql,Ca:Ga,Xa:ki,Da:Qo,cb:du,ea:Te,xa:De,va:St,da:$t,O:xn,H:Fn,wa:Rt,Z:Yn,ya:Or,Sa:Kn,Aa:Wp,Ja:qp,ta:bh,fa:fu,Ra:yi,$a:la,R:Yl,s:gu,c:at,ib:wh,y:Zp,M:ua,D:Eh,m:yu,t:Ih,jb:xu,I:vu,S:eA,j:ii,v:Vo,r:Ch,l:Xl,Ma:iy,Na:wu,Oa:tA,Ka:nA,La:rA,ua:iA,eb:sy,bb:oy,u:ly,aa:cy,ga:uy,ab:ay,V:dy,_a:Th,Ba:hy,F:Sh,U:fy,la:Eu,za:Ay,gb:py,fb:my,Ta:jo,Ua:aA,Ha:q,$:kh,ja:Nh,Qa:Qh,ia:Ph,lb:bA,na:br,mb:_A,oa:fa,G:Xa,d:af,q:rf,w:Fu,B:qi,pb:ha,K:cf,x:yy,pa:Pn,X:Gr,ba:il,nb:Uu,ob:Vr,ra:sc,qa:uf,qb:rl,N:_y,Y:Tn,e:of,A:xA,k:sf,kb:Ou,p:vy,z:lf,C:xy,E:da,L:ic,rb:by,Q:Ja,ca:ws,W:sl,sb:nl,sa:vA,P:zu,i:Wo,a:Ce,db:re}}}async function he(){function C(z,se){var ue=Wi=z.exports;z={};for(let[Se,Ue]of Object.entries(ue))typeof Ue=="function"?(ue=ca(Ue),z[Se]=ue):z[Se]=Ue;return Wi=z,Wi=(function(){var Se=Wi,Ue=ht=>Nt=>ht(Nt)>>>0,it=ht=>()=>ht()>>>0;return(Se=Object.assign({},Se)).ub=Ue(Se.ub),Se.Yb=it(Se.Yb),Se._b=Ue(Se._b),Se.mc=Ue(Se.mc),Se.nc=it(Se.nc),Se.rc=Ue(Se.rc),Se})(),be.push(Wi.$b),lA=(z=Wi).ub,cA=z.vb,e._OrtInit=z.wb,e._OrtGetLastError=z.xb,e._OrtCreateSessionOptions=z.yb,e._OrtAppendExecutionProvider=z.zb,e._OrtAddFreeDimensionOverride=z.Ab,e._OrtAddSessionConfigEntry=z.Bb,e._OrtReleaseSessionOptions=z.Cb,e._OrtCreateSession=z.Db,e._OrtReleaseSession=z.Eb,e._OrtGetInputOutputCount=z.Fb,e._OrtGetInputOutputMetadata=z.Gb,e._OrtFree=z.Hb,e._OrtCreateTensor=z.Ib,e._OrtGetTensorData=z.Jb,e._OrtReleaseTensor=z.Kb,e._OrtCreateRunOptions=z.Lb,e._OrtAddRunConfigEntry=z.Mb,e._OrtReleaseRunOptions=z.Nb,e._OrtCreateBinding=z.Ob,e._OrtBindInput=z.Pb,e._OrtBindOutput=z.Qb,e._OrtClearBoundOutputs=z.Rb,e._OrtReleaseBinding=z.Sb,e._OrtRunWithBinding=z.Tb,e._OrtRun=z.Ub,e._OrtEndProfiling=z.Vb,e._JsepOutput=z.Wb,e._JsepGetNodeName=z.Xb,Cu=z.Yb,Qi=e._free=z.Zb,qo=e._malloc=z._b,ja=z.bc,Yo=z.cc,uA=z.dc,Zl=z.ec,Lh=z.fc,Fh=z.gc,Su=z.hc,Yt=z.ic,Xo=z.jc,zh=z.kc,qt=z.lc,Uh=z.mc,Xt=z.nc,dA=z.oc,Oh=z.pc,hA=z.qc,vi=z.rc,Jo=z.sc,Bu=z.tc,$h=z.uc,Gh=z.vc,Vh=z.wc,Mu=z.xc,fA=z.yc,pA=z.zc,Wa=z.Ac,Tu=z.Bc,Ko=z.Cc,Ru=z.Dc,Hh=z.Ec,ec=z.Fc,qa=z.Gc,Du=z.Hc,jh=z.Ic,tc=z.Jc,Wh=z.Kc,qh=z.Lc,Yh=z.Mc,Xh=z.Nc,Jh=z.Oc,Kh=z.Pc,bs=z.Rc,ku=z.Sc,Nu=z.bd,AA=z.cd,mA=z.hd,Zo=z.kd,gA=z.ld,Zh=z.md,ef=z.nd,Mn=z.od,Qu=z.pd,nc=z.qd,el=z.rd,tf=z.wd,Pu=z.Rd,tl=z.Sd,rc=z.Td,Ya=z.Ud,A=se,Wi}var N,O=ye();return e.instantiateWasm?new Promise(z=>{e.instantiateWasm(O,(se,ue)=>{z(C(se,ue))})}):i?C(new WebAssembly.Instance(A,ye()),A):(ne??=e.locateFile?e.locateFile?e.locateFile("ort-wasm-simd-threaded.jsep.wasm",h):h+"ort-wasm-simd-threaded.jsep.wasm":new URL("/assets/ort-wasm-simd-threaded.jsep-C887KxcQ.wasm",import.meta.url).href,N=await(async function(z){var se=ne;if(!p&&!M(se))try{var ue=fetch(se,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(ue,z)}catch(Se){I(`wasm streaming compile failed: ${Se}`),I("falling back to ArrayBuffer instantiation")}return(async function(Se,Ue){try{var it=await(async function(ht){if(!p)try{var Nt=await o(ht);return new Uint8Array(Nt)}catch{}if(ht==ne&&p)ht=new Uint8Array(p);else{if(!l)throw"both async and sync fetching of the wasm failed";ht=l(ht)}return ht})(Se);return await WebAssembly.instantiate(it,Ue)}catch(ht){I(`failed to asynchronously prepare wasm: ${ht}`),Ae(ht)}})(se,z)})(O),C(N.instance,N.module))}class fe{name="ExitStatus";constructor(N){this.message=`Program terminated with exit(${N})`,this.status=N}}var Ie=C=>{C.terminate(),C.onmessage=()=>{}},Re=[],ge=0,Ne=null,tt=C=>{ee.length==0&&(le(),Y(ee[0]));var N=ee.pop();if(!N)return 6;ie.push(N),ve[C.Tc]=N,N.Tc=C.Tc;var O={Uc:"run",Pd:C.Od,dd:C.dd,Tc:C.Tc};return N.postMessage(O,C.ud),0},Ge=0,F=(C,N,...O)=>{var z,se=16*O.length,ue=Xt(),Se=Uh(se),Ue=Se>>>3;for(z of O)typeof z=="bigint"?((T(),$)[Ue++>>>0]=1n,(T(),$)[Ue++>>>0]=z):((T(),$)[Ue++>>>0]=0n,(T(),X)[Ue++>>>0]=z);return C=uA(C,0,se,Se,N),qt(ue),C};function re(C){if(i)return F(0,1,C);if(y=C,!(0<Ge)){for(var N of ie)Ie(N);for(N of ee)Ie(N);ee=[],ie=[],ve={},S=!0}c(0,new fe(C))}function Ee(C){if(i)return F(1,0,C);q(C)}var q=C=>{if(y=C,i)throw Ee(C),"unwind";re(C)},ee=[],ie=[],be=[],ve={},ce=C=>{var N=C.Tc;delete ve[N],ee.push(C),ie.splice(ie.indexOf(C),1),C.Tc=0,Zl(N)};function Z(){be.forEach(C=>C())}var Y=C=>new Promise(N=>{C.onmessage=se=>{var ue=se.data;if(se=ue.Uc,ue.ad&&ue.ad!=Cu()){var Se=ve[ue.ad];Se?Se.postMessage(ue,ue.ud):I(`Internal error! Worker sent a message "${se}" to target pthread ${ue.ad}, but that thread no longer exists!`)}else se==="checkMailbox"?zo():se==="spawnThread"?tt(ue):se==="cleanupThread"?Gt(()=>{ce(ve[ue.Qd])}):se==="loaded"?(C.loaded=!0,N(C)):ue.target==="setimmediate"?C.postMessage(ue):se==="uncaughtException"?C.onerror(ue.error):se==="callHandler"?e[ue.zd](...ue.args):se&&I(`worker sent an unknown command ${se}`)},C.onerror=se=>{throw I(`worker sent an error! ${se.filename}:${se.lineno}: ${se.message}`),se};var O,z=[];for(O of[])e.propertyIsEnumerable(O)&&z.push(O);C.postMessage({Uc:"load",Ad:z,Vd:Ce,Wd:A})});function le(){var C=new Worker((()=>{let N=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new N("ort.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});ee.push(C)}var Ce,me=(C,N)=>{Ge=0,C=Bu(C,N),0<Ge?y=C:Lh(C)},xe=[],st=0;function He(C){var N=new pt(C>>>=0);return(T(),k)[N.Vc+12>>>0]==0&&(ze(N,!0),st--),Ze(N,!1),xe.push(N),vi(C)}var Ke=0,nt=()=>{Yt(0,0);var C=xe.pop();dA(C.ed),Ke=0};function ze(C,N){N=N?1:0,(T(),k)[C.Vc+12>>>0]=N}function Ze(C,N){N=N?1:0,(T(),k)[C.Vc+13>>>0]=N}class pt{constructor(N){this.ed=N,this.Vc=N-24}}var ft=C=>{var N=Ke;if(!N)return Xo(0),0;var O=new pt(N);(T(),W)[O.Vc+16>>>2>>>0]=N;var z=(T(),W)[O.Vc+4>>>2>>>0];if(!z)return Xo(0),N;for(var se of C){if(se===0||se===z)break;if(hA(se,z,O.Vc+16))return Xo(se),N}return Xo(z),N};function dt(){return ft([])}function Mt(C){return ft([C>>>0])}function _e(C,N,O,z){return ft([C>>>0,N>>>0,O>>>0,z>>>0])}var ut=()=>{var C=xe.pop();C||Ae("no exception to throw");var N=C.ed;throw(T(),k)[C.Vc+13>>>0]==0&&(xe.push(C),Ze(C,!0),ze(C,!1),st++),Oh(N),Ke=N};function je(C,N,O){var z=new pt(C>>>=0);throw N>>>=0,O>>>=0,(T(),W)[z.Vc+16>>>2>>>0]=0,(T(),W)[z.Vc+4>>>2>>>0]=N,(T(),W)[z.Vc+8>>>2>>>0]=O,Oh(C),st++,Ke=C}var Ye=()=>st;function We(C,N,O,z){return i?F(2,1,C,N,O,z):Ve(C,N,O,z)}function Ve(C,N,O,z){if(C>>>=0,N>>>=0,O>>>=0,z>>>=0,!globalThis.SharedArrayBuffer)return 6;var se=[];return i&&se.length===0?We(C,N,O,z):(C={Od:O,Tc:C,dd:z,ud:se},i?(C.Uc="spawnThread",postMessage(C,se),0):tt(C))}function _t(C){throw Ke||=C>>>0,Ke}var Ot=globalThis.TextDecoder&&new TextDecoder,En=(C,N,O,z)=>{if(O=N+O,z)return O;for(;C[N]&&!(N>=O);)++N;return N},dn=(C,N=0,O,z)=>{if(16<(O=En(C,N>>>=0,O,z))-N&&C.buffer&&Ot)return Ot.decode(C.buffer instanceof ArrayBuffer?C.subarray(N,O):C.slice(N,O));for(z="";N<O;){var se=C[N++];if(128&se){var ue=63&C[N++];if((224&se)==192)z+=String.fromCharCode((31&se)<<6|ue);else{var Se=63&C[N++];65536>(se=(240&se)==224?(15&se)<<12|ue<<6|Se:(7&se)<<18|ue<<12|Se<<6|63&C[N++])?z+=String.fromCharCode(se):(se-=65536,z+=String.fromCharCode(55296|se>>10,56320|1023&se))}}else z+=String.fromCharCode(se)}return z},hn=(C,N,O)=>(C>>>=0)?dn((T(),H),C,N,O):"";function tr(C,N,O){return i?F(3,1,C,N,O):0}function No(C,N){if(i)return F(4,1,C,N)}function ys(C,N){if(i)return F(5,1,C,N)}function Wl(C,N,O){if(i)return F(6,1,C,N,O)}function Ur(C,N,O){return i?F(7,1,C,N,O):0}function xs(C,N){if(i)return F(8,1,C,N)}function sa(C,N,O){if(i)return F(9,1,C,N,O)}function Oa(C,N,O,z){if(i)return F(10,1,C,N,O,z)}function $a(C,N,O,z){if(i)return F(11,1,C,N,O,z)}function ql(C,N,O,z){if(i)return F(12,1,C,N,O,z)}function Ga(C){if(i)return F(13,1,C)}function ki(C,N){if(i)return F(14,1,C,N)}function Qo(C,N,O){if(i)return F(15,1,C,N,O)}var du=()=>Ae(""),mi=C=>{C>>>=0;for(var N="";;){var O=(T(),H)[C++>>>0];if(!O)return N;N+=String.fromCharCode(O)}},Po={},Lo={},vs=class extends Error{constructor(C){super(C),this.name="BindingError"}};function gi(C,N,O={}){return(function(z,se,ue={}){var Se=se.name;if(!z)throw new vs(`type "${Se}" must have a positive integer typeid pointer`);if(Lo.hasOwnProperty(z)){if(ue.Bd)return;throw new vs(`Cannot register type '${Se}' twice`)}Lo[z]=se,Po.hasOwnProperty(z)&&(se=Po[z],delete Po[z],se.forEach(Ue=>Ue()))})(C,N,O)}var ae=(C,N,O)=>{switch(N){case 1:return O?z=>(T(),k)[z>>>0]:z=>(T(),H)[z>>>0];case 2:return O?z=>(T(),Q)[z>>>1>>>0]:z=>(T(),V)[z>>>1>>>0];case 4:return O?z=>(T(),B)[z>>>2>>>0]:z=>(T(),W)[z>>>2>>>0];case 8:return O?z=>(T(),$)[z>>>3>>>0]:z=>(T(),J)[z>>>3>>>0];default:throw new TypeError(`invalid integer width (${N}): ${C}`)}};function Te(C,N,O,z,se){C>>>=0,O>>>=0,N=mi(N>>>0);let ue=Se=>Se;if(z=z===0n){let Se=8*O;ue=Ue=>BigInt.asUintN(Se,Ue),se=ue(se)}gi(C,{name:N,Qc:ue,Xc:(Se,Ue)=>(typeof Ue=="number"&&(Ue=BigInt(Ue)),Ue),Wc:ae(N,O,!z),Yc:null})}function De(C,N,O,z){gi(C>>>=0,{name:N=mi(N>>>0),Qc:function(se){return!!se},Xc:function(se,ue){return ue?O:z},Wc:function(se){return this.Qc((T(),H)[se>>>0])},Yc:null})}var Fe=[],Me=[0,1,,1,null,1,!0,1,!1,1];function at(C){9<(C>>>=0)&&--Me[C+1]==0&&(Me[C]=void 0,Fe.push(C))}var lt=C=>{if(!C)throw new vs(`Cannot use deleted val. handle = ${C}`);return Me[C]},At=C=>{switch(C){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let N=Fe.pop()||Me.length;return Me[N]=C,Me[N+1]=1,N}};function gt(C){return this.Qc((T(),W)[C>>>2>>>0])}var Qt={name:"emscripten::val",Qc:C=>{var N=lt(C);return at(C),N},Xc:(C,N)=>At(N),Wc:gt,Yc:null};function St(C){return gi(C>>>0,Qt)}var kt=(C,N)=>{switch(N){case 4:return function(O){return this.Qc((T(),K)[O>>>2>>>0])};case 8:return function(O){return this.Qc((T(),X)[O>>>3>>>0])};default:throw new TypeError(`invalid float width (${N}): ${C}`)}};function $t(C,N,O){O>>>=0,gi(C>>>=0,{name:N=mi(N>>>0),Qc:z=>z,Xc:(z,se)=>se,Wc:kt(N,O),Yc:null})}function xn(C,N,O,z,se){C>>>=0,O>>>=0,N=mi(N>>>0);let ue=Ue=>Ue;if(z===0){var Se=32-8*O;ue=Ue=>Ue<<Se>>>Se,se=ue(se)}gi(C,{name:N,Qc:ue,Xc:(Ue,it)=>it,Wc:ae(N,O,z!==0),Yc:null})}function Fn(C,N,O){function z(ue){var Se=(T(),W)[ue>>>2>>>0];return ue=(T(),W)[ue+4>>>2>>>0],new se((T(),k).buffer,ue,Se)}var se=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][N];gi(C>>>=0,{name:O=mi(O>>>0),Qc:z,Wc:z},{Bd:!0})}var pn=(C,N,O)=>{var z=(T(),H);if(N>>>=0,0<O){var se=N;O=N+O-1;for(var ue=0;ue<C.length;++ue){var Se=C.codePointAt(ue);if(127>=Se){if(N>=O)break;z[N++>>>0]=Se}else if(2047>=Se){if(N+1>=O)break;z[N++>>>0]=192|Se>>6,z[N++>>>0]=128|63&Se}else if(65535>=Se){if(N+2>=O)break;z[N++>>>0]=224|Se>>12,z[N++>>>0]=128|Se>>6&63,z[N++>>>0]=128|63&Se}else{if(N+3>=O)break;z[N++>>>0]=240|Se>>18,z[N++>>>0]=128|Se>>12&63,z[N++>>>0]=128|Se>>6&63,z[N++>>>0]=128|63&Se,ue++}}z[N>>>0]=0,C=N-se}else C=0;return C},an=C=>{for(var N=0,O=0;O<C.length;++O){var z=C.charCodeAt(O);127>=z?N++:2047>=z?N+=2:55296<=z&&57343>=z?(N+=4,++O):N+=3}return N};function Rt(C,N){gi(C>>>=0,{name:N=mi(N>>>0),Qc(O){var z=(T(),W)[O>>>2>>>0];return z=hn(O+4,z,!0),Qi(O),z},Xc(O,z){z instanceof ArrayBuffer&&(z=new Uint8Array(z));var se=typeof z=="string";if(!(se||ArrayBuffer.isView(z)&&z.BYTES_PER_ELEMENT==1))throw new vs("Cannot pass non-string to std::string");var ue=se?an(z):z.length,Se=qo(4+ue+1),Ue=Se+4;return(T(),W)[Se>>>2>>>0]=ue,se?pn(z,Ue,ue+1):(T(),H).set(z,Ue>>>0),O!==null&&O.push(Qi,Se),Se},Wc:gt,Yc(O){Qi(O)}})}var vn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,tn=(C,N,O)=>{if(C>>>=1,16<(N=En((T(),V),C,N/2,O))-C&&vn)return vn.decode((T(),V).slice(C,N));for(O="";C<N;++C){var z=(T(),V)[C>>>0];O+=String.fromCharCode(z)}return O},Nr=(C,N,O)=>{if(O??=2147483647,2>O)return 0;var z=N;O=(O-=2)<2*C.length?O/2:C.length;for(var se=0;se<O;++se){var ue=C.charCodeAt(se);(T(),Q)[N>>>1>>>0]=ue,N+=2}return(T(),Q)[N>>>1>>>0]=0,N-z},aa=C=>2*C.length,cr=(C,N,O)=>{var z="";C>>>=2;for(var se=0;!(se>=N/4);se++){var ue=(T(),W)[C+se>>>0];if(!ue&&!O)break;z+=String.fromCodePoint(ue)}return z},oa=(C,N,O)=>{if(N>>>=0,O??=2147483647,4>O)return 0;var z=N;O=z+O-4;for(var se=0;se<C.length;++se){var ue=C.codePointAt(se);if(65535<ue&&se++,(T(),B)[N>>>2>>>0]=ue,(N+=4)+4>O)break}return(T(),B)[N>>>2>>>0]=0,N-z},Cn=C=>{for(var N=0,O=0;O<C.length;++O)65535<C.codePointAt(O)&&O++,N+=4;return N};function Yn(C,N,O){if(C>>>=0,N>>>=0,O=mi(O>>>=0),N===2)var z=tn,se=Nr,ue=aa;else z=cr,se=oa,ue=Cn;gi(C,{name:O,Qc:Se=>{var Ue=(T(),W)[Se>>>2>>>0];return Ue=z(Se+4,Ue*N,!0),Qi(Se),Ue},Xc:(Se,Ue)=>{if(typeof Ue!="string")throw new vs(`Cannot pass non-string to C++ string type ${O}`);var it=ue(Ue),ht=qo(4+it+N);return(T(),W)[ht>>>2>>>0]=it/N,se(Ue,ht+4,it+N),Se!==null&&Se.push(Qi,ht),ht},Wc:gt,Yc(Se){Qi(Se)}})}function Or(C,N){gi(C>>>=0,{Cd:!0,name:N=mi(N>>>0),Qc:()=>{},Xc:()=>{}})}function Kn(C){ja(C>>>0,!r,1,!t,131072,!1),Z()}var Gt=C=>{if(!S)try{if(C(),!(0<Ge))try{i?Cu()&&Lh(y):q(y)}catch(N){N instanceof fe||N=="unwind"||c(0,N)}}catch(N){N instanceof fe||N=="unwind"||c(0,N)}},Fo=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function yi(C){C>>>=0,Fo||(Atomics.waitAsync((T(),B),C>>>2,C).value.then(zo),C+=128,Atomics.store((T(),B),C>>>2,1))}var zo=()=>Gt(()=>{var C=Cu();C&&(yi(C),Su())});function Wp(C,N){(C>>>=0)==N>>>0?setTimeout(zo):i?postMessage({ad:C,Uc:"checkMailbox"}):(C=ve[C])&&C.postMessage({Uc:"checkMailbox"})}var hu=[];function qp(C,N,O,z,se){for(N>>>=0,se>>>=0,hu.length=0,O=se>>>3,z=se+z>>>3;O<z;){var ue;ue=(T(),$)[O++>>>0]?(T(),$)[O++>>>0]:(T(),X)[O++>>>0],hu.push(ue)}return(N?nf[N]:gy[C])(...hu)}var bh=()=>{Ge=0};function fu(C){C>>>=0,i?postMessage({Uc:"cleanupThread",Qd:C}):ce(ve[C])}function la(C){}var Ni=C=>{try{C()}catch(N){Ae(N)}};function ca(C){var N=(...O)=>{pu.push(C);try{return C(...O)}finally{S||(pu.pop(),$r&&xi===1&&pu.length===0&&(xi=0,Ge+=1,Ni(tl),typeof Fibers<"u"&&Fibers.ce()))}};return Yp.set(C,N),N}var xi=0,$r=null,_s=0,pu=[],Au=new Map,Uo=new Map,Yp=new Map,Xp=0,Oo=null,Jp=[],Kp=C=>(function(N){if(!S){if(xi===0){var O=!1,z=!1;N((se=0)=>{if(!S&&(_s=se,O=!0,z)){xi=2,Ni(()=>rc($r)),typeof MainLoop<"u"&&MainLoop.yd&&MainLoop.resume(),se=!1;try{var ue=(function(){var it=(T(),B)[$r+8>>>2>>>0];return it=Uo.get(it),it=Yp.get(it),--Ge,it()})()}catch(it){ue=it,se=!0}var Se=!1;if(!$r){var Ue=Oo;Ue&&(Oo=null,(se?Ue.reject:Ue.resolve)(ue),Se=!0)}if(se&&!Se)throw ue}}),z=!0,O||(xi=1,$r=(function(){var se=qo(65548),ue=se+12;if((T(),W)[se>>>2>>>0]=ue,(T(),W)[se+4>>>2>>>0]=ue+65536,ue=pu[0],!Au.has(ue)){var Se=Xp++;Au.set(ue,Se),Uo.set(Se,ue)}return ue=Au.get(ue),(T(),B)[se+8>>>2>>>0]=ue,se})(),typeof MainLoop<"u"&&MainLoop.yd&&MainLoop.pause(),Ni(()=>Pu($r)))}else xi===2?(xi=0,Ni(Ya),Qi($r),$r=null,Jp.forEach(Gt)):Ae(`invalid state: ${xi}`);return _s}})(N=>{C().then(N)});function Yl(C){return C>>>=0,Kp(async()=>{var N=await lt(C);return At(N)})}var Va=[],$o=C=>{var N=Va.length;return Va.push(C),N},mu=(C,N)=>{for(var O=Array(C),z=0;z<C;++z){var se=z,ue=(T(),W)[N+4*z>>>2>>>0],Se=Lo[ue];if(Se===void 0)throw C=`parameter ${z}`,ue=lA(ue),N=mi(ue),Qi(ue),new vs(`${C} has unknown type ${N}`);O[se]=Se}return O},ny=(C,N,O)=>{var z=[];return C=C(z,O),z.length&&((T(),W)[N>>>2>>>0]=At(z)),C},ry={},Go=C=>{var N=ry[C];return N===void 0?mi(C):N};function gu(C,N,O){var[z,...se]=mu(C,N>>>0);N=z.Xc.bind(z);var ue=se.map(it=>it.Wc.bind(it));C--;var Se={toValue:lt};switch(C=ue.map((it,ht)=>{var Nt=`argFromPtr${ht}`;return Se[Nt]=it,`${Nt}(args${ht?"+"+8*ht:""})`}),O){case 0:var Ue="toValue(handle)";break;case 2:Ue="new (toValue(handle))";break;case 3:Ue="";break;case 1:Se.getStringOrSymbol=Go,Ue="toValue(handle)[getStringOrSymbol(methodName)]"}return Ue+=`(${C})`,z.Cd||(Se.toReturnWire=N,Se.emval_returnValue=ny,Ue=`return emval_returnValue(toReturnWire, destructorsRef, ${Ue})`),Ue=`return function (handle, methodName, destructorsRef, args) {
|
|
12821
|
+
`);new ms(new de(-1,-1,-1),new de(1,1,1)),new de(-1,-3,1).normalize(),new xt(1,1,1),new xt(.5,.5,1),new de(1,1,1);new ms(new de(-2,-1,-2),new de(2,5,2)),new de(0,-1,0),new xt(1,1,1),new xt(.25,.25,.5),new de(.1,1,.1);const oP=class ww{static createButton(e,t={}){const r=navigator.xr;if(!r)return null;const i=r,s=document.createElement("button");e.xr.enabled=!0,e.xr.setReferenceSpaceType("local");function a(){let h=null;async function p(m){m.addEventListener("end",A),await e.xr.setSession(m),s.textContent="EXIT VR",h=m}function A(){h?.removeEventListener("end",A),s.textContent="ENTER VR",h=null}s.style.display="",s.style.cursor="pointer",s.style.left="calc(50% - 100px)",s.style.width="200px",s.style.height="100px",s.textContent="ENTER VR";const y={...t,optionalFeatures:[...t.optionalFeatures||[]]};s.onmouseenter=()=>{s.style.opacity="1.0"},s.onmouseleave=()=>{s.style.opacity="0.5"},s.onclick=()=>{h===null?i.requestSession("immersive-vr",y).then(p):h.end()}}function o(){s.style.display="none",s.style.cursor="auto",s.style.left="calc(50% - 75px)",s.style.width="150px",s.onmouseenter=null,s.onmouseleave=null,s.onclick=null}function l(){o(),s.textContent="VR NOT SUPPORTED"}function c(h){o(),s.textContent="VR NOT ALLOWED"}function d(h){h.style.position="absolute",h.style.bottom="20px",h.style.padding="12px 6px",h.style.border="1px solid #fff",h.style.borderRadius="4px",h.style.background="rgba(0,0,0,0.1)",h.style.color="#fff",h.style.font="normal 13px sans-serif",h.style.textAlign="center",h.style.opacity="0.5",h.style.outline="none",h.style.zIndex="999"}return s.id="VRButton",s.style.display="none",d(s),i.isSessionSupported("immersive-vr").then(h=>{h?a():l(),h&&ww.xrSessionIsGranted&&s.click()}).catch(c),s}static registerSessionGrantedListener(){const e=navigator.xr;if(!e)return null;const t=e;/WebXRViewer\//i.test(navigator.userAgent)||t.addEventListener("sessiongranted",()=>{ww.xrSessionIsGranted=!0})}};oP.xrSessionIsGranted=!1;let rZ=oP;rZ.registerSessionGrantedListener();var lP=(n=>(n.w="wrist",n.t0="thumb-metacarpal",n.t1="thumb-phalanx-proximal",n.t2="thumb-phalanx-distal",n.t3="thumb-tip",n.i0="index-finger-metacarpal",n.i1="index-finger-phalanx-proximal",n.i2="index-finger-phalanx-intermediate",n.i3="index-finger-phalanx-distal",n.i4="index-finger-tip",n.m0="middle-finger-metacarpal",n.m1="middle-finger-phalanx-proximal",n.m2="middle-finger-phalanx-intermediate",n.m3="middle-finger-phalanx-distal",n.m4="middle-finger-tip",n.r0="ring-finger-metacarpal",n.r1="ring-finger-phalanx-proximal",n.r2="ring-finger-phalanx-intermediate",n.r3="ring-finger-phalanx-distal",n.r4="ring-finger-tip",n.p0="pinky-finger-metacarpal",n.p1="pinky-finger-phalanx-proximal",n.p2="pinky-finger-phalanx-intermediate",n.p3="pinky-finger-phalanx-distal",n.p4="pinky-finger-tip",n))(lP||{});const iZ=Object.keys(lP);iZ.length;new de(0,0,-1),new de(0,0,1),new de(-1,0,0),new de(1,0,0),new de(0,1,0),new de(0,-1,0);new de(0,0,-1),new de(0,0,1),new de(-1,0,0),new de(1,0,0),new de(0,1,0),new de(0,-1,0);new de(0,0,1),new de(0,0,-1);new de(0,-1,0),new de(0,1,0),new de(-1,0,0),new de(1,0,0);const jv=Math.PI/180,sZ=new In().setFromEuler(new Hi(Math.PI,0,0));function cP(n,e){const t=e.scale??1,r=e.xOffset??0,i=e.yOffset??0,s=e.zOffset??0,a=(e.roll??0)*jv,o=(e.pitch??0)*jv,l=(e.yaw??0)*jv;n.scale.setScalar(t);const c=new In().setFromEuler(new Hi(o,l,a));n.quaternion.copy(sZ.clone().multiply(c)),n.position.set(r*t,s*t,i*t)}function eB(n,e){const t=n.url;if(!t)throw new Error("SplatConfig.url must be resolved before calling loadSplat. Use App.tsx resolvedSplatConfig.");const r=new UI({url:t});return cP(r,n),e.add(r),r}function tB(n,e){e.remove(n),n.dispose?.()}function nB(n,e){if(e===uH)return n;if(e===sw||e===WN){let t=n.getIndex();if(t===null){const a=[],o=n.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);n.setIndex(a),t=n.getIndex()}else return n}const r=t.count-2,i=[];if(e===sw)for(let a=1;a<=r;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<r;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3;const s=n.clone();return s.setIndex(i),s.clearGroups(),s}else return n}class aZ extends lu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new dZ(t)}),this.register(function(t){return new hZ(t)}),this.register(function(t){return new _Z(t)}),this.register(function(t){return new bZ(t)}),this.register(function(t){return new wZ(t)}),this.register(function(t){return new pZ(t)}),this.register(function(t){return new AZ(t)}),this.register(function(t){return new mZ(t)}),this.register(function(t){return new gZ(t)}),this.register(function(t){return new uZ(t)}),this.register(function(t){return new yZ(t)}),this.register(function(t){return new fZ(t)}),this.register(function(t){return new vZ(t)}),this.register(function(t){return new xZ(t)}),this.register(function(t){return new lZ(t)}),this.register(function(t){return new EZ(t)}),this.register(function(t){return new IZ(t)})}load(e,t,r,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Ap.extractUrlBase(e);a=Ap.resolveURL(c,this.path)}else a=Ap.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i&&i(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new MI(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,a,function(d){t(d),s.manager.itemEnd(e)},o)}catch(d){o(d)}},r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,i){let s;const a={},o={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===uP){try{a[cn.KHR_BINARY_GLTF]=new CZ(e)}catch(h){i&&i(h);return}s=JSON.parse(a[cn.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new zZ(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const h=this.pluginCallbacks[d](c);h.name,o[h.name]=h,a[h.name]=!0}if(s.extensionsUsed)for(let d=0;d<s.extensionsUsed.length;++d){const h=s.extensionsUsed[d],p=s.extensionsRequired||[];switch(h){case cn.KHR_MATERIALS_UNLIT:a[h]=new cZ;break;case cn.KHR_DRACO_MESH_COMPRESSION:a[h]=new SZ(s,this.dracoLoader);break;case cn.KHR_TEXTURE_TRANSFORM:a[h]=new BZ;break;case cn.KHR_MESH_QUANTIZATION:a[h]=new MZ;break;default:p.indexOf(h)>=0&&o[h]}}c.setExtensions(a),c.setPlugins(o),c.parse(r,i)}parseAsync(e,t){const r=this;return new Promise(function(i,s){r.parse(e,t,i,s)})}}function oZ(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const cn={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class lZ{constructor(e){this.parser=e,this.name=cn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,i=t.length;r<i;r++){const s=t[r];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let i=t.cache.get(r);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const d=new xt(16777215);l.color!==void 0&&d.setRGB(l.color[0],l.color[1],l.color[2],ri);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new uw(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new pQ(d),c.distance=h;break;case"spot":c=new fQ(d),c.distance=h,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),va(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(r,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,s=r.json.nodes[e],o=(s.extensions&&s.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return r._getNodeRef(t.cache,o,l)})}}class cZ{constructor(){this.name=cn.KHR_MATERIALS_UNLIT}getMaterialType(){return Oc}extendParams(e,t,r){const i=[];e.color=new xt(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],ri),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(r.assignTexture(e,"map",s.baseColorTexture,Ar))}return Promise.all(i)}}class uZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class dZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(r.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Dt(o,o)}return Promise.all(s)}}class hZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_DISPERSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class fZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(s)}}class pZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new xt(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],ri)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(r.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Ar)),a.sheenRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(s)}}class AZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(r.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(s)}}class mZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(r.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new xt().setRGB(o[0],o[1],o[2],ri),Promise.all(s)}}class gZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class yZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(r.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new xt().setRGB(o[0],o[1],o[2],ri),a.specularColorTexture!==void 0&&s.push(r.assignTexture(t,"specularColorMap",a.specularColorTexture,Ar)),Promise.all(s)}}class xZ{constructor(e){this.parser=e,this.name=cn.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(r.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(s)}}class vZ{constructor(e){this.parser=e,this.name=cn.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:ds}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(r.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(s)}}class _Z{constructor(e){this.parser=e,this.name=cn.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,i=r.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,a)}}class bZ{constructor(e){this.parser=e,this.name=cn.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let l=r.textureLoader;if(o.uri){const c=r.options.manager.getHandler(o.uri);c!==null&&(l=c)}return r.loadTextureImage(e,a.source,l)}}class wZ{constructor(e){this.parser=e,this.name=cn.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,r=this.parser,i=r.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let l=r.textureLoader;if(o.uri){const c=r.options.manager.getHandler(o.uri);c!==null&&(l=c)}return r.loadTextureImage(e,a.source,l)}}class EZ{constructor(e){this.name=cn.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const i=r.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(o){const l=i.byteOffset||0,c=i.byteLength||0,d=i.count,h=i.byteStride,p=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(d,h,p,i.mode,i.filter).then(function(A){return A.buffer}):a.ready.then(function(){const A=new ArrayBuffer(d*h);return a.decodeGltfBuffer(new Uint8Array(A),d,h,p,i.mode,i.filter),A})})}else return null}}class IZ{constructor(e){this.name=cn.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const i=t.meshes[r.mesh];for(const c of i.primitives)if(c.mode!==ns.TRIANGLES&&c.mode!==ns.TRIANGLE_STRIP&&c.mode!==ns.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=r.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(d=>(l[c]=d,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const d=c.pop(),h=d.isGroup?d.children:[d],p=c[0].count,A=[];for(const y of h){const m=new Ft,x=new de,g=new In,_=new de(1,1,1),b=new lw(y.geometry,y.material,p);for(let w=0;w<p;w++)l.TRANSLATION&&x.fromBufferAttribute(l.TRANSLATION,w),l.ROTATION&&g.fromBufferAttribute(l.ROTATION,w),l.SCALE&&_.fromBufferAttribute(l.SCALE,w),b.setMatrixAt(w,m.compose(x,g,_));for(const w in l)if(w==="_COLOR_0"){const I=l[w];b.instanceColor=new Gg(I.array,I.itemSize,I.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&y.geometry.setAttribute(w,l[w]);zn.prototype.copy.call(b,y),this.parser.assignFinalMaterial(b),A.push(b)}return d.isGroup?(d.clear(),d.add(...A),d):A[0]}))}}const uP="glTF",Ff=12,rB={JSON:1313821514,BIN:5130562};class CZ{constructor(e){this.name=cn.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ff),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==uP)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Ff,s=new DataView(e,Ff);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===rB.JSON){const c=new Uint8Array(e,Ff+a,o);this.content=r.decode(c)}else if(l===rB.BIN){const c=Ff+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class SZ{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=cn.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const d in a){const h=Ew[d]||d.toLowerCase();o[h]=a[d]}for(const d in e.attributes){const h=Ew[d]||d.toLowerCase();if(a[d]!==void 0){const p=r.accessors[e.attributes[d]],A=Ud[p.componentType];c[h]=A.name,l[h]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(d){return new Promise(function(h,p){i.decodeDracoFile(d,function(A){for(const y in A.attributes){const m=A.attributes[y],x=l[y];x!==void 0&&(m.normalized=x)}h(A)},o,c,ri,p)})})}}class BZ{constructor(){this.name=cn.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class MZ{constructor(){this.name=cn.KHR_MESH_QUANTIZATION}}class dP extends Gp{constructor(e,t,r,i){super(e,t,r,i)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let a=0;a!==i;a++)t[a]=r[s+a];return t}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,d=i-t,h=(r-t)/d,p=h*h,A=p*h,y=e*c,m=y-c,x=-2*A+3*p,g=A-p,_=1-x,b=g-p+h;for(let w=0;w!==o;w++){const I=a[m+w+o],S=a[m+w+l]*d,M=a[y+w+o],T=a[y+w]*d;s[w]=_*I+b*S+x*M+g*T}return s}}const TZ=new In;class RZ extends dP{interpolate_(e,t,r,i){const s=super.interpolate_(e,t,r,i);return TZ.fromArray(s).normalize().toArray(s),s}}const ns={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ud={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},iB={9728:mr,9729:ir,9984:UN,9985:mg,9986:tp,9987:Ia},sB={33071:os,33648:Fg,10497:Fl},Wv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ew={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},wl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},DZ={CUBICSPLINE:void 0,LINEAR:Tp,STEP:Mp},qv={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kZ(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new Jd({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Eo})),n.DefaultMaterial}function wc(n,e,t){for(const r in t.extensions)n[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function va(n,e){e.extras!==void 0&&typeof e.extras=="object"&&Object.assign(n.userData,e.extras)}function NZ(n,e,t){let r=!1,i=!1,s=!1;for(let c=0,d=e.length;c<d;c++){const h=e[c];if(h.POSITION!==void 0&&(r=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(n);const a=[],o=[],l=[];for(let c=0,d=e.length;c<d;c++){const h=e[c];if(r){const p=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):n.attributes.position;a.push(p)}if(i){const p=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):n.attributes.normal;o.push(p)}if(s){const p=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):n.attributes.color;l.push(p)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const d=c[0],h=c[1],p=c[2];return r&&(n.morphAttributes.position=d),i&&(n.morphAttributes.normal=h),s&&(n.morphAttributes.color=p),n.morphTargetsRelative=!0,n})}function QZ(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let r=0,i=t.length;r<i;r++)n.morphTargetDictionary[t[r]]=r}}}function PZ(n){let e;const t=n.extensions&&n.extensions[cn.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Yv(t.attributes):e=n.indices+":"+Yv(n.attributes)+":"+n.mode,n.targets!==void 0)for(let r=0,i=n.targets.length;r<i;r++)e+=":"+Yv(n.targets[r]);return e}function Yv(n){let e="";const t=Object.keys(n).sort();for(let r=0,i=t.length;r<i;r++)e+=t[r]+":"+n[t[r]]+";";return e}function Iw(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function LZ(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const FZ=new Ft;class zZ{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new oZ,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,i=-1,s=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=r&&l?parseInt(l[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&i<17||s&&a<98?this.textureLoader=new Q9(this.options.manager):this.textureLoader=new O9(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new MI(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:r,userData:{}};return wc(s,o,i),va(o,i),Promise.all(r._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(r[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const i=r.clone(),s=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,d]of a.children.entries())s(d,o.children[c])};return s(r,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const i=e(t[r]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&r.push(s)}return r}getDependency(e,t){const r=e+":"+t;let i=this.cache.get(r);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(r,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,a){return r.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[cn.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,a){r.load(Ap.resolveURL(t.uri,i.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(r){const i=t.byteLength||0,s=t.byteOffset||0;return r.slice(s,s+i)})}loadAccessor(e){const t=this,r=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Wv[i.type],o=Ud[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new or(c,a,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],l=Wv[i.type],c=Ud[i.componentType],d=c.BYTES_PER_ELEMENT,h=d*l,p=i.byteOffset||0,A=i.bufferView!==void 0?r.bufferViews[i.bufferView].byteStride:void 0,y=i.normalized===!0;let m,x;if(A&&A!==h){const g=Math.floor(p/A),_="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+g+":"+i.count;let b=t.cache.get(_);b||(m=new c(o,g*A,i.count*A/d),b=new o9(m,A/d),t.cache.add(_,b)),x=new bI(b,l,p%A/d,y)}else o===null?m=new c(i.count*l):m=new c(o,p,i.count*l),x=new or(m,l,y);if(i.sparse!==void 0){const g=Wv.SCALAR,_=Ud[i.sparse.indices.componentType],b=i.sparse.indices.byteOffset||0,w=i.sparse.values.byteOffset||0,I=new _(a[1],b,i.sparse.count*g),S=new c(a[2],w,i.sparse.count*l);o!==null&&(x=new or(x.array.slice(),x.itemSize,x.normalized)),x.normalized=!1;for(let M=0,T=I.length;M<T;M++){const R=I[M];if(x.setX(R,S[M*l]),l>=2&&x.setY(R,S[M*l+1]),l>=3&&x.setZ(R,S[M*l+2]),l>=4&&x.setW(R,S[M*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=y}return x})}loadTexture(e){const t=this.json,r=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const l=r.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,r){const i=this,s=this.json,a=s.textures[e],o=s.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,r).then(function(d){d.flipY=!1,d.name=a.name||o.name||"",d.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(d.name=o.uri);const p=(s.samplers||{})[a.sampler]||{};return d.magFilter=iB[p.magFilter]||ir,d.minFilter=iB[p.minFilter]||Ia,d.wrapS=sB[p.wrapS]||Fl,d.wrapT=sB[p.wrapT]||Fl,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==mr&&d.minFilter!==ir,i.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const r=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=r.getDependency("bufferView",a.bufferView).then(function(h){c=!0;const p=new Blob([h],{type:a.mimeType});return l=o.createObjectURL(p),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(l).then(function(h){return new Promise(function(p,A){let y=p;t.isImageBitmapLoader===!0&&(y=function(m){const x=new ar(m);x.needsUpdate=!0,p(x)}),t.load(Ap.resolveURL(h,s.path),y,void 0,A)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),va(h,a),h.userData.mimeType=a.mimeType||LZ(a.uri),h}).catch(function(h){throw h});return this.sourceCache[e]=d,d}assignTexture(e,t,r,i){const s=this;return this.getDependency("texture",r.index).then(function(a){if(!a)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(a=a.clone(),a.channel=r.texCoord),s.extensions[cn.KHR_TEXTURE_TRANSFORM]){const o=r.extensions!==void 0?r.extensions[cn.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=s.associations.get(a);a=s.extensions[cn.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+r.uuid;let l=this.cache.get(o);l||(l=new lQ,Xs.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,l.sizeAttenuation=!1,this.cache.add(o,l)),r=l}else if(e.isLine){const o="LineBasicMaterial:"+r.uuid;let l=this.cache.get(o);l||(l=new oQ,Xs.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,this.cache.add(o,l)),r=l}if(i||s||a){let o="ClonedMaterial:"+r.uuid+":";i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=r.clone(),s&&(l.vertexColors=!0),a&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(r))),r=l}e.material=r}getMaterialType(){return Jd}loadMaterial(e){const t=this,r=this.json,i=this.extensions,s=r.materials[e];let a;const o={},l=s.extensions||{},c=[];if(l[cn.KHR_MATERIALS_UNLIT]){const h=i[cn.KHR_MATERIALS_UNLIT];a=h.getMaterialType(),c.push(h.extendParams(o,s,t))}else{const h=s.pbrMetallicRoughness||{};if(o.color=new xt(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const p=h.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],ri),o.opacity=p[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",h.baseColorTexture,Ar)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),a=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=rs);const d=s.alphaMode||qv.OPAQUE;if(d===qv.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,d===qv.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Oc&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new Dt(1,1),s.normalTexture.scale!==void 0)){const h=s.normalTexture.scale;o.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&a!==Oc&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Oc){const h=s.emissiveFactor;o.emissive=new xt().setRGB(h[0],h[1],h[2],ri)}return s.emissiveTexture!==void 0&&a!==Oc&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Ar)),Promise.all(c).then(function(){const h=new a(o);return s.name&&(h.name=s.name),va(h,s),t.associations.set(h,{materials:e}),s.extensions&&wc(i,h,s),h})}createUniqueName(e){const t=Mn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,i=this.primitiveCache;function s(o){return r[cn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return aB(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],d=PZ(c),h=i[d];if(h)a.push(h.promise);else{let p;c.extensions&&c.extensions[cn.KHR_DRACO_MESH_COMPRESSION]?p=s(c):p=aB(new _r,c,t),i[d]={primitive:c,promise:p},a.push(p)}}return Promise.all(a)}loadMesh(e){const t=this,r=this.json,i=this.extensions,s=r.meshes[e],a=s.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const d=a[l].material===void 0?kZ(this.cache):this.getDependency("material",a[l].material);o.push(d)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),d=l[l.length-1],h=[];for(let A=0,y=d.length;A<y;A++){const m=d[A],x=a[A];let g;const _=c[A];if(x.mode===ns.TRIANGLES||x.mode===ns.TRIANGLE_STRIP||x.mode===ns.TRIANGLE_FAN||x.mode===void 0)g=s.isSkinnedMesh===!0?new c9(m,_):new Jn(m,_),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),x.mode===ns.TRIANGLE_STRIP?g.geometry=nB(g.geometry,WN):x.mode===ns.TRIANGLE_FAN&&(g.geometry=nB(g.geometry,sw));else if(x.mode===ns.LINES)g=new A9(m,_);else if(x.mode===ns.LINE_STRIP)g=new II(m,_);else if(x.mode===ns.LINE_LOOP)g=new m9(m,_);else if(x.mode===ns.POINTS)g=new g9(m,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(g.geometry.morphAttributes).length>0&&QZ(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),va(g,s),x.extensions&&wc(i,g,x),t.assignFinalMaterial(g),h.push(g)}for(let A=0,y=h.length;A<y;A++)t.associations.set(h[A],{meshes:e,primitives:A});if(h.length===1)return s.extensions&&wc(i,h[0],s),h[0];const p=new ls;s.extensions&&wc(i,p,s),t.associations.set(p,{meshes:e});for(let A=0,y=h.length;A<y;A++)p.add(h[A]);return p})}loadCamera(e){let t;const r=this.json.cameras[e],i=r[r.type];if(i)return r.type==="perspective"?t=new Fr(XN.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):r.type==="orthographic"&&(t=new $0(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),va(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let i=0,s=t.joints.length;i<s;i++)r.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(i){const s=i.pop(),a=i,o=[],l=[];for(let c=0,d=a.length;c<d;c++){const h=a[c];if(h){o.push(h);const p=new Ft;s!==null&&p.fromArray(s.array,c*16),l.push(p)}}return new wI(o,l)})}loadAnimation(e){const t=this.json,r=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],d=[];for(let h=0,p=i.channels.length;h<p;h++){const A=i.channels[h],y=i.samplers[A.sampler],m=A.target,x=m.node,g=i.parameters!==void 0?i.parameters[y.input]:y.input,_=i.parameters!==void 0?i.parameters[y.output]:y.output;m.node!==void 0&&(a.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",g)),l.push(this.getDependency("accessor",_)),c.push(y),d.push(m))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(d)]).then(function(h){const p=h[0],A=h[1],y=h[2],m=h[3],x=h[4],g=[];for(let b=0,w=p.length;b<w;b++){const I=p[b],S=A[b],M=y[b],T=m[b],R=x[b];if(I===void 0)continue;I.updateMatrix&&I.updateMatrix();const k=r._createAnimationTracks(I,S,M,T,R);if(k)for(let H=0;H<k.length;H++)g.push(k[H])}const _=new B9(s,void 0,g);return va(_,i),_})}createNodeMesh(e){const t=this.json,r=this,i=t.nodes[e];return i.mesh===void 0?null:r.getDependency("mesh",i.mesh).then(function(s){const a=r._getNodeRef(r.meshCache,i.mesh,s);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,r=this,i=t.nodes[e],s=r._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,d=o.length;c<d;c++)a.push(r.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):r.getDependency("skin",i.skin);return Promise.all([s,Promise.all(a),l]).then(function(c){const d=c[0],h=c[1],p=c[2];p!==null&&d.traverse(function(A){A.isSkinnedMesh&&A.bind(p,FZ)});for(let A=0,y=h.length;A<y;A++)d.add(h[A]);return d})}_loadNodeShallow(e){const t=this.json,r=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?i.createUniqueName(s.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),s.camera!==void 0&&o.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let d;if(s.isBone===!0?d=new aQ:c.length>1?d=new ls:c.length===1?d=c[0]:d=new zn,d!==c[0])for(let h=0,p=c.length;h<p;h++)d.add(c[h]);if(s.name&&(d.userData.name=s.name,d.name=a),va(d,s),s.extensions&&wc(r,d,s),s.matrix!==void 0){const h=new Ft;h.fromArray(s.matrix),d.applyMatrix4(h)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);if(!i.associations.has(d))i.associations.set(d,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const h=i.associations.get(d);i.associations.set(d,{...h})}return i.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],i=this,s=new ls;r.name&&(s.name=i.createUniqueName(r.name)),va(s,r),r.extensions&&wc(t,s,r);const a=r.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let d=0,h=l.length;d<h;d++)s.add(l[d]);const c=d=>{const h=new Map;for(const[p,A]of i.associations)(p instanceof Xs||p instanceof ar)&&h.set(p,A);return d.traverse(p=>{const A=i.associations.get(p);A!=null&&h.set(p,A)}),h};return i.associations=c(s),s})}_createAnimationTracks(e,t,r,i,s){const a=[],o=e.name?e.name:e.uuid,l=[];wl[s.path]===wl.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let c;switch(wl[s.path]){case wl.weights:c=Kd;break;case wl.rotation:c=Zd;break;case wl.translation:case wl.scale:c=eh;break;default:r.itemSize===1?c=Kd:c=eh;break}const d=i.interpolation!==void 0?DZ[i.interpolation]:Tp,h=this._getArrayFromAccessor(r);for(let p=0,A=l.length;p<A;p++){const y=new c(l[p]+"."+wl[s.path],t.array,h,d);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),a.push(y)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=Iw(t.constructor),i=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)i[s]=t[s]*r;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const i=this instanceof Zd?RZ:dP;return new i(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function UZ(n,e,t){const r=e.attributes,i=new ms;if(r.POSITION!==void 0){const o=t.json.accessors[r.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new de(l[0],l[1],l[2]),new de(c[0],c[1],c[2])),o.normalized){const d=Iw(Ud[o.componentType]);i.min.multiplyScalar(d),i.max.multiplyScalar(d)}}else return}else return;const s=e.targets;if(s!==void 0){const o=new de,l=new de;for(let c=0,d=s.length;c<d;c++){const h=s[c];if(h.POSITION!==void 0){const p=t.json.accessors[h.POSITION],A=p.min,y=p.max;if(A!==void 0&&y!==void 0){if(l.setX(Math.max(Math.abs(A[0]),Math.abs(y[0]))),l.setY(Math.max(Math.abs(A[1]),Math.abs(y[1]))),l.setZ(Math.max(Math.abs(A[2]),Math.abs(y[2]))),p.normalized){const m=Iw(Ud[p.componentType]);l.multiplyScalar(m)}o.max(l)}}}i.expandByVector(o)}n.boundingBox=i;const a=new Fa;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,n.boundingSphere=a}function aB(n,e,t){const r=e.attributes,i=[];function s(a,o){return t.getDependency("accessor",a).then(function(l){n.setAttribute(o,l)})}for(const a in r){const o=Ew[a]||a.toLowerCase();o in n.attributes||i.push(s(r[a],o))}if(e.indices!==void 0&&!n.index){const a=t.getDependency("accessor",e.indices).then(function(o){n.setIndex(o)});i.push(a)}return mn.workingColorSpace!==ri&&"COLOR_0"in r,va(n,e),UZ(n,e,t),Promise.all(i).then(function(){return e.targets!==void 0?NZ(n,e.targets,t):n})}async function oB(n,e){const i=(await new aZ().loadAsync(n)).scene;return i.traverse(s=>{s.visible=!1}),e.add(i),i}function lB(n,e){e.remove(n),n.traverse(t=>{const r=t;r.geometry?.dispose(),Array.isArray(r.material)?r.material.forEach(i=>i.dispose()):r.material?.dispose()})}class cB{constructor(e){this.onPointer=s=>{s.type==="pointerdown"?(this.start(s.clientX,s.clientY),this.mouseDown=!0):s.type==="pointermove"&&this.mouseDown?this.move(s.clientX,s.clientY):s.type==="pointerup"&&this.end()},this.scene=e.scene,this.renderer=e.renderer,this.camera=e.camera,this.container=e.container,this.controls=e.controls,this.draggableBodyIds=e.draggableBodyIds??null,this.mousePos=new Dt,this.raycaster=new K9,this.raycaster.params.Line.threshold=.1,this.grabDistance=0,this.active=!1,this.mouseDown=!1,this.physicsObject=null,this.localHit=new de,this.worldHit=new de,this.currentWorld=new de,this.offset=new de,this.arrow=new ls;const t=new gh(.008,.008,1),r=new Jd({color:16737095,transparent:!0,opacity:.5,metalness:0,roughness:.2});this.arrowShaft=new Jn(t,r),this.arrowShaft.position.y=.5;const i=new SI(.03,.1);this.arrowHead=new Jn(i,r),this.arrowHead.position.y=1,this.arrow.add(this.arrowShaft),this.arrow.add(this.arrowHead),this.arrow.visible=!1,this.scene.add(this.arrow),this.container.addEventListener("pointerdown",this.onPointer,!0),document.addEventListener("pointermove",this.onPointer,!0),document.addEventListener("pointerup",this.onPointer,!0)}updateRaycaster(e,t){const r=this.renderer.domElement.getBoundingClientRect();this.mousePos.x=(e-r.left)/r.width*2-1,this.mousePos.y=-((t-r.top)/r.height)*2+1,this.raycaster.setFromCamera(this.mousePos,this.camera)}start(e,t){this.physicsObject=null,this.updateRaycaster(e,t);const r=this.raycaster.intersectObjects(this.scene.children,!0);for(const i of r){const s=i.object;if(!this.shouldIgnoreForDrag(s)&&this.isDraggableObject(s)){this.physicsObject=s,this.grabDistance=i.distance;const a=this.raycaster.ray.origin.clone().addScaledVector(this.raycaster.ray.direction,this.grabDistance);this.localHit.copy(s.worldToLocal(a.clone())),this.worldHit.copy(a),this.currentWorld.copy(a),this.offset.set(0,0,0),this.arrow.position.copy(a),this.arrow.visible=!1,this.active=!0,this.controls.enabled=!1;break}}}setDraggableBodyIds(e){this.draggableBodyIds=e}isDraggableObject(e){if(!("bodyID"in e)||typeof e.bodyID!="number")return!1;const t=e.bodyID;return!(t<=0||this.draggableBodyIds&&!this.draggableBodyIds.has(t))}shouldIgnoreForDrag(e){let t=e;for(;t;){if(t.userData?.ignoreDragForce===!0)return!0;t=t.parent}return!1}move(e,t){this.active&&this.updateRaycaster(e,t)}update(){if(!this.physicsObject||!this.active)return;this.raycaster.setFromCamera(this.mousePos,this.camera),this.currentWorld.copy(this.raycaster.ray.origin.clone().addScaledVector(this.raycaster.ray.direction,this.grabDistance)),this.worldHit.copy(this.localHit),this.physicsObject.localToWorld(this.worldHit),this.offset.copy(this.currentWorld).sub(this.worldHit),this.arrow.position.copy(this.worldHit);const e=this.offset.length();if(e>.001){this.arrow.visible=!0;const t=this.offset.clone().normalize();this.arrow.quaternion.setFromUnitVectors(new de(0,1,0),t);const r=.1,i=Math.max(.01,e-r);this.arrowShaft.scale.y=i,this.arrowShaft.position.y=i/2,this.arrowHead.position.y=i+r/2}else this.arrow.visible=!1}end(){this.physicsObject=null,this.active=!1,this.controls.enabled=!0,this.arrow.visible=!1,this.mouseDown=!1}dispose(){this.container.removeEventListener("pointerdown",this.onPointer,!0),document.removeEventListener("pointermove",this.onPointer,!0),document.removeEventListener("pointerup",this.onPointer,!0),this.arrow.parent&&this.scene.remove(this.arrow),this.arrowShaft.geometry.dispose(),this.arrowHead.geometry.dispose(),this.arrowShaft.material&&this.arrowShaft.material.dispose()}}const zf={lookat:[0,0,0],distance:4,elevation:-30,azimuth:45,fovy:45};function OZ(n,e,t,r){const i=t*Math.PI/180,s=r*Math.PI/180,a=n[0]+e*Math.cos(i)*Math.cos(s),o=n[1]+e*Math.cos(i)*Math.sin(s),l=n[2]-e*Math.sin(i);return zl([a,o,l])}function $Z(n,e,t,r,i){const s={trackBodyId:null,prevBodyPos:null};t.enabled=!0;const a=n?.lookat??zf.lookat,o=n?.distance??zf.distance,l=n?.elevation??zf.elevation,c=n?.azimuth??zf.azimuth;if(e.fov=n?.fovy??zf.fovy,e.updateProjectionMatrix(),e.position.copy(OZ(a,o,l,c)),t.target.copy(zl(a)),t.update(),!n)return s;const d=n.originType??"AUTO";if(d==="ASSET_BODY"&&n.bodyName&&r){const h=n.bodyName,p=n.entityName,A=p?`${p}/${h}`:null;for(let y=0;y<r.nbody;y++){const m=r.body(y).name;if(m===h||m===A||m.endsWith(`/${h}`)){s.trackBodyId=y;break}}s.trackBodyId}else(d==="AUTO"||d==="ASSET_ROOT")&&r&&r.nbody>1&&(s.trackBodyId=1);if(s.trackBodyId!==null&&i){const h=zl(i.xpos.slice(s.trackBodyId*3,s.trackBodyId*3+3));e.position.add(h),t.target.add(h),s.prevBodyPos=h,t.update()}return s}function GZ(n,e,t,r){if(r.trackBodyId!==null){const i=r.trackBodyId,s=zl(n.xpos.slice(i*3,i*3+3));if(r.prevBodyPos!==null){const a=s.clone().sub(r.prevBodyPos);e.position.add(a),t.target.add(a)}r.prevBodyPos=s}}const Tl=class Tl{constructor(e){this.MAX_CACHE_SIZE=5,this.mujoco=e,this.cache=new Map,this.metrics={totalScenes:0,totalMemoryBytes:0,oldestAccessTime:Date.now(),newestAccessTime:Date.now(),cacheHits:0,cacheMisses:0,evictions:0}}static getInstance(e){return Tl.instance||(Tl.instance=new Tl(e)),Tl.instance}static resetInstance(){Tl.instance=null}normalizeScenePath(e){return e?QI(e):""}has(e){const t=this.normalizeScenePath(e);return this.cache.has(t)}get(e){const t=this.normalizeScenePath(e),r=this.cache.get(t);return r?(r.lastAccessed=Date.now(),this.metrics.cacheHits++,this.updateMetricsTimestamps(),r):(this.metrics.cacheMisses++,null)}async set(e,t){const r=this.normalizeScenePath(e);!this.cache.has(r)&&this.cache.size>=this.MAX_CACHE_SIZE&&await this.maybeEvict(),t.scenePath=r,t.lastAccessed=Date.now(),this.cache.set(r,t),this.updateMetrics()}async evict(e){const t=this.normalizeScenePath(e),r=this.cache.get(t);r&&(await this.disposeSceneResources(r),this.cache.delete(t),this.metrics.evictions++,this.updateMetrics())}async clear(){const e=Array.from(this.cache.keys());for(const t of e)await this.evict(t)}getMetrics(){return{...this.metrics}}async prepareForNewScene(){this.cache.size>=this.MAX_CACHE_SIZE&&await this.maybeEvict()}findLRUScene(){let e=null,t=1/0;for(const[r,i]of this.cache.entries())i.lastAccessed<t&&(t=i.lastAccessed,e=r);return e}async maybeEvict(){const e=this.findLRUScene();e&&await this.evict(e)}async disposeSceneResources(e){const t=performance.now();if(e.skybox&&e.skybox.dispose(),e.mujocoRoot&&this.disposeThreeJSObject(e.mujocoRoot),e.mjData)try{e.mjData.delete()}catch{}if(e.mjModel)try{e.mjModel.delete()}catch{}for(const r of e.fsFiles)try{const i=`/working/${r}`;this.mujoco.FS.analyzePath(i,!1).exists&&this.mujoco.FS.unlink(i)}catch{}gX(e.scenePath),performance.now()-t,(e.estimatedMemoryBytes/1048576).toFixed(1)}disposeThreeJSObject(e){e.traverse(t=>{"geometry"in t&&t.geometry&&t.geometry.dispose(),"material"in t&&t.material&&(Array.isArray(t.material)?t.material.forEach(r=>this.disposeMaterial(r)):this.disposeMaterial(t.material))}),e.parent&&e.parent.remove(e)}disposeMaterial(e){const t=e;t.map&&t.map.dispose(),t.aoMap&&t.aoMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.envMap&&t.envMap.dispose(),t.alphaMap&&t.alphaMap.dispose(),t.lightMap&&t.lightMap.dispose(),t.displacementMap&&t.displacementMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),e.dispose()}updateMetrics(){this.metrics.totalScenes=this.cache.size,this.metrics.totalMemoryBytes=0;for(const e of this.cache.values())this.metrics.totalMemoryBytes+=e.estimatedMemoryBytes;this.updateMetricsTimestamps()}updateMetricsTimestamps(){let e=Date.now(),t=0;for(const r of this.cache.values())r.lastAccessed<e&&(e=r.lastAccessed),r.lastAccessed>t&&(t=r.lastAccessed);this.metrics.oldestAccessTime=e,this.metrics.newestAccessTime=t}};Tl.instance=null;let Cw=Tl;class VZ{constructor(){this.fsWriteLog=[],this.isTracking=!1}startTracking(e){if(this.isTracking)return;this.fsWriteLog=[],this.isTracking=!0,this.originalWriteFile=e.FS.writeFile;const t=this.fsWriteLog,r=this.originalWriteFile;e.FS.writeFile=function(i,s,a){if(i.startsWith("/working/")){const o=i.replace(/^\/working\//,"");t.includes(o)||t.push(o)}if(r)return r.call(e.FS,i,s,a)}}stopTracking(e){return this.isTracking?(this.originalWriteFile&&(e.FS.writeFile=this.originalWriteFile,this.originalWriteFile=void 0),this.isTracking=!1,[...this.fsWriteLog]):[]}estimateSceneMemory(e){let t=0;t+=this.estimateMuJoCoMemory(e.mjModel),t+=this.estimateMjDataMemory(e.mjData);const r=new Set,i=new Set,s=new Set;for(const a of Object.values(e.meshes))r.has(a)||(t+=this.estimateGeometryMemory(a),r.add(a));return e.mujocoRoot.traverse(a=>{if("geometry"in a&&a.geometry){const o=a.geometry;r.has(o)||(t+=this.estimateGeometryMemory(o),r.add(o))}if("material"in a&&a.material){const o=Array.isArray(a.material)?a.material:[a.material];for(const l of o)i.has(l)||(t+=1024,i.add(l),this.collectMaterialTextures(l).forEach(c=>{s.has(c)||(t+=this.estimateTextureMemory(c),s.add(c))}))}}),t}collectMaterialTextures(e){const t=[],r=e;return r.map&&t.push(r.map),r.aoMap&&t.push(r.aoMap),r.emissiveMap&&t.push(r.emissiveMap),r.metalnessMap&&t.push(r.metalnessMap),r.normalMap&&t.push(r.normalMap),r.roughnessMap&&t.push(r.roughnessMap),r.envMap&&t.push(r.envMap),r.alphaMap&&t.push(r.alphaMap),r.lightMap&&t.push(r.lightMap),r.displacementMap&&t.push(r.displacementMap),r.bumpMap&&t.push(r.bumpMap),t}estimateMuJoCoMemory(e){let t=0;return e.nq&&(t+=e.nq*8),e.nv&&(t+=e.nv*8),e.nbody&&(t+=e.nbody*256),e.mesh_vert&&(t+=e.mesh_vert.length*4),e.mesh_normal&&(t+=e.mesh_normal.length*4),e.mesh_texcoord&&(t+=e.mesh_texcoord.length*4),e.mesh_face&&(t+=e.mesh_face.length*4),e.tex_data&&(t+=e.tex_data.length),t}estimateMjDataMemory(e){let t=0;return e.qpos&&(t+=e.qpos.length*8),e.qvel&&(t+=e.qvel.length*8),e.qacc&&(t+=e.qacc.length*8),e.qacc_warmstart&&(t+=e.qacc_warmstart.length*8),e.ctrl&&(t+=e.ctrl.length*8),e.qfrc_applied&&(t+=e.qfrc_applied.length*8),e.xfrc_applied&&(t+=e.xfrc_applied.length*8),e.xpos&&(t+=e.xpos.length*8),e.xquat&&(t+=e.xquat.length*8),e.xmat&&(t+=e.xmat.length*8),e.xipos&&(t+=e.xipos.length*8),e.ximat&&(t+=e.ximat.length*8),e.ncon&&(t+=e.ncon*256),e.efc_force&&(t+=e.efc_force.length*8),e.sensordata&&(t+=e.sensordata.length*8),t}estimateGeometryMemory(e){let t=0;const r=e.attributes;for(const i in r){const s=r[i];s&&"array"in s&&(t+=s.array.byteLength)}return e.index&&(t+=e.index.array.byteLength),t}estimateTextureMemory(e){if(!e.image)return 1024;if(e instanceof mh&&Array.isArray(e.image)&&e.image.length===6){let r=0;for(const i of e.image){const s=i;s&&typeof s=="object"&&"width"in s&&"height"in s&&(r+=s.width*s.height*4)}return r}const t=e.image;return t&&typeof t=="object"&&"width"in t&&"height"in t?t.width*t.height*4:1024}}class HZ{getStats(e,t){const r=this.getJSHeapStats(),i={jsHeapUsedMB:r.used,jsHeapTotalMB:r.total,jsHeapLimitMB:r.limit,cachedScenesCount:e.totalScenes,estimatedCacheMemoryMB:e.totalMemoryBytes/1048576,estimatedGPUMemoryMB:0,sceneBreakdown:[]};if(t)for(const[s,a]of t.entries())i.sceneBreakdown.push({scenePath:s,memoryMB:a.memoryBytes/1048576,lastAccessed:new Date(a.lastAccessed)});return i}logCacheOperation(e,t,r){switch(e){case"load":{r?.memoryMB&&`${r.memoryMB.toFixed(1)}`,r?.totalScenes!==void 0&&r?.totalMemoryMB!==void 0&&`${r.totalScenes}${r.totalMemoryMB.toFixed(1)}`;break}case"hit":{r?.elapsedMs!==void 0&&`${r.elapsedMs.toFixed(0)}`;break}case"miss":break;case"evict":{r?.memoryMB&&`${r.memoryMB.toFixed(1)}`;break}}}logStats(e){if(e.sceneBreakdown.length>0)for(const t of e.sceneBreakdown);}getJSHeapStats(){const e=performance;return e.memory?{used:e.memory.usedJSHeapSize/1048576,total:e.memory.totalJSHeapSize/1048576,limit:e.memory.jsHeapSizeLimit/1048576}:{used:0,total:0,limit:0}}estimateGPUMemory(e){const t=e.info,r=t.memory.geometries,i=t.memory.textures;return r*1+i*2}}const jZ={},WZ=jZ;class qZ{constructor(e){this.config=e}}const YZ={};async function XZ(n){const e=new DecompressionStream("deflate-raw"),t=e.writable.getWriter(),r=e.readable.getReader();t.write(n),t.close();const i=[];let s=0;for(;;){const{done:l,value:c}=await r.read();if(l)break;i.push(c),s+=c.byteLength}const a=new Uint8Array(s);let o=0;for(const l of i)a.set(l,o),o+=l.byteLength;return a}function JZ(n){const e=[147,78,85,77,80,89];for(let w=0;w<e.length;w++)if(n[w]!==e[w])throw new Error("Invalid .npy magic number");const t=n[6];let r,i;t===1?(r=n[8]|n[9]<<8,i=10):(r=n[8]|n[9]<<8|n[10]<<16|n[11]<<24,i=12);const s=n.slice(i,i+r),a=new TextDecoder().decode(s),o=a.match(/'descr'\s*:\s*'([^']+)'/),l=a.match(/'shape'\s*:\s*\(([^)]*)\)/),c=a.match(/'fortran_order'\s*:\s*(True|False)/);if(!o||!l)throw new Error(`Cannot parse .npy header: ${a}`);const d=o[1];if(c?c[1]==="True":!1)throw new Error("Fortran-ordered arrays not supported");const A=l[1].split(",").map(w=>w.trim()).filter(w=>w.length>0).map(w=>parseInt(w,10)),y=i+r,m=n.slice(y),x=d[0],g=d.slice(1),_=x===">"||x==="="&&!ZZ();let b;if(g==="f4")b=new Float32Array(m.buffer,m.byteOffset,m.byteLength/4),_&&(b=eee(b));else if(g==="f8"){let w=new Float64Array(m.buffer,m.byteOffset,m.byteLength/8);_&&(w=tee(w)),b=new Float32Array(w.length);for(let I=0;I<w.length;I++)b[I]=w[I]}else if(g==="i4"){let w=new Int32Array(m.buffer,m.byteOffset,m.byteLength/4);_&&(w=nee(w)),b=new Float32Array(w.length);for(let I=0;I<w.length;I++)b[I]=w[I]}else if(g==="i8"){let w=new BigInt64Array(m.buffer,m.byteOffset,m.byteLength/8);_&&(w=ree(w)),b=new Float32Array(w.length);for(let I=0;I<w.length;I++)b[I]=Number(w[I])}else{const w=d.match(/^S(\d+)$/);if(w){const S=parseInt(w[1],10),M=m.length/S,T=A.reduce((H,Q)=>H*Q,1);if(M!==T)throw new Error(`npz: byte-string array size mismatch (shape ${A} expects ${T} elements, got ${M})`);const R=new TextDecoder("utf-8"),k=[];for(let H=0;H<M;H++){const Q=m.slice(H*S,(H+1)*S),V=Q.indexOf(0);k.push(R.decode(V>=0?Q.slice(0,V):Q))}return{shape:A,data:new Float32Array(0),strings:k}}const I=g.match(/^U(\d+)$/);if(I){const S=parseInt(I[1],10),M=S*4,T=m.length/M,R=A.reduce((V,B)=>V*B,1);if(T!==R)throw new Error(`npz: unicode array size mismatch (shape ${A} expects ${R} elements, got ${T})`);const k=new DataView(m.buffer,m.byteOffset,m.byteLength),H=!_,Q=[];for(let V=0;V<T;V++){const B=[];for(let W=0;W<S;W++){const K=k.getUint32(V*M+W*4,H);if(K===0)break;B.push(K)}Q.push(String.fromCodePoint(...B))}return{shape:A,data:new Float32Array(0),strings:Q}}throw g==="O"?new Error(KZ):new Error(`Unsupported numpy dtype: ${d}`)}return{shape:A,data:b}}const KZ="npz: pickled python objects (|O dtype) cannot be loaded in the browser";function ZZ(){const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,1,!0),new Int16Array(n)[0]===1}function eee(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new Float32Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getFloat32(r*4,!0);return t}function tee(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new Float64Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getFloat64(r*8,!0);return t}function nee(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new Int32Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getInt32(r*4,!0);return t}function ree(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new BigInt64Array(n.length);for(let r=0;r<n.length;r++)t[r]=e.getBigInt64(r*8,!0);return t}async function iee(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch NPZ: ${e.status} ${n}`);const t=await e.arrayBuffer(),r=new Uint8Array(t),i={};let s=0;for(;s+30<=r.length&&!(r[s]!==80||r[s+1]!==75||r[s+2]!==3||r[s+3]!==4);){const a=r[s+8]|r[s+9]<<8,o=(r[s+22]|r[s+23]<<8|r[s+24]<<16|r[s+25]<<24)>>>0;let l=(r[s+18]|r[s+19]<<8|r[s+20]<<16|r[s+21]<<24)>>>0;const c=r[s+26]|r[s+27]<<8,d=r[s+28]|r[s+29]<<8,h=r.slice(s+30,s+30+c);let p=new TextDecoder().decode(h);if(l===4294967295||o===4294967295){const x=s+30+c;let g=x;for(;g+4<=x+d;){const _=r[g]|r[g+1]<<8,b=r[g+2]|r[g+3]<<8;if(_===1){let w=g+4;if(o===4294967295&&w+8<=g+4+b&&(w+=8),l===4294967295&&w+8<=g+4+b){const I=(r[w]|r[w+1]<<8|r[w+2]<<16|r[w+3]<<24)>>>0;l=((r[w+4]|r[w+5]<<8|r[w+6]<<16|r[w+7]<<24)>>>0)*4294967296+I}break}g+=4+b}}const A=s+30+c+d,y=r.slice(A,A+l);if(s=A+l,p.endsWith("/"))continue;p.endsWith(".npy")&&(p=p.slice(0,-4));let m;if(a===0)m=y;else if(a===8)m=await XZ(y);else continue;try{i[p]=JZ(m)}catch(x){x instanceof Error?x.message:String(x)}}return i}function Xv(n){const e=Math.hypot(n[0]??1,n[1]??0,n[2]??0,n[3]??0)||1;return new Float32Array([(n[0]??1)/e,(n[1]??0)/e,(n[2]??0)/e,(n[3]??0)/e])}function Ec(n){const e=n.shape[0]??0,t=n.shape.length<=1?1:n.shape.slice(1).reduce((i,s)=>i*s,1),r=[];for(let i=0;i<e;i++){const s=new Float32Array(t),a=i*t;for(let o=0;o<t;o++)s[o]=n.data[a+o]??0;r.push(s)}return r}function hP(n,e){if(!Array.isArray(n)||n.length<2)return e;const t=Number(n[0]),r=Number(n[1]);return!Number.isFinite(t)||!Number.isFinite(r)?e:[t,r]}function uB(n){if(n===null||typeof n!="object"||Array.isArray(n))return{};const e={};for(const t of["x","y","z","roll","pitch","yaw"]){const r=hP(n[t],[0,0]);(r[0]!==0||r[1]!==0)&&(e[t]=r)}return e}function Oi(n){return n?n[0]+Math.random()*(n[1]-n[0]):0}function see(n,e){const t=n[0]??1,r=n[1]??0,i=n[2]??0,s=n[3]??0,a=e[0]??1,o=e[1]??0,l=e[2]??0,c=e[3]??0;return new Float32Array([t*a-r*o-i*l-s*c,t*o+r*a+i*c-s*l,t*l-r*c+i*a+s*o,t*c+r*l-i*o+s*a])}function aee(n,e,t){const r=Math.cos(n*.5),i=Math.sin(n*.5),s=Math.cos(e*.5),a=Math.sin(e*.5),o=Math.cos(t*.5),l=Math.sin(t*.5);return new Float32Array([r*s*o+i*a*l,i*s*o-r*a*l,r*a*o+i*s*l,r*s*l-i*a*o])}function dB(n){const e=n.clone();return"transparent"in e&&(e.transparent=!0),"opacity"in e&&(e.opacity=.5),"depthWrite"in e&&(e.depthWrite=!1),"color"in e&&e.color instanceof xt&&(e.color=new xt(.5,.7,.5)),e}function oee(n){let e=!1;return n.traverse(t=>{t instanceof Jn&&(e=!0)}),e}class lee{constructor(e,t,r){this.context=r,this.motions=Array.isArray(t.motions)?t.motions:[],this.loadedMotions=new Map,this.sampleHz=50,this.selectedMotionName=this.motions.find(i=>i.default)?.name??this.motions[0]?.name??null,this.selectedMotion=null,this.selectedAnchorBodyIndex=0,this.selectedRootBodyIndex=0,this.datasetQposAdr=[],this.frameAccumulator=0,this.justReset=!0,this.referenceVisible=!0,this.samplingMode=typeof t.sampling_mode=="string"?t.sampling_mode:"start",this.poseRange=uB(t.pose_range),this.velocityRange=uB(t.velocity_range),this.jointPositionRange=hP(t.joint_position_range,[0,0]),this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refIdx=0,this.refLen=0,this.nJoints=this.motions.find(i=>i.name===this.selectedMotionName)?.dataset_joint_names?.length??0,this.ghostBodies=new Map,this.ghostData=r.mjModel?new r.mujoco.MjData(r.mjModel):null,this.ghostRoot=this.createGhostRoot(),this.refBodyPosW=[],this.refBodyQuatW=[],this.refBodyLinVelW=[],this.refBodyAngVelW=[]}getCommand(){if(!this.selectedMotion||this.refLen===0)return new Float32Array(this.nJoints*2);if(this.selectedMotion.clip_format==="qpos")return new Float32Array(0);const e=this.refJointPos[this.refIdx]??new Float32Array(this.nJoints),t=this.selectedMotion.jointVel[this.refIdx]??new Float32Array(this.nJoints),r=new Float32Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r}getUiConfig(){return null}async setSelectedMotion(e){if(e===null)return this.selectedMotionName=null,this.selectedMotion=null,this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refBodyPosW=[],this.refBodyQuatW=[],this.refBodyLinVelW=[],this.refBodyAngVelW=[],this.refLen=0,this.nJoints=0,this.updateGhostPose(),!1;const t=this.motions.find(i=>i.name===e);if(!t)return!1;const r=this.loadedMotions.get(e)??await this.loadMotion(t);return this.loadedMotions.set(e,r),this.selectedMotionName=e,this.selectedMotion=r,this.selectedAnchorBodyIndex=Math.max(0,r.body_names.indexOf(r.anchor_body_name)),this.selectedRootBodyIndex=0,this.datasetQposAdr=this.resolveQposAdr(r.dataset_joint_names??[]),this.refLen=r.frameCount,this.refJointPos=r.jointPos,this.refIdx=this.sampleInitialFrame(this.refLen),this.nJoints=r.jointPos[0]?.length??0,this.frameAccumulator=0,this.justReset=!0,this.updateReferenceState(),this.applyReferenceStateToSim(),this.updateGhostPose(),!0}setReferenceVisible(e){this.referenceVisible=e,this.ghostRoot&&(this.ghostRoot.visible=e&&this.selectedMotion!==null)}reset(){this.refIdx=this.sampleInitialFrame(this.refLen),this.frameAccumulator=0,this.justReset=!0,this.updateReferenceState(),this.applyReferenceStateToSim(),this.updateGhostPose()}update(e){if(!this.selectedMotion||this.refLen<=1)return;if(this.justReset){this.justReset=!1,this.updateGhostPose();return}if(this.selectedMotion.time_source==="sim"){const i=this.context.mjData?.time??0;this.refIdx=this.sampleHz>0?Math.floor(i*this.sampleHz)%this.refLen:0,this.updateGhostPose();return}const t=this.selectedMotion?.loop!==!1;this.frameAccumulator+=e*this.sampleHz;let r=!1;for(;this.frameAccumulator>=1;){if(this.refIdx+=1,this.refIdx>=this.refLen){if(!t){this.refIdx=this.refLen-1,this.frameAccumulator=0;break}this.refIdx=0,r=!0}this.frameAccumulator-=1}r&&this.context.requestReset?.(),this.updateGhostPose()}updateDebugVisuals(){this.ghostRoot&&(this.ghostRoot.visible=this.referenceVisible&&this.selectedMotion!==null)}dispose(){this.ghostRoot&&(this.ghostRoot.parent?.remove(this.ghostRoot),this.ghostRoot.traverse(e=>{if(e instanceof Jn)if(Array.isArray(e.material))for(const t of e.material)t.dispose?.();else e.material?.dispose?.()})),this.ghostData?.delete?.()}isReady(){return this.selectedMotion!==null&&this.refLen>0}getSelectedMotion(){return this.selectedMotion}getSelectedMotionName(){return this.selectedMotionName}getClipUrl(){return this.selectedMotion?.path??this.motions[0]?.path??null}getAnchorBodyName(){return this.selectedMotion?.anchor_body_name??this.motions.find(e=>e.name===this.selectedMotionName)?.anchor_body_name??null}getBodyNames(){return this.selectedMotion?.body_names??this.motions.find(e=>e.name===this.selectedMotionName)?.body_names??[]}getAnchorBodyIndex(){return this.selectedAnchorBodyIndex}getAnchorPos(e=this.refIdx){if(!this.selectedMotion)return null;const r=this.refBodyPosW[e];if(!r)return null;const i=this.selectedAnchorBodyIndex*3;return r.slice(i,i+3)}getAnchorQuat(e=this.refIdx){if(!this.selectedMotion)return null;const r=this.refBodyQuatW[e];if(!r)return null;const i=this.selectedAnchorBodyIndex*4;return Xv(r.slice(i,i+4))}getBodyPosW(e=this.refIdx){if(!this.selectedMotion)return null;const r=this.refBodyPosW[e];return r?r.slice():null}createGhostRoot(){const e=this.context.bodies??null,t=this.context.mjModel;if(!e||!t)return null;const r=new ls;r.name="Tracking Ghost",r.visible=!1;for(const[i,s]of Object.entries(e)){const a=Number(i);if(!this.isDynamicBody(a))continue;const o=s.clone(!0);o.traverse(l=>{l instanceof Jn&&(Array.isArray(l.material)?l.material=l.material.map(dB):l.material=dB(l.material),l.renderOrder=2)}),oee(o)&&(this.ghostBodies.set(a,o),r.add(o))}return(this.context.mujocoRoot??this.context.scene).add(r),r}isDynamicBody(e){const t=this.context.mjModel;if(!t||e<=0||e>=t.nbody)return!1;let r=e;for(;r>0;){if(t.body_jntnum[r]>0)return!0;r=t.body_parentid[r]}return!1}async loadMotion(e){this.sampleHz=e.fps;const t=await iee(e.path),r=[];if(e.clip_format==="qpos"){if(!t.qpos)throw new Error("Motion asset with clip_format='qpos' is missing 'qpos'");const p=Ec(t.qpos);return{...e,jointPos:r,jointVel:r,bodyPosW:r,bodyQuatW:r,bodyLinVelW:r,bodyAngVelW:r,qposFrames:p,frameCount:p.length}}const i=["joint_pos","joint_vel","body_pos_w","body_quat_w","body_lin_vel_w","body_ang_vel_w"];for(const p of i)if(!t[p])throw new Error(`Motion asset is missing '${p}'`);const s=Ec(t.joint_pos),a=Ec(t.joint_vel),o=t.body_names?.strings??null,l=this.selectMotionBodyFrames(Ec(t.body_pos_w),e.body_names,3,o),c=this.selectMotionBodyFrames(Ec(t.body_quat_w),e.body_names,4,o),d=this.selectMotionBodyFrames(Ec(t.body_lin_vel_w),e.body_names,3,o),h=this.selectMotionBodyFrames(Ec(t.body_ang_vel_w),e.body_names,3,o);return{...e,jointPos:s,jointVel:a,bodyPosW:l,bodyQuatW:c,bodyLinVelW:d,bodyAngVelW:h,frameCount:s.length}}selectMotionBodyFrames(e,t,r,i=null){const s=this.context.mjModel,a=e[0];if(!s||!a||t.length===0)return e;const o=Math.floor(a.length/r);if(o===t.length)return e;let l;if(i!==null)l=t.map(c=>i.indexOf(c));else{const c=this.findBodyIdByName(t[0]);l=t.map(h=>this.findBodyIdByName(h)).map(h=>h-c)}return l.some(c=>c<0||c>=o)?e:e.map(c=>{const d=new Float32Array(t.length*r);for(let h=0;h<l.length;h++){const p=l[h]*r,A=h*r;for(let y=0;y<r;y++)d[A+y]=c[p+y]??0}return d})}updateReferenceState(){const e=this.selectedMotion;if(!e||e.frameCount===0||e.clip_format==="qpos"){this.refRootPos=[],this.refRootQuat=[],this.refBodyPosW=[],this.refBodyQuatW=[],this.refBodyLinVelW=[],this.refBodyAngVelW=[];return}this.refBodyPosW=e.bodyPosW.map(t=>t.slice()),this.refBodyQuatW=e.bodyQuatW.map(t=>t.slice()),this.refBodyLinVelW=e.bodyLinVelW.map(t=>t.slice()),this.refBodyAngVelW=e.bodyAngVelW.map(t=>t.slice()),this.refRootPos=this.refBodyPosW.map(t=>t.slice(this.selectedRootBodyIndex*3,this.selectedRootBodyIndex*3+3)),this.refRootQuat=this.refBodyQuatW.map(t=>Xv(t.slice(this.selectedRootBodyIndex*4,this.selectedRootBodyIndex*4+4)))}applyReferenceStateToSim(){const e=this.context.mjModel,t=this.context.mjData,r=this.selectedMotion;if(!e||!t||!r||this.refLen===0||r.clip_format==="qpos")return;const i=this.sampleRootPos(this.refIdx),s=this.sampleRootQuat(this.refIdx),a=this.findFreeJointIndex();if(i&&s&&a>=0){const c=e.jnt_qposadr[a],d=e.jnt_dofadr[a];t.qpos[c+0]=i[0]??0,t.qpos[c+1]=i[1]??0,t.qpos[c+2]=i[2]??0,t.qpos[c+3]=s[0]??1,t.qpos[c+4]=s[1]??0,t.qpos[c+5]=s[2]??0,t.qpos[c+6]=s[3]??0;const h=this.sampleRootVelocity(this.refIdx,this.refBodyLinVelW),p=this.sampleRootAngularVelocity(this.refIdx);h&&p&&(t.qvel[d+0]=h[0]??0,t.qvel[d+1]=h[1]??0,t.qvel[d+2]=h[2]??0,t.qvel[d+3]=p[0]??0,t.qvel[d+4]=p[1]??0,t.qvel[d+5]=p[2]??0)}const o=this.sampleJointPos(this.refIdx),l=r.jointVel[this.refIdx]??new Float32Array(0);for(let c=0;c<this.datasetQposAdr.length&&c<o.length;c++)t.qpos[this.datasetQposAdr[c]]=o[c]??0;for(let c=0;c<this.datasetQposAdr.length&&c<l.length;c++){const d=this.resolveQvelAdrForQposAdr(this.datasetQposAdr[c]);d>=0&&(t.qvel[d]=l[c]??0)}this.context.mujoco.mj_forward(e,t)}sampleRootPos(e){const t=this.refRootPos[e];if(!t)return null;const r=t.slice();return r[0]+=Oi(this.poseRange.x),r[1]+=Oi(this.poseRange.y),r[2]+=Oi(this.poseRange.z),r}sampleRootQuat(e){const t=this.refRootQuat[e];if(!t)return null;const r=Oi(this.poseRange.roll),i=Oi(this.poseRange.pitch),s=Oi(this.poseRange.yaw);return r===0&&i===0&&s===0?t:Xv(see(aee(r,i,s),t))}sampleRootVelocity(e,t){const r=t[e]?.slice(this.selectedRootBodyIndex*3,this.selectedRootBodyIndex*3+3);return r?(r[0]+=Oi(this.velocityRange.x),r[1]+=Oi(this.velocityRange.y),r[2]+=Oi(this.velocityRange.z),r):null}sampleRootAngularVelocity(e){const t=this.refBodyAngVelW[e]?.slice(this.selectedRootBodyIndex*3,this.selectedRootBodyIndex*3+3);return t?(t[0]+=Oi(this.velocityRange.roll),t[1]+=Oi(this.velocityRange.pitch),t[2]+=Oi(this.velocityRange.yaw),t):null}sampleInitialFrame(e){return e<=1||this.samplingMode==="start"?0:this.samplingMode==="uniform"?Math.floor(Math.random()*e):0}sampleJointPos(e){const t=this.refJointPos[e]??new Float32Array(0);if(this.jointPositionRange[0]===0&&this.jointPositionRange[1]===0)return t;const r=t.slice();for(let i=0;i<r.length;i++)r[i]+=Oi(this.jointPositionRange);return r}resolveQposAdr(e){const t=this.context.mjModel;if(!t||e.length===0)return[];const r=[];for(const i of e){let s=-1;for(let a=0;a<t.njnt;a++){const o=t.jnt(a).name;if(o===i||o.endsWith(`/${i}`)){s=t.jnt_qposadr[a];break}}s>=0&&r.push(s)}return r}resolveQvelAdrForQposAdr(e){const t=this.context.mjModel;if(!t)return-1;for(let r=0;r<t.njnt;r++)if(t.jnt_qposadr[r]===e)return t.jnt_dofadr[r];return-1}findBodyIdByName(e){const t=this.context.mjModel;if(!t)return-1;for(let r=0;r<t.nbody;r++){const i=t.body(r).name;if(i===e||i.endsWith(`/${e}`))return r}return-1}updateGhostPose(){if(!this.ghostRoot||!this.ghostData||!this.context.mjModel||!this.selectedMotion||!this.refLen){this.ghostRoot&&(this.ghostRoot.visible=!1);return}if(this.selectedMotion.clip_format==="qpos"&&this.selectedMotion.qposFrames){const a=this.selectedMotion.qposFrames[this.refIdx];a&&this.ghostData.qpos.set(a),this.context.mujoco.mj_forward(this.context.mjModel,this.ghostData);for(const[o,l]of this.ghostBodies)Ll(this.ghostData.xpos,o,l.position),Fd(this.ghostData.xquat,o,l.quaternion);this.ghostRoot.visible=this.referenceVisible;return}const e=this.ghostData.qpos;e.set(this.context.mjModel.qpos0);const t=this.refRootPos[this.refIdx],r=this.refRootQuat[this.refIdx],i=this.findFreeJointIndex();if(i>=0&&t&&r){const a=this.context.mjModel.jnt_qposadr[i];e[a+0]=t[0]??0,e[a+1]=t[1]??0,e[a+2]=t[2]??0,e[a+3]=r[0]??1,e[a+4]=r[1]??0,e[a+5]=r[2]??0,e[a+6]=r[3]??0}const s=this.refJointPos[this.refIdx]??new Float32Array(0);for(let a=0;a<this.datasetQposAdr.length&&a<s.length;a++)e[this.datasetQposAdr[a]]=s[a]??0;this.context.mujoco.mj_forward(this.context.mjModel,this.ghostData);for(const[a,o]of this.ghostBodies)Ll(this.ghostData.xpos,a,o.position),Fd(this.ghostData.xquat,a,o.quaternion);this.ghostRoot.visible=this.referenceVisible}findFreeJointIndex(){const e=this.context.mjModel;if(!e)return-1;for(let t=0;t<e.njnt;t++)if(e.jnt_type[t]===0)return t;return-1}}function Sw(n,e){return`${n}:${e}`}function cee(n){return typeof n=="object"&&n!==null&&"isReady"in n&&"getAnchorBodyName"in n&&"getBodyNames"in n}class uee{constructor(e,t){this.inputs=Array.isArray(t.ui?.inputs)?t.ui.inputs:[],this.values=new Map;for(const r of this.inputs)r.type==="slider"?this.values.set(r.name,r.default):r.type==="checkbox"&&this.values.set(r.name,r.default?1:0)}getCommand(){const e=this.inputs.filter(r=>r.type==="slider"||r.type==="checkbox"),t=new Float32Array(e.length);for(let r=0;r<e.length;r++){const i=e[r],s=i.type==="checkbox"?i.default?1:0:i.default;t[r]=this.values.get(i.name)??s??0}return t}getUiConfig(){return{inputs:this.inputs}}reset(){for(const e of this.inputs)e.type==="slider"?this.values.set(e.name,e.default):e.type==="checkbox"&&this.values.set(e.name,e.default?1:0)}setValue(e,t){const r=this.inputs.find(s=>(s.type==="slider"||s.type==="checkbox")&&s.name===e);if(!r)return 0;if(r.type==="checkbox"){const s=t>=.5?1:0;return this.values.set(r.name,s),s}const i=Math.max(r.min,Math.min(r.max,t));return this.values.set(r.name,i),i}}const dee={UiCommand:uee,TrackingCommand:lee};class hee{constructor(){this.terms=new Map,this.commands=new Map,this.commandGroups=new Map,this.values=new Map,this.listeners=new Set,this.resetCallback=null,this.context=null,this.registerSystemReset()}initialize(e,t){this.clear(),this.context=t;const r={...dee,...YZ};for(const[i,s]of Object.entries(e)){const a=r[s.name];if(!a)throw new Error(`Unknown command term: ${s.name}`);const o=new a(i,s,t);this.terms.set(i,o),this.registerUi(i,o)}}update(e){for(const t of this.terms.values())t.update?.(e)}updateDebugVisuals(){for(const e of this.terms.values())e.updateDebugVisuals?.()}resetTerms(){for(const e of this.terms.values())e.reset?.();this.syncValuesFromTerms(),this.emit({type:"reset",commandId:"*"})}getCommandGroups(){return Array.from(this.commandGroups.keys()).filter(e=>e!=="_system")}getCommandsInGroup(e){return(this.commandGroups.get(e)??[]).map(r=>this.commands.get(r)).filter(Boolean)}getCommands(){return Array.from(this.commands.values()).filter(e=>e.groupName!=="_system")}getAllCommands(){return Array.from(this.commands.values())}getResetCommand(){return this.commands.get("_system:reset")}getCommandById(e){return this.commands.get(e)}getValue(e){return this.values.get(e)??0}getValues(){const e={};for(const[t,r]of this.values)e[t]=r;return e}getCommand(e){const t=this.terms.get(e);return t?t.getCommand():new Float32Array(0)}getTerm(e){return this.terms.get(e)}getContext(){return this.context}getVelocityCommand(){return this.terms.has("velocity")?this.getCommand("velocity"):this.terms.has("twist")?this.getCommand("twist"):new Float32Array([.5,0,0])}setValue(e,t){const r=this.commands.get(e);if(!r||r.config.type!=="slider"&&r.config.type!=="checkbox")return;const i=this.terms.get(r.groupName),s=r.config.name,a=i?.setValue?i.setValue(s,t):void 0,o=typeof a=="number"?a:t;this.values.set(e,o),this.emit({type:"change",commandId:e,groupName:r.groupName,value:o})}triggerButton(e){const t=this.commands.get(e);!t||t.config.type!=="button"||(e==="_system:reset"&&this.resetCallback?this.resetCallback():this.terms.get(t.groupName)?.triggerButton?.(t.config.name),this.emit({type:"button",commandId:e,groupName:t.groupName}))}resetToDefaults(){this.resetTerms()}setResetCallback(e){this.resetCallback=e}addEventListener(e){this.listeners.add(e)}removeEventListener(e){this.listeners.delete(e)}clear(){for(const e of this.terms.values())e.dispose?.();this.terms.clear(),this.commands.clear(),this.commandGroups.clear(),this.values.clear(),this.context=null,this.registerSystemReset(),this.emit({type:"clear",commandId:""})}hasCommands(){return this.commands.size>1}dispose(){for(const e of this.terms.values())e.dispose?.();this.terms.clear(),this.commands.clear(),this.commandGroups.clear(),this.values.clear(),this.listeners.clear(),this.resetCallback=null,this.context=null}registerSystemReset(){const e=Sw("_system","reset");this.commands.set(e,{id:e,groupName:"_system",config:{type:"button",name:"reset",label:"Reset Simulation"}}),this.commandGroups.set("_system",[e])}registerUi(e,t){const r=t.getUiConfig?.(),i=Array.isArray(r?.inputs)?r.inputs:[];if(i.length!==0){this.commandGroups.set(e,[]);for(const s of i){const a=Sw(e,s.name);if(this.commands.set(a,{id:a,groupName:e,config:s}),this.commandGroups.get(e).push(a),s.type==="slider"||s.type==="checkbox"){const o=t.getCommand(),l=i.filter(d=>d.type==="slider"||d.type==="checkbox").findIndex(d=>d.name===s.name),c=s.type==="checkbox"?s.default?1:0:s.default;this.values.set(a,o[l]??c)}}this.emit({type:"group_registered",commandId:e,groupName:e})}}syncValuesFromTerms(){for(const[e,t]of this.commands){if(t.config.type!=="slider"&&t.config.type!=="checkbox")continue;const r=this.terms.get(t.groupName);if(!r)continue;const a=(r.getUiConfig?.()?.inputs??[]).filter(o=>o.type==="slider"||o.type==="checkbox").findIndex(o=>o.name===t.config.name);if(a>=0){const o=r.getCommand();this.values.set(e,o[a]??this.values.get(e)??0)}}}emit(e){for(const t of this.listeners)try{t(e)}catch{}}}let Jv=null;function Lr(){return Jv||(Jv=new hee),Jv}function fee(n){const e=n[0]??1,t=n[1]??0,r=n[2]??0,i=n[3]??0,s=Math.hypot(e,t,r,i);if(s<1e-9)return[1,0,0,0];const a=1/s;return[e*a,t*a,r*a,i*a]}function pee(n,e){const t=n[0]??1,r=n[1]??0,i=n[2]??0,s=n[3]??0,a=e[0]??1,o=e[1]??0,l=e[2]??0,c=e[3]??0;return[t*a-r*o-i*l-s*c,t*o+r*a+i*c-s*l,t*l-r*c+i*a+s*o,t*c+r*l-i*o+s*a]}function Aee(n){const e=n[0]??1,t=n[1]??0,r=n[2]??0,i=n[3]??0,s=e*e+t*t+r*r+i*i;if(s<1e-9)return[1,0,0,0];const a=1/s;return[e*a,-t*a,-r*a,-i*a]}function mee(n,e){const t=n[0]??1,r=n[1]??0,i=n[2]??0,s=n[3]??0,a=e[0]??0,o=e[1]??0,l=e[2]??0,c=2*(i*l-s*o),d=2*(s*a-r*l),h=2*(r*o-i*a),p=i*h-s*d,A=s*c-r*h,y=r*d-i*c;return[a-t*c+p,o-t*d+A,l-t*h+y]}function gee(n){const[e,t,r,i]=fee(n),s=t*t,a=r*r,o=i*i,l=t*r,c=t*i,d=r*i,h=e*t,p=e*r,A=e*i,y=1-2*(a+o),m=2*(l-A),x=2*(l+A),g=1-2*(s+o),_=2*(c-p),b=2*(d+h);return[y,m,x,g,_,b]}function mo(n,e=0){return typeof n=="number"?n:n instanceof Float32Array?n[e]??0:typeof n=="boolean"&&n?1:0}function ga(n){return n instanceof Float32Array?n:typeof n=="number"?new Float32Array([n]):new Float32Array(0)}function Uf(n,e){const t=n.getContext()?.mjModel??null;if(!t)return-1;for(let r=0;r<t.nbody;r++){const i=t.body(r).name;if(i===e||i.endsWith(`/${e}`))return r}return-1}function wd(){const n=Lr().getTerm("motion");return cee(n)&&n.isReady()?n:null}function VI(n,e,t){const r=new Uint8Array(n.names),i=new TextDecoder,s=[];for(let a=0;a<e;a++){let o=t[a],l=o;for(;l<r.length&&r[l]!==0;)l++;s.push(i.decode(r.subarray(o,l)))}return s}function fP(n){return VI(n,n.njnt,n.name_jntadr)}function hB(n,e){const t=n.getContext()?.mjModel??null;if(!t)return e.map(()=>-1);const r=fP(t);return e.map(i=>{const s=r.indexOf(i);return s<0?-1:t.jnt_qposadr[s]})}function yee(n,e){const t=n.getContext()?.mjModel??null;if(!t)return e.map(()=>-1);const r=fP(t);return e.map(i=>{const s=r.indexOf(i);return s<0?-1:t.jnt_dofadr[s]})}function xee(n,e){const t=n.getContext()?.mjModel??null;return t?VI(t,t.nsite,t.name_siteadr).indexOf(e):-1}function vee(n,e){const t=n.getContext()?.mjModel??null;if(!t)return{adr:0,dim:0};const i=VI(t,t.nsensor,t.name_sensoradr).indexOf(e);return i<0?{adr:0,dim:0}:{adr:t.sensor_adr[i],dim:t.sensor_dim[i]}}function Kv(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")?n:null}const _ee={Const:(n,e)=>Number(e.value??0),StepCount:(n,e,t,r)=>{const i=(r.count??0)+1;return r.count=i,i},Param:(n,e,t)=>{const r=t.params[String(e.name)];return typeof r=="number"?r:Array.isArray(r)?Float32Array.from(r):0},RootAngVelB:(n,e,t)=>t.state.rootAngVel?new Float32Array(t.state.rootAngVel):new Float32Array(3),RootLinkLinVelB:(n,e,t)=>t.state.rootLinVel?new Float32Array(t.state.rootLinVel):new Float32Array(3),RootLinkPosW:(n,e,t)=>t.state.rootPos?new Float32Array(t.state.rootPos):new Float32Array(3),RootLinkQuatW:(n,e,t)=>t.state.rootQuat?new Float32Array(t.state.rootQuat):new Float32Array([1,0,0,0]),ProjectedGravityB:(n,e,t)=>{const r=t.state.rootQuat??new Float32Array([1,0,0,0]),i=r[0],s=r[1],a=r[2],o=r[3],l=0,c=0,d=-1,h=2*(a*d-o*c),p=2*(o*l-s*d),A=2*(s*c-a*l),y=a*A-o*p,m=o*h-s*A,x=s*p-a*h;return new Float32Array([l-i*h+y,c-i*p+m,d-i*A+x])},Add:n=>Zv(n[0],n[1],(e,t)=>e+t),Sub:n=>Zv(n[0],n[1],(e,t)=>e-t),Mul:n=>Zv(n[0],n[1],(e,t)=>e*t),Neg:n=>Ed(n[0],e=>-e),Abs:n=>Ed(n[0],Math.abs),Acos:n=>Ed(n[0],e=>Math.acos(Math.max(-1,Math.min(1,e)))),Index:(n,e)=>{const t=ga(n[0]),r=Number(e.i??0);return t[r]??0},Gt:n=>jm(n[0],n[1],(e,t)=>e>t),Lt:n=>jm(n[0],n[1],(e,t)=>e<t),Ge:n=>jm(n[0],n[1],(e,t)=>e>=t),Le:n=>jm(n[0],n[1],(e,t)=>e<=t),Any:n=>pB(n[0],(e,t)=>e||t,!1),All:n=>pB(n[0],(e,t)=>e&&t,!0),Or:n=>fB(n[0],n[1],(e,t)=>e||t),And:n=>fB(n[0],n[1],(e,t)=>e&&t),Not:n=>{const e=n[0];if(typeof e=="boolean")return!e;if(typeof e=="number")return e===0;if(e instanceof Uint8Array){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r]?0:1;return t}return!1},ConstVec:(n,e)=>{const t=Array.isArray(e.values)?e.values:[];return Float32Array.from(t)},SpawnCapture:(n,e,t,r)=>(r.captured===void 0&&(r.captured=ga(n[0]).slice()),r.captured),QuatApplyInv:n=>Float32Array.from(mee(ga(n[0]),ga(n[1]))),TrackingAnchorPos:()=>{const n=wd()?.getAnchorPos()??null;return n?new Float32Array(n):new Float32Array(3)},TrackingAnchorQuat:()=>{const n=wd()?.getAnchorQuat()??null;return n?new Float32Array(n):new Float32Array([1,0,0,0])},TrackingCurrentAnchorPos:(n,e,t)=>{const i=wd()?.getAnchorBodyName()??null,s=t.runner.getContext()?.mjData??null;if(!i||!s)return new Float32Array(3);const a=Uf(t.runner,i);return a<0?new Float32Array(3):new Float32Array([s.xpos[a*3],s.xpos[a*3+1],s.xpos[a*3+2]])},TrackingCurrentAnchorQuat:(n,e,t)=>{const i=wd()?.getAnchorBodyName()??null,s=t.runner.getContext()?.mjData??null;if(!i||!s)return new Float32Array([1,0,0,0]);const a=Uf(t.runner,i);return a<0?new Float32Array([1,0,0,0]):new Float32Array(s.xquat.slice(a*4,a*4+4))},TrackingBodyPosZDeviationMax:(n,e,t)=>{const r=wd(),i=t.runner.getContext()?.mjData??null;if(!r||!i)return 0;const s=r.getBodyPosW();if(!s)return 0;const a=r.getBodyNames(),o=Array.isArray(e.body_names)&&e.body_names.length>0?e.body_names:a;let l=0;for(const c of o){const d=a.indexOf(c),h=Uf(t.runner,c);if(d<0||h<0)continue;const p=s[d*3+2]??0,A=i.xpos[h*3+2]??0,y=Math.abs(p-A);y>l&&(l=y)}return l},Clip:(n,e)=>{const t=Number(e.min??-1/0),r=Number(e.max??1/0);return Ed(n[0],i=>Math.min(r,Math.max(t,i)))},History:(n,e,t,r)=>{const i=Math.max(1,Math.floor(Number(e.steps??1))),s=ga(n[0]);let a=r.buffer;if(a===void 0||a.length!==i||a[0].length!==s.length)a=Array.from({length:i},()=>s.slice()),r.buffer=a;else{for(let c=a.length-1;c>0;c--)a[c].set(a[c-1]);a[0].set(s)}if(i===1)return new Float32Array(a[0]);const o=s.length,l=new Float32Array(o*i);if(e.interleaved)for(let c=0;c<o;c++)for(let d=0;d<i;d++)l[c*i+d]=a[d][c];else for(let c=0;c<i;c++)l.set(a[c],c*o);return l},Concat:n=>{let e=0;const t=n.map(s=>ga(s));for(const s of t)e+=s.length;const r=new Float32Array(e);let i=0;for(const s of t)r.set(s,i),i+=s.length;return r},Cos:n=>Ed(n[0],Math.cos),Sin:n=>Ed(n[0],Math.sin),QuatMul:n=>Float32Array.from(pee(ga(n[0]),ga(n[1]))),QuatInv:n=>Float32Array.from(Aee(ga(n[0]))),QuatToRot6d:n=>Float32Array.from(gee(ga(n[0]))),JointPos:(n,e,t)=>{const r=Kv(e.joint_names);if(r===null){const o=t.state.jointPos;return o?new Float32Array(o):new Float32Array(t.runner.getNumActions())}const i=hB(t.runner,r),s=t.runner.getContext()?.mjData?.qpos,a=new Float32Array(i.length);for(let o=0;o<i.length;o++)a[o]=i[o]>=0&&s!==void 0?s[i[o]]:0;return a},DefaultJointPos:(n,e,t)=>{const r=Kv(e.joint_names);if(r===null)return new Float32Array(t.runner.getDefaultJointPos());const i=hB(t.runner,r),s=t.runner.getContext()?.mjModel?.qpos0,a=new Float32Array(i.length);for(let o=0;o<i.length;o++)a[o]=i[o]>=0&&s!==void 0?s[i[o]]:0;return a},JointVel:(n,e,t)=>{const r=Kv(e.joint_names);if(r===null){const o=t.state.jointVel;return o?new Float32Array(o):new Float32Array(t.runner.getNumActions())}const i=yee(t.runner,r),s=t.runner.getContext()?.mjData?.qvel,a=new Float32Array(i.length);for(let o=0;o<i.length;o++)a[o]=i[o]>=0&&s!==void 0?s[i[o]]:0;return a},PrevAction:(n,e,t)=>new Float32Array(t.runner.getLastActions()),CommandValue:(n,e)=>{const t=String(e.command??""),r=t?Lr().getCommand(t):null;return r?new Float32Array(r):new Float32Array(0)},Sensor:(n,e,t)=>{const{adr:r,dim:i}=vee(t.runner,String(e.sensor??"")),s=t.runner.getContext()?.mjData?.sensordata,a=new Float32Array(i);if(s!==void 0)for(let o=0;o<i;o++)a[o]=s[r+o]??0;return a},SitePos:(n,e,t)=>{const r=xee(t.runner,String(e.site??"")),i=t.runner.getContext()?.mjData?.site_xpos;return r<0||i===void 0?new Float32Array(3):new Float32Array([i[r*3],i[r*3+1],i[r*3+2]])},BodyPos:(n,e,t)=>{const r=Uf(t.runner,String(e.body??"")),i=t.runner.getContext()?.mjData?.xpos;return r<0||i===void 0?new Float32Array(3):new Float32Array([i[r*3],i[r*3+1],i[r*3+2]])},BodyQuat:(n,e,t)=>{const r=Uf(t.runner,String(e.body??"")),i=t.runner.getContext()?.mjData?.xquat;return r<0||i===void 0?new Float32Array([1,0,0,0]):new Float32Array(i.slice(r*4,r*4+4))},TrackingRefBodyPos:(n,e)=>{const t=wd();if(!t)return new Float32Array(3);const r=t.getBodyPosW();if(!r)return new Float32Array(3);const i=t.getBodyNames().indexOf(String(e.body??""));return i<0?new Float32Array(3):new Float32Array([r[i*3],r[i*3+1],r[i*3+2]])}};function fB(n,e,t){const r=(d,h)=>typeof d=="boolean"?d:typeof d=="number"?d!==0:d instanceof Uint8Array||d instanceof Float32Array?(d[h]??0)!==0:!1,i=n instanceof Uint8Array||n instanceof Float32Array,s=e instanceof Uint8Array||e instanceof Float32Array;if(!i&&!s)return t(r(n,0),r(e,0));const a=i?n.length:1,o=s?e.length:1,l=Math.max(a,o),c=new Uint8Array(l);for(let d=0;d<l;d++)c[d]=t(r(n,d),r(e,d))?1:0;return c}function Ed(n,e){if(typeof n=="number")return e(n);if(n instanceof Float32Array){const t=new Float32Array(n.length);for(let r=0;r<n.length;r++)t[r]=e(n[r]);return t}return e(mo(n))}function Zv(n,e,t){const r=n instanceof Float32Array,i=e instanceof Float32Array;if(!r&&!i)return t(mo(n),mo(e));const s=Math.max(r?n.length:1,i?e.length:1),a=new Float32Array(s);for(let o=0;o<s;o++){const l=r?n[o]??0:mo(n),c=i?e[o]??0:mo(e);a[o]=t(l,c)}return a}function jm(n,e,t){const r=n instanceof Float32Array,i=e instanceof Float32Array;if(!r&&!i)return t(mo(n),mo(e));const s=Math.max(r?n.length:1,i?e.length:1),a=new Uint8Array(s);for(let o=0;o<s;o++){const l=r?n[o]??0:mo(n),c=i?e[o]??0:mo(e);a[o]=t(l,c)?1:0}return a}function pB(n,e,t){if(typeof n=="boolean")return n;if(typeof n=="number")return n!==0;let r=t;if(n instanceof Uint8Array){for(let i=0;i<n.length;i++)r=e(r,n[i]!==0);return r}if(n instanceof Float32Array){for(let i=0;i<n.length;i++)r=e(r,n[i]!==0);return r}return r}class pP{constructor(){this.states=new Map}get(e){let t=this.states.get(e);return t===void 0&&(t={},this.states.set(e,t)),t}reset(){this.states.clear()}}function AP(n,e,t){const r={};for(const s of n.nodes){const a=_ee[s.op];if(a===void 0)throw new Error(`DSL interpreter: unknown primitive op "${s.op}". Add it to the engine's primitive registry, or fix the build's serializer.`);const o=(s.in??[]).map(l=>{if(!(l in r))throw new Error(`DSL interpreter: node "${s.out}" references unresolved input "${l}". Graph nodes must appear in topological order.`);return r[l]});r[s.out]=a(o,s.attrs??{},e,t.get(s.out))}const i=r[n.output];if(i===void 0)throw new Error(`DSL interpreter: graph output "${n.output}" was not produced by any node.`);return i}class bee extends qZ{constructor(e,t){super(t),this.store=new pP,this.runner=e,this.graph=t.graph,this.params=t.params??{}}evaluate(e){const t=AP(this.graph,{runner:this.runner,state:e,params:this.params},this.store);return typeof t=="boolean"?t:typeof t=="number"?t!==0:!1}reset(){this.store.reset()}}function wee(n){return"kind"in n&&n.kind==="termination"}class Eee{constructor(e,t,r){this.terms=[];for(const[i,s]of Object.entries(e)){if(wee(s)){const l={name:i,params:s.params,time_out:s.time_out,graph:{kind:"termination",nodes:s.nodes,output:s.output}};this.terms.push({name:i,term:new bee(r,l),isTimeOut:s.time_out??!1});continue}const a=t[s.name];if(!a)continue;const o={name:s.name,params:s.params,time_out:s.time_out};this.terms.push({name:i,term:new a(o),isTimeOut:s.time_out??!1})}}evaluate(e){let t=!1,r=!1;const i=[];for(const{name:s,term:a,isTimeOut:o}of this.terms)a.evaluate(e)&&(i.push(s),o?r=!0:t=!0);return{done:t||r,terminated:t,truncated:r,reasons:i}}reset(){for(const{term:e}of this.terms)e.reset?.()}get size(){return this.terms.length}}const Iee={},Cee={...Iee};var HI=Object.defineProperty,See=Object.getOwnPropertyDescriptor,Bee=Object.getOwnPropertyNames,Mee=Object.prototype.hasOwnProperty,Tee=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')}),et=(n,e)=>()=>(n&&(e=n(n=0)),e),_h=(n,e)=>{for(var t in e)HI(n,t,{get:e[t],enumerable:!0})},Ree=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Bee(e))!Mee.call(n,i)&&i!==t&&HI(n,i,{get:()=>e[i],enumerable:!(r=See(e,i))||r.enumerable});return n},Lp=n=>Ree(HI({},"__esModule",{value:!0}),n),Of,El,Td,AB,mP,gP=et(()=>{Of=new Map,El=[],Td=(n,e,t)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let r=Of.get(n);if(r===void 0)Of.set(n,{backend:e,priority:t});else{if(r.priority>t)return;if(r.priority===t&&r.backend!==e)throw new Error(`cannot register backend "${n}" using priority ${t}`)}if(t>=0){let i=El.indexOf(n);i!==-1&&El.splice(i,1);for(let s=0;s<El.length;s++)if(Of.get(El[s]).priority<=t){El.splice(s,0,n);return}El.push(n)}return}throw new TypeError("not a valid backend")},AB=async n=>{let e=Of.get(n);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let t=!!e.initPromise;try{return t||(e.initPromise=e.backend.init(n)),await e.initPromise,e.initialized=!0,e.backend}catch(r){return t||(e.error=`${r}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},mP=async n=>{let e=n.executionProviders||[],t=e.map(l=>typeof l=="string"?l:l.name),r=t.length===0?El:t,i,s=[],a=new Set;for(let l of r){let c=await AB(l);typeof c=="string"?s.push({name:l,err:c}):(i||(i=c),i===c&&a.add(l))}if(!i)throw new Error(`no available backend found. ERR: ${s.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(let{name:l,err:c}of s)t.includes(l);let o=e.filter(l=>a.has(typeof l=="string"?l:l.name));return[i,new Proxy(n,{get:(l,c)=>c==="executionProviders"?o:Reflect.get(l,c)})]}}),Dee=et(()=>{gP()}),yP,kee=et(()=>{yP="1.24.3"}),e_,Br,xP=et(()=>{kee(),e_="warning",Br={wasm:{},webgl:{},webgpu:{},versions:{common:yP},set logLevel(n){if(n!==void 0){if(typeof n!="string"||["verbose","info","warning","error","fatal"].indexOf(n)===-1)throw new Error(`Unsupported logging level: ${n}`);e_=n}},get logLevel(){return e_}},Object.defineProperty(Br,"logLevel",{enumerable:!0})}),Bn,Nee=et(()=>{xP(),Bn=Br}),vP,_P,Qee=et(()=>{vP=(n,e)=>{let t=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);t.width=n.dims[3],t.height=n.dims[2];let r=t.getContext("2d");if(r!=null){let i,s;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(i=n.dims[2],s=n.dims[3]):(i=n.dims[3],s=n.dims[2]);let a=e?.format!==void 0?e.format:"RGB",o=e?.norm,l,c;o===void 0||o.mean===void 0?l=[255,255,255,255]:typeof o.mean=="number"?l=[o.mean,o.mean,o.mean,o.mean]:(l=[o.mean[0],o.mean[1],o.mean[2],0],o.mean[3]!==void 0&&(l[3]=o.mean[3])),o===void 0||o.bias===void 0?c=[0,0,0,0]:typeof o.bias=="number"?c=[o.bias,o.bias,o.bias,o.bias]:(c=[o.bias[0],o.bias[1],o.bias[2],0],o.bias[3]!==void 0&&(c[3]=o.bias[3]));let d=s*i,h=0,p=d,A=d*2,y=-1;a==="RGBA"?(h=0,p=d,A=d*2,y=d*3):a==="RGB"?(h=0,p=d,A=d*2):a==="RBG"&&(h=0,A=d,p=d*2);for(let m=0;m<s;m++)for(let x=0;x<i;x++){let g=(n.data[h++]-c[0])*l[0],_=(n.data[p++]-c[1])*l[1],b=(n.data[A++]-c[2])*l[2],w=y===-1?255:(n.data[y++]-c[3])*l[3];r.fillStyle="rgba("+g+","+_+","+b+","+w+")",r.fillRect(x,m,1,1)}if("toDataURL"in t)return t.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},_P=(n,e)=>{let t=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),r;if(t!=null){let i,s,a;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(i=n.dims[2],s=n.dims[1],a=n.dims[3]):(i=n.dims[3],s=n.dims[2],a=n.dims[1]);let o=e!==void 0&&e.format!==void 0?e.format:"RGB",l=e?.norm,c,d;l===void 0||l.mean===void 0?c=[255,255,255,255]:typeof l.mean=="number"?c=[l.mean,l.mean,l.mean,l.mean]:(c=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(c[3]=l.mean[3])),l===void 0||l.bias===void 0?d=[0,0,0,0]:typeof l.bias=="number"?d=[l.bias,l.bias,l.bias,l.bias]:(d=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(d[3]=l.bias[3]));let h=s*i;if(e!==void 0&&(e.format!==void 0&&a===4&&e.format!=="RGBA"||a===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let p=4,A=0,y=1,m=2,x=3,g=0,_=h,b=h*2,w=-1;o==="RGBA"?(g=0,_=h,b=h*2,w=h*3):o==="RGB"?(g=0,_=h,b=h*2):o==="RBG"&&(g=0,b=h,_=h*2),r=t.createImageData(i,s);for(let I=0;I<s*i;A+=p,y+=p,m+=p,x+=p,I++)r.data[A]=(n.data[g++]-d[0])*c[0],r.data[y]=(n.data[_++]-d[1])*c[1],r.data[m]=(n.data[b++]-d[2])*c[2],r.data[x]=w===-1?255:(n.data[w++]-d[3])*c[3]}else throw new Error("Can not access image data");return r}}),Wm,bP,wP,EP,IP,CP,Pee=et(()=>{jI(),Wm=(n,e)=>{if(n===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:t,width:r}=e,i=e.norm??{mean:255,bias:0},s,a;typeof i.mean=="number"?s=[i.mean,i.mean,i.mean,i.mean]:s=[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],typeof i.bias=="number"?a=[i.bias,i.bias,i.bias,i.bias]:a=[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let o=e.format!==void 0?e.format:"RGBA",l=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",c=t*r,d=l==="RGBA"?new Float32Array(c*4):new Float32Array(c*3),h=4,p=0,A=1,y=2,m=3,x=0,g=c,_=c*2,b=-1;o==="RGB"&&(h=3,p=0,A=1,y=2,m=-1),l==="RGBA"?b=c*3:l==="RBG"?(x=0,_=c,g=c*2):l==="BGR"&&(_=0,g=c,x=c*2);for(let w=0;w<c;w++,p+=h,y+=h,A+=h,m+=h)d[x++]=(n[p]+a[0])/s[0],d[g++]=(n[A]+a[1])/s[1],d[_++]=(n[y]+a[2])/s[2],b!==-1&&m!==-1&&(d[b++]=(n[m]+a[3])/s[3]);return l==="RGBA"?new Gi("float32",d,[1,4,t,r]):new Gi("float32",d,[1,3,t,r])},bP=async(n,e)=>{let t=typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement,r=typeof ImageData<"u"&&n instanceof ImageData,i=typeof ImageBitmap<"u"&&n instanceof ImageBitmap,s=typeof n=="string",a,o=e??{},l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},c=d=>typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement||d instanceof OffscreenCanvas?d.getContext("2d"):null;if(t){let d=l();d.width=n.width,d.height=n.height;let h=c(d);if(h!=null){let p=n.height,A=n.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(p=e.resizedHeight,A=e.resizedWidth),e!==void 0){if(o=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");o.tensorFormat="RGBA",o.height=p,o.width=A}else o.tensorFormat="RGBA",o.height=p,o.width=A;h.drawImage(n,0,0),a=h.getImageData(0,0,A,p).data}else throw new Error("Can not access image data")}else if(r){let d,h;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(d=e.resizedHeight,h=e.resizedWidth):(d=n.height,h=n.width),e!==void 0&&(o=e),o.format="RGBA",o.height=d,o.width=h,e!==void 0){let p=l();p.width=h,p.height=d;let A=c(p);if(A!=null)A.putImageData(n,0,0),a=A.getImageData(0,0,h,d).data;else throw new Error("Can not access image data")}else a=n.data}else if(i){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let d=l();d.width=n.width,d.height=n.height;let h=c(d);if(h!=null){let p=n.height,A=n.width;return h.drawImage(n,0,0,A,p),a=h.getImageData(0,0,A,p).data,o.height=p,o.width=A,Wm(a,o)}else throw new Error("Can not access image data")}else{if(s)return new Promise((d,h)=>{let p=l(),A=c(p);if(!n||!A)return h();let y=new Image;y.crossOrigin="Anonymous",y.src=n,y.onload=()=>{p.width=y.width,p.height=y.height,A.drawImage(y,0,0,p.width,p.height);let m=A.getImageData(0,0,p.width,p.height);o.height=p.height,o.width=p.width,d(Wm(m.data,o))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Wm(a,o);throw new Error("Input data provided is not supported - aborted tensor creation")},wP=(n,e)=>{let{width:t,height:r,download:i,dispose:s}=e,a=[1,r,t,4];return new Gi({location:"texture",type:"float32",texture:n,dims:a,download:i,dispose:s})},EP=(n,e)=>{let{dataType:t,dims:r,download:i,dispose:s}=e;return new Gi({location:"gpu-buffer",type:t??"float32",gpuBuffer:n,dims:r,download:i,dispose:s})},IP=(n,e)=>{let{dataType:t,dims:r,download:i,dispose:s}=e;return new Gi({location:"ml-tensor",type:t??"float32",mlTensor:n,dims:r,download:i,dispose:s})},CP=(n,e,t)=>new Gi({location:"cpu-pinned",type:n,data:e,dims:t??[e.length]})}),Qc,op,t_,SP,Lee=et(()=>{Qc=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),op=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),t_=!1,SP=()=>{if(!t_){t_=!0;let n=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,t=globalThis.Float16Array,r=typeof t<"u"&&t.from;n&&(Qc.set("int64",BigInt64Array),op.set(BigInt64Array,"int64")),e&&(Qc.set("uint64",BigUint64Array),op.set(BigUint64Array,"uint64")),r?(Qc.set("float16",t),op.set(t,"float16")):Qc.set("float16",Uint16Array)}}}),BP,MP,Fee=et(()=>{jI(),BP=n=>{let e=1;for(let t=0;t<n.length;t++){let r=n[t];if(typeof r!="number"||!Number.isSafeInteger(r))throw new TypeError(`dims[${t}] must be an integer, got: ${r}`);if(r<0)throw new RangeError(`dims[${t}] must be a non-negative integer, got: ${r}`);e*=r}return e},MP=(n,e)=>{switch(n.location){case"cpu":return new Gi(n.type,n.data,e);case"cpu-pinned":return new Gi({location:"cpu-pinned",data:n.data,type:n.type,dims:e});case"texture":return new Gi({location:"texture",texture:n.texture,type:n.type,dims:e});case"gpu-buffer":return new Gi({location:"gpu-buffer",gpuBuffer:n.gpuBuffer,type:n.type,dims:e});case"ml-tensor":return new Gi({location:"ml-tensor",mlTensor:n.mlTensor,type:n.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${n.location} is not supported`)}}}),Gi,jI=et(()=>{Qee(),Pee(),Lee(),Fee(),Gi=class{constructor(n,e,t){SP();let r,i;if(typeof n=="object"&&"location"in n)switch(this.dataLocation=n.location,r=n.type,i=n.dims,n.location){case"cpu-pinned":{let a=Qc.get(r);if(!a)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(n.data instanceof a))throw new TypeError(`buffer should be of type ${a.name}`);this.cpuData=n.data;break}case"texture":{if(r!=="float32")throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=n.texture,this.downloader=n.download,this.disposer=n.dispose;break}case"gpu-buffer":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint8"&&r!=="bool"&&r!=="uint4"&&r!=="int4")throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=n.gpuBuffer,this.downloader=n.download,this.disposer=n.dispose;break}case"ml-tensor":{if(r!=="float32"&&r!=="float16"&&r!=="int32"&&r!=="int64"&&r!=="uint32"&&r!=="uint64"&&r!=="int8"&&r!=="uint8"&&r!=="bool"&&r!=="uint4"&&r!=="int4")throw new TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=n.mlTensor,this.downloader=n.download,this.disposer=n.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof n=="string")if(r=n,o=t,n==="string"){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");a=e}else{let l=Qc.get(n);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${n}.`);if(Array.isArray(e)){if(n==="float16"&&l===Uint16Array||n==="uint4"||n==="int4")throw new TypeError(`Creating a ${n} tensor from number array is not supported. Please use ${l.name} as data.`);n==="uint64"||n==="int64"?a=l.from(e,BigInt):a=l.from(e)}else if(e instanceof l)a=e;else if(e instanceof Uint8ClampedArray)if(n==="uint8")a=Uint8Array.from(e);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(n==="float16"&&e instanceof Uint16Array&&l!==Uint16Array)a=new globalThis.Float16Array(e.buffer,e.byteOffset,e.length);else throw new TypeError(`A ${r} tensor's data must be type of ${l}`)}else if(o=e,Array.isArray(n)){if(n.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof n[0];if(l==="string")r="string",a=n;else if(l==="boolean")r="bool",a=Uint8Array.from(n);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(n instanceof Uint8ClampedArray)r="uint8",a=Uint8Array.from(n);else{let l=op.get(n.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${n.constructor}.`);r=l,a=n}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");i=o,this.cpuData=a,this.dataLocation="cpu"}let s=BP(i);if(this.cpuData&&s!==this.cpuData.length&&!((r==="uint4"||r==="int4")&&Math.ceil(s/2)===this.cpuData.length))throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=s}static async fromImage(n,e){return bP(n,e)}static fromTexture(n,e){return wP(n,e)}static fromGpuBuffer(n,e){return EP(n,e)}static fromMLTensor(n,e){return IP(n,e)}static fromPinnedBuffer(n,e,t){return CP(n,e,t)}toDataURL(n){return vP(this,n)}toImageData(n){return _P(this,n)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(n){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,n&&this.disposer&&(this.disposer(),this.disposer=void 0),e}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(n){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return MP(this,n)}}}),ei,TP=et(()=>{jI(),ei=Gi}),Xg,n_,Pa,Js,Wc,qc,RP=et(()=>{xP(),Xg=(n,e)=>{typeof Br.trace>"u"?Br.wasm.trace:Br.trace},n_=(n,e)=>{let t=new Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<t.length;i++){if(r&&!t[i].includes("TRACE_FUNC")){let s=`FUNC_${n}::${t[i].trim().split(" ")[1]}`;e&&(s+=`::${e}`),Xg("CPU",s);return}t[i].includes("TRACE_FUNC")&&(r=!0)}},Pa=n=>{(typeof Br.trace>"u"?!Br.wasm.trace:!Br.trace)||n_("BEGIN",n)},Js=n=>{(typeof Br.trace>"u"?!Br.wasm.trace:!Br.trace)||n_("END",n)},Wc=n=>{typeof Br.trace>"u"?Br.wasm.trace:Br.trace},qc=n=>{typeof Br.trace>"u"?Br.wasm.trace:Br.trace}}),DP,zee=et(()=>{gP(),TP(),RP(),DP=class kP{constructor(e){this.handler=e}async run(e,t,r){Pa(),Wc("InferenceSession.run");let i={},s={};if(typeof e!="object"||e===null||e instanceof ei||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof t=="object"){if(t===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof ei)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(t.length===0)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let c of t){if(typeof c!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(c)===-1)throw new RangeError(`'fetches' contains invalid output name: ${c}.`);i[c]=null}if(typeof r=="object"&&r!==null)s=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else{let c=!1,d=Object.getOwnPropertyNames(t);for(let h of this.outputNames)if(d.indexOf(h)!==-1){let p=t[h];(p===null||p instanceof ei)&&(c=!0,a=!1,i[h]=p)}if(c){if(typeof r=="object"&&r!==null)s=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else s=t}}else if(typeof t<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let c of this.inputNames)if(typeof e[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(a)for(let c of this.outputNames)i[c]=null;let o=await this.handler.run(e,i,s),l={};for(let c in o)if(Object.hasOwnProperty.call(o,c)){let d=o[c];d instanceof ei?l[c]=d:l[c]=new ei(d.type,d.data,d.dims)}return qc("InferenceSession.run"),Js(),l}async release(){return this.handler.dispose()}static async create(e,t,r,i){Pa(),Wc("InferenceSession.create");let s,a={};if(typeof e=="string"){if(s=e,typeof t=="object"&&t!==null)a=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(s=e,typeof t=="object"&&t!==null)a=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let d=e,h=0,p=e.byteLength;if(typeof t=="object"&&t!==null)a=t;else if(typeof t=="number"){if(h=t,!Number.isSafeInteger(h))throw new RangeError("'byteOffset' must be an integer.");if(h<0||h>=d.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${d.byteLength}).`);if(p=e.byteLength-h,typeof r=="number"){if(p=r,!Number.isSafeInteger(p))throw new RangeError("'byteLength' must be an integer.");if(p<=0||h+p>d.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${d.byteLength-h}].`);if(typeof i=="object"&&i!==null)a=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(typeof r<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof t<"u")throw new TypeError("'options' must be an object.");s=new Uint8Array(d,h,p)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[o,l]=await mP(a),c=await o.createInferenceSessionHandler(s,l);return qc("InferenceSession.create"),Js(),new kP(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),WI,Uee=et(()=>{zee(),WI=DP}),Oee=et(()=>{}),$ee=et(()=>{}),Gee=et(()=>{}),Vee=et(()=>{}),Hee={};_h(Hee,{InferenceSession:()=>WI,TRACE:()=>Xg,TRACE_EVENT_BEGIN:()=>Wc,TRACE_EVENT_END:()=>qc,TRACE_FUNC_BEGIN:()=>Pa,TRACE_FUNC_END:()=>Js,Tensor:()=>ei,env:()=>Bn,registerBackend:()=>Td});var gs=et(()=>{Dee(),Nee(),Uee(),TP(),Oee(),$ee(),RP(),Gee(),Vee()}),qI=et(()=>{}),NP={};_h(NP,{default:()=>QP});var r_,i_,QP,jee=et(()=>{U4(),cu(),YI(),r_="ort-wasm-proxy-worker",i_=globalThis.self?.name===r_,i_&&(self.onmessage=n=>{let{type:e,in:t}=n.data;try{switch(e){case"init-wasm":XI(t.wasm).then(()=>{fC(t).then(()=>{postMessage({type:e})},r=>{postMessage({type:e,err:r})})},r=>{postMessage({type:e,err:r})});break;case"init-ep":{let{epName:r,env:i}=t;pC(i,r).then(()=>{postMessage({type:e})},s=>{postMessage({type:e,err:s})});break}case"copy-from":{let{buffer:r}=t,i=r0(r);postMessage({type:e,out:i});break}case"create":{let{model:r,options:i}=t;AC(r,i).then(s=>{postMessage({type:e,out:s})},s=>{postMessage({type:e,err:s})});break}case"release":mC(t),postMessage({type:e});break;case"run":{let{sessionId:r,inputIndices:i,inputs:s,outputIndices:a,options:o}=t;gC(r,i,s,a,new Array(a.length).fill(null),o).then(l=>{l.some(c=>c[3]!=="cpu")?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:l},xC([...s,...l]))},l=>{postMessage({type:e,err:l})});break}case"end-profiling":yC(t),postMessage({type:e});break;default:}}catch(r){postMessage({type:e,err:r})}}),QP=i_?null:n=>new Worker(n??$i,{type:"module",name:r_})}),PP={};_h(PP,{default:()=>LP});async function mB(n={}){var e=n,t=!!globalThis.window,r=!!globalThis.WorkerGlobalScope,i=r&&self.name?.startsWith("em-pthread");e.mountExternalData=(C,N)=>{C.startsWith("./")&&(C=C.substring(2)),(e.Zc||(e.Zc=new Map)).set(C,N)},e.unmountExternalData=()=>{delete e.Zc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,ae:!0}).buffer.constructor;let s=C=>async(...N)=>{try{if(e.$c)throw Error("Session already started");let O=e.$c={Nd:N[0],errors:[]},z=await C(...N);if(e.$c!==O)throw Error("Session mismatch");e.gd?.flush();let se=O.errors;if(0<se.length){let ue=await Promise.all(se);if(ue=ue.filter(Se=>Se),0<ue.length)throw Error(ue.join(`
|
|
12822
|
+
`))}return z}finally{e.$c=null}};e.jsepInit=(C,N)=>{if(C==="webgpu"){[e.gd,e.Dd,e.Hd,e.jd,e.Gd,e.ac,e.Id,e.Kd,e.Ed,e.Fd,e.Jd]=N;let O=e.gd;e.jsepRegisterBuffer=(z,se,ue,Se)=>O.registerBuffer(z,se,ue,Se),e.jsepGetBuffer=z=>O.getBuffer(z),e.jsepCreateDownloader=(z,se,ue)=>O.createDownloader(z,se,ue),e.jsepOnCreateSession=z=>{O.onCreateSession(z)},e.jsepOnReleaseSession=z=>{O.onReleaseSession(z)},e.jsepOnRunStart=z=>O.onRunStart(z),e.Ld=(z,se)=>{O.upload(z,se)}}else if(C==="webnn"){let O=N[0];[e.Zd,e.vd,e.webnnEnsureTensor,e.xd,e.webnnDownloadTensor,e.Yd,e.webnnEnableTraceEvent]=N.slice(1),e.webnnReleaseTensorId=e.vd,e.webnnUploadTensor=e.xd,e.webnnRegisterMLContext=e.Yd,e.webnnOnRunStart=z=>O.onRunStart(z),e.webnnOnRunEnd=O.onRunEnd.bind(O),e.webnnOnReleaseSession=z=>{O.onReleaseSession(z)},e.webnnCreateMLTensorDownloader=(z,se)=>O.createMLTensorDownloader(z,se),e.webnnRegisterMLTensor=(z,se,ue,Se)=>O.registerMLTensor(z,se,ue,Se),e.webnnCreateMLContext=z=>O.createMLContext(z),e.webnnRegisterMLConstant=(z,se,ue,Se,Ue,it)=>O.registerMLConstant(z,se,ue,Se,Ue,e.Zc,it),e.webnnRegisterGraphInput=O.registerGraphInput.bind(O),e.webnnIsGraphInput=O.isGraphInput.bind(O),e.webnnRegisterGraphOutput=O.registerGraphOutput.bind(O),e.webnnIsGraphOutput=O.isGraphOutput.bind(O),e.webnnCreateTemporaryTensor=O.createTemporaryTensor.bind(O),e.webnnIsGraphInputOutputTypeSupported=O.isGraphInputOutputTypeSupported.bind(O)}};let a=()=>{let C=N=>(...O)=>{let z=$r;return O=N(...O),$r!=z?new Promise((se,ue)=>{Oo={resolve:se,reject:ue}}):O};(()=>{for(let N of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])e[N]=C(e[N])})(),s!==void 0&&(e._OrtRun=s(e._OrtRun),e._OrtRunWithBinding=s(e._OrtRunWithBinding)),a=void 0};e.asyncInit=()=>{a?.()};var o,l,c=(C,N)=>{throw N},d=import.meta.url,h="";if(t||r){try{h=new URL(".",d).href}catch{}r&&(l=C=>{var N=new XMLHttpRequest;return N.open("GET",C,!1),N.responseType="arraybuffer",N.send(null),new Uint8Array(N.response)}),o=async C=>{if(M(C))return new Promise((O,z)=>{var se=new XMLHttpRequest;se.open("GET",C,!0),se.responseType="arraybuffer",se.onload=()=>{se.status==200||se.status==0&&se.response?O(se.response):z(se.status)},se.onerror=z,se.send(null)});var N=await fetch(C,{credentials:"same-origin"});if(N.ok)return N.arrayBuffer();throw Error(N.status+" : "+N.url)}}var p,A,y,m,x,g,_=(()=>{}).bind(console),b=(()=>{}).bind(console),w=_,I=b,S=!1,M=C=>C.startsWith("file://");function T(){Ce.buffer!=k.buffer&&G()}if(i){let C=function(N){try{var O=N.data,z=O.Uc;if(z==="load"){let se=[];self.onmessage=ue=>se.push(ue),g=()=>{postMessage({Uc:"loaded"});for(let ue of se)C(ue);self.onmessage=C};for(let ue of O.Ad)e[ue]&&!e[ue].proxy||(e[ue]=(...Se)=>{postMessage({Uc:"callHandler",zd:ue,args:Se})},ue=="print"&&(w=e[ue]),ue=="printErr"&&(I=e[ue]));Ce=O.Vd,G(),A=O.Wd,he(),ac()}else if(z==="run"){(function(se){var ue=(T(),W)[se+52>>>2>>>0];se=(T(),W)[se+56>>>2>>>0],zh(ue,ue-se),qt(ue)})(O.Tc),ja(O.Tc,0,0,1,0,0),Z(),yi(O.Tc),R||(cA(),R=!0);try{me(O.Pd,O.dd)}catch(se){if(se!="unwind")throw se}}else O.target!=="setimmediate"&&(z==="checkMailbox"?R&&zo():z&&(I(`worker: received unknown command ${z}`),I(O)))}catch(se){throw Yo(),se}};var R=!1;self.onunhandledrejection=N=>{throw N.reason||N},self.onmessage=C}var k,H,Q,V,B,W,K,X,$,J,ne,L=!1;function G(){var C=Ce.buffer;e.HEAP8=k=new Int8Array(C),Q=new Int16Array(C),e.HEAPU8=H=new Uint8Array(C),V=new Uint16Array(C),e.HEAP32=B=new Int32Array(C),e.HEAPU32=W=new Uint32Array(C),K=new Float32Array(C),X=new Float64Array(C),$=new BigInt64Array(C),J=new BigUint64Array(C)}function oe(){L=!0,i?g():Wi.tb()}function Ae(C){throw I(C="Aborted("+C+")"),S=!0,C=new WebAssembly.RuntimeError(C+". Build with -sASSERTIONS for more info."),x?.(C),C}function ye(){return{a:{ma:Lu,hb:yA,g:He,J:nt,f:dt,o:Mt,h:_e,ha:ut,b:je,T:Ye,Ia:Ve,n:_t,_:tr,Ya:No,Ea:ys,Ga:Wl,Za:Ur,Wa:xs,Pa:sa,Va:Oa,ka:$a,Fa:ql,Ca:Ga,Xa:ki,Da:Qo,cb:du,ea:Te,xa:De,va:St,da:$t,O:xn,H:Fn,wa:Rt,Z:Yn,ya:Or,Sa:Kn,Aa:Wp,Ja:qp,ta:bh,fa:fu,Ra:yi,$a:la,R:Yl,s:gu,c:at,ib:wh,y:Zp,M:ua,D:Eh,m:yu,t:Ih,jb:xu,I:vu,S:eA,j:ii,v:Vo,r:Ch,l:Xl,Ma:iy,Na:wu,Oa:tA,Ka:nA,La:rA,ua:iA,eb:sy,bb:oy,u:ly,aa:cy,ga:uy,ab:ay,V:dy,_a:Th,Ba:hy,F:Sh,U:fy,la:Eu,za:Ay,gb:py,fb:my,Ta:jo,Ua:aA,Ha:q,$:kh,ja:Nh,Qa:Qh,ia:Ph,lb:bA,na:br,mb:_A,oa:fa,G:Xa,d:af,q:rf,w:Fu,B:qi,pb:ha,K:cf,x:yy,pa:Pn,X:Gr,ba:il,nb:Uu,ob:Vr,ra:sc,qa:uf,qb:rl,N:_y,Y:Rn,e:of,A:xA,k:sf,kb:Ou,p:vy,z:lf,C:xy,E:da,L:ic,rb:by,Q:Ja,ca:ws,W:sl,sb:nl,sa:vA,P:zu,i:Wo,a:Ce,db:re}}}async function he(){function C(z,se){var ue=Wi=z.exports;z={};for(let[Se,Ue]of Object.entries(ue))typeof Ue=="function"?(ue=ca(Ue),z[Se]=ue):z[Se]=Ue;return Wi=z,Wi=(function(){var Se=Wi,Ue=ht=>Nt=>ht(Nt)>>>0,it=ht=>()=>ht()>>>0;return(Se=Object.assign({},Se)).ub=Ue(Se.ub),Se.Yb=it(Se.Yb),Se._b=Ue(Se._b),Se.mc=Ue(Se.mc),Se.nc=it(Se.nc),Se.rc=Ue(Se.rc),Se})(),be.push(Wi.$b),lA=(z=Wi).ub,cA=z.vb,e._OrtInit=z.wb,e._OrtGetLastError=z.xb,e._OrtCreateSessionOptions=z.yb,e._OrtAppendExecutionProvider=z.zb,e._OrtAddFreeDimensionOverride=z.Ab,e._OrtAddSessionConfigEntry=z.Bb,e._OrtReleaseSessionOptions=z.Cb,e._OrtCreateSession=z.Db,e._OrtReleaseSession=z.Eb,e._OrtGetInputOutputCount=z.Fb,e._OrtGetInputOutputMetadata=z.Gb,e._OrtFree=z.Hb,e._OrtCreateTensor=z.Ib,e._OrtGetTensorData=z.Jb,e._OrtReleaseTensor=z.Kb,e._OrtCreateRunOptions=z.Lb,e._OrtAddRunConfigEntry=z.Mb,e._OrtReleaseRunOptions=z.Nb,e._OrtCreateBinding=z.Ob,e._OrtBindInput=z.Pb,e._OrtBindOutput=z.Qb,e._OrtClearBoundOutputs=z.Rb,e._OrtReleaseBinding=z.Sb,e._OrtRunWithBinding=z.Tb,e._OrtRun=z.Ub,e._OrtEndProfiling=z.Vb,e._JsepOutput=z.Wb,e._JsepGetNodeName=z.Xb,Cu=z.Yb,Qi=e._free=z.Zb,qo=e._malloc=z._b,ja=z.bc,Yo=z.cc,uA=z.dc,Zl=z.ec,Lh=z.fc,Fh=z.gc,Su=z.hc,Yt=z.ic,Xo=z.jc,zh=z.kc,qt=z.lc,Uh=z.mc,Xt=z.nc,dA=z.oc,Oh=z.pc,hA=z.qc,vi=z.rc,Jo=z.sc,Bu=z.tc,$h=z.uc,Gh=z.vc,Vh=z.wc,Mu=z.xc,fA=z.yc,pA=z.zc,Wa=z.Ac,Tu=z.Bc,Ko=z.Cc,Ru=z.Dc,Hh=z.Ec,ec=z.Fc,qa=z.Gc,Du=z.Hc,jh=z.Ic,tc=z.Jc,Wh=z.Kc,qh=z.Lc,Yh=z.Mc,Xh=z.Nc,Jh=z.Oc,Kh=z.Pc,bs=z.Rc,ku=z.Sc,Nu=z.bd,AA=z.cd,mA=z.hd,Zo=z.kd,gA=z.ld,Zh=z.md,ef=z.nd,Tn=z.od,Qu=z.pd,nc=z.qd,el=z.rd,tf=z.wd,Pu=z.Rd,tl=z.Sd,rc=z.Td,Ya=z.Ud,A=se,Wi}var N,O=ye();return e.instantiateWasm?new Promise(z=>{e.instantiateWasm(O,(se,ue)=>{z(C(se,ue))})}):i?C(new WebAssembly.Instance(A,ye()),A):(ne??=e.locateFile?e.locateFile?e.locateFile("ort-wasm-simd-threaded.jsep.wasm",h):h+"ort-wasm-simd-threaded.jsep.wasm":new URL("/assets/ort-wasm-simd-threaded.jsep-C887KxcQ.wasm",import.meta.url).href,N=await(async function(z){var se=ne;if(!p&&!M(se))try{var ue=fetch(se,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(ue,z)}catch(Se){I(`wasm streaming compile failed: ${Se}`),I("falling back to ArrayBuffer instantiation")}return(async function(Se,Ue){try{var it=await(async function(ht){if(!p)try{var Nt=await o(ht);return new Uint8Array(Nt)}catch{}if(ht==ne&&p)ht=new Uint8Array(p);else{if(!l)throw"both async and sync fetching of the wasm failed";ht=l(ht)}return ht})(Se);return await WebAssembly.instantiate(it,Ue)}catch(ht){I(`failed to asynchronously prepare wasm: ${ht}`),Ae(ht)}})(se,z)})(O),C(N.instance,N.module))}class fe{name="ExitStatus";constructor(N){this.message=`Program terminated with exit(${N})`,this.status=N}}var Ie=C=>{C.terminate(),C.onmessage=()=>{}},Re=[],ge=0,Ne=null,tt=C=>{ee.length==0&&(le(),Y(ee[0]));var N=ee.pop();if(!N)return 6;ie.push(N),ve[C.Tc]=N,N.Tc=C.Tc;var O={Uc:"run",Pd:C.Od,dd:C.dd,Tc:C.Tc};return N.postMessage(O,C.ud),0},Ge=0,F=(C,N,...O)=>{var z,se=16*O.length,ue=Xt(),Se=Uh(se),Ue=Se>>>3;for(z of O)typeof z=="bigint"?((T(),$)[Ue++>>>0]=1n,(T(),$)[Ue++>>>0]=z):((T(),$)[Ue++>>>0]=0n,(T(),X)[Ue++>>>0]=z);return C=uA(C,0,se,Se,N),qt(ue),C};function re(C){if(i)return F(0,1,C);if(y=C,!(0<Ge)){for(var N of ie)Ie(N);for(N of ee)Ie(N);ee=[],ie=[],ve={},S=!0}c(0,new fe(C))}function Ee(C){if(i)return F(1,0,C);q(C)}var q=C=>{if(y=C,i)throw Ee(C),"unwind";re(C)},ee=[],ie=[],be=[],ve={},ce=C=>{var N=C.Tc;delete ve[N],ee.push(C),ie.splice(ie.indexOf(C),1),C.Tc=0,Zl(N)};function Z(){be.forEach(C=>C())}var Y=C=>new Promise(N=>{C.onmessage=se=>{var ue=se.data;if(se=ue.Uc,ue.ad&&ue.ad!=Cu()){var Se=ve[ue.ad];Se?Se.postMessage(ue,ue.ud):I(`Internal error! Worker sent a message "${se}" to target pthread ${ue.ad}, but that thread no longer exists!`)}else se==="checkMailbox"?zo():se==="spawnThread"?tt(ue):se==="cleanupThread"?Gt(()=>{ce(ve[ue.Qd])}):se==="loaded"?(C.loaded=!0,N(C)):ue.target==="setimmediate"?C.postMessage(ue):se==="uncaughtException"?C.onerror(ue.error):se==="callHandler"?e[ue.zd](...ue.args):se&&I(`worker sent an unknown command ${se}`)},C.onerror=se=>{throw I(`worker sent an error! ${se.filename}:${se.lineno}: ${se.message}`),se};var O,z=[];for(O of[])e.propertyIsEnumerable(O)&&z.push(O);C.postMessage({Uc:"load",Ad:z,Vd:Ce,Wd:A})});function le(){var C=new Worker((()=>{let N=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new N("ort.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});ee.push(C)}var Ce,me=(C,N)=>{Ge=0,C=Bu(C,N),0<Ge?y=C:Lh(C)},xe=[],st=0;function He(C){var N=new pt(C>>>=0);return(T(),k)[N.Vc+12>>>0]==0&&(ze(N,!0),st--),Ze(N,!1),xe.push(N),vi(C)}var Ke=0,nt=()=>{Yt(0,0);var C=xe.pop();dA(C.ed),Ke=0};function ze(C,N){N=N?1:0,(T(),k)[C.Vc+12>>>0]=N}function Ze(C,N){N=N?1:0,(T(),k)[C.Vc+13>>>0]=N}class pt{constructor(N){this.ed=N,this.Vc=N-24}}var ft=C=>{var N=Ke;if(!N)return Xo(0),0;var O=new pt(N);(T(),W)[O.Vc+16>>>2>>>0]=N;var z=(T(),W)[O.Vc+4>>>2>>>0];if(!z)return Xo(0),N;for(var se of C){if(se===0||se===z)break;if(hA(se,z,O.Vc+16))return Xo(se),N}return Xo(z),N};function dt(){return ft([])}function Mt(C){return ft([C>>>0])}function _e(C,N,O,z){return ft([C>>>0,N>>>0,O>>>0,z>>>0])}var ut=()=>{var C=xe.pop();C||Ae("no exception to throw");var N=C.ed;throw(T(),k)[C.Vc+13>>>0]==0&&(xe.push(C),Ze(C,!0),ze(C,!1),st++),Oh(N),Ke=N};function je(C,N,O){var z=new pt(C>>>=0);throw N>>>=0,O>>>=0,(T(),W)[z.Vc+16>>>2>>>0]=0,(T(),W)[z.Vc+4>>>2>>>0]=N,(T(),W)[z.Vc+8>>>2>>>0]=O,Oh(C),st++,Ke=C}var Ye=()=>st;function We(C,N,O,z){return i?F(2,1,C,N,O,z):Ve(C,N,O,z)}function Ve(C,N,O,z){if(C>>>=0,N>>>=0,O>>>=0,z>>>=0,!globalThis.SharedArrayBuffer)return 6;var se=[];return i&&se.length===0?We(C,N,O,z):(C={Od:O,Tc:C,dd:z,ud:se},i?(C.Uc="spawnThread",postMessage(C,se),0):tt(C))}function _t(C){throw Ke||=C>>>0,Ke}var Ot=globalThis.TextDecoder&&new TextDecoder,En=(C,N,O,z)=>{if(O=N+O,z)return O;for(;C[N]&&!(N>=O);)++N;return N},dn=(C,N=0,O,z)=>{if(16<(O=En(C,N>>>=0,O,z))-N&&C.buffer&&Ot)return Ot.decode(C.buffer instanceof ArrayBuffer?C.subarray(N,O):C.slice(N,O));for(z="";N<O;){var se=C[N++];if(128&se){var ue=63&C[N++];if((224&se)==192)z+=String.fromCharCode((31&se)<<6|ue);else{var Se=63&C[N++];65536>(se=(240&se)==224?(15&se)<<12|ue<<6|Se:(7&se)<<18|ue<<12|Se<<6|63&C[N++])?z+=String.fromCharCode(se):(se-=65536,z+=String.fromCharCode(55296|se>>10,56320|1023&se))}}else z+=String.fromCharCode(se)}return z},hn=(C,N,O)=>(C>>>=0)?dn((T(),H),C,N,O):"";function tr(C,N,O){return i?F(3,1,C,N,O):0}function No(C,N){if(i)return F(4,1,C,N)}function ys(C,N){if(i)return F(5,1,C,N)}function Wl(C,N,O){if(i)return F(6,1,C,N,O)}function Ur(C,N,O){return i?F(7,1,C,N,O):0}function xs(C,N){if(i)return F(8,1,C,N)}function sa(C,N,O){if(i)return F(9,1,C,N,O)}function Oa(C,N,O,z){if(i)return F(10,1,C,N,O,z)}function $a(C,N,O,z){if(i)return F(11,1,C,N,O,z)}function ql(C,N,O,z){if(i)return F(12,1,C,N,O,z)}function Ga(C){if(i)return F(13,1,C)}function ki(C,N){if(i)return F(14,1,C,N)}function Qo(C,N,O){if(i)return F(15,1,C,N,O)}var du=()=>Ae(""),mi=C=>{C>>>=0;for(var N="";;){var O=(T(),H)[C++>>>0];if(!O)return N;N+=String.fromCharCode(O)}},Po={},Lo={},vs=class extends Error{constructor(C){super(C),this.name="BindingError"}};function gi(C,N,O={}){return(function(z,se,ue={}){var Se=se.name;if(!z)throw new vs(`type "${Se}" must have a positive integer typeid pointer`);if(Lo.hasOwnProperty(z)){if(ue.Bd)return;throw new vs(`Cannot register type '${Se}' twice`)}Lo[z]=se,Po.hasOwnProperty(z)&&(se=Po[z],delete Po[z],se.forEach(Ue=>Ue()))})(C,N,O)}var ae=(C,N,O)=>{switch(N){case 1:return O?z=>(T(),k)[z>>>0]:z=>(T(),H)[z>>>0];case 2:return O?z=>(T(),Q)[z>>>1>>>0]:z=>(T(),V)[z>>>1>>>0];case 4:return O?z=>(T(),B)[z>>>2>>>0]:z=>(T(),W)[z>>>2>>>0];case 8:return O?z=>(T(),$)[z>>>3>>>0]:z=>(T(),J)[z>>>3>>>0];default:throw new TypeError(`invalid integer width (${N}): ${C}`)}};function Te(C,N,O,z,se){C>>>=0,O>>>=0,N=mi(N>>>0);let ue=Se=>Se;if(z=z===0n){let Se=8*O;ue=Ue=>BigInt.asUintN(Se,Ue),se=ue(se)}gi(C,{name:N,Qc:ue,Xc:(Se,Ue)=>(typeof Ue=="number"&&(Ue=BigInt(Ue)),Ue),Wc:ae(N,O,!z),Yc:null})}function De(C,N,O,z){gi(C>>>=0,{name:N=mi(N>>>0),Qc:function(se){return!!se},Xc:function(se,ue){return ue?O:z},Wc:function(se){return this.Qc((T(),H)[se>>>0])},Yc:null})}var Fe=[],Me=[0,1,,1,null,1,!0,1,!1,1];function at(C){9<(C>>>=0)&&--Me[C+1]==0&&(Me[C]=void 0,Fe.push(C))}var lt=C=>{if(!C)throw new vs(`Cannot use deleted val. handle = ${C}`);return Me[C]},At=C=>{switch(C){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let N=Fe.pop()||Me.length;return Me[N]=C,Me[N+1]=1,N}};function gt(C){return this.Qc((T(),W)[C>>>2>>>0])}var Qt={name:"emscripten::val",Qc:C=>{var N=lt(C);return at(C),N},Xc:(C,N)=>At(N),Wc:gt,Yc:null};function St(C){return gi(C>>>0,Qt)}var kt=(C,N)=>{switch(N){case 4:return function(O){return this.Qc((T(),K)[O>>>2>>>0])};case 8:return function(O){return this.Qc((T(),X)[O>>>3>>>0])};default:throw new TypeError(`invalid float width (${N}): ${C}`)}};function $t(C,N,O){O>>>=0,gi(C>>>=0,{name:N=mi(N>>>0),Qc:z=>z,Xc:(z,se)=>se,Wc:kt(N,O),Yc:null})}function xn(C,N,O,z,se){C>>>=0,O>>>=0,N=mi(N>>>0);let ue=Ue=>Ue;if(z===0){var Se=32-8*O;ue=Ue=>Ue<<Se>>>Se,se=ue(se)}gi(C,{name:N,Qc:ue,Xc:(Ue,it)=>it,Wc:ae(N,O,z!==0),Yc:null})}function Fn(C,N,O){function z(ue){var Se=(T(),W)[ue>>>2>>>0];return ue=(T(),W)[ue+4>>>2>>>0],new se((T(),k).buffer,ue,Se)}var se=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][N];gi(C>>>=0,{name:O=mi(O>>>0),Qc:z,Wc:z},{Bd:!0})}var pn=(C,N,O)=>{var z=(T(),H);if(N>>>=0,0<O){var se=N;O=N+O-1;for(var ue=0;ue<C.length;++ue){var Se=C.codePointAt(ue);if(127>=Se){if(N>=O)break;z[N++>>>0]=Se}else if(2047>=Se){if(N+1>=O)break;z[N++>>>0]=192|Se>>6,z[N++>>>0]=128|63&Se}else if(65535>=Se){if(N+2>=O)break;z[N++>>>0]=224|Se>>12,z[N++>>>0]=128|Se>>6&63,z[N++>>>0]=128|63&Se}else{if(N+3>=O)break;z[N++>>>0]=240|Se>>18,z[N++>>>0]=128|Se>>12&63,z[N++>>>0]=128|Se>>6&63,z[N++>>>0]=128|63&Se,ue++}}z[N>>>0]=0,C=N-se}else C=0;return C},an=C=>{for(var N=0,O=0;O<C.length;++O){var z=C.charCodeAt(O);127>=z?N++:2047>=z?N+=2:55296<=z&&57343>=z?(N+=4,++O):N+=3}return N};function Rt(C,N){gi(C>>>=0,{name:N=mi(N>>>0),Qc(O){var z=(T(),W)[O>>>2>>>0];return z=hn(O+4,z,!0),Qi(O),z},Xc(O,z){z instanceof ArrayBuffer&&(z=new Uint8Array(z));var se=typeof z=="string";if(!(se||ArrayBuffer.isView(z)&&z.BYTES_PER_ELEMENT==1))throw new vs("Cannot pass non-string to std::string");var ue=se?an(z):z.length,Se=qo(4+ue+1),Ue=Se+4;return(T(),W)[Se>>>2>>>0]=ue,se?pn(z,Ue,ue+1):(T(),H).set(z,Ue>>>0),O!==null&&O.push(Qi,Se),Se},Wc:gt,Yc(O){Qi(O)}})}var vn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,tn=(C,N,O)=>{if(C>>>=1,16<(N=En((T(),V),C,N/2,O))-C&&vn)return vn.decode((T(),V).slice(C,N));for(O="";C<N;++C){var z=(T(),V)[C>>>0];O+=String.fromCharCode(z)}return O},Nr=(C,N,O)=>{if(O??=2147483647,2>O)return 0;var z=N;O=(O-=2)<2*C.length?O/2:C.length;for(var se=0;se<O;++se){var ue=C.charCodeAt(se);(T(),Q)[N>>>1>>>0]=ue,N+=2}return(T(),Q)[N>>>1>>>0]=0,N-z},aa=C=>2*C.length,cr=(C,N,O)=>{var z="";C>>>=2;for(var se=0;!(se>=N/4);se++){var ue=(T(),W)[C+se>>>0];if(!ue&&!O)break;z+=String.fromCodePoint(ue)}return z},oa=(C,N,O)=>{if(N>>>=0,O??=2147483647,4>O)return 0;var z=N;O=z+O-4;for(var se=0;se<C.length;++se){var ue=C.codePointAt(se);if(65535<ue&&se++,(T(),B)[N>>>2>>>0]=ue,(N+=4)+4>O)break}return(T(),B)[N>>>2>>>0]=0,N-z},Cn=C=>{for(var N=0,O=0;O<C.length;++O)65535<C.codePointAt(O)&&O++,N+=4;return N};function Yn(C,N,O){if(C>>>=0,N>>>=0,O=mi(O>>>=0),N===2)var z=tn,se=Nr,ue=aa;else z=cr,se=oa,ue=Cn;gi(C,{name:O,Qc:Se=>{var Ue=(T(),W)[Se>>>2>>>0];return Ue=z(Se+4,Ue*N,!0),Qi(Se),Ue},Xc:(Se,Ue)=>{if(typeof Ue!="string")throw new vs(`Cannot pass non-string to C++ string type ${O}`);var it=ue(Ue),ht=qo(4+it+N);return(T(),W)[ht>>>2>>>0]=it/N,se(Ue,ht+4,it+N),Se!==null&&Se.push(Qi,ht),ht},Wc:gt,Yc(Se){Qi(Se)}})}function Or(C,N){gi(C>>>=0,{Cd:!0,name:N=mi(N>>>0),Qc:()=>{},Xc:()=>{}})}function Kn(C){ja(C>>>0,!r,1,!t,131072,!1),Z()}var Gt=C=>{if(!S)try{if(C(),!(0<Ge))try{i?Cu()&&Lh(y):q(y)}catch(N){N instanceof fe||N=="unwind"||c(0,N)}}catch(N){N instanceof fe||N=="unwind"||c(0,N)}},Fo=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function yi(C){C>>>=0,Fo||(Atomics.waitAsync((T(),B),C>>>2,C).value.then(zo),C+=128,Atomics.store((T(),B),C>>>2,1))}var zo=()=>Gt(()=>{var C=Cu();C&&(yi(C),Su())});function Wp(C,N){(C>>>=0)==N>>>0?setTimeout(zo):i?postMessage({ad:C,Uc:"checkMailbox"}):(C=ve[C])&&C.postMessage({Uc:"checkMailbox"})}var hu=[];function qp(C,N,O,z,se){for(N>>>=0,se>>>=0,hu.length=0,O=se>>>3,z=se+z>>>3;O<z;){var ue;ue=(T(),$)[O++>>>0]?(T(),$)[O++>>>0]:(T(),X)[O++>>>0],hu.push(ue)}return(N?nf[N]:gy[C])(...hu)}var bh=()=>{Ge=0};function fu(C){C>>>=0,i?postMessage({Uc:"cleanupThread",Qd:C}):ce(ve[C])}function la(C){}var Ni=C=>{try{C()}catch(N){Ae(N)}};function ca(C){var N=(...O)=>{pu.push(C);try{return C(...O)}finally{S||(pu.pop(),$r&&xi===1&&pu.length===0&&(xi=0,Ge+=1,Ni(tl),typeof Fibers<"u"&&Fibers.ce()))}};return Yp.set(C,N),N}var xi=0,$r=null,_s=0,pu=[],Au=new Map,Uo=new Map,Yp=new Map,Xp=0,Oo=null,Jp=[],Kp=C=>(function(N){if(!S){if(xi===0){var O=!1,z=!1;N((se=0)=>{if(!S&&(_s=se,O=!0,z)){xi=2,Ni(()=>rc($r)),typeof MainLoop<"u"&&MainLoop.yd&&MainLoop.resume(),se=!1;try{var ue=(function(){var it=(T(),B)[$r+8>>>2>>>0];return it=Uo.get(it),it=Yp.get(it),--Ge,it()})()}catch(it){ue=it,se=!0}var Se=!1;if(!$r){var Ue=Oo;Ue&&(Oo=null,(se?Ue.reject:Ue.resolve)(ue),Se=!0)}if(se&&!Se)throw ue}}),z=!0,O||(xi=1,$r=(function(){var se=qo(65548),ue=se+12;if((T(),W)[se>>>2>>>0]=ue,(T(),W)[se+4>>>2>>>0]=ue+65536,ue=pu[0],!Au.has(ue)){var Se=Xp++;Au.set(ue,Se),Uo.set(Se,ue)}return ue=Au.get(ue),(T(),B)[se+8>>>2>>>0]=ue,se})(),typeof MainLoop<"u"&&MainLoop.yd&&MainLoop.pause(),Ni(()=>Pu($r)))}else xi===2?(xi=0,Ni(Ya),Qi($r),$r=null,Jp.forEach(Gt)):Ae(`invalid state: ${xi}`);return _s}})(N=>{C().then(N)});function Yl(C){return C>>>=0,Kp(async()=>{var N=await lt(C);return At(N)})}var Va=[],$o=C=>{var N=Va.length;return Va.push(C),N},mu=(C,N)=>{for(var O=Array(C),z=0;z<C;++z){var se=z,ue=(T(),W)[N+4*z>>>2>>>0],Se=Lo[ue];if(Se===void 0)throw C=`parameter ${z}`,ue=lA(ue),N=mi(ue),Qi(ue),new vs(`${C} has unknown type ${N}`);O[se]=Se}return O},ny=(C,N,O)=>{var z=[];return C=C(z,O),z.length&&((T(),W)[N>>>2>>>0]=At(z)),C},ry={},Go=C=>{var N=ry[C];return N===void 0?mi(C):N};function gu(C,N,O){var[z,...se]=mu(C,N>>>0);N=z.Xc.bind(z);var ue=se.map(it=>it.Wc.bind(it));C--;var Se={toValue:lt};switch(C=ue.map((it,ht)=>{var Nt=`argFromPtr${ht}`;return Se[Nt]=it,`${Nt}(args${ht?"+"+8*ht:""})`}),O){case 0:var Ue="toValue(handle)";break;case 2:Ue="new (toValue(handle))";break;case 3:Ue="";break;case 1:Se.getStringOrSymbol=Go,Ue="toValue(handle)[getStringOrSymbol(methodName)]"}return Ue+=`(${C})`,z.Cd||(Se.toReturnWire=N,Se.emval_returnValue=ny,Ue=`return emval_returnValue(toReturnWire, destructorsRef, ${Ue})`),Ue=`return function (handle, methodName, destructorsRef, args) {
|
|
12823
12823
|
${Ue}
|
|
12824
12824
|
}`,O=new Function(Object.keys(Se),Ue)(...Object.values(Se)),Ue=`methodCaller<(${se.map(it=>it.name)}) => ${z.name}>`,$o(Object.defineProperty(O,"name",{value:Ue}))}function wh(C,N){return N>>>=0,(C=lt(C>>>0))==lt(N)}function Zp(C){return(C>>>=0)?(C=Go(C),At(globalThis[C])):At(globalThis)}function ua(C){return C=Go(C>>>0),At(e[C])}function Eh(C,N){return N>>>=0,C=lt(C>>>0),N=lt(N),At(C[N])}function yu(C){9<(C>>>=0)&&(Me[C+1]+=1)}function Ih(C,N,O,z,se){return Va[C>>>0](N>>>0,O>>>0,z>>>0,se>>>0)}function xu(C,N,O,z,se){return Ih(C>>>0,N>>>0,O>>>0,z>>>0,se>>>0)}function vu(){return At([])}function eA(C){C=lt(C>>>0);for(var N=Array(C.length),O=0;O<C.length;O++)N[O]=C[O];return At(N)}function ii(C){return At(Go(C>>>0))}function Vo(){return At({})}function Ch(C){for(var N=lt(C>>>=0);N.length;){var O=N.pop();N.pop()(O)}at(C)}function Xl(C,N,O){N>>>=0,O>>>=0,C=lt(C>>>0),N=lt(N),O=lt(O),C[N]=O}function iy(C,N){C=-9007199254740992>C||9007199254740992<C?NaN:Number(C),N>>>=0,C=new Date(1e3*C),(T(),B)[N>>>2>>>0]=C.getUTCSeconds(),(T(),B)[N+4>>>2>>>0]=C.getUTCMinutes(),(T(),B)[N+8>>>2>>>0]=C.getUTCHours(),(T(),B)[N+12>>>2>>>0]=C.getUTCDate(),(T(),B)[N+16>>>2>>>0]=C.getUTCMonth(),(T(),B)[N+20>>>2>>>0]=C.getUTCFullYear()-1900,(T(),B)[N+24>>>2>>>0]=C.getUTCDay(),C=(C.getTime()-Date.UTC(C.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(T(),B)[N+28>>>2>>>0]=C}var _u=C=>C%4==0&&(C%100!=0||C%400==0),bu=[0,31,60,91,121,152,182,213,244,274,305,335],Ho=[0,31,59,90,120,151,181,212,243,273,304,334];function wu(C,N){C=-9007199254740992>C||9007199254740992<C?NaN:Number(C),N>>>=0,C=new Date(1e3*C),(T(),B)[N>>>2>>>0]=C.getSeconds(),(T(),B)[N+4>>>2>>>0]=C.getMinutes(),(T(),B)[N+8>>>2>>>0]=C.getHours(),(T(),B)[N+12>>>2>>>0]=C.getDate(),(T(),B)[N+16>>>2>>>0]=C.getMonth(),(T(),B)[N+20>>>2>>>0]=C.getFullYear()-1900,(T(),B)[N+24>>>2>>>0]=C.getDay();var O=(_u(C.getFullYear())?bu:Ho)[C.getMonth()]+C.getDate()-1|0;(T(),B)[N+28>>>2>>>0]=O,(T(),B)[N+36>>>2>>>0]=-60*C.getTimezoneOffset(),O=new Date(C.getFullYear(),6,1).getTimezoneOffset();var z=new Date(C.getFullYear(),0,1).getTimezoneOffset();C=0|(O!=z&&C.getTimezoneOffset()==Math.min(z,O)),(T(),B)[N+32>>>2>>>0]=C}function tA(C){C>>>=0;var N=new Date((T(),B)[C+20>>>2>>>0]+1900,(T(),B)[C+16>>>2>>>0],(T(),B)[C+12>>>2>>>0],(T(),B)[C+8>>>2>>>0],(T(),B)[C+4>>>2>>>0],(T(),B)[C>>>2>>>0],0),O=(T(),B)[C+32>>>2>>>0],z=N.getTimezoneOffset(),se=new Date(N.getFullYear(),6,1).getTimezoneOffset(),ue=new Date(N.getFullYear(),0,1).getTimezoneOffset(),Se=Math.min(ue,se);return 0>O?(T(),B)[C+32>>>2>>>0]=+(se!=ue&&Se==z):0<O!=(Se==z)&&(se=Math.max(ue,se),N.setTime(N.getTime()+6e4*((0<O?Se:se)-z))),(T(),B)[C+24>>>2>>>0]=N.getDay(),O=(_u(N.getFullYear())?bu:Ho)[N.getMonth()]+N.getDate()-1|0,(T(),B)[C+28>>>2>>>0]=O,(T(),B)[C>>>2>>>0]=N.getSeconds(),(T(),B)[C+4>>>2>>>0]=N.getMinutes(),(T(),B)[C+8>>>2>>>0]=N.getHours(),(T(),B)[C+12>>>2>>>0]=N.getDate(),(T(),B)[C+16>>>2>>>0]=N.getMonth(),(T(),B)[C+20>>>2>>>0]=N.getYear(),C=N.getTime(),BigInt(isNaN(C)?-1:C/1e3)}function nA(C,N,O,z,se,ue,Se){return i?F(16,1,C,N,O,z,se,ue,Se):-52}function rA(C,N,O,z,se,ue){if(i)return F(17,1,C,N,O,z,se,ue)}var Jl={},Sh=()=>performance.timeOrigin+performance.now();function iA(C,N){if(i)return F(18,1,C,N);if(Jl[C]&&(clearTimeout(Jl[C].id),delete Jl[C]),!N)return 0;var O=setTimeout(()=>{delete Jl[C],Gt(()=>Fh(C,performance.timeOrigin+performance.now()))},N);return Jl[C]={id:O,be:N},0}function sy(C,N,O,z){C>>>=0,N>>>=0,O>>>=0,z>>>=0;var se=new Date().getFullYear(),ue=new Date(se,0,1).getTimezoneOffset();se=new Date(se,6,1).getTimezoneOffset();var Se=Math.max(ue,se);(T(),W)[C>>>2>>>0]=60*Se,(T(),B)[N>>>2>>>0]=+(ue!=se),C=(N=Ue=>{var it=Math.abs(Ue);return`UTC${0<=Ue?"-":"+"}${String(Math.floor(it/60)).padStart(2,"0")}${String(it%60).padStart(2,"0")}`})(ue),N=N(se),se<ue?(pn(C,O,17),pn(N,z,17)):(pn(C,z,17),pn(N,O,17))}var ay=()=>Date.now();function oy(C,N,O){return O>>>=0,0<=C&&3>=C?(C===0?C=Date.now():C=performance.timeOrigin+performance.now(),C=Math.round(1e6*C),(T(),$)[O>>>3>>>0]=BigInt(C),0):28}var Bh=[],Mh=(C,N)=>{Bh.length=0;for(var O;O=(T(),H)[C++>>>0];){var z=O!=105;N+=(z&=O!=112)&&N%8?4:0,Bh.push(O==112?(T(),W)[N>>>2>>>0]:O==106?(T(),$)[N>>>3>>>0]:O==105?(T(),B)[N>>>2>>>0]:(T(),X)[N>>>3>>>0]),N+=z?8:4}return Bh};function ly(C,N,O){return C>>>=0,N=Mh(N>>>0,O>>>0),nf[C](...N)}function cy(C,N,O){return C>>>=0,N=Mh(N>>>0,O>>>0),nf[C](...N)}var uy=()=>{};function dy(C,N){return I(hn(C>>>0,N>>>0))}var Th=()=>{throw Ge+=1,"unwind"};function hy(){return 4294901760}var fy=()=>navigator.hardwareConcurrency,Ha={},Kl=C=>{var N;return(N=/\bwasm-function\[\d+\]:(0x[0-9a-f]+)/.exec(C))?+N[1]:(N=/:(\d+):\d+(?:\)|$)/.exec(C))?2147483648|+N[1]:0},sA=C=>{for(var N of C)(C=Kl(N))&&(Ha[C]=N)};function py(){var C=Error().stack.toString().split(`
|
|
12825
12825
|
`);return C[0]=="Error"&&C.shift(),sA(C),Ha.sd=Kl(C[3]),Ha.Md=C,Ha.sd}function Eu(C){if(!(C=Ha[C>>>0]))return 0;var N;if(N=/^\s+at .*\.wasm\.(.*) \(.*\)$/.exec(C))C=N[1];else if(N=/^\s+at (.*) \(.*\)$/.exec(C))C=N[1];else{if(!(N=/^(.+?)@/.exec(C)))return 0;C=N[1]}Qi(Eu.td??0),N=an(C)+1;var O=qo(N);return O&&pn(C,O,N),Eu.td=O,Eu.td}function Ay(C){C>>>=0;var N=(T(),H).length;if(C<=N||4294901760<C)return!1;for(var O=1;4>=O;O*=2){var z=N*(1+.2/O);z=Math.min(z,C+100663296);e:{z=(Math.min(4294901760,65536*Math.ceil(Math.max(C,z)/65536))-Ce.buffer.byteLength+65535)/65536|0;try{Ce.grow(z),G();var se=1;break e}catch{}se=void 0}if(se)return!0}return!1}function my(C,N,O){if(C>>>=0,N>>>=0,Ha.sd==C)var z=Ha.Md;else(z=Error().stack.toString().split(`
|
|
12826
|
-
`))[0]=="Error"&&z.shift(),sA(z);for(var se=3;z[se]&&Kl(z[se])!=C;)++se;for(C=0;C<O&&z[C+se];++C)(T(),B)[N+4*C>>>2>>>0]=Kl(z[C+se]);return C}var Rh,Dh={},Iu=()=>{if(!Rh){var C,N={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"};for(C in Dh)Dh[C]===void 0?delete N[C]:N[C]=Dh[C];var O=[];for(C in N)O.push(`${C}=${N[C]}`);Rh=O}return Rh};function jo(C,N){if(i)return F(19,1,C,N);C>>>=0,N>>>=0;var O,z=0,se=0;for(O of Iu()){var ue=N+z;(T(),W)[C+se>>>2>>>0]=ue,z+=pn(O,ue,1/0)+1,se+=4}return 0}function aA(C,N){if(i)return F(20,1,C,N);C>>>=0,N>>>=0;var O=Iu();for(var z of((T(),W)[C>>>2>>>0]=O.length,C=0,O))C+=an(z)+1;return(T(),W)[N>>>2>>>0]=C,0}function kh(C){return i?F(21,1,C):52}function Nh(C,N,O,z){return i?F(22,1,C,N,O,z):52}function Qh(C,N,O,z){return i?F(23,1,C,N,O,z):70}var oA=[null,[],[]];function Ph(C,N,O,z){if(i)return F(24,1,C,N,O,z);N>>>=0,O>>>=0,z>>>=0;for(var se=0,ue=0;ue<O;ue++){var Se=(T(),W)[N>>>2>>>0],Ue=(T(),W)[N+4>>>2>>>0];N+=8;for(var it=0;it<Ue;it++){var ht=C,Nt=(T(),H)[Se+it>>>0],Vt=oA[ht];Nt===0||Nt===10?((ht===1?w:I)(dn(Vt)),Vt.length=0):Vt.push(Nt)}se+=Ue}return(T(),W)[z>>>2>>>0]=se,0}function Wo(C){return C>>>0}i||(function(){for(var C=e.numThreads-1;C--;)le();Re.push(async()=>{var N=(async function(){if(!i)return Promise.all(ee.map(Y))})();ge++,await N,--ge==0&&Ne&&(N=Ne,Ne=null,N())})})(),i||(Ce=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),G()),e.wasmBinary&&(p=e.wasmBinary),e.stackSave=()=>Xt(),e.stackRestore=C=>qt(C),e.stackAlloc=C=>Uh(C),e.setValue=function(C,N,O="i8"){switch(O.endsWith("*")&&(O="*"),O){case"i1":case"i8":(T(),k)[C>>>0]=N;break;case"i16":(T(),Q)[C>>>1>>>0]=N;break;case"i32":(T(),B)[C>>>2>>>0]=N;break;case"i64":(T(),$)[C>>>3>>>0]=BigInt(N);break;case"float":(T(),K)[C>>>2>>>0]=N;break;case"double":(T(),X)[C>>>3>>>0]=N;break;case"*":(T(),W)[C>>>2>>>0]=N;break;default:Ae(`invalid type for setValue: ${O}`)}},e.getValue=function(C,N="i8"){switch(N.endsWith("*")&&(N="*"),N){case"i1":case"i8":return(T(),k)[C>>>0];case"i16":return(T(),Q)[C>>>1>>>0];case"i32":return(T(),B)[C>>>2>>>0];case"i64":return(T(),$)[C>>>3>>>0];case"float":return(T(),K)[C>>>2>>>0];case"double":return(T(),X)[C>>>3>>>0];case"*":return(T(),W)[C>>>2>>>0];default:Ae(`invalid type for getValue: ${N}`)}},e.UTF8ToString=hn,e.stringToUTF8=pn,e.lengthBytesUTF8=an;var lA,cA,Cu,Qi,qo,ja,Yo,uA,Zl,Lh,Fh,Su,Yt,Xo,zh,qt,Uh,Xt,dA,Oh,hA,vi,Jo,Bu,$h,Gh,Vh,Mu,fA,pA,Wa,Tu,Ko,Ru,Hh,ec,qa,Du,jh,tc,Wh,qh,Yh,Xh,Jh,Kh,bs,ku,Nu,AA,mA,Zo,gA,Zh,ef,Mn,Qu,nc,el,tf,Pu,tl,rc,Ya,Wi,gy=[re,Ee,We,tr,No,ys,Wl,Ur,xs,sa,Oa,$a,ql,Ga,ki,Qo,nA,rA,iA,jo,aA,kh,Nh,Qh,Ph],nf={929356:(C,N,O,z,se)=>{if(e===void 0||!e.Zc)return 1;if((C=hn(Number(C>>>0))).startsWith("./")&&(C=C.substring(2)),!(C=e.Zc.get(C)))return 2;if(N=Number(N>>>0),O=Number(O>>>0),z=Number(z>>>0),N+O>C.byteLength)return 3;try{let ue=C.subarray(N,N+O);switch(se){case 0:(T(),H).set(ue,z>>>0);break;case 1:e.Xd?e.Xd(z,ue):e.Ld(z,ue);break;default:return 4}return 0}catch{return 4}},930180:(C,N,O)=>{e.xd(C,(T(),H).subarray(N>>>0,N+O>>>0))},930244:()=>e.Zd(),930286:C=>{e.vd(C)},930323:()=>{e.Ed()},930354:()=>{e.Fd()},930383:()=>{e.Jd()},930408:C=>e.Dd(C),930441:C=>e.Hd(C),930473:(C,N,O)=>{e.jd(Number(C),Number(N),Number(O),!0)},930536:(C,N,O)=>{e.jd(Number(C),Number(N),Number(O))},930593:()=>typeof wasmOffsetConverter<"u",930650:C=>{e.ac("Abs",C,void 0)},930701:C=>{e.ac("Neg",C,void 0)},930752:C=>{e.ac("Floor",C,void 0)},930805:C=>{e.ac("Ceil",C,void 0)},930857:C=>{e.ac("Reciprocal",C,void 0)},930915:C=>{e.ac("Sqrt",C,void 0)},930967:C=>{e.ac("Exp",C,void 0)},931018:C=>{e.ac("Erf",C,void 0)},931069:C=>{e.ac("Sigmoid",C,void 0)},931124:(C,N,O)=>{e.ac("HardSigmoid",C,{alpha:N,beta:O})},931203:C=>{e.ac("Log",C,void 0)},931254:C=>{e.ac("Sin",C,void 0)},931305:C=>{e.ac("Cos",C,void 0)},931356:C=>{e.ac("Tan",C,void 0)},931407:C=>{e.ac("Asin",C,void 0)},931459:C=>{e.ac("Acos",C,void 0)},931511:C=>{e.ac("Atan",C,void 0)},931563:C=>{e.ac("Sinh",C,void 0)},931615:C=>{e.ac("Cosh",C,void 0)},931667:C=>{e.ac("Asinh",C,void 0)},931720:C=>{e.ac("Acosh",C,void 0)},931773:C=>{e.ac("Atanh",C,void 0)},931826:C=>{e.ac("Tanh",C,void 0)},931878:C=>{e.ac("Not",C,void 0)},931929:(C,N,O)=>{e.ac("Clip",C,{min:N,max:O})},931998:C=>{e.ac("Clip",C,void 0)},932050:(C,N)=>{e.ac("Elu",C,{alpha:N})},932108:C=>{e.ac("Gelu",C,void 0)},932160:C=>{e.ac("Relu",C,void 0)},932212:(C,N)=>{e.ac("LeakyRelu",C,{alpha:N})},932276:(C,N)=>{e.ac("ThresholdedRelu",C,{alpha:N})},932346:(C,N)=>{e.ac("Cast",C,{to:N})},932404:C=>{e.ac("Add",C,void 0)},932455:C=>{e.ac("Sub",C,void 0)},932506:C=>{e.ac("Mul",C,void 0)},932557:C=>{e.ac("Div",C,void 0)},932608:C=>{e.ac("Pow",C,void 0)},932659:C=>{e.ac("Equal",C,void 0)},932712:C=>{e.ac("Greater",C,void 0)},932767:C=>{e.ac("GreaterOrEqual",C,void 0)},932829:C=>{e.ac("Less",C,void 0)},932881:C=>{e.ac("LessOrEqual",C,void 0)},932940:(C,N,O,z,se)=>{e.ac("ReduceMean",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933115:(C,N,O,z,se)=>{e.ac("ReduceMax",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933289:(C,N,O,z,se)=>{e.ac("ReduceMin",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933463:(C,N,O,z,se)=>{e.ac("ReduceProd",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933638:(C,N,O,z,se)=>{e.ac("ReduceSum",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933812:(C,N,O,z,se)=>{e.ac("ReduceL1",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933985:(C,N,O,z,se)=>{e.ac("ReduceL2",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934158:(C,N,O,z,se)=>{e.ac("ReduceLogSum",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934335:(C,N,O,z,se)=>{e.ac("ReduceSumSquare",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934515:(C,N,O,z,se)=>{e.ac("ReduceLogSumExp",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934695:C=>{e.ac("Where",C,void 0)},934748:(C,N,O)=>{e.ac("Transpose",C,{perm:N?Array.from((T(),B).subarray(Number(N)>>>0,Number(O)>>>0)):[]})},934872:(C,N,O,z)=>{e.ac("DepthToSpace",C,{blocksize:N,mode:hn(O),format:z?"NHWC":"NCHW"})},935005:(C,N,O,z)=>{e.ac("DepthToSpace",C,{blocksize:N,mode:hn(O),format:z?"NHWC":"NCHW"})},935138:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr)=>{e.ac("ConvTranspose",C,{format:it?"NHWC":"NCHW",autoPad:N,dilations:[O],group:z,kernelShape:[se],pads:[ue,Se],strides:[Ue],wIsConst:()=>!!(T(),k)[ht>>>0],outputPadding:Nt?Array.from((T(),B).subarray(Number(Nt)>>>0,Number(Vt)>>>0)):[],outputShape:on?Array.from((T(),B).subarray(Number(on)>>>0,Number(ln)>>>0)):[],activation:hn(wr)})},935571:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("ConvTranspose",C,{format:Ue?"NHWC":"NCHW",autoPad:N,dilations:Array.from((T(),B).subarray(Number(O)>>>0,2+(Number(O)>>>0)>>>0)),group:z,kernelShape:Array.from((T(),B).subarray(Number(se)>>>0,2+(Number(se)>>>0)>>>0)),pads:Array.from((T(),B).subarray(Number(ue)>>>0,4+(Number(ue)>>>0)>>>0)),strides:Array.from((T(),B).subarray(Number(Se)>>>0,2+(Number(Se)>>>0)>>>0)),wIsConst:()=>!!(T(),k)[it>>>0],outputPadding:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],outputShape:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[],activation:hn(ln)})},936232:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr)=>{e.ac("ConvTranspose",C,{format:it?"NHWC":"NCHW",autoPad:N,dilations:[O],group:z,kernelShape:[se],pads:[ue,Se],strides:[Ue],wIsConst:()=>!!(T(),k)[ht>>>0],outputPadding:Nt?Array.from((T(),B).subarray(Number(Nt)>>>0,Number(Vt)>>>0)):[],outputShape:on?Array.from((T(),B).subarray(Number(on)>>>0,Number(ln)>>>0)):[],activation:hn(wr)})},936665:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("ConvTranspose",C,{format:Ue?"NHWC":"NCHW",autoPad:N,dilations:Array.from((T(),B).subarray(Number(O)>>>0,2+(Number(O)>>>0)>>>0)),group:z,kernelShape:Array.from((T(),B).subarray(Number(se)>>>0,2+(Number(se)>>>0)>>>0)),pads:Array.from((T(),B).subarray(Number(ue)>>>0,4+(Number(ue)>>>0)>>>0)),strides:Array.from((T(),B).subarray(Number(Se)>>>0,2+(Number(Se)>>>0)>>>0)),wIsConst:()=>!!(T(),k)[it>>>0],outputPadding:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],outputShape:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[],activation:hn(ln)})},937326:(C,N)=>{e.ac("GlobalAveragePool",C,{format:N?"NHWC":"NCHW"})},937417:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("AveragePool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},937896:(C,N)=>{e.ac("GlobalAveragePool",C,{format:N?"NHWC":"NCHW"})},937987:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("AveragePool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},938466:(C,N)=>{e.ac("GlobalMaxPool",C,{format:N?"NHWC":"NCHW"})},938553:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("MaxPool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},939028:(C,N)=>{e.ac("GlobalMaxPool",C,{format:N?"NHWC":"NCHW"})},939115:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("MaxPool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},939590:(C,N,O,z,se)=>{e.ac("Gemm",C,{alpha:N,beta:O,transA:z,transB:se})},939694:C=>{e.ac("MatMul",C,void 0)},939748:(C,N,O,z)=>{e.ac("ArgMax",C,{keepDims:!!N,selectLastIndex:!!O,axis:z})},939856:(C,N,O,z)=>{e.ac("ArgMin",C,{keepDims:!!N,selectLastIndex:!!O,axis:z})},939964:(C,N)=>{e.ac("Softmax",C,{axis:N})},940027:(C,N)=>{e.ac("Concat",C,{axis:N})},940087:(C,N,O,z,se)=>{e.ac("Split",C,{axis:N,numOutputs:O,splitSizes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},940243:C=>{e.ac("Expand",C,void 0)},940297:(C,N)=>{e.ac("Gather",C,{axis:Number(N)})},940368:(C,N)=>{e.ac("GatherElements",C,{axis:Number(N)})},940447:(C,N)=>{e.ac("GatherND",C,{batch_dims:Number(N)})},940526:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt)=>{e.ac("Resize",C,{antialias:N,axes:O?Array.from((T(),B).subarray(Number(O)>>>0,Number(z)>>>0)):[],coordinateTransformMode:hn(se),cubicCoeffA:ue,excludeOutside:Se,extrapolationValue:Ue,keepAspectRatioPolicy:hn(it),mode:hn(ht),nearestMode:hn(Nt)})},940888:(C,N,O,z,se,ue,Se)=>{e.ac("Slice",C,{starts:N?Array.from((T(),B).subarray(Number(N)>>>0,Number(O)>>>0)):[],ends:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[],axes:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[]})},941152:C=>{e.ac("Tile",C,void 0)},941204:(C,N,O)=>{e.ac("InstanceNormalization",C,{epsilon:N,format:O?"NHWC":"NCHW"})},941318:(C,N,O)=>{e.ac("InstanceNormalization",C,{epsilon:N,format:O?"NHWC":"NCHW"})},941432:C=>{e.ac("Range",C,void 0)},941485:(C,N)=>{e.ac("Einsum",C,{equation:hn(N)})},941566:(C,N,O,z,se)=>{e.ac("Pad",C,{mode:N,value:O,pads:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},941709:(C,N,O,z,se,ue)=>{e.ac("BatchNormalization",C,{epsilon:N,momentum:O,spatial:!!se,trainingMode:!!z,format:ue?"NHWC":"NCHW"})},941878:(C,N,O,z,se,ue)=>{e.ac("BatchNormalization",C,{epsilon:N,momentum:O,spatial:!!se,trainingMode:!!z,format:ue?"NHWC":"NCHW"})},942047:(C,N,O)=>{e.ac("CumSum",C,{exclusive:Number(N),reverse:Number(O)})},942144:(C,N,O)=>{e.ac("DequantizeLinear",C,{axis:N,blockSize:O})},942234:(C,N,O,z,se)=>{e.ac("GridSample",C,{align_corners:N,mode:hn(O),padding_mode:hn(z),format:se?"NHWC":"NCHW"})},942404:(C,N,O,z,se)=>{e.ac("GridSample",C,{align_corners:N,mode:hn(O),padding_mode:hn(z),format:se?"NHWC":"NCHW"})},942574:(C,N)=>{e.ac("ScatterND",C,{reduction:hn(N)})},942659:(C,N,O,z,se,ue,Se,Ue,it)=>{e.ac("Attention",C,{numHeads:N,isUnidirectional:O,maskFilterValue:z,scale:se,doRotary:ue,qkvHiddenSizes:Se?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(Ue)+Se>>>0)):[],pastPresentShareBuffer:!!it})},942931:C=>{e.ac("BiasAdd",C,void 0)},942986:C=>{e.ac("BiasSplitGelu",C,void 0)},943047:C=>{e.ac("FastGelu",C,void 0)},943103:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr,Es)=>{e.ac("Conv",C,{format:Vt?"NHWC":"NCHW",auto_pad:N,dilations:O?Array.from((T(),B).subarray(Number(O)>>>0,Number(z)>>>0)):[],group:se,kernel_shape:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],pads:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],strides:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],w_is_const:()=>!!(T(),k)[Number(on)>>>0],activation:hn(ln),activation_params:wr?Array.from((T(),K).subarray(Number(wr)>>>0,Number(Es)>>>0)):[]})},943687:C=>{e.ac("Gelu",C,void 0)},943739:(C,N,O,z,se,ue,Se,Ue,it)=>{e.ac("GroupQueryAttention",C,{numHeads:N,kvNumHeads:O,scale:z,softcap:se,doRotary:ue,rotaryInterleaved:Se,smoothSoftmax:Ue,localWindowSize:it})},943956:(C,N,O,z)=>{e.ac("LayerNormalization",C,{axis:N,epsilon:O,simplified:!!z})},944067:(C,N,O,z)=>{e.ac("LayerNormalization",C,{axis:N,epsilon:O,simplified:!!z})},944178:(C,N,O,z,se,ue)=>{e.ac("MatMulNBits",C,{k:N,n:O,accuracyLevel:z,bits:se,blockSize:ue})},944305:(C,N,O,z,se,ue)=>{e.ac("MultiHeadAttention",C,{numHeads:N,isUnidirectional:O,maskFilterValue:z,scale:se,doRotary:ue})},944464:(C,N)=>{e.ac("QuickGelu",C,{alpha:N})},944528:(C,N,O,z,se)=>{e.ac("RotaryEmbedding",C,{interleaved:!!N,numHeads:O,rotaryEmbeddingDim:z,scale:se})},944667:(C,N,O)=>{e.ac("SkipLayerNormalization",C,{epsilon:N,simplified:!!O})},944769:(C,N,O)=>{e.ac("SkipLayerNormalization",C,{epsilon:N,simplified:!!O})},944871:(C,N,O,z)=>{e.ac("GatherBlockQuantized",C,{gatherAxis:N,quantizeAxis:O,blockSize:z})},944992:C=>{e.Id(C)},945026:(C,N)=>e.Kd(Number(C),Number(N),e.$c.Nd,e.$c.errors)};function yA(C,N,O){return Kp(async()=>{await e.Gd(Number(C),Number(N),Number(O))})}function Lu(){return typeof wasmOffsetConverter<"u"}function Fu(C,N,O,z){var se=Xt();try{return Tu(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function rf(C,N,O){var z=Xt();try{return Mu(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function sf(C,N,O){var z=Xt();try{Jo(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function af(C,N){var O=Xt();try{return Bu(C,N)}catch(z){if(qt(O),z!==z+0)throw z;Yt(1,0)}}function of(C){var N=Xt();try{$h(C)}catch(O){if(qt(N),O!==O+0)throw O;Yt(1,0)}}function yy(C,N,O,z,se,ue,Se){var Ue=Xt();try{return pA(C,N,O,z,se,ue,Se)}catch(it){if(qt(Ue),it!==it+0)throw it;Yt(1,0)}}function xA(C,N){var O=Xt();try{Ko(C,N)}catch(z){if(qt(O),z!==z+0)throw z;Yt(1,0)}}function xy(C,N,O,z,se,ue){var Se=Xt();try{Gh(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function vy(C,N,O,z){var se=Xt();try{Wa(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function lf(C,N,O,z,se){var ue=Xt();try{Vh(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function da(C,N,O,z,se,ue,Se){var Ue=Xt();try{Hh(C,N,O,z,se,ue,Se)}catch(it){if(qt(Ue),it!==it+0)throw it;Yt(1,0)}}function vA(C,N,O,z,se,ue,Se){var Ue=Xt();try{ec(C,N,O,z,se,ue,Se)}catch(it){if(qt(Ue),it!==it+0)throw it;Yt(1,0)}}function nl(C,N,O,z,se,ue,Se,Ue){var it=Xt();try{tc(C,N,O,z,se,ue,Se,Ue)}catch(ht){if(qt(it),ht!==ht+0)throw ht;Yt(1,0)}}function qi(C,N,O,z,se){var ue=Xt();try{return Ru(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function ic(C,N,O,z,se,ue,Se,Ue){var it=Xt();try{Wh(C,N,O,z,se,ue,Se,Ue)}catch(ht){if(qt(it),ht!==ht+0)throw ht;Yt(1,0)}}function ws(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt){var on=Xt();try{qa(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt)}catch(ln){if(qt(on),ln!==ln+0)throw ln;Yt(1,0)}}function cf(C,N,O,z,se,ue){var Se=Xt();try{return Du(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function _y(C,N,O){var z=Xt();try{return qh(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;return Yt(1,0),0n}}function by(C,N,O,z,se,ue,Se,Ue,it){var ht=Xt();try{fA(C,N,O,z,se,ue,Se,Ue,it)}catch(Nt){if(qt(ht),Nt!==Nt+0)throw Nt;Yt(1,0)}}function Xa(C){var N=Xt();try{return Yh(C)}catch(O){if(qt(N),O!==O+0)throw O;Yt(1,0)}}function sc(C,N,O){var z=Xt();try{return Xh(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function rl(C,N){var O=Xt();try{return tf(C,N)}catch(z){if(qt(O),z!==z+0)throw z;return Yt(1,0),0n}}function zu(C,N,O,z,se){var ue=Xt();try{Jh(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function uf(C){var N=Xt();try{return Kh(C)}catch(O){if(qt(N),O!==O+0)throw O;return Yt(1,0),0n}}function il(C,N,O,z,se,ue){var Se=Xt();try{return Zo(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function ha(C,N,O,z,se,ue){var Se=Xt();try{return gA(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function Pn(C,N,O,z,se,ue,Se,Ue){var it=Xt();try{return jh(C,N,O,z,se,ue,Se,Ue)}catch(ht){if(qt(it),ht!==ht+0)throw ht;Yt(1,0)}}function Tn(C,N,O,z,se){var ue=Xt();try{return Zh(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;return Yt(1,0),0n}}function fa(C,N,O,z){var se=Xt();try{return ef(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function br(C,N,O,z){var se=Xt();try{return Mn(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function Gr(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt){var on=Xt();try{return Qu(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt)}catch(ln){if(qt(on),ln!==ln+0)throw ln;Yt(1,0)}}function Ja(C,N,O,z,se,ue,Se,Ue,it,ht,Nt){var Vt=Xt();try{AA(C,N,O,z,se,ue,Se,Ue,it,ht,Nt)}catch(on){if(qt(Vt),on!==on+0)throw on;Yt(1,0)}}function sl(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr,Es){var wA=Xt();try{mA(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr,Es)}catch(oc){if(qt(wA),oc!==oc+0)throw oc;Yt(1,0)}}function Vr(C,N,O,z){var se=Xt();try{return nc(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function Uu(C,N,O,z,se){var ue=Xt();try{return el(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function _A(C,N,O){var z=Xt();try{return bs(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function bA(C,N,O){var z=Xt();try{return ku(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function Ou(C,N,O,z){var se=Xt();try{Nu(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function ac(){if(0<ge)Ne=ac;else if(i)m?.(e),oe();else{for(var C=Re;0<C.length;)C.shift()(e);0<ge?Ne=ac:(e.calledRun=!0,S||(oe(),m?.(e)))}}return i||(Wi=await he(),ac()),e.PTR_SIZE=4,L?e:new Promise((C,N)=>{m=C,x=N})}var LP,gB,Wee=et(()=>{LP=mB,gB=globalThis.self?.name?.startsWith("em-pthread"),gB&&mB()}),s_,Bw,yB,$i,FP,qm,xB,vB,a_,_B,o_,zP,l_,UP,YI=et(()=>{qI(),s_=typeof location>"u"?void 0:location.origin,Bw=import.meta.url>"file:"&&import.meta.url<"file;",yB=()=>{{if(Bw){let n=URL;return new URL(new n("ort.bundle.min.mjs",import.meta.url).href,s_).href}return import.meta.url}},$i=yB(),FP=()=>{if($i&&!$i.startsWith("blob:"))return $i.substring(0,$i.lastIndexOf("/")+1)},qm=(n,e)=>{try{let t=e??$i;return(t?new URL(n,t):new URL(n)).origin===s_}catch{return!1}},xB=(n,e)=>{let t=e??$i;try{return(t?new URL(n,t):new URL(n)).href}catch{return}},vB=(n,e)=>`${e??"./"}${n}`,a_=async n=>{let e=await(await fetch(n,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},_B=async n=>(await import(n)).default,o_=(jee(),Lp(NP)).default,zP=async()=>{if(!$i)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(qm($i))return[void 0,o_()];let n=await a_($i);return[n,o_(n)]},l_=(Wee(),Lp(PP)).default,UP=async(n,e,t,r)=>{let i=l_&&!(n||e);if(i)if($i)i=qm($i)||r&&!t;else if(r&&!t)i=!0;else throw new Error("cannot determine the script source URL.");if(i)return[void 0,l_];{let s="ort-wasm-simd-threaded.jsep.mjs",a=n??xB(s,e),o=t&&a&&!qm(a,e),l=o?await a_(a):a??vB(s,e);return[o?l:void 0,await _B(l)]}}}),c_,Ym,$f,u_,bB,wB,EB,XI,kn,cu=et(()=>{YI(),Ym=!1,$f=!1,u_=!1,bB=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},wB=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},EB=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},XI=async n=>{if(Ym)return Promise.resolve();if($f)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(u_)throw new Error("previous call to 'initializeWebAssembly()' failed.");$f=!0;let e=n.initTimeout,t=n.numThreads;if(n.simd!==!1){if(n.simd==="relaxed"){if(!EB())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!wB())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let r=bB();t>1&&!r&&(typeof self<"u"&&self.crossOriginIsolated,n.numThreads=t=1);let i=n.wasmPaths,s=typeof i=="string"?i:void 0,a=i?.mjs,o=a?.href??a,l=i?.wasm,c=l?.href??l,d=n.wasmBinary,[h,p]=await UP(o,s,t>1,!!d||!!c),A=!1,y=[];if(e>0&&y.push(new Promise(m=>{setTimeout(()=>{A=!0,m()},e)})),y.push(new Promise((m,x)=>{let g={numThreads:t};if(d)g.wasmBinary=d,g.locateFile=_=>_;else if(c||s)g.locateFile=_=>c??s+_;else if(o&&o.indexOf("blob:")!==0)g.locateFile=_=>new URL(_,o).href;else if(h){let _=FP();_&&(g.locateFile=b=>_+b)}p(g).then(_=>{$f=!1,Ym=!0,c_=_,m(),h&&URL.revokeObjectURL(h)},_=>{$f=!1,u_=!0,x(_)})})),await Promise.race(y),A)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},kn=()=>{if(Ym&&c_)return c_;throw new Error("WebAssembly is not initialized yet.")}}),Os,Jg,wn,JI=et(()=>{cu(),Os=(n,e)=>{let t=kn(),r=t.lengthBytesUTF8(n)+1,i=t._malloc(r);return t.stringToUTF8(n,i,r),e.push(i),i},Jg=(n,e,t,r)=>{if(typeof n=="object"&&n!==null){if(t.has(n))throw new Error("Circular reference in options");t.add(n)}Object.entries(n).forEach(([i,s])=>{let a=e?e+i:i;if(typeof s=="object")Jg(s,a+".",t,r);else if(typeof s=="string"||typeof s=="number")r(a,s.toString());else if(typeof s=="boolean")r(a,s?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof s}`)})},wn=n=>{let e=kn(),t=e.stackSave();try{let r=e.PTR_SIZE,i=e.stackAlloc(2*r);e._OrtGetLastError(i,i+r);let s=Number(e.getValue(i,r===4?"i32":"i64")),a=e.getValue(i+r,"*"),o=a?e.UTF8ToString(a):"";throw new Error(`${n} ERROR_CODE: ${s}, ERROR_MESSAGE: ${o}`)}finally{e.stackRestore(t)}}}),OP,qee=et(()=>{cu(),JI(),OP=n=>{let e=kn(),t=0,r=[],i=n||{};try{if(n?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof n.logSeverityLevel!="number"||!Number.isInteger(n.logSeverityLevel)||n.logSeverityLevel<0||n.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${n.logSeverityLevel}`);if(n?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof n.logVerbosityLevel!="number"||!Number.isInteger(n.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${n.logVerbosityLevel}`);n?.terminate===void 0&&(i.terminate=!1);let s=0;return n?.tag!==void 0&&(s=Os(n.tag,r)),t=e._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,s),t===0&&wn("Can't create run options."),n?.extra!==void 0&&Jg(n.extra,"",new WeakSet,(a,o)=>{let l=Os(a,r),c=Os(o,r);e._OrtAddRunConfigEntry(t,l,c)!==0&&wn(`Can't set a run config entry: ${a} - ${o}.`)}),[t,r]}catch(s){throw t!==0&&e._OrtReleaseRunOptions(t),r.forEach(a=>e._free(a)),s}}}),IB,CB,SB,Gf,BB,$P,Yee=et(()=>{cu(),JI(),IB=n=>{switch(n){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${n}`)}},CB=n=>{switch(n){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${n}`)}},SB=n=>{n.extra||(n.extra={}),n.extra.session||(n.extra.session={});let e=n.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),n.executionProviders&&n.executionProviders.some(t=>(typeof t=="string"?t:t.name)==="webgpu")&&(n.enableMemPattern=!1)},Gf=(n,e,t,r)=>{let i=Os(e,r),s=Os(t,r);kn()._OrtAddSessionConfigEntry(n,i,s)!==0&&wn(`Can't set a session config entry: ${e} - ${t}.`)},BB=async(n,e,t)=>{let r=e.executionProviders;for(let i of r){let s=typeof i=="string"?i:i.name,a=[];switch(s){case"webnn":if(s="WEBNN",typeof i!="string"){let h=i?.deviceType;h&&Gf(n,"deviceType",h,t)}break;case"webgpu":if(s="JS",typeof i!="string"){let h=i;if(h?.preferredLayout){if(h.preferredLayout!=="NCHW"&&h.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${h.preferredLayout}`);Gf(n,"preferredLayout",h.preferredLayout,t)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${s}`)}let o=Os(s,t),l=a.length,c=0,d=0;if(l>0){c=kn()._malloc(l*kn().PTR_SIZE),t.push(c),d=kn()._malloc(l*kn().PTR_SIZE),t.push(d);for(let h=0;h<l;h++)kn().setValue(c+h*kn().PTR_SIZE,a[h][0],"*"),kn().setValue(d+h*kn().PTR_SIZE,a[h][1],"*")}await kn()._OrtAppendExecutionProvider(n,o,c,d,l)!==0&&wn(`Can't append execution provider: ${s}.`)}},$P=async n=>{let e=kn(),t=0,r=[],i=n||{};SB(i);try{let s=IB(i.graphOptimizationLevel??"all"),a=CB(i.executionMode??"sequential"),o=typeof i.logId=="string"?Os(i.logId,r):0,l=i.logSeverityLevel??2;if(!Number.isInteger(l)||l<0||l>4)throw new Error(`log severity level is not valid: ${l}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw new Error(`log verbosity level is not valid: ${c}`);let d=typeof i.optimizedModelFilePath=="string"?Os(i.optimizedModelFilePath,r):0;if(t=e._OrtCreateSessionOptions(s,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,l,c,d),t===0&&wn("Can't create session options."),i.executionProviders&&await BB(t,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);Gf(t,"enableGraphCapture",i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[h,p]of Object.entries(i.freeDimensionOverrides)){if(typeof h!="string")throw new Error(`free dimension override name must be a string: ${h}`);if(typeof p!="number"||!Number.isInteger(p)||p<0)throw new Error(`free dimension override value must be a non-negative integer: ${p}`);let A=Os(h,r);e._OrtAddFreeDimensionOverride(t,A,p)!==0&&wn(`Can't set a free dimension override: ${h} - ${p}.`)}return i.extra!==void 0&&Jg(i.extra,"",new WeakSet,(h,p)=>{Gf(t,h,p,r)}),[t,r]}catch(s){throw t!==0&&e._OrtReleaseSessionOptions(t)!==0&&wn("Can't release session options."),r.forEach(a=>e._free(a)),s}}}),Pc,ho,Lc,ey,Kg,KI,ZI,Mw,Lt=et(()=>{Pc=n=>{switch(n){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${n}`)}},ho=n=>{switch(n){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${n}`)}},Lc=(n,e)=>{let t=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][n],r=typeof e=="number"?e:e.reduce((i,s)=>i*s,1);return t>0?Math.ceil(r*t):void 0},ey=n=>{switch(n){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${n}`)}},Kg=n=>{switch(n){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${n}`)}},KI=n=>n==="float32"||n==="float16"||n==="int32"||n==="int64"||n==="uint32"||n==="uint8"||n==="bool"||n==="uint4"||n==="int4",ZI=n=>n==="float32"||n==="float16"||n==="int32"||n==="int64"||n==="uint32"||n==="uint64"||n==="int8"||n==="uint8"||n==="bool"||n==="uint4"||n==="int4",Mw=n=>{switch(n){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${n}`)}}}),eC,GP=et(()=>{qI(),eC=async n=>{if(typeof n=="string"){let e=await fetch(n);if(!e.ok)throw new Error(`failed to load external data file: ${n}`);let t=e.headers.get("Content-Length"),r=t?parseInt(t,10):0;if(r<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${n}, no response body.`);let i=e.body.getReader(),s;try{s=new ArrayBuffer(r)}catch(o){if(o instanceof RangeError){let l=Math.ceil(r/65536);s=new WebAssembly.Memory({initial:l,maximum:l}).buffer}else throw o}let a=0;for(;;){let{done:o,value:l}=await i.read();if(o)break;let c=l.byteLength;new Uint8Array(s,a,c).set(l),a+=c}return new Uint8Array(s,0,r)}}else return n instanceof Blob?new Uint8Array(await n.arrayBuffer()):n instanceof Uint8Array?n:new Uint8Array(n)}}),Xee,MB,TB,RB,tC,DB,un,ko=et(()=>{Lt(),Xee=["V","I","W","E","F"],MB=(n,e)=>{},tC=(n,e)=>{TB=n,RB=e},DB=(n,e)=>{let t=Kg(n),r=Kg(TB);t>=r&&MB(t,typeof e=="function"?e():e)},un=(...n)=>{RB&&DB(...n)}}),kB,th,Le,Zg,VP,HP,jP,jt=et(()=>{kB=class{static calcMatMulShape(n,e){return n[1]!==e[0]?void 0:[n[0],e[1]]}},th=class{static calcShape(n,e,t=!1){let r=n.length,i=e.length;if(r===0)return e;if(i===0)return n;let s=Math.max(n.length,e.length),a=new Array(s);if(t){if(r<2||i<2)return;let o=kB.calcMatMulShape([n[r-2],n[r-1]],[e[i-2],e[i-1]]);if(o===void 0)return;[a[s-2],a[s-1]]=o}for(let o=t?3:1;o<=s;o++){let l=r-o<0?1:n[r-o],c=i-o<0?1:e[i-o];if(l!==c&&l>1&&c>1)return;let d=Math.max(l,c);if(l&&c)a[s-o]=Math.max(l,c);else{if(d>1)return;a[s-o]=0}}return a}static isValidBroadcast(n,e){let t=n.length,r=e.length;if(t>r)return!1;for(let i=1;i<=t;i++)if(n[t-i]!==1&&n[t-i]!==e[r-i])return!1;return!0}},Le=class Ig{static size(e){return Ig.getSizeFromDimensionRange(e,0,e.length)}static convertShape(e,t=4){let r=e.length;if(r===0)return[];let i=new Array(r),s=r-1;for(;s>=0;){if(e[s]%t===0){i[s]=e[s]/t;break}if(t%e[s]!==0)throw new Error("cannot convert shape");i[s]=1,t/=e[s],s--}for(s--;s>=0;s--)i[s]=e[s];return i}static sizeFromDimension(e,t){if(t<0||t>e.length)throw new Error(`invalid dimension of ${t} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return Ig.getSizeFromDimensionRange(e,t,e.length)}static sizeToDimension(e,t){if(t<0||t>e.length)throw new Error(`invalid dimension of ${t} for sizeToDimension as Tensor has ${e.length} dimensions.`);return Ig.getSizeFromDimensionRange(e,0,t)}static getSizeFromDimensionRange(e,t,r){let i=1;for(let s=t;s<r;s++){if(e[s]<0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains negative values in them.");i*=Number(e[s])}return i}static computeStrides(e){let t=e.length;if(t===0)return[];if(t===1)return[1];let r=new Array(t);r[t-1]=1,r[t-2]=e[t-1];for(let i=t-3;i>=0;--i)r[i]=r[i+1]*e[i+1];return r}static normalizeAxis(e,t){if(e<-t&&e>=t)throw new Error("unsupported axis for this operation.");return e<0?e+t:e}static normalizeAxes(e,t){return e.map(r=>this.normalizeAxis(r,t??e.length))}static sortBasedOnPerm(e,t){return t?t.map(r=>e[r]):e.slice().reverse()}static padShape(e,t){let r=e.length;return e.map((i,s)=>i+t[s]+t[s+r])}static areEqual(e,t){return e.length!==t.length?!1:e.every((r,i)=>r===t[i])}},Zg=class lp{static adjustPoolAttributes(e,t,r,i,s,a){if(!e&&r.length!==t.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let o=0;o<t.length-2;o++)o>=r.length?r.push(t[o+2]):r[o]=t[o+2];for(let o=0;o<r.length;o++)if(o<i.length){if(i[o]<0)throw new Error("strides should be greater than or equal to 1")}else i.push(1);for(let o=0;o<r.length;o++)if(o<s.length){if(s[o]<0)throw new Error("dilations should be greater than or equal to 1")}else s.push(1);for(let o=0;o<r.length*2;o++)if(o<a.length){if(a[o]<0)throw new Error("pad should be greater than or equal to 1")}else a.push(0);for(let o=0;o<r.length;o++){if(r[o]<=0)throw new Error("kernel shapes need to be greater than 0");if(a[o]>=r[o]||a[o+r.length]>=r[o])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,t,r,i,s,a,o){if(o){if(s.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(t.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(i.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let l=0;l<e.length-2;l++)lp.adjustPadAndReturnShape(e[l+(a?1:2)],t[l],r[l],i[l],s,l,l+e.length-2,o)}}static computePoolOutputShape(e,t,r,i,s,a,o){if(t.length<=0)throw new Error("input shape must be of size greater than 0");let l=[t[0],t[1]];return lp.computeShapeHelper(e,t,l,r,i,s,a,o),l}static computeConvOutputShape(e,t,r,i,s,a,o){if(e.length<=0||t.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let l=[e[0],t[0]];return lp.computeShapeHelper(!1,e,l,r,i,s,a,o),l}static computeShapeHelper(e,t,r,i,s,a,o,l){if(e)for(let c=0;c<t.length-2;c++)r.push(1);else for(let c=0;c<t.length-2;c++)r.push(lp.adjustPadAndReturnShape(t[c+2],i[c],s[c],a[c],o,c,c+t.length-2,l))}static adjustPadAndReturnShape(e,t,r,i,s,a,o,l){let c=r*(i-1)+1;if(l&&l!=="NOTSET")switch(l){case"VALID":return s[a]=0,s[o]=0,Math.floor((e-c)/t+1);case"SAME_LOWER":case"SAME_UPPER":if(r!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let d=((e+t-1)/t-1)*t+i-e;return s[a]=Math.floor(l==="SAME_LOWER"?(d+1)/2:d/2),s[o]=d-s[a],Math.floor((e+d-i)/t+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((e+s[a]+s[o]-c)/t+1)}},VP=class{static getShapeOfGemmResult(n,e,t,r,i){if(n.length!==2||t.length!==2)throw new Error("shape need to be of size 2");let s,a,o;e?(s=n[1],a=n[0]):(s=n[0],a=n[1]);let l=-1;if(r?(o=t[0],l=1):(o=t[1],l=0),t[l]!==a)throw new Error("dimension mismatch");if(s<=0||o<=0||a<=0)throw new Error("invalid shape specified");if(i&&!th.isValidBroadcast(i,[s,o]))throw new Error("gemm: invalid bias shape for broadcast");return[s,o,a]}},HP=-34028234663852886e22,jP=34028234663852886e22}),nC,WP=et(()=>{Lt(),nC=(n,e)=>new(ey(e))(n)}),d_,Tw,h_,NB,f_,QB,p_,A_,m_,PB,qP,Jee=et(()=>{Lt(),ko(),d_=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),Tw=(n,e)=>{if(e==="int32")return n;let t=d_.get(e);if(!t)throw new Error(`WebNN backend does not support data type: ${e}`);let r=t/8;if(n.byteLength%r!==0)throw new Error(`Invalid Uint8Array length - must be a multiple of ${r}.`);let i=n.byteLength/r,s=new(ey(e))(n.buffer,n.byteOffset,i);switch(e){case"int64":case"uint64":{let a=new Int32Array(i);for(let o=0;o<i;o++){let l=s[o];if(l>2147483647n||l<-2147483648n)throw new Error("Can not convert int64 data to int32 - value out of range.");a[o]=Number(l)}return new Uint8Array(a.buffer)}case"int8":case"uint8":case"uint32":{if(e==="uint32"&&s.some(o=>o>2147483647))throw new Error("Can not convert uint32 data to int32 - value out of range.");let a=Int32Array.from(s,Number);return new Uint8Array(a.buffer)}default:throw new Error(`Unsupported data conversion from ${e} to 'int32'`)}},h_=(n,e)=>{if(e==="int32")return n;if(n.byteLength%4!==0)throw new Error("Invalid Uint8Array length - must be a multiple of 4 (int32).");let t=n.byteLength/4,r=new Int32Array(n.buffer,n.byteOffset,t);switch(e){case"int64":{let i=BigInt64Array.from(r,BigInt);return new Uint8Array(i.buffer)}case"uint64":{if(r.some(s=>s<0))throw new Error("Can not convert int32 data to uin64 - negative value found.");let i=BigUint64Array.from(r,BigInt);return new Uint8Array(i.buffer)}case"int8":{if(r.some(s=>s<-128||s>127))throw new Error("Can not convert int32 data to int8 - value out of range.");let i=Int8Array.from(r,Number);return new Uint8Array(i.buffer)}case"uint8":{if(r.some(i=>i<0||i>255))throw new Error("Can not convert int32 data to uint8 - value out of range.");return Uint8Array.from(r,Number)}case"uint32":{if(r.some(s=>s<0))throw new Error("Can not convert int32 data to uint32 - negative value found.");let i=Uint32Array.from(r,Number);return new Uint8Array(i.buffer)}default:throw new Error(`Unsupported data conversion from 'int32' to ${e}`)}},NB=1,f_=()=>NB++,QB=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),p_=(n,e)=>{let t=d_.get(n);if(!t)throw new Error(`WebNN backend does not support data type: ${n}`);return e.length>0?Math.ceil(e.reduce((r,i)=>r*i)*t/8):0},A_=class{constructor(n){this.isDataConverted=!1;let{sessionId:e,context:t,tensor:r,dataType:i,shape:s,fallbackDataType:a}=n;this.sessionId=e,this.mlContext=t,this.mlTensor=r,this.dataType=i,this.tensorShape=s,this.fallbackDataType=a}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return p_(this.dataType,this.tensorShape)}destroy(){un("verbose",()=>"[WebNN] TensorWrapper.destroy"),this.mlTensor.destroy()}write(n){this.mlContext.writeTensor(this.mlTensor,n)}async read(n){if(this.fallbackDataType){let e=await this.mlContext.readTensor(this.mlTensor),t=h_(new Uint8Array(e),this.dataType);if(n){(n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)).set(t);return}else return t.buffer}else return n?this.mlContext.readTensor(this.mlTensor,n):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(n,e,t){return this.mlContext===n&&this.dataType===e&&this.tensorShape.length===t.length&&this.tensorShape.every((r,i)=>r===t[i])}setIsDataConverted(n){this.isDataConverted=n}},m_=class{constructor(n,e){this.tensorManager=n,this.wrapper=e}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(n,e,t,r){let i=this.tensorManager.getMLContext(n),s=this.tensorManager.getMLOpSupportLimits(n),a;if(!s?.input.dataTypes.includes(e)){if(a=QB.get(e),!a||s?.input.dataTypes.includes(a))throw new Error(`WebNN backend does not support data type: ${e}`);un("verbose",()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${e} to ${a}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(i,e,t))return this.wrapper.tensor;if(r){if(this.wrapper.byteLength!==p_(e,t))throw new Error("Unable to copy data to tensor with different size.");this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let o=typeof MLTensorUsage>"u"?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(n,e,t,o,!0,!0,a),r&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(n){let e=n;if(this.wrapper){if(this.wrapper.fallbackType)if(this.wrapper.fallbackType==="int32")e=Tw(n,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw new Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(n.byteLength===this.wrapper.byteLength){this.wrapper.write(e);return}else un("verbose",()=>"Data size does not match tensor size. Releasing tensor."),this.releaseTensor()}this.activeUpload?this.activeUpload.set(e):this.activeUpload=new Uint8Array(e)}async download(n){if(this.activeUpload){let e=this.wrapper?.isDataConverted?h_(this.activeUpload,this.wrapper?.type):this.activeUpload;if(n){n instanceof ArrayBuffer?new Uint8Array(n).set(e):new Uint8Array(n.buffer,n.byteOffset,n.byteLength).set(e);return}else return e.buffer}if(!this.wrapper)throw new Error("Tensor has not been created.");return n?this.wrapper.read(n):this.wrapper.read()}},PB=class{constructor(n){this.backend=n,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(n){let e=this.backend.getMLContext(n);if(!e)throw new Error("MLContext not found for session.");return e}getMLOpSupportLimits(n){return this.backend.getMLOpSupportLimits(n)}reserveTensorId(){let n=f_();return this.tensorTrackersById.set(n,new m_(this)),n}releaseTensorId(n){let e=this.tensorTrackersById.get(n);e&&(this.tensorTrackersById.delete(n),e.tensorWrapper&&this.releaseTensor(e.tensorWrapper))}async ensureTensor(n,e,t,r,i){un("verbose",()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${e}, dataType: ${t}, shape: ${r}, copyOld: ${i}}`);let s=this.tensorTrackersById.get(e);if(!s)throw new Error("Tensor not found.");return s.ensureTensor(n,t,r,i)}upload(n,e){let t=this.tensorTrackersById.get(n);if(!t)throw new Error("Tensor not found.");t.upload(e)}async download(n,e){un("verbose",()=>`[WebNN] TensorManager.download {tensorId: ${n}, dstBuffer: ${e?.byteLength}}`);let t=this.tensorTrackersById.get(n);if(!t)throw new Error("Tensor not found.");return t.download(e)}releaseTensorsForSession(n){for(let e of this.freeTensors)e.sessionId===n&&e.destroy();this.freeTensors=this.freeTensors.filter(e=>e.sessionId!==n)}registerTensor(n,e,t,r){let i=this.getMLContext(n),s=f_(),a=new A_({sessionId:n,context:i,tensor:e,dataType:t,shape:r});return this.tensorTrackersById.set(s,new m_(this,a)),this.externalTensors.add(a),s}async getCachedTensor(n,e,t,r,i,s,a){let o=this.getMLContext(n);for(let[c,d]of this.freeTensors.entries())if(d.canReuseTensor(o,e,t)){un("verbose",()=>`[WebNN] Reusing tensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${t}`);let h=this.freeTensors.splice(c,1)[0];return h.sessionId=n,h}un("verbose",()=>`[WebNN] MLContext.createTensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${t}}`);let l=await o.createTensor({dataType:a??e,shape:t,dimensions:t,usage:r,writable:i,readable:s});return new A_({sessionId:n,context:o,tensor:l,dataType:e,shape:t,fallbackDataType:a})}releaseTensor(n){this.externalTensors.has(n)&&this.externalTensors.delete(n),this.freeTensors.push(n)}},qP=(...n)=>new PB(...n)}),Vf,LB,YP,Kee=et(()=>{Lt(),cu(),WP(),Jee(),ko(),Vf=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),LB=(n,e)=>{if(n===e)return!0;if(n===void 0||e===void 0)return!1;let t=Object.keys(n).sort(),r=Object.keys(e).sort();return t.length===r.length&&t.every((i,s)=>i===r[s]&&n[i]===e[i])},YP=class{constructor(n){this.tensorManager=qP(this),this.mlContextBySessionId=new Map,this.sessionIdsByMLContext=new Map,this.mlContextCache=[],this.sessionGraphInputs=new Map,this.sessionGraphOutputs=new Map,this.temporaryGraphInputs=[],this.temporaryGraphOutputs=[],this.temporarySessionTensorIds=new Map,this.mlOpSupportLimitsBySessionId=new Map,tC(n.logLevel,!!n.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(n){un("verbose",()=>`[WebNN] onRunStart {sessionId: ${n}}`),this.activeSessionId=n}onRunEnd(n){un("verbose",()=>`[WebNN] onRunEnd {sessionId: ${n}}`);let e=this.temporarySessionTensorIds.get(n);if(e){for(let t of e)un("verbose",()=>`[WebNN] releasing temporary tensor {tensorId: ${t}}`),this.tensorManager.releaseTensorId(t);this.temporarySessionTensorIds.delete(n),this.activeSessionId=void 0}}async createMLContext(n){if(n instanceof GPUDevice){let t=this.mlContextCache.findIndex(r=>r.gpuDevice===n);if(t!==-1)return this.mlContextCache[t].mlContext;{let r=await navigator.ml.createContext(n);return this.mlContextCache.push({gpuDevice:n,mlContext:r}),r}}else if(n===void 0){let t=this.mlContextCache.findIndex(r=>r.options===void 0&&r.gpuDevice===void 0);if(t!==-1)return this.mlContextCache[t].mlContext;{let r=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:r}),r}}let e=this.mlContextCache.findIndex(t=>LB(t.options,n));if(e!==-1)return this.mlContextCache[e].mlContext;{let t=await navigator.ml.createContext(n);return this.mlContextCache.push({options:n,mlContext:t}),t}}registerMLContext(n,e){this.mlContextBySessionId.set(n,e);let t=this.sessionIdsByMLContext.get(e);t||(t=new Set,this.sessionIdsByMLContext.set(e,t)),t.add(n),this.mlOpSupportLimitsBySessionId.has(n)||this.mlOpSupportLimitsBySessionId.set(n,e.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(n,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(n,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(n){this.sessionGraphInputs.delete(n),this.sessionGraphOutputs.delete(n);let e=this.mlContextBySessionId.get(n);if(!e)return;this.tensorManager.releaseTensorsForSession(n),this.mlContextBySessionId.delete(n),this.mlOpSupportLimitsBySessionId.delete(n);let t=this.sessionIdsByMLContext.get(e);if(t.delete(n),t.size===0){this.sessionIdsByMLContext.delete(e);let r=this.mlContextCache.findIndex(i=>i.mlContext===e);r!==-1&&this.mlContextCache.splice(r,1)}}getMLContext(n){return this.mlContextBySessionId.get(n)}getMLOpSupportLimits(n){return this.mlOpSupportLimitsBySessionId.get(n)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(n){un("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${n}}`),this.tensorManager.releaseTensorId(n)}async ensureTensor(n,e,t,r,i){let s=Vf.get(t);if(!s)throw new Error(`Unsupported ONNX data type: ${t}`);return this.tensorManager.ensureTensor(n??this.currentSessionId,e,s,r,i)}async createTemporaryTensor(n,e,t){un("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${e}, shape: ${t}}`);let r=Vf.get(e);if(!r)throw new Error(`Unsupported ONNX data type: ${e}`);let i=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(n,i,r,t,!1);let s=this.temporarySessionTensorIds.get(n);return s?s.push(i):this.temporarySessionTensorIds.set(n,[i]),i}uploadTensor(n,e){if(!kn().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");un("verbose",()=>`[WebNN] uploadTensor {tensorId: ${n}, data: ${e.byteLength}}`),this.tensorManager.upload(n,e)}async downloadTensor(n,e){return this.tensorManager.download(n,e)}createMLTensorDownloader(n,e){return async()=>{let t=await this.tensorManager.download(n);return nC(t,e)}}registerMLTensor(n,e,t,r){let i=Vf.get(t);if(!i)throw new Error(`Unsupported ONNX data type: ${t}`);let s=this.tensorManager.registerTensor(n,e,i,r);return un("verbose",()=>`[WebNN] registerMLTensor {tensor: ${e}, dataType: ${i}, dimensions: ${r}} -> {tensorId: ${s}}`),s}registerMLConstant(n,e,t,r,i,s,a=!1){if(!s)throw new Error("External mounted files are not available.");let o=n;n.startsWith("./")&&(o=n.substring(2));let l=s.get(o);if(!l)throw new Error(`File with name ${o} not found in preloaded files.`);if(e+t>l.byteLength)throw new Error("Out of bounds: data offset and length exceed the external file data size.");let c=l.slice(e,e+t).buffer,d;switch(i.dataType){case"float32":d=new Float32Array(c);break;case"float16":d=typeof Float16Array<"u"&&Float16Array.from?new Float16Array(c):new Uint16Array(c);break;case"int32":d=new Int32Array(c);break;case"uint32":d=new Uint32Array(c);break;case"int64":if(a){let h=Tw(new Uint8Array(c),"int64");d=new Int32Array(h.buffer),i.dataType="int32"}else d=new BigInt64Array(c);break;case"uint64":d=new BigUint64Array(c);break;case"int8":d=new Int8Array(c);break;case"int4":case"uint4":case"uint8":d=new Uint8Array(c);break;default:throw new Error(`Unsupported data type: ${i.dataType} in creating WebNN Constant from external data.`)}return un("verbose",()=>`[WebNN] registerMLConstant {dataType: ${i.dataType}, shape: ${i.shape}}} ${a?"(Note: it was int64 data type and registered to int32 as workaround)":""}`),r.constant(i,d)}registerGraphInput(n){this.temporaryGraphInputs.push(n)}registerGraphOutput(n){this.temporaryGraphOutputs.push(n)}isGraphInput(n,e){let t=this.sessionGraphInputs.get(n);return t?t.includes(e):!1}isGraphOutput(n,e){let t=this.sessionGraphOutputs.get(n);return t?t.includes(e):!1}isGraphInputOutputTypeSupported(n,e,t=!0){let r=Vf.get(Pc(e)),i=this.mlOpSupportLimitsBySessionId.get(n);return typeof r>"u"?!1:t?!!i?.input.dataTypes.includes(r):!!i?.output.dataTypes.includes(r)}flush(){}}}),rC=et(()=>{}),g_,Xm,Jm,FB,zB,y_,Rw,UB,XP,Zee=et(()=>{ko(),rC(),g_=new Map([[64,250],[128,200],[256,200],[512,200],[2048,230],[4096,200],[8192,50],[16384,50],[32768,50],[65536,50],[131072,50],[262144,50],[524288,50],[1048576,50],[2097152,30],[4194304,20],[8388608,10],[12582912,10],[16777216,10],[26214400,15],[33554432,22],[44236800,2],[58982400,6],[67108864,6],[134217728,6],[167772160,6]]),Xm=[],Jm=n=>Math.ceil(Number(n)/16)*16,FB=n=>{for(let e=0;e<Xm.length;e++){let t=Xm[e];if(n<=t)return t}return Math.ceil(n/16)*16},zB=1,y_=()=>zB++,Rw=async(n,e,t,r)=>{let i=Jm(t),s=n.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});try{let a=n.getCommandEncoder();n.endComputePass(),a.copyBufferToBuffer(e,0,s,0,i),n.flush(),await s.mapAsync(GPUMapMode.READ);let o=s.getMappedRange();if(r){let l=r();return l.set(new Uint8Array(o,0,t)),l}else return new Uint8Array(o.slice(0,t))}finally{s.destroy()}},UB=class{constructor(n){this.backend=n,this.storageCache=new Map,this.freeBuffers=new Map,this.freeUniformBuffers=new Map,this.buffersPending=[],this.capturedPendingBuffers=new Map;for(let[e]of g_)Xm.push(e),this.freeBuffers.set(e,[]),this.freeUniformBuffers.set(e,[]);this.sessionCount=0}upload(n,e){let t=e.buffer,r=e.byteOffset,i=e.byteLength,s=Jm(i),a=this.storageCache.get(n);if(!a)throw new Error("gpu data for uploading does not exist");if(Number(a.originalSize)!==i)throw new Error(`inconsistent data size. gpu data size=${a.originalSize}, data size=${i}`);let o=this.backend.device.createBuffer({mappedAtCreation:!0,size:s,usage:GPUBufferUsage.MAP_WRITE|GPUBufferUsage.COPY_SRC}),l=o.getMappedRange();new Uint8Array(l).set(new Uint8Array(t,r,i)),o.unmap();let c=this.backend.device.createCommandEncoder();c.copyBufferToBuffer(o,0,a.gpuData.buffer,0,s),this.backend.device.queue.submit([c.finish()]),o.destroy(),un("verbose",()=>`[WebGPU] GpuDataManager.upload(id=${n})`)}memcpy(n,e){let t=this.storageCache.get(n);if(!t)throw new Error("source gpu data for memcpy does not exist");let r=this.storageCache.get(e);if(!r)throw new Error("destination gpu data for memcpy does not exist");if(t.originalSize!==r.originalSize)throw new Error("inconsistent source and destination gpu data size");let i=Jm(t.originalSize),s=this.backend.getCommandEncoder();this.backend.endComputePass(),s.copyBufferToBuffer(t.gpuData.buffer,0,r.gpuData.buffer,0,i)}registerExternalBuffer(n,e,t){let r;if(t){if(r=t[0],n===t[1])return un("verbose",()=>`[WebGPU] GpuDataManager.registerExternalBuffer(size=${e}) => id=${r}, buffer is the same, skip.`),r;if(this.backend.capturedCommandList.has(this.backend.currentSessionId))throw new Error(`Registering a different external buffer under graph capture mode is not supported yet.
|
|
12826
|
+
`))[0]=="Error"&&z.shift(),sA(z);for(var se=3;z[se]&&Kl(z[se])!=C;)++se;for(C=0;C<O&&z[C+se];++C)(T(),B)[N+4*C>>>2>>>0]=Kl(z[C+se]);return C}var Rh,Dh={},Iu=()=>{if(!Rh){var C,N={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"};for(C in Dh)Dh[C]===void 0?delete N[C]:N[C]=Dh[C];var O=[];for(C in N)O.push(`${C}=${N[C]}`);Rh=O}return Rh};function jo(C,N){if(i)return F(19,1,C,N);C>>>=0,N>>>=0;var O,z=0,se=0;for(O of Iu()){var ue=N+z;(T(),W)[C+se>>>2>>>0]=ue,z+=pn(O,ue,1/0)+1,se+=4}return 0}function aA(C,N){if(i)return F(20,1,C,N);C>>>=0,N>>>=0;var O=Iu();for(var z of((T(),W)[C>>>2>>>0]=O.length,C=0,O))C+=an(z)+1;return(T(),W)[N>>>2>>>0]=C,0}function kh(C){return i?F(21,1,C):52}function Nh(C,N,O,z){return i?F(22,1,C,N,O,z):52}function Qh(C,N,O,z){return i?F(23,1,C,N,O,z):70}var oA=[null,[],[]];function Ph(C,N,O,z){if(i)return F(24,1,C,N,O,z);N>>>=0,O>>>=0,z>>>=0;for(var se=0,ue=0;ue<O;ue++){var Se=(T(),W)[N>>>2>>>0],Ue=(T(),W)[N+4>>>2>>>0];N+=8;for(var it=0;it<Ue;it++){var ht=C,Nt=(T(),H)[Se+it>>>0],Vt=oA[ht];Nt===0||Nt===10?((ht===1?w:I)(dn(Vt)),Vt.length=0):Vt.push(Nt)}se+=Ue}return(T(),W)[z>>>2>>>0]=se,0}function Wo(C){return C>>>0}i||(function(){for(var C=e.numThreads-1;C--;)le();Re.push(async()=>{var N=(async function(){if(!i)return Promise.all(ee.map(Y))})();ge++,await N,--ge==0&&Ne&&(N=Ne,Ne=null,N())})})(),i||(Ce=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),G()),e.wasmBinary&&(p=e.wasmBinary),e.stackSave=()=>Xt(),e.stackRestore=C=>qt(C),e.stackAlloc=C=>Uh(C),e.setValue=function(C,N,O="i8"){switch(O.endsWith("*")&&(O="*"),O){case"i1":case"i8":(T(),k)[C>>>0]=N;break;case"i16":(T(),Q)[C>>>1>>>0]=N;break;case"i32":(T(),B)[C>>>2>>>0]=N;break;case"i64":(T(),$)[C>>>3>>>0]=BigInt(N);break;case"float":(T(),K)[C>>>2>>>0]=N;break;case"double":(T(),X)[C>>>3>>>0]=N;break;case"*":(T(),W)[C>>>2>>>0]=N;break;default:Ae(`invalid type for setValue: ${O}`)}},e.getValue=function(C,N="i8"){switch(N.endsWith("*")&&(N="*"),N){case"i1":case"i8":return(T(),k)[C>>>0];case"i16":return(T(),Q)[C>>>1>>>0];case"i32":return(T(),B)[C>>>2>>>0];case"i64":return(T(),$)[C>>>3>>>0];case"float":return(T(),K)[C>>>2>>>0];case"double":return(T(),X)[C>>>3>>>0];case"*":return(T(),W)[C>>>2>>>0];default:Ae(`invalid type for getValue: ${N}`)}},e.UTF8ToString=hn,e.stringToUTF8=pn,e.lengthBytesUTF8=an;var lA,cA,Cu,Qi,qo,ja,Yo,uA,Zl,Lh,Fh,Su,Yt,Xo,zh,qt,Uh,Xt,dA,Oh,hA,vi,Jo,Bu,$h,Gh,Vh,Mu,fA,pA,Wa,Tu,Ko,Ru,Hh,ec,qa,Du,jh,tc,Wh,qh,Yh,Xh,Jh,Kh,bs,ku,Nu,AA,mA,Zo,gA,Zh,ef,Tn,Qu,nc,el,tf,Pu,tl,rc,Ya,Wi,gy=[re,Ee,We,tr,No,ys,Wl,Ur,xs,sa,Oa,$a,ql,Ga,ki,Qo,nA,rA,iA,jo,aA,kh,Nh,Qh,Ph],nf={929356:(C,N,O,z,se)=>{if(e===void 0||!e.Zc)return 1;if((C=hn(Number(C>>>0))).startsWith("./")&&(C=C.substring(2)),!(C=e.Zc.get(C)))return 2;if(N=Number(N>>>0),O=Number(O>>>0),z=Number(z>>>0),N+O>C.byteLength)return 3;try{let ue=C.subarray(N,N+O);switch(se){case 0:(T(),H).set(ue,z>>>0);break;case 1:e.Xd?e.Xd(z,ue):e.Ld(z,ue);break;default:return 4}return 0}catch{return 4}},930180:(C,N,O)=>{e.xd(C,(T(),H).subarray(N>>>0,N+O>>>0))},930244:()=>e.Zd(),930286:C=>{e.vd(C)},930323:()=>{e.Ed()},930354:()=>{e.Fd()},930383:()=>{e.Jd()},930408:C=>e.Dd(C),930441:C=>e.Hd(C),930473:(C,N,O)=>{e.jd(Number(C),Number(N),Number(O),!0)},930536:(C,N,O)=>{e.jd(Number(C),Number(N),Number(O))},930593:()=>typeof wasmOffsetConverter<"u",930650:C=>{e.ac("Abs",C,void 0)},930701:C=>{e.ac("Neg",C,void 0)},930752:C=>{e.ac("Floor",C,void 0)},930805:C=>{e.ac("Ceil",C,void 0)},930857:C=>{e.ac("Reciprocal",C,void 0)},930915:C=>{e.ac("Sqrt",C,void 0)},930967:C=>{e.ac("Exp",C,void 0)},931018:C=>{e.ac("Erf",C,void 0)},931069:C=>{e.ac("Sigmoid",C,void 0)},931124:(C,N,O)=>{e.ac("HardSigmoid",C,{alpha:N,beta:O})},931203:C=>{e.ac("Log",C,void 0)},931254:C=>{e.ac("Sin",C,void 0)},931305:C=>{e.ac("Cos",C,void 0)},931356:C=>{e.ac("Tan",C,void 0)},931407:C=>{e.ac("Asin",C,void 0)},931459:C=>{e.ac("Acos",C,void 0)},931511:C=>{e.ac("Atan",C,void 0)},931563:C=>{e.ac("Sinh",C,void 0)},931615:C=>{e.ac("Cosh",C,void 0)},931667:C=>{e.ac("Asinh",C,void 0)},931720:C=>{e.ac("Acosh",C,void 0)},931773:C=>{e.ac("Atanh",C,void 0)},931826:C=>{e.ac("Tanh",C,void 0)},931878:C=>{e.ac("Not",C,void 0)},931929:(C,N,O)=>{e.ac("Clip",C,{min:N,max:O})},931998:C=>{e.ac("Clip",C,void 0)},932050:(C,N)=>{e.ac("Elu",C,{alpha:N})},932108:C=>{e.ac("Gelu",C,void 0)},932160:C=>{e.ac("Relu",C,void 0)},932212:(C,N)=>{e.ac("LeakyRelu",C,{alpha:N})},932276:(C,N)=>{e.ac("ThresholdedRelu",C,{alpha:N})},932346:(C,N)=>{e.ac("Cast",C,{to:N})},932404:C=>{e.ac("Add",C,void 0)},932455:C=>{e.ac("Sub",C,void 0)},932506:C=>{e.ac("Mul",C,void 0)},932557:C=>{e.ac("Div",C,void 0)},932608:C=>{e.ac("Pow",C,void 0)},932659:C=>{e.ac("Equal",C,void 0)},932712:C=>{e.ac("Greater",C,void 0)},932767:C=>{e.ac("GreaterOrEqual",C,void 0)},932829:C=>{e.ac("Less",C,void 0)},932881:C=>{e.ac("LessOrEqual",C,void 0)},932940:(C,N,O,z,se)=>{e.ac("ReduceMean",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933115:(C,N,O,z,se)=>{e.ac("ReduceMax",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933289:(C,N,O,z,se)=>{e.ac("ReduceMin",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933463:(C,N,O,z,se)=>{e.ac("ReduceProd",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933638:(C,N,O,z,se)=>{e.ac("ReduceSum",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933812:(C,N,O,z,se)=>{e.ac("ReduceL1",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},933985:(C,N,O,z,se)=>{e.ac("ReduceL2",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934158:(C,N,O,z,se)=>{e.ac("ReduceLogSum",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934335:(C,N,O,z,se)=>{e.ac("ReduceSumSquare",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934515:(C,N,O,z,se)=>{e.ac("ReduceLogSumExp",C,{keepDims:!!N,noopWithEmptyAxes:!!O,axes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},934695:C=>{e.ac("Where",C,void 0)},934748:(C,N,O)=>{e.ac("Transpose",C,{perm:N?Array.from((T(),B).subarray(Number(N)>>>0,Number(O)>>>0)):[]})},934872:(C,N,O,z)=>{e.ac("DepthToSpace",C,{blocksize:N,mode:hn(O),format:z?"NHWC":"NCHW"})},935005:(C,N,O,z)=>{e.ac("DepthToSpace",C,{blocksize:N,mode:hn(O),format:z?"NHWC":"NCHW"})},935138:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr)=>{e.ac("ConvTranspose",C,{format:it?"NHWC":"NCHW",autoPad:N,dilations:[O],group:z,kernelShape:[se],pads:[ue,Se],strides:[Ue],wIsConst:()=>!!(T(),k)[ht>>>0],outputPadding:Nt?Array.from((T(),B).subarray(Number(Nt)>>>0,Number(Vt)>>>0)):[],outputShape:on?Array.from((T(),B).subarray(Number(on)>>>0,Number(ln)>>>0)):[],activation:hn(wr)})},935571:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("ConvTranspose",C,{format:Ue?"NHWC":"NCHW",autoPad:N,dilations:Array.from((T(),B).subarray(Number(O)>>>0,2+(Number(O)>>>0)>>>0)),group:z,kernelShape:Array.from((T(),B).subarray(Number(se)>>>0,2+(Number(se)>>>0)>>>0)),pads:Array.from((T(),B).subarray(Number(ue)>>>0,4+(Number(ue)>>>0)>>>0)),strides:Array.from((T(),B).subarray(Number(Se)>>>0,2+(Number(Se)>>>0)>>>0)),wIsConst:()=>!!(T(),k)[it>>>0],outputPadding:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],outputShape:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[],activation:hn(ln)})},936232:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr)=>{e.ac("ConvTranspose",C,{format:it?"NHWC":"NCHW",autoPad:N,dilations:[O],group:z,kernelShape:[se],pads:[ue,Se],strides:[Ue],wIsConst:()=>!!(T(),k)[ht>>>0],outputPadding:Nt?Array.from((T(),B).subarray(Number(Nt)>>>0,Number(Vt)>>>0)):[],outputShape:on?Array.from((T(),B).subarray(Number(on)>>>0,Number(ln)>>>0)):[],activation:hn(wr)})},936665:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("ConvTranspose",C,{format:Ue?"NHWC":"NCHW",autoPad:N,dilations:Array.from((T(),B).subarray(Number(O)>>>0,2+(Number(O)>>>0)>>>0)),group:z,kernelShape:Array.from((T(),B).subarray(Number(se)>>>0,2+(Number(se)>>>0)>>>0)),pads:Array.from((T(),B).subarray(Number(ue)>>>0,4+(Number(ue)>>>0)>>>0)),strides:Array.from((T(),B).subarray(Number(Se)>>>0,2+(Number(Se)>>>0)>>>0)),wIsConst:()=>!!(T(),k)[it>>>0],outputPadding:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],outputShape:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[],activation:hn(ln)})},937326:(C,N)=>{e.ac("GlobalAveragePool",C,{format:N?"NHWC":"NCHW"})},937417:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("AveragePool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},937896:(C,N)=>{e.ac("GlobalAveragePool",C,{format:N?"NHWC":"NCHW"})},937987:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("AveragePool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},938466:(C,N)=>{e.ac("GlobalMaxPool",C,{format:N?"NHWC":"NCHW"})},938553:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("MaxPool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},939028:(C,N)=>{e.ac("GlobalMaxPool",C,{format:N?"NHWC":"NCHW"})},939115:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln)=>{e.ac("MaxPool",C,{format:ln?"NHWC":"NCHW",auto_pad:N,ceil_mode:O,count_include_pad:z,storage_order:se,dilations:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],kernel_shape:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],pads:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],strides:Vt?Array.from((T(),B).subarray(Number(Vt)>>>0,Number(on)>>>0)):[]})},939590:(C,N,O,z,se)=>{e.ac("Gemm",C,{alpha:N,beta:O,transA:z,transB:se})},939694:C=>{e.ac("MatMul",C,void 0)},939748:(C,N,O,z)=>{e.ac("ArgMax",C,{keepDims:!!N,selectLastIndex:!!O,axis:z})},939856:(C,N,O,z)=>{e.ac("ArgMin",C,{keepDims:!!N,selectLastIndex:!!O,axis:z})},939964:(C,N)=>{e.ac("Softmax",C,{axis:N})},940027:(C,N)=>{e.ac("Concat",C,{axis:N})},940087:(C,N,O,z,se)=>{e.ac("Split",C,{axis:N,numOutputs:O,splitSizes:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},940243:C=>{e.ac("Expand",C,void 0)},940297:(C,N)=>{e.ac("Gather",C,{axis:Number(N)})},940368:(C,N)=>{e.ac("GatherElements",C,{axis:Number(N)})},940447:(C,N)=>{e.ac("GatherND",C,{batch_dims:Number(N)})},940526:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt)=>{e.ac("Resize",C,{antialias:N,axes:O?Array.from((T(),B).subarray(Number(O)>>>0,Number(z)>>>0)):[],coordinateTransformMode:hn(se),cubicCoeffA:ue,excludeOutside:Se,extrapolationValue:Ue,keepAspectRatioPolicy:hn(it),mode:hn(ht),nearestMode:hn(Nt)})},940888:(C,N,O,z,se,ue,Se)=>{e.ac("Slice",C,{starts:N?Array.from((T(),B).subarray(Number(N)>>>0,Number(O)>>>0)):[],ends:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[],axes:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[]})},941152:C=>{e.ac("Tile",C,void 0)},941204:(C,N,O)=>{e.ac("InstanceNormalization",C,{epsilon:N,format:O?"NHWC":"NCHW"})},941318:(C,N,O)=>{e.ac("InstanceNormalization",C,{epsilon:N,format:O?"NHWC":"NCHW"})},941432:C=>{e.ac("Range",C,void 0)},941485:(C,N)=>{e.ac("Einsum",C,{equation:hn(N)})},941566:(C,N,O,z,se)=>{e.ac("Pad",C,{mode:N,value:O,pads:z?Array.from((T(),B).subarray(Number(z)>>>0,Number(se)>>>0)):[]})},941709:(C,N,O,z,se,ue)=>{e.ac("BatchNormalization",C,{epsilon:N,momentum:O,spatial:!!se,trainingMode:!!z,format:ue?"NHWC":"NCHW"})},941878:(C,N,O,z,se,ue)=>{e.ac("BatchNormalization",C,{epsilon:N,momentum:O,spatial:!!se,trainingMode:!!z,format:ue?"NHWC":"NCHW"})},942047:(C,N,O)=>{e.ac("CumSum",C,{exclusive:Number(N),reverse:Number(O)})},942144:(C,N,O)=>{e.ac("DequantizeLinear",C,{axis:N,blockSize:O})},942234:(C,N,O,z,se)=>{e.ac("GridSample",C,{align_corners:N,mode:hn(O),padding_mode:hn(z),format:se?"NHWC":"NCHW"})},942404:(C,N,O,z,se)=>{e.ac("GridSample",C,{align_corners:N,mode:hn(O),padding_mode:hn(z),format:se?"NHWC":"NCHW"})},942574:(C,N)=>{e.ac("ScatterND",C,{reduction:hn(N)})},942659:(C,N,O,z,se,ue,Se,Ue,it)=>{e.ac("Attention",C,{numHeads:N,isUnidirectional:O,maskFilterValue:z,scale:se,doRotary:ue,qkvHiddenSizes:Se?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(Ue)+Se>>>0)):[],pastPresentShareBuffer:!!it})},942931:C=>{e.ac("BiasAdd",C,void 0)},942986:C=>{e.ac("BiasSplitGelu",C,void 0)},943047:C=>{e.ac("FastGelu",C,void 0)},943103:(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr,Es)=>{e.ac("Conv",C,{format:Vt?"NHWC":"NCHW",auto_pad:N,dilations:O?Array.from((T(),B).subarray(Number(O)>>>0,Number(z)>>>0)):[],group:se,kernel_shape:ue?Array.from((T(),B).subarray(Number(ue)>>>0,Number(Se)>>>0)):[],pads:Ue?Array.from((T(),B).subarray(Number(Ue)>>>0,Number(it)>>>0)):[],strides:ht?Array.from((T(),B).subarray(Number(ht)>>>0,Number(Nt)>>>0)):[],w_is_const:()=>!!(T(),k)[Number(on)>>>0],activation:hn(ln),activation_params:wr?Array.from((T(),K).subarray(Number(wr)>>>0,Number(Es)>>>0)):[]})},943687:C=>{e.ac("Gelu",C,void 0)},943739:(C,N,O,z,se,ue,Se,Ue,it)=>{e.ac("GroupQueryAttention",C,{numHeads:N,kvNumHeads:O,scale:z,softcap:se,doRotary:ue,rotaryInterleaved:Se,smoothSoftmax:Ue,localWindowSize:it})},943956:(C,N,O,z)=>{e.ac("LayerNormalization",C,{axis:N,epsilon:O,simplified:!!z})},944067:(C,N,O,z)=>{e.ac("LayerNormalization",C,{axis:N,epsilon:O,simplified:!!z})},944178:(C,N,O,z,se,ue)=>{e.ac("MatMulNBits",C,{k:N,n:O,accuracyLevel:z,bits:se,blockSize:ue})},944305:(C,N,O,z,se,ue)=>{e.ac("MultiHeadAttention",C,{numHeads:N,isUnidirectional:O,maskFilterValue:z,scale:se,doRotary:ue})},944464:(C,N)=>{e.ac("QuickGelu",C,{alpha:N})},944528:(C,N,O,z,se)=>{e.ac("RotaryEmbedding",C,{interleaved:!!N,numHeads:O,rotaryEmbeddingDim:z,scale:se})},944667:(C,N,O)=>{e.ac("SkipLayerNormalization",C,{epsilon:N,simplified:!!O})},944769:(C,N,O)=>{e.ac("SkipLayerNormalization",C,{epsilon:N,simplified:!!O})},944871:(C,N,O,z)=>{e.ac("GatherBlockQuantized",C,{gatherAxis:N,quantizeAxis:O,blockSize:z})},944992:C=>{e.Id(C)},945026:(C,N)=>e.Kd(Number(C),Number(N),e.$c.Nd,e.$c.errors)};function yA(C,N,O){return Kp(async()=>{await e.Gd(Number(C),Number(N),Number(O))})}function Lu(){return typeof wasmOffsetConverter<"u"}function Fu(C,N,O,z){var se=Xt();try{return Tu(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function rf(C,N,O){var z=Xt();try{return Mu(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function sf(C,N,O){var z=Xt();try{Jo(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function af(C,N){var O=Xt();try{return Bu(C,N)}catch(z){if(qt(O),z!==z+0)throw z;Yt(1,0)}}function of(C){var N=Xt();try{$h(C)}catch(O){if(qt(N),O!==O+0)throw O;Yt(1,0)}}function yy(C,N,O,z,se,ue,Se){var Ue=Xt();try{return pA(C,N,O,z,se,ue,Se)}catch(it){if(qt(Ue),it!==it+0)throw it;Yt(1,0)}}function xA(C,N){var O=Xt();try{Ko(C,N)}catch(z){if(qt(O),z!==z+0)throw z;Yt(1,0)}}function xy(C,N,O,z,se,ue){var Se=Xt();try{Gh(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function vy(C,N,O,z){var se=Xt();try{Wa(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function lf(C,N,O,z,se){var ue=Xt();try{Vh(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function da(C,N,O,z,se,ue,Se){var Ue=Xt();try{Hh(C,N,O,z,se,ue,Se)}catch(it){if(qt(Ue),it!==it+0)throw it;Yt(1,0)}}function vA(C,N,O,z,se,ue,Se){var Ue=Xt();try{ec(C,N,O,z,se,ue,Se)}catch(it){if(qt(Ue),it!==it+0)throw it;Yt(1,0)}}function nl(C,N,O,z,se,ue,Se,Ue){var it=Xt();try{tc(C,N,O,z,se,ue,Se,Ue)}catch(ht){if(qt(it),ht!==ht+0)throw ht;Yt(1,0)}}function qi(C,N,O,z,se){var ue=Xt();try{return Ru(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function ic(C,N,O,z,se,ue,Se,Ue){var it=Xt();try{Wh(C,N,O,z,se,ue,Se,Ue)}catch(ht){if(qt(it),ht!==ht+0)throw ht;Yt(1,0)}}function ws(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt){var on=Xt();try{qa(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt)}catch(ln){if(qt(on),ln!==ln+0)throw ln;Yt(1,0)}}function cf(C,N,O,z,se,ue){var Se=Xt();try{return Du(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function _y(C,N,O){var z=Xt();try{return qh(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;return Yt(1,0),0n}}function by(C,N,O,z,se,ue,Se,Ue,it){var ht=Xt();try{fA(C,N,O,z,se,ue,Se,Ue,it)}catch(Nt){if(qt(ht),Nt!==Nt+0)throw Nt;Yt(1,0)}}function Xa(C){var N=Xt();try{return Yh(C)}catch(O){if(qt(N),O!==O+0)throw O;Yt(1,0)}}function sc(C,N,O){var z=Xt();try{return Xh(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function rl(C,N){var O=Xt();try{return tf(C,N)}catch(z){if(qt(O),z!==z+0)throw z;return Yt(1,0),0n}}function zu(C,N,O,z,se){var ue=Xt();try{Jh(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function uf(C){var N=Xt();try{return Kh(C)}catch(O){if(qt(N),O!==O+0)throw O;return Yt(1,0),0n}}function il(C,N,O,z,se,ue){var Se=Xt();try{return Zo(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function ha(C,N,O,z,se,ue){var Se=Xt();try{return gA(C,N,O,z,se,ue)}catch(Ue){if(qt(Se),Ue!==Ue+0)throw Ue;Yt(1,0)}}function Pn(C,N,O,z,se,ue,Se,Ue){var it=Xt();try{return jh(C,N,O,z,se,ue,Se,Ue)}catch(ht){if(qt(it),ht!==ht+0)throw ht;Yt(1,0)}}function Rn(C,N,O,z,se){var ue=Xt();try{return Zh(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;return Yt(1,0),0n}}function fa(C,N,O,z){var se=Xt();try{return ef(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function br(C,N,O,z){var se=Xt();try{return Tn(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function Gr(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt){var on=Xt();try{return Qu(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt)}catch(ln){if(qt(on),ln!==ln+0)throw ln;Yt(1,0)}}function Ja(C,N,O,z,se,ue,Se,Ue,it,ht,Nt){var Vt=Xt();try{AA(C,N,O,z,se,ue,Se,Ue,it,ht,Nt)}catch(on){if(qt(Vt),on!==on+0)throw on;Yt(1,0)}}function sl(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr,Es){var wA=Xt();try{mA(C,N,O,z,se,ue,Se,Ue,it,ht,Nt,Vt,on,ln,wr,Es)}catch(oc){if(qt(wA),oc!==oc+0)throw oc;Yt(1,0)}}function Vr(C,N,O,z){var se=Xt();try{return nc(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function Uu(C,N,O,z,se){var ue=Xt();try{return el(C,N,O,z,se)}catch(Se){if(qt(ue),Se!==Se+0)throw Se;Yt(1,0)}}function _A(C,N,O){var z=Xt();try{return bs(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function bA(C,N,O){var z=Xt();try{return ku(C,N,O)}catch(se){if(qt(z),se!==se+0)throw se;Yt(1,0)}}function Ou(C,N,O,z){var se=Xt();try{Nu(C,N,O,z)}catch(ue){if(qt(se),ue!==ue+0)throw ue;Yt(1,0)}}function ac(){if(0<ge)Ne=ac;else if(i)m?.(e),oe();else{for(var C=Re;0<C.length;)C.shift()(e);0<ge?Ne=ac:(e.calledRun=!0,S||(oe(),m?.(e)))}}return i||(Wi=await he(),ac()),e.PTR_SIZE=4,L?e:new Promise((C,N)=>{m=C,x=N})}var LP,gB,Wee=et(()=>{LP=mB,gB=globalThis.self?.name?.startsWith("em-pthread"),gB&&mB()}),s_,Bw,yB,$i,FP,qm,xB,vB,a_,_B,o_,zP,l_,UP,YI=et(()=>{qI(),s_=typeof location>"u"?void 0:location.origin,Bw=import.meta.url>"file:"&&import.meta.url<"file;",yB=()=>{{if(Bw){let n=URL;return new URL(new n("ort.bundle.min.mjs",import.meta.url).href,s_).href}return import.meta.url}},$i=yB(),FP=()=>{if($i&&!$i.startsWith("blob:"))return $i.substring(0,$i.lastIndexOf("/")+1)},qm=(n,e)=>{try{let t=e??$i;return(t?new URL(n,t):new URL(n)).origin===s_}catch{return!1}},xB=(n,e)=>{let t=e??$i;try{return(t?new URL(n,t):new URL(n)).href}catch{return}},vB=(n,e)=>`${e??"./"}${n}`,a_=async n=>{let e=await(await fetch(n,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},_B=async n=>(await import(n)).default,o_=(jee(),Lp(NP)).default,zP=async()=>{if(!$i)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(qm($i))return[void 0,o_()];let n=await a_($i);return[n,o_(n)]},l_=(Wee(),Lp(PP)).default,UP=async(n,e,t,r)=>{let i=l_&&!(n||e);if(i)if($i)i=qm($i)||r&&!t;else if(r&&!t)i=!0;else throw new Error("cannot determine the script source URL.");if(i)return[void 0,l_];{let s="ort-wasm-simd-threaded.jsep.mjs",a=n??xB(s,e),o=t&&a&&!qm(a,e),l=o?await a_(a):a??vB(s,e);return[o?l:void 0,await _B(l)]}}}),c_,Ym,$f,u_,bB,wB,EB,XI,kn,cu=et(()=>{YI(),Ym=!1,$f=!1,u_=!1,bB=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},wB=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},EB=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},XI=async n=>{if(Ym)return Promise.resolve();if($f)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(u_)throw new Error("previous call to 'initializeWebAssembly()' failed.");$f=!0;let e=n.initTimeout,t=n.numThreads;if(n.simd!==!1){if(n.simd==="relaxed"){if(!EB())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!wB())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let r=bB();t>1&&!r&&(typeof self<"u"&&self.crossOriginIsolated,n.numThreads=t=1);let i=n.wasmPaths,s=typeof i=="string"?i:void 0,a=i?.mjs,o=a?.href??a,l=i?.wasm,c=l?.href??l,d=n.wasmBinary,[h,p]=await UP(o,s,t>1,!!d||!!c),A=!1,y=[];if(e>0&&y.push(new Promise(m=>{setTimeout(()=>{A=!0,m()},e)})),y.push(new Promise((m,x)=>{let g={numThreads:t};if(d)g.wasmBinary=d,g.locateFile=_=>_;else if(c||s)g.locateFile=_=>c??s+_;else if(o&&o.indexOf("blob:")!==0)g.locateFile=_=>new URL(_,o).href;else if(h){let _=FP();_&&(g.locateFile=b=>_+b)}p(g).then(_=>{$f=!1,Ym=!0,c_=_,m(),h&&URL.revokeObjectURL(h)},_=>{$f=!1,u_=!0,x(_)})})),await Promise.race(y),A)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},kn=()=>{if(Ym&&c_)return c_;throw new Error("WebAssembly is not initialized yet.")}}),Os,Jg,wn,JI=et(()=>{cu(),Os=(n,e)=>{let t=kn(),r=t.lengthBytesUTF8(n)+1,i=t._malloc(r);return t.stringToUTF8(n,i,r),e.push(i),i},Jg=(n,e,t,r)=>{if(typeof n=="object"&&n!==null){if(t.has(n))throw new Error("Circular reference in options");t.add(n)}Object.entries(n).forEach(([i,s])=>{let a=e?e+i:i;if(typeof s=="object")Jg(s,a+".",t,r);else if(typeof s=="string"||typeof s=="number")r(a,s.toString());else if(typeof s=="boolean")r(a,s?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof s}`)})},wn=n=>{let e=kn(),t=e.stackSave();try{let r=e.PTR_SIZE,i=e.stackAlloc(2*r);e._OrtGetLastError(i,i+r);let s=Number(e.getValue(i,r===4?"i32":"i64")),a=e.getValue(i+r,"*"),o=a?e.UTF8ToString(a):"";throw new Error(`${n} ERROR_CODE: ${s}, ERROR_MESSAGE: ${o}`)}finally{e.stackRestore(t)}}}),OP,qee=et(()=>{cu(),JI(),OP=n=>{let e=kn(),t=0,r=[],i=n||{};try{if(n?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof n.logSeverityLevel!="number"||!Number.isInteger(n.logSeverityLevel)||n.logSeverityLevel<0||n.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${n.logSeverityLevel}`);if(n?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof n.logVerbosityLevel!="number"||!Number.isInteger(n.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${n.logVerbosityLevel}`);n?.terminate===void 0&&(i.terminate=!1);let s=0;return n?.tag!==void 0&&(s=Os(n.tag,r)),t=e._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,s),t===0&&wn("Can't create run options."),n?.extra!==void 0&&Jg(n.extra,"",new WeakSet,(a,o)=>{let l=Os(a,r),c=Os(o,r);e._OrtAddRunConfigEntry(t,l,c)!==0&&wn(`Can't set a run config entry: ${a} - ${o}.`)}),[t,r]}catch(s){throw t!==0&&e._OrtReleaseRunOptions(t),r.forEach(a=>e._free(a)),s}}}),IB,CB,SB,Gf,BB,$P,Yee=et(()=>{cu(),JI(),IB=n=>{switch(n){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${n}`)}},CB=n=>{switch(n){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${n}`)}},SB=n=>{n.extra||(n.extra={}),n.extra.session||(n.extra.session={});let e=n.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),n.executionProviders&&n.executionProviders.some(t=>(typeof t=="string"?t:t.name)==="webgpu")&&(n.enableMemPattern=!1)},Gf=(n,e,t,r)=>{let i=Os(e,r),s=Os(t,r);kn()._OrtAddSessionConfigEntry(n,i,s)!==0&&wn(`Can't set a session config entry: ${e} - ${t}.`)},BB=async(n,e,t)=>{let r=e.executionProviders;for(let i of r){let s=typeof i=="string"?i:i.name,a=[];switch(s){case"webnn":if(s="WEBNN",typeof i!="string"){let h=i?.deviceType;h&&Gf(n,"deviceType",h,t)}break;case"webgpu":if(s="JS",typeof i!="string"){let h=i;if(h?.preferredLayout){if(h.preferredLayout!=="NCHW"&&h.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${h.preferredLayout}`);Gf(n,"preferredLayout",h.preferredLayout,t)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${s}`)}let o=Os(s,t),l=a.length,c=0,d=0;if(l>0){c=kn()._malloc(l*kn().PTR_SIZE),t.push(c),d=kn()._malloc(l*kn().PTR_SIZE),t.push(d);for(let h=0;h<l;h++)kn().setValue(c+h*kn().PTR_SIZE,a[h][0],"*"),kn().setValue(d+h*kn().PTR_SIZE,a[h][1],"*")}await kn()._OrtAppendExecutionProvider(n,o,c,d,l)!==0&&wn(`Can't append execution provider: ${s}.`)}},$P=async n=>{let e=kn(),t=0,r=[],i=n||{};SB(i);try{let s=IB(i.graphOptimizationLevel??"all"),a=CB(i.executionMode??"sequential"),o=typeof i.logId=="string"?Os(i.logId,r):0,l=i.logSeverityLevel??2;if(!Number.isInteger(l)||l<0||l>4)throw new Error(`log severity level is not valid: ${l}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw new Error(`log verbosity level is not valid: ${c}`);let d=typeof i.optimizedModelFilePath=="string"?Os(i.optimizedModelFilePath,r):0;if(t=e._OrtCreateSessionOptions(s,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,l,c,d),t===0&&wn("Can't create session options."),i.executionProviders&&await BB(t,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);Gf(t,"enableGraphCapture",i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[h,p]of Object.entries(i.freeDimensionOverrides)){if(typeof h!="string")throw new Error(`free dimension override name must be a string: ${h}`);if(typeof p!="number"||!Number.isInteger(p)||p<0)throw new Error(`free dimension override value must be a non-negative integer: ${p}`);let A=Os(h,r);e._OrtAddFreeDimensionOverride(t,A,p)!==0&&wn(`Can't set a free dimension override: ${h} - ${p}.`)}return i.extra!==void 0&&Jg(i.extra,"",new WeakSet,(h,p)=>{Gf(t,h,p,r)}),[t,r]}catch(s){throw t!==0&&e._OrtReleaseSessionOptions(t)!==0&&wn("Can't release session options."),r.forEach(a=>e._free(a)),s}}}),Pc,ho,Lc,ey,Kg,KI,ZI,Mw,Lt=et(()=>{Pc=n=>{switch(n){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${n}`)}},ho=n=>{switch(n){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${n}`)}},Lc=(n,e)=>{let t=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][n],r=typeof e=="number"?e:e.reduce((i,s)=>i*s,1);return t>0?Math.ceil(r*t):void 0},ey=n=>{switch(n){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${n}`)}},Kg=n=>{switch(n){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${n}`)}},KI=n=>n==="float32"||n==="float16"||n==="int32"||n==="int64"||n==="uint32"||n==="uint8"||n==="bool"||n==="uint4"||n==="int4",ZI=n=>n==="float32"||n==="float16"||n==="int32"||n==="int64"||n==="uint32"||n==="uint64"||n==="int8"||n==="uint8"||n==="bool"||n==="uint4"||n==="int4",Mw=n=>{switch(n){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${n}`)}}}),eC,GP=et(()=>{qI(),eC=async n=>{if(typeof n=="string"){let e=await fetch(n);if(!e.ok)throw new Error(`failed to load external data file: ${n}`);let t=e.headers.get("Content-Length"),r=t?parseInt(t,10):0;if(r<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${n}, no response body.`);let i=e.body.getReader(),s;try{s=new ArrayBuffer(r)}catch(o){if(o instanceof RangeError){let l=Math.ceil(r/65536);s=new WebAssembly.Memory({initial:l,maximum:l}).buffer}else throw o}let a=0;for(;;){let{done:o,value:l}=await i.read();if(o)break;let c=l.byteLength;new Uint8Array(s,a,c).set(l),a+=c}return new Uint8Array(s,0,r)}}else return n instanceof Blob?new Uint8Array(await n.arrayBuffer()):n instanceof Uint8Array?n:new Uint8Array(n)}}),Xee,MB,TB,RB,tC,DB,un,ko=et(()=>{Lt(),Xee=["V","I","W","E","F"],MB=(n,e)=>{},tC=(n,e)=>{TB=n,RB=e},DB=(n,e)=>{let t=Kg(n),r=Kg(TB);t>=r&&MB(t,typeof e=="function"?e():e)},un=(...n)=>{RB&&DB(...n)}}),kB,th,Le,Zg,VP,HP,jP,jt=et(()=>{kB=class{static calcMatMulShape(n,e){return n[1]!==e[0]?void 0:[n[0],e[1]]}},th=class{static calcShape(n,e,t=!1){let r=n.length,i=e.length;if(r===0)return e;if(i===0)return n;let s=Math.max(n.length,e.length),a=new Array(s);if(t){if(r<2||i<2)return;let o=kB.calcMatMulShape([n[r-2],n[r-1]],[e[i-2],e[i-1]]);if(o===void 0)return;[a[s-2],a[s-1]]=o}for(let o=t?3:1;o<=s;o++){let l=r-o<0?1:n[r-o],c=i-o<0?1:e[i-o];if(l!==c&&l>1&&c>1)return;let d=Math.max(l,c);if(l&&c)a[s-o]=Math.max(l,c);else{if(d>1)return;a[s-o]=0}}return a}static isValidBroadcast(n,e){let t=n.length,r=e.length;if(t>r)return!1;for(let i=1;i<=t;i++)if(n[t-i]!==1&&n[t-i]!==e[r-i])return!1;return!0}},Le=class Ig{static size(e){return Ig.getSizeFromDimensionRange(e,0,e.length)}static convertShape(e,t=4){let r=e.length;if(r===0)return[];let i=new Array(r),s=r-1;for(;s>=0;){if(e[s]%t===0){i[s]=e[s]/t;break}if(t%e[s]!==0)throw new Error("cannot convert shape");i[s]=1,t/=e[s],s--}for(s--;s>=0;s--)i[s]=e[s];return i}static sizeFromDimension(e,t){if(t<0||t>e.length)throw new Error(`invalid dimension of ${t} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return Ig.getSizeFromDimensionRange(e,t,e.length)}static sizeToDimension(e,t){if(t<0||t>e.length)throw new Error(`invalid dimension of ${t} for sizeToDimension as Tensor has ${e.length} dimensions.`);return Ig.getSizeFromDimensionRange(e,0,t)}static getSizeFromDimensionRange(e,t,r){let i=1;for(let s=t;s<r;s++){if(e[s]<0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains negative values in them.");i*=Number(e[s])}return i}static computeStrides(e){let t=e.length;if(t===0)return[];if(t===1)return[1];let r=new Array(t);r[t-1]=1,r[t-2]=e[t-1];for(let i=t-3;i>=0;--i)r[i]=r[i+1]*e[i+1];return r}static normalizeAxis(e,t){if(e<-t&&e>=t)throw new Error("unsupported axis for this operation.");return e<0?e+t:e}static normalizeAxes(e,t){return e.map(r=>this.normalizeAxis(r,t??e.length))}static sortBasedOnPerm(e,t){return t?t.map(r=>e[r]):e.slice().reverse()}static padShape(e,t){let r=e.length;return e.map((i,s)=>i+t[s]+t[s+r])}static areEqual(e,t){return e.length!==t.length?!1:e.every((r,i)=>r===t[i])}},Zg=class lp{static adjustPoolAttributes(e,t,r,i,s,a){if(!e&&r.length!==t.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let o=0;o<t.length-2;o++)o>=r.length?r.push(t[o+2]):r[o]=t[o+2];for(let o=0;o<r.length;o++)if(o<i.length){if(i[o]<0)throw new Error("strides should be greater than or equal to 1")}else i.push(1);for(let o=0;o<r.length;o++)if(o<s.length){if(s[o]<0)throw new Error("dilations should be greater than or equal to 1")}else s.push(1);for(let o=0;o<r.length*2;o++)if(o<a.length){if(a[o]<0)throw new Error("pad should be greater than or equal to 1")}else a.push(0);for(let o=0;o<r.length;o++){if(r[o]<=0)throw new Error("kernel shapes need to be greater than 0");if(a[o]>=r[o]||a[o+r.length]>=r[o])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,t,r,i,s,a,o){if(o){if(s.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(t.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(i.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let l=0;l<e.length-2;l++)lp.adjustPadAndReturnShape(e[l+(a?1:2)],t[l],r[l],i[l],s,l,l+e.length-2,o)}}static computePoolOutputShape(e,t,r,i,s,a,o){if(t.length<=0)throw new Error("input shape must be of size greater than 0");let l=[t[0],t[1]];return lp.computeShapeHelper(e,t,l,r,i,s,a,o),l}static computeConvOutputShape(e,t,r,i,s,a,o){if(e.length<=0||t.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");let l=[e[0],t[0]];return lp.computeShapeHelper(!1,e,l,r,i,s,a,o),l}static computeShapeHelper(e,t,r,i,s,a,o,l){if(e)for(let c=0;c<t.length-2;c++)r.push(1);else for(let c=0;c<t.length-2;c++)r.push(lp.adjustPadAndReturnShape(t[c+2],i[c],s[c],a[c],o,c,c+t.length-2,l))}static adjustPadAndReturnShape(e,t,r,i,s,a,o,l){let c=r*(i-1)+1;if(l&&l!=="NOTSET")switch(l){case"VALID":return s[a]=0,s[o]=0,Math.floor((e-c)/t+1);case"SAME_LOWER":case"SAME_UPPER":if(r!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{let d=((e+t-1)/t-1)*t+i-e;return s[a]=Math.floor(l==="SAME_LOWER"?(d+1)/2:d/2),s[o]=d-s[a],Math.floor((e+d-i)/t+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((e+s[a]+s[o]-c)/t+1)}},VP=class{static getShapeOfGemmResult(n,e,t,r,i){if(n.length!==2||t.length!==2)throw new Error("shape need to be of size 2");let s,a,o;e?(s=n[1],a=n[0]):(s=n[0],a=n[1]);let l=-1;if(r?(o=t[0],l=1):(o=t[1],l=0),t[l]!==a)throw new Error("dimension mismatch");if(s<=0||o<=0||a<=0)throw new Error("invalid shape specified");if(i&&!th.isValidBroadcast(i,[s,o]))throw new Error("gemm: invalid bias shape for broadcast");return[s,o,a]}},HP=-34028234663852886e22,jP=34028234663852886e22}),nC,WP=et(()=>{Lt(),nC=(n,e)=>new(ey(e))(n)}),d_,Tw,h_,NB,f_,QB,p_,A_,m_,PB,qP,Jee=et(()=>{Lt(),ko(),d_=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),Tw=(n,e)=>{if(e==="int32")return n;let t=d_.get(e);if(!t)throw new Error(`WebNN backend does not support data type: ${e}`);let r=t/8;if(n.byteLength%r!==0)throw new Error(`Invalid Uint8Array length - must be a multiple of ${r}.`);let i=n.byteLength/r,s=new(ey(e))(n.buffer,n.byteOffset,i);switch(e){case"int64":case"uint64":{let a=new Int32Array(i);for(let o=0;o<i;o++){let l=s[o];if(l>2147483647n||l<-2147483648n)throw new Error("Can not convert int64 data to int32 - value out of range.");a[o]=Number(l)}return new Uint8Array(a.buffer)}case"int8":case"uint8":case"uint32":{if(e==="uint32"&&s.some(o=>o>2147483647))throw new Error("Can not convert uint32 data to int32 - value out of range.");let a=Int32Array.from(s,Number);return new Uint8Array(a.buffer)}default:throw new Error(`Unsupported data conversion from ${e} to 'int32'`)}},h_=(n,e)=>{if(e==="int32")return n;if(n.byteLength%4!==0)throw new Error("Invalid Uint8Array length - must be a multiple of 4 (int32).");let t=n.byteLength/4,r=new Int32Array(n.buffer,n.byteOffset,t);switch(e){case"int64":{let i=BigInt64Array.from(r,BigInt);return new Uint8Array(i.buffer)}case"uint64":{if(r.some(s=>s<0))throw new Error("Can not convert int32 data to uin64 - negative value found.");let i=BigUint64Array.from(r,BigInt);return new Uint8Array(i.buffer)}case"int8":{if(r.some(s=>s<-128||s>127))throw new Error("Can not convert int32 data to int8 - value out of range.");let i=Int8Array.from(r,Number);return new Uint8Array(i.buffer)}case"uint8":{if(r.some(i=>i<0||i>255))throw new Error("Can not convert int32 data to uint8 - value out of range.");return Uint8Array.from(r,Number)}case"uint32":{if(r.some(s=>s<0))throw new Error("Can not convert int32 data to uint32 - negative value found.");let i=Uint32Array.from(r,Number);return new Uint8Array(i.buffer)}default:throw new Error(`Unsupported data conversion from 'int32' to ${e}`)}},NB=1,f_=()=>NB++,QB=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),p_=(n,e)=>{let t=d_.get(n);if(!t)throw new Error(`WebNN backend does not support data type: ${n}`);return e.length>0?Math.ceil(e.reduce((r,i)=>r*i)*t/8):0},A_=class{constructor(n){this.isDataConverted=!1;let{sessionId:e,context:t,tensor:r,dataType:i,shape:s,fallbackDataType:a}=n;this.sessionId=e,this.mlContext=t,this.mlTensor=r,this.dataType=i,this.tensorShape=s,this.fallbackDataType=a}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return p_(this.dataType,this.tensorShape)}destroy(){un("verbose",()=>"[WebNN] TensorWrapper.destroy"),this.mlTensor.destroy()}write(n){this.mlContext.writeTensor(this.mlTensor,n)}async read(n){if(this.fallbackDataType){let e=await this.mlContext.readTensor(this.mlTensor),t=h_(new Uint8Array(e),this.dataType);if(n){(n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)).set(t);return}else return t.buffer}else return n?this.mlContext.readTensor(this.mlTensor,n):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(n,e,t){return this.mlContext===n&&this.dataType===e&&this.tensorShape.length===t.length&&this.tensorShape.every((r,i)=>r===t[i])}setIsDataConverted(n){this.isDataConverted=n}},m_=class{constructor(n,e){this.tensorManager=n,this.wrapper=e}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(n,e,t,r){let i=this.tensorManager.getMLContext(n),s=this.tensorManager.getMLOpSupportLimits(n),a;if(!s?.input.dataTypes.includes(e)){if(a=QB.get(e),!a||s?.input.dataTypes.includes(a))throw new Error(`WebNN backend does not support data type: ${e}`);un("verbose",()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${e} to ${a}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(i,e,t))return this.wrapper.tensor;if(r){if(this.wrapper.byteLength!==p_(e,t))throw new Error("Unable to copy data to tensor with different size.");this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let o=typeof MLTensorUsage>"u"?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(n,e,t,o,!0,!0,a),r&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(n){let e=n;if(this.wrapper){if(this.wrapper.fallbackType)if(this.wrapper.fallbackType==="int32")e=Tw(n,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw new Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(n.byteLength===this.wrapper.byteLength){this.wrapper.write(e);return}else un("verbose",()=>"Data size does not match tensor size. Releasing tensor."),this.releaseTensor()}this.activeUpload?this.activeUpload.set(e):this.activeUpload=new Uint8Array(e)}async download(n){if(this.activeUpload){let e=this.wrapper?.isDataConverted?h_(this.activeUpload,this.wrapper?.type):this.activeUpload;if(n){n instanceof ArrayBuffer?new Uint8Array(n).set(e):new Uint8Array(n.buffer,n.byteOffset,n.byteLength).set(e);return}else return e.buffer}if(!this.wrapper)throw new Error("Tensor has not been created.");return n?this.wrapper.read(n):this.wrapper.read()}},PB=class{constructor(n){this.backend=n,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(n){let e=this.backend.getMLContext(n);if(!e)throw new Error("MLContext not found for session.");return e}getMLOpSupportLimits(n){return this.backend.getMLOpSupportLimits(n)}reserveTensorId(){let n=f_();return this.tensorTrackersById.set(n,new m_(this)),n}releaseTensorId(n){let e=this.tensorTrackersById.get(n);e&&(this.tensorTrackersById.delete(n),e.tensorWrapper&&this.releaseTensor(e.tensorWrapper))}async ensureTensor(n,e,t,r,i){un("verbose",()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${e}, dataType: ${t}, shape: ${r}, copyOld: ${i}}`);let s=this.tensorTrackersById.get(e);if(!s)throw new Error("Tensor not found.");return s.ensureTensor(n,t,r,i)}upload(n,e){let t=this.tensorTrackersById.get(n);if(!t)throw new Error("Tensor not found.");t.upload(e)}async download(n,e){un("verbose",()=>`[WebNN] TensorManager.download {tensorId: ${n}, dstBuffer: ${e?.byteLength}}`);let t=this.tensorTrackersById.get(n);if(!t)throw new Error("Tensor not found.");return t.download(e)}releaseTensorsForSession(n){for(let e of this.freeTensors)e.sessionId===n&&e.destroy();this.freeTensors=this.freeTensors.filter(e=>e.sessionId!==n)}registerTensor(n,e,t,r){let i=this.getMLContext(n),s=f_(),a=new A_({sessionId:n,context:i,tensor:e,dataType:t,shape:r});return this.tensorTrackersById.set(s,new m_(this,a)),this.externalTensors.add(a),s}async getCachedTensor(n,e,t,r,i,s,a){let o=this.getMLContext(n);for(let[c,d]of this.freeTensors.entries())if(d.canReuseTensor(o,e,t)){un("verbose",()=>`[WebNN] Reusing tensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${t}`);let h=this.freeTensors.splice(c,1)[0];return h.sessionId=n,h}un("verbose",()=>`[WebNN] MLContext.createTensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${t}}`);let l=await o.createTensor({dataType:a??e,shape:t,dimensions:t,usage:r,writable:i,readable:s});return new A_({sessionId:n,context:o,tensor:l,dataType:e,shape:t,fallbackDataType:a})}releaseTensor(n){this.externalTensors.has(n)&&this.externalTensors.delete(n),this.freeTensors.push(n)}},qP=(...n)=>new PB(...n)}),Vf,LB,YP,Kee=et(()=>{Lt(),cu(),WP(),Jee(),ko(),Vf=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),LB=(n,e)=>{if(n===e)return!0;if(n===void 0||e===void 0)return!1;let t=Object.keys(n).sort(),r=Object.keys(e).sort();return t.length===r.length&&t.every((i,s)=>i===r[s]&&n[i]===e[i])},YP=class{constructor(n){this.tensorManager=qP(this),this.mlContextBySessionId=new Map,this.sessionIdsByMLContext=new Map,this.mlContextCache=[],this.sessionGraphInputs=new Map,this.sessionGraphOutputs=new Map,this.temporaryGraphInputs=[],this.temporaryGraphOutputs=[],this.temporarySessionTensorIds=new Map,this.mlOpSupportLimitsBySessionId=new Map,tC(n.logLevel,!!n.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(n){un("verbose",()=>`[WebNN] onRunStart {sessionId: ${n}}`),this.activeSessionId=n}onRunEnd(n){un("verbose",()=>`[WebNN] onRunEnd {sessionId: ${n}}`);let e=this.temporarySessionTensorIds.get(n);if(e){for(let t of e)un("verbose",()=>`[WebNN] releasing temporary tensor {tensorId: ${t}}`),this.tensorManager.releaseTensorId(t);this.temporarySessionTensorIds.delete(n),this.activeSessionId=void 0}}async createMLContext(n){if(n instanceof GPUDevice){let t=this.mlContextCache.findIndex(r=>r.gpuDevice===n);if(t!==-1)return this.mlContextCache[t].mlContext;{let r=await navigator.ml.createContext(n);return this.mlContextCache.push({gpuDevice:n,mlContext:r}),r}}else if(n===void 0){let t=this.mlContextCache.findIndex(r=>r.options===void 0&&r.gpuDevice===void 0);if(t!==-1)return this.mlContextCache[t].mlContext;{let r=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:r}),r}}let e=this.mlContextCache.findIndex(t=>LB(t.options,n));if(e!==-1)return this.mlContextCache[e].mlContext;{let t=await navigator.ml.createContext(n);return this.mlContextCache.push({options:n,mlContext:t}),t}}registerMLContext(n,e){this.mlContextBySessionId.set(n,e);let t=this.sessionIdsByMLContext.get(e);t||(t=new Set,this.sessionIdsByMLContext.set(e,t)),t.add(n),this.mlOpSupportLimitsBySessionId.has(n)||this.mlOpSupportLimitsBySessionId.set(n,e.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(n,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(n,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(n){this.sessionGraphInputs.delete(n),this.sessionGraphOutputs.delete(n);let e=this.mlContextBySessionId.get(n);if(!e)return;this.tensorManager.releaseTensorsForSession(n),this.mlContextBySessionId.delete(n),this.mlOpSupportLimitsBySessionId.delete(n);let t=this.sessionIdsByMLContext.get(e);if(t.delete(n),t.size===0){this.sessionIdsByMLContext.delete(e);let r=this.mlContextCache.findIndex(i=>i.mlContext===e);r!==-1&&this.mlContextCache.splice(r,1)}}getMLContext(n){return this.mlContextBySessionId.get(n)}getMLOpSupportLimits(n){return this.mlOpSupportLimitsBySessionId.get(n)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(n){un("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${n}}`),this.tensorManager.releaseTensorId(n)}async ensureTensor(n,e,t,r,i){let s=Vf.get(t);if(!s)throw new Error(`Unsupported ONNX data type: ${t}`);return this.tensorManager.ensureTensor(n??this.currentSessionId,e,s,r,i)}async createTemporaryTensor(n,e,t){un("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${e}, shape: ${t}}`);let r=Vf.get(e);if(!r)throw new Error(`Unsupported ONNX data type: ${e}`);let i=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(n,i,r,t,!1);let s=this.temporarySessionTensorIds.get(n);return s?s.push(i):this.temporarySessionTensorIds.set(n,[i]),i}uploadTensor(n,e){if(!kn().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");un("verbose",()=>`[WebNN] uploadTensor {tensorId: ${n}, data: ${e.byteLength}}`),this.tensorManager.upload(n,e)}async downloadTensor(n,e){return this.tensorManager.download(n,e)}createMLTensorDownloader(n,e){return async()=>{let t=await this.tensorManager.download(n);return nC(t,e)}}registerMLTensor(n,e,t,r){let i=Vf.get(t);if(!i)throw new Error(`Unsupported ONNX data type: ${t}`);let s=this.tensorManager.registerTensor(n,e,i,r);return un("verbose",()=>`[WebNN] registerMLTensor {tensor: ${e}, dataType: ${i}, dimensions: ${r}} -> {tensorId: ${s}}`),s}registerMLConstant(n,e,t,r,i,s,a=!1){if(!s)throw new Error("External mounted files are not available.");let o=n;n.startsWith("./")&&(o=n.substring(2));let l=s.get(o);if(!l)throw new Error(`File with name ${o} not found in preloaded files.`);if(e+t>l.byteLength)throw new Error("Out of bounds: data offset and length exceed the external file data size.");let c=l.slice(e,e+t).buffer,d;switch(i.dataType){case"float32":d=new Float32Array(c);break;case"float16":d=typeof Float16Array<"u"&&Float16Array.from?new Float16Array(c):new Uint16Array(c);break;case"int32":d=new Int32Array(c);break;case"uint32":d=new Uint32Array(c);break;case"int64":if(a){let h=Tw(new Uint8Array(c),"int64");d=new Int32Array(h.buffer),i.dataType="int32"}else d=new BigInt64Array(c);break;case"uint64":d=new BigUint64Array(c);break;case"int8":d=new Int8Array(c);break;case"int4":case"uint4":case"uint8":d=new Uint8Array(c);break;default:throw new Error(`Unsupported data type: ${i.dataType} in creating WebNN Constant from external data.`)}return un("verbose",()=>`[WebNN] registerMLConstant {dataType: ${i.dataType}, shape: ${i.shape}}} ${a?"(Note: it was int64 data type and registered to int32 as workaround)":""}`),r.constant(i,d)}registerGraphInput(n){this.temporaryGraphInputs.push(n)}registerGraphOutput(n){this.temporaryGraphOutputs.push(n)}isGraphInput(n,e){let t=this.sessionGraphInputs.get(n);return t?t.includes(e):!1}isGraphOutput(n,e){let t=this.sessionGraphOutputs.get(n);return t?t.includes(e):!1}isGraphInputOutputTypeSupported(n,e,t=!0){let r=Vf.get(Pc(e)),i=this.mlOpSupportLimitsBySessionId.get(n);return typeof r>"u"?!1:t?!!i?.input.dataTypes.includes(r):!!i?.output.dataTypes.includes(r)}flush(){}}}),rC=et(()=>{}),g_,Xm,Jm,FB,zB,y_,Rw,UB,XP,Zee=et(()=>{ko(),rC(),g_=new Map([[64,250],[128,200],[256,200],[512,200],[2048,230],[4096,200],[8192,50],[16384,50],[32768,50],[65536,50],[131072,50],[262144,50],[524288,50],[1048576,50],[2097152,30],[4194304,20],[8388608,10],[12582912,10],[16777216,10],[26214400,15],[33554432,22],[44236800,2],[58982400,6],[67108864,6],[134217728,6],[167772160,6]]),Xm=[],Jm=n=>Math.ceil(Number(n)/16)*16,FB=n=>{for(let e=0;e<Xm.length;e++){let t=Xm[e];if(n<=t)return t}return Math.ceil(n/16)*16},zB=1,y_=()=>zB++,Rw=async(n,e,t,r)=>{let i=Jm(t),s=n.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});try{let a=n.getCommandEncoder();n.endComputePass(),a.copyBufferToBuffer(e,0,s,0,i),n.flush(),await s.mapAsync(GPUMapMode.READ);let o=s.getMappedRange();if(r){let l=r();return l.set(new Uint8Array(o,0,t)),l}else return new Uint8Array(o.slice(0,t))}finally{s.destroy()}},UB=class{constructor(n){this.backend=n,this.storageCache=new Map,this.freeBuffers=new Map,this.freeUniformBuffers=new Map,this.buffersPending=[],this.capturedPendingBuffers=new Map;for(let[e]of g_)Xm.push(e),this.freeBuffers.set(e,[]),this.freeUniformBuffers.set(e,[]);this.sessionCount=0}upload(n,e){let t=e.buffer,r=e.byteOffset,i=e.byteLength,s=Jm(i),a=this.storageCache.get(n);if(!a)throw new Error("gpu data for uploading does not exist");if(Number(a.originalSize)!==i)throw new Error(`inconsistent data size. gpu data size=${a.originalSize}, data size=${i}`);let o=this.backend.device.createBuffer({mappedAtCreation:!0,size:s,usage:GPUBufferUsage.MAP_WRITE|GPUBufferUsage.COPY_SRC}),l=o.getMappedRange();new Uint8Array(l).set(new Uint8Array(t,r,i)),o.unmap();let c=this.backend.device.createCommandEncoder();c.copyBufferToBuffer(o,0,a.gpuData.buffer,0,s),this.backend.device.queue.submit([c.finish()]),o.destroy(),un("verbose",()=>`[WebGPU] GpuDataManager.upload(id=${n})`)}memcpy(n,e){let t=this.storageCache.get(n);if(!t)throw new Error("source gpu data for memcpy does not exist");let r=this.storageCache.get(e);if(!r)throw new Error("destination gpu data for memcpy does not exist");if(t.originalSize!==r.originalSize)throw new Error("inconsistent source and destination gpu data size");let i=Jm(t.originalSize),s=this.backend.getCommandEncoder();this.backend.endComputePass(),s.copyBufferToBuffer(t.gpuData.buffer,0,r.gpuData.buffer,0,i)}registerExternalBuffer(n,e,t){let r;if(t){if(r=t[0],n===t[1])return un("verbose",()=>`[WebGPU] GpuDataManager.registerExternalBuffer(size=${e}) => id=${r}, buffer is the same, skip.`),r;if(this.backend.capturedCommandList.has(this.backend.currentSessionId))throw new Error(`Registering a different external buffer under graph capture mode is not supported yet.
|
|
12827
12827
|
Please use the previous external buffer!`)}else r=y_();return this.storageCache.set(r,{gpuData:{id:r,type:0,buffer:n},originalSize:e}),un("verbose",()=>`[WebGPU] GpuDataManager.registerExternalBuffer(size=${e}) => id=${r}, registered.`),r}unregisterExternalBuffer(n){n!==void 0&&(this.storageCache.delete(n),un("verbose",()=>`[WebGPU] GpuDataManager.unregisterExternalBuffer() => id=${n}`))}create(n,e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST){let t=FB(n),r,i=(e&GPUBufferUsage.STORAGE)===GPUBufferUsage.STORAGE,s=(e&GPUBufferUsage.UNIFORM)===GPUBufferUsage.UNIFORM;if(i||s){let o=(i?this.freeBuffers:this.freeUniformBuffers).get(t);o?o.length>0?r=o.pop():r=this.backend.device.createBuffer({size:t,usage:e}):r=this.backend.device.createBuffer({size:t,usage:e})}else r=this.backend.device.createBuffer({size:t,usage:e});let a={id:y_(),type:0,buffer:r};return this.storageCache.set(a.id,{gpuData:a,originalSize:Number(n)}),un("verbose",()=>`[WebGPU] GpuDataManager.create(size=${n}) => id=${a.id}`),a}get(n){return this.storageCache.get(n)?.gpuData}release(n){let e=typeof n=="bigint"?Number(n):n,t=this.storageCache.get(e);if(!t){if(this.storageCache.size===0)return 0;throw new Error("releasing data does not exist")}return un("verbose",()=>`[WebGPU] GpuDataManager.release(id=${e}), gpuDataId=${t.gpuData.id}`),this.storageCache.delete(e),this.buffersPending.push(t.gpuData.buffer),t.originalSize}async download(n,e){let t=this.storageCache.get(Number(n));if(!t)throw new Error("data does not exist");await Rw(this.backend,t.gpuData.buffer,t.originalSize,e)}refreshPendingBuffers(){if(this.buffersPending.length!==0)if(this.backend.sessionStatus==="default"){for(let n of this.buffersPending){let e=g_.get(n.size);if((n.usage&GPUBufferUsage.STORAGE)===GPUBufferUsage.STORAGE){let t=this.freeBuffers.get(n.size)||[];e===void 0||t.length>=e?n.destroy():t.push(n)}else if((n.usage&GPUBufferUsage.UNIFORM)===GPUBufferUsage.UNIFORM){let t=this.freeUniformBuffers.get(n.size)||[];e===void 0||t.length>=e?n.destroy():t.push(n)}else n.destroy()}this.buffersPending=[]}else{let n=this.capturedPendingBuffers.get(this.backend.currentSessionId);n||(n=[],this.capturedPendingBuffers.set(this.backend.currentSessionId,n));for(let e of this.buffersPending)n.push(e);this.buffersPending=[]}}dispose(){this.freeBuffers.forEach(n=>{n.forEach(e=>{e.destroy()})}),this.freeUniformBuffers.forEach(n=>{n.forEach(e=>{e.destroy()})}),this.storageCache.forEach(n=>{n.gpuData.buffer.destroy()}),this.capturedPendingBuffers.forEach(n=>{n.forEach(e=>{e.destroy()})}),this.storageCache=new Map,this.freeBuffers=new Map,this.freeUniformBuffers=new Map,this.capturedPendingBuffers=new Map}onCreateSession(){this.sessionCount+=1}onReleaseSession(n){let e=this.capturedPendingBuffers.get(n);e&&(e.forEach(t=>{t.destroy()}),this.capturedPendingBuffers.delete(n)),this.sessionCount-=1,this.sessionCount===0&&(un("warning",()=>"[WebGPU] Clearing webgpu buffer cache"),this.storageCache.forEach(t=>{t.gpuData.buffer.destroy()}),this.storageCache=new Map)}},XP=(...n)=>new UB(...n)}),OB,yn,qn=et(()=>{OB=class{constructor(n){Object.assign(this,n)}get cacheKey(){return this.key||(this.key=Object.getOwnPropertyNames(this).sort().map(n=>`${this[n]}`).join(";")),this.key}},yn=n=>new OB(n)}),nh,Km,gr,Kr,It,Vn,Dw,Rd,Ul,wt,Hf,Oe,vt,JP,iC,$B,KP,Wt=et(()=>{Lt(),jt(),nh=64,Km=(n,e)=>{if(e===3)throw new Error("vec3 has same alignment as vec4, use vec4 instead");switch(Number(n)){case 10:return e>1?`vec${e}<f16>`:"f16";case 1:return e>1?`vec${e}<f32>`:"f32";case 6:return e>1?`vec${e}<i32>`:"i32";case 12:return e>1?`vec${e}<u32>`:"u32";case 7:if(e>1)throw new Error("currently not supported vecX of uint64 yet");return["vec2<u32>","i32"];case 13:if(e>1)throw new Error("currently not supported vecX of uint64 yet");return["vec2<u32>","u32"];case 9:if(e!==4)throw new Error("bool must be vec4");return["u32","vec4<bool>"];case 22:return"i32";case 21:return"u32";default:throw new Error(`Unknown data type: ${n}`)}},gr=(n,e=1)=>{let t=Km(n,e);return typeof t=="string"?t:t[0]},Kr=(n,e=1)=>{let t=Km(n,e);return typeof t=="string"?t:t[1]},It=(...n)=>{let e=[];return n.forEach(t=>{t.length!==0&&e.push({type:12,data:t},{type:12,data:Le.computeStrides(t)})}),e},Vn=n=>n%4===0?4:n%2===0?2:1,Dw=(n="f32",e,t="0")=>!e||e===1?`${n}(${t})`:`vec${e}<${n}>(${t})`,Rd=(n,e,t)=>n==="f32"?t:e===1?`f32(${t})`:`vec${e}<f32>(${t})`,Ul=(n,e)=>e===4?`(${n}.x + ${n}.y + ${n}.z + ${n}.w)`:e===2?`(${n}.x + ${n}.y)`:e===3?`(${n}.x + ${n}.y + ${n}.z)`:n,wt=(n,e,t,r)=>n.startsWith("uniforms.")&&t>4?typeof e=="string"?r==="f16"?`${n}[(${e}) / 8][(${e}) % 8 / 4][(${e}) % 8 % 4]`:`${n}[(${e}) / 4][(${e}) % 4]`:r==="f16"?`${n}[${Math.floor(e/8)}][${Math.floor(e%8/4)}][${e%8%4}]`:`${n}[${Math.floor(e/4)}][${e%4}]`:t>1?`${n}[${e}]`:n,Hf=(n,e,t,r,i)=>{let s=typeof t=="number",a=s?t:t.length,o=[...new Array(a).keys()],l=a<2?"u32":a<=4?`vec${a}<u32>`:`array<u32, ${a}>`,c=Km(e,i),d=typeof c=="string"?c:c[1],h=typeof c=="string"?c:c[0],p={indices:l,value:d,storage:h,tensor:e},A=L=>typeof L=="string"?L:`${L}u`,y={offsetToIndices:!1,indicesToOffset:!1,broadcastedIndicesToOffset:!1,set:!1,setByIndices:!1,get:!1,getByIndices:!1},m=s?"uniforms.":"",x=`${m}${n}_shape`,g=`${m}${n}_strides`,_="";for(let L=0;L<a-1;L++)_+=`
|
|
12828
12828
|
let dim${L} = current / ${wt(g,L,a)};
|
|
12829
12829
|
let rest${L} = current % ${wt(g,L,a)};
|
|
@@ -13227,7 +13227,7 @@ var best_index : i32 = 0;`,`if (${r.getByIndices("input_indices")} ${e.selectLas
|
|
|
13227
13227
|
let x = ${h.getByOffset("global_idx")};
|
|
13228
13228
|
let value = (x - inputMean) * inverseSqrt(inputVar + epsilon) * scale + bias;
|
|
13229
13229
|
${x.setByOffset("global_idx","value")}
|
|
13230
|
-
}`;return{name:"BatchNormalization",shaderCache:{hint:`${e.epsilon}_${e.format}_${r}_${a}`,inputDependencies:c?["rank","type","type","type","type"]:void 0},getShaderSource:_,getRunData:()=>({outputs:[{dims:n[0].dims,dataType:n[0].dataType}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:c?[{type:12,data:l},...It(s)]:[{type:12,data:l}]})}},bM=n=>yn(n),EL=(n,e)=>{let{inputs:t,outputCount:r}=n,i=bM({...e,outputCount:r});if(
|
|
13230
|
+
}`;return{name:"BatchNormalization",shaderCache:{hint:`${e.epsilon}_${e.format}_${r}_${a}`,inputDependencies:c?["rank","type","type","type","type"]:void 0},getShaderSource:_,getRunData:()=>({outputs:[{dims:n[0].dims,dataType:n[0].dataType}],dispatchGroup:{x:Math.ceil(l/64)},programUniforms:c?[{type:12,data:l},...It(s)]:[{type:12,data:l}]})}},bM=n=>yn(n),EL=(n,e)=>{let{inputs:t,outputCount:r}=n,i=bM({...e,outputCount:r});if(Bn.webgpu.validateInputContent&&vM(t,i),e.trainingMode)throw new Error("BatchNormalization trainingMode is not supported yet.");n.compute(_M(t,i))}}),wM,EM,IL,rte=et(()=>{jt(),Wt(),wM=n=>{if(n[0].dims.length!==3)throw new Error("input should have 3 dimensions");if(![320,640,1280].includes(n[0].dims[2]))throw new Error("number of channels should be 320, 640 or 1280");if(n[1].dims.length!==1)throw new Error("bias is expected to have 1 dimensions");if(n[0].dims[2]!==n[1].dims[0])throw new Error("last dimension of input and bias are not the same")},EM=n=>{let e=n[0].dims,t=n[0].dims[2],r=Le.size(e)/4,i=n[0].dataType,s=Oe("input",i,e,4),a=Oe("bias",i,[t],4),o=Oe("residual",i,e,4),l=vt("output",i,e,4);return{name:"BiasAdd",getRunData:()=>({outputs:[{dims:e,dataType:n[0].dataType}],dispatchGroup:{x:Math.ceil(r/64)}}),getShaderSource:c=>`
|
|
13231
13231
|
const channels = ${t}u / 4;
|
|
13232
13232
|
${c.declareVariables(s,a,o,l)}
|
|
13233
13233
|
|
|
@@ -14959,7 +14959,7 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
14959
14959
|
var value = ${p}(0);
|
|
14960
14960
|
${A}
|
|
14961
14961
|
output[global_idx] = value;
|
|
14962
|
-
}`};return{name:"Pad",shaderCache:{hint:`${e.mode}${a}`,inputDependencies:o},getRunData:()=>({outputs:[{dims:t,dataType:n[0].dataType}],dispatchGroup:{x:Math.ceil(Le.size(t)/64)},programUniforms:s}),getShaderSource:l}},tR=(n,e)=>{if(n.length>1){let t=n[1].getBigInt64Array(),r=n.length>=3&&n[2].data?n[2].dataType===10?n[2].getUint16Array()[0]:n[2].getFloat32Array()[0]:0,i=n[0].dims.length,s=new Int32Array(2*i).fill(0);if(n.length>=4){let o=n[3].getBigInt64Array();for(let l=0;l<o.length;l++)s[Number(o[l])]=Number(t[l]),s[Number(o[l])+i]=Number(t[l+o.length])}else t.forEach((o,l)=>s[Number(l)]=Number(o));let a=[];return s.forEach(o=>a.push(o)),{mode:e.mode,value:r,pads:a}}else return e},u4=(n,e)=>{qT(n.inputs);let t=tR(n.inputs,e);n.compute(eR(n.inputs,t),{inputs:[0]})}}),qf,N_,Q_,P_,L_,nR,rR,F_,z_,d4,h4,U_,f4,p4,O_,A4,m4,g4,y4,Rte=et(()=>{gs(),Lt(),jt(),Wt(),qf=n=>{if(
|
|
14962
|
+
}`};return{name:"Pad",shaderCache:{hint:`${e.mode}${a}`,inputDependencies:o},getRunData:()=>({outputs:[{dims:t,dataType:n[0].dataType}],dispatchGroup:{x:Math.ceil(Le.size(t)/64)},programUniforms:s}),getShaderSource:l}},tR=(n,e)=>{if(n.length>1){let t=n[1].getBigInt64Array(),r=n.length>=3&&n[2].data?n[2].dataType===10?n[2].getUint16Array()[0]:n[2].getFloat32Array()[0]:0,i=n[0].dims.length,s=new Int32Array(2*i).fill(0);if(n.length>=4){let o=n[3].getBigInt64Array();for(let l=0;l<o.length;l++)s[Number(o[l])]=Number(t[l]),s[Number(o[l])+i]=Number(t[l+o.length])}else t.forEach((o,l)=>s[Number(l)]=Number(o));let a=[];return s.forEach(o=>a.push(o)),{mode:e.mode,value:r,pads:a}}else return e},u4=(n,e)=>{qT(n.inputs);let t=tR(n.inputs,e);n.compute(eR(n.inputs,t),{inputs:[0]})}}),qf,N_,Q_,P_,L_,nR,rR,F_,z_,d4,h4,U_,f4,p4,O_,A4,m4,g4,y4,Rte=et(()=>{gs(),Lt(),jt(),Wt(),qf=n=>{if(Bn.webgpu.validateInputContent&&(!n||n.length!==1))throw new Error("Pool ops requires 1 input.")},N_=(n,e,t)=>{let r=e.format==="NHWC",i=n.dims.slice();r&&i.splice(1,0,i.pop());let s=Object.hasOwnProperty.call(e,"dilations"),a=e.kernelShape.slice(),o=e.strides.slice(),l=s?e.dilations.slice():[],c=e.pads.slice();Zg.adjustPoolAttributes(t,i,a,o,l,c);let d=Zg.computePoolOutputShape(t,i,o,l,a,c,e.autoPad),h=Object.assign({},e);s?Object.assign(h,{kernelShape:a,strides:o,pads:c,dilations:l,cacheKey:e.cacheKey}):Object.assign(h,{kernelShape:a,strides:o,pads:c,cacheKey:e.cacheKey});let p=d.slice();return p.push(p.splice(1,1)[0]),[h,r?p:d]},Q_=(n,e)=>{let t=e.format==="NHWC",r=Le.size(n),i=Le.size(e.kernelShape),s=[{type:12,data:r},{type:12,data:i}],a=[{name:"outputSize",type:"u32"},{name:"kernelSize",type:"u32"}];if(e.kernelShape.length<=2){let o=e.kernelShape[e.kernelShape.length-1],l=e.strides[e.strides.length-1],c=e.pads[e.pads.length/2-1],d=e.pads[e.pads.length-1],h=!!(c+d);s.push({type:12,data:o},{type:12,data:l},{type:12,data:c},{type:12,data:d}),a.push({name:"kw",type:"u32"},{name:"sw",type:"u32"},{name:"pwStart",type:"u32"},{name:"pwEnd",type:"u32"});let p=!1;if(e.kernelShape.length===2){let A=e.kernelShape[e.kernelShape.length-2],y=e.strides[e.strides.length-2],m=e.pads[e.pads.length/2-2],x=e.pads[e.pads.length-2];p=!!(m+x),s.push({type:12,data:A},{type:12,data:y},{type:12,data:m},{type:12,data:x}),a.push({name:"kh",type:"u32"},{name:"sh",type:"u32"},{name:"phStart",type:"u32"},{name:"phEnd",type:"u32"})}return[s,a,!0,h,p]}else{if(t)throw new Error("Pooling with kernelShape.length > 2 is not supported for NHWC format.");let o=Le.computeStrides(e.kernelShape);s.push({type:12,data:o},{type:12,data:e.pads},{type:12,data:e.strides}),a.push({name:"kernelStrides",type:"u32",length:o.length},{name:"pads",type:"u32",length:e.pads.length},{name:"strides",type:"u32",length:e.strides.length});let l=e.pads.reduce((c,d)=>c+d);return[s,a,!!l,!1,!1]}},P_=(n,e,t,r,i,s,a,o,l,c,d,h)=>{let p=i.format==="NHWC",A=e.type.value,y=vt("output",e.type.tensor,r);if(i.kernelShape.length<=2){let m="",x="",g="",_=t-(p?2:1);if(d?m=`
|
|
14963
14963
|
for (var i: u32 = 0u; i < uniforms.kw; i++) {
|
|
14964
14964
|
xIndices[${_}] = indices[${_}] * uniforms.sw - uniforms.pwStart + i;
|
|
14965
14965
|
if (xIndices[${_}] < 0 || xIndices[${_}]
|
|
@@ -15093,7 +15093,7 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
15093
15093
|
${c.mainStart()}
|
|
15094
15094
|
${c.guardAgainstOutOfBoundsWorkgroupSizes("uniforms.outputSize")}
|
|
15095
15095
|
output[global_idx] = uniforms.start + ${h}(global_idx) * uniforms.delta;
|
|
15096
|
-
}`};return{name:"Range",shaderCache:{hint:`${r}`},getShaderSource:l,getRunData:()=>({outputs:[{dims:s,dataType:r}],dispatchGroup:{x:Math.ceil(a/64)},programUniforms:o})}},_4=n=>{let e=0,t=0,r=0;n.inputs[0].dataType===6?(e=n.inputs[0].getInt32Array()[0],t=n.inputs[1].getInt32Array()[0],r=n.inputs[2].getInt32Array()[0]):n.inputs[0].dataType===1&&(e=n.inputs[0].getFloat32Array()[0],t=n.inputs[1].getFloat32Array()[0],r=n.inputs[2].getFloat32Array()[0]),
|
|
15096
|
+
}`};return{name:"Range",shaderCache:{hint:`${r}`},getShaderSource:l,getRunData:()=>({outputs:[{dims:s,dataType:r}],dispatchGroup:{x:Math.ceil(a/64)},programUniforms:o})}},_4=n=>{let e=0,t=0,r=0;n.inputs[0].dataType===6?(e=n.inputs[0].getInt32Array()[0],t=n.inputs[1].getInt32Array()[0],r=n.inputs[2].getInt32Array()[0]):n.inputs[0].dataType===1&&(e=n.inputs[0].getFloat32Array()[0],t=n.inputs[1].getFloat32Array()[0],r=n.inputs[2].getFloat32Array()[0]),Bn.webgpu.validateInputContent&&aR(e,t,r),n.compute(oR(e,t,r,n.inputs[0].dataType),{inputs:[]})}}),lR,cR,b4,w4,Nte=et(()=>{Lt(),jt(),qn(),Wt(),lR=(n,e,t,r)=>{if(n!=="none"&&r!=="i32"&&r!=="u32"&&r!=="f32")throw new Error(`Input ${r} is not supported with reduction ${n}.`);let i=`{
|
|
15097
15097
|
var oldValue = 0;
|
|
15098
15098
|
loop {
|
|
15099
15099
|
let newValueF32 =`,s=`;
|
|
@@ -15606,4 +15606,4 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
15606
15606
|
}`},FR=n=>{let e=n[1].dims,t=n[2].dims,r=n[0].dims,i=n[1].dataType,s=!(Le.areEqual(e,t)&&Le.areEqual(t,r)),a=e,o=Le.size(e);if(s){let c=th.calcShape(th.calcShape(e,t,!1),r,!1);if(!c)throw new Error("Can't perform where op on the given tensors");a=c,o=Le.size(a)}let l=Math.ceil(o/4);return{name:"Where",shaderCache:{inputDependencies:["rank","rank","rank"]},getShaderSource:c=>LR(c,n,a,s,i),getRunData:()=>({outputs:[{dims:a,dataType:i}],dispatchGroup:{x:Math.ceil(o/64/4)},programUniforms:[{type:12,data:l},...It(r,e,t,a)]})}},D4=n=>{n.compute(FR(n.inputs))}}),k4,Ote=et(()=>{tte(),aC(),nte(),rte(),ite(),ste(),ate(),dte(),fte(),pte(),Ate(),mte(),gte(),yte(),xte(),vte(),_te(),bte(),wte(),Ete(),Ite(),Cte(),Ste(),Bte(),Mte(),KF(),Tte(),Rte(),Dte(),kte(),Nte(),sC(),Qte(),r4(),Pte(),Lte(),Fte(),t4(),zte(),jl(),oC(),Ute(),k4=new Map([["Abs",[CL]],["Acos",[SL]],["Acosh",[BL]],["Add",[lF]],["ArgMax",[bL,Nw]],["ArgMin",[_L,Nw]],["Asin",[ML]],["Asinh",[TL]],["Atan",[RL]],["Atanh",[DL]],["Attention",[wL]],["AveragePool",[h4,d4]],["BatchNormalization",[EL]],["BiasAdd",[IL]],["BiasSplitGelu",[oF]],["Cast",[NL,kL]],["Ceil",[PL]],["Clip",[QL]],["Concat",[yF,xF]],["Conv",[Uw,zw]],["ConvTranspose",[MF,BF]],["Cos",[LL]],["Cosh",[FL]],["CumSum",[TF,RF]],["DepthToSpace",[DF,kF]],["DequantizeLinear",[x4,v4]],["Div",[cF]],["Einsum",[NF,QF]],["Elu",[zL,cp]],["Equal",[uF]],["Erf",[UL]],["Exp",[OL]],["Expand",[PF]],["FastGelu",[LF]],["Floor",[$L]],["FusedConv",[Uw,zw]],["Gather",[zF,FF]],["GatherElements",[HF,VF]],["GatherBlockQuantized",[$F,GF]],["GatherND",[UF,OF]],["Gelu",[GL]],["Gemm",[WF,jF]],["GlobalAveragePool",[p4,f4]],["GlobalMaxPool",[y4,g4]],["Greater",[pF]],["GreaterOrEqual",[mF]],["GridSample",[qF,YF]],["GroupQueryAttention",[i4]],["HardSigmoid",[JL,XL]],["InstanceNormalization",[s4]],["LayerNormalization",[a4]],["LeakyRelu",[VL,cp]],["Less",[AF]],["LessOrEqual",[gF]],["Log",[sF]],["MatMul",[o4]],["MatMulNBits",[l4,c4]],["MaxPool",[A4,m4]],["Mul",[dF]],["MultiHeadAttention",[JF,XF]],["Neg",[jL]],["Not",[HL]],["Pad",[u4]],["Pow",[hF]],["QuickGelu",[aF,cp]],["Range",[_4]],["Reciprocal",[WL]],["ReduceMin",[mL]],["ReduceMean",[dL]],["ReduceMax",[AL]],["ReduceSum",[yL]],["ReduceProd",[gL]],["ReduceL1",[hL]],["ReduceL2",[fL]],["ReduceLogSum",[vL]],["ReduceLogSumExp",[pL]],["ReduceSumSquare",[xL]],["Relu",[qL]],["Resize",[E4,I4]],["RotaryEmbedding",[n4]],["ScatterND",[w4,b4]],["Sigmoid",[YL]],["Sin",[KL]],["Sinh",[ZL]],["Slice",[S4,B4]],["SkipLayerNormalization",[C4]],["Split",[ZF,e4]],["Sqrt",[eF]],["Softmax",[M4,T4]],["Sub",[fF]],["Tan",[tF]],["Tanh",[nF]],["ThresholdedRelu",[iF,cp]],["Tile",[R4]],["Transpose",[ZP,eL]],["Where",[D4]]])}),N4,$te=et(()=>{gs(),ko(),Wt(),N4=class{constructor(n){this.backend=n,this.repo=new Map,this.attributesBound=!1}getArtifact(n){return this.repo.get(n)}setArtifact(n,e){this.repo.set(n,e)}run(n,e,t,r,i){Pa(n.programInfo.name);let s=this.backend.device,a=this.backend.getComputePassEncoder();this.backend.writeTimestamp(this.backend.pendingDispatchNumber*2);let o=[];for(let c of e)o.push({binding:o.length,resource:{buffer:c.buffer}});for(let c of t)o.push({binding:o.length,resource:{buffer:c.buffer}});i&&o.push({binding:o.length,resource:i});let l=s.createBindGroup({layout:n.computePipeline.getBindGroupLayout(0),entries:o,label:n.programInfo.name});if(this.backend.sessionStatus==="capturing"){let c={kernelId:this.backend.currentKernelId,computePipeline:n.computePipeline,bindGroup:l,dispatchGroup:r};this.backend.capturedCommandList.get(this.backend.currentSessionId).push(c)}a.setPipeline(n.computePipeline),a.setBindGroup(0,l),a.dispatchWorkgroups(...r),this.backend.writeTimestamp(this.backend.pendingDispatchNumber*2+1),this.backend.pendingDispatchNumber++,(this.backend.pendingDispatchNumber>=this.backend.maxDispatchNumber||this.backend.queryType==="at-passes")&&this.backend.endComputePass(),this.backend.pendingDispatchNumber>=this.backend.maxDispatchNumber&&this.backend.flush(),Js(n.programInfo.name)}dispose(){}build(n,e){Pa(n.name);let t=this.backend.device,r=[];[{feature:"shader-f16",extension:"f16"},{feature:"subgroups",extension:"subgroups"}].forEach(c=>{t.features.has(c.feature)&&r.push(`enable ${c.extension};`)});let i=KP(e,this.backend.device.limits),s=n.getShaderSource(i),a=`${r.join(`
|
|
15607
15607
|
`)}
|
|
15608
15608
|
${i.additionalImplementations}
|
|
15609
|
-
${s}`,o=t.createShaderModule({code:a,label:n.name});un("verbose",()=>`[WebGPU] ${n.name} shader code: ${a}`);let l=t.createComputePipeline({compute:{module:o,entryPoint:"main"},layout:"auto",label:n.name});return Js(n.name),{programInfo:n,computePipeline:l,uniformVariablesInfo:i.variablesInfo}}normalizeDispatchGroupSize(n){let e=typeof n=="number"?n:n.x,t=typeof n=="number"?1:n.y||1,r=typeof n=="number"?1:n.z||1,i=this.backend.device.limits.maxComputeWorkgroupsPerDimension;if(e<=i&&t<=i&&r<=i)return[e,t,r];let s=e*t*r,a=Math.ceil(Math.sqrt(s));if(a>i){if(a=Math.ceil(Math.cbrt(s)),a>i)throw new Error("Total dispatch size exceeds WebGPU maximum.");return[a,a,a]}else return[a,a,1]}}}),Q4={};_h(Q4,{WebGpuBackend:()=>P4});var zR,UR,OR,P4,Gte=et(()=>{gs(),Lt(),ko(),WP(),Zee(),Ote(),$te(),zR=(n,e)=>{if(e.length!==n.length)throw new Error(`inputDependencies length ${e.length} is not equal to inputTensors length ${n.length}.`);let t=[];for(let r=0;r<n.length;++r){let i=n[r].dataType;switch(e[r]){case"none":{t.push("");break}case"type":{t.push(`${i}`);break}case"rank":{let s=n[r].dims.length;t.push(`${i};${s}`);break}case"dims":{let s=n[r].dims.join(",");t.push(`${i};${s}`);break}default:throw new Error(`unsupported input dependency: ${e[r]}`)}}return t.join("|")},UR=(n,e,t)=>{let r=n.name;return n.shaderCache?.hint&&(r+="["+n.shaderCache.hint+"]"),r+=":"+t+`:${zR(e,n.shaderCache?.inputDependencies??new Array(e.length).fill("dims"))}`,r},OR=class{constructor(n){n&&(this.architecture=n.architecture,this.vendor=n.vendor)}isArchitecture(n){return this.architecture===n}isVendor(n){return this.vendor===n}},P4=class{constructor(){this.currentSessionId=null,this.currentKernelId=null,this.commandEncoder=null,this.computePassEncoder=null,this.maxDispatchNumber=16,this.pendingDispatchNumber=0,this.pendingKernels=[],this.pendingQueries=new Map,this.sessionStatus="default",this.capturedCommandList=new Map,this.capturedPendingKernels=new Map,this.sessionExternalDataMapping=new Map}get currentKernelCustomData(){if(this.currentKernelId===null)throw new Error("currentKernelCustomData(): currentKernelId is null. (should not happen)");let n=this.kernelCustomData.get(this.currentKernelId);return n||(n={},this.kernelCustomData.set(this.currentKernelId,n)),n}async initialize(n,e){this.env=n;let t=[],r={requiredLimits:{maxComputeWorkgroupStorageSize:e.limits.maxComputeWorkgroupStorageSize,maxComputeWorkgroupsPerDimension:e.limits.maxComputeWorkgroupsPerDimension,maxStorageBufferBindingSize:e.limits.maxStorageBufferBindingSize,maxBufferSize:e.limits.maxBufferSize,maxComputeInvocationsPerWorkgroup:e.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupSizeX:e.limits.maxComputeWorkgroupSizeX,maxComputeWorkgroupSizeY:e.limits.maxComputeWorkgroupSizeY,maxComputeWorkgroupSizeZ:e.limits.maxComputeWorkgroupSizeZ},requiredFeatures:t},i=s=>e.features.has(s)&&t.push(s)&&!0;i("chromium-experimental-timestamp-query-inside-passes")||i("timestamp-query"),i("shader-f16"),i("subgroups"),this.device=await e.requestDevice(r),this.adapterInfo=new OR(e.info||await e.requestAdapterInfo()),this.gpuDataManager=XP(this),this.programManager=new N4(this),this.kernels=new Map,this.kernelPersistentData=new Map,this.kernelCustomData=new Map,tC(n.logLevel,!!n.debug),this.device.onuncapturederror=s=>{s.error instanceof GPUValidationError},Object.defineProperty(this.env.webgpu,"device",{value:this.device,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.env.webgpu,"adapter",{value:e,writable:!1,enumerable:!0,configurable:!1}),this.setQueryType()}dispose(){typeof this.querySet<"u"&&this.querySet.destroy(),this.gpuDataManager.dispose()}getCommandEncoder(){return this.commandEncoder||(this.commandEncoder=this.device.createCommandEncoder()),this.commandEncoder}getComputePassEncoder(){if(!this.computePassEncoder){let n=this.getCommandEncoder(),e={};this.queryType==="at-passes"&&(e.timestampWrites={querySet:this.querySet,beginningOfPassWriteIndex:this.pendingDispatchNumber*2,endOfPassWriteIndex:this.pendingDispatchNumber*2+1}),this.computePassEncoder=n.beginComputePass(e)}return this.computePassEncoder}endComputePass(){this.computePassEncoder&&(this.computePassEncoder.end(),this.computePassEncoder=null)}flush(){if(!this.commandEncoder)return;Pa(),this.endComputePass();let n;this.queryType!=="none"&&(this.commandEncoder.resolveQuerySet(this.querySet,0,this.pendingDispatchNumber*2,this.queryResolveBuffer,0),n=this.device.createBuffer({size:this.pendingDispatchNumber*2*8,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),this.pendingQueries.set(n,this.pendingKernels),this.pendingKernels=[],this.commandEncoder.copyBufferToBuffer(this.queryResolveBuffer,0,n,0,this.pendingDispatchNumber*2*8)),this.device.queue.submit([this.commandEncoder.finish()]),this.gpuDataManager.refreshPendingBuffers(),this.commandEncoder=null,this.pendingDispatchNumber=0,this.queryType!=="none"&&n.mapAsync(GPUMapMode.READ).then(()=>{let e=new BigUint64Array(n.getMappedRange()),t=this.pendingQueries.get(n);for(let r=0;r<e.length/2;r++){let i=t[r],s=i.kernelId,a=this.kernels.get(s),o=a.kernelType,l=a.kernelName,c=i.programName,d=i.inputTensorViews,h=i.outputTensorViews,p=e[r*2],A=e[r*2+1];typeof this.queryTimeBase>"u"&&(this.queryTimeBase=p);let y=Number(p-this.queryTimeBase),m=Number(A-this.queryTimeBase);if(!Number.isSafeInteger(y)||!Number.isSafeInteger(m))throw new RangeError("incorrect timestamp range");if(this.env.webgpu.profiling?.ondata)this.env.webgpu.profiling.ondata({version:1,inputsMetadata:d.map(x=>({dims:x.dims,dataType:ho(x.dataType)})),outputsMetadata:h.map(x=>({dims:x.dims,dataType:ho(x.dataType)})),kernelId:s,kernelType:o,kernelName:l,programName:c,startTime:y,endTime:m});else{let x="";d.forEach((_,b)=>{x+=`input[${b}]: [${_.dims}] | ${ho(_.dataType)}, `});let g="";h.forEach((_,b)=>{g+=`output[${b}]: [${_.dims}] | ${ho(_.dataType)}, `})}Xg("GPU",`${c}::${p}::${A}`)}n.unmap(),this.pendingQueries.delete(n)}),Js()}run(n,e,t,r,i,s){Pa(n.name);let a=[];for(let _=0;_<e.length;++_){let b=e[_].data;if(b===0)continue;let w=this.gpuDataManager.get(b);if(!w)throw new Error(`no GPU data for input: ${b}`);a.push(w)}let{outputs:o,dispatchGroup:l,programUniforms:c}=n.getRunData(e),d=t.length===0?o.map((_,b)=>b):t;if(d.length!==o.length)throw new Error(`Output size ${d.length} must be equal to ${o.length}.`);let h=[],p=[];for(let _=0;_<o.length;++_){if(!Number.isInteger(d[_])||d[_]<-3||d[_]>=s)throw new Error(`Invalid output index: ${d[_]}`);if(d[_]===-3)continue;let b=d[_]===-1,w=d[_]===-2,I=b||w?i(o[_].dataType,o[_].dims):r(d[_],o[_].dataType,o[_].dims);if(h.push(I),I.data===0)continue;let S=this.gpuDataManager.get(I.data);if(!S)throw new Error(`no GPU data for output: ${I.data}`);if(b&&this.temporaryData.push(S),w){let M=this.kernelPersistentData.get(this.currentKernelId);M||(M=[],this.kernelPersistentData.set(this.currentKernelId,M)),M.push(S)}p.push(S)}if(a.length!==e.length||p.length!==h.length){if(p.length===0)return Js(n.name),h;throw new Error(`Program ${n.name} has zero-sized tensor(s) in inputs or outputs. This is not supported now.`)}let A;if(c){let _=0,b=[];c.forEach(M=>{let T=typeof M.data=="number"?[M.data]:M.data;if(T.length===0)return;let R=M.type===10?2:4,k,H;M.type===10?(H=T.length>4?16:T.length>2?8:T.length*R,k=T.length>4?16:R*T.length):(H=T.length<=2?T.length*R:16,k=16),_=Math.ceil(_/H)*H,b.push(_);let Q=M.type===10?8:4;_+=T.length>4?Math.ceil(T.length/Q)*k:T.length*R});let w=16;_=Math.ceil(_/w)*w;let I=new ArrayBuffer(_);c.forEach((M,T)=>{let R=b[T],k=typeof M.data=="number"?[M.data]:M.data;if(M.type===6)new Int32Array(I,R,k.length).set(k);else if(M.type===12)new Uint32Array(I,R,k.length).set(k);else if(M.type===10)new Uint16Array(I,R,k.length).set(k);else if(M.type===1)new Float32Array(I,R,k.length).set(k);else throw new Error(`Unsupported uniform type: ${ho(M.type)}`)});let S=this.gpuDataManager.create(_,GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM);this.device.queue.writeBuffer(S.buffer,0,I,0,_),this.gpuDataManager.release(S.id),A={offset:0,size:_,buffer:S.buffer}}let y=this.programManager.normalizeDispatchGroupSize(l),m=y[1]===1&&y[2]===1,x=UR(n,e,m),g=this.programManager.getArtifact(x);if(g||(g=this.programManager.build(n,y),this.programManager.setArtifact(x,g),un("info",()=>`[artifact] key: ${x}, programName: ${n.name}`)),c&&g.uniformVariablesInfo){if(c.length!==g.uniformVariablesInfo.length)throw new Error(`Uniform variables count mismatch: expect ${g.uniformVariablesInfo.length}, got ${c.length} in program "${g.programInfo.name}".`);for(let _=0;_<c.length;_++){let b=c[_],w=b.type,I=typeof b.data=="number"?1:b.data.length,[S,M]=g.uniformVariablesInfo[_];if(w!==S||I!==M)throw new Error(`Uniform variable ${_} mismatch: expect type ${S} with size ${M}, got type ${w} with size ${I} in program "${g.programInfo.name}".`)}}if(un("info",()=>`[ProgramManager] run "${n.name}" (key=${x}) with ${y[0]}x${y[1]}x${y[2]}`),this.queryType!=="none"||this.sessionStatus==="capturing"){let _={kernelId:this.currentKernelId,programName:g.programInfo.name,inputTensorViews:e,outputTensorViews:h};this.pendingKernels.push(_),this.sessionStatus==="capturing"&&this.capturedPendingKernels.get(this.currentSessionId).push(_)}return this.programManager.run(g,a,p,y,A),Js(n.name),h}upload(n,e){this.gpuDataManager.upload(n,e)}memcpy(n,e){this.gpuDataManager.memcpy(n,e)}async download(n,e){await this.gpuDataManager.download(n,e)}alloc(n){return this.gpuDataManager.create(n).id}free(n){return this.gpuDataManager.release(n)}createKernel(n,e,t,r){let i=k4.get(n);if(!i)throw new Error(`kernel not implemented: ${n}`);let s={kernelType:n,kernelName:r,kernelEntry:i[0],attributes:[i[1],t]};this.kernels.set(e,s)}releaseKernel(n){let e=this.kernelPersistentData.get(n);if(e){for(let t of e)this.gpuDataManager.release(t.id);this.kernelPersistentData.delete(n)}this.kernelCustomData.delete(n),this.kernels.delete(n)}computeKernel(n,e,t){let r=this.kernels.get(n);if(!r)throw new Error(`kernel not created: ${n}`);let i=r.kernelType,s=r.kernelName,a=r.kernelEntry,o=r.attributes;if(this.currentKernelId!==null)throw new Error(`kernel "[${i}] ${s}" is not allowed to be called recursively`);this.currentKernelId=n,o[0]&&(o[1]=o[0](o[1]),o[0]=void 0),un("info",()=>`[WebGPU] Start to run kernel "[${i}] ${s}"...`);let l=this.env.debug;this.temporaryData=[];try{return l&&this.device.pushErrorScope("validation"),a(e,o[1]),0}catch(c){return t.push(Promise.resolve(`[WebGPU] Kernel "[${i}] ${s}" failed. ${c}`)),1}finally{l&&t.push(this.device.popErrorScope().then(c=>c?`GPU validation error for kernel "[${i}] ${s}": ${c.message}`:null));for(let c of this.temporaryData)this.gpuDataManager.release(c.id);this.temporaryData=[],this.currentKernelId=null}}registerBuffer(n,e,t,r){let i=this.sessionExternalDataMapping.get(n);i||(i=new Map,this.sessionExternalDataMapping.set(n,i));let s=i.get(e),a=this.gpuDataManager.registerExternalBuffer(t,r,s);return i.set(e,[a,t]),a}unregisterBuffers(n){let e=this.sessionExternalDataMapping.get(n);e&&(e.forEach(t=>this.gpuDataManager.unregisterExternalBuffer(t[0])),this.sessionExternalDataMapping.delete(n))}getBuffer(n){let e=this.gpuDataManager.get(n);if(!e)throw new Error(`no GPU data for buffer: ${n}`);return e.buffer}createDownloader(n,e,t){return async()=>{let r=await Rw(this,n,e);return nC(r.buffer,t)}}writeTimestamp(n){this.queryType==="inside-passes"&&this.computePassEncoder.writeTimestamp(this.querySet,n)}setQueryType(){this.queryType="none",(this.env.webgpu.profiling?.mode==="default"||(typeof this.env.trace>"u"?this.env.wasm.trace:this.env.trace))&&(this.device.features.has("chromium-experimental-timestamp-query-inside-passes")?this.queryType="inside-passes":this.device.features.has("timestamp-query")&&(this.queryType="at-passes"),this.queryType!=="none"&&typeof this.querySet>"u"&&(this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxDispatchNumber*2}),this.queryResolveBuffer=this.device.createBuffer({size:this.maxDispatchNumber*2*8,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.QUERY_RESOLVE})))}captureBegin(){un("info","captureBegin"),this.capturedCommandList.get(this.currentSessionId)||this.capturedCommandList.set(this.currentSessionId,[]),this.capturedPendingKernels.get(this.currentSessionId)||this.capturedPendingKernels.set(this.currentSessionId,[]),this.flush(),this.sessionStatus="capturing"}captureEnd(){un("info","captureEnd"),this.flush(),this.sessionStatus="default"}replay(){un("info","replay"),this.sessionStatus="replaying";let n=this.capturedCommandList.get(this.currentSessionId),e=this.capturedPendingKernels.get(this.currentSessionId),t=n.length;this.pendingKernels=[];for(let r=0;r<t;r++){let i=this.getComputePassEncoder(),s=n[r];this.writeTimestamp(this.pendingDispatchNumber*2),i.setPipeline(s.computePipeline),i.setBindGroup(0,s.bindGroup),i.dispatchWorkgroups(...s.dispatchGroup),this.writeTimestamp(this.pendingDispatchNumber*2+1),this.pendingDispatchNumber++,this.queryType!=="none"&&this.pendingKernels.push(e[r]),(this.pendingDispatchNumber>=this.maxDispatchNumber||this.queryType==="at-passes")&&this.endComputePass(),this.pendingDispatchNumber>=this.maxDispatchNumber&&this.flush()}this.flush(),this.sessionStatus="default"}onCreateSession(){this.gpuDataManager.onCreateSession()}onReleaseSession(n){this.unregisterBuffers(n),this.capturedCommandList.has(n)&&this.capturedCommandList.delete(n),this.capturedPendingKernels.has(n)&&this.capturedPendingKernels.delete(n),this.gpuDataManager.onReleaseSession(n)}onRunStart(n){this.currentSessionId=n,this.setQueryType()}}}),L4={};_h(L4,{init:()=>F4});var rg,$R,F4,Vte=et(()=>{Lt(),ko(),jt(),Kee(),rg=class z4{constructor(e,t,r,i){this.module=e,this.dataType=t,this.data=r,this.dims=i}getFloat32Array(){if(this.dataType!==1)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new Float32Array:new Float32Array(this.module.HEAP8.buffer,this.data,e)}getBigInt64Array(){if(this.dataType!==7)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new BigInt64Array:new BigInt64Array(this.module.HEAP8.buffer,this.data,e)}getInt32Array(){if(this.dataType!==6)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new Int32Array:new Int32Array(this.module.HEAP8.buffer,this.data,e)}getUint16Array(){if(this.dataType!==10&&this.dataType!==4)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new Uint16Array:new Uint16Array(this.module.HEAP8.buffer,this.data,e)}reshape(e){if(Le.size(e)!==Le.size(this.dims))throw new Error("Invalid new shape");return new z4(this.module,this.dataType,this.data,e)}},$R=class{constructor(n,e,t){this.module=n,this.backend=e,this.customDataOffset=0,this.customDataSize=0,this.adapterInfo=e.adapterInfo;let r=n.PTR_SIZE,i=t/n.PTR_SIZE,s=r===4?"i32":"i64";this.opKernelContext=Number(n.getValue(r*i++,s));let a=Number(n.getValue(r*i++,s));this.outputCount=Number(n.getValue(r*i++,s)),this.customDataOffset=Number(n.getValue(r*i++,"*")),this.customDataSize=Number(n.getValue(r*i++,s));let o=[];for(let l=0;l<a;l++){let c=Number(n.getValue(r*i++,s)),d=Number(n.getValue(r*i++,"*")),h=Number(n.getValue(r*i++,s)),p=[];for(let A=0;A<h;A++)p.push(Number(n.getValue(r*i++,s)));o.push(new rg(n,c,d,p))}this.inputs=o}get kernelCustomData(){return this.backend.currentKernelCustomData}get customDataBuffer(){return this.module.HEAPU8.subarray(this.customDataOffset,this.customDataOffset+this.customDataSize)}compute(n,e){let t=e?.inputs?.map(a=>typeof a=="number"?this.inputs[a]:a)??this.inputs,r=e?.outputs??[],i=(a,o,l)=>new rg(this.module,o,this.output(a,l),l),s=(a,o)=>{let l=Lc(a,o);if(!l)throw new Error(`Unsupported data type: ${a}`);let c=l>0?this.backend.gpuDataManager.create(l).id:0;return new rg(this.module,a,c,o)};return this.backend.run(n,t,r,i,s,this.outputCount)}output(n,e){let t=this.module.stackSave();try{let r=this.module.PTR_SIZE,i=r===4?"i32":"i64",s=this.module.stackAlloc((1+e.length)*r);this.module.setValue(s,e.length,i);for(let a=0;a<e.length;a++)this.module.setValue(s+r*(a+1),e[a],i);return this.module._JsepOutput(this.opKernelContext,n,s)}catch(r){throw new Error(`Failed to generate kernel's output[${n}] with dims [${e}]. If you are running with pre-allocated output, please make sure the output type/dims are correct. Error: ${r}`)}finally{this.module.stackRestore(t)}}},F4=async(n,e,t,r)=>{let i=e.jsepInit;if(!i)throw new Error("Failed to initialize JSEP. The WebAssembly module is not built with JSEP support.");if(n==="webgpu"){let s=(Gte(),Lp(Q4)).WebGpuBackend,a=new s;await a.initialize(t,r),i("webgpu",[a,o=>a.alloc(Number(o)),o=>a.free(o),(o,l,c,d=!1)=>{if(d)un("verbose",()=>`[WebGPU] jsepCopyGpuToGpu: src=${Number(o)}, dst=${Number(l)}, size=${Number(c)}`),a.memcpy(Number(o),Number(l));else{un("verbose",()=>`[WebGPU] jsepCopyCpuToGpu: dataOffset=${Number(o)}, gpuDataId=${Number(l)}, size=${Number(c)}`);let h=e.HEAPU8.subarray(Number(o>>>0),Number(o>>>0)+Number(c));a.upload(Number(l),h)}},async(o,l,c)=>{un("verbose",()=>`[WebGPU] jsepCopyGpuToCpu: gpuDataId=${o}, dataOffset=${l}, size=${c}`),await a.download(Number(o),()=>e.HEAPU8.subarray(Number(l)>>>0,Number(l+c)>>>0))},(o,l,c)=>a.createKernel(o,Number(l),c,e.UTF8ToString(e._JsepGetNodeName(Number(l)))),o=>a.releaseKernel(o),(o,l,c,d)=>{un("verbose",()=>`[WebGPU] jsepRun: sessionHandle=${c}, kernel=${o}, contextDataOffset=${l}`);let h=new $R(e,a,Number(l));return a.computeKernel(Number(o),h,d)},()=>a.captureBegin(),()=>a.captureEnd(),()=>a.replay()])}else{let s=new YP(t);i("webnn",[s,()=>s.reserveTensorId(),a=>s.releaseTensorId(a),async(a,o,l,c,d)=>s.ensureTensor(a,o,l,c,d),(a,o)=>{s.uploadTensor(a,o)},async(a,o)=>s.downloadTensor(a,o),(a,o)=>s.registerMLContext(a,o),!!t.trace])}}}),GR,fC,pC,Il,VR,j_,r0,AC,mC,W_,gC,yC,xC,U4=et(()=>{gs(),qee(),Yee(),Lt(),cu(),JI(),GP(),GR=(n,e)=>{kn()._OrtInit(n,e)!==0&&wn("Can't initialize onnxruntime.")},fC=async n=>{GR(n.wasm.numThreads,Kg(n.logLevel))},pC=async(n,e)=>{kn().asyncInit?.();let t=n.webgpu.adapter;if(e==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(t){if(typeof t.limits!="object"||typeof t.features!="object"||typeof t.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let r=n.webgpu.powerPreference;if(r!==void 0&&r!=="low-power"&&r!=="high-performance")throw new Error(`Invalid powerPreference setting: "${r}"`);let i=n.webgpu.forceFallbackAdapter;if(i!==void 0&&typeof i!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${i}"`);if(t=await navigator.gpu.requestAdapter({powerPreference:r,forceFallbackAdapter:i}),!t)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(e==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment");{let r=(Vte(),Lp(L4)).init;e==="webgpu"&&await r("webgpu",kn(),n,t),e==="webnn"&&await r("webnn",kn(),n)}},Il=new Map,VR=n=>{let e=kn(),t=e.stackSave();try{let r=e.PTR_SIZE,i=e.stackAlloc(2*r);e._OrtGetInputOutputCount(n,i,i+r)!==0&&wn("Can't get session input/output count.");let s=r===4?"i32":"i64";return[Number(e.getValue(i,s)),Number(e.getValue(i+r,s))]}finally{e.stackRestore(t)}},j_=(n,e)=>{let t=kn(),r=t.stackSave(),i=0;try{let s=t.PTR_SIZE,a=t.stackAlloc(2*s);t._OrtGetInputOutputMetadata(n,e,a,a+s)!==0&&wn("Can't get session input/output metadata.");let o=Number(t.getValue(a,"*"));i=Number(t.getValue(a+s,"*"));let l=t.HEAP32[i/4];if(l===0)return[o,0];let c=t.HEAPU32[i/4+1],d=[];for(let h=0;h<c;h++){let p=Number(t.getValue(i+8+h*s,"*"));d.push(p!==0?t.UTF8ToString(p):Number(t.getValue(i+8+(h+c)*s,"*")))}return[o,l,d]}finally{t.stackRestore(r),i!==0&&t._OrtFree(i)}},r0=n=>{let e=kn(),t=e._malloc(n.byteLength);if(t===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${n.byteLength}.`);return e.HEAPU8.set(n,t),[t,n.byteLength]},AC=async(n,e)=>{let t,r,i=kn();Array.isArray(n)?[t,r]=n:n.buffer===i.HEAPU8.buffer?[t,r]=[n.byteOffset,n.byteLength]:[t,r]=r0(n);let s=0,a=0,o=0,l=[],c=[],d=[];try{if([a,l]=await $P(e),e?.externalData&&i.mountExternalData){let w=[];for(let I of e.externalData){let S=typeof I=="string"?I:I.path;w.push(eC(typeof I=="string"?I:I.data).then(M=>{i.mountExternalData(S,M)}))}await Promise.all(w)}for(let w of e?.executionProviders??[])if((typeof w=="string"?w:w.name)==="webnn"){if(i.shouldTransferToMLTensor=!1,typeof w!="string"){let I=w,S=I?.context,M=I?.gpuDevice,T=I?.deviceType,R=I?.powerPreference;S?i.currentContext=S:M?i.currentContext=await i.webnnCreateMLContext(M):i.currentContext=await i.webnnCreateMLContext({deviceType:T,powerPreference:R})}else i.currentContext=await i.webnnCreateMLContext();break}s=await i._OrtCreateSession(t,r,a),i.webgpuOnCreateSession?.(s),s===0&&wn("Can't create a session."),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(s,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[h,p]=VR(s),A=!!e?.enableGraphCapture,y=[],m=[],x=[],g=[],_=[];for(let w=0;w<h;w++){let[I,S,M]=j_(s,w);I===0&&wn("Can't get an input name."),c.push(I);let T=i.UTF8ToString(I);y.push(T),x.push(S===0?{name:T,isTensor:!1}:{name:T,isTensor:!0,type:ho(S),shape:M})}for(let w=0;w<p;w++){let[I,S,M]=j_(s,w+h);I===0&&wn("Can't get an output name."),d.push(I);let T=i.UTF8ToString(I);m.push(T),g.push(S===0?{name:T,isTensor:!1}:{name:T,isTensor:!0,type:ho(S),shape:M});{if(A&&e?.preferredOutputLocation===void 0){_.push("gpu-buffer");continue}let R=typeof e?.preferredOutputLocation=="string"?e.preferredOutputLocation:e?.preferredOutputLocation?.[T]??"cpu",k=i.webnnIsGraphOutput;if(R==="cpu"&&k&&k(s,T)){_.push("ml-tensor-cpu-output");continue}if(R!=="cpu"&&R!=="cpu-pinned"&&R!=="gpu-buffer"&&R!=="ml-tensor")throw new Error(`Not supported preferred output location: ${R}.`);if(A&&R!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${R}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);_.push(R)}}let b=null;return _.some(w=>w==="gpu-buffer"||w==="ml-tensor"||w==="ml-tensor-cpu-output")&&(o=i._OrtCreateBinding(s),o===0&&wn("Can't create IO binding."),b={handle:o,outputPreferredLocations:_,outputPreferredLocationsEncoded:_.map(w=>w==="ml-tensor-cpu-output"?"ml-tensor":w).map(w=>Mw(w))}),Il.set(s,[s,c,d,b,A,!1]),[s,y,m,x,g]}catch(h){throw c.forEach(p=>i._OrtFree(p)),d.forEach(p=>i._OrtFree(p)),o!==0&&i._OrtReleaseBinding(o)!==0&&wn("Can't release IO binding."),s!==0&&i._OrtReleaseSession(s)!==0&&wn("Can't release session."),h}finally{i._free(t),a!==0&&i._OrtReleaseSessionOptions(a)!==0&&wn("Can't release session options."),l.forEach(h=>i._free(h)),i.unmountExternalData?.()}},mC=n=>{let e=kn(),t=Il.get(n);if(!t)throw new Error(`cannot release session. invalid session id: ${n}`);let[r,i,s,a,o]=t;a&&(o&&e._OrtClearBoundOutputs(a.handle)!==0&&wn("Can't clear bound outputs."),e._OrtReleaseBinding(a.handle)!==0&&wn("Can't release IO binding.")),e.jsepOnReleaseSession?.(n),e.webnnOnReleaseSession?.(n),e.webgpuOnReleaseSession?.(n),i.forEach(l=>e._OrtFree(l)),s.forEach(l=>e._OrtFree(l)),e._OrtReleaseSession(r)!==0&&wn("Can't release session."),Il.delete(n)},W_=async(n,e,t,r,i,s,a=!1)=>{if(!n){e.push(0);return}let o=kn(),l=o.PTR_SIZE,c=n[0],d=n[1],h=n[3],p=h,A,y;if(c==="string"&&(h==="gpu-buffer"||h==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(a&&h!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${s} when enableGraphCapture is true.`);if(h==="gpu-buffer"){let g=n[2].gpuBuffer;y=Lc(Pc(c),d);{let _=o.jsepRegisterBuffer;if(!_)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');A=_(r,s,g,y)}}else if(h==="ml-tensor"){let g=n[2].mlTensor;y=Lc(Pc(c),d);let _=o.webnnRegisterMLTensor;if(!_)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');A=_(r,g,Pc(c),d)}else{let g=n[2];if(Array.isArray(g)){y=l*g.length,A=o._malloc(y),t.push(A);for(let _=0;_<g.length;_++){if(typeof g[_]!="string")throw new TypeError(`tensor data at index ${_} is not a string`);o.setValue(A+_*l,Os(g[_],t),"*")}}else{let _=o.webnnIsGraphInput,b=o.webnnIsGraphOutput;if(c!=="string"&&_&&b){let w=o.UTF8ToString(i);if(_(r,w)||b(r,w)){let I=Pc(c);y=Lc(I,d),p="ml-tensor";let S=o.webnnCreateTemporaryTensor,M=o.webnnUploadTensor;if(!S||!M)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let T=await S(r,I,d);M(T,new Uint8Array(g.buffer,g.byteOffset,g.byteLength)),A=T}else y=g.byteLength,A=o._malloc(y),t.push(A),o.HEAPU8.set(new Uint8Array(g.buffer,g.byteOffset,y),A)}else y=g.byteLength,A=o._malloc(y),t.push(A),o.HEAPU8.set(new Uint8Array(g.buffer,g.byteOffset,y),A)}}let m=o.stackSave(),x=o.stackAlloc(4*d.length);try{d.forEach((_,b)=>o.setValue(x+b*l,_,l===4?"i32":"i64"));let g=o._OrtCreateTensor(Pc(c),A,y,x,d.length,Mw(p));g===0&&wn(`Can't create tensor for input/output. session=${r}, index=${s}.`),e.push(g)}finally{o.stackRestore(m)}},gC=async(n,e,t,r,i,s)=>{let a=kn(),o=a.PTR_SIZE,l=Il.get(n);if(!l)throw new Error(`cannot run inference. invalid session id: ${n}`);let c=l[0],d=l[1],h=l[2],p=l[3],A=l[4],y=l[5],m=e.length,x=r.length,g=0,_=[],b=[],w=[],I=[],S=[],M=a.stackSave(),T=a.stackAlloc(m*o),R=a.stackAlloc(m*o),k=a.stackAlloc(x*o),H=a.stackAlloc(x*o);try{[g,_]=OP(s),Wc("wasm prepareInputOutputTensor");for(let W=0;W<m;W++)await W_(t[W],b,I,n,d[e[W]],e[W],A);for(let W=0;W<x;W++)await W_(i[W],w,I,n,h[r[W]],m+r[W],A);qc("wasm prepareInputOutputTensor");for(let W=0;W<m;W++)a.setValue(T+W*o,b[W],"*"),a.setValue(R+W*o,d[e[W]],"*");for(let W=0;W<x;W++)a.setValue(k+W*o,w[W],"*"),a.setValue(H+W*o,h[r[W]],"*");if(p&&!y){let{handle:W,outputPreferredLocations:K,outputPreferredLocationsEncoded:X}=p;if(d.length!==m)throw new Error(`input count from feeds (${m}) is expected to be always equal to model's input count (${d.length}).`);Wc("wasm bindInputsOutputs");for(let $=0;$<m;$++){let J=e[$];await a._OrtBindInput(W,d[J],b[$])!==0&&wn(`Can't bind input[${$}] for session=${n}.`)}for(let $=0;$<x;$++){let J=r[$];i[$]?.[3]?(S.push(w[$]),a._OrtBindOutput(W,h[J],w[$],0)!==0&&wn(`Can't bind pre-allocated output[${$}] for session=${n}.`)):a._OrtBindOutput(W,h[J],0,X[J])!==0&&wn(`Can't bind output[${$}] to ${K[$]} for session=${n}.`)}qc("wasm bindInputsOutputs"),Il.set(n,[c,d,h,p,A,!0])}a.jsepOnRunStart?.(c),a.webnnOnRunStart?.(c);let Q;p?Q=await a._OrtRunWithBinding(c,p.handle,x,k,g):Q=await a._OrtRun(c,R,T,m,H,x,k,g),Q!==0&&wn("failed to call OrtRun().");let V=[],B=[];Wc("wasm ProcessOutputTensor");for(let W=0;W<x;W++){let K=Number(a.getValue(k+W*o,"*"));if(K===w[W]||S.includes(w[W])){V.push(i[W]),K!==w[W]&&a._OrtReleaseTensor(K)!==0&&wn("Can't release tensor.");continue}let X=a.stackSave(),$=a.stackAlloc(4*o),J=!1,ne,L=0;try{a._OrtGetTensorData(K,$,$+o,$+2*o,$+3*o)!==0&&wn(`Can't access output tensor data on index ${W}.`);let G=o===4?"i32":"i64",oe=Number(a.getValue($,G));L=a.getValue($+o,"*");let Ae=a.getValue($+o*2,"*"),ye=Number(a.getValue($+o*3,G)),he=[];for(let Re=0;Re<ye;Re++)he.push(Number(a.getValue(Ae+Re*o,G)));a._OrtFree(Ae)!==0&&wn("Can't free memory for tensor dims.");let fe=he.reduce((Re,ge)=>Re*ge,1);ne=ho(oe);let Ie=p?.outputPreferredLocations[r[W]];if(ne==="string"){if(Ie==="gpu-buffer"||Ie==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Re=[];for(let ge=0;ge<fe;ge++){let Ne=a.getValue(L+ge*o,"*"),tt=a.getValue(L+(ge+1)*o,"*"),Ge=ge===fe-1?void 0:tt-Ne;Re.push(a.UTF8ToString(Ne,Ge))}V.push([ne,he,Re,"cpu"])}else if(Ie==="gpu-buffer"&&fe>0){let Re=a.jsepGetBuffer;if(!Re)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let ge=Re(L),Ne=Lc(oe,fe);if(Ne===void 0||!KI(ne))throw new Error(`Unsupported data type: ${ne}`);J=!0,V.push([ne,he,{gpuBuffer:ge,download:a.jsepCreateDownloader(ge,Ne,ne),dispose:()=>{a._OrtReleaseTensor(K)!==0&&wn("Can't release tensor.")}},"gpu-buffer"])}else if(Ie==="ml-tensor"&&fe>0){let Re=a.webnnEnsureTensor,ge=a.webnnIsGraphInputOutputTypeSupported;if(!Re||!ge)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Lc(oe,fe)===void 0||!ZI(ne))throw new Error(`Unsupported data type: ${ne}`);if(!ge(n,ne,!1))throw new Error(`preferredLocation "ml-tensor" for ${ne} output is not supported by current WebNN Context.`);let Ne=await Re(n,L,oe,he,!1);J=!0,V.push([ne,he,{mlTensor:Ne,download:a.webnnCreateMLTensorDownloader(L,ne),dispose:()=>{a.webnnReleaseTensorId(L),a._OrtReleaseTensor(K)}},"ml-tensor"])}else if(Ie==="ml-tensor-cpu-output"&&fe>0){let Re=a.webnnCreateMLTensorDownloader(L,ne)(),ge=V.length;J=!0,B.push((async()=>{let Ne=[ge,await Re];return a.webnnReleaseTensorId(L),a._OrtReleaseTensor(K),Ne})()),V.push([ne,he,[],"cpu"])}else{let Re=ey(ne),ge=new Re(fe);new Uint8Array(ge.buffer,ge.byteOffset,ge.byteLength).set(a.HEAPU8.subarray(L,L+ge.byteLength)),V.push([ne,he,ge,"cpu"])}}finally{a.stackRestore(X),ne==="string"&&L&&a._free(L),J||a._OrtReleaseTensor(K)}}p&&!A&&(a._OrtClearBoundOutputs(p.handle)!==0&&wn("Can't clear bound outputs."),Il.set(n,[c,d,h,p,A,!1]));for(let[W,K]of await Promise.all(B))V[W][2]=K;return qc("wasm ProcessOutputTensor"),V}finally{a.webnnOnRunEnd?.(c),a.stackRestore(M),b.forEach(Q=>a._OrtReleaseTensor(Q)),w.forEach(Q=>a._OrtReleaseTensor(Q)),I.forEach(Q=>a._free(Q)),g!==0&&a._OrtReleaseRunOptions(g),_.forEach(Q=>a._free(Q))}},yC=n=>{let e=kn(),t=Il.get(n);if(!t)throw new Error("invalid session id");let r=t[0],i=e._OrtEndProfiling(r);i===0&&wn("Can't get an profile file name."),e._OrtFree(i)},xC=n=>{let e=[];for(let t of n){let r=t[2];!Array.isArray(r)&&"buffer"in r&&e.push(r.buffer)}return e}}),Cl,es,Id,Xf,Jf,ig,q_,sg,Sc,Bc,HR,O4,$4,G4,V4,H4,j4,W4,q4=et(()=>{gs(),U4(),cu(),YI(),Cl=()=>!!Dn.wasm.proxy&&typeof document<"u",Id=!1,Xf=!1,Jf=!1,sg=new Map,Sc=(n,e)=>{let t=sg.get(n);t?t.push(e):sg.set(n,[e])},Bc=()=>{if(Id||!Xf||Jf||!es)throw new Error("worker not ready")},HR=n=>{switch(n.data.type){case"init-wasm":Id=!1,n.data.err?(Jf=!0,q_[1](n.data.err)):(Xf=!0,q_[0]()),ig&&(URL.revokeObjectURL(ig),ig=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=sg.get(n.data.type);n.data.err?e.shift()[1](n.data.err):e.shift()[0](n.data.out);break}}},O4=async()=>{if(!Xf){if(Id)throw new Error("multiple calls to 'initWasm()' detected.");if(Jf)throw new Error("previous call to 'initWasm()' failed.");if(Id=!0,Cl())return new Promise((n,e)=>{es?.terminate(),zP().then(([t,r])=>{try{es=r,es.onerror=s=>e(s),es.onmessage=HR,q_=[n,e];let i={type:"init-wasm",in:Dn};!i.in.wasm.wasmPaths&&(t||Bw)&&(i.in.wasm.wasmPaths={wasm:new URL("/assets/ort-wasm-simd-threaded.jsep-C887KxcQ.wasm",import.meta.url).href}),es.postMessage(i),ig=t}catch(i){e(i)}},e)});try{await XI(Dn.wasm),await fC(Dn),Xf=!0}catch(n){throw Jf=!0,n}finally{Id=!1}}},$4=async n=>{if(Cl())return Bc(),new Promise((e,t)=>{Sc("init-ep",[e,t]);let r={type:"init-ep",in:{epName:n,env:Dn}};es.postMessage(r)});await pC(Dn,n)},G4=async n=>Cl()?(Bc(),new Promise((e,t)=>{Sc("copy-from",[e,t]);let r={type:"copy-from",in:{buffer:n}};es.postMessage(r,[n.buffer])})):r0(n),V4=async(n,e)=>{if(Cl()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Bc(),new Promise((t,r)=>{Sc("create",[t,r]);let i={type:"create",in:{model:n,options:{...e}}},s=[];n instanceof Uint8Array&&s.push(n.buffer),es.postMessage(i,s)})}else return AC(n,e)},H4=async n=>{if(Cl())return Bc(),new Promise((e,t)=>{Sc("release",[e,t]);let r={type:"release",in:n};es.postMessage(r)});mC(n)},j4=async(n,e,t,r,i,s)=>{if(Cl()){if(t.some(a=>a[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(i.some(a=>a))throw new Error("pre-allocated output tensor is not supported for proxy.");return Bc(),new Promise((a,o)=>{Sc("run",[a,o]);let l=t,c={type:"run",in:{sessionId:n,inputIndices:e,inputs:l,outputIndices:r,options:s}};es.postMessage(c,xC(l))})}else return gC(n,e,t,r,i,s)},W4=async n=>{if(Cl())return Bc(),new Promise((e,t)=>{Sc("end-profiling",[e,t]);let r={type:"end-profiling",in:n};es.postMessage(r)});yC(n)}}),Y_,jR,Y4,Hte=et(()=>{gs(),q4(),Lt(),qI(),GP(),Y_=(n,e)=>{switch(n.location){case"cpu":return[n.type,n.dims,n.data,"cpu"];case"gpu-buffer":return[n.type,n.dims,{gpuBuffer:n.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[n.type,n.dims,{mlTensor:n.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${n.location} for ${e()}`)}},jR=n=>{switch(n[3]){case"cpu":return new ei(n[0],n[2],n[1]);case"gpu-buffer":{let e=n[0];if(!KI(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:t,download:r,dispose:i}=n[2];return ei.fromGpuBuffer(t,{dataType:e,dims:n[1],download:r,dispose:i})}case"ml-tensor":{let e=n[0];if(!ZI(e))throw new Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:t,download:r,dispose:i}=n[2];return ei.fromMLTensor(t,{dataType:e,dims:n[1],download:r,dispose:i})}default:throw new Error(`invalid data location: ${n[3]}`)}},Y4=class{async fetchModelAndCopyToWasmMemory(n){return G4(await eC(n))}async loadModel(n,e){Pa();let t;typeof n=="string"?t=await this.fetchModelAndCopyToWasmMemory(n):t=n,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await V4(t,e),Js()}async dispose(){return H4(this.sessionId)}async run(n,e,t){Pa();let r=[],i=[];Object.entries(n).forEach(h=>{let p=h[0],A=h[1],y=this.inputNames.indexOf(p);if(y===-1)throw new Error(`invalid input '${p}'`);r.push(A),i.push(y)});let s=[],a=[];Object.entries(e).forEach(h=>{let p=h[0],A=h[1],y=this.outputNames.indexOf(p);if(y===-1)throw new Error(`invalid output '${p}'`);s.push(A),a.push(y)});let o=r.map((h,p)=>Y_(h,()=>`input "${this.inputNames[i[p]]}"`)),l=s.map((h,p)=>h?Y_(h,()=>`output "${this.outputNames[a[p]]}"`):null),c=await j4(this.sessionId,i,o,a,l,t),d={};for(let h=0;h<c.length;h++)d[this.outputNames[a[h]]]=s[h]??jR(c[h]);return Js(),d}startProfiling(){}endProfiling(){W4(this.sessionId)}}}),X4={};_h(X4,{OnnxruntimeWebAssemblyBackend:()=>Gw,initializeFlags:()=>$w,wasmBackend:()=>J4});var $w,Gw,J4,jte=et(()=>{gs(),q4(),Hte(),$w=()=>{(typeof Dn.wasm.initTimeout!="number"||Dn.wasm.initTimeout<0)&&(Dn.wasm.initTimeout=0);let n=Dn.wasm.simd;if(typeof n!="boolean"&&n!==void 0&&n!=="fixed"&&n!=="relaxed"&&(Dn.wasm.simd=!1),typeof Dn.wasm.proxy!="boolean"&&(Dn.wasm.proxy=!1),typeof Dn.wasm.trace!="boolean"&&(Dn.wasm.trace=!1),typeof Dn.wasm.numThreads!="number"||!Number.isInteger(Dn.wasm.numThreads)||Dn.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)Dn.wasm.numThreads=1;else{let e=typeof navigator>"u"?Tee("node:os").cpus().length:navigator.hardwareConcurrency;Dn.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},Gw=class{async init(n){$w(),await O4(),await $4(n)}async createInferenceSessionHandler(n,e){let t=new Y4;return await t.loadModel(n,e),t}},J4=new Gw});gs();gs();gs();var Wte="1.24.3";{let n=(jte(),Lp(X4)).wasmBackend;Td("webgpu",n,5),Td("webnn",n,5),Td("cpu",n,10),Td("wasm",n,10)}Object.defineProperty(Dn.versions,"web",{value:Wte,enumerable:!0});class qte{constructor(e,t){this.runner=e,this.config=t}}class WR extends qte{constructor(e,t){super(e,t),this.store=new pP,this.cachedSize=null,this.graph=t.graph,this.params=t.params??{}}get size(){return this.cachedSize??this.inferSize()}reset(e){this.store.reset()}compute(e){const t=AP(this.graph,{runner:this.runner,state:e,params:this.params},this.store);if(t instanceof Float32Array)return this.cachedSize=t.length,t;if(typeof t=="number")return this.cachedSize=1,new Float32Array([t]);if(typeof t=="boolean")return this.cachedSize=1,new Float32Array([t?1:0]);if(t instanceof Uint8Array){this.cachedSize=t.length;const r=new Float32Array(t.length);for(let i=0;i<t.length;i++)r[i]=t[i];return r}return this.cachedSize=0,new Float32Array(0)}inferSize(){this.runner.getContext();const e={jointPos:new Float32Array(this.runner.getNumActions())};return this.compute(e),this.cachedSize??0}}class Yte{constructor(e,t={}){this.config=e,this.options=t,this.policyModule=null,this.obsGroups={},this.obsLayouts={},this.obsSizes={},this.historyConfig={},this.historyBuffers={},this.defaultObsKey=null,this.context=null,this.policyJointNames=(e.policy_joint_names??[]).slice(),this.numActions=e.policy_num_actions??this.policyJointNames.length,this.lastActions=new Float32Array(this.numActions),this.defaultJointPos=this.normalizeArray(e.default_joint_pos??[],this.numActions,0),this.encoderBias=this.normalizeArray(e.encoder_bias??[],this.numActions,0)}async init(e){this.context=e,this.policyModule=await this.buildPolicyModule(e),this.buildObservationGroups()}reset(e){this.lastActions.fill(0),this.policyModule?.reset();for(const t of Object.values(this.obsGroups))for(const r of t)r.reset&&r.reset(e);if(e){for(const[t,r]of Object.entries(this.historyConfig))if(r.steps>1){const i=this.buildFrame(this.obsGroups[t]??[],e),s=this.historyBuffers[t];for(let a=0;a<r.steps;a++)s.set(i,a*i.length)}}}update(e){this.policyModule?.update();for(const t of Object.values(this.obsGroups))for(const r of t)r.update&&r.update(e)}collectObservationsByKey(e){this.update(e);const t={};for(const[r,i]of Object.entries(this.obsGroups)){const s=this.historyConfig[r];if(s&&s.steps>1){const a=this.buildFrame(i,e),o=this.historyBuffers[r];for(let l=o.length-1;l>=a.length;l--)o[l]=o[l-a.length];o.set(a,0),t[r]=new Float32Array(o)}else t[r]=this.buildFrame(i,e)}return t}collectObservations(e){const t=this.collectObservationsByKey(e);if(this.defaultObsKey&&t[this.defaultObsKey])return t[this.defaultObsKey];const r=Object.keys(t)[0];return r?t[r]:new Float32Array(0)}async preloadAll(){const e=[];for(const t of Object.values(this.obsGroups))for(const r of t)typeof r.preload=="function"&&e.push(r.preload());await Promise.all(e)}getObservationSize(){if(this.defaultObsKey&&this.obsSizes[this.defaultObsKey]!==void 0)return this.obsSizes[this.defaultObsKey];const e=Object.keys(this.obsSizes)[0];return e?this.obsSizes[e]:0}getObservationLayout(){if(this.defaultObsKey&&this.obsLayouts[this.defaultObsKey])return this.obsLayouts[this.defaultObsKey].map(t=>({...t}));const e=Object.keys(this.obsLayouts)[0];return e?this.obsLayouts[e].map(t=>({...t})):[]}getPolicyModuleContext(){return this.policyModule?.getContext()??{}}getPolicyModule(){return this.policyModule}getContext(){return this.context}getPolicyJointNames(){return this.policyJointNames.slice()}getNumActions(){return this.numActions}getDefaultJointPos(){return new Float32Array(this.defaultJointPos)}getEncoderBias(){return new Float32Array(this.encoderBias)}getLastActions(){return new Float32Array(this.lastActions)}getConfig(){return this.config}setLastActions(e){if(e.length!==this.lastActions.length){this.lastActions=new Float32Array(e);return}this.lastActions.set(e)}async buildPolicyModule(e){const t=this.options.policyModules??{},r=this.config.policy_module,i=r?t[r]:t.default;if(r&&!i)throw new Error(`Unknown policy module: ${r}`);if(!i)return null;const s=new i(this.config);return await s.init(e),s}buildObservationGroups(){const e=this.options.observations??{},t=this.config.observations??{};this.obsGroups={},this.obsLayouts={},this.obsSizes={},this.historyConfig={},this.historyBuffers={},this.defaultObsKey=null;const r=i=>{const s=i;if(s.kind==="observation"&&Array.isArray(s.nodes))return new WR(this,{name:"DslObservation",graph:{kind:"observation",nodes:s.nodes,output:s.output??""},params:s.params});const a=e[i.name];if(!a)throw new Error(`Unknown observation type: ${i.name}`);return new a(this,i)};for(const[i,s]of Object.entries(t)){if(Array.isArray(s)){const a=s.map(r);this.registerGroup(i,a,s);continue}if(s&&typeof s=="object"){const a=s;if(Array.isArray(a.components)){const o=a.components.map(d=>{const h=d;if(h.kind==="observation"&&Array.isArray(h.nodes))return new WR(this,{name:"DslObservation",graph:{kind:"observation",nodes:h.nodes,output:h.output??""},params:h.params});const p=e[d.name];if(!p)throw new Error(`Unknown observation type: ${d.name}`);const A={...d,history_steps:1};return new p(this,A)}),l=Math.max(1,Math.floor(a.history_steps??1)),c=!!a.interleaved;this.registerGroup(i,o,a.components,{steps:l,interleaved:c})}}}this.obsGroups.policy?this.defaultObsKey="policy":this.obsGroups.observation?this.defaultObsKey="observation":this.obsGroups.obs_history?this.defaultObsKey="obs_history":this.defaultObsKey=Object.keys(this.obsGroups)[0]??null}registerGroup(e,t,r,i){this.obsGroups[e]=t,this.obsLayouts[e]=t.map((a,o)=>({name:r[o]?.name??`obs_${o}`,size:a.size}));const s=this.obsLayouts[e].reduce((a,o)=>a+o.size,0);i&&i.steps>1?(this.historyConfig[e]=i,this.historyBuffers[e]=new Float32Array(s*i.steps),this.obsSizes[e]=s*i.steps):this.obsSizes[e]=s}buildFrame(e,t){const r=e.reduce((a,o)=>a+o.size,0),i=new Float32Array(r);let s=0;for(const a of e){const o=a.compute(t),l=o instanceof Float32Array?o:Float32Array.from(o);if(l.length!==a.size)throw new Error(`Observation size mismatch: expected ${a.size}, got ${l.length}`);i.set(l,s),s+=l.length}return i}normalizeArray(e,t,r){const i=new Float32Array(t);for(let s=0;s<t;s++)i[s]=typeof e[s]=="number"?e[s]:r;return i}}Dn.wasm.proxy=!1;Dn.wasm.numThreads=1;class Xte{constructor(e){if(!e?.path)throw new Error("OnnxModule requires a path.");this.config=e,this.session=null;const t=e.meta?.in_keys??["policy"],r=e.meta?.out_keys??["action"];this.configuredInKeys=t.map(i=>Array.isArray(i)?i.join(","):i),this.inKeys=[...this.configuredInKeys],this.outKeys=r.map(i=>Array.isArray(i)?i.join(","):i),this.isRecurrent=this.inKeys.includes("adapt_hx")}async init(){const e=await fetch(this.config.path);if(!e.ok)throw new Error(`Failed to fetch ONNX model: ${e.status}`);const t=await e.arrayBuffer();this.session=await WI.create(t,{executionProviders:["wasm"],graphOptimizationLevel:"all"}),this.inferInputKeys(),this.isRecurrent=this.inKeys.includes("adapt_hx")}initInput(){const e={};return this.isRecurrent&&(e.is_init=new ei("bool",[!0],[1]),e.adapt_hx=new ei("float32",new Float32Array(128),[1,128])),this.inKeys.includes("time_step")&&(e.time_step=new ei("float32",new Float32Array([0]),[1,1])),e}async runInference(e){if(!this.session)throw new Error("OnnxModule not initialized.");const t={};for(let a=0;a<this.inKeys.length;a++){const o=this.inKeys[a],l=this.session.inputNames[a];if(!l||!e[o])throw new Error(`Missing ONNX input for key: ${o}`);t[l]=e[o]}const r=await this.session.run(t),i={};for(let a=0;a<this.outKeys.length;a++){const o=this.outKeys[a],l=this.session.outputNames[a];l&&r[l]&&(i[o]=r[l])}const s={};return this.isRecurrent&&i["next,adapt_hx"]&&(s.is_init=new ei("bool",[!1],[1]),s.adapt_hx=i["next,adapt_hx"]),[i,s]}inferInputKeys(){if(!this.session)return;const e=this.session.inputNames;if(e.length<=1){this.inKeys=[...this.configuredInKeys];return}if(this.configuredInKeys.length===e.length){this.inKeys=[...this.configuredInKeys];return}this.inKeys=e.map(t=>this.configuredInKeys.includes(t)?t:t==="obs"&&this.configuredInKeys.includes("policy")?"policy":t)}}class Jte{constructor(e,t,r,i){this.mujoco=e,this.mjModel=t,this.mjData=r;const s=this.getJointNames(t);this.qposAdr=[],this.qvelAdr=[],this.jointIndices=[],this.ctrlAdr=null;for(const a of i){const o=s.indexOf(a);if(o<0)throw new Error(`Joint "${a}" not found in MuJoCo model`);this.qposAdr.push(t.jnt_qposadr[o]),this.qvelAdr.push(t.jnt_dofadr[o]),this.jointIndices.push(o)}this.numActions=i.length,this.ctrlAdr=this.buildCtrlAdr()}build(){const e=this.mjData.qpos,t=this.mjData.qvel,r=new Float32Array(this.numActions),i=new Float32Array(this.numActions);for(let c=0;c<this.numActions;c++)r[c]=e[this.qposAdr[c]],i[c]=t[this.qvelAdr[c]];const s=new Float32Array([e[0],e[1],e[2]]),a=new Float32Array([e[3],e[4],e[5],e[6]]),o=new Float32Array([t[0],t[1],t[2]]),l=new Float32Array([t[3],t[4],t[5]]);return{jointPos:r,jointVel:i,rootPos:s,rootQuat:a,rootLinVel:o,rootAngVel:l}}getControlMapping(){return this.ctrlAdr?{ctrlAdr:this.ctrlAdr.slice(),qposAdr:this.qposAdr.slice(),qvelAdr:this.qvelAdr.slice()}:null}getControlMappingFor(e,t){if(!this.ctrlAdr)return null;const r=e.map(c=>new RegExp(`^(?:${c})$`)),i=c=>r.some(d=>d.test(c)),s=[],a=[],o=[],l=[];for(let c=0;c<t.length;c++)i(t[c])&&(s.push(this.ctrlAdr[c]),a.push(this.qposAdr[c]),o.push(this.qvelAdr[c]),l.push(c));return s.length===0?null:{ctrlAdr:s,qposAdr:a,qvelAdr:o,actionIndices:l}}getCtrlMappingByActuatorNames(e){const t=this.getActuatorNames(this.mjModel),r=e.map(o=>new RegExp(`^(?:${o})$`)),i=o=>r.some(l=>l.test(o)),s=[],a=[];for(let o=0;o<t.length;o++)i(t[o])&&(s.push(o),a.push(s.length-1));return s.length>0?{ctrlAdr:s,actionIndices:a}:null}getActuatorNames(e){const t=new Uint8Array(e.names),r=new TextDecoder,i=[];for(let s=0;s<e.nu;s++){let a=e.name_actuatoradr[s],o=a;for(;o<t.length&&t[o]!==0;)o++;i.push(r.decode(t.subarray(a,o)))}return i}buildCtrlAdr(){if(this.mjModel.nu<=0)return null;const e=this.mujoco.mjtTrn?.mjTRN_JOINT?.value,t=[];for(let i=0;i<this.mjModel.nu;i++){const s=this.mjModel.actuator_trntype[i];e===void 0||s===e?t.push(this.mjModel.actuator_trnid[2*i]):t.push(-1)}const r=[];for(const i of this.jointIndices){const s=t.findIndex(a=>a===i);if(s<0)return null;r.push(s)}return r}getJointNames(e){const t=new Uint8Array(e.names),r=new TextDecoder,i=[];for(let s=0;s<e.njnt;s++){let a=e.name_jntadr[s],o=a;for(;o<t.length&&t[o]!==0;)o++;let l=r.decode(t.subarray(a,o));!l&&s===0&&(l="floating_base_joint"),i.push(l)}return i}}class K4{constructor(e){this.config=e,this.context=null}init(e){this.context=e}reset(){}update(){}getContext(){return{}}}class Kte{constructor(e){this.policyJointNames=(e.policy_joint_names??[]).slice(),this.datasetJointNames=(e.dataset_joint_names??[]).slice(),this.nJoints=this.datasetJointNames.length||this.policyJointNames.length||0,this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refIdx=0,this.refLen=0,this.currentName="default",this.currentDone=!0}reset(e){const t=e?.jointPos??new Float32Array(this.nJoints),r=e?.rootPos??new Float32Array([0,0,0]),i=e?.rootQuat??new Float32Array([1,0,0,0]);this.refJointPos=[Float32Array.from(t)],this.refRootPos=[Float32Array.from(r)],this.refRootQuat=[Float32Array.from(i)],this.refIdx=0,this.refLen=1,this.currentDone=!0,this.currentName="default"}advance(){this.refLen<=1||this.refIdx<this.refLen-1&&(this.refIdx+=1,this.refIdx===this.refLen-1&&(this.currentDone=!0))}isReady(){return this.refLen>0}}class Zte extends K4{constructor(e){super(e),this.tracking=null}async init(e){await super.init(e);const t=this.config.policy_joint_names??[],r={...this.config.tracking,policy_joint_names:t};this.tracking=new Kte(r)}reset(e){this.tracking?.reset(e)}update(){this.tracking?.advance()}getContext(){return{tracking:this.tracking}}}class ene{constructor(e){this.policyJointNames=(e.policy_joint_names??[]).slice(),this.datasetJointNames=(e.dataset_joint_names??[]).slice(),this.nJoints=this.datasetJointNames.length||this.policyJointNames.length||0,this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refIdx=0,this.refLen=0,this.currentName="default",this.currentDone=!0}reset(e){const t=e?.jointPos??new Float32Array(this.nJoints),r=e?.rootPos??new Float32Array([0,0,0]),i=e?.rootQuat??new Float32Array([1,0,0,0]);this.refJointPos=[Float32Array.from(t)],this.refRootPos=[Float32Array.from(r)],this.refRootQuat=[Float32Array.from(i)],this.refIdx=0,this.refLen=1,this.currentDone=!0,this.currentName="default"}advance(){this.refLen<=1||this.refIdx<this.refLen-1&&(this.refIdx+=1,this.refIdx===this.refLen-1&&(this.currentDone=!0))}isReady(){return this.refLen>0}}class tne extends K4{constructor(e){super(e),this.locomotion=null}async init(e){await super.init(e);const t=this.config.policy_joint_names??[],r={...this.config.tracking,policy_joint_names:t};this.locomotion=new ene(r)}reset(e){this.locomotion?.reset(e)}update(){this.locomotion?.advance()}getContext(){return{tracking:this.locomotion}}}class nne{constructor(e){this.config=e}}function Cd(n,e){return n+Math.random()*(e-n)}function rne(n){const e=new Uint8Array(n.names),t=new TextDecoder,r=[];for(let i=0;i<n.njnt;i++){let s=n.name_jntadr[i],a=s;for(;a<e.length&&e[a]!==0;)a++;r.push(t.decode(e.subarray(s,a)))}return r}function qR(n){for(let e=0;e<n.njnt;e++)if(n.jnt_type[e]===0)return e;return-1}class ine extends nne{constructor(e){super(e),this.mutations=e.mutations??[]}onReset(e){const{mjModel:t,mjData:r}=e;if(!(!t||!r))for(const i of this.mutations)switch(i.target){case"joint_qpos":this.applyJointOffset(t,r,i,"qpos");break;case"joint_qvel":this.applyJointOffset(t,r,i,"qvel");break;case"freejoint_pos":this.applyFreejointPos(t,r,i);break;case"freejoint_yaw":this.applyFreejointYaw(t,r,i);break}}resolveJointIndices(e,t){const r=t.select??{};if(r.joint_ids&&r.joint_ids.length>0)return r.joint_ids.filter(s=>s>=0&&s<e.njnt);const i=rne(e);return r.joint_names&&r.joint_names.length>0?r.joint_names.map(s=>this.findJointIndex(i,s,r.entity_name)).filter(s=>s!==null):i.map((s,a)=>({name:s,idx:a})).filter(({name:s,idx:a})=>e.jnt_type[a]===0?!1:r.entity_name?s===r.entity_name||s.startsWith(`${r.entity_name}/`):!0).map(({idx:s})=>s)}findJointIndex(e,t,r){const i=e.indexOf(t);if(i>=0)return i;if(r){const a=e.indexOf(`${r}/${t}`);if(a>=0)return a}const s=e.map((a,o)=>({name:a,idx:o})).filter(({name:a})=>a===t||a.endsWith(`/${t}`));if(s.length===1)return s[0].idx;if(r){const a=s.find(({name:o})=>o===r||o.startsWith(`${r}/`));if(a)return a.idx}return null}applyJointOffset(e,t,r,i){if(r.sample.dist!=="uniform")return;const{low:s,high:a}=r.sample;for(const o of this.resolveJointIndices(e,r)){const l=e.jnt_type[o];if(!(l!==2&&l!==3))if(i==="qpos"){const c=e.jnt_qposadr[o];if(t.qpos[c]+=Cd(s,a),r.clip_to_limits&&e.jnt_limited[o]){const d=e.jnt_range[o*2],h=e.jnt_range[o*2+1];t.qpos[c]=Math.min(Math.max(t.qpos[c],d),h)}}else t.qvel[e.jnt_dofadr[o]]+=Cd(s,a)}}applyFreejointPos(e,t,r){if(r.sample.dist!=="uniform_xyz")return;const i=qR(e);if(i<0)return;const s=e.jnt_qposadr[i];t.qpos[s]+=Cd(r.sample.x[0],r.sample.x[1]),t.qpos[s+1]+=Cd(r.sample.y[0],r.sample.y[1]),t.qpos[s+2]+=Cd(r.sample.z[0],r.sample.z[1])}applyFreejointYaw(e,t,r){if(r.sample.dist!=="uniform")return;const i=qR(e);if(i<0)return;const s=e.jnt_qposadr[i]+3,a=Cd(r.sample.low,r.sample.high),o=Math.cos(a/2),l=Math.sin(a/2),c=t.qpos[s],d=t.qpos[s+1],h=t.qpos[s+2],p=t.qpos[s+3];t.qpos[s]=o*c-l*p,t.qpos[s+1]=o*d+l*h,t.qpos[s+2]=o*h-l*d,t.qpos[s+3]=o*p+l*c}}function sne(n){return"kind"in n&&n.kind==="event"&&Array.isArray(n.mutations)}class ane{constructor(e,t){this.terms=[];for(const r of e){if(sne(r)){this.terms.push(new ine(r));continue}const i=t[r.name];i&&this.terms.push(new i(r))}}onReset(e){for(const t of this.terms)t.onReset(e)}get size(){return this.terms.length}}const one={},lne={...one};function ag(n){return typeof n=="object"&&n!==null&&typeof n.setSelectedMotion=="function"}class Z4 extends Error{constructor(){super("This scene cannot be loaded because it exceeds the browser's WebAssembly 2 GB memory limit. Try closing other browser tabs or reloading the page to free memory."),this.name="WasmMemoryLimitError"}}function YR(n){const e=n instanceof Error?n.message:String(n);return e.includes("MjModel loading returned null")||e.includes("Could not allocate memory")||e.includes("memory allocation failed")||e.includes("bad_alloc")}class cne{constructor(e,t,r={}){this.render=()=>{if(Lr().updateDebugVisuals(),this.mjData&&GZ(this.mjData,this.camera,this.controls,this.cameraState),this.controls.update(),this.mjModel&&this.mjData&&this.bodies){L3(this.camera,this.lights);for(const[o,l]of this.lastSimState.bodies){const c=this.bodies[o];c&&(c.position.copy(l.position),c.quaternion.copy(l.quaternion))}P3(this.mujoco,this.mjData,this.lights),this.mujocoRoot&&this.mujocoRoot.cylinders&&fX({cylinders:this.mujocoRoot.cylinders,spheres:this.mujocoRoot.spheres},this.lastSimState.tendons)}this.renderer.render(this.scene,this.camera)},this.onWindowResize=()=>{const{width:o,height:l}=this.getSize();this.camera.aspect=o/l,this.camera.updateProjectionMatrix(),this.renderer.setSize(o,l)},this.mujoco=e,this.container=t,this.baseUrl=r.baseUrl||"/";const i="/working";try{this.mujoco.FS.mkdir(i)}catch(o){o&&typeof o=="object"&&"code"in o&&o.code}try{this.mujoco.FS.mount(this.mujoco.MEMFS,{root:"."},i)}catch(o){o&&typeof o=="object"&&"code"in o&&o.code!=="EEXIST"&&o.code}const{width:s,height:a}=this.getSize();this.scene=new a9,this.scene.name="scene",this.camera=new Fr(45,s/a,.001,1e3),this.camera.name="PerspectiveCamera",this.camera.position.set(2,1.7,1.7),this.scene.add(this.camera),this.renderer=new U7({antialias:!0}),this.renderer.xr.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(s,a),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=LN,this.renderer.outputColorSpace=ri,this.renderer.toneMapping=FN,this.renderer.toneMappingExposure=1,this.container.appendChild(this.renderer.domElement),this.vrButton=null,navigator.xr?.isSessionSupported("immersive-vr").then(o=>{o&&(this.vrButton=NI.createButton(this.renderer),document.body.appendChild(this.vrButton))}),this.controls=new $7(this.camera,this.renderer.domElement),this.controls.target.set(0,.2,0),this.controls.panSpeed=2,this.controls.zoomSpeed=1,this.controls.enableDamping=!0,this.controls.dampingFactor=.1,this.controls.screenSpacePanning=!0,this.controls.update(),this.renderer.setAnimationLoop(this.render),window.addEventListener("resize",this.onWindowResize),"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver(()=>this.onWindowResize()),this.resizeObserver.observe(this.container)):this.resizeObserver=null,this.lastSimState={bodies:new Map,tendons:pX()},this.dynamicBodyIds=null,this.mjModel=null,this.mjData=null,this.bodies=null,this.lights=[],this.mujocoRoot=null,this.loopPromise=null,this.running=!1,this.timestep=.001,this.decimation=1,this.policyCtrlDt=null,this.loadingScene=null,this.dragStateManager=null,this.dragForceScale=100,this.policyRunner=null,this.policyStateBuilder=null,this.policyConfigPath=null,this.initialQpos=null,this.initialQvel=null,this.policyControl=null,this.onnxModule=null,this.onnxInputDict=null,this.onnxInferencing=!1,this.onnxTimeStep=0,this.terminationManager=null,this.eventManager=null,this.terrainData=null,this.splatMesh=null,this.colliderMesh=null,this.cameraState={trackBodyId:null,prevBodyPos:null},this.sceneCacheManager=Cw.getInstance(this.mujoco),this.resourceTracker=new VZ,this.memoryMonitor=new HZ}async loadEnvironment(e,t=null,r=null,i=null,s=null,a=null){this.terrainData=a,s&&s.length>0?this.eventManager=new ane(s,lne):this.eventManager=null,await this.stop(),this.splatMesh&&(tB(this.splatMesh,this.scene),this.splatMesh=null),this.colliderMesh&&(lB(this.colliderMesh,this.scene),this.colliderMesh=null);const o=performance.now();if(this.initializeCommands(),this.sceneCacheManager.has(e)){await this.restoreFromCache(e);const l=performance.now()-o;this.memoryMonitor.logCacheOperation("hit",e,{elapsedMs:l})}else this.memoryMonitor.logCacheOperation("miss",e),await this.sceneCacheManager.prepareForNewScene(),this.mjModel=null,this.mjData=null,this.bodies=null,this.lights=[],this.mujocoRoot=null,this.dynamicBodyIds=null,this.resourceTracker.startTracking(this.mujoco),await wX(this.mujoco,e,this.baseUrl),await this.loadSceneWithOomRetry(e),await this.captureAndCacheResources(e);r&&(this.splatMesh=eB(r,this.scene),r.colliderUrl&&(this.colliderMesh=await oB(this.resolveAssetUrl(r.colliderUrl),this.scene))),await this.loadPolicyConfig(t),this.applyViewerConfig(i),this.running=!0,this.startLoop()}initializeCommands(){const e=Lr();e.clear(),e.setResetCallback(()=>this.resetSimulation())}initializeCommandsFromConfig(e,t){Lr().initialize(e,t)}resetSimulation(){if(this.resetSimulationState(),this.policyRunner&&this.policyStateBuilder){const e=this.policyStateBuilder.build();this.policyRunner.reset(e)}}async setSelectedMotion(e){const t=Lr().getTerm("motion");if(!ag(t))return!1;const r=await t.setSelectedMotion(e);return r&&this.resetSimulation(),r}getSelectedMotionName(){const e=Lr().getTerm("motion");return ag(e)?e.getSelectedMotionName?.()??null:null}setReferenceVisible(e){const t=Lr().getTerm("motion");!ag(t)||typeof t.setReferenceVisible!="function"||t.setReferenceVisible(e)}async loadScene(e){this.loadingScene&&await this.loadingScene,this.loadingScene=(async()=>{const t=this.scene.getObjectByName("MuJoCo Root");t&&this.scene.remove(t);const r={mjModel:this.mjModel,mjData:this.mjData,scene:this.scene};if([this.mjModel,this.mjData,this.bodies,this.lights]=await _X(this.mujoco,e,r),!this.mjModel||!this.mjData)throw new Error("Failed to load MuJoCo model.");this.mujocoRoot=this.scene.getObjectByName("MuJoCo Root"),this.mujoco.mj_forward(this.mjModel,this.mjData),P3(this.mujoco,this.mjData,this.lights),L3(this.camera,this.lights),this.dynamicBodyIds=this.computeDynamicBodyIds(this.mjModel),this.syncStaticBodiesFromData(),this.timestep=this.mjModel.opt.timestep||.001;const i=this.policyCtrlDt??.02;this.decimation=Math.max(1,Math.round(i/this.timestep)),this.lastSimState.bodies.clear(),this.updateCachedState(),this.dragStateManager?this.dragStateManager.setDraggableBodyIds(this.dynamicBodyIds):this.dragStateManager=new cB({scene:this.scene,renderer:this.renderer,camera:this.camera,container:this.container,controls:this.controls,draggableBodyIds:this.dynamicBodyIds}),this.loadingScene=null})(),await this.loadingScene}async loadSceneWithOomRetry(e){try{await this.loadScene(e)}catch(t){if(!YR(t))throw t;this.loadingScene=null,await this.sceneCacheManager.clear();try{await this.loadScene(e)}catch(r){throw this.loadingScene=null,YR(r)?new Z4:r}}}async startLoop(){return this.loopPromise?this.loopPromise:(this.running=!0,this.loopPromise=this.mainLoop(),this.loopPromise)}async setSplat(e){this.splatMesh&&(tB(this.splatMesh,this.scene),this.splatMesh=null),this.colliderMesh&&(lB(this.colliderMesh,this.scene),this.colliderMesh=null),e&&(this.splatMesh=eB(e,this.scene),e.colliderUrl&&(this.colliderMesh=await oB(this.resolveAssetUrl(e.colliderUrl),this.scene)))}calibrateSplat(e){this.splatMesh&&cP(this.splatMesh,e)}setSplatVisible(e){this.splatMesh&&(this.splatMesh.visible=e)}async stop(){this.running=!1;const e=this.loopPromise;e&&await e,this.loopPromise=null}async mainLoop(){for(;this.running;){const e=performance.now(),t=this.timestep*this.decimation;if(this.mjModel&&this.mjData){if(this.mujoco.mj_forward(this.mjModel,this.mjData),this.policyRunner&&this.policyStateBuilder){const s=this.policyStateBuilder.build(),a=this.policyRunner.collectObservationsByKey(s);await this.runOnnxInference(a)}if(this.executeSimulationSteps(),this.updateCachedState(),this.terminationManager&&this.policyStateBuilder){const s=this.policyStateBuilder.build();if(this.terminationManager.evaluate(s).done&&(this.resetSimulationState(),this.terminationManager.reset(),this.policyRunner)){const o=this.policyStateBuilder.build();this.policyRunner.reset(o)}}Lr().update(t),Lr().updateDebugVisuals()}const r=(performance.now()-e)/1e3,i=Math.max(0,t-r);i>0&&await new Promise(s=>setTimeout(s,i*1e3))}this.loopPromise=null}async loadPolicyConfig(e){const t=this.policyConfigPath;this.policyConfigPath=e,this.policyRunner=null,this.policyStateBuilder=null,this.policyControl=null,this.onnxModule=null,this.onnxInputDict=null,this.onnxInferencing=!1,this.onnxTimeStep=0,this.terminationManager=null;const r=Lr();if(r.clear(),r.setResetCallback(()=>this.resetSimulation()),!!e&&!(!this.mjModel||!this.mjData)){e!==t&&this.resetSimulationState();try{const{config:i}=await this.fetchPolicyConfig(e);if(Array.isArray(i.motions)&&(i.motions=i.motions.map(o=>({...o,path:this.resolveAssetUrl(this.resolvePolicyAssetPath(e,o.path))}))),i.commands?.motion&&Array.isArray(i.motions)&&(i.commands.motion={...i.commands.motion,motions:i.motions}),this.initialQpos=Array.isArray(i.initial_qpos)?i.initial_qpos:null,this.initialQvel=Array.isArray(i.initial_qvel)?i.initial_qvel:null,this.resetSimulationState(),this.mujoco.mj_forward(this.mjModel,this.mjData),this.updateCachedState(),i.commands&&typeof i.commands=="object"){this.initializeCommandsFromConfig(i.commands,{mujoco:this.mujoco,mjModel:this.mjModel,mjData:this.mjData,scene:this.scene,bodies:this.bodies,mujocoRoot:this.mujocoRoot,requestReset:()=>this.resetSimulation()}),Lr().resetTerms();const o=Lr().getTerm("motion");ag(o)&&(await o.setSelectedMotion(i.motions?.find(l=>l.default)?.name??i.motions?.[0]?.name??null),o.setReferenceVisible?.(!0)),this.mujoco.mj_forward(this.mjModel,this.mjData),this.updateCachedState()}if(!i.policy_num_actions&&(!i.policy_joint_names||i.policy_joint_names.length===0))throw new Error("Policy config missing policy_joint_names.");const s=new Yte(i,{policyModules:{tracking:Zte,locomotion:tne},observations:WZ});await s.init({mujoco:this.mujoco,mjModel:this.mjModel,mjData:this.mjData,scene:this.scene}),await s.preloadAll(),this.policyRunner=s,this.policyStateBuilder=new Jte(this.mujoco,this.mjModel,this.mjData,s.getPolicyJointNames());const a=this.policyStateBuilder.build();this.policyRunner.reset(a),this.policyControl=this.buildPolicyControl(i,s,this.policyStateBuilder);{const o=i.observations,l=[];if(Array.isArray(o))l.push(...o);else if(o&&typeof o=="object")for(const c of Object.values(o))Array.isArray(c)&&l.push(...c);for(const c of l)if(!(!c||this.timestep<=0)&&typeof c.fps=="number"&&c.fps>0){this.policyCtrlDt=1/c.fps;const d=Math.max(1,Math.round(this.policyCtrlDt/this.timestep));d!==this.decimation&&(this.decimation=d);break}}if(i.terminations&&Object.keys(i.terminations).length>0&&(this.terminationManager=new Eee(i.terminations,Cee,s)),i.onnx?.path){const o=this.resolvePolicyAssetPath(e,i.onnx.path),l=this.resolveAssetUrl(o),c={...i.onnx,path:l},d=new Xte(c);await d.init(),this.onnxModule=d,this.onnxInputDict=d.initInput()}}catch{}}}async fetchPolicyConfig(e){const t=this.resolveAssetUrl(e),r=await fetch(t,{cache:"no-store"});if(!r.ok)throw new Error(`Failed to fetch policy config: ${r.status}`);return{config:await r.json(),resolvedUrl:t}}resolveAssetUrl(e){if(/^[a-z]+:\/\//i.test(e))return e;const t=(this.baseUrl||"/").replace(/\/+$/,"/"),r=new URL(t,window.location.origin+"/").toString();return new URL(e.replace(/^\/+/,""),r).toString()}resolvePolicyAssetPath(e,t){const r=e.replace(/\\/g,"/"),i=r.lastIndexOf("/");return i>=0?`${r.slice(0,i+1)}${t}`.replace(/\/+/g,"/"):t}buildPolicyControl(e,t,r){const i=t.getPolicyJointNames(),s=this.mujoco.mjtBias?.mjBIAS_AFFINE?.value??1,a=(c,d,h,p,A,y,m,x)=>{const g=h.qposAdr.length,_=h.actionIndices.map(Q=>i[Q]),b=this.normalizeControlArray(p,g,1,_),w=this.normalizeControlArray(A,g,0,_),I=x?t.getDefaultJointPos():new Float32Array(i.length),S=new Float32Array(g);for(let Q=0;Q<g;Q++)S[Q]=I[h.actionIndices[Q]];const M=Array.isArray(e.encoder_bias)?Float32Array.from(e.encoder_bias):new Float32Array(i.length),T=new Float32Array(g);for(let Q=0;Q<g;Q++)T[Q]=M[h.actionIndices[Q]]??0;const R=this.normalizeControlArray(y,g,0,_),k=this.normalizeControlArray(m,g,0,_),H=h.ctrlAdr.map(Q=>Q<0||!this.mjModel?!1:this.mjModel.actuator_biastype[Q]===s);return H.some(Boolean),H.some(Q=>!Q),{controlType:d,ctrlAdr:h.ctrlAdr,qposAdr:h.qposAdr,qvelAdr:h.qvelAdr,actionIndices:h.actionIndices,actionScale:b,actionOffset:w,defaultJointPos:S,encoderBias:T,positionActuator:H,kp:R,kd:k,muscleNormalize:!1}},o=e.actions;if(!o||Object.keys(o).length===0){const c=e.control_type??"joint_position";if(c!=="joint_position"&&c!=="torque")return null;const d=r.getControlMapping();if(!d)return null;const h={...d,actionIndices:Array.from({length:d.qposAdr.length},(p,A)=>A)};return[a("legacy",c,h,e.action_scale,void 0,e.stiffness,e.damping,!0)]}const l=[];for(const[c,d]of Object.entries(o)){const h=d.type??"joint_position";if(h!=="joint_position"&&h!=="torque"&&h!=="muscle_activation")continue;const p=d.actuator_names??[".*"];if(h==="muscle_activation"){const x=r.getCtrlMappingByActuatorNames(p);if(!x)continue;const g=x.ctrlAdr.length,_=this.normalizeControlArray(d.scale,g,1),b=this.normalizeControlArray(d.offset,g,0),w=d.normalize??!0;l.push({controlType:h,ctrlAdr:x.ctrlAdr,qposAdr:[],qvelAdr:[],actionIndices:x.actionIndices,actionScale:_,actionOffset:b,defaultJointPos:new Float32Array(g),encoderBias:new Float32Array(g),positionActuator:new Array(g).fill(!1),kp:new Float32Array(g),kd:new Float32Array(g),muscleNormalize:w});continue}const A=p.length===1&&p[0]===".*";let y;if(A){const x=r.getControlMapping();if(!x)continue;y={...x,actionIndices:Array.from({length:x.qposAdr.length},(g,_)=>_)}}else if(y=r.getControlMappingFor(p,i),!y)continue;const m=d.use_default_offset!==void 0?d.use_default_offset:h==="joint_position";l.push(a(c,h,y,d.scale,d.offset,d.stiffness,d.damping,m))}return l.length===0?null:l}normalizeControlArray(e,t,r,i){const s=new Float32Array(t);if(s.fill(r),typeof e=="number")return s.fill(e),s;if(Array.isArray(e)){for(let a=0;a<t;a++)s[a]=typeof e[a]=="number"?e[a]:r;return s}if(e!==null&&typeof e=="object"&&i){for(const[a,o]of Object.entries(e)){const l=i.indexOf(a);l>=0&&l<t&&(s[l]=o)}return s}return s}resetSimulationState(){if(!(!this.mjModel||!this.mjData)){if(this.mjModel.nkey>0?this.mujoco.mj_resetDataKeyframe(this.mjModel,this.mjData,0):this.mujoco.mj_resetData(this.mjModel,this.mjData),this.initialQpos){const e=this.mjData.qpos;for(let t=0;t<Math.min(this.initialQpos.length,this.mjModel.nq);t++)e[t]=this.initialQpos[t]}if(this.initialQvel){const e=this.mjData.qvel;for(let t=0;t<Math.min(this.initialQvel.length,this.mjModel.nv);t++)e[t]=this.initialQvel[t]}this.eventManager&&this.eventManager.onReset({mjModel:this.mjModel,mjData:this.mjData,terrainData:this.terrainData}),Lr().resetTerms(),this.onnxModule&&(this.onnxInputDict=this.onnxModule.initInput()),this.onnxTimeStep=0,this.mujoco.mj_forward(this.mjModel,this.mjData),this.lastSimState.bodies.clear(),this.updateCachedState()}}executeSimulationSteps(){if(!(!this.mjModel||!this.mjData)){this.applyDragForces();for(let e=0;e<this.decimation;e++)this.applyPolicyControl(),this.mujoco.mj_step(this.mjModel,this.mjData)}}applyPolicyControl(){if(!this.policyControl||!this.mjData)return;const e=this.mjData.ctrl;e.fill(0);const t=this.policyRunner?.getLastActions()??new Float32Array(0);for(const r of this.policyControl){const{controlType:i,ctrlAdr:s,qposAdr:a,qvelAdr:o,actionIndices:l,actionScale:c,actionOffset:d,defaultJointPos:h,encoderBias:p,positionActuator:A,kp:y,kd:m,muscleNormalize:x}=r,g=s.length;if(i==="joint_position")for(let _=0;_<g;_++){const b=s[_];if(b<0)continue;const w=t[l[_]]??0,I=h[_]+d[_]+c[_]*w-p[_];if(A[_])e[b]=I;else{const S=this.mjData.qpos[a[_]],M=this.mjData.qvel[o[_]];e[b]=y[_]*(I-S)+m[_]*(0-M)}}else if(i==="torque")for(let _=0;_<g;_++){const b=s[_];b>=0&&(e[b]=c[_]*(t[l[_]]??0))}else if(i==="muscle_activation")for(let _=0;_<g;_++){const b=s[_];if(b<0)continue;const w=(t[l[_]]??0)*c[_]+d[_];x?e[b]=1/(1+Math.exp(-5*(w-.5))):e[b]=w<0?0:w>1?1:w}}}async runOnnxInference(e){if(!(!this.onnxModule||!this.policyRunner||this.onnxInferencing)){this.onnxInferencing=!0;try{this.onnxInputDict||(this.onnxInputDict=this.onnxModule.initInput());const t={...this.onnxInputDict};this.onnxModule.inKeys.includes("time_step")&&(t.time_step=new ei("float32",new Float32Array([this.onnxTimeStep]),[1,1]));for(const[d,h]of Object.entries(e))t[d]=new ei("float32",h,[1,h.length]);for(const d of this.onnxModule.inKeys)if(!t[d])return;const[r,i]=await this.onnxModule.runInference(t);Object.keys(i).length>0&&(this.onnxInputDict={...this.onnxInputDict,...i}),this.onnxModule.inKeys.includes("time_step")&&(this.onnxTimeStep+=1);const s=this.onnxModule.outKeys[0],a=r.action??(s?r[s]:null)??r.policy??null;if(!a)return;const o=a.data,l=ArrayBuffer.isView(o)?new Float32Array(o):Float32Array.from(o),c=this.policyRunner?.getNumActions()??0;if(this.policyControl&&l.length!==c)return;this.policyRunner.setLastActions(l)}catch{}finally{this.onnxInferencing=!1}}}applyDragForces(){if(!this.dragStateManager||!this.mjModel||!this.mjData||!this.bodies)return;for(let p=0;p<this.mjData.xfrc_applied.length;p++)this.mjData.xfrc_applied[p]=0;const e=this.dragStateManager.physicsObject;if(!e||!("bodyID"in e)||typeof e.bodyID!="number"||e.bodyID<=0)return;const t=e.bodyID;if(this.dynamicBodyIds&&!this.dynamicBodyIds.has(t))return;for(let p=0;p<this.mjModel.nbody;p++)this.bodies[p]&&(Ll(this.mjData.xpos,p,this.bodies[p].position),Fd(this.mjData.xquat,p,this.bodies[p].quaternion),this.bodies[p].updateWorldMatrix(!0,!1));this.dragStateManager.update();const r=this.dragStateManager.offset.clone().multiplyScalar(this.dragForceScale),i=Q3(r),s=this.dragStateManager.worldHit.clone(),a=Q3(s),o=new de(this.mjData.xpos[t*3+0],this.mjData.xpos[t*3+1],this.mjData.xpos[t*3+2]),l=new de(a.x-o.x,a.y-o.y,a.z-o.z),c=new de(i.x,i.y,i.z),d=new de().crossVectors(l,c),h=t*6;this.mjData.xfrc_applied[h+0]=i.x,this.mjData.xfrc_applied[h+1]=i.y,this.mjData.xfrc_applied[h+2]=i.z,this.mjData.xfrc_applied[h+3]=d.x,this.mjData.xfrc_applied[h+4]=d.y,this.mjData.xfrc_applied[h+5]=d.z}updateCachedState(){if(!this.mjModel||!this.mjData||!this.bodies)return;const e=this.dynamicBodyIds;for(let t=0;t<this.mjModel.nbody;t++)if(!(e&&!e.has(t))&&this.bodies[t]){this.lastSimState.bodies.has(t)||this.lastSimState.bodies.set(t,{position:new de,quaternion:new In});const r=this.lastSimState.bodies.get(t);Ll(this.mjData.xpos,t,r.position),Fd(this.mjData.xquat,t,r.quaternion)}this.mujocoRoot&&this.mujocoRoot.cylinders&&hX(this.mjModel,this.mjData,{cylinders:this.mujocoRoot.cylinders,spheres:this.mujocoRoot.spheres},this.lastSimState.tendons)}applyViewerConfig(e){this.cameraState=$Z(e,this.camera,this.controls,this.mjModel,this.mjData)}computeDynamicBodyIds(e){const t=new Set;for(let r=1;r<e.nbody;r++){let i=r;for(;i>0;){if(e.body_jntnum[i]>0){t.add(r);break}i=e.body_parentid[i]}}return t}syncStaticBodiesFromData(){if(!this.mjModel||!this.mjData||!this.bodies)return;const e=this.dynamicBodyIds;for(let t=0;t<this.mjModel.nbody;t++){if(e?.has(t))continue;const r=this.bodies[t];r&&(Ll(this.mjData.xpos,t,r.position),Fd(this.mjData.xquat,t,r.quaternion))}}dispose(){this.stop(),this.policyRunner=null,this.policyStateBuilder=null,this.policyConfigPath=null,this.dragStateManager&&(this.dragStateManager.dispose(),this.dragStateManager=null),this.mjData=null,this.mjModel=null,window.removeEventListener("resize",this.onWindowResize),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.controls.dispose(),this.renderer.setAnimationLoop(null),this.renderer.dispose(),this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.vrButton?.parentElement&&(this.vrButton.parentElement.removeChild(this.vrButton),this.vrButton=null),this.bodies=null,this.lights=[],this.mujocoRoot=null,this.dynamicBodyIds=null,this.lastSimState.bodies.clear()}disposeThreeJSResources(){if(this.scene)for(this.scene.traverse(e=>{"geometry"in e&&e.geometry&&e.geometry.dispose(),"material"in e&&e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material))});this.scene.children.length>0;)this.scene.remove(this.scene.children[0])}disposeMaterial(e){const t=e;t.map&&t.map.dispose(),t.aoMap&&t.aoMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),e.dispose()}getSize(){const e=this.container.clientWidth||window.innerWidth,t=this.container.clientHeight||window.innerHeight;return{width:Math.max(1,e),height:Math.max(1,t)}}async restoreFromCache(e){const t=this.sceneCacheManager.get(e);if(!t)throw new Error(`Scene ${e} not found in cache`);const r=this.scene.getObjectByName("MuJoCo Root");r&&this.scene.remove(r),this.mjModel=t.mjModel,this.mjData=t.mjData,this.bodies=t.bodies,this.lights=t.lights,this.mujocoRoot=t.mujocoRoot,this.scene.add(this.mujocoRoot),this.scene.background=t.skybox,this.mujoco.mj_forward(this.mjModel,this.mjData),this.dynamicBodyIds=this.computeDynamicBodyIds(this.mjModel),this.syncStaticBodiesFromData(),this.timestep=this.mjModel.opt.timestep||.001;const i=this.policyCtrlDt??.02;this.decimation=Math.max(1,Math.round(i/this.timestep)),this.lastSimState.bodies.clear(),this.updateCachedState(),this.dragStateManager?this.dragStateManager.setDraggableBodyIds(this.dynamicBodyIds):this.dragStateManager=new cB({scene:this.scene,renderer:this.renderer,camera:this.camera,container:this.container,controls:this.controls,draggableBodyIds:this.dynamicBodyIds})}async captureAndCacheResources(e){const t=this.resourceTracker.stopTracking(this.mujoco);if(!this.mjModel||!this.mjData||!this.bodies||!this.mujocoRoot)return;const r=this.resourceTracker.estimateSceneMemory({mjModel:this.mjModel,mjData:this.mjData,bodies:this.bodies,meshes:{},mujocoRoot:this.mujocoRoot});await this.sceneCacheManager.set(e,{scenePath:e,lastAccessed:Date.now(),loadedAt:Date.now(),mjModel:this.mjModel,mjData:this.mjData,bodies:this.bodies,lights:this.lights,meshes:{},mujocoRoot:this.mujocoRoot,skybox:this.scene.background instanceof mh?this.scene.background:null,fsFiles:t,estimatedMemoryBytes:r});const i=this.sceneCacheManager.getMetrics();this.memoryMonitor.logCacheOperation("load",e,{memoryMB:r/1048576,totalScenes:i.totalScenes,totalMemoryMB:i.totalMemoryBytes/1048576})}}const og="mjswan_oom_reload_scene",une=({scenePath:n,baseUrl:e,policyConfigPath:t,splatConfig:r,cameraConfig:i,eventsConfig:s,terrainData:a,selectedMotion:o,showReferenceMotion:l=!0,onStatusChange:c,onError:d,onReady:h,onRuntimeReady:p})=>{const A=U.useRef(null),y=U.useRef(null),m=U.useRef(null),x=U.useRef(r);x.current=r;const g=U.useRef(o);g.current=o;const _=U.useRef(l);return _.current=l,U.useEffect(()=>{let b=!1;const w=S=>{c?.(S)};return(async()=>{if(!m.current){w("Loading MuJoCo…");const T=await DV(()=>import("./mujoco-CSmtoTxq.js"),[]);m.current=await T.default()}if(b)return;const S=A.current;if(!S)throw new Error("Failed to find viewer container.");const M=m.current;if(!M)throw new Error("MuJoCo not loaded.");y.current||(y.current=new cne(M,S,{baseUrl:e}),p?.(y.current)),w("Loading scene…"),await y.current.loadEnvironment(n,t??null,x.current??null,i??null,s??null,a??null),await y.current.setSelectedMotion(g.current??null),y.current.setReferenceVisible(_.current),!b&&(sessionStorage.removeItem(og),w("Running simulation"),h?.())})().catch(S=>{if(!b){if(S instanceof Z4){if(sessionStorage.getItem(og)!==n){sessionStorage.setItem(og,n),window.location.reload();return}sessionStorage.removeItem(og)}d?.(S instanceof Error?S:new Error(String(S))),w("Failed to load scene")}}),()=>{b=!0,y.current?.dispose(),y.current=null}},[n,e,t,i,s,a,c,d,h]),U.useEffect(()=>{y.current?.setReferenceVisible(l)},[l]),j.jsx("div",{ref:A,className:"viewer"})};var dne={outline:{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"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};const ty=(n,e,t,r)=>{const i=U.forwardRef(({color:s="currentColor",size:a=24,stroke:o=2,title:l,className:c,children:d,...h},p)=>U.createElement("svg",{ref:p,...dne[n],width:a,height:a,className:["tabler-icon",`tabler-icon-${e}`,c].join(" "),strokeWidth:o,stroke:s,...h},[l&&U.createElement("title",{key:"svg-title"},l),...r.map(([A,y])=>U.createElement(A,y)),...Array.isArray(d)?d:[d]]));return i.displayName=`${t}`,i};const hne=[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]],ez=ty("outline","chevron-down","ChevronDown",hne);const fne=[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]],pne=ty("outline","chevron-up","ChevronUp",fne);const Ane=[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]],mne=ty("outline","refresh","Refresh",Ane);const gne=[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]],yne=ty("outline","x","X",gne),XR="0.7.0-beta.1",JR=[{login:"ttktjmt",html_url:"https://github.com/ttktjmt"},{login:"claude",html_url:"https://github.com/claude"},{login:"Axellwppr",html_url:"https://github.com/Axellwppr"},{login:"julien-blanchon",html_url:"https://github.com/julien-blanchon"},{login:"unmoyai",html_url:"https://github.com/unmoyai"},{login:"brentyi",html_url:"https://github.com/brentyi"},{login:"CharlieLeee",html_url:"https://github.com/CharlieLeee"}],xne={move:"touchmove",end:"touchend"},vne={move:"mousemove",end:"mouseup"};function _ne(n){return n.type==="touchmove"}function bne(n){return n.type==="mousemove"}const jp=On.createContext(null);function fo({children:n,width:e,visible:t=!0,onVisibleChange:r,hiddenButtonTooltip:i}){const s=On.useRef(null),[a,{toggle:o}]=o0(!0),[l,c]=On.useState(800),d=On.useRef({dragging:!1,startPosX:0,startPosY:0,startClientX:0,startClientY:0}),h=On.useRef({}),p=(x,g,_)=>Math.abs(x+g/2)<Math.abs(x-_+g/2)?x:x-_,A=15;function y(x,g){const _=s.current;if(_===null)return[x,g];const b=_.parentElement;if(b===null)return[x,g];let w=x,I=g;return w=Math.min(w,b.clientWidth-_.clientWidth-A),w=Math.max(w,A),I=Math.min(I,b.clientHeight-_.clientHeight-A),I=Math.max(I,A),_.style.top=`${I.toString()}px`,_.style.left=`${w.toString()}px`,[p(w,_.clientWidth,b.clientWidth),p(I,_.clientHeight,b.clientHeight)]}On.useEffect(()=>{const x=s.current;if(x===null)return;const g=x.parentElement;if(g===null)return;const _=new ResizeObserver(()=>{h.current.x===void 0&&(h.current.x=p(x.offsetLeft,x.clientWidth,g.clientWidth)),h.current.y===void 0&&(h.current.y=p(x.offsetTop,x.clientHeight,g.clientHeight));const b=g.clientHeight-A*2;l!==b&&c(b);let w=h.current.x,I=h.current.y;for(;w<0;)w+=g.clientWidth;for(;I<0;)I+=g.clientHeight;y(w,I)});return _.observe(x),_.observe(g),()=>{_.disconnect()}});const m=x=>{const g=d.current,_=s.current;if(!_)return;x.type=="touchstart"?(x=x,g.startClientX=x.touches[0].clientX,g.startClientY=x.touches[0].clientY):(x=x,g.startClientX=x.clientX,g.startClientY=x.clientY),g.startPosX=_.offsetLeft,g.startPosY=_.offsetTop;const b=x.type=="touchstart"?xne:vne;function w(I){let S=0,M=0;if(_ne(I)?(I=I,S=I.touches[0].clientX-g.startClientX,M=I.touches[0].clientY-g.startClientY):bne(I)&&(I=I,S=I.clientX-g.startClientX,M=I.clientY-g.startClientY),Math.abs(S)<=3&&Math.abs(M)<=3)return;g.dragging=!0;const T=g.startPosX+S,R=g.startPosY+M;[h.current.x,h.current.y]=y(T,R)}window.addEventListener(b.move,w),window.addEventListener(b.end,()=>{x.type=="touchstart"&&(g.dragging=!1),window.removeEventListener(b.move,w)},{once:!0})};if(!t){const x=j.jsx(Je,{component:"button","aria-label":i??"Show controls",onClick:()=>r?.(!0),style:{width:"0.85rem",height:"0.85rem",minWidth:"0.85rem",minHeight:"0.85rem",display:"block",padding:0,border:"none",borderRadius:"9999px",background:"rgba(255, 255, 255, 0.82)",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.18)",cursor:"pointer"}});return j.jsx(Je,{style:{zIndex:10,position:"absolute",top:"1em",right:"1em"},children:i?j.jsx(Ql,{label:i,children:j.jsx(Je,{children:x})}):x})}return j.jsx(jp.Provider,{value:{wrapperRef:s,expanded:a,width:e,maxHeight:l,toggleExpanded:o,dragHandler:m,dragInfo:d},children:j.jsx(Xc,{radius:"xs",shadow:"0.1em 0 1em 0 rgba(0,0,0,0.1)",style:{boxSizing:"border-box",width:e,zIndex:10,position:"absolute",top:"1em",right:"1em",margin:0,"& .expandIcon":{transform:"rotate(0)"},overflow:"hidden"},ref:s,children:n})})}fo.Handle=function({children:e}){const t=On.useContext(jp);return j.jsx(j.Fragment,{children:j.jsx(Je,{style:{borderRadius:"0.2em 0.2em 0 0",lineHeight:"1.5em",cursor:"pointer",position:"relative",fontWeight:400,userSelect:"none",display:"flex",alignItems:"center",padding:"0 0.75em",height:"2.75em"},onClick:()=>{const r=t.dragInfo.current;if(r.dragging){r.dragging=!1;return}t.toggleExpanded()},onTouchStart:r=>{t.dragHandler(r)},onMouseDown:r=>{t.dragHandler(r)},children:e})})};fo.Contents=function({children:e}){const t=On.useContext(jp);return j.jsxs(Tg,{in:t.expanded,children:[j.jsx(Nd,{mx:"xs"}),j.jsx(su.Autosize,{mah:t.maxHeight,children:j.jsx(Je,{style:{width:t.width},children:e})})]})};fo.HideWhenCollapsed=function({children:e}){return On.useContext(jp)?.expanded??!0?e:null};fo.HideWhenExpanded=function({children:e}){return On.useContext(jp)?.expanded??!0?null:e};function lg({id:n,label:e,children:t}){return j.jsx(Je,{pb:"0.5em",px:"xs",children:j.jsxs(SE,{align:"center",children:[j.jsx(Je,{pr:"xs",style:{width:"7.25em",flexShrink:0,position:"relative"},children:j.jsx(qs,{c:"dimmed",style:{fontSize:"0.875em",fontWeight:450,lineHeight:"1.375em",letterSpacing:"-0.75px",width:"100%",boxSizing:"content-box"},children:j.jsx("label",{htmlFor:n,children:e})})}),j.jsx(Je,{style:{flexGrow:1},children:t})]})})}function tz({label:n,expandByDefault:e=!0,children:t}){const[r,{toggle:i}]=o0(e),s=r?pne:ez;return j.jsxs(Xc,{withBorder:!0,style:{borderWidth:"1px",position:"relative",marginLeft:"var(--mantine-spacing-xs)",marginRight:"var(--mantine-spacing-xs)",marginTop:"var(--mantine-spacing-xs)",marginBottom:"var(--mantine-spacing-xs)",paddingBottom:"calc(var(--mantine-spacing-xs) - 0.5em)"},children:[j.jsxs(Xc,{onClick:i,style:{fontSize:"0.875em",position:"absolute",padding:"0 0.375em",top:0,left:"0.375em",transform:"translateY(-50%)",userSelect:"none",fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center"},children:[n,j.jsx(s,{style:{width:"0.9em",height:"0.9em",strokeWidth:3,top:"0.1em",position:"relative",marginLeft:"0.25em",marginRight:"-0.1em",opacity:.5}})]}),j.jsx(Tg,{in:r,children:j.jsx(Je,{pt:"1em",children:t})}),j.jsx(Tg,{in:!r,children:j.jsx(Je,{p:"xs"})})]})}const nz={fontSize:"0.875em",fontWeight:450,lineHeight:"1.375em",letterSpacing:"-0.75px",width:"4.5em",flexShrink:0},wne={root:{padding:"0"},track:{height:4},thumb:{width:12,height:12}},Ene={flex:1,minWidth:0,height:"1.75em",fontSize:"0.8em",fontFamily:"inherit",border:"1px solid var(--mantine-color-default-border)",borderRadius:"var(--mantine-radius-sm)",background:"var(--mantine-color-default)",color:"var(--mantine-color-text)",textAlign:"right",padding:"0 0.4em",outline:"none",cursor:"ns-resize",touchAction:"none"};function X_({axis:n,value:e,min:t=-1/0,max:r=1/0,step:i,onChange:s}){const a=U.useRef(null),o=U.useRef(null);U.useEffect(()=>{const y=a.current;y&&document.activeElement!==y&&(y.value=e.toFixed(2))},[e]);const l=y=>Math.max(t,Math.min(r,parseFloat((Math.round(y/i)*i).toFixed(10)))),c=y=>{y.preventDefault(),y.currentTarget.setPointerCapture(y.pointerId),o.current={startY:y.clientY,startValue:e,moved:!1}},d=y=>{if(!o.current||!(y.buttons&1))return;const m=o.current.startY-y.clientY;if(Math.abs(m)>3&&(o.current.moved=!0),!o.current.moved)return;const x=l(o.current.startValue+m*i);s(x),a.current&&(a.current.value=x.toFixed(2))},h=()=>{if(o.current&&!o.current.moved){const y=a.current;y&&(y.focus(),y.select())}o.current=null},p=y=>{const m=parseFloat(y.target.value);isNaN(m)||s(l(m)),y.target.value=e.toFixed(2)},A=y=>{y.key==="Enter"&&y.currentTarget.blur(),y.key==="Escape"&&(a.current&&(a.current.value=e.toFixed(2)),a.current?.blur())};return j.jsxs(Je,{style:{display:"flex",alignItems:"center",gap:"0.25em",flex:1},children:[j.jsx(qs,{c:"dimmed",style:{fontSize:"0.875em",fontWeight:450,letterSpacing:"-0.75px",flexShrink:0},children:n}),j.jsx("input",{ref:a,size:1,defaultValue:e.toFixed(2),onPointerDown:c,onPointerMove:d,onPointerUp:h,onBlur:p,onKeyDown:A,onFocus:y=>y.currentTarget.style.outline="2px solid var(--mantine-color-blue-5)",onBlurCapture:y=>y.currentTarget.style.outline="none",style:Ene})]})}function KR({label:n,x:e,y:t,z:r,step:i,xLabel:s="X",yLabel:a="Y",zLabel:o="Z",onX:l,onY:c,onZ:d}){return j.jsxs(Je,{pb:"0.5em",px:"xs",style:{display:"flex",alignItems:"center",gap:"0.5em"},children:[j.jsx(qs,{c:"dimmed",style:nz,children:n}),j.jsx(X_,{axis:s,value:e,step:i,onChange:l}),j.jsx(X_,{axis:a,value:t,step:i,onChange:c}),j.jsx(X_,{axis:o,value:r,step:i,onChange:d})]})}function Ine({scale:n,xOffset:e,yOffset:t,zOffset:r,roll:i,pitch:s,yaw:a,onCalibrate:o}){const[l,c]=U.useState(n),[d,h]=U.useState(e),[p,A]=U.useState(t),[y,m]=U.useState(r),[x,g]=U.useState(i),[_,b]=U.useState(s),[w,I]=U.useState(a);U.useEffect(()=>{c(n)},[n]),U.useEffect(()=>{h(e)},[e]),U.useEffect(()=>{A(t)},[t]),U.useEffect(()=>{m(r)},[r]),U.useEffect(()=>{g(i)},[i]),U.useEffect(()=>{b(s)},[s]),U.useEffect(()=>{I(a)},[a]);const S=(M,T,R,k,H,Q,V)=>o(M,T,R,k,H,Q,V);return j.jsxs(tz,{label:"Control",expandByDefault:!0,children:[j.jsxs(Je,{pb:"0.5em",px:"xs",style:{display:"flex",alignItems:"center",gap:"0.5em"},children:[j.jsx(qs,{c:"dimmed",style:nz,children:"Scale"}),j.jsx(Je,{style:{flex:1},children:j.jsx(F0,{value:l,onChange:M=>{c(M),S(M,d,p,y,x,_,w)},min:.1,max:5,step:.05,size:"xs",label:M=>M.toFixed(2),styles:wne})})]}),j.jsx(KR,{label:"Position",x:d,y:p,z:y,step:.05,onX:M=>{h(M),S(l,M,p,y,x,_,w)},onY:M=>{A(M),S(l,d,M,y,x,_,w)},onZ:M=>{m(M),S(l,d,p,M,x,_,w)}}),j.jsx(KR,{label:"Rotation",x,y:_,z:w,step:.5,xLabel:"R",yLabel:"P",zLabel:"Y",onX:M=>{g(M),S(l,d,p,y,M,_,w)},onY:M=>{b(M),S(l,d,p,y,x,M,w)},onZ:M=>{I(M),S(l,d,p,y,x,_,M)}})]})}function Cne(n){return n instanceof HTMLElement?n.isContentEditable?!0:n.closest('input, textarea, select, [contenteditable], [role="textbox"], [role="searchbox"], [role="combobox"]')!==null:!1}function Sne(n){return n.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Bne({command:n,value:e,onChange:t,disabled:r,enabledWhenValue:i}){const s=n.config,a=s.enabled_when!==void 0&&(i??0)<.5,o=r||a;return j.jsxs(Je,{pb:"0.5em",px:"xs",style:{display:"flex",alignItems:"center"},children:[j.jsx(qs,{c:"dimmed",style:{fontSize:"0.875em",fontWeight:450,lineHeight:"1.375em",letterSpacing:"-0.75px",width:"50%",flexShrink:0},children:s.label}),j.jsx(Je,{style:{width:"50%"},children:j.jsx(F0,{value:e,onChange:l=>t(n.id,l),min:s.min,max:s.max,step:s.step,size:"xs",disabled:o,styles:{root:{padding:"0"},track:{height:4},thumb:{width:12,height:12}}})})]})}function Mne({command:n,value:e,onChange:t,disabled:r}){const i=n.config;return j.jsx(Je,{pb:"0.5em",px:"xs",children:j.jsx(Gl,{label:i.label,checked:e>=.5,onChange:s=>t(n.id,s.currentTarget.checked?1:0),size:"xs",disabled:r})})}function Tne(n){const{visible:e,onVisibleChange:t,projects:r,projectValue:i,projectLabel:s,onProjectChange:a,scenes:o,sceneValue:l,onSceneChange:c,splats:d,splatSection:h=!1,splatValue:p,onSplatChange:A,splatConfig:y,onCalibrateSplat:m,onSplatUrlLoad:x,policies:g,policyValue:_,onPolicyChange:b,motions:w,motionValue:I,onMotionChange:S,showReferenceMotion:M,onShowReferenceMotionChange:T,commandsEnabled:R=!1,onReset:k}=n,[H,{open:Q,close:V}]=o0(!1),[B,W]=U.useState(""),[K,X]=U.useState(null),[$,J]=U.useState(!1),ne=U.useCallback(async ge=>{if(ge.key!=="Enter"||!x)return;const Ne=B.trim();if(d.some(Ge=>Ge.label===Ne||Ge.value===Ne))return;if(!Ne.toLowerCase().endsWith(".spz")){X("URL must end with .spz");return}await x(Ne)?(X(null),J(!0)):X("File not found at the specified URL")},[x,B,d]),[L,G]=U.useState([]),[oe,Ae]=U.useState([]),[ye,he]=U.useState({});U.useEffect(()=>{const ge=Lr(),Ne=()=>{G(ge.getCommands()),Ae(ge.getCommandGroups()),he(ge.getValues())};return Ne(),ge.addEventListener(Ne),()=>{ge.removeEventListener(Ne)}},[]);const fe=U.useCallback((ge,Ne)=>{Lr().setValue(ge,Ne),he(Ge=>({...Ge,[ge]:Ne}))},[]),Ie=U.useCallback(()=>{Lr().triggerButton("_system:reset"),k&&k()},[k]);U.useEffect(()=>{const ge=Ne=>{if(Ne.defaultPrevented||Ne.repeat||Ne.altKey||Ne.ctrlKey||Ne.metaKey)return;const tt=Ne.key.toLowerCase();if(tt!=="c"&&tt!=="r")return;const Ge=Ne.target instanceof Element?Ne.target:document.activeElement;Cne(Ge)||(Ne.preventDefault(),tt==="c"?t(!e):Ie())};return window.addEventListener("keydown",ge),()=>{window.removeEventListener("keydown",ge)}},[e,t,Ie]);const Re=ge=>L.filter(Ne=>Ne.groupName===ge&&(Ne.config.type==="slider"||Ne.config.type==="checkbox"));return!r.length&&!o.length&&!g.length?null:j.jsxs(j.Fragment,{children:[j.jsx(ra,{opened:H,onClose:V,size:"lg",title:null,centered:!0,styles:{body:{textAlign:"center"}},children:j.jsxs(lI,{gap:"md",align:"center",children:[j.jsx(Lg,{src:"./logo-color.svg",style:{width:"8em",height:"auto"}}),j.jsx(qs,{size:"xl",fw:700,children:"powered by mjswan"}),j.jsxs(qs,{size:"sm",c:"dimmed",children:["version ",XR]}),j.jsx(qs,{size:"sm",c:"dimmed",children:"MuJoco Simulation on Web Assembly with Neural netwroks"}),j.jsx(Nd,{w:"100%"}),j.jsxs(Je,{children:[j.jsx(hp,{href:"https://github.com/ttktjmt/mjswan",target:"_blank",style:{fontWeight:"600"},children:"GitHub"})," • ",j.jsx(hp,{href:"https://mjswan.readthedocs.io",target:"_blank",style:{fontWeight:"600"},children:"Documentation"})]}),j.jsx(Nd,{w:"100%"}),j.jsxs(Je,{style:{textAlign:"left",maxHeight:"120px",overflowY:"auto",lineHeight:"1",fontSize:"0.8rem",opacity:"0.75"},px:"md",children:["Thanks to our contributors! ",j.jsx("br",{}),JR.map((ge,Ne)=>j.jsxs("span",{children:[j.jsx(hp,{href:ge.html_url,target:"_blank",style:{textDecoration:"none",fontSize:"0.75rem"},children:ge.login}),Ne<JR.length-1&&", "]},ge.login))]})]})}),j.jsxs(fo,{width:"20em",visible:e,onVisibleChange:t,hiddenButtonTooltip:"Show controls (C)",children:[j.jsxs(fo.Handle,{children:[j.jsx(Ql,{label:`mjswan ${XR}`,children:j.jsx(Je,{component:"a",onClick:ge=>{ge.stopPropagation(),Q()},onMouseDown:ge=>ge.stopPropagation(),onTouchStart:ge=>ge.stopPropagation(),style:{position:"absolute",cursor:"pointer",display:"flex",top:"0.8em",left:"0.9em"},children:j.jsx(Lg,{src:"./logo.svg",style:{width:"1.2em",height:"auto"}})})}),j.jsx("div",{style:{width:"1.1em"}}),j.jsx(fo.HideWhenCollapsed,{children:j.jsxs(Je,{px:"xs",style:{flexGrow:1,letterSpacing:"-0.5px",display:"flex",alignItems:"center",gap:"0.5em"},pt:"0.1em",children:[j.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),r.length>1&&j.jsxs(fi,{position:"bottom-start",offset:5,children:[j.jsx(fi.Target,{children:j.jsx(Je,{onClick:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onTouchStart:ge=>ge.stopPropagation(),style:{cursor:"pointer",display:"flex",alignItems:"center",flexShrink:0},children:j.jsx(ez,{size:16})})}),j.jsx(fi.Dropdown,{onClick:ge=>ge.stopPropagation(),children:r.map(ge=>j.jsx(fi.Item,{onClick:Ne=>{Ne.stopPropagation(),a(ge.value)},style:{fontWeight:ge.value===i?600:400,backgroundColor:ge.value===i?"rgba(34, 139, 230, 0.1)":void 0},children:ge.label},ge.value))})]})]})}),j.jsx(fo.HideWhenExpanded,{children:j.jsx(Je,{px:"xs",style:{flexGrow:1,letterSpacing:"-0.5px"},pt:"0.1em",children:s})}),j.jsx(Ql,{label:"Hide controls (C)",children:j.jsx(au,{variant:"subtle",color:"gray",size:"sm","aria-label":"Hide controls",onClick:ge=>{ge.stopPropagation(),t(!1)},onMouseDown:ge=>ge.stopPropagation(),onTouchStart:ge=>ge.stopPropagation(),children:j.jsx(yne,{size:14})})})]}),j.jsx(fo.Contents,{children:j.jsxs(Je,{pt:"0.375em",children:[o.length>0&&j.jsx(lg,{id:"scene-select",label:"Scene",children:j.jsx(Uc,{id:"scene-select",placeholder:"Select scene",data:o,value:l,onChange:c,size:"xs",radius:"xs",searchable:!0,clearable:!1,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})}),(d.length>0||h)&&j.jsx(lg,{id:"splat-select",label:"Splat",children:j.jsx(Ql,{label:K??"",color:"red",position:"bottom",opened:K!==null,withArrow:!0,children:j.jsx(Uc,{id:"splat-select",placeholder:x!==void 0?"Select splat or paste .spz URL":"Select splat",data:d,value:p,onChange:ge=>{A(ge),X(null),J(!1)},searchable:x!==void 0,searchValue:B,onSearchChange:ge=>{W(ge),ge&&X(null)},onKeyDown:ne,size:"xs",radius:"xs",clearable:!0,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})})}),(y?.control&&p!==null||$)&&m&&j.jsx(Ine,{scale:y?.scale??1,xOffset:y?.xOffset??0,yOffset:y?.yOffset??0,zOffset:y?.zOffset??0,roll:y?.roll??0,pitch:y?.pitch??0,yaw:y?.yaw??0,onCalibrate:m}),g.length>0&&j.jsx(lg,{id:"policy-select",label:"Policy",children:j.jsx(Uc,{id:"policy-select",placeholder:"Select policy",data:g,value:_,onChange:b,size:"xs",radius:"xs",searchable:!0,clearable:!0,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})}),w.length>0&&j.jsxs(j.Fragment,{children:[j.jsx(lg,{id:"motion-select",label:"Motion",children:j.jsx(Uc,{id:"motion-select",placeholder:"Select motion",data:w,value:I,onChange:S,size:"xs",radius:"xs",searchable:!0,clearable:!0,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})}),j.jsx(Je,{pb:"0.5em",px:"xs",children:j.jsx(Gl,{label:"Show reference",checked:M,onChange:ge=>T(ge.currentTarget.checked),size:"xs"})})]}),oe.length>0&&L.some(ge=>ge.config.type==="slider"||ge.config.type==="checkbox")&&j.jsx(j.Fragment,{children:oe.map(ge=>{const Ne=Re(ge);return Ne.length===0?null:j.jsx(tz,{label:Sne(ge),expandByDefault:!0,children:Ne.map(tt=>tt.config.type==="checkbox"?j.jsx(Mne,{command:tt,value:ye[tt.id]??0,onChange:fe,disabled:!R},tt.id):tt.config.type!=="slider"?null:j.jsx(Bne,{command:tt,value:ye[tt.id]??0,onChange:fe,disabled:!R,enabledWhenValue:tt.config.enabled_when?ye[Sw(tt.groupName,tt.config.enabled_when)]:void 0},tt.id))},ge)})}),j.jsx(Nd,{mb:"xs",mx:"xs"}),j.jsx(Je,{px:"xs",pb:"xs",children:j.jsx(uh,{variant:"light",color:"red",size:"xs",fullWidth:!0,leftSection:j.jsx(mne,{size:14}),onClick:Ie,children:"Reset"})})]})})]})]})}function Kf(n,e,t){return Object.keys(n[e]).reduce((r,i)=>(r[i]=`var(--mantine-${t}-${i})`,r),{})}function ZR(n,e){return n in e.breakpoints?e.breakpoints[n]:Z_(n)}function Rne(n){const e=ID(d0,n),t=Kf(e,"fontSizes","font-size"),r=Kf(e,"lineHeights","line-height"),i=Kf(e,"shadows","shadow"),s=Kf(e,"radius","radius"),a=Kf(e,"spacing","spacing"),o=Object.keys(e.headings.sizes).reduce((c,d)=>(c[d]={fontSize:`var(--mantine-${d}-font-size)`,lineHeight:`var(--mantine-${d}-line-height)`,fontWeight:`var(--mantine-${d}-font-weight)`},c),{}),l=Object.keys(e.colors).reduce((c,d)=>(c[d]={0:`var(--mantine-color-${d}-0)`,1:`var(--mantine-color-${d}-1)`,2:`var(--mantine-color-${d}-2)`,3:`var(--mantine-color-${d}-3)`,4:`var(--mantine-color-${d}-4)`,5:`var(--mantine-color-${d}-5)`,6:`var(--mantine-color-${d}-6)`,7:`var(--mantine-color-${d}-7)`,8:`var(--mantine-color-${d}-8)`,9:`var(--mantine-color-${d}-9)`,filled:`var(--mantine-color-${d}-filled)`,filledHover:`var(--mantine-color-${d}-filled-hover)`,light:`var(--mantine-color-${d}-light)`,lightHover:`var(--mantine-color-${d}-light-hover)`,lightColor:`var(--mantine-color-${d}-light-color)`,outline:`var(--mantine-color-${d}-outline)`,outlineHover:`var(--mantine-color-${d}-outline-hover)`},c),{primary:"var(--mantine-primary-color-filled)",primaryColors:{0:"var(--mantine-primary-color-0)",1:"var(--mantine-primary-color-1)",2:"var(--mantine-primary-color-2)",3:"var(--mantine-primary-color-3)",4:"var(--mantine-primary-color-4)",5:"var(--mantine-primary-color-5)",6:"var(--mantine-primary-color-6)",7:"var(--mantine-primary-color-7)",8:"var(--mantine-primary-color-8)",9:"var(--mantine-primary-color-9)",filled:"var(--mantine-primary-color-filled)",filledHover:"var(--mantine-primary-color-filled-hover)",light:"var(--mantine-primary-color-light)",lightHover:"var(--mantine-primary-color-light-hover)",lightColor:"var(--mantine-primary-color-light-color)",outline:"var(--mantine-primary-color-outline)",outlineHover:"var(--mantine-primary-color-outline-hover)"},white:"var(--mantine-color-white)",black:"var(--mantine-color-black)",text:"var(--mantine-color-text)",body:"var(--mantine-color-body)",error:"var(--mantine-color-error)",placeholder:"var(--mantine-color-placeholder)",anchor:"var(--mantine-color-anchor)",default:"var(--mantine-color-default)",defaultHover:"var(--mantine-color-default-hover)",defaultColor:"var(--mantine-color-default-color)",defaultBorder:"var(--mantine-color-default-border)",dimmed:"var(--mantine-color-dimmed)",disabledBody:"var(--mantine-color-disabled)",disabledText:"var(--mantine-color-disabled-color)",disabledBorder:"var(--mantine-color-disabled-border)"});return{scale:"var(--mantine-scale)",cursorType:"var(--mantine-cursor-type)",webkitFontSmoothing:"var(--mantine-webkit-font-smoothing)",mozFontSmoothing:"var(--mantine-moz-font-smoothing)",lineHeight:"var(--mantine-line-height)",fontFamily:"var(--mantine-font-family)",fontFamilyMonospace:"var(--mantine-font-family-monospace)",fontFamilyHeadings:"var(--mantine-font-family-headings)",headingFontWeight:"var(--mantine-heading-font-weight)",radiusDefault:"var(--mantine-radius-default)",breakpoints:e.breakpoints,fontSizes:t,lineHeights:r,shadows:i,radius:s,headings:o,spacing:a,colors:l,rtlSelector:'[dir="rtl"] &',darkSelector:'[data-mantine-color-scheme="dark"] &',lightSelector:'[data-mantine-color-scheme="light"] &',smallerThan:c=>`(max-width: ${ZR(c,e)})`,largerThan:c=>`(min-width: ${ZR(c,e)})`}}const Vw={fontFamily:"Inter",autoContrast:!0,components:{Checkbox:Gl.extend({defaultProps:{radius:"xs"}}),ColorInput:YE.extend({defaultProps:{radius:"xs"}}),Select:Uc.extend({defaultProps:{radius:"sm"}}),Textarea:JE.extend({defaultProps:{radius:"xs"}}),TextInput:cI.extend({defaultProps:{radius:"xs"}}),NumberInput:sI.extend({defaultProps:{radius:"xs"}}),Paper:Xc.extend({defaultProps:{radius:"xs",shadow:"0"}}),ActionIcon:au.extend({defaultProps:{variant:"subtle",color:"gray",radius:"xs"}}),Button:uh.extend({defaultProps:{radius:"xs",styles:{label:{fontWeight:450}}}})}};Rne(Vw);const rz=U.createContext(void 0),iz=()=>{const n=U.useContext(rz);if(!n)throw new Error("useLoading must be used within a LoadingProvider");return n},Dne=({children:n})=>{const[e,t]=U.useState(!1),[r,i]=U.useState(null),s=U.useRef(0),a=U.useCallback(c=>{s.current+=1,c!==void 0&&i(c),s.current>0&&t(!0)},[]),o=U.useCallback(c=>{i(c)},[]),l=U.useCallback(()=>{s.current=Math.max(0,s.current-1),s.current===0&&(t(!1),i(null))},[]);return j.jsx(rz.Provider,{value:{isLoading:e,loadingMessage:r,showLoading:a,setLoadingMessage:o,hideLoading:l},children:n})},kne=()=>{const{isLoading:n,loadingMessage:e}=iz();return n?j.jsx("div",{className:"loader-overlay",children:j.jsxs("div",{className:"loader-content",children:[j.jsx(oh,{size:64,type:"bars"}),e&&j.jsx("p",{className:"loader-message",children:e})]})}):null};function vC(n){return n.toLowerCase().replace(/ /g,"_").replace(/-/g,"_")}function sz(n){return n.id?n.id:"main"}function eD(n,e){if(!n.scenes.length)return null;if(!e)return n.scenes[0];const t=e.trim().toLowerCase();return n.scenes.find(r=>r.name.toLowerCase()===t)||n.scenes.find(r=>vC(r.name)===t)||n.scenes[0]}function J_(n,e){if(!n.policies.length)return null;const t=n.policies.find(s=>s.default)??n.policies[0];if(!e)return t.name;const r=e.trim().toLowerCase();return(n.policies.find(s=>s.name.toLowerCase()===r)||n.policies.find(s=>vC(s.name)===r))?.name??t.name}function Zf(n,e){return n?.motions?.length?(n.motions.find(r=>r.default)??n.motions[0]).name:null}function Nne(n,e){const t=sz(n),r=e.path?e.path:`scene/${vC(e.name)}/scene.xml`;return`${t}/assets/${r}`.replace(/\/+/g,"/")}function tD(n,e){return`${sz(n)}/assets/${e}`.replace(/\/+/g,"/")}const Hw="panel",jw="ref";function Qne(){const n="/".replace(/\/+$/,"/");let t=window.location.pathname.replace(/^\/+|\/+$/g,"");const r=n.replace(/^\/+|\/+$/g,"");if(r&&(t===r?t="":t.startsWith(`${r}/`)&&(t=t.slice(r.length+1))),!t)return null;const i=t.split("/")[0];return i==="main"||i.includes(".")||i==="assets"?null:i}function Pne(n,e){const t=n.replace(/\/+$/,"/"),r=new Set,i=(h,p)=>{if(h)try{const A=new URL(h,p||window.location.href).toString();r.add(A)}catch{r.add(h.replace(/\/+/g,"/"))}},s=`${window.location.origin}/`,a=new URL(t,s).toString();i("assets/config.json",a);const l=window.location.pathname.split("/").filter(Boolean);l.length>0&&l[l.length-1]==="index.html"&&l.pop(),l.length>0&&l[l.length-1]===(e??"main")&&l.pop();const c=`/${l.join("/")}${l.length?"/":""}`,d=`${window.location.origin}${c}`;return i("assets/config.json",d),i("assets/config.json"),i("../assets/config.json"),i("../../assets/config.json"),Array.from(r)}async function Lne(n,e){const r=new URLSearchParams(window.location.search).get("config"),i=Pne(n,e);if(r)try{i.unshift(new URL(r,window.location.href).toString())}catch{i.unshift(r)}let s=null;for(const a of i)try{const o=await fetch(a,{cache:"no-store"});if(!o.ok)throw new Error(`Failed to fetch ${a}: ${o.status}`);const l=await o.text(),c=l.trim();if((o.headers.get("content-type")||"").includes("text/html")||c.startsWith("<!doctype")||c.startsWith("<html"))throw new Error(`Received HTML from ${a}`);try{return JSON.parse(l)}catch(h){throw new Error(`Invalid JSON from ${a}: ${h instanceof Error?h.message:String(h)}`)}}catch(o){s=o instanceof Error?o:new Error(String(o))}throw s??new Error("Failed to load config.json.")}function Fne(n){return new URLSearchParams(n).get(Hw)!=="0"}function zne(n){return new URLSearchParams(n).get(jw)!=="0"}function Une(n){const t="/".replace(/\/+$/,"/").replace(/^\//g,"").replace(/\/+$/g,"");let r=t?`/${t}/`:"/";return n&&n!=="main"&&(r+=`${n}/`),r}function One({projectId:n,sceneName:e,policyName:t,panelVisible:r,showReference:i}){const s=Une(n),a=new URLSearchParams(window.location.search);e?a.set("scene",e):a.delete("scene"),t?a.set("policy",t):a.delete("policy"),r?a.delete(Hw):a.set(Hw,"0"),i?a.delete(jw):a.set(jw,"0");const o=a.toString(),l=s+(o?`?${o}`:"")+window.location.hash;window.history.replaceState({},"",l)}function $ne(){const[n,e]=U.useState(null),[t,r]=U.useState(null),[i,s]=U.useState(null),[a,o]=U.useState(null),[l,c]=U.useState(null),[d,h]=U.useState(()=>zne(window.location.search)),[p,A]=U.useState(null),[y,m]=U.useState(null),[x,g]=U.useState(null),[_,b]=U.useState(()=>Fne(window.location.search)),w=U.useRef(null),{showLoading:I,hideLoading:S,setLoadingMessage:M}=iz(),T=U.useMemo(()=>Qne(),[]),R=U.useMemo(()=>new URLSearchParams(window.location.search).get("scene"),[]),k=U.useMemo(()=>new URLSearchParams(window.location.search).get("policy"),[]);U.useEffect(()=>{I("Loading…"),Lne("/",T).then(q=>{e(q);const ee=q.projects.find(ce=>T===null?ce.id===null:ce.id===T);if(!ee)throw new Error(`Project "${T??"(main)"}" not found in config.json.`);r(ee);const ie=eD(ee,R);s(ie);const be=ie?J_(ie,k):null;o(be);const ve=ie?.policies.find(ce=>ce.name===be)??null;c(Zf(ve))}).catch(q=>{A(q.message||"Failed to load config."),S()})},[T,R,k,I,S]);const H=U.useMemo(()=>!t||!i?null:Nne(t,i),[t,i]),Q=U.useMemo(()=>!i||!a?null:i.policies.find(q=>q.name===a)??null,[i,a]),V=U.useMemo(()=>!t||!Q?.config?null:tD(t,Q.config),[t,Q]),B=U.useMemo(()=>Q?.motions?.length?Q.motions.map(q=>({value:q.name,label:q.name})):[],[Q]),W=U.useMemo(()=>!t||!i?.splats?.length?[]:i.splats.map(q=>q.path?{...q,url:tD(t,q.path)}:q),[t,i?.splats]),K=U.useMemo(()=>y?W.find(q=>q.name===y)??null:x?{name:"Custom",url:x}:null,[W,y,x]),X=U.useMemo(()=>n?n.projects.map(q=>({value:q.id??"main",label:q.name||(q.id??"Main")})):[],[n]),$=U.useMemo(()=>t?t.scenes.map(q=>({value:q.name,label:q.name})):[],[t]),J=U.useMemo(()=>!i||!i.policies?[]:i.policies.map(q=>({value:q.name,label:q.name})),[i]),ne=t?t.id??"main":null,L=i?.name??null,G=U.useCallback(q=>{A(q.message),S()},[S]),oe=U.useCallback(()=>{S()},[S]),Ae=U.useCallback(q=>{q==="Running simulation"||q==="Failed to load scene"||M(q)},[M]);U.useEffect(()=>{const q=i?.splats?.[0];m(q?q.name:null),g(null)},[i]);const ye=U.useCallback(q=>{w.current=q},[]);U.useEffect(()=>{c(Zf(Q)),h(!!Q?.motions?.length)},[Q]);const he=U.useMemo(()=>i?.splats?.length?i.splats.map(q=>({value:q.name,label:q.name})):[],[i?.splats]),fe=U.useCallback(async q=>{m(q),g(null);const ee=w.current;if(!ee)return;const ie=q===null?null:W.find(be=>be.name===q)??null;if(!(q!==null&&!ie)){I(q===null?"Removing splat…":`Loading splat "${q}"…`);try{await ee.setSplat(ie)}catch{}finally{S()}}},[W,I,S]),Ie=U.useCallback(async q=>{try{if(!(await fetch(q,{method:"HEAD"})).ok)return!1}catch{return!1}const ee=w.current;if(!ee)return!1;I('Loading splat "Custom"…');try{return await ee.setSplat({name:"Custom",url:q}),g(q),!0}catch{return!1}finally{S()}},[I,S]),Re=U.useCallback((q,ee,ie,be,ve,ce,Z)=>{const Y=K??(x?{name:"Custom",url:x}:null);Y&&w.current?.calibrateSplat({...Y,scale:q,xOffset:ee,yOffset:ie,zOffset:be,roll:ve,pitch:ce,yaw:Z})},[K,x]),ge=U.useCallback(q=>{One({projectId:q.projectId??t?.id??null,sceneName:q.sceneName??i?.name??null,policyName:q.policyName??a,panelVisible:q.panelVisible??_,showReference:q.showReference??d})},[t?.id,i?.name,a,_,d]),Ne=U.useCallback(q=>{if(!n||!q)return;const ee=q==="main"?null:q,ie=n.projects.find(Z=>(Z.id??"main")===(ee??"main"));if(!ie)return;const be=eD(ie,null);I(be?`Loading scene "${be.name}"…`:"Loading…"),r(ie),s(be);const ve=be?J_(be,null):null;o(ve);const ce=be?.policies.find(Z=>Z.name===ve)??null;c(Zf(ce)),ge({projectId:ie.id,sceneName:be?.name??null,policyName:ve})},[n,I,ge]),tt=U.useCallback(q=>{if(!t||!q)return;const ee=t.scenes.find(ve=>ve.name===q);if(!ee)return;I(`Loading scene "${ee.name}"…`),s(ee);const ie=J_(ee,null);o(ie);const be=ee.policies.find(ve=>ve.name===ie)??null;c(Zf(be)),ge({projectId:t.id,sceneName:q,policyName:ie})},[t,I,ge]),Ge=U.useCallback(q=>{q!==a&&I(q?`Loading policy "${q}"…`:"Loading policy…"),o(q);const ee=i?.policies.find(ie=>ie.name===q)??null;c(Zf(ee)),ge({policyName:q})},[a,I,ge]),F=U.useCallback(q=>{b(q),ge({panelVisible:q})},[ge]),re=U.useCallback(async q=>{const ee=l;c(q);const ie=w.current;if(ie){I(q===null?"Clearing motion…":`Loading motion "${q}"…`);try{await ie.setSelectedMotion(q)===!1&&q!==null&&c(ie.getSelectedMotionName()??ee)}catch{}finally{S()}}},[l,I,S]),Ee=U.useCallback(q=>{h(q),w.current?.setReferenceVisible(q),ge({showReference:q})},[ge]);return p?j.jsx(rb,{theme:Vw,defaultColorScheme:"auto",children:j.jsx("div",{className:"app",children:j.jsxs("div",{className:"hud hud-error",children:[j.jsx("h1",{className:"hud-title",children:"mjswan"}),j.jsx("p",{className:"hud-message",children:p})]})})}):!t||!i||!H?null:j.jsx(rb,{theme:Vw,defaultColorScheme:"auto",children:j.jsxs("div",{className:"app",children:[j.jsx(kne,{}),j.jsx(Tne,{visible:_,onVisibleChange:F,projects:X,projectValue:ne,projectLabel:t?.name??"mjswan",onProjectChange:Ne,scenes:$,sceneValue:L,onSceneChange:tt,splats:he,splatSection:i?.splatSection??!1,splatValue:y,onSplatChange:fe,splatConfig:K,onCalibrateSplat:Re,onSplatUrlLoad:Ie,policies:J,policyValue:a,onPolicyChange:Ge,motions:B,motionValue:l,onMotionChange:re,showReferenceMotion:d,onShowReferenceMotionChange:Ee,commandsEnabled:!!V}),j.jsx(une,{scenePath:H,baseUrl:"/",policyConfigPath:V,splatConfig:K,cameraConfig:i?.camera,eventsConfig:i?.events,terrainData:i?.terrainData,selectedMotion:l,showReferenceMotion:d,onError:G,onReady:oe,onStatusChange:Ae,onRuntimeReady:ye})]})})}function Gne(){return j.jsx(Dne,{children:j.jsx($ne,{})})}const nD=document.getElementById("root");nD&&qz.createRoot(nD).render(j.jsx(On.StrictMode,{children:j.jsx(Gne,{})}));export{DV as _};
|
|
15609
|
+
${s}`,o=t.createShaderModule({code:a,label:n.name});un("verbose",()=>`[WebGPU] ${n.name} shader code: ${a}`);let l=t.createComputePipeline({compute:{module:o,entryPoint:"main"},layout:"auto",label:n.name});return Js(n.name),{programInfo:n,computePipeline:l,uniformVariablesInfo:i.variablesInfo}}normalizeDispatchGroupSize(n){let e=typeof n=="number"?n:n.x,t=typeof n=="number"?1:n.y||1,r=typeof n=="number"?1:n.z||1,i=this.backend.device.limits.maxComputeWorkgroupsPerDimension;if(e<=i&&t<=i&&r<=i)return[e,t,r];let s=e*t*r,a=Math.ceil(Math.sqrt(s));if(a>i){if(a=Math.ceil(Math.cbrt(s)),a>i)throw new Error("Total dispatch size exceeds WebGPU maximum.");return[a,a,a]}else return[a,a,1]}}}),Q4={};_h(Q4,{WebGpuBackend:()=>P4});var zR,UR,OR,P4,Gte=et(()=>{gs(),Lt(),ko(),WP(),Zee(),Ote(),$te(),zR=(n,e)=>{if(e.length!==n.length)throw new Error(`inputDependencies length ${e.length} is not equal to inputTensors length ${n.length}.`);let t=[];for(let r=0;r<n.length;++r){let i=n[r].dataType;switch(e[r]){case"none":{t.push("");break}case"type":{t.push(`${i}`);break}case"rank":{let s=n[r].dims.length;t.push(`${i};${s}`);break}case"dims":{let s=n[r].dims.join(",");t.push(`${i};${s}`);break}default:throw new Error(`unsupported input dependency: ${e[r]}`)}}return t.join("|")},UR=(n,e,t)=>{let r=n.name;return n.shaderCache?.hint&&(r+="["+n.shaderCache.hint+"]"),r+=":"+t+`:${zR(e,n.shaderCache?.inputDependencies??new Array(e.length).fill("dims"))}`,r},OR=class{constructor(n){n&&(this.architecture=n.architecture,this.vendor=n.vendor)}isArchitecture(n){return this.architecture===n}isVendor(n){return this.vendor===n}},P4=class{constructor(){this.currentSessionId=null,this.currentKernelId=null,this.commandEncoder=null,this.computePassEncoder=null,this.maxDispatchNumber=16,this.pendingDispatchNumber=0,this.pendingKernels=[],this.pendingQueries=new Map,this.sessionStatus="default",this.capturedCommandList=new Map,this.capturedPendingKernels=new Map,this.sessionExternalDataMapping=new Map}get currentKernelCustomData(){if(this.currentKernelId===null)throw new Error("currentKernelCustomData(): currentKernelId is null. (should not happen)");let n=this.kernelCustomData.get(this.currentKernelId);return n||(n={},this.kernelCustomData.set(this.currentKernelId,n)),n}async initialize(n,e){this.env=n;let t=[],r={requiredLimits:{maxComputeWorkgroupStorageSize:e.limits.maxComputeWorkgroupStorageSize,maxComputeWorkgroupsPerDimension:e.limits.maxComputeWorkgroupsPerDimension,maxStorageBufferBindingSize:e.limits.maxStorageBufferBindingSize,maxBufferSize:e.limits.maxBufferSize,maxComputeInvocationsPerWorkgroup:e.limits.maxComputeInvocationsPerWorkgroup,maxComputeWorkgroupSizeX:e.limits.maxComputeWorkgroupSizeX,maxComputeWorkgroupSizeY:e.limits.maxComputeWorkgroupSizeY,maxComputeWorkgroupSizeZ:e.limits.maxComputeWorkgroupSizeZ},requiredFeatures:t},i=s=>e.features.has(s)&&t.push(s)&&!0;i("chromium-experimental-timestamp-query-inside-passes")||i("timestamp-query"),i("shader-f16"),i("subgroups"),this.device=await e.requestDevice(r),this.adapterInfo=new OR(e.info||await e.requestAdapterInfo()),this.gpuDataManager=XP(this),this.programManager=new N4(this),this.kernels=new Map,this.kernelPersistentData=new Map,this.kernelCustomData=new Map,tC(n.logLevel,!!n.debug),this.device.onuncapturederror=s=>{s.error instanceof GPUValidationError},Object.defineProperty(this.env.webgpu,"device",{value:this.device,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.env.webgpu,"adapter",{value:e,writable:!1,enumerable:!0,configurable:!1}),this.setQueryType()}dispose(){typeof this.querySet<"u"&&this.querySet.destroy(),this.gpuDataManager.dispose()}getCommandEncoder(){return this.commandEncoder||(this.commandEncoder=this.device.createCommandEncoder()),this.commandEncoder}getComputePassEncoder(){if(!this.computePassEncoder){let n=this.getCommandEncoder(),e={};this.queryType==="at-passes"&&(e.timestampWrites={querySet:this.querySet,beginningOfPassWriteIndex:this.pendingDispatchNumber*2,endOfPassWriteIndex:this.pendingDispatchNumber*2+1}),this.computePassEncoder=n.beginComputePass(e)}return this.computePassEncoder}endComputePass(){this.computePassEncoder&&(this.computePassEncoder.end(),this.computePassEncoder=null)}flush(){if(!this.commandEncoder)return;Pa(),this.endComputePass();let n;this.queryType!=="none"&&(this.commandEncoder.resolveQuerySet(this.querySet,0,this.pendingDispatchNumber*2,this.queryResolveBuffer,0),n=this.device.createBuffer({size:this.pendingDispatchNumber*2*8,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),this.pendingQueries.set(n,this.pendingKernels),this.pendingKernels=[],this.commandEncoder.copyBufferToBuffer(this.queryResolveBuffer,0,n,0,this.pendingDispatchNumber*2*8)),this.device.queue.submit([this.commandEncoder.finish()]),this.gpuDataManager.refreshPendingBuffers(),this.commandEncoder=null,this.pendingDispatchNumber=0,this.queryType!=="none"&&n.mapAsync(GPUMapMode.READ).then(()=>{let e=new BigUint64Array(n.getMappedRange()),t=this.pendingQueries.get(n);for(let r=0;r<e.length/2;r++){let i=t[r],s=i.kernelId,a=this.kernels.get(s),o=a.kernelType,l=a.kernelName,c=i.programName,d=i.inputTensorViews,h=i.outputTensorViews,p=e[r*2],A=e[r*2+1];typeof this.queryTimeBase>"u"&&(this.queryTimeBase=p);let y=Number(p-this.queryTimeBase),m=Number(A-this.queryTimeBase);if(!Number.isSafeInteger(y)||!Number.isSafeInteger(m))throw new RangeError("incorrect timestamp range");if(this.env.webgpu.profiling?.ondata)this.env.webgpu.profiling.ondata({version:1,inputsMetadata:d.map(x=>({dims:x.dims,dataType:ho(x.dataType)})),outputsMetadata:h.map(x=>({dims:x.dims,dataType:ho(x.dataType)})),kernelId:s,kernelType:o,kernelName:l,programName:c,startTime:y,endTime:m});else{let x="";d.forEach((_,b)=>{x+=`input[${b}]: [${_.dims}] | ${ho(_.dataType)}, `});let g="";h.forEach((_,b)=>{g+=`output[${b}]: [${_.dims}] | ${ho(_.dataType)}, `})}Xg("GPU",`${c}::${p}::${A}`)}n.unmap(),this.pendingQueries.delete(n)}),Js()}run(n,e,t,r,i,s){Pa(n.name);let a=[];for(let _=0;_<e.length;++_){let b=e[_].data;if(b===0)continue;let w=this.gpuDataManager.get(b);if(!w)throw new Error(`no GPU data for input: ${b}`);a.push(w)}let{outputs:o,dispatchGroup:l,programUniforms:c}=n.getRunData(e),d=t.length===0?o.map((_,b)=>b):t;if(d.length!==o.length)throw new Error(`Output size ${d.length} must be equal to ${o.length}.`);let h=[],p=[];for(let _=0;_<o.length;++_){if(!Number.isInteger(d[_])||d[_]<-3||d[_]>=s)throw new Error(`Invalid output index: ${d[_]}`);if(d[_]===-3)continue;let b=d[_]===-1,w=d[_]===-2,I=b||w?i(o[_].dataType,o[_].dims):r(d[_],o[_].dataType,o[_].dims);if(h.push(I),I.data===0)continue;let S=this.gpuDataManager.get(I.data);if(!S)throw new Error(`no GPU data for output: ${I.data}`);if(b&&this.temporaryData.push(S),w){let M=this.kernelPersistentData.get(this.currentKernelId);M||(M=[],this.kernelPersistentData.set(this.currentKernelId,M)),M.push(S)}p.push(S)}if(a.length!==e.length||p.length!==h.length){if(p.length===0)return Js(n.name),h;throw new Error(`Program ${n.name} has zero-sized tensor(s) in inputs or outputs. This is not supported now.`)}let A;if(c){let _=0,b=[];c.forEach(M=>{let T=typeof M.data=="number"?[M.data]:M.data;if(T.length===0)return;let R=M.type===10?2:4,k,H;M.type===10?(H=T.length>4?16:T.length>2?8:T.length*R,k=T.length>4?16:R*T.length):(H=T.length<=2?T.length*R:16,k=16),_=Math.ceil(_/H)*H,b.push(_);let Q=M.type===10?8:4;_+=T.length>4?Math.ceil(T.length/Q)*k:T.length*R});let w=16;_=Math.ceil(_/w)*w;let I=new ArrayBuffer(_);c.forEach((M,T)=>{let R=b[T],k=typeof M.data=="number"?[M.data]:M.data;if(M.type===6)new Int32Array(I,R,k.length).set(k);else if(M.type===12)new Uint32Array(I,R,k.length).set(k);else if(M.type===10)new Uint16Array(I,R,k.length).set(k);else if(M.type===1)new Float32Array(I,R,k.length).set(k);else throw new Error(`Unsupported uniform type: ${ho(M.type)}`)});let S=this.gpuDataManager.create(_,GPUBufferUsage.COPY_DST|GPUBufferUsage.UNIFORM);this.device.queue.writeBuffer(S.buffer,0,I,0,_),this.gpuDataManager.release(S.id),A={offset:0,size:_,buffer:S.buffer}}let y=this.programManager.normalizeDispatchGroupSize(l),m=y[1]===1&&y[2]===1,x=UR(n,e,m),g=this.programManager.getArtifact(x);if(g||(g=this.programManager.build(n,y),this.programManager.setArtifact(x,g),un("info",()=>`[artifact] key: ${x}, programName: ${n.name}`)),c&&g.uniformVariablesInfo){if(c.length!==g.uniformVariablesInfo.length)throw new Error(`Uniform variables count mismatch: expect ${g.uniformVariablesInfo.length}, got ${c.length} in program "${g.programInfo.name}".`);for(let _=0;_<c.length;_++){let b=c[_],w=b.type,I=typeof b.data=="number"?1:b.data.length,[S,M]=g.uniformVariablesInfo[_];if(w!==S||I!==M)throw new Error(`Uniform variable ${_} mismatch: expect type ${S} with size ${M}, got type ${w} with size ${I} in program "${g.programInfo.name}".`)}}if(un("info",()=>`[ProgramManager] run "${n.name}" (key=${x}) with ${y[0]}x${y[1]}x${y[2]}`),this.queryType!=="none"||this.sessionStatus==="capturing"){let _={kernelId:this.currentKernelId,programName:g.programInfo.name,inputTensorViews:e,outputTensorViews:h};this.pendingKernels.push(_),this.sessionStatus==="capturing"&&this.capturedPendingKernels.get(this.currentSessionId).push(_)}return this.programManager.run(g,a,p,y,A),Js(n.name),h}upload(n,e){this.gpuDataManager.upload(n,e)}memcpy(n,e){this.gpuDataManager.memcpy(n,e)}async download(n,e){await this.gpuDataManager.download(n,e)}alloc(n){return this.gpuDataManager.create(n).id}free(n){return this.gpuDataManager.release(n)}createKernel(n,e,t,r){let i=k4.get(n);if(!i)throw new Error(`kernel not implemented: ${n}`);let s={kernelType:n,kernelName:r,kernelEntry:i[0],attributes:[i[1],t]};this.kernels.set(e,s)}releaseKernel(n){let e=this.kernelPersistentData.get(n);if(e){for(let t of e)this.gpuDataManager.release(t.id);this.kernelPersistentData.delete(n)}this.kernelCustomData.delete(n),this.kernels.delete(n)}computeKernel(n,e,t){let r=this.kernels.get(n);if(!r)throw new Error(`kernel not created: ${n}`);let i=r.kernelType,s=r.kernelName,a=r.kernelEntry,o=r.attributes;if(this.currentKernelId!==null)throw new Error(`kernel "[${i}] ${s}" is not allowed to be called recursively`);this.currentKernelId=n,o[0]&&(o[1]=o[0](o[1]),o[0]=void 0),un("info",()=>`[WebGPU] Start to run kernel "[${i}] ${s}"...`);let l=this.env.debug;this.temporaryData=[];try{return l&&this.device.pushErrorScope("validation"),a(e,o[1]),0}catch(c){return t.push(Promise.resolve(`[WebGPU] Kernel "[${i}] ${s}" failed. ${c}`)),1}finally{l&&t.push(this.device.popErrorScope().then(c=>c?`GPU validation error for kernel "[${i}] ${s}": ${c.message}`:null));for(let c of this.temporaryData)this.gpuDataManager.release(c.id);this.temporaryData=[],this.currentKernelId=null}}registerBuffer(n,e,t,r){let i=this.sessionExternalDataMapping.get(n);i||(i=new Map,this.sessionExternalDataMapping.set(n,i));let s=i.get(e),a=this.gpuDataManager.registerExternalBuffer(t,r,s);return i.set(e,[a,t]),a}unregisterBuffers(n){let e=this.sessionExternalDataMapping.get(n);e&&(e.forEach(t=>this.gpuDataManager.unregisterExternalBuffer(t[0])),this.sessionExternalDataMapping.delete(n))}getBuffer(n){let e=this.gpuDataManager.get(n);if(!e)throw new Error(`no GPU data for buffer: ${n}`);return e.buffer}createDownloader(n,e,t){return async()=>{let r=await Rw(this,n,e);return nC(r.buffer,t)}}writeTimestamp(n){this.queryType==="inside-passes"&&this.computePassEncoder.writeTimestamp(this.querySet,n)}setQueryType(){this.queryType="none",(this.env.webgpu.profiling?.mode==="default"||(typeof this.env.trace>"u"?this.env.wasm.trace:this.env.trace))&&(this.device.features.has("chromium-experimental-timestamp-query-inside-passes")?this.queryType="inside-passes":this.device.features.has("timestamp-query")&&(this.queryType="at-passes"),this.queryType!=="none"&&typeof this.querySet>"u"&&(this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxDispatchNumber*2}),this.queryResolveBuffer=this.device.createBuffer({size:this.maxDispatchNumber*2*8,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.QUERY_RESOLVE})))}captureBegin(){un("info","captureBegin"),this.capturedCommandList.get(this.currentSessionId)||this.capturedCommandList.set(this.currentSessionId,[]),this.capturedPendingKernels.get(this.currentSessionId)||this.capturedPendingKernels.set(this.currentSessionId,[]),this.flush(),this.sessionStatus="capturing"}captureEnd(){un("info","captureEnd"),this.flush(),this.sessionStatus="default"}replay(){un("info","replay"),this.sessionStatus="replaying";let n=this.capturedCommandList.get(this.currentSessionId),e=this.capturedPendingKernels.get(this.currentSessionId),t=n.length;this.pendingKernels=[];for(let r=0;r<t;r++){let i=this.getComputePassEncoder(),s=n[r];this.writeTimestamp(this.pendingDispatchNumber*2),i.setPipeline(s.computePipeline),i.setBindGroup(0,s.bindGroup),i.dispatchWorkgroups(...s.dispatchGroup),this.writeTimestamp(this.pendingDispatchNumber*2+1),this.pendingDispatchNumber++,this.queryType!=="none"&&this.pendingKernels.push(e[r]),(this.pendingDispatchNumber>=this.maxDispatchNumber||this.queryType==="at-passes")&&this.endComputePass(),this.pendingDispatchNumber>=this.maxDispatchNumber&&this.flush()}this.flush(),this.sessionStatus="default"}onCreateSession(){this.gpuDataManager.onCreateSession()}onReleaseSession(n){this.unregisterBuffers(n),this.capturedCommandList.has(n)&&this.capturedCommandList.delete(n),this.capturedPendingKernels.has(n)&&this.capturedPendingKernels.delete(n),this.gpuDataManager.onReleaseSession(n)}onRunStart(n){this.currentSessionId=n,this.setQueryType()}}}),L4={};_h(L4,{init:()=>F4});var rg,$R,F4,Vte=et(()=>{Lt(),ko(),jt(),Kee(),rg=class z4{constructor(e,t,r,i){this.module=e,this.dataType=t,this.data=r,this.dims=i}getFloat32Array(){if(this.dataType!==1)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new Float32Array:new Float32Array(this.module.HEAP8.buffer,this.data,e)}getBigInt64Array(){if(this.dataType!==7)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new BigInt64Array:new BigInt64Array(this.module.HEAP8.buffer,this.data,e)}getInt32Array(){if(this.dataType!==6)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new Int32Array:new Int32Array(this.module.HEAP8.buffer,this.data,e)}getUint16Array(){if(this.dataType!==10&&this.dataType!==4)throw new Error("Invalid data type");let e=Le.size(this.dims);return e===0?new Uint16Array:new Uint16Array(this.module.HEAP8.buffer,this.data,e)}reshape(e){if(Le.size(e)!==Le.size(this.dims))throw new Error("Invalid new shape");return new z4(this.module,this.dataType,this.data,e)}},$R=class{constructor(n,e,t){this.module=n,this.backend=e,this.customDataOffset=0,this.customDataSize=0,this.adapterInfo=e.adapterInfo;let r=n.PTR_SIZE,i=t/n.PTR_SIZE,s=r===4?"i32":"i64";this.opKernelContext=Number(n.getValue(r*i++,s));let a=Number(n.getValue(r*i++,s));this.outputCount=Number(n.getValue(r*i++,s)),this.customDataOffset=Number(n.getValue(r*i++,"*")),this.customDataSize=Number(n.getValue(r*i++,s));let o=[];for(let l=0;l<a;l++){let c=Number(n.getValue(r*i++,s)),d=Number(n.getValue(r*i++,"*")),h=Number(n.getValue(r*i++,s)),p=[];for(let A=0;A<h;A++)p.push(Number(n.getValue(r*i++,s)));o.push(new rg(n,c,d,p))}this.inputs=o}get kernelCustomData(){return this.backend.currentKernelCustomData}get customDataBuffer(){return this.module.HEAPU8.subarray(this.customDataOffset,this.customDataOffset+this.customDataSize)}compute(n,e){let t=e?.inputs?.map(a=>typeof a=="number"?this.inputs[a]:a)??this.inputs,r=e?.outputs??[],i=(a,o,l)=>new rg(this.module,o,this.output(a,l),l),s=(a,o)=>{let l=Lc(a,o);if(!l)throw new Error(`Unsupported data type: ${a}`);let c=l>0?this.backend.gpuDataManager.create(l).id:0;return new rg(this.module,a,c,o)};return this.backend.run(n,t,r,i,s,this.outputCount)}output(n,e){let t=this.module.stackSave();try{let r=this.module.PTR_SIZE,i=r===4?"i32":"i64",s=this.module.stackAlloc((1+e.length)*r);this.module.setValue(s,e.length,i);for(let a=0;a<e.length;a++)this.module.setValue(s+r*(a+1),e[a],i);return this.module._JsepOutput(this.opKernelContext,n,s)}catch(r){throw new Error(`Failed to generate kernel's output[${n}] with dims [${e}]. If you are running with pre-allocated output, please make sure the output type/dims are correct. Error: ${r}`)}finally{this.module.stackRestore(t)}}},F4=async(n,e,t,r)=>{let i=e.jsepInit;if(!i)throw new Error("Failed to initialize JSEP. The WebAssembly module is not built with JSEP support.");if(n==="webgpu"){let s=(Gte(),Lp(Q4)).WebGpuBackend,a=new s;await a.initialize(t,r),i("webgpu",[a,o=>a.alloc(Number(o)),o=>a.free(o),(o,l,c,d=!1)=>{if(d)un("verbose",()=>`[WebGPU] jsepCopyGpuToGpu: src=${Number(o)}, dst=${Number(l)}, size=${Number(c)}`),a.memcpy(Number(o),Number(l));else{un("verbose",()=>`[WebGPU] jsepCopyCpuToGpu: dataOffset=${Number(o)}, gpuDataId=${Number(l)}, size=${Number(c)}`);let h=e.HEAPU8.subarray(Number(o>>>0),Number(o>>>0)+Number(c));a.upload(Number(l),h)}},async(o,l,c)=>{un("verbose",()=>`[WebGPU] jsepCopyGpuToCpu: gpuDataId=${o}, dataOffset=${l}, size=${c}`),await a.download(Number(o),()=>e.HEAPU8.subarray(Number(l)>>>0,Number(l+c)>>>0))},(o,l,c)=>a.createKernel(o,Number(l),c,e.UTF8ToString(e._JsepGetNodeName(Number(l)))),o=>a.releaseKernel(o),(o,l,c,d)=>{un("verbose",()=>`[WebGPU] jsepRun: sessionHandle=${c}, kernel=${o}, contextDataOffset=${l}`);let h=new $R(e,a,Number(l));return a.computeKernel(Number(o),h,d)},()=>a.captureBegin(),()=>a.captureEnd(),()=>a.replay()])}else{let s=new YP(t);i("webnn",[s,()=>s.reserveTensorId(),a=>s.releaseTensorId(a),async(a,o,l,c,d)=>s.ensureTensor(a,o,l,c,d),(a,o)=>{s.uploadTensor(a,o)},async(a,o)=>s.downloadTensor(a,o),(a,o)=>s.registerMLContext(a,o),!!t.trace])}}}),GR,fC,pC,Il,VR,j_,r0,AC,mC,W_,gC,yC,xC,U4=et(()=>{gs(),qee(),Yee(),Lt(),cu(),JI(),GP(),GR=(n,e)=>{kn()._OrtInit(n,e)!==0&&wn("Can't initialize onnxruntime.")},fC=async n=>{GR(n.wasm.numThreads,Kg(n.logLevel))},pC=async(n,e)=>{kn().asyncInit?.();let t=n.webgpu.adapter;if(e==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(t){if(typeof t.limits!="object"||typeof t.features!="object"||typeof t.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let r=n.webgpu.powerPreference;if(r!==void 0&&r!=="low-power"&&r!=="high-performance")throw new Error(`Invalid powerPreference setting: "${r}"`);let i=n.webgpu.forceFallbackAdapter;if(i!==void 0&&typeof i!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${i}"`);if(t=await navigator.gpu.requestAdapter({powerPreference:r,forceFallbackAdapter:i}),!t)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(e==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment");{let r=(Vte(),Lp(L4)).init;e==="webgpu"&&await r("webgpu",kn(),n,t),e==="webnn"&&await r("webnn",kn(),n)}},Il=new Map,VR=n=>{let e=kn(),t=e.stackSave();try{let r=e.PTR_SIZE,i=e.stackAlloc(2*r);e._OrtGetInputOutputCount(n,i,i+r)!==0&&wn("Can't get session input/output count.");let s=r===4?"i32":"i64";return[Number(e.getValue(i,s)),Number(e.getValue(i+r,s))]}finally{e.stackRestore(t)}},j_=(n,e)=>{let t=kn(),r=t.stackSave(),i=0;try{let s=t.PTR_SIZE,a=t.stackAlloc(2*s);t._OrtGetInputOutputMetadata(n,e,a,a+s)!==0&&wn("Can't get session input/output metadata.");let o=Number(t.getValue(a,"*"));i=Number(t.getValue(a+s,"*"));let l=t.HEAP32[i/4];if(l===0)return[o,0];let c=t.HEAPU32[i/4+1],d=[];for(let h=0;h<c;h++){let p=Number(t.getValue(i+8+h*s,"*"));d.push(p!==0?t.UTF8ToString(p):Number(t.getValue(i+8+(h+c)*s,"*")))}return[o,l,d]}finally{t.stackRestore(r),i!==0&&t._OrtFree(i)}},r0=n=>{let e=kn(),t=e._malloc(n.byteLength);if(t===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${n.byteLength}.`);return e.HEAPU8.set(n,t),[t,n.byteLength]},AC=async(n,e)=>{let t,r,i=kn();Array.isArray(n)?[t,r]=n:n.buffer===i.HEAPU8.buffer?[t,r]=[n.byteOffset,n.byteLength]:[t,r]=r0(n);let s=0,a=0,o=0,l=[],c=[],d=[];try{if([a,l]=await $P(e),e?.externalData&&i.mountExternalData){let w=[];for(let I of e.externalData){let S=typeof I=="string"?I:I.path;w.push(eC(typeof I=="string"?I:I.data).then(M=>{i.mountExternalData(S,M)}))}await Promise.all(w)}for(let w of e?.executionProviders??[])if((typeof w=="string"?w:w.name)==="webnn"){if(i.shouldTransferToMLTensor=!1,typeof w!="string"){let I=w,S=I?.context,M=I?.gpuDevice,T=I?.deviceType,R=I?.powerPreference;S?i.currentContext=S:M?i.currentContext=await i.webnnCreateMLContext(M):i.currentContext=await i.webnnCreateMLContext({deviceType:T,powerPreference:R})}else i.currentContext=await i.webnnCreateMLContext();break}s=await i._OrtCreateSession(t,r,a),i.webgpuOnCreateSession?.(s),s===0&&wn("Can't create a session."),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(s,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[h,p]=VR(s),A=!!e?.enableGraphCapture,y=[],m=[],x=[],g=[],_=[];for(let w=0;w<h;w++){let[I,S,M]=j_(s,w);I===0&&wn("Can't get an input name."),c.push(I);let T=i.UTF8ToString(I);y.push(T),x.push(S===0?{name:T,isTensor:!1}:{name:T,isTensor:!0,type:ho(S),shape:M})}for(let w=0;w<p;w++){let[I,S,M]=j_(s,w+h);I===0&&wn("Can't get an output name."),d.push(I);let T=i.UTF8ToString(I);m.push(T),g.push(S===0?{name:T,isTensor:!1}:{name:T,isTensor:!0,type:ho(S),shape:M});{if(A&&e?.preferredOutputLocation===void 0){_.push("gpu-buffer");continue}let R=typeof e?.preferredOutputLocation=="string"?e.preferredOutputLocation:e?.preferredOutputLocation?.[T]??"cpu",k=i.webnnIsGraphOutput;if(R==="cpu"&&k&&k(s,T)){_.push("ml-tensor-cpu-output");continue}if(R!=="cpu"&&R!=="cpu-pinned"&&R!=="gpu-buffer"&&R!=="ml-tensor")throw new Error(`Not supported preferred output location: ${R}.`);if(A&&R!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${R}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);_.push(R)}}let b=null;return _.some(w=>w==="gpu-buffer"||w==="ml-tensor"||w==="ml-tensor-cpu-output")&&(o=i._OrtCreateBinding(s),o===0&&wn("Can't create IO binding."),b={handle:o,outputPreferredLocations:_,outputPreferredLocationsEncoded:_.map(w=>w==="ml-tensor-cpu-output"?"ml-tensor":w).map(w=>Mw(w))}),Il.set(s,[s,c,d,b,A,!1]),[s,y,m,x,g]}catch(h){throw c.forEach(p=>i._OrtFree(p)),d.forEach(p=>i._OrtFree(p)),o!==0&&i._OrtReleaseBinding(o)!==0&&wn("Can't release IO binding."),s!==0&&i._OrtReleaseSession(s)!==0&&wn("Can't release session."),h}finally{i._free(t),a!==0&&i._OrtReleaseSessionOptions(a)!==0&&wn("Can't release session options."),l.forEach(h=>i._free(h)),i.unmountExternalData?.()}},mC=n=>{let e=kn(),t=Il.get(n);if(!t)throw new Error(`cannot release session. invalid session id: ${n}`);let[r,i,s,a,o]=t;a&&(o&&e._OrtClearBoundOutputs(a.handle)!==0&&wn("Can't clear bound outputs."),e._OrtReleaseBinding(a.handle)!==0&&wn("Can't release IO binding.")),e.jsepOnReleaseSession?.(n),e.webnnOnReleaseSession?.(n),e.webgpuOnReleaseSession?.(n),i.forEach(l=>e._OrtFree(l)),s.forEach(l=>e._OrtFree(l)),e._OrtReleaseSession(r)!==0&&wn("Can't release session."),Il.delete(n)},W_=async(n,e,t,r,i,s,a=!1)=>{if(!n){e.push(0);return}let o=kn(),l=o.PTR_SIZE,c=n[0],d=n[1],h=n[3],p=h,A,y;if(c==="string"&&(h==="gpu-buffer"||h==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(a&&h!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${s} when enableGraphCapture is true.`);if(h==="gpu-buffer"){let g=n[2].gpuBuffer;y=Lc(Pc(c),d);{let _=o.jsepRegisterBuffer;if(!_)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');A=_(r,s,g,y)}}else if(h==="ml-tensor"){let g=n[2].mlTensor;y=Lc(Pc(c),d);let _=o.webnnRegisterMLTensor;if(!_)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');A=_(r,g,Pc(c),d)}else{let g=n[2];if(Array.isArray(g)){y=l*g.length,A=o._malloc(y),t.push(A);for(let _=0;_<g.length;_++){if(typeof g[_]!="string")throw new TypeError(`tensor data at index ${_} is not a string`);o.setValue(A+_*l,Os(g[_],t),"*")}}else{let _=o.webnnIsGraphInput,b=o.webnnIsGraphOutput;if(c!=="string"&&_&&b){let w=o.UTF8ToString(i);if(_(r,w)||b(r,w)){let I=Pc(c);y=Lc(I,d),p="ml-tensor";let S=o.webnnCreateTemporaryTensor,M=o.webnnUploadTensor;if(!S||!M)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let T=await S(r,I,d);M(T,new Uint8Array(g.buffer,g.byteOffset,g.byteLength)),A=T}else y=g.byteLength,A=o._malloc(y),t.push(A),o.HEAPU8.set(new Uint8Array(g.buffer,g.byteOffset,y),A)}else y=g.byteLength,A=o._malloc(y),t.push(A),o.HEAPU8.set(new Uint8Array(g.buffer,g.byteOffset,y),A)}}let m=o.stackSave(),x=o.stackAlloc(4*d.length);try{d.forEach((_,b)=>o.setValue(x+b*l,_,l===4?"i32":"i64"));let g=o._OrtCreateTensor(Pc(c),A,y,x,d.length,Mw(p));g===0&&wn(`Can't create tensor for input/output. session=${r}, index=${s}.`),e.push(g)}finally{o.stackRestore(m)}},gC=async(n,e,t,r,i,s)=>{let a=kn(),o=a.PTR_SIZE,l=Il.get(n);if(!l)throw new Error(`cannot run inference. invalid session id: ${n}`);let c=l[0],d=l[1],h=l[2],p=l[3],A=l[4],y=l[5],m=e.length,x=r.length,g=0,_=[],b=[],w=[],I=[],S=[],M=a.stackSave(),T=a.stackAlloc(m*o),R=a.stackAlloc(m*o),k=a.stackAlloc(x*o),H=a.stackAlloc(x*o);try{[g,_]=OP(s),Wc("wasm prepareInputOutputTensor");for(let W=0;W<m;W++)await W_(t[W],b,I,n,d[e[W]],e[W],A);for(let W=0;W<x;W++)await W_(i[W],w,I,n,h[r[W]],m+r[W],A);qc("wasm prepareInputOutputTensor");for(let W=0;W<m;W++)a.setValue(T+W*o,b[W],"*"),a.setValue(R+W*o,d[e[W]],"*");for(let W=0;W<x;W++)a.setValue(k+W*o,w[W],"*"),a.setValue(H+W*o,h[r[W]],"*");if(p&&!y){let{handle:W,outputPreferredLocations:K,outputPreferredLocationsEncoded:X}=p;if(d.length!==m)throw new Error(`input count from feeds (${m}) is expected to be always equal to model's input count (${d.length}).`);Wc("wasm bindInputsOutputs");for(let $=0;$<m;$++){let J=e[$];await a._OrtBindInput(W,d[J],b[$])!==0&&wn(`Can't bind input[${$}] for session=${n}.`)}for(let $=0;$<x;$++){let J=r[$];i[$]?.[3]?(S.push(w[$]),a._OrtBindOutput(W,h[J],w[$],0)!==0&&wn(`Can't bind pre-allocated output[${$}] for session=${n}.`)):a._OrtBindOutput(W,h[J],0,X[J])!==0&&wn(`Can't bind output[${$}] to ${K[$]} for session=${n}.`)}qc("wasm bindInputsOutputs"),Il.set(n,[c,d,h,p,A,!0])}a.jsepOnRunStart?.(c),a.webnnOnRunStart?.(c);let Q;p?Q=await a._OrtRunWithBinding(c,p.handle,x,k,g):Q=await a._OrtRun(c,R,T,m,H,x,k,g),Q!==0&&wn("failed to call OrtRun().");let V=[],B=[];Wc("wasm ProcessOutputTensor");for(let W=0;W<x;W++){let K=Number(a.getValue(k+W*o,"*"));if(K===w[W]||S.includes(w[W])){V.push(i[W]),K!==w[W]&&a._OrtReleaseTensor(K)!==0&&wn("Can't release tensor.");continue}let X=a.stackSave(),$=a.stackAlloc(4*o),J=!1,ne,L=0;try{a._OrtGetTensorData(K,$,$+o,$+2*o,$+3*o)!==0&&wn(`Can't access output tensor data on index ${W}.`);let G=o===4?"i32":"i64",oe=Number(a.getValue($,G));L=a.getValue($+o,"*");let Ae=a.getValue($+o*2,"*"),ye=Number(a.getValue($+o*3,G)),he=[];for(let Re=0;Re<ye;Re++)he.push(Number(a.getValue(Ae+Re*o,G)));a._OrtFree(Ae)!==0&&wn("Can't free memory for tensor dims.");let fe=he.reduce((Re,ge)=>Re*ge,1);ne=ho(oe);let Ie=p?.outputPreferredLocations[r[W]];if(ne==="string"){if(Ie==="gpu-buffer"||Ie==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Re=[];for(let ge=0;ge<fe;ge++){let Ne=a.getValue(L+ge*o,"*"),tt=a.getValue(L+(ge+1)*o,"*"),Ge=ge===fe-1?void 0:tt-Ne;Re.push(a.UTF8ToString(Ne,Ge))}V.push([ne,he,Re,"cpu"])}else if(Ie==="gpu-buffer"&&fe>0){let Re=a.jsepGetBuffer;if(!Re)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let ge=Re(L),Ne=Lc(oe,fe);if(Ne===void 0||!KI(ne))throw new Error(`Unsupported data type: ${ne}`);J=!0,V.push([ne,he,{gpuBuffer:ge,download:a.jsepCreateDownloader(ge,Ne,ne),dispose:()=>{a._OrtReleaseTensor(K)!==0&&wn("Can't release tensor.")}},"gpu-buffer"])}else if(Ie==="ml-tensor"&&fe>0){let Re=a.webnnEnsureTensor,ge=a.webnnIsGraphInputOutputTypeSupported;if(!Re||!ge)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Lc(oe,fe)===void 0||!ZI(ne))throw new Error(`Unsupported data type: ${ne}`);if(!ge(n,ne,!1))throw new Error(`preferredLocation "ml-tensor" for ${ne} output is not supported by current WebNN Context.`);let Ne=await Re(n,L,oe,he,!1);J=!0,V.push([ne,he,{mlTensor:Ne,download:a.webnnCreateMLTensorDownloader(L,ne),dispose:()=>{a.webnnReleaseTensorId(L),a._OrtReleaseTensor(K)}},"ml-tensor"])}else if(Ie==="ml-tensor-cpu-output"&&fe>0){let Re=a.webnnCreateMLTensorDownloader(L,ne)(),ge=V.length;J=!0,B.push((async()=>{let Ne=[ge,await Re];return a.webnnReleaseTensorId(L),a._OrtReleaseTensor(K),Ne})()),V.push([ne,he,[],"cpu"])}else{let Re=ey(ne),ge=new Re(fe);new Uint8Array(ge.buffer,ge.byteOffset,ge.byteLength).set(a.HEAPU8.subarray(L,L+ge.byteLength)),V.push([ne,he,ge,"cpu"])}}finally{a.stackRestore(X),ne==="string"&&L&&a._free(L),J||a._OrtReleaseTensor(K)}}p&&!A&&(a._OrtClearBoundOutputs(p.handle)!==0&&wn("Can't clear bound outputs."),Il.set(n,[c,d,h,p,A,!1]));for(let[W,K]of await Promise.all(B))V[W][2]=K;return qc("wasm ProcessOutputTensor"),V}finally{a.webnnOnRunEnd?.(c),a.stackRestore(M),b.forEach(Q=>a._OrtReleaseTensor(Q)),w.forEach(Q=>a._OrtReleaseTensor(Q)),I.forEach(Q=>a._free(Q)),g!==0&&a._OrtReleaseRunOptions(g),_.forEach(Q=>a._free(Q))}},yC=n=>{let e=kn(),t=Il.get(n);if(!t)throw new Error("invalid session id");let r=t[0],i=e._OrtEndProfiling(r);i===0&&wn("Can't get an profile file name."),e._OrtFree(i)},xC=n=>{let e=[];for(let t of n){let r=t[2];!Array.isArray(r)&&"buffer"in r&&e.push(r.buffer)}return e}}),Cl,es,Id,Xf,Jf,ig,q_,sg,Sc,Bc,HR,O4,$4,G4,V4,H4,j4,W4,q4=et(()=>{gs(),U4(),cu(),YI(),Cl=()=>!!Bn.wasm.proxy&&typeof document<"u",Id=!1,Xf=!1,Jf=!1,sg=new Map,Sc=(n,e)=>{let t=sg.get(n);t?t.push(e):sg.set(n,[e])},Bc=()=>{if(Id||!Xf||Jf||!es)throw new Error("worker not ready")},HR=n=>{switch(n.data.type){case"init-wasm":Id=!1,n.data.err?(Jf=!0,q_[1](n.data.err)):(Xf=!0,q_[0]()),ig&&(URL.revokeObjectURL(ig),ig=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=sg.get(n.data.type);n.data.err?e.shift()[1](n.data.err):e.shift()[0](n.data.out);break}}},O4=async()=>{if(!Xf){if(Id)throw new Error("multiple calls to 'initWasm()' detected.");if(Jf)throw new Error("previous call to 'initWasm()' failed.");if(Id=!0,Cl())return new Promise((n,e)=>{es?.terminate(),zP().then(([t,r])=>{try{es=r,es.onerror=s=>e(s),es.onmessage=HR,q_=[n,e];let i={type:"init-wasm",in:Bn};!i.in.wasm.wasmPaths&&(t||Bw)&&(i.in.wasm.wasmPaths={wasm:new URL("/assets/ort-wasm-simd-threaded.jsep-C887KxcQ.wasm",import.meta.url).href}),es.postMessage(i),ig=t}catch(i){e(i)}},e)});try{await XI(Bn.wasm),await fC(Bn),Xf=!0}catch(n){throw Jf=!0,n}finally{Id=!1}}},$4=async n=>{if(Cl())return Bc(),new Promise((e,t)=>{Sc("init-ep",[e,t]);let r={type:"init-ep",in:{epName:n,env:Bn}};es.postMessage(r)});await pC(Bn,n)},G4=async n=>Cl()?(Bc(),new Promise((e,t)=>{Sc("copy-from",[e,t]);let r={type:"copy-from",in:{buffer:n}};es.postMessage(r,[n.buffer])})):r0(n),V4=async(n,e)=>{if(Cl()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Bc(),new Promise((t,r)=>{Sc("create",[t,r]);let i={type:"create",in:{model:n,options:{...e}}},s=[];n instanceof Uint8Array&&s.push(n.buffer),es.postMessage(i,s)})}else return AC(n,e)},H4=async n=>{if(Cl())return Bc(),new Promise((e,t)=>{Sc("release",[e,t]);let r={type:"release",in:n};es.postMessage(r)});mC(n)},j4=async(n,e,t,r,i,s)=>{if(Cl()){if(t.some(a=>a[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(i.some(a=>a))throw new Error("pre-allocated output tensor is not supported for proxy.");return Bc(),new Promise((a,o)=>{Sc("run",[a,o]);let l=t,c={type:"run",in:{sessionId:n,inputIndices:e,inputs:l,outputIndices:r,options:s}};es.postMessage(c,xC(l))})}else return gC(n,e,t,r,i,s)},W4=async n=>{if(Cl())return Bc(),new Promise((e,t)=>{Sc("end-profiling",[e,t]);let r={type:"end-profiling",in:n};es.postMessage(r)});yC(n)}}),Y_,jR,Y4,Hte=et(()=>{gs(),q4(),Lt(),qI(),GP(),Y_=(n,e)=>{switch(n.location){case"cpu":return[n.type,n.dims,n.data,"cpu"];case"gpu-buffer":return[n.type,n.dims,{gpuBuffer:n.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[n.type,n.dims,{mlTensor:n.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${n.location} for ${e()}`)}},jR=n=>{switch(n[3]){case"cpu":return new ei(n[0],n[2],n[1]);case"gpu-buffer":{let e=n[0];if(!KI(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:t,download:r,dispose:i}=n[2];return ei.fromGpuBuffer(t,{dataType:e,dims:n[1],download:r,dispose:i})}case"ml-tensor":{let e=n[0];if(!ZI(e))throw new Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:t,download:r,dispose:i}=n[2];return ei.fromMLTensor(t,{dataType:e,dims:n[1],download:r,dispose:i})}default:throw new Error(`invalid data location: ${n[3]}`)}},Y4=class{async fetchModelAndCopyToWasmMemory(n){return G4(await eC(n))}async loadModel(n,e){Pa();let t;typeof n=="string"?t=await this.fetchModelAndCopyToWasmMemory(n):t=n,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await V4(t,e),Js()}async dispose(){return H4(this.sessionId)}async run(n,e,t){Pa();let r=[],i=[];Object.entries(n).forEach(h=>{let p=h[0],A=h[1],y=this.inputNames.indexOf(p);if(y===-1)throw new Error(`invalid input '${p}'`);r.push(A),i.push(y)});let s=[],a=[];Object.entries(e).forEach(h=>{let p=h[0],A=h[1],y=this.outputNames.indexOf(p);if(y===-1)throw new Error(`invalid output '${p}'`);s.push(A),a.push(y)});let o=r.map((h,p)=>Y_(h,()=>`input "${this.inputNames[i[p]]}"`)),l=s.map((h,p)=>h?Y_(h,()=>`output "${this.outputNames[a[p]]}"`):null),c=await j4(this.sessionId,i,o,a,l,t),d={};for(let h=0;h<c.length;h++)d[this.outputNames[a[h]]]=s[h]??jR(c[h]);return Js(),d}startProfiling(){}endProfiling(){W4(this.sessionId)}}}),X4={};_h(X4,{OnnxruntimeWebAssemblyBackend:()=>Gw,initializeFlags:()=>$w,wasmBackend:()=>J4});var $w,Gw,J4,jte=et(()=>{gs(),q4(),Hte(),$w=()=>{(typeof Bn.wasm.initTimeout!="number"||Bn.wasm.initTimeout<0)&&(Bn.wasm.initTimeout=0);let n=Bn.wasm.simd;if(typeof n!="boolean"&&n!==void 0&&n!=="fixed"&&n!=="relaxed"&&(Bn.wasm.simd=!1),typeof Bn.wasm.proxy!="boolean"&&(Bn.wasm.proxy=!1),typeof Bn.wasm.trace!="boolean"&&(Bn.wasm.trace=!1),typeof Bn.wasm.numThreads!="number"||!Number.isInteger(Bn.wasm.numThreads)||Bn.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)Bn.wasm.numThreads=1;else{let e=typeof navigator>"u"?Tee("node:os").cpus().length:navigator.hardwareConcurrency;Bn.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},Gw=class{async init(n){$w(),await O4(),await $4(n)}async createInferenceSessionHandler(n,e){let t=new Y4;return await t.loadModel(n,e),t}},J4=new Gw});gs();gs();gs();var Wte="1.24.3";{let n=(jte(),Lp(X4)).wasmBackend;Td("webgpu",n,5),Td("webnn",n,5),Td("cpu",n,10),Td("wasm",n,10)}Object.defineProperty(Bn.versions,"web",{value:Wte,enumerable:!0});class qte{constructor(e,t){this.runner=e,this.config=t}}class WR extends qte{constructor(e,t){super(e,t),this.store=new pP,this.cachedSize=null,this.graph=t.graph,this.params=t.params??{}}get size(){return this.cachedSize??this.inferSize()}reset(e){this.store.reset()}compute(e){const t=AP(this.graph,{runner:this.runner,state:e,params:this.params},this.store);if(t instanceof Float32Array)return this.cachedSize=t.length,t;if(typeof t=="number")return this.cachedSize=1,new Float32Array([t]);if(typeof t=="boolean")return this.cachedSize=1,new Float32Array([t?1:0]);if(t instanceof Uint8Array){this.cachedSize=t.length;const r=new Float32Array(t.length);for(let i=0;i<t.length;i++)r[i]=t[i];return r}return this.cachedSize=0,new Float32Array(0)}inferSize(){this.runner.getContext();const e={jointPos:new Float32Array(this.runner.getNumActions())};return this.compute(e),this.cachedSize??0}}class Yte{constructor(e,t={}){this.config=e,this.options=t,this.policyModule=null,this.obsGroups={},this.obsLayouts={},this.obsSizes={},this.historyConfig={},this.historyBuffers={},this.defaultObsKey=null,this.context=null,this.policyJointNames=(e.policy_joint_names??[]).slice(),this.numActions=e.policy_num_actions??this.policyJointNames.length,this.lastActions=new Float32Array(this.numActions),this.defaultJointPos=this.normalizeArray(e.default_joint_pos??[],this.numActions,0),this.encoderBias=this.normalizeArray(e.encoder_bias??[],this.numActions,0)}async init(e){this.context=e,this.policyModule=await this.buildPolicyModule(e),this.buildObservationGroups()}reset(e){this.lastActions.fill(0),this.policyModule?.reset();for(const t of Object.values(this.obsGroups))for(const r of t)r.reset&&r.reset(e);if(e){for(const[t,r]of Object.entries(this.historyConfig))if(r.steps>1){const i=this.buildFrame(this.obsGroups[t]??[],e),s=this.historyBuffers[t];for(let a=0;a<r.steps;a++)s.set(i,a*i.length)}}}update(e){this.policyModule?.update();for(const t of Object.values(this.obsGroups))for(const r of t)r.update&&r.update(e)}collectObservationsByKey(e){this.update(e);const t={};for(const[r,i]of Object.entries(this.obsGroups)){const s=this.historyConfig[r];if(s&&s.steps>1){const a=this.buildFrame(i,e),o=this.historyBuffers[r];for(let l=o.length-1;l>=a.length;l--)o[l]=o[l-a.length];o.set(a,0),t[r]=new Float32Array(o)}else t[r]=this.buildFrame(i,e)}return t}collectObservations(e){const t=this.collectObservationsByKey(e);if(this.defaultObsKey&&t[this.defaultObsKey])return t[this.defaultObsKey];const r=Object.keys(t)[0];return r?t[r]:new Float32Array(0)}async preloadAll(){const e=[];for(const t of Object.values(this.obsGroups))for(const r of t)typeof r.preload=="function"&&e.push(r.preload());await Promise.all(e)}getObservationSize(){if(this.defaultObsKey&&this.obsSizes[this.defaultObsKey]!==void 0)return this.obsSizes[this.defaultObsKey];const e=Object.keys(this.obsSizes)[0];return e?this.obsSizes[e]:0}getObservationLayout(){if(this.defaultObsKey&&this.obsLayouts[this.defaultObsKey])return this.obsLayouts[this.defaultObsKey].map(t=>({...t}));const e=Object.keys(this.obsLayouts)[0];return e?this.obsLayouts[e].map(t=>({...t})):[]}getPolicyModuleContext(){return this.policyModule?.getContext()??{}}getPolicyModule(){return this.policyModule}getContext(){return this.context}getPolicyJointNames(){return this.policyJointNames.slice()}getNumActions(){return this.numActions}getDefaultJointPos(){return new Float32Array(this.defaultJointPos)}getEncoderBias(){return new Float32Array(this.encoderBias)}getLastActions(){return new Float32Array(this.lastActions)}getConfig(){return this.config}setLastActions(e){if(e.length!==this.lastActions.length){this.lastActions=new Float32Array(e);return}this.lastActions.set(e)}async buildPolicyModule(e){const t=this.options.policyModules??{},r=this.config.policy_module,i=r?t[r]:t.default;if(r&&!i)throw new Error(`Unknown policy module: ${r}`);if(!i)return null;const s=new i(this.config);return await s.init(e),s}buildObservationGroups(){const e=this.options.observations??{},t=this.config.observations??{};this.obsGroups={},this.obsLayouts={},this.obsSizes={},this.historyConfig={},this.historyBuffers={},this.defaultObsKey=null;const r=i=>{const s=i;if(s.kind==="observation"&&Array.isArray(s.nodes))return new WR(this,{name:"DslObservation",graph:{kind:"observation",nodes:s.nodes,output:s.output??""},params:s.params});const a=e[i.name];if(!a)throw new Error(`Unknown observation type: ${i.name}`);return new a(this,i)};for(const[i,s]of Object.entries(t)){if(Array.isArray(s)){const a=s.map(r);this.registerGroup(i,a,s);continue}if(s&&typeof s=="object"){const a=s;if(Array.isArray(a.components)){const o=a.components.map(d=>{const h=d;if(h.kind==="observation"&&Array.isArray(h.nodes))return new WR(this,{name:"DslObservation",graph:{kind:"observation",nodes:h.nodes,output:h.output??""},params:h.params});const p=e[d.name];if(!p)throw new Error(`Unknown observation type: ${d.name}`);const A={...d,history_steps:1};return new p(this,A)}),l=Math.max(1,Math.floor(a.history_steps??1)),c=!!a.interleaved;this.registerGroup(i,o,a.components,{steps:l,interleaved:c})}}}this.obsGroups.policy?this.defaultObsKey="policy":this.obsGroups.observation?this.defaultObsKey="observation":this.obsGroups.obs_history?this.defaultObsKey="obs_history":this.defaultObsKey=Object.keys(this.obsGroups)[0]??null}registerGroup(e,t,r,i){this.obsGroups[e]=t,this.obsLayouts[e]=t.map((a,o)=>({name:r[o]?.name??`obs_${o}`,size:a.size}));const s=this.obsLayouts[e].reduce((a,o)=>a+o.size,0);i&&i.steps>1?(this.historyConfig[e]=i,this.historyBuffers[e]=new Float32Array(s*i.steps),this.obsSizes[e]=s*i.steps):this.obsSizes[e]=s}buildFrame(e,t){const r=e.reduce((a,o)=>a+o.size,0),i=new Float32Array(r);let s=0;for(const a of e){const o=a.compute(t),l=o instanceof Float32Array?o:Float32Array.from(o);if(l.length!==a.size)throw new Error(`Observation size mismatch: expected ${a.size}, got ${l.length}`);i.set(l,s),s+=l.length}return i}normalizeArray(e,t,r){const i=new Float32Array(t);for(let s=0;s<t;s++)i[s]=typeof e[s]=="number"?e[s]:r;return i}}Bn.wasm.proxy=!1;Bn.wasm.numThreads=1;typeof __ORT_CDN_BASE__<"u"&&(Bn.wasm.wasmPaths=__ORT_CDN_BASE__);class Xte{constructor(e){if(!e?.path)throw new Error("OnnxModule requires a path.");this.config=e,this.session=null;const t=e.meta?.in_keys??["policy"],r=e.meta?.out_keys??["action"];this.configuredInKeys=t.map(i=>Array.isArray(i)?i.join(","):i),this.inKeys=[...this.configuredInKeys],this.outKeys=r.map(i=>Array.isArray(i)?i.join(","):i),this.isRecurrent=this.inKeys.includes("adapt_hx")}async init(){const e=await fetch(this.config.path);if(!e.ok)throw new Error(`Failed to fetch ONNX model: ${e.status}`);const t=await e.arrayBuffer();this.session=await WI.create(t,{executionProviders:["wasm"],graphOptimizationLevel:"all"}),this.inferInputKeys(),this.isRecurrent=this.inKeys.includes("adapt_hx")}initInput(){const e={};return this.isRecurrent&&(e.is_init=new ei("bool",[!0],[1]),e.adapt_hx=new ei("float32",new Float32Array(128),[1,128])),this.inKeys.includes("time_step")&&(e.time_step=new ei("float32",new Float32Array([0]),[1,1])),e}async runInference(e){if(!this.session)throw new Error("OnnxModule not initialized.");const t={};for(let a=0;a<this.inKeys.length;a++){const o=this.inKeys[a],l=this.session.inputNames[a];if(!l||!e[o])throw new Error(`Missing ONNX input for key: ${o}`);t[l]=e[o]}const r=await this.session.run(t),i={};for(let a=0;a<this.outKeys.length;a++){const o=this.outKeys[a],l=this.session.outputNames[a];l&&r[l]&&(i[o]=r[l])}const s={};return this.isRecurrent&&i["next,adapt_hx"]&&(s.is_init=new ei("bool",[!1],[1]),s.adapt_hx=i["next,adapt_hx"]),[i,s]}inferInputKeys(){if(!this.session)return;const e=this.session.inputNames;if(e.length<=1){this.inKeys=[...this.configuredInKeys];return}if(this.configuredInKeys.length===e.length){this.inKeys=[...this.configuredInKeys];return}this.inKeys=e.map(t=>this.configuredInKeys.includes(t)?t:t==="obs"&&this.configuredInKeys.includes("policy")?"policy":t)}}class Jte{constructor(e,t,r,i){this.mujoco=e,this.mjModel=t,this.mjData=r;const s=this.getJointNames(t);this.qposAdr=[],this.qvelAdr=[],this.jointIndices=[],this.ctrlAdr=null;for(const a of i){const o=s.indexOf(a);if(o<0)throw new Error(`Joint "${a}" not found in MuJoCo model`);this.qposAdr.push(t.jnt_qposadr[o]),this.qvelAdr.push(t.jnt_dofadr[o]),this.jointIndices.push(o)}this.numActions=i.length,this.ctrlAdr=this.buildCtrlAdr()}build(){const e=this.mjData.qpos,t=this.mjData.qvel,r=new Float32Array(this.numActions),i=new Float32Array(this.numActions);for(let c=0;c<this.numActions;c++)r[c]=e[this.qposAdr[c]],i[c]=t[this.qvelAdr[c]];const s=new Float32Array([e[0],e[1],e[2]]),a=new Float32Array([e[3],e[4],e[5],e[6]]),o=new Float32Array([t[0],t[1],t[2]]),l=new Float32Array([t[3],t[4],t[5]]);return{jointPos:r,jointVel:i,rootPos:s,rootQuat:a,rootLinVel:o,rootAngVel:l}}getControlMapping(){return this.ctrlAdr?{ctrlAdr:this.ctrlAdr.slice(),qposAdr:this.qposAdr.slice(),qvelAdr:this.qvelAdr.slice()}:null}getControlMappingFor(e,t){if(!this.ctrlAdr)return null;const r=e.map(c=>new RegExp(`^(?:${c})$`)),i=c=>r.some(d=>d.test(c)),s=[],a=[],o=[],l=[];for(let c=0;c<t.length;c++)i(t[c])&&(s.push(this.ctrlAdr[c]),a.push(this.qposAdr[c]),o.push(this.qvelAdr[c]),l.push(c));return s.length===0?null:{ctrlAdr:s,qposAdr:a,qvelAdr:o,actionIndices:l}}getCtrlMappingByActuatorNames(e){const t=this.getActuatorNames(this.mjModel),r=e.map(o=>new RegExp(`^(?:${o})$`)),i=o=>r.some(l=>l.test(o)),s=[],a=[];for(let o=0;o<t.length;o++)i(t[o])&&(s.push(o),a.push(s.length-1));return s.length>0?{ctrlAdr:s,actionIndices:a}:null}getActuatorNames(e){const t=new Uint8Array(e.names),r=new TextDecoder,i=[];for(let s=0;s<e.nu;s++){let a=e.name_actuatoradr[s],o=a;for(;o<t.length&&t[o]!==0;)o++;i.push(r.decode(t.subarray(a,o)))}return i}buildCtrlAdr(){if(this.mjModel.nu<=0)return null;const e=this.mujoco.mjtTrn?.mjTRN_JOINT?.value,t=[];for(let i=0;i<this.mjModel.nu;i++){const s=this.mjModel.actuator_trntype[i];e===void 0||s===e?t.push(this.mjModel.actuator_trnid[2*i]):t.push(-1)}const r=[];for(const i of this.jointIndices){const s=t.findIndex(a=>a===i);if(s<0)return null;r.push(s)}return r}getJointNames(e){const t=new Uint8Array(e.names),r=new TextDecoder,i=[];for(let s=0;s<e.njnt;s++){let a=e.name_jntadr[s],o=a;for(;o<t.length&&t[o]!==0;)o++;let l=r.decode(t.subarray(a,o));!l&&s===0&&(l="floating_base_joint"),i.push(l)}return i}}class K4{constructor(e){this.config=e,this.context=null}init(e){this.context=e}reset(){}update(){}getContext(){return{}}}class Kte{constructor(e){this.policyJointNames=(e.policy_joint_names??[]).slice(),this.datasetJointNames=(e.dataset_joint_names??[]).slice(),this.nJoints=this.datasetJointNames.length||this.policyJointNames.length||0,this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refIdx=0,this.refLen=0,this.currentName="default",this.currentDone=!0}reset(e){const t=e?.jointPos??new Float32Array(this.nJoints),r=e?.rootPos??new Float32Array([0,0,0]),i=e?.rootQuat??new Float32Array([1,0,0,0]);this.refJointPos=[Float32Array.from(t)],this.refRootPos=[Float32Array.from(r)],this.refRootQuat=[Float32Array.from(i)],this.refIdx=0,this.refLen=1,this.currentDone=!0,this.currentName="default"}advance(){this.refLen<=1||this.refIdx<this.refLen-1&&(this.refIdx+=1,this.refIdx===this.refLen-1&&(this.currentDone=!0))}isReady(){return this.refLen>0}}class Zte extends K4{constructor(e){super(e),this.tracking=null}async init(e){await super.init(e);const t=this.config.policy_joint_names??[],r={...this.config.tracking,policy_joint_names:t};this.tracking=new Kte(r)}reset(e){this.tracking?.reset(e)}update(){this.tracking?.advance()}getContext(){return{tracking:this.tracking}}}class ene{constructor(e){this.policyJointNames=(e.policy_joint_names??[]).slice(),this.datasetJointNames=(e.dataset_joint_names??[]).slice(),this.nJoints=this.datasetJointNames.length||this.policyJointNames.length||0,this.refJointPos=[],this.refRootPos=[],this.refRootQuat=[],this.refIdx=0,this.refLen=0,this.currentName="default",this.currentDone=!0}reset(e){const t=e?.jointPos??new Float32Array(this.nJoints),r=e?.rootPos??new Float32Array([0,0,0]),i=e?.rootQuat??new Float32Array([1,0,0,0]);this.refJointPos=[Float32Array.from(t)],this.refRootPos=[Float32Array.from(r)],this.refRootQuat=[Float32Array.from(i)],this.refIdx=0,this.refLen=1,this.currentDone=!0,this.currentName="default"}advance(){this.refLen<=1||this.refIdx<this.refLen-1&&(this.refIdx+=1,this.refIdx===this.refLen-1&&(this.currentDone=!0))}isReady(){return this.refLen>0}}class tne extends K4{constructor(e){super(e),this.locomotion=null}async init(e){await super.init(e);const t=this.config.policy_joint_names??[],r={...this.config.tracking,policy_joint_names:t};this.locomotion=new ene(r)}reset(e){this.locomotion?.reset(e)}update(){this.locomotion?.advance()}getContext(){return{tracking:this.locomotion}}}class nne{constructor(e){this.config=e}}function Cd(n,e){return n+Math.random()*(e-n)}function rne(n){const e=new Uint8Array(n.names),t=new TextDecoder,r=[];for(let i=0;i<n.njnt;i++){let s=n.name_jntadr[i],a=s;for(;a<e.length&&e[a]!==0;)a++;r.push(t.decode(e.subarray(s,a)))}return r}function qR(n){for(let e=0;e<n.njnt;e++)if(n.jnt_type[e]===0)return e;return-1}class ine extends nne{constructor(e){super(e),this.mutations=e.mutations??[]}onReset(e){const{mjModel:t,mjData:r}=e;if(!(!t||!r))for(const i of this.mutations)switch(i.target){case"joint_qpos":this.applyJointOffset(t,r,i,"qpos");break;case"joint_qvel":this.applyJointOffset(t,r,i,"qvel");break;case"freejoint_pos":this.applyFreejointPos(t,r,i);break;case"freejoint_yaw":this.applyFreejointYaw(t,r,i);break}}resolveJointIndices(e,t){const r=t.select??{};if(r.joint_ids&&r.joint_ids.length>0)return r.joint_ids.filter(s=>s>=0&&s<e.njnt);const i=rne(e);return r.joint_names&&r.joint_names.length>0?r.joint_names.map(s=>this.findJointIndex(i,s,r.entity_name)).filter(s=>s!==null):i.map((s,a)=>({name:s,idx:a})).filter(({name:s,idx:a})=>e.jnt_type[a]===0?!1:r.entity_name?s===r.entity_name||s.startsWith(`${r.entity_name}/`):!0).map(({idx:s})=>s)}findJointIndex(e,t,r){const i=e.indexOf(t);if(i>=0)return i;if(r){const a=e.indexOf(`${r}/${t}`);if(a>=0)return a}const s=e.map((a,o)=>({name:a,idx:o})).filter(({name:a})=>a===t||a.endsWith(`/${t}`));if(s.length===1)return s[0].idx;if(r){const a=s.find(({name:o})=>o===r||o.startsWith(`${r}/`));if(a)return a.idx}return null}applyJointOffset(e,t,r,i){if(r.sample.dist!=="uniform")return;const{low:s,high:a}=r.sample;for(const o of this.resolveJointIndices(e,r)){const l=e.jnt_type[o];if(!(l!==2&&l!==3))if(i==="qpos"){const c=e.jnt_qposadr[o];if(t.qpos[c]+=Cd(s,a),r.clip_to_limits&&e.jnt_limited[o]){const d=e.jnt_range[o*2],h=e.jnt_range[o*2+1];t.qpos[c]=Math.min(Math.max(t.qpos[c],d),h)}}else t.qvel[e.jnt_dofadr[o]]+=Cd(s,a)}}applyFreejointPos(e,t,r){if(r.sample.dist!=="uniform_xyz")return;const i=qR(e);if(i<0)return;const s=e.jnt_qposadr[i];t.qpos[s]+=Cd(r.sample.x[0],r.sample.x[1]),t.qpos[s+1]+=Cd(r.sample.y[0],r.sample.y[1]),t.qpos[s+2]+=Cd(r.sample.z[0],r.sample.z[1])}applyFreejointYaw(e,t,r){if(r.sample.dist!=="uniform")return;const i=qR(e);if(i<0)return;const s=e.jnt_qposadr[i]+3,a=Cd(r.sample.low,r.sample.high),o=Math.cos(a/2),l=Math.sin(a/2),c=t.qpos[s],d=t.qpos[s+1],h=t.qpos[s+2],p=t.qpos[s+3];t.qpos[s]=o*c-l*p,t.qpos[s+1]=o*d+l*h,t.qpos[s+2]=o*h-l*d,t.qpos[s+3]=o*p+l*c}}function sne(n){return"kind"in n&&n.kind==="event"&&Array.isArray(n.mutations)}class ane{constructor(e,t){this.terms=[];for(const r of e){if(sne(r)){this.terms.push(new ine(r));continue}const i=t[r.name];i&&this.terms.push(new i(r))}}onReset(e){for(const t of this.terms)t.onReset(e)}get size(){return this.terms.length}}const one={},lne={...one};function ag(n){return typeof n=="object"&&n!==null&&typeof n.setSelectedMotion=="function"}class Z4 extends Error{constructor(){super("This scene cannot be loaded because it exceeds the browser's WebAssembly 2 GB memory limit. Try closing other browser tabs or reloading the page to free memory."),this.name="WasmMemoryLimitError"}}function YR(n){const e=n instanceof Error?n.message:String(n);return e.includes("MjModel loading returned null")||e.includes("Could not allocate memory")||e.includes("memory allocation failed")||e.includes("bad_alloc")}class cne{constructor(e,t,r={}){this.render=()=>{if(Lr().updateDebugVisuals(),this.mjData&&GZ(this.mjData,this.camera,this.controls,this.cameraState),this.controls.update(),this.mjModel&&this.mjData&&this.bodies){L3(this.camera,this.lights);for(const[o,l]of this.lastSimState.bodies){const c=this.bodies[o];c&&(c.position.copy(l.position),c.quaternion.copy(l.quaternion))}P3(this.mujoco,this.mjData,this.lights),this.mujocoRoot&&this.mujocoRoot.cylinders&&fX({cylinders:this.mujocoRoot.cylinders,spheres:this.mujocoRoot.spheres},this.lastSimState.tendons)}this.renderer.render(this.scene,this.camera)},this.onWindowResize=()=>{const{width:o,height:l}=this.getSize();this.camera.aspect=o/l,this.camera.updateProjectionMatrix(),this.renderer.setSize(o,l)},this.mujoco=e,this.container=t,this.baseUrl=r.baseUrl||"/";const i="/working";try{this.mujoco.FS.mkdir(i)}catch(o){o&&typeof o=="object"&&"code"in o&&o.code}try{this.mujoco.FS.mount(this.mujoco.MEMFS,{root:"."},i)}catch(o){o&&typeof o=="object"&&"code"in o&&o.code!=="EEXIST"&&o.code}const{width:s,height:a}=this.getSize();this.scene=new a9,this.scene.name="scene",this.camera=new Fr(45,s/a,.001,1e3),this.camera.name="PerspectiveCamera",this.camera.position.set(2,1.7,1.7),this.scene.add(this.camera),this.renderer=new U7({antialias:!0}),this.renderer.xr.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(s,a),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=LN,this.renderer.outputColorSpace=ri,this.renderer.toneMapping=FN,this.renderer.toneMappingExposure=1,this.container.appendChild(this.renderer.domElement),this.vrButton=null,navigator.xr?.isSessionSupported("immersive-vr").then(o=>{o&&(this.vrButton=NI.createButton(this.renderer),document.body.appendChild(this.vrButton))}),this.controls=new $7(this.camera,this.renderer.domElement),this.controls.target.set(0,.2,0),this.controls.panSpeed=2,this.controls.zoomSpeed=1,this.controls.enableDamping=!0,this.controls.dampingFactor=.1,this.controls.screenSpacePanning=!0,this.controls.update(),this.renderer.setAnimationLoop(this.render),window.addEventListener("resize",this.onWindowResize),"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver(()=>this.onWindowResize()),this.resizeObserver.observe(this.container)):this.resizeObserver=null,this.lastSimState={bodies:new Map,tendons:pX()},this.dynamicBodyIds=null,this.mjModel=null,this.mjData=null,this.bodies=null,this.lights=[],this.mujocoRoot=null,this.loopPromise=null,this.running=!1,this.timestep=.001,this.decimation=1,this.policyCtrlDt=null,this.loadingScene=null,this.dragStateManager=null,this.dragForceScale=100,this.policyRunner=null,this.policyStateBuilder=null,this.policyConfigPath=null,this.initialQpos=null,this.initialQvel=null,this.policyControl=null,this.onnxModule=null,this.onnxInputDict=null,this.onnxInferencing=!1,this.onnxTimeStep=0,this.terminationManager=null,this.eventManager=null,this.terrainData=null,this.splatMesh=null,this.colliderMesh=null,this.cameraState={trackBodyId:null,prevBodyPos:null},this.sceneCacheManager=Cw.getInstance(this.mujoco),this.resourceTracker=new VZ,this.memoryMonitor=new HZ}async loadEnvironment(e,t=null,r=null,i=null,s=null,a=null){this.terrainData=a,s&&s.length>0?this.eventManager=new ane(s,lne):this.eventManager=null,await this.stop(),this.splatMesh&&(tB(this.splatMesh,this.scene),this.splatMesh=null),this.colliderMesh&&(lB(this.colliderMesh,this.scene),this.colliderMesh=null);const o=performance.now();if(this.initializeCommands(),this.sceneCacheManager.has(e)){await this.restoreFromCache(e);const l=performance.now()-o;this.memoryMonitor.logCacheOperation("hit",e,{elapsedMs:l})}else this.memoryMonitor.logCacheOperation("miss",e),await this.sceneCacheManager.prepareForNewScene(),this.mjModel=null,this.mjData=null,this.bodies=null,this.lights=[],this.mujocoRoot=null,this.dynamicBodyIds=null,this.resourceTracker.startTracking(this.mujoco),await wX(this.mujoco,e,this.baseUrl),await this.loadSceneWithOomRetry(e),await this.captureAndCacheResources(e);r&&(this.splatMesh=eB(r,this.scene),r.colliderUrl&&(this.colliderMesh=await oB(this.resolveAssetUrl(r.colliderUrl),this.scene))),await this.loadPolicyConfig(t),this.applyViewerConfig(i),this.running=!0,this.startLoop()}initializeCommands(){const e=Lr();e.clear(),e.setResetCallback(()=>this.resetSimulation())}initializeCommandsFromConfig(e,t){Lr().initialize(e,t)}resetSimulation(){if(this.resetSimulationState(),this.policyRunner&&this.policyStateBuilder){const e=this.policyStateBuilder.build();this.policyRunner.reset(e)}}async setSelectedMotion(e){const t=Lr().getTerm("motion");if(!ag(t))return!1;const r=await t.setSelectedMotion(e);return r&&this.resetSimulation(),r}getSelectedMotionName(){const e=Lr().getTerm("motion");return ag(e)?e.getSelectedMotionName?.()??null:null}setReferenceVisible(e){const t=Lr().getTerm("motion");!ag(t)||typeof t.setReferenceVisible!="function"||t.setReferenceVisible(e)}async loadScene(e){this.loadingScene&&await this.loadingScene,this.loadingScene=(async()=>{const t=this.scene.getObjectByName("MuJoCo Root");t&&this.scene.remove(t);const r={mjModel:this.mjModel,mjData:this.mjData,scene:this.scene};if([this.mjModel,this.mjData,this.bodies,this.lights]=await _X(this.mujoco,e,r),!this.mjModel||!this.mjData)throw new Error("Failed to load MuJoCo model.");this.mujocoRoot=this.scene.getObjectByName("MuJoCo Root"),this.mujoco.mj_forward(this.mjModel,this.mjData),P3(this.mujoco,this.mjData,this.lights),L3(this.camera,this.lights),this.dynamicBodyIds=this.computeDynamicBodyIds(this.mjModel),this.syncStaticBodiesFromData(),this.timestep=this.mjModel.opt.timestep||.001;const i=this.policyCtrlDt??.02;this.decimation=Math.max(1,Math.round(i/this.timestep)),this.lastSimState.bodies.clear(),this.updateCachedState(),this.dragStateManager?this.dragStateManager.setDraggableBodyIds(this.dynamicBodyIds):this.dragStateManager=new cB({scene:this.scene,renderer:this.renderer,camera:this.camera,container:this.container,controls:this.controls,draggableBodyIds:this.dynamicBodyIds}),this.loadingScene=null})(),await this.loadingScene}async loadSceneWithOomRetry(e){try{await this.loadScene(e)}catch(t){if(!YR(t))throw t;this.loadingScene=null,await this.sceneCacheManager.clear();try{await this.loadScene(e)}catch(r){throw this.loadingScene=null,YR(r)?new Z4:r}}}async startLoop(){return this.loopPromise?this.loopPromise:(this.running=!0,this.loopPromise=this.mainLoop(),this.loopPromise)}async setSplat(e){this.splatMesh&&(tB(this.splatMesh,this.scene),this.splatMesh=null),this.colliderMesh&&(lB(this.colliderMesh,this.scene),this.colliderMesh=null),e&&(this.splatMesh=eB(e,this.scene),e.colliderUrl&&(this.colliderMesh=await oB(this.resolveAssetUrl(e.colliderUrl),this.scene)))}calibrateSplat(e){this.splatMesh&&cP(this.splatMesh,e)}setSplatVisible(e){this.splatMesh&&(this.splatMesh.visible=e)}async stop(){this.running=!1;const e=this.loopPromise;e&&await e,this.loopPromise=null}async mainLoop(){for(;this.running;){const e=performance.now(),t=this.timestep*this.decimation;if(this.mjModel&&this.mjData){if(this.mujoco.mj_forward(this.mjModel,this.mjData),this.policyRunner&&this.policyStateBuilder){const s=this.policyStateBuilder.build(),a=this.policyRunner.collectObservationsByKey(s);await this.runOnnxInference(a)}if(this.executeSimulationSteps(),this.updateCachedState(),this.terminationManager&&this.policyStateBuilder){const s=this.policyStateBuilder.build();if(this.terminationManager.evaluate(s).done&&(this.resetSimulationState(),this.terminationManager.reset(),this.policyRunner)){const o=this.policyStateBuilder.build();this.policyRunner.reset(o)}}Lr().update(t),Lr().updateDebugVisuals()}const r=(performance.now()-e)/1e3,i=Math.max(0,t-r);i>0&&await new Promise(s=>setTimeout(s,i*1e3))}this.loopPromise=null}async loadPolicyConfig(e){const t=this.policyConfigPath;this.policyConfigPath=e,this.policyRunner=null,this.policyStateBuilder=null,this.policyControl=null,this.onnxModule=null,this.onnxInputDict=null,this.onnxInferencing=!1,this.onnxTimeStep=0,this.terminationManager=null;const r=Lr();if(r.clear(),r.setResetCallback(()=>this.resetSimulation()),!!e&&!(!this.mjModel||!this.mjData)){e!==t&&this.resetSimulationState();try{const{config:i}=await this.fetchPolicyConfig(e);if(Array.isArray(i.motions)&&(i.motions=i.motions.map(o=>({...o,path:this.resolveAssetUrl(this.resolvePolicyAssetPath(e,o.path))}))),i.commands?.motion&&Array.isArray(i.motions)&&(i.commands.motion={...i.commands.motion,motions:i.motions}),this.initialQpos=Array.isArray(i.initial_qpos)?i.initial_qpos:null,this.initialQvel=Array.isArray(i.initial_qvel)?i.initial_qvel:null,this.resetSimulationState(),this.mujoco.mj_forward(this.mjModel,this.mjData),this.updateCachedState(),i.commands&&typeof i.commands=="object"){this.initializeCommandsFromConfig(i.commands,{mujoco:this.mujoco,mjModel:this.mjModel,mjData:this.mjData,scene:this.scene,bodies:this.bodies,mujocoRoot:this.mujocoRoot,requestReset:()=>this.resetSimulation()}),Lr().resetTerms();const o=Lr().getTerm("motion");ag(o)&&(await o.setSelectedMotion(i.motions?.find(l=>l.default)?.name??i.motions?.[0]?.name??null),o.setReferenceVisible?.(!0)),this.mujoco.mj_forward(this.mjModel,this.mjData),this.updateCachedState()}if(!i.policy_num_actions&&(!i.policy_joint_names||i.policy_joint_names.length===0))throw new Error("Policy config missing policy_joint_names.");const s=new Yte(i,{policyModules:{tracking:Zte,locomotion:tne},observations:WZ});await s.init({mujoco:this.mujoco,mjModel:this.mjModel,mjData:this.mjData,scene:this.scene}),await s.preloadAll(),this.policyRunner=s,this.policyStateBuilder=new Jte(this.mujoco,this.mjModel,this.mjData,s.getPolicyJointNames());const a=this.policyStateBuilder.build();this.policyRunner.reset(a),this.policyControl=this.buildPolicyControl(i,s,this.policyStateBuilder);{const o=i.observations,l=[];if(Array.isArray(o))l.push(...o);else if(o&&typeof o=="object")for(const c of Object.values(o))Array.isArray(c)&&l.push(...c);for(const c of l)if(!(!c||this.timestep<=0)&&typeof c.fps=="number"&&c.fps>0){this.policyCtrlDt=1/c.fps;const d=Math.max(1,Math.round(this.policyCtrlDt/this.timestep));d!==this.decimation&&(this.decimation=d);break}}if(i.terminations&&Object.keys(i.terminations).length>0&&(this.terminationManager=new Eee(i.terminations,Cee,s)),i.onnx?.path){const o=this.resolvePolicyAssetPath(e,i.onnx.path),l=this.resolveAssetUrl(o),c={...i.onnx,path:l},d=new Xte(c);await d.init(),this.onnxModule=d,this.onnxInputDict=d.initInput()}}catch{}}}async fetchPolicyConfig(e){const t=this.resolveAssetUrl(e),r=await fetch(t,{cache:"no-store"});if(!r.ok)throw new Error(`Failed to fetch policy config: ${r.status}`);return{config:await r.json(),resolvedUrl:t}}resolveAssetUrl(e){if(/^[a-z]+:\/\//i.test(e))return e;const t=(this.baseUrl||"/").replace(/\/+$/,"/"),r=new URL(t,window.location.origin+"/").toString();return new URL(e.replace(/^\/+/,""),r).toString()}resolvePolicyAssetPath(e,t){const r=e.replace(/\\/g,"/"),i=r.lastIndexOf("/");return i>=0?`${r.slice(0,i+1)}${t}`.replace(/\/+/g,"/"):t}buildPolicyControl(e,t,r){const i=t.getPolicyJointNames(),s=this.mujoco.mjtBias?.mjBIAS_AFFINE?.value??1,a=(c,d,h,p,A,y,m,x)=>{const g=h.qposAdr.length,_=h.actionIndices.map(Q=>i[Q]),b=this.normalizeControlArray(p,g,1,_),w=this.normalizeControlArray(A,g,0,_),I=x?t.getDefaultJointPos():new Float32Array(i.length),S=new Float32Array(g);for(let Q=0;Q<g;Q++)S[Q]=I[h.actionIndices[Q]];const M=Array.isArray(e.encoder_bias)?Float32Array.from(e.encoder_bias):new Float32Array(i.length),T=new Float32Array(g);for(let Q=0;Q<g;Q++)T[Q]=M[h.actionIndices[Q]]??0;const R=this.normalizeControlArray(y,g,0,_),k=this.normalizeControlArray(m,g,0,_),H=h.ctrlAdr.map(Q=>Q<0||!this.mjModel?!1:this.mjModel.actuator_biastype[Q]===s);return H.some(Boolean),H.some(Q=>!Q),{controlType:d,ctrlAdr:h.ctrlAdr,qposAdr:h.qposAdr,qvelAdr:h.qvelAdr,actionIndices:h.actionIndices,actionScale:b,actionOffset:w,defaultJointPos:S,encoderBias:T,positionActuator:H,kp:R,kd:k,muscleNormalize:!1}},o=e.actions;if(!o||Object.keys(o).length===0){const c=e.control_type??"joint_position";if(c!=="joint_position"&&c!=="torque")return null;const d=r.getControlMapping();if(!d)return null;const h={...d,actionIndices:Array.from({length:d.qposAdr.length},(p,A)=>A)};return[a("legacy",c,h,e.action_scale,void 0,e.stiffness,e.damping,!0)]}const l=[];for(const[c,d]of Object.entries(o)){const h=d.type??"joint_position";if(h!=="joint_position"&&h!=="torque"&&h!=="muscle_activation")continue;const p=d.actuator_names??[".*"];if(h==="muscle_activation"){const x=r.getCtrlMappingByActuatorNames(p);if(!x)continue;const g=x.ctrlAdr.length,_=this.normalizeControlArray(d.scale,g,1),b=this.normalizeControlArray(d.offset,g,0),w=d.normalize??!0;l.push({controlType:h,ctrlAdr:x.ctrlAdr,qposAdr:[],qvelAdr:[],actionIndices:x.actionIndices,actionScale:_,actionOffset:b,defaultJointPos:new Float32Array(g),encoderBias:new Float32Array(g),positionActuator:new Array(g).fill(!1),kp:new Float32Array(g),kd:new Float32Array(g),muscleNormalize:w});continue}const A=p.length===1&&p[0]===".*";let y;if(A){const x=r.getControlMapping();if(!x)continue;y={...x,actionIndices:Array.from({length:x.qposAdr.length},(g,_)=>_)}}else if(y=r.getControlMappingFor(p,i),!y)continue;const m=d.use_default_offset!==void 0?d.use_default_offset:h==="joint_position";l.push(a(c,h,y,d.scale,d.offset,d.stiffness,d.damping,m))}return l.length===0?null:l}normalizeControlArray(e,t,r,i){const s=new Float32Array(t);if(s.fill(r),typeof e=="number")return s.fill(e),s;if(Array.isArray(e)){for(let a=0;a<t;a++)s[a]=typeof e[a]=="number"?e[a]:r;return s}if(e!==null&&typeof e=="object"&&i){for(const[a,o]of Object.entries(e)){const l=i.indexOf(a);l>=0&&l<t&&(s[l]=o)}return s}return s}resetSimulationState(){if(!(!this.mjModel||!this.mjData)){if(this.mjModel.nkey>0?this.mujoco.mj_resetDataKeyframe(this.mjModel,this.mjData,0):this.mujoco.mj_resetData(this.mjModel,this.mjData),this.initialQpos){const e=this.mjData.qpos;for(let t=0;t<Math.min(this.initialQpos.length,this.mjModel.nq);t++)e[t]=this.initialQpos[t]}if(this.initialQvel){const e=this.mjData.qvel;for(let t=0;t<Math.min(this.initialQvel.length,this.mjModel.nv);t++)e[t]=this.initialQvel[t]}this.eventManager&&this.eventManager.onReset({mjModel:this.mjModel,mjData:this.mjData,terrainData:this.terrainData}),Lr().resetTerms(),this.onnxModule&&(this.onnxInputDict=this.onnxModule.initInput()),this.onnxTimeStep=0,this.mujoco.mj_forward(this.mjModel,this.mjData),this.lastSimState.bodies.clear(),this.updateCachedState()}}executeSimulationSteps(){if(!(!this.mjModel||!this.mjData)){this.applyDragForces();for(let e=0;e<this.decimation;e++)this.applyPolicyControl(),this.mujoco.mj_step(this.mjModel,this.mjData)}}applyPolicyControl(){if(!this.policyControl||!this.mjData)return;const e=this.mjData.ctrl;e.fill(0);const t=this.policyRunner?.getLastActions()??new Float32Array(0);for(const r of this.policyControl){const{controlType:i,ctrlAdr:s,qposAdr:a,qvelAdr:o,actionIndices:l,actionScale:c,actionOffset:d,defaultJointPos:h,encoderBias:p,positionActuator:A,kp:y,kd:m,muscleNormalize:x}=r,g=s.length;if(i==="joint_position")for(let _=0;_<g;_++){const b=s[_];if(b<0)continue;const w=t[l[_]]??0,I=h[_]+d[_]+c[_]*w-p[_];if(A[_])e[b]=I;else{const S=this.mjData.qpos[a[_]],M=this.mjData.qvel[o[_]];e[b]=y[_]*(I-S)+m[_]*(0-M)}}else if(i==="torque")for(let _=0;_<g;_++){const b=s[_];b>=0&&(e[b]=c[_]*(t[l[_]]??0))}else if(i==="muscle_activation")for(let _=0;_<g;_++){const b=s[_];if(b<0)continue;const w=(t[l[_]]??0)*c[_]+d[_];x?e[b]=1/(1+Math.exp(-5*(w-.5))):e[b]=w<0?0:w>1?1:w}}}async runOnnxInference(e){if(!(!this.onnxModule||!this.policyRunner||this.onnxInferencing)){this.onnxInferencing=!0;try{this.onnxInputDict||(this.onnxInputDict=this.onnxModule.initInput());const t={...this.onnxInputDict};this.onnxModule.inKeys.includes("time_step")&&(t.time_step=new ei("float32",new Float32Array([this.onnxTimeStep]),[1,1]));for(const[d,h]of Object.entries(e))t[d]=new ei("float32",h,[1,h.length]);for(const d of this.onnxModule.inKeys)if(!t[d])return;const[r,i]=await this.onnxModule.runInference(t);Object.keys(i).length>0&&(this.onnxInputDict={...this.onnxInputDict,...i}),this.onnxModule.inKeys.includes("time_step")&&(this.onnxTimeStep+=1);const s=this.onnxModule.outKeys[0],a=r.action??(s?r[s]:null)??r.policy??null;if(!a)return;const o=a.data,l=ArrayBuffer.isView(o)?new Float32Array(o):Float32Array.from(o),c=this.policyRunner?.getNumActions()??0;if(this.policyControl&&l.length!==c)return;this.policyRunner.setLastActions(l)}catch{}finally{this.onnxInferencing=!1}}}applyDragForces(){if(!this.dragStateManager||!this.mjModel||!this.mjData||!this.bodies)return;for(let p=0;p<this.mjData.xfrc_applied.length;p++)this.mjData.xfrc_applied[p]=0;const e=this.dragStateManager.physicsObject;if(!e||!("bodyID"in e)||typeof e.bodyID!="number"||e.bodyID<=0)return;const t=e.bodyID;if(this.dynamicBodyIds&&!this.dynamicBodyIds.has(t))return;for(let p=0;p<this.mjModel.nbody;p++)this.bodies[p]&&(Ll(this.mjData.xpos,p,this.bodies[p].position),Fd(this.mjData.xquat,p,this.bodies[p].quaternion),this.bodies[p].updateWorldMatrix(!0,!1));this.dragStateManager.update();const r=this.dragStateManager.offset.clone().multiplyScalar(this.dragForceScale),i=Q3(r),s=this.dragStateManager.worldHit.clone(),a=Q3(s),o=new de(this.mjData.xpos[t*3+0],this.mjData.xpos[t*3+1],this.mjData.xpos[t*3+2]),l=new de(a.x-o.x,a.y-o.y,a.z-o.z),c=new de(i.x,i.y,i.z),d=new de().crossVectors(l,c),h=t*6;this.mjData.xfrc_applied[h+0]=i.x,this.mjData.xfrc_applied[h+1]=i.y,this.mjData.xfrc_applied[h+2]=i.z,this.mjData.xfrc_applied[h+3]=d.x,this.mjData.xfrc_applied[h+4]=d.y,this.mjData.xfrc_applied[h+5]=d.z}updateCachedState(){if(!this.mjModel||!this.mjData||!this.bodies)return;const e=this.dynamicBodyIds;for(let t=0;t<this.mjModel.nbody;t++)if(!(e&&!e.has(t))&&this.bodies[t]){this.lastSimState.bodies.has(t)||this.lastSimState.bodies.set(t,{position:new de,quaternion:new In});const r=this.lastSimState.bodies.get(t);Ll(this.mjData.xpos,t,r.position),Fd(this.mjData.xquat,t,r.quaternion)}this.mujocoRoot&&this.mujocoRoot.cylinders&&hX(this.mjModel,this.mjData,{cylinders:this.mujocoRoot.cylinders,spheres:this.mujocoRoot.spheres},this.lastSimState.tendons)}applyViewerConfig(e){this.cameraState=$Z(e,this.camera,this.controls,this.mjModel,this.mjData)}computeDynamicBodyIds(e){const t=new Set;for(let r=1;r<e.nbody;r++){let i=r;for(;i>0;){if(e.body_jntnum[i]>0){t.add(r);break}i=e.body_parentid[i]}}return t}syncStaticBodiesFromData(){if(!this.mjModel||!this.mjData||!this.bodies)return;const e=this.dynamicBodyIds;for(let t=0;t<this.mjModel.nbody;t++){if(e?.has(t))continue;const r=this.bodies[t];r&&(Ll(this.mjData.xpos,t,r.position),Fd(this.mjData.xquat,t,r.quaternion))}}dispose(){this.stop(),this.policyRunner=null,this.policyStateBuilder=null,this.policyConfigPath=null,this.dragStateManager&&(this.dragStateManager.dispose(),this.dragStateManager=null),this.mjData=null,this.mjModel=null,window.removeEventListener("resize",this.onWindowResize),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.controls.dispose(),this.renderer.setAnimationLoop(null),this.renderer.dispose(),this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.vrButton?.parentElement&&(this.vrButton.parentElement.removeChild(this.vrButton),this.vrButton=null),this.bodies=null,this.lights=[],this.mujocoRoot=null,this.dynamicBodyIds=null,this.lastSimState.bodies.clear()}disposeThreeJSResources(){if(this.scene)for(this.scene.traverse(e=>{"geometry"in e&&e.geometry&&e.geometry.dispose(),"material"in e&&e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material))});this.scene.children.length>0;)this.scene.remove(this.scene.children[0])}disposeMaterial(e){const t=e;t.map&&t.map.dispose(),t.aoMap&&t.aoMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),e.dispose()}getSize(){const e=this.container.clientWidth||window.innerWidth,t=this.container.clientHeight||window.innerHeight;return{width:Math.max(1,e),height:Math.max(1,t)}}async restoreFromCache(e){const t=this.sceneCacheManager.get(e);if(!t)throw new Error(`Scene ${e} not found in cache`);const r=this.scene.getObjectByName("MuJoCo Root");r&&this.scene.remove(r),this.mjModel=t.mjModel,this.mjData=t.mjData,this.bodies=t.bodies,this.lights=t.lights,this.mujocoRoot=t.mujocoRoot,this.scene.add(this.mujocoRoot),this.scene.background=t.skybox,this.mujoco.mj_forward(this.mjModel,this.mjData),this.dynamicBodyIds=this.computeDynamicBodyIds(this.mjModel),this.syncStaticBodiesFromData(),this.timestep=this.mjModel.opt.timestep||.001;const i=this.policyCtrlDt??.02;this.decimation=Math.max(1,Math.round(i/this.timestep)),this.lastSimState.bodies.clear(),this.updateCachedState(),this.dragStateManager?this.dragStateManager.setDraggableBodyIds(this.dynamicBodyIds):this.dragStateManager=new cB({scene:this.scene,renderer:this.renderer,camera:this.camera,container:this.container,controls:this.controls,draggableBodyIds:this.dynamicBodyIds})}async captureAndCacheResources(e){const t=this.resourceTracker.stopTracking(this.mujoco);if(!this.mjModel||!this.mjData||!this.bodies||!this.mujocoRoot)return;const r=this.resourceTracker.estimateSceneMemory({mjModel:this.mjModel,mjData:this.mjData,bodies:this.bodies,meshes:{},mujocoRoot:this.mujocoRoot});await this.sceneCacheManager.set(e,{scenePath:e,lastAccessed:Date.now(),loadedAt:Date.now(),mjModel:this.mjModel,mjData:this.mjData,bodies:this.bodies,lights:this.lights,meshes:{},mujocoRoot:this.mujocoRoot,skybox:this.scene.background instanceof mh?this.scene.background:null,fsFiles:t,estimatedMemoryBytes:r});const i=this.sceneCacheManager.getMetrics();this.memoryMonitor.logCacheOperation("load",e,{memoryMB:r/1048576,totalScenes:i.totalScenes,totalMemoryMB:i.totalMemoryBytes/1048576})}}const og="mjswan_oom_reload_scene",une=({scenePath:n,baseUrl:e,policyConfigPath:t,splatConfig:r,cameraConfig:i,eventsConfig:s,terrainData:a,selectedMotion:o,showReferenceMotion:l=!0,onStatusChange:c,onError:d,onReady:h,onRuntimeReady:p})=>{const A=U.useRef(null),y=U.useRef(null),m=U.useRef(null),x=U.useRef(r);x.current=r;const g=U.useRef(o);g.current=o;const _=U.useRef(l);return _.current=l,U.useEffect(()=>{let b=!1;const w=S=>{c?.(S)};return(async()=>{if(!m.current){w("Loading MuJoCo…");const T=await DV(()=>import("./mujoco-Da3xPlsY.js"),[]);m.current=await T.default()}if(b)return;const S=A.current;if(!S)throw new Error("Failed to find viewer container.");const M=m.current;if(!M)throw new Error("MuJoCo not loaded.");y.current||(y.current=new cne(M,S,{baseUrl:e}),p?.(y.current)),w("Loading scene…"),await y.current.loadEnvironment(n,t??null,x.current??null,i??null,s??null,a??null),await y.current.setSelectedMotion(g.current??null),y.current.setReferenceVisible(_.current),!b&&(sessionStorage.removeItem(og),w("Running simulation"),h?.())})().catch(S=>{if(!b){if(S instanceof Z4){if(sessionStorage.getItem(og)!==n){sessionStorage.setItem(og,n),window.location.reload();return}sessionStorage.removeItem(og)}d?.(S instanceof Error?S:new Error(String(S))),w("Failed to load scene")}}),()=>{b=!0,y.current?.dispose(),y.current=null}},[n,e,t,i,s,a,c,d,h]),U.useEffect(()=>{y.current?.setReferenceVisible(l)},[l]),j.jsx("div",{ref:A,className:"viewer"})};var dne={outline:{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"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};const ty=(n,e,t,r)=>{const i=U.forwardRef(({color:s="currentColor",size:a=24,stroke:o=2,title:l,className:c,children:d,...h},p)=>U.createElement("svg",{ref:p,...dne[n],width:a,height:a,className:["tabler-icon",`tabler-icon-${e}`,c].join(" "),strokeWidth:o,stroke:s,...h},[l&&U.createElement("title",{key:"svg-title"},l),...r.map(([A,y])=>U.createElement(A,y)),...Array.isArray(d)?d:[d]]));return i.displayName=`${t}`,i};const hne=[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]],ez=ty("outline","chevron-down","ChevronDown",hne);const fne=[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]],pne=ty("outline","chevron-up","ChevronUp",fne);const Ane=[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]],mne=ty("outline","refresh","Refresh",Ane);const gne=[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]],yne=ty("outline","x","X",gne),XR="0.7.0-beta.2",JR=[{login:"ttktjmt",html_url:"https://github.com/ttktjmt"},{login:"claude",html_url:"https://github.com/claude"},{login:"Axellwppr",html_url:"https://github.com/Axellwppr"},{login:"julien-blanchon",html_url:"https://github.com/julien-blanchon"},{login:"unmoyai",html_url:"https://github.com/unmoyai"},{login:"brentyi",html_url:"https://github.com/brentyi"},{login:"CharlieLeee",html_url:"https://github.com/CharlieLeee"}],xne={move:"touchmove",end:"touchend"},vne={move:"mousemove",end:"mouseup"};function _ne(n){return n.type==="touchmove"}function bne(n){return n.type==="mousemove"}const jp=On.createContext(null);function fo({children:n,width:e,visible:t=!0,onVisibleChange:r,hiddenButtonTooltip:i}){const s=On.useRef(null),[a,{toggle:o}]=o0(!0),[l,c]=On.useState(800),d=On.useRef({dragging:!1,startPosX:0,startPosY:0,startClientX:0,startClientY:0}),h=On.useRef({}),p=(x,g,_)=>Math.abs(x+g/2)<Math.abs(x-_+g/2)?x:x-_,A=15;function y(x,g){const _=s.current;if(_===null)return[x,g];const b=_.parentElement;if(b===null)return[x,g];let w=x,I=g;return w=Math.min(w,b.clientWidth-_.clientWidth-A),w=Math.max(w,A),I=Math.min(I,b.clientHeight-_.clientHeight-A),I=Math.max(I,A),_.style.top=`${I.toString()}px`,_.style.left=`${w.toString()}px`,[p(w,_.clientWidth,b.clientWidth),p(I,_.clientHeight,b.clientHeight)]}On.useEffect(()=>{const x=s.current;if(x===null)return;const g=x.parentElement;if(g===null)return;const _=new ResizeObserver(()=>{h.current.x===void 0&&(h.current.x=p(x.offsetLeft,x.clientWidth,g.clientWidth)),h.current.y===void 0&&(h.current.y=p(x.offsetTop,x.clientHeight,g.clientHeight));const b=g.clientHeight-A*2;l!==b&&c(b);let w=h.current.x,I=h.current.y;for(;w<0;)w+=g.clientWidth;for(;I<0;)I+=g.clientHeight;y(w,I)});return _.observe(x),_.observe(g),()=>{_.disconnect()}});const m=x=>{const g=d.current,_=s.current;if(!_)return;x.type=="touchstart"?(x=x,g.startClientX=x.touches[0].clientX,g.startClientY=x.touches[0].clientY):(x=x,g.startClientX=x.clientX,g.startClientY=x.clientY),g.startPosX=_.offsetLeft,g.startPosY=_.offsetTop;const b=x.type=="touchstart"?xne:vne;function w(I){let S=0,M=0;if(_ne(I)?(I=I,S=I.touches[0].clientX-g.startClientX,M=I.touches[0].clientY-g.startClientY):bne(I)&&(I=I,S=I.clientX-g.startClientX,M=I.clientY-g.startClientY),Math.abs(S)<=3&&Math.abs(M)<=3)return;g.dragging=!0;const T=g.startPosX+S,R=g.startPosY+M;[h.current.x,h.current.y]=y(T,R)}window.addEventListener(b.move,w),window.addEventListener(b.end,()=>{x.type=="touchstart"&&(g.dragging=!1),window.removeEventListener(b.move,w)},{once:!0})};if(!t){const x=j.jsx(Je,{component:"button","aria-label":i??"Show controls",onClick:()=>r?.(!0),style:{width:"0.85rem",height:"0.85rem",minWidth:"0.85rem",minHeight:"0.85rem",display:"block",padding:0,border:"none",borderRadius:"9999px",background:"rgba(255, 255, 255, 0.82)",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.18)",cursor:"pointer"}});return j.jsx(Je,{style:{zIndex:10,position:"absolute",top:"1em",right:"1em"},children:i?j.jsx(Ql,{label:i,children:j.jsx(Je,{children:x})}):x})}return j.jsx(jp.Provider,{value:{wrapperRef:s,expanded:a,width:e,maxHeight:l,toggleExpanded:o,dragHandler:m,dragInfo:d},children:j.jsx(Xc,{radius:"xs",shadow:"0.1em 0 1em 0 rgba(0,0,0,0.1)",style:{boxSizing:"border-box",width:e,zIndex:10,position:"absolute",top:"1em",right:"1em",margin:0,"& .expandIcon":{transform:"rotate(0)"},overflow:"hidden"},ref:s,children:n})})}fo.Handle=function({children:e}){const t=On.useContext(jp);return j.jsx(j.Fragment,{children:j.jsx(Je,{style:{borderRadius:"0.2em 0.2em 0 0",lineHeight:"1.5em",cursor:"pointer",position:"relative",fontWeight:400,userSelect:"none",display:"flex",alignItems:"center",padding:"0 0.75em",height:"2.75em"},onClick:()=>{const r=t.dragInfo.current;if(r.dragging){r.dragging=!1;return}t.toggleExpanded()},onTouchStart:r=>{t.dragHandler(r)},onMouseDown:r=>{t.dragHandler(r)},children:e})})};fo.Contents=function({children:e}){const t=On.useContext(jp);return j.jsxs(Tg,{in:t.expanded,children:[j.jsx(Nd,{mx:"xs"}),j.jsx(su.Autosize,{mah:t.maxHeight,children:j.jsx(Je,{style:{width:t.width},children:e})})]})};fo.HideWhenCollapsed=function({children:e}){return On.useContext(jp)?.expanded??!0?e:null};fo.HideWhenExpanded=function({children:e}){return On.useContext(jp)?.expanded??!0?null:e};function lg({id:n,label:e,children:t}){return j.jsx(Je,{pb:"0.5em",px:"xs",children:j.jsxs(SE,{align:"center",children:[j.jsx(Je,{pr:"xs",style:{width:"7.25em",flexShrink:0,position:"relative"},children:j.jsx(qs,{c:"dimmed",style:{fontSize:"0.875em",fontWeight:450,lineHeight:"1.375em",letterSpacing:"-0.75px",width:"100%",boxSizing:"content-box"},children:j.jsx("label",{htmlFor:n,children:e})})}),j.jsx(Je,{style:{flexGrow:1},children:t})]})})}function tz({label:n,expandByDefault:e=!0,children:t}){const[r,{toggle:i}]=o0(e),s=r?pne:ez;return j.jsxs(Xc,{withBorder:!0,style:{borderWidth:"1px",position:"relative",marginLeft:"var(--mantine-spacing-xs)",marginRight:"var(--mantine-spacing-xs)",marginTop:"var(--mantine-spacing-xs)",marginBottom:"var(--mantine-spacing-xs)",paddingBottom:"calc(var(--mantine-spacing-xs) - 0.5em)"},children:[j.jsxs(Xc,{onClick:i,style:{fontSize:"0.875em",position:"absolute",padding:"0 0.375em",top:0,left:"0.375em",transform:"translateY(-50%)",userSelect:"none",fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center"},children:[n,j.jsx(s,{style:{width:"0.9em",height:"0.9em",strokeWidth:3,top:"0.1em",position:"relative",marginLeft:"0.25em",marginRight:"-0.1em",opacity:.5}})]}),j.jsx(Tg,{in:r,children:j.jsx(Je,{pt:"1em",children:t})}),j.jsx(Tg,{in:!r,children:j.jsx(Je,{p:"xs"})})]})}const nz={fontSize:"0.875em",fontWeight:450,lineHeight:"1.375em",letterSpacing:"-0.75px",width:"4.5em",flexShrink:0},wne={root:{padding:"0"},track:{height:4},thumb:{width:12,height:12}},Ene={flex:1,minWidth:0,height:"1.75em",fontSize:"0.8em",fontFamily:"inherit",border:"1px solid var(--mantine-color-default-border)",borderRadius:"var(--mantine-radius-sm)",background:"var(--mantine-color-default)",color:"var(--mantine-color-text)",textAlign:"right",padding:"0 0.4em",outline:"none",cursor:"ns-resize",touchAction:"none"};function X_({axis:n,value:e,min:t=-1/0,max:r=1/0,step:i,onChange:s}){const a=U.useRef(null),o=U.useRef(null);U.useEffect(()=>{const y=a.current;y&&document.activeElement!==y&&(y.value=e.toFixed(2))},[e]);const l=y=>Math.max(t,Math.min(r,parseFloat((Math.round(y/i)*i).toFixed(10)))),c=y=>{y.preventDefault(),y.currentTarget.setPointerCapture(y.pointerId),o.current={startY:y.clientY,startValue:e,moved:!1}},d=y=>{if(!o.current||!(y.buttons&1))return;const m=o.current.startY-y.clientY;if(Math.abs(m)>3&&(o.current.moved=!0),!o.current.moved)return;const x=l(o.current.startValue+m*i);s(x),a.current&&(a.current.value=x.toFixed(2))},h=()=>{if(o.current&&!o.current.moved){const y=a.current;y&&(y.focus(),y.select())}o.current=null},p=y=>{const m=parseFloat(y.target.value);isNaN(m)||s(l(m)),y.target.value=e.toFixed(2)},A=y=>{y.key==="Enter"&&y.currentTarget.blur(),y.key==="Escape"&&(a.current&&(a.current.value=e.toFixed(2)),a.current?.blur())};return j.jsxs(Je,{style:{display:"flex",alignItems:"center",gap:"0.25em",flex:1},children:[j.jsx(qs,{c:"dimmed",style:{fontSize:"0.875em",fontWeight:450,letterSpacing:"-0.75px",flexShrink:0},children:n}),j.jsx("input",{ref:a,size:1,defaultValue:e.toFixed(2),onPointerDown:c,onPointerMove:d,onPointerUp:h,onBlur:p,onKeyDown:A,onFocus:y=>y.currentTarget.style.outline="2px solid var(--mantine-color-blue-5)",onBlurCapture:y=>y.currentTarget.style.outline="none",style:Ene})]})}function KR({label:n,x:e,y:t,z:r,step:i,xLabel:s="X",yLabel:a="Y",zLabel:o="Z",onX:l,onY:c,onZ:d}){return j.jsxs(Je,{pb:"0.5em",px:"xs",style:{display:"flex",alignItems:"center",gap:"0.5em"},children:[j.jsx(qs,{c:"dimmed",style:nz,children:n}),j.jsx(X_,{axis:s,value:e,step:i,onChange:l}),j.jsx(X_,{axis:a,value:t,step:i,onChange:c}),j.jsx(X_,{axis:o,value:r,step:i,onChange:d})]})}function Ine({scale:n,xOffset:e,yOffset:t,zOffset:r,roll:i,pitch:s,yaw:a,onCalibrate:o}){const[l,c]=U.useState(n),[d,h]=U.useState(e),[p,A]=U.useState(t),[y,m]=U.useState(r),[x,g]=U.useState(i),[_,b]=U.useState(s),[w,I]=U.useState(a);U.useEffect(()=>{c(n)},[n]),U.useEffect(()=>{h(e)},[e]),U.useEffect(()=>{A(t)},[t]),U.useEffect(()=>{m(r)},[r]),U.useEffect(()=>{g(i)},[i]),U.useEffect(()=>{b(s)},[s]),U.useEffect(()=>{I(a)},[a]);const S=(M,T,R,k,H,Q,V)=>o(M,T,R,k,H,Q,V);return j.jsxs(tz,{label:"Control",expandByDefault:!0,children:[j.jsxs(Je,{pb:"0.5em",px:"xs",style:{display:"flex",alignItems:"center",gap:"0.5em"},children:[j.jsx(qs,{c:"dimmed",style:nz,children:"Scale"}),j.jsx(Je,{style:{flex:1},children:j.jsx(F0,{value:l,onChange:M=>{c(M),S(M,d,p,y,x,_,w)},min:.1,max:5,step:.05,size:"xs",label:M=>M.toFixed(2),styles:wne})})]}),j.jsx(KR,{label:"Position",x:d,y:p,z:y,step:.05,onX:M=>{h(M),S(l,M,p,y,x,_,w)},onY:M=>{A(M),S(l,d,M,y,x,_,w)},onZ:M=>{m(M),S(l,d,p,M,x,_,w)}}),j.jsx(KR,{label:"Rotation",x,y:_,z:w,step:.5,xLabel:"R",yLabel:"P",zLabel:"Y",onX:M=>{g(M),S(l,d,p,y,M,_,w)},onY:M=>{b(M),S(l,d,p,y,x,M,w)},onZ:M=>{I(M),S(l,d,p,y,x,_,M)}})]})}function Cne(n){return n instanceof HTMLElement?n.isContentEditable?!0:n.closest('input, textarea, select, [contenteditable], [role="textbox"], [role="searchbox"], [role="combobox"]')!==null:!1}function Sne(n){return n.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Bne({command:n,value:e,onChange:t,disabled:r,enabledWhenValue:i}){const s=n.config,a=s.enabled_when!==void 0&&(i??0)<.5,o=r||a;return j.jsxs(Je,{pb:"0.5em",px:"xs",style:{display:"flex",alignItems:"center"},children:[j.jsx(qs,{c:"dimmed",style:{fontSize:"0.875em",fontWeight:450,lineHeight:"1.375em",letterSpacing:"-0.75px",width:"50%",flexShrink:0},children:s.label}),j.jsx(Je,{style:{width:"50%"},children:j.jsx(F0,{value:e,onChange:l=>t(n.id,l),min:s.min,max:s.max,step:s.step,size:"xs",disabled:o,styles:{root:{padding:"0"},track:{height:4},thumb:{width:12,height:12}}})})]})}function Mne({command:n,value:e,onChange:t,disabled:r}){const i=n.config;return j.jsx(Je,{pb:"0.5em",px:"xs",children:j.jsx(Gl,{label:i.label,checked:e>=.5,onChange:s=>t(n.id,s.currentTarget.checked?1:0),size:"xs",disabled:r})})}function Tne(n){const{visible:e,onVisibleChange:t,projects:r,projectValue:i,projectLabel:s,onProjectChange:a,scenes:o,sceneValue:l,onSceneChange:c,splats:d,splatSection:h=!1,splatValue:p,onSplatChange:A,splatConfig:y,onCalibrateSplat:m,onSplatUrlLoad:x,policies:g,policyValue:_,onPolicyChange:b,motions:w,motionValue:I,onMotionChange:S,showReferenceMotion:M,onShowReferenceMotionChange:T,commandsEnabled:R=!1,onReset:k}=n,[H,{open:Q,close:V}]=o0(!1),[B,W]=U.useState(""),[K,X]=U.useState(null),[$,J]=U.useState(!1),ne=U.useCallback(async ge=>{if(ge.key!=="Enter"||!x)return;const Ne=B.trim();if(d.some(Ge=>Ge.label===Ne||Ge.value===Ne))return;if(!Ne.toLowerCase().endsWith(".spz")){X("URL must end with .spz");return}await x(Ne)?(X(null),J(!0)):X("File not found at the specified URL")},[x,B,d]),[L,G]=U.useState([]),[oe,Ae]=U.useState([]),[ye,he]=U.useState({});U.useEffect(()=>{const ge=Lr(),Ne=()=>{G(ge.getCommands()),Ae(ge.getCommandGroups()),he(ge.getValues())};return Ne(),ge.addEventListener(Ne),()=>{ge.removeEventListener(Ne)}},[]);const fe=U.useCallback((ge,Ne)=>{Lr().setValue(ge,Ne),he(Ge=>({...Ge,[ge]:Ne}))},[]),Ie=U.useCallback(()=>{Lr().triggerButton("_system:reset"),k&&k()},[k]);U.useEffect(()=>{const ge=Ne=>{if(Ne.defaultPrevented||Ne.repeat||Ne.altKey||Ne.ctrlKey||Ne.metaKey)return;const tt=Ne.key.toLowerCase();if(tt!=="c"&&tt!=="r")return;const Ge=Ne.target instanceof Element?Ne.target:document.activeElement;Cne(Ge)||(Ne.preventDefault(),tt==="c"?t(!e):Ie())};return window.addEventListener("keydown",ge),()=>{window.removeEventListener("keydown",ge)}},[e,t,Ie]);const Re=ge=>L.filter(Ne=>Ne.groupName===ge&&(Ne.config.type==="slider"||Ne.config.type==="checkbox"));return!r.length&&!o.length&&!g.length?null:j.jsxs(j.Fragment,{children:[j.jsx(ra,{opened:H,onClose:V,size:"lg",title:null,centered:!0,styles:{body:{textAlign:"center"}},children:j.jsxs(lI,{gap:"md",align:"center",children:[j.jsx(Lg,{src:"./logo-color.svg",style:{width:"8em",height:"auto"}}),j.jsx(qs,{size:"xl",fw:700,children:"powered by mjswan"}),j.jsxs(qs,{size:"sm",c:"dimmed",children:["version ",XR]}),j.jsx(qs,{size:"sm",c:"dimmed",children:"MuJoco Simulation on Web Assembly with Neural netwroks"}),j.jsx(Nd,{w:"100%"}),j.jsxs(Je,{children:[j.jsx(hp,{href:"https://github.com/ttktjmt/mjswan",target:"_blank",style:{fontWeight:"600"},children:"GitHub"})," • ",j.jsx(hp,{href:"https://mjswan.readthedocs.io",target:"_blank",style:{fontWeight:"600"},children:"Documentation"})]}),j.jsx(Nd,{w:"100%"}),j.jsxs(Je,{style:{textAlign:"left",maxHeight:"120px",overflowY:"auto",lineHeight:"1",fontSize:"0.8rem",opacity:"0.75"},px:"md",children:["Thanks to our contributors! ",j.jsx("br",{}),JR.map((ge,Ne)=>j.jsxs("span",{children:[j.jsx(hp,{href:ge.html_url,target:"_blank",style:{textDecoration:"none",fontSize:"0.75rem"},children:ge.login}),Ne<JR.length-1&&", "]},ge.login))]})]})}),j.jsxs(fo,{width:"20em",visible:e,onVisibleChange:t,hiddenButtonTooltip:"Show controls (C)",children:[j.jsxs(fo.Handle,{children:[j.jsx(Ql,{label:`mjswan ${XR}`,children:j.jsx(Je,{component:"a",onClick:ge=>{ge.stopPropagation(),Q()},onMouseDown:ge=>ge.stopPropagation(),onTouchStart:ge=>ge.stopPropagation(),style:{position:"absolute",cursor:"pointer",display:"flex",top:"0.8em",left:"0.9em"},children:j.jsx(Lg,{src:"./logo.svg",style:{width:"1.2em",height:"auto"}})})}),j.jsx("div",{style:{width:"1.1em"}}),j.jsx(fo.HideWhenCollapsed,{children:j.jsxs(Je,{px:"xs",style:{flexGrow:1,letterSpacing:"-0.5px",display:"flex",alignItems:"center",gap:"0.5em"},pt:"0.1em",children:[j.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),r.length>1&&j.jsxs(fi,{position:"bottom-start",offset:5,children:[j.jsx(fi.Target,{children:j.jsx(Je,{onClick:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onTouchStart:ge=>ge.stopPropagation(),style:{cursor:"pointer",display:"flex",alignItems:"center",flexShrink:0},children:j.jsx(ez,{size:16})})}),j.jsx(fi.Dropdown,{onClick:ge=>ge.stopPropagation(),children:r.map(ge=>j.jsx(fi.Item,{onClick:Ne=>{Ne.stopPropagation(),a(ge.value)},style:{fontWeight:ge.value===i?600:400,backgroundColor:ge.value===i?"rgba(34, 139, 230, 0.1)":void 0},children:ge.label},ge.value))})]})]})}),j.jsx(fo.HideWhenExpanded,{children:j.jsx(Je,{px:"xs",style:{flexGrow:1,letterSpacing:"-0.5px"},pt:"0.1em",children:s})}),j.jsx(Ql,{label:"Hide controls (C)",children:j.jsx(au,{variant:"subtle",color:"gray",size:"sm","aria-label":"Hide controls",onClick:ge=>{ge.stopPropagation(),t(!1)},onMouseDown:ge=>ge.stopPropagation(),onTouchStart:ge=>ge.stopPropagation(),children:j.jsx(yne,{size:14})})})]}),j.jsx(fo.Contents,{children:j.jsxs(Je,{pt:"0.375em",children:[o.length>0&&j.jsx(lg,{id:"scene-select",label:"Scene",children:j.jsx(Uc,{id:"scene-select",placeholder:"Select scene",data:o,value:l,onChange:c,size:"xs",radius:"xs",searchable:!0,clearable:!1,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})}),(d.length>0||h)&&j.jsx(lg,{id:"splat-select",label:"Splat",children:j.jsx(Ql,{label:K??"",color:"red",position:"bottom",opened:K!==null,withArrow:!0,children:j.jsx(Uc,{id:"splat-select",placeholder:x!==void 0?"Select splat or paste .spz URL":"Select splat",data:d,value:p,onChange:ge=>{A(ge),X(null),J(!1)},searchable:x!==void 0,searchValue:B,onSearchChange:ge=>{W(ge),ge&&X(null)},onKeyDown:ne,size:"xs",radius:"xs",clearable:!0,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})})}),(y?.control&&p!==null||$)&&m&&j.jsx(Ine,{scale:y?.scale??1,xOffset:y?.xOffset??0,yOffset:y?.yOffset??0,zOffset:y?.zOffset??0,roll:y?.roll??0,pitch:y?.pitch??0,yaw:y?.yaw??0,onCalibrate:m}),g.length>0&&j.jsx(lg,{id:"policy-select",label:"Policy",children:j.jsx(Uc,{id:"policy-select",placeholder:"Select policy",data:g,value:_,onChange:b,size:"xs",radius:"xs",searchable:!0,clearable:!0,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})}),w.length>0&&j.jsxs(j.Fragment,{children:[j.jsx(lg,{id:"motion-select",label:"Motion",children:j.jsx(Uc,{id:"motion-select",placeholder:"Select motion",data:w,value:I,onChange:S,size:"xs",radius:"xs",searchable:!0,clearable:!0,styles:{input:{minHeight:"1.625rem",height:"1.625rem",padding:"0.5em"}},comboboxProps:{zIndex:1e3}})}),j.jsx(Je,{pb:"0.5em",px:"xs",children:j.jsx(Gl,{label:"Show reference",checked:M,onChange:ge=>T(ge.currentTarget.checked),size:"xs"})})]}),oe.length>0&&L.some(ge=>ge.config.type==="slider"||ge.config.type==="checkbox")&&j.jsx(j.Fragment,{children:oe.map(ge=>{const Ne=Re(ge);return Ne.length===0?null:j.jsx(tz,{label:Sne(ge),expandByDefault:!0,children:Ne.map(tt=>tt.config.type==="checkbox"?j.jsx(Mne,{command:tt,value:ye[tt.id]??0,onChange:fe,disabled:!R},tt.id):tt.config.type!=="slider"?null:j.jsx(Bne,{command:tt,value:ye[tt.id]??0,onChange:fe,disabled:!R,enabledWhenValue:tt.config.enabled_when?ye[Sw(tt.groupName,tt.config.enabled_when)]:void 0},tt.id))},ge)})}),j.jsx(Nd,{mb:"xs",mx:"xs"}),j.jsx(Je,{px:"xs",pb:"xs",children:j.jsx(uh,{variant:"light",color:"red",size:"xs",fullWidth:!0,leftSection:j.jsx(mne,{size:14}),onClick:Ie,children:"Reset"})})]})})]})]})}function Kf(n,e,t){return Object.keys(n[e]).reduce((r,i)=>(r[i]=`var(--mantine-${t}-${i})`,r),{})}function ZR(n,e){return n in e.breakpoints?e.breakpoints[n]:Z_(n)}function Rne(n){const e=ID(d0,n),t=Kf(e,"fontSizes","font-size"),r=Kf(e,"lineHeights","line-height"),i=Kf(e,"shadows","shadow"),s=Kf(e,"radius","radius"),a=Kf(e,"spacing","spacing"),o=Object.keys(e.headings.sizes).reduce((c,d)=>(c[d]={fontSize:`var(--mantine-${d}-font-size)`,lineHeight:`var(--mantine-${d}-line-height)`,fontWeight:`var(--mantine-${d}-font-weight)`},c),{}),l=Object.keys(e.colors).reduce((c,d)=>(c[d]={0:`var(--mantine-color-${d}-0)`,1:`var(--mantine-color-${d}-1)`,2:`var(--mantine-color-${d}-2)`,3:`var(--mantine-color-${d}-3)`,4:`var(--mantine-color-${d}-4)`,5:`var(--mantine-color-${d}-5)`,6:`var(--mantine-color-${d}-6)`,7:`var(--mantine-color-${d}-7)`,8:`var(--mantine-color-${d}-8)`,9:`var(--mantine-color-${d}-9)`,filled:`var(--mantine-color-${d}-filled)`,filledHover:`var(--mantine-color-${d}-filled-hover)`,light:`var(--mantine-color-${d}-light)`,lightHover:`var(--mantine-color-${d}-light-hover)`,lightColor:`var(--mantine-color-${d}-light-color)`,outline:`var(--mantine-color-${d}-outline)`,outlineHover:`var(--mantine-color-${d}-outline-hover)`},c),{primary:"var(--mantine-primary-color-filled)",primaryColors:{0:"var(--mantine-primary-color-0)",1:"var(--mantine-primary-color-1)",2:"var(--mantine-primary-color-2)",3:"var(--mantine-primary-color-3)",4:"var(--mantine-primary-color-4)",5:"var(--mantine-primary-color-5)",6:"var(--mantine-primary-color-6)",7:"var(--mantine-primary-color-7)",8:"var(--mantine-primary-color-8)",9:"var(--mantine-primary-color-9)",filled:"var(--mantine-primary-color-filled)",filledHover:"var(--mantine-primary-color-filled-hover)",light:"var(--mantine-primary-color-light)",lightHover:"var(--mantine-primary-color-light-hover)",lightColor:"var(--mantine-primary-color-light-color)",outline:"var(--mantine-primary-color-outline)",outlineHover:"var(--mantine-primary-color-outline-hover)"},white:"var(--mantine-color-white)",black:"var(--mantine-color-black)",text:"var(--mantine-color-text)",body:"var(--mantine-color-body)",error:"var(--mantine-color-error)",placeholder:"var(--mantine-color-placeholder)",anchor:"var(--mantine-color-anchor)",default:"var(--mantine-color-default)",defaultHover:"var(--mantine-color-default-hover)",defaultColor:"var(--mantine-color-default-color)",defaultBorder:"var(--mantine-color-default-border)",dimmed:"var(--mantine-color-dimmed)",disabledBody:"var(--mantine-color-disabled)",disabledText:"var(--mantine-color-disabled-color)",disabledBorder:"var(--mantine-color-disabled-border)"});return{scale:"var(--mantine-scale)",cursorType:"var(--mantine-cursor-type)",webkitFontSmoothing:"var(--mantine-webkit-font-smoothing)",mozFontSmoothing:"var(--mantine-moz-font-smoothing)",lineHeight:"var(--mantine-line-height)",fontFamily:"var(--mantine-font-family)",fontFamilyMonospace:"var(--mantine-font-family-monospace)",fontFamilyHeadings:"var(--mantine-font-family-headings)",headingFontWeight:"var(--mantine-heading-font-weight)",radiusDefault:"var(--mantine-radius-default)",breakpoints:e.breakpoints,fontSizes:t,lineHeights:r,shadows:i,radius:s,headings:o,spacing:a,colors:l,rtlSelector:'[dir="rtl"] &',darkSelector:'[data-mantine-color-scheme="dark"] &',lightSelector:'[data-mantine-color-scheme="light"] &',smallerThan:c=>`(max-width: ${ZR(c,e)})`,largerThan:c=>`(min-width: ${ZR(c,e)})`}}const Vw={fontFamily:"Inter",autoContrast:!0,components:{Checkbox:Gl.extend({defaultProps:{radius:"xs"}}),ColorInput:YE.extend({defaultProps:{radius:"xs"}}),Select:Uc.extend({defaultProps:{radius:"sm"}}),Textarea:JE.extend({defaultProps:{radius:"xs"}}),TextInput:cI.extend({defaultProps:{radius:"xs"}}),NumberInput:sI.extend({defaultProps:{radius:"xs"}}),Paper:Xc.extend({defaultProps:{radius:"xs",shadow:"0"}}),ActionIcon:au.extend({defaultProps:{variant:"subtle",color:"gray",radius:"xs"}}),Button:uh.extend({defaultProps:{radius:"xs",styles:{label:{fontWeight:450}}}})}};Rne(Vw);const rz=U.createContext(void 0),iz=()=>{const n=U.useContext(rz);if(!n)throw new Error("useLoading must be used within a LoadingProvider");return n},Dne=({children:n})=>{const[e,t]=U.useState(!1),[r,i]=U.useState(null),s=U.useRef(0),a=U.useCallback(c=>{s.current+=1,c!==void 0&&i(c),s.current>0&&t(!0)},[]),o=U.useCallback(c=>{i(c)},[]),l=U.useCallback(()=>{s.current=Math.max(0,s.current-1),s.current===0&&(t(!1),i(null))},[]);return j.jsx(rz.Provider,{value:{isLoading:e,loadingMessage:r,showLoading:a,setLoadingMessage:o,hideLoading:l},children:n})},kne=()=>{const{isLoading:n,loadingMessage:e}=iz();return n?j.jsx("div",{className:"loader-overlay",children:j.jsxs("div",{className:"loader-content",children:[j.jsx(oh,{size:64,type:"bars"}),e&&j.jsx("p",{className:"loader-message",children:e})]})}):null};function vC(n){return n.toLowerCase().replace(/ /g,"_").replace(/-/g,"_")}function sz(n){return n.id?n.id:"main"}function eD(n,e){if(!n.scenes.length)return null;if(!e)return n.scenes[0];const t=e.trim().toLowerCase();return n.scenes.find(r=>r.name.toLowerCase()===t)||n.scenes.find(r=>vC(r.name)===t)||n.scenes[0]}function J_(n,e){if(!n.policies.length)return null;const t=n.policies.find(s=>s.default)??n.policies[0];if(!e)return t.name;const r=e.trim().toLowerCase();return(n.policies.find(s=>s.name.toLowerCase()===r)||n.policies.find(s=>vC(s.name)===r))?.name??t.name}function Zf(n,e){return n?.motions?.length?(n.motions.find(r=>r.default)??n.motions[0]).name:null}function Nne(n,e){const t=sz(n),r=e.path?e.path:`scene/${vC(e.name)}/scene.xml`;return`${t}/assets/${r}`.replace(/\/+/g,"/")}function tD(n,e){return`${sz(n)}/assets/${e}`.replace(/\/+/g,"/")}const Hw="panel",jw="ref";function Qne(){const n="/".replace(/\/+$/,"/");let t=window.location.pathname.replace(/^\/+|\/+$/g,"");const r=n.replace(/^\/+|\/+$/g,"");if(r&&(t===r?t="":t.startsWith(`${r}/`)&&(t=t.slice(r.length+1))),!t)return null;const i=t.split("/")[0];return i==="main"||i.includes(".")||i==="assets"?null:i}function Pne(n,e){const t=n.replace(/\/+$/,"/"),r=new Set,i=(h,p)=>{if(h)try{const A=new URL(h,p||window.location.href).toString();r.add(A)}catch{r.add(h.replace(/\/+/g,"/"))}},s=`${window.location.origin}/`,a=new URL(t,s).toString();i("assets/config.json",a);const l=window.location.pathname.split("/").filter(Boolean);l.length>0&&l[l.length-1]==="index.html"&&l.pop(),l.length>0&&l[l.length-1]===(e??"main")&&l.pop();const c=`/${l.join("/")}${l.length?"/":""}`,d=`${window.location.origin}${c}`;return i("assets/config.json",d),i("assets/config.json"),i("../assets/config.json"),i("../../assets/config.json"),Array.from(r)}async function Lne(n,e){const r=new URLSearchParams(window.location.search).get("config"),i=Pne(n,e);if(r)try{i.unshift(new URL(r,window.location.href).toString())}catch{i.unshift(r)}let s=null;for(const a of i)try{const o=await fetch(a,{cache:"no-store"});if(!o.ok)throw new Error(`Failed to fetch ${a}: ${o.status}`);const l=await o.text(),c=l.trim();if((o.headers.get("content-type")||"").includes("text/html")||c.startsWith("<!doctype")||c.startsWith("<html"))throw new Error(`Received HTML from ${a}`);try{return JSON.parse(l)}catch(h){throw new Error(`Invalid JSON from ${a}: ${h instanceof Error?h.message:String(h)}`)}}catch(o){s=o instanceof Error?o:new Error(String(o))}throw s??new Error("Failed to load config.json.")}function Fne(n){return new URLSearchParams(n).get(Hw)!=="0"}function zne(n){return new URLSearchParams(n).get(jw)!=="0"}function Une(n){const t="/".replace(/\/+$/,"/").replace(/^\//g,"").replace(/\/+$/g,"");let r=t?`/${t}/`:"/";return n&&n!=="main"&&(r+=`${n}/`),r}function One({projectId:n,sceneName:e,policyName:t,panelVisible:r,showReference:i}){const s=Une(n),a=new URLSearchParams(window.location.search);e?a.set("scene",e):a.delete("scene"),t?a.set("policy",t):a.delete("policy"),r?a.delete(Hw):a.set(Hw,"0"),i?a.delete(jw):a.set(jw,"0");const o=a.toString(),l=s+(o?`?${o}`:"")+window.location.hash;window.history.replaceState({},"",l)}function $ne(){const[n,e]=U.useState(null),[t,r]=U.useState(null),[i,s]=U.useState(null),[a,o]=U.useState(null),[l,c]=U.useState(null),[d,h]=U.useState(()=>zne(window.location.search)),[p,A]=U.useState(null),[y,m]=U.useState(null),[x,g]=U.useState(null),[_,b]=U.useState(()=>Fne(window.location.search)),w=U.useRef(null),{showLoading:I,hideLoading:S,setLoadingMessage:M}=iz(),T=U.useMemo(()=>Qne(),[]),R=U.useMemo(()=>new URLSearchParams(window.location.search).get("scene"),[]),k=U.useMemo(()=>new URLSearchParams(window.location.search).get("policy"),[]);U.useEffect(()=>{I("Loading…"),Lne("/",T).then(q=>{e(q);const ee=q.projects.find(ce=>T===null?ce.id===null:ce.id===T);if(!ee)throw new Error(`Project "${T??"(main)"}" not found in config.json.`);r(ee);const ie=eD(ee,R);s(ie);const be=ie?J_(ie,k):null;o(be);const ve=ie?.policies.find(ce=>ce.name===be)??null;c(Zf(ve))}).catch(q=>{A(q.message||"Failed to load config."),S()})},[T,R,k,I,S]);const H=U.useMemo(()=>!t||!i?null:Nne(t,i),[t,i]),Q=U.useMemo(()=>!i||!a?null:i.policies.find(q=>q.name===a)??null,[i,a]),V=U.useMemo(()=>!t||!Q?.config?null:tD(t,Q.config),[t,Q]),B=U.useMemo(()=>Q?.motions?.length?Q.motions.map(q=>({value:q.name,label:q.name})):[],[Q]),W=U.useMemo(()=>!t||!i?.splats?.length?[]:i.splats.map(q=>q.path?{...q,url:tD(t,q.path)}:q),[t,i?.splats]),K=U.useMemo(()=>y?W.find(q=>q.name===y)??null:x?{name:"Custom",url:x}:null,[W,y,x]),X=U.useMemo(()=>n?n.projects.map(q=>({value:q.id??"main",label:q.name||(q.id??"Main")})):[],[n]),$=U.useMemo(()=>t?t.scenes.map(q=>({value:q.name,label:q.name})):[],[t]),J=U.useMemo(()=>!i||!i.policies?[]:i.policies.map(q=>({value:q.name,label:q.name})),[i]),ne=t?t.id??"main":null,L=i?.name??null,G=U.useCallback(q=>{A(q.message),S()},[S]),oe=U.useCallback(()=>{S()},[S]),Ae=U.useCallback(q=>{q==="Running simulation"||q==="Failed to load scene"||M(q)},[M]);U.useEffect(()=>{const q=i?.splats?.[0];m(q?q.name:null),g(null)},[i]);const ye=U.useCallback(q=>{w.current=q},[]);U.useEffect(()=>{c(Zf(Q)),h(!!Q?.motions?.length)},[Q]);const he=U.useMemo(()=>i?.splats?.length?i.splats.map(q=>({value:q.name,label:q.name})):[],[i?.splats]),fe=U.useCallback(async q=>{m(q),g(null);const ee=w.current;if(!ee)return;const ie=q===null?null:W.find(be=>be.name===q)??null;if(!(q!==null&&!ie)){I(q===null?"Removing splat…":`Loading splat "${q}"…`);try{await ee.setSplat(ie)}catch{}finally{S()}}},[W,I,S]),Ie=U.useCallback(async q=>{try{if(!(await fetch(q,{method:"HEAD"})).ok)return!1}catch{return!1}const ee=w.current;if(!ee)return!1;I('Loading splat "Custom"…');try{return await ee.setSplat({name:"Custom",url:q}),g(q),!0}catch{return!1}finally{S()}},[I,S]),Re=U.useCallback((q,ee,ie,be,ve,ce,Z)=>{const Y=K??(x?{name:"Custom",url:x}:null);Y&&w.current?.calibrateSplat({...Y,scale:q,xOffset:ee,yOffset:ie,zOffset:be,roll:ve,pitch:ce,yaw:Z})},[K,x]),ge=U.useCallback(q=>{One({projectId:q.projectId??t?.id??null,sceneName:q.sceneName??i?.name??null,policyName:q.policyName??a,panelVisible:q.panelVisible??_,showReference:q.showReference??d})},[t?.id,i?.name,a,_,d]),Ne=U.useCallback(q=>{if(!n||!q)return;const ee=q==="main"?null:q,ie=n.projects.find(Z=>(Z.id??"main")===(ee??"main"));if(!ie)return;const be=eD(ie,null);I(be?`Loading scene "${be.name}"…`:"Loading…"),r(ie),s(be);const ve=be?J_(be,null):null;o(ve);const ce=be?.policies.find(Z=>Z.name===ve)??null;c(Zf(ce)),ge({projectId:ie.id,sceneName:be?.name??null,policyName:ve})},[n,I,ge]),tt=U.useCallback(q=>{if(!t||!q)return;const ee=t.scenes.find(ve=>ve.name===q);if(!ee)return;I(`Loading scene "${ee.name}"…`),s(ee);const ie=J_(ee,null);o(ie);const be=ee.policies.find(ve=>ve.name===ie)??null;c(Zf(be)),ge({projectId:t.id,sceneName:q,policyName:ie})},[t,I,ge]),Ge=U.useCallback(q=>{q!==a&&I(q?`Loading policy "${q}"…`:"Loading policy…"),o(q);const ee=i?.policies.find(ie=>ie.name===q)??null;c(Zf(ee)),ge({policyName:q})},[a,I,ge]),F=U.useCallback(q=>{b(q),ge({panelVisible:q})},[ge]),re=U.useCallback(async q=>{const ee=l;c(q);const ie=w.current;if(ie){I(q===null?"Clearing motion…":`Loading motion "${q}"…`);try{await ie.setSelectedMotion(q)===!1&&q!==null&&c(ie.getSelectedMotionName()??ee)}catch{}finally{S()}}},[l,I,S]),Ee=U.useCallback(q=>{h(q),w.current?.setReferenceVisible(q),ge({showReference:q})},[ge]);return p?j.jsx(rb,{theme:Vw,defaultColorScheme:"auto",children:j.jsx("div",{className:"app",children:j.jsxs("div",{className:"hud hud-error",children:[j.jsx("h1",{className:"hud-title",children:"mjswan"}),j.jsx("p",{className:"hud-message",children:p})]})})}):!t||!i||!H?null:j.jsx(rb,{theme:Vw,defaultColorScheme:"auto",children:j.jsxs("div",{className:"app",children:[j.jsx(kne,{}),j.jsx(Tne,{visible:_,onVisibleChange:F,projects:X,projectValue:ne,projectLabel:t?.name??"mjswan",onProjectChange:Ne,scenes:$,sceneValue:L,onSceneChange:tt,splats:he,splatSection:i?.splatSection??!1,splatValue:y,onSplatChange:fe,splatConfig:K,onCalibrateSplat:Re,onSplatUrlLoad:Ie,policies:J,policyValue:a,onPolicyChange:Ge,motions:B,motionValue:l,onMotionChange:re,showReferenceMotion:d,onShowReferenceMotionChange:Ee,commandsEnabled:!!V}),j.jsx(une,{scenePath:H,baseUrl:"/",policyConfigPath:V,splatConfig:K,cameraConfig:i?.camera,eventsConfig:i?.events,terrainData:i?.terrainData,selectedMotion:l,showReferenceMotion:d,onError:G,onReady:oe,onStatusChange:Ae,onRuntimeReady:ye})]})})}function Gne(){return j.jsx(Dne,{children:j.jsx($ne,{})})}const nD=document.getElementById("root");nD&&qz.createRoot(nD).render(j.jsx(On.StrictMode,{children:j.jsx(Gne,{})}));export{DV as _};
|