From 600f916d52f71f5293616c848c7669e403359019 Mon Sep 17 00:00:00 2001 From: h0lybyte <5599058+h0lybyte@users.noreply.github.com> Date: Sun, 14 Jul 2024 11:22:25 +0000 Subject: [PATCH] Merge pull request #2400 from KBVE/beta Preparing Release Branch --- .../{App.CrXvH9GP.js => App.ZqzL3Mo9.js} | 68 +++++++++--------- docs/assets/items/npc/sprites/jesus.png | Bin 0 -> 6801 bytes .../items/potion/energy/velocity_rush.png | Bin 0 -> 3691 bytes docs/index.html | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) rename docs/_astro/{App.CrXvH9GP.js => App.ZqzL3Mo9.js} (97%) create mode 100644 docs/assets/items/npc/sprites/jesus.png create mode 100644 docs/assets/items/potion/energy/velocity_rush.png diff --git a/docs/_astro/App.CrXvH9GP.js b/docs/_astro/App.ZqzL3Mo9.js similarity index 97% rename from docs/_astro/App.CrXvH9GP.js rename to docs/_astro/App.ZqzL3Mo9.js index 75df83f..16c39a8 100644 --- a/docs/_astro/App.CrXvH9GP.js +++ b/docs/_astro/App.ZqzL3Mo9.js @@ -1,4 +1,4 @@ -import{j as he}from"./jsx-runtime.BFYNFNPI.js";import{g as Wd,r as Am,a as Pe,c as py}from"./index.DIpCM_17.js";import{p as CL,a as bx}from"./index.DxhZiom7.js";import{t as Dr}from"./index.BH1EYZ08.js";var EM={exports:{}},on={};/** +import{j as he}from"./jsx-runtime.BFYNFNPI.js";import{g as Wd,r as Pm,a as Pe,c as vy}from"./index.DIpCM_17.js";import{p as CL,a as bx}from"./index.DxhZiom7.js";import{t as Dr}from"./index.BH1EYZ08.js";var EM={exports:{}},on={};/** * @license React * react-is.production.min.js * @@ -6,17 +6,17 @@ import{j as he}from"./jsx-runtime.BFYNFNPI.js";import{g as Wd,r as Am,a as Pe,c * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Lx=Symbol.for("react.element"),Fx=Symbol.for("react.portal"),Pm=Symbol.for("react.fragment"),Rm=Symbol.for("react.strict_mode"),bm=Symbol.for("react.profiler"),Lm=Symbol.for("react.provider"),Fm=Symbol.for("react.context"),wL=Symbol.for("react.server_context"),Om=Symbol.for("react.forward_ref"),Dm=Symbol.for("react.suspense"),Im=Symbol.for("react.suspense_list"),Nm=Symbol.for("react.memo"),Bm=Symbol.for("react.lazy"),AL=Symbol.for("react.offscreen"),MM;MM=Symbol.for("react.module.reference");function Aa(g){if(typeof g=="object"&&g!==null){var t=g.$$typeof;switch(t){case Lx:switch(g=g.type,g){case Pm:case bm:case Rm:case Dm:case Im:return g;default:switch(g=g&&g.$$typeof,g){case wL:case Fm:case Om:case Bm:case Nm:case Lm:return g;default:return t}}case Fx:return t}}}on.ContextConsumer=Fm;on.ContextProvider=Lm;on.Element=Lx;on.ForwardRef=Om;on.Fragment=Pm;on.Lazy=Bm;on.Memo=Nm;on.Portal=Fx;on.Profiler=bm;on.StrictMode=Rm;on.Suspense=Dm;on.SuspenseList=Im;on.isAsyncMode=function(){return!1};on.isConcurrentMode=function(){return!1};on.isContextConsumer=function(g){return Aa(g)===Fm};on.isContextProvider=function(g){return Aa(g)===Lm};on.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===Lx};on.isForwardRef=function(g){return Aa(g)===Om};on.isFragment=function(g){return Aa(g)===Pm};on.isLazy=function(g){return Aa(g)===Bm};on.isMemo=function(g){return Aa(g)===Nm};on.isPortal=function(g){return Aa(g)===Fx};on.isProfiler=function(g){return Aa(g)===bm};on.isStrictMode=function(g){return Aa(g)===Rm};on.isSuspense=function(g){return Aa(g)===Dm};on.isSuspenseList=function(g){return Aa(g)===Im};on.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===Pm||g===bm||g===Rm||g===Dm||g===Im||g===AL||typeof g=="object"&&g!==null&&(g.$$typeof===Bm||g.$$typeof===Nm||g.$$typeof===Lm||g.$$typeof===Fm||g.$$typeof===Om||g.$$typeof===MM||g.getModuleId!==void 0)};on.typeOf=Aa;EM.exports=on;var CM=EM.exports;function PL(g){function t(tt,Y,Z,U,H){for(var J=0,_=0,q=0,at=0,ot,rt,gt=0,yt=0,Et,At=Et=ot=0,Pt=0,Vt=0,dt=0,ut=0,Rt=Z.length,Dt=Rt-1,Ht,Bt="",ne="",oe="",ge="",xe;Ptot)&&(ut=(Bt=Bt.replace(" ",":")).length),0U&&(U=(Y=Y.trim()).charCodeAt(0)),U){case 38:return Y.replace(o,"$1"+tt.trim());case 58:return tt.trim()+Y.replace(o,"$1"+tt.trim());default:if(0<1*Z&&0_.charCodeAt(8))break;case 115:H=H.replace(_,"-webkit-"+_)+";"+H;break;case 207:case 102:H=H.replace(_,"-webkit-"+(102Z.charCodeAt(0)&&(Z=Z.trim()),Q=Z,Z=[Q],0ot)&&(ut=(Bt=Bt.replace(" ",":")).length),0U&&(U=(Y=Y.trim()).charCodeAt(0)),U){case 38:return Y.replace(o,"$1"+tt.trim());case 58:return tt.trim()+Y.replace(o,"$1"+tt.trim());default:if(0<1*Z&&0_.charCodeAt(8))break;case 115:H=H.replace(_,"-webkit-"+_)+";"+H;break;case 207:case 102:H=H.replace(_,"-webkit-"+(102Z.charCodeAt(0)&&(Z=Z.trim()),Q=Z,Z=[Q],01?t-1:0),x=1;x0?" Args: "+i.join(", "):""))}var jL=function(){function g(i){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=i}var t=g.prototype;return t.indexOfGroup=function(i){for(var x=0,T=0;T=this.groupSizes.length){for(var T=this.groupSizes,E=T.length,s=E;i>=s;)(s<<=1)<0&&Xd(16,""+i);this.groupSizes=new Uint32Array(s),this.groupSizes.set(T),this.length=s;for(var y=E;y=this.length||this.groupSizes[i]===0)return x;for(var T=this.groupSizes[i],E=this.indexOfGroup(i),s=E+T,y=E;y=rd&&(rd=t+1),Zv.set(g,t),fm.set(t,g)},$L="style["+Yf+'][data-styled-version="5.3.6"]',QL=new RegExp("^"+Yf+'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)'),_L=function(g,t,i){for(var x,T=i.split(","),E=0,s=T.length;E1?t-1:0),x=1;x0?" Args: "+i.join(", "):""))}var jL=function(){function g(i){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=i}var t=g.prototype;return t.indexOfGroup=function(i){for(var x=0,T=0;T=this.groupSizes.length){for(var T=this.groupSizes,E=T.length,s=E;i>=s;)(s<<=1)<0&&Xd(16,""+i);this.groupSizes=new Uint32Array(s),this.groupSizes.set(T),this.length=s;for(var y=E;y=this.length||this.groupSizes[i]===0)return x;for(var T=this.groupSizes[i],E=this.indexOfGroup(i),s=E+T,y=E;y=rd&&(rd=t+1),Zv.set(g,t),cm.set(t,g)},$L="style["+Yf+'][data-styled-version="5.3.6"]',QL=new RegExp("^"+Yf+'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)'),_L=function(g,t,i){for(var x,T=i.split(","),E=0,s=T.length;E=0;r--){var p=e[r];if(p&&p.nodeType===1&&p.hasAttribute(Yf))return p}}(i),E=T!==void 0?T.nextSibling:null;x.setAttribute(Yf,"active"),x.setAttribute("data-styled-version","5.3.6");var s=tF();return s&&x.setAttribute("nonce",s),i.insertBefore(x,E),x},eF=function(){function g(i){var x=this.element=bM(i);x.appendChild(document.createTextNode("")),this.sheet=function(T){if(T.sheet)return T.sheet;for(var E=document.styleSheets,s=0,y=E.length;s=0){var T=document.createTextNode(x),E=this.nodes[i];return this.element.insertBefore(T,E||null),this.length++,!0}return!1},t.deleteRule=function(i){this.element.removeChild(this.nodes[i]),this.length--},t.getRule=function(i){return i0&&(h+=a+",")}),E+=""+r+p+'{content:"'+h+`"}/*!sc*/ -`}}}return E}(this)},g}(),sF=/(a)(d)/gi,kS=function(g){return String.fromCharCode(g+(g>25?39:97))};function my(g){var t,i="";for(t=Math.abs(g);t>52;t=t/52|0)i=kS(t%52)+i;return(kS(t%52)+i).replace(sF,"$1-$2")}var Df=function(g,t){for(var i=t.length;i;)g=33*g^t.charCodeAt(--i);return g},FM=function(g){return Df(5381,g)};function aF(g){for(var t=0;t>>0);if(!i.hasNameForId(T,y)){var e=x(s,"."+y,void 0,T);i.insertRules(T,y,e)}E.push(y),this.staticRulesId=y}else{for(var r=this.rules.length,p=Df(this.baseHash,x.hash),h="",a=0;a>>0);if(!i.hasNameForId(T,f)){var o=x(h,"."+f,void 0,T);i.insertRules(T,f,o)}E.push(f)}}return E.join(" ")},g}(),hF=/^\s*\/\/.*$/gm,uF=[":","[",".","#"];function fF(g){var t,i,x,T,E=g===void 0?lh:g,s=E.options,y=s===void 0?lh:s,e=E.plugins,r=e===void 0?um:e,p=new PL(y),h=[],a=function(u){function f(o){if(o)try{u(o+"}")}catch{}}return function(o,c,d,v,m,S,M,w,C,A){switch(o){case 1:if(C===0&&c.charCodeAt(0)===64)return u(c+";"),"";break;case 2:if(w===0)return c+"/*|*/";break;case 3:switch(w){case 102:case 112:return u(d[0]+c),"";default:return c+(A===0?"/*|*/":"")}case-2:c.split("/*|*/}").forEach(f)}}}(function(u){h.push(u)}),l=function(u,f,o){return f===0&&uF.indexOf(o[i.length])!==-1||o.match(T)?u:"."+t};function n(u,f,o,c){c===void 0&&(c="&");var d=u.replace(hF,""),v=f&&o?o+" "+f+" { "+d+" }":d;return t=c,i=f,x=new RegExp("\\"+i+"\\b","g"),T=new RegExp("(\\"+i+"\\b){2,}"),p(o||!f?"":f,v)}return p.use([].concat(r,[function(u,f,o){u===2&&o.length&&o[0].lastIndexOf(i)>0&&(o[0]=o[0].replace(x,l))},a,function(u){if(u===-2){var f=h;return h=[],f}}])),n.hash=r.length?r.reduce(function(u,f){return f.name||Xd(15),Df(u,f.name)},5381).toString():"",n}var OM=Am.createContext();OM.Consumer;var DM=Am.createContext(),cF=(DM.Consumer,new LM),gy=fF();function dF(){return Pe.useContext(OM)||cF}function pF(){return Pe.useContext(DM)||gy}var vF=function(){function g(t,i){var x=this;this.inject=function(T,E){E===void 0&&(E=gy);var s=x.name+E.hash;T.hasNameForId(x.id,s)||T.insertRules(x.id,s,E(x.rules,s,"@keyframes"))},this.toString=function(){return Xd(12,String(x.name))},this.name=t,this.id="sc-keyframes-"+t,this.rules=i}return g.prototype.getName=function(t){return t===void 0&&(t=gy),this.name+t.hash},g}(),mF=/([A-Z])/,gF=/([A-Z])/g,yF=/^ms-/,xF=function(g){return"-"+g.toLowerCase()};function KS(g){return mF.test(g)?g.replace(gF,xF).replace(yF,"-ms-"):g}var jS=function(g){return g==null||g===!1||g===""};function kf(g,t,i,x){if(Array.isArray(g)){for(var T,E=[],s=0,y=g.length;s1?t-1:0),x=1;x?@[\\\]^`{|}~-]+/g,MF=/(^-|-$)/g;function l0(g){return g.replace(EF,"-").replace(MF,"")}var CF=function(g){return my(FM(g)>>>0)};function _p(g){return typeof g=="string"&&!0}var yy=function(g){return typeof g=="function"||typeof g=="object"&&g!==null&&!Array.isArray(g)},wF=function(g){return g!=="__proto__"&&g!=="constructor"&&g!=="prototype"};function AF(g,t,i){var x=g[i];yy(t)&&yy(x)?IM(x,t):g[i]=t}function IM(g){for(var t=arguments.length,i=new Array(t>1?t-1:0),x=1;x=0||(A[w]=S[w]);return A}(t,["componentId"]),m=d&&d+"-"+(_p(c)?c:l0(XS(c)));return BM(c,gl({},v,{attrs:a,componentId:m}),i)},Object.defineProperty(n,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(c){this._foldedDefaultProps=x?IM({},g.defaultProps,c):c}}),n.toString=function(){return"."+n.styledComponentId},T&&kL(n,g,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0,withComponent:!0}),n}var cm=function(g){return function t(i,x,T){if(T===void 0&&(T=lh),!CM.isValidElementType(x))return Xd(1,String(x));var E=function(){return i(x,T,SF.apply(void 0,arguments))};return E.withConfig=function(s){return t(i,x,gl({},T,{},s))},E.attrs=function(s){return t(i,x,gl({},T,{attrs:Array.prototype.concat(T.attrs,s).filter(Boolean)}))},E}(BM,g)};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","textPath","tspan"].forEach(function(g){cm[g]=cm(g)});var UM={exports:{}};(function(g,t){(function(x,T){g.exports=T()})(py,()=>(()=>{var i={50792:s=>{var y=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function p(n,u,f){this.fn=n,this.context=u,this.once=f||!1}function h(n,u,f,o,c){if(typeof f!="function")throw new TypeError("The listener must be a function");var d=new p(f,o||n,c),v=e?e+u:u;return n._events[v]?n._events[v].fn?n._events[v]=[n._events[v],d]:n._events[v].push(d):(n._events[v]=d,n._eventsCount++),n}function a(n,u){--n._eventsCount===0?n._events=new r:delete n._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],f,o;if(this._eventsCount===0)return u;for(o in f=this._events)y.call(f,o)&&u.push(e?o.slice(1):o);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(f)):u},l.prototype.listeners=function(u){var f=e?e+u:u,o=this._events[f];if(!o)return[];if(o.fn)return[o.fn];for(var c=0,d=o.length,v=new Array(d);c{/** +`}}}return E}(this)},g}(),sF=/(a)(d)/gi,kS=function(g){return String.fromCharCode(g+(g>25?39:97))};function gy(g){var t,i="";for(t=Math.abs(g);t>52;t=t/52|0)i=kS(t%52)+i;return(kS(t%52)+i).replace(sF,"$1-$2")}var Df=function(g,t){for(var i=t.length;i;)g=33*g^t.charCodeAt(--i);return g},FM=function(g){return Df(5381,g)};function aF(g){for(var t=0;t>>0);if(!i.hasNameForId(T,y)){var e=x(s,"."+y,void 0,T);i.insertRules(T,y,e)}E.push(y),this.staticRulesId=y}else{for(var r=this.rules.length,p=Df(this.baseHash,x.hash),h="",a=0;a>>0);if(!i.hasNameForId(T,f)){var o=x(h,"."+f,void 0,T);i.insertRules(T,f,o)}E.push(f)}}return E.join(" ")},g}(),hF=/^\s*\/\/.*$/gm,uF=[":","[",".","#"];function fF(g){var t,i,x,T,E=g===void 0?lh:g,s=E.options,y=s===void 0?lh:s,e=E.plugins,r=e===void 0?fm:e,p=new PL(y),h=[],a=function(u){function f(o){if(o)try{u(o+"}")}catch{}}return function(o,c,d,v,m,S,M,w,C,A){switch(o){case 1:if(C===0&&c.charCodeAt(0)===64)return u(c+";"),"";break;case 2:if(w===0)return c+"/*|*/";break;case 3:switch(w){case 102:case 112:return u(d[0]+c),"";default:return c+(A===0?"/*|*/":"")}case-2:c.split("/*|*/}").forEach(f)}}}(function(u){h.push(u)}),l=function(u,f,o){return f===0&&uF.indexOf(o[i.length])!==-1||o.match(T)?u:"."+t};function n(u,f,o,c){c===void 0&&(c="&");var d=u.replace(hF,""),v=f&&o?o+" "+f+" { "+d+" }":d;return t=c,i=f,x=new RegExp("\\"+i+"\\b","g"),T=new RegExp("(\\"+i+"\\b){2,}"),p(o||!f?"":f,v)}return p.use([].concat(r,[function(u,f,o){u===2&&o.length&&o[0].lastIndexOf(i)>0&&(o[0]=o[0].replace(x,l))},a,function(u){if(u===-2){var f=h;return h=[],f}}])),n.hash=r.length?r.reduce(function(u,f){return f.name||Xd(15),Df(u,f.name)},5381).toString():"",n}var OM=Pm.createContext();OM.Consumer;var DM=Pm.createContext(),cF=(DM.Consumer,new LM),yy=fF();function dF(){return Pe.useContext(OM)||cF}function pF(){return Pe.useContext(DM)||yy}var vF=function(){function g(t,i){var x=this;this.inject=function(T,E){E===void 0&&(E=yy);var s=x.name+E.hash;T.hasNameForId(x.id,s)||T.insertRules(x.id,s,E(x.rules,s,"@keyframes"))},this.toString=function(){return Xd(12,String(x.name))},this.name=t,this.id="sc-keyframes-"+t,this.rules=i}return g.prototype.getName=function(t){return t===void 0&&(t=yy),this.name+t.hash},g}(),mF=/([A-Z])/,gF=/([A-Z])/g,yF=/^ms-/,xF=function(g){return"-"+g.toLowerCase()};function KS(g){return mF.test(g)?g.replace(gF,xF).replace(yF,"-ms-"):g}var jS=function(g){return g==null||g===!1||g===""};function kf(g,t,i,x){if(Array.isArray(g)){for(var T,E=[],s=0,y=g.length;s1?t-1:0),x=1;x?@[\\\]^`{|}~-]+/g,MF=/(^-|-$)/g;function h0(g){return g.replace(EF,"-").replace(MF,"")}var CF=function(g){return gy(FM(g)>>>0)};function _p(g){return typeof g=="string"&&!0}var xy=function(g){return typeof g=="function"||typeof g=="object"&&g!==null&&!Array.isArray(g)},wF=function(g){return g!=="__proto__"&&g!=="constructor"&&g!=="prototype"};function AF(g,t,i){var x=g[i];xy(t)&&xy(x)?IM(x,t):g[i]=t}function IM(g){for(var t=arguments.length,i=new Array(t>1?t-1:0),x=1;x=0||(A[w]=S[w]);return A}(t,["componentId"]),m=d&&d+"-"+(_p(c)?c:h0(XS(c)));return BM(c,gl({},v,{attrs:a,componentId:m}),i)},Object.defineProperty(n,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(c){this._foldedDefaultProps=x?IM({},g.defaultProps,c):c}}),n.toString=function(){return"."+n.styledComponentId},T&&kL(n,g,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0,withComponent:!0}),n}var dm=function(g){return function t(i,x,T){if(T===void 0&&(T=lh),!CM.isValidElementType(x))return Xd(1,String(x));var E=function(){return i(x,T,SF.apply(void 0,arguments))};return E.withConfig=function(s){return t(i,x,gl({},T,{},s))},E.attrs=function(s){return t(i,x,gl({},T,{attrs:Array.prototype.concat(T.attrs,s).filter(Boolean)}))},E}(BM,g)};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","textPath","tspan"].forEach(function(g){dm[g]=dm(g)});var UM={exports:{}};(function(g,t){(function(x,T){g.exports=T()})(vy,()=>(()=>{var i={50792:s=>{var y=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function p(n,u,f){this.fn=n,this.context=u,this.once=f||!1}function h(n,u,f,o,c){if(typeof f!="function")throw new TypeError("The listener must be a function");var d=new p(f,o||n,c),v=e?e+u:u;return n._events[v]?n._events[v].fn?n._events[v]=[n._events[v],d]:n._events[v].push(d):(n._events[v]=d,n._eventsCount++),n}function a(n,u){--n._eventsCount===0?n._events=new r:delete n._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],f,o;if(this._eventsCount===0)return u;for(o in f=this._events)y.call(f,o)&&u.push(e?o.slice(1):o);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(f)):u},l.prototype.listeners=function(u){var f=e?e+u:u,o=this._events[f];if(!o)return[];if(o.fn)return[o.fn];for(var c=0,d=o.length,v=new Array(d);c{/** * @author samme * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} @@ -6360,11 +6360,11 @@ return new `+this.key+`(); * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} - */s.exports={Format:e(27902),Pad:e(41836),RemoveAt:e(33628),Reverse:e(27671),UppercaseFirst:e(35355),UUID:e(45650)}}},x={};function T(s){var y=x[s];if(y!==void 0)return y.exports;var e=x[s]={exports:{}};return i[s](e,e.exports,T),e.exports}T.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}();var E=T(85454);return E})())})(UM);var jm=UM.exports;const sd=Wd(jm);var PF=Object.create,Gx=Object.defineProperty,RF=Object.defineProperties,bF=Object.getOwnPropertyDescriptor,LF=Object.getOwnPropertyDescriptors,FF=Object.getOwnPropertyNames,JS=Object.getOwnPropertySymbols,OF=Object.getPrototypeOf,zM=Object.prototype.hasOwnProperty,DF=Object.prototype.propertyIsEnumerable,$S=(g,t,i)=>t in g?Gx(g,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):g[t]=i,An=(g,t)=>{for(var i in t||(t={}))zM.call(t,i)&&$S(g,i,t[i]);if(JS)for(var i of JS(t))DF.call(t,i)&&$S(g,i,t[i]);return g},dh=(g,t)=>RF(g,LF(t)),si=(g,t)=>()=>(t||g((t={exports:{}}).exports,t),t.exports),IF=(g,t,i,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let T of FF(t))!zM.call(g,T)&&T!==i&&Gx(g,T,{get:()=>t[T],enumerable:!(x=bF(t,T))||x.enumerable});return g},GM=(g,t,i)=>(i=g!=null?PF(OF(g)):{},IF(t||!g||!g.__esModule?Gx(i,"default",{value:g,enumerable:!0}):i,g)),Zm=si(g=>{var t=function(E,s){return Es?1:0},i=function(E,s){return Es?-1:0};function x(E){return function(s,y){return E(y,s)}}function T(E){return E===2?function(s,y){return s[0]y[0]?1:s[1]y[1]?1:0}:function(s,y){for(var e=0;ey[e])return 1;e++}return 0}}g.DEFAULT_COMPARATOR=t,g.DEFAULT_REVERSE_COMPARATOR=i,g.reverseComparator=x,g.createTupleComparator=T}),NF=si(g=>{g.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",g.SYMBOL_SUPPORT=typeof Symbol<"u"}),zn=si((g,t)=>{var i=NF(),x=i.ARRAY_BUFFER_SUPPORT,T=i.SYMBOL_SUPPORT;t.exports=function(E,s){var y,e,r,p,h;if(!E)throw new Error("obliterator/forEach: invalid iterable.");if(typeof s!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(E)||x&&ArrayBuffer.isView(E)||typeof E=="string"||E.toString()==="[object Arguments]"){for(r=0,p=E.length;r{var i=Zm(),x=zn(),T=i.DEFAULT_COMPARATOR,E=i.reverseComparator;function s(u){if(this.clear(),this.comparator=u||T,typeof this.comparator!="function")throw new Error("mnemonist/FibonacciHeap.constructor: given comparator should be a function.")}s.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function y(u){return{item:u,degree:0}}function e(u,f){u.root?(f.right=u.root.right,f.left=u.root,u.root.right.left=f,u.root.right=f):u.root=f}s.prototype.push=function(u){var f=y(u);return f.left=f,f.right=f,e(this,f),(!this.min||this.comparator(f.item,this.min.item)<=0)&&(this.min=f),++this.size},s.prototype.peek=function(){return this.min?this.min.item:void 0};function r(u){for(var f=[],o=u,c=!1;!(o===u&&c);)o===u&&(c=!0),f.push(o),o=o.right;return f}function p(u,f){u.root===f&&(u.root=f.right),f.left.right=f.right,f.right.left=f.left}function h(u,f){u.child?(f.right=u.child.right,f.left=u.child,u.child.right.left=f,u.child.right=f):u.child=f}function a(u,f,o){p(u,f),f.left=f,f.right=f,h(o,f),o.degree++,f.parent=o}function l(u){var f=new Array(u.size),o=r(u.root),c,d,v,m,S,M;for(c=0,d=o.length;c0&&(M=v,v=m,m=M),a(u,m,v),f[S]=null,S++;f[S]=v}for(c=0;c{var t=Math.pow(2,8)-1,i=Math.pow(2,16)-1,x=Math.pow(2,32)-1,T=Math.pow(2,7)-1,E=Math.pow(2,15)-1,s=Math.pow(2,31)-1;g.getPointerArray=function(e){var r=e-1;if(r<=t)return Uint8Array;if(r<=i)return Uint16Array;if(r<=x)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},g.getSignedPointerArray=function(e){var r=e-1;return r<=T?Int8Array:r<=E?Int16Array:r<=s?Int32Array:Float64Array},g.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var y={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};g.getMinimalRepresentation=function(e,r){var p=null,h=0,a,l,n,u,f;for(u=0,f=e.length;uh&&(h=a,p=l);return p},g.isTypedArray=function(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)},g.concat=function(){var e=0,r,p,h;for(r=0,h=arguments.length;r{var t=zn(),i=Is();function x(y){return Array.isArray(y)||i.isTypedArray(y)}function T(y){if(typeof y.length=="number")return y.length;if(typeof y.size=="number")return y.size}function E(y){var e=T(y),r=typeof e=="number"?new Array(e):[],p=0;return t(y,function(h){r[p++]=h}),r}function s(y){var e=T(y),r=typeof e=="number"?i.getPointerArray(e):Array,p=typeof e=="number"?new Array(e):[],h=typeof e=="number"?new r(e):[],a=0;return t(y,function(l){p[a]=l,h[a]=a++}),[p,h]}g.isArrayLike=x,g.guessLength=T,g.toArray=E,g.toArrayWithIndices=s}),Hx=si((g,t)=>{var i=zn(),x=Zm(),T=sa(),E=x.DEFAULT_COMPARATOR,s=x.reverseComparator;function y(d,v,m,S){for(var M=v[S],w,C;S>m;){if(w=S-1>>1,C=v[w],d(M,C)<0){v[S]=C,S=w;continue}break}v[S]=M}function e(d,v,m){for(var S=v.length,M=m,w=v[m],C=2*m+1,A;C=0&&(C=A),v[m]=v[C],m=C,C=2*m+1;v[m]=w,y(d,v,M,m)}function r(d,v,m){v.push(m),y(d,v,0,v.length-1)}function p(d,v){var m=v.pop();if(v.length!==0){var S=v[0];return v[0]=m,e(d,v,0),S}return m}function h(d,v,m){if(v.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var S=v[0];return v[0]=m,e(d,v,0),S}function a(d,v,m){var S;return v.length!==0&&d(v[0],m)<0&&(S=v[0],v[0]=m,m=S,e(d,v,0)),m}function l(d,v){for(var m=v.length,S=m>>1,M=S;--M>=0;)e(d,v,M)}function n(d,v){for(var m=v.length,S=0,M=new Array(m);S=m.length)return m.slice().sort(d);for(P=m.slice(0,v),l(S,P),M=v,w=m.length;M0&&h(S,P,m[M]);return P.sort(d)}var b=T.guessLength(m);return b!==null&&b0&&h(S,P,O)),M++}),P.length>M&&(P.length=M),P.sort(d)}function f(d,v,m){arguments.length===2&&(m=v,v=d,d=E);var S=s(d),M,w,C,A=-1/0,P;if(v===1){if(T.isArrayLike(m)){for(M=0,w=m.length;M0)&&(A=C);return P=new m.constructor(1),P[0]=A,P}return i(m,function(O){(A===-1/0||d(O,A)>0)&&(A=O)}),[A]}if(T.isArrayLike(m)){if(v>=m.length)return m.slice().sort(S);for(P=m.slice(0,v),l(d,P),M=v,w=m.length;M0&&h(d,P,m[M]);return P.sort(S)}var b=T.guessLength(m);return b!==null&&b0&&h(d,P,O)),M++}),P.length>M&&(P.length=M),P.sort(S)}function o(d){if(this.clear(),this.comparator=d||E,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}o.prototype.clear=function(){this.items=[],this.size=0},o.prototype.push=function(d){return r(this.comparator,this.items,d),++this.size},o.prototype.peek=function(){return this.items[0]},o.prototype.pop=function(){return this.size!==0&&this.size--,p(this.comparator,this.items)},o.prototype.replace=function(d){return h(this.comparator,this.items,d)},o.prototype.pushpop=function(d){return a(this.comparator,this.items,d)},o.prototype.consume=function(){return this.size=0,n(this.comparator,this.items)},o.prototype.toArray=function(){return n(this.comparator,this.items.slice())},o.prototype.inspect=function(){var d=this.toArray();return Object.defineProperty(d,"constructor",{value:o,enumerable:!1}),d},typeof Symbol<"u"&&(o.prototype[Symbol.for("nodejs.util.inspect.custom")]=o.prototype.inspect);function c(d){if(this.clear(),this.comparator=d||E,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=s(this.comparator)}c.prototype=o.prototype,o.from=function(d,v){var m=new o(v),S;return T.isArrayLike(d)?S=d.slice():S=T.toArray(d),l(m.comparator,S),m.items=S,m.size=S.length,m},c.from=function(d,v){var m=new c(v),S;return T.isArrayLike(d)?S=d.slice():S=T.toArray(d),l(m.comparator,S),m.items=S,m.size=S.length,m},o.siftUp=e,o.siftDown=y,o.push=r,o.pop=p,o.replace=h,o.pushpop=a,o.heapify=l,o.consume=n,o.nsmallest=u,o.nlargest=f,o.MinHeap=o,o.MaxHeap=c,t.exports=o}),BF=si((g,t)=>{var i="";function x(r,p,h){for(var a=p.length,l=[],n=a,u=-1,f,o=0,c;n--;)u=Math.max(r[p[n]+h],u);for(c=u>>24&&32||u>>16&&24||u>>8&&16||8;o>o&15].push(p[n]);for(f=0;f<16;f++)for(u=l[f].length;u--;)p[++n]=l[f][u]}}function T(r,p,h,a){return r[h]-r[a]||(h%3===2?r[h+1]-r[a+1]||p[h+2]-p[a+2]:p[h+1]-p[a+1])}function E(r,p){var h=[],a=[],l=2*p/3|0,n=p-l,u=l+1>>1,f=l,o=0,c,d=[],v=[];if(p===1)return[0];for(;f--;)h[f]=(f*3>>1)+1;for(f=3;f--;)x(r,h,f);for(o=a[(h[0]/3|0)+(h[0]%3===1?0:u)]=1,f=1;fthis.firstLength&&n>this.firstLength)){for(p=Math.min(this.length-l,this.length-n),a=0;ar.length&&(r=this.text.slice(l,l+p))}return r},e.prototype.toString=function(){return this.array.join(",")},e.prototype.toJSON=function(){return this.array},e.prototype.inspect=function(){for(var r=new Array(this.length),p=0;p{var i=zn();function x(r){this.size=0,this.items=new Map,this.inverse=r}function T(){this.size=0,this.items=new Map,this.inverse=new x(this)}function E(){this.size=0,this.items.clear(),this.inverse.items.clear()}T.prototype.clear=E,x.prototype.clear=E;function s(r,p){if(this.items.has(r)){var h=this.items.get(r);if(h===p)return this;this.inverse.items.delete(h)}if(this.inverse.items.has(p)){var a=this.inverse.items.get(p);if(a===r)return this;this.items.delete(a)}return this.items.set(r,p),this.inverse.items.set(p,r),this.size=this.items.size,this.inverse.size=this.inverse.items.size,this}T.prototype.set=s,x.prototype.set=s;function y(r){if(this.items.has(r)){var p=this.items.get(r);return this.items.delete(r),this.inverse.items.delete(p),this.size=this.items.size,this.inverse.size=this.inverse.items.size,!0}return!1}T.prototype.delete=y,x.prototype.delete=y;var e=["has","get","forEach","keys","values","entries"];e.forEach(function(r){T.prototype[r]=x.prototype[r]=function(){return Map.prototype[r].apply(this.items,arguments)}}),typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.entries,x.prototype[Symbol.iterator]=x.prototype.entries),T.prototype.inspect=function(){var r={left:this.items,right:this.inverse.items};return Object.defineProperty(r,"constructor",{value:T,enumerable:!1}),r},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),x.prototype.inspect=function(){var r={left:this.inverse.items,right:this.items};return Object.defineProperty(r,"constructor",{value:x,enumerable:!1}),r},typeof Symbol<"u"&&(x.prototype[Symbol.for("nodejs.util.inspect.custom")]=x.prototype.inspect),T.from=function(r){var p=new T;return i(r,function(h,a){p.set(a,h)}),p},t.exports=T}),Vr=si((g,t)=>{function i(x){if(typeof x!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=x}typeof Symbol<"u"&&(i.prototype[Symbol.iterator]=function(){return this}),i.of=function(){var x=arguments,T=x.length,E=0;return new i(function(){return E>=T?{done:!0}:{done:!1,value:x[E++]}})},i.empty=function(){var x=new i(function(){return{done:!0}});return x},i.fromSequence=function(x){var T=0,E=x.length;return new i(function(){return T>=E?{done:!0}:{done:!1,value:x[T++]}})},i.is=function(x){return x instanceof i?!0:typeof x=="object"&&x!==null&&typeof x.next=="function"},t.exports=i}),VM=si(g=>{function t(s){return s|=s>>1,s|=s>>2,s|=s>>4,s|=s>>8,s|=s>>16,s&~(s>>1)}g.msb32=t;function i(s){return s|=s>>1,s|=s>>2,s|=s>>4,s&~(s>>1)}g.msb8=i,g.test=function(s,y){return s>>y&1},g.criticalBit8=function(s,y){return i(s^y)},g.criticalBit8Mask=function(s,y){return~i(s^y)>>>0&255},g.testCriticalBit8=function(s,y){return 1+(s|y)>>8},g.criticalBit32Mask=function(s,y){return~t(s^y)>>>0&4294967295},g.popcount=function(s){return s-=s>>1&1431655765,s=(s&858993459)+(s>>2&858993459),s=s+(s>>4)&252645135,s+=s>>8,s+=s>>16,s&127};var x=new Uint8Array(Math.pow(2,8));for(T=0,E=x.length;T>8&255]+x[s>>16&255]+x[s>>24&255]}}),zF=si((g,t)=>{var i=Vr(),x=VM();function T(E){this.length=E,this.clear()}T.prototype.clear=function(){this.size=0,this.array=new Uint32Array(Math.ceil(this.length/32))},T.prototype.set=function(E,s){var y=E>>5,e=E&31,r=this.array[y],p;return s===0||s===!1?p=this.array[y]&=~(1<>>0,p>r?this.size++:p>5,y=E&31,e=this.array[s],r;return r=this.array[s]&=~(1<>5,y=E&31,e=this.array[s],r=this.array[s]^=1<>>0,r>e?this.size++:r>5,y=E&31;return this.array[s]>>y&1},T.prototype.test=function(E){return!!this.get(E)},T.prototype.rank=function(E){if(this.size===0)return 0;for(var s=E>>5,y=E&31,e=0,r=0;r=this.length)return-1;for(var s,y=32,e=0,r=0,p=0,h=this.array.length;p>a&1,r===E)return e}},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=this.length,e,r,p=32,h=0,a=this.array.length;h>l&1,E.call(s,r,h*32+l)}},T.prototype.values=function(){var E=this.length,s=!1,y,e,r=this.array,p=r.length,h=0,a=-1,l=32;return new i(function n(){if(!s){if(h>=p)return{done:!0};h===p-1&&(l=E%32||32),y=r[h++],s=!0,a=-1}return a++,a>=l?(s=!1,n()):(e=y>>a&1,{value:e})})},T.prototype.entries=function(){var E=this.length,s=!1,y,e,r=this.array,p,h=r.length,a=0,l=-1,n=32;return new i(function u(){if(!s){if(a>=h)return{done:!0};a===h-1&&(n=E%32||32),y=r[a++],s=!0,l=-1}return l++,p=~-a*32+l,l>=n?(s=!1,u()):(e=y>>l&1,{value:[p,e]})})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=new Uint8Array(this.length);return this.forEach(function(s,y){E[y]=s}),Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.prototype.toJSON=function(){return Array.from(this.array)},t.exports=T}),GF=si((g,t)=>{var i=Vr(),x=VM(),T=function(y){return Math.max(1,Math.ceil(y*1.5))};function E(y){return new Uint32Array(Math.ceil(y/32))}function s(y){var e=y||0,r=T;typeof y=="object"&&(e=y.initialLength||y.initialCapacity||0,r=y.policy||r),this.size=0,this.length=e,this.capacity=Math.ceil(this.length/32)*32,this.policy=r,this.array=E(this.capacity)}s.prototype.set=function(y,e){if(this.length>5,p=y&31,h=this.array[r],a;return e===0||e===!1?a=this.array[r]&=~(1<>>0,a>h?this.size++:a>5,r=y&31,p=this.array[e],h;return h=this.array[e]&=~(1<>5,r=y&31,p=this.array[e],h=this.array[e]^=1<>>0,h>p?this.size++:hthis.array.length?(this.array=new Uint32Array(p),this.array.set(r,0)):this.array=r.slice(0,p),this.capacity=y,this)},s.prototype.grow=function(y){var e;if(typeof y=="number"){if(this.capacity>=y)return this;for(e=this.capacity;e>5,p=e&31;return this.array[r]|=1<>5,r=y&31;return this.array[e]>>r&1}},s.prototype.get=function(y){if(!(this.length>5,r=y&31;return this.array[e]>>r&1}},s.prototype.test=function(y){return this.length>5,r=y&31,p=0,h=0;h=this.length)return-1;for(var e,r=32,p=0,h=0,a=0,l=this.array.length;a>n&1,h===y)return p}},s.prototype.forEach=function(y,e){e=arguments.length>1?e:this;for(var r=this.length,p,h,a=32,l=0,n=this.array.length;l>u&1,y.call(e,h,l*32+u)}},s.prototype.values=function(){var y=this.length,e=!1,r,p,h=this.array,a=h.length,l=0,n=-1,u=32;return new i(function f(){if(!e){if(l>=a)return{done:!0};l===a-1&&(u=y%32||32),r=h[l++],e=!0,n=-1}return n++,n>=u?(e=!1,f()):(p=r>>n&1,{value:p})})},s.prototype.entries=function(){var y=this.length,e=!1,r,p,h=this.array,a,l=h.length,n=0,u=-1,f=32;return new i(function o(){if(!e){if(n>=l)return{done:!0};n===l-1&&(f=y%32||32),r=h[n++],e=!0,u=-1}return u++,a=~-n*32+u,u>=f?(e=!1,o()):(p=r>>u&1,{value:[a,p]})})},typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=s.prototype.values),s.prototype.inspect=function(){var y=new Uint8Array(this.length);return this.forEach(function(e,r){y[r]=e}),Object.defineProperty(y,"constructor",{value:s,enumerable:!1}),y},typeof Symbol<"u"&&(s.prototype[Symbol.for("nodejs.util.inspect.custom")]=s.prototype.inspect),s.prototype.toJSON=function(){return Array.from(this.array.slice(0,(this.length>>5)+1))},t.exports=s}),VF=si((g,t)=>{function i(E,s){return(E&65535)*s+(((E>>>16)*s&65535)<<16)&4294967295}function x(E,s){return(E&65535)+(s>>>16)+(((E>>>16)+s&65535)<<16)&4294967295}function T(E,s){return E<>>32-s}t.exports=function(E,s){var y=3432918353,e=461845907,r=15,p=13,h=5,a=1801774676,l=E,n,u,f;for(u=0,f=s.length-4;u<=f;u+=4)n=s[u]|s[u+1]<<8|s[u+2]<<16|s[u+3]<<24,n=i(n,y),n=T(n,r),n=i(n,e),l^=n,l=T(l,p),l=i(l,h),l=x(l,a);switch(n=0,s.length&3){case 3:n^=s[u+2]<<16;case 2:n^=s[u+1]<<8;case 1:n^=s[u],n=i(n,y),n=T(n,r),n=i(n,e),l^=n}return l^=s.length,l^=l>>>16,l=i(l,2246822507),l^=l>>>13,l=i(l,3266489909),l^=l>>>16,l>>>0}}),HF=si((g,t)=>{var i=VF(),x=zn(),T=Math.LN2*Math.LN2,E={errorRate:.005};function s(r){var p=new Uint16Array(r.length),h,a;for(h=0,a=r.length;h>3]|=n}return this},e.prototype.test=function(r){for(var p=s(r),h=0,a=this.hashFunctions;h>3]&1<<(7&l)))return!1}return!0},e.prototype.toJSON=function(){return this.data},e.from=function(r,p){if(!p&&(p=r.length||r.size,typeof p!="number"))throw new Error("BloomFilter.from: could not infer the filter's capacity. Try passing it as second argument.");var h=new e(p);return x(r,function(a){h.add(a)}),h},t.exports=e}),WF=si((g,t)=>{var i=zn();function x(T){if(typeof T!="function")throw new Error("mnemonist/BKTree.constructor: given `distance` should be a function.");this.distance=T,this.clear()}x.prototype.add=function(T){if(!this.root)return this.root={item:T,children:{}},this.size++,this;for(var E=this.root,s;s=this.distance(T,E.item),!!E.children[s];)E=E.children[s];return E.children[s]={item:T,children:{}},this.size++,this},x.prototype.search=function(T,E){if(!this.root)return[];for(var s=[],y=[this.root],e,r,p,h,a;y.length;)for(e=y.pop(),p=this.distance(E,e.item),p<=T&&s.push({item:e.item,distance:p}),h=p-T,a=p+T+1;h{var i=sa(),x=Vr();function T(E,s){if(arguments.length<2)throw new Error("mnemonist/fixed-deque: expecting an Array class and a capacity.");if(typeof s!="number"||s<=0)throw new Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=E,this.capacity=s,this.items=new E(this.capacity),this.clear()}T.prototype.clear=function(){this.start=0,this.size=0},T.prototype.push=function(E){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.push: deque capacity ("+this.capacity+") exceeded!");var s=this.start+this.size;return s>=this.capacity&&(s-=this.capacity),this.items[s]=E,++this.size},T.prototype.unshift=function(E){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var s=this.start-1;return this.start===0&&(s=this.capacity-1),this.items[s]=E,this.start=s,++this.size},T.prototype.pop=function(){if(this.size!==0){this.size--;var E=this.start+this.size;return E>=this.capacity&&(E-=this.capacity),this.items[E]}},T.prototype.shift=function(){if(this.size!==0){var E=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[E]}},T.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},T.prototype.peekLast=function(){if(this.size!==0){var E=this.start+this.size-1;return E>=this.capacity&&(E-=this.capacity),this.items[E]}},T.prototype.get=function(E){if(!(this.size===0||E>=this.capacity))return E=this.start+E,E>=this.capacity&&(E-=this.capacity),this.items[E]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=this.capacity,e=this.size,r=this.start,p=0;p=y)return{done:!0};var p=E[e];return e++,r++,e===s&&(e=0),{value:p,done:!1}})},T.prototype.entries=function(){var E=this.items,s=this.capacity,y=this.size,e=this.start,r=0;return new x(function(){if(r>=y)return{done:!0};var p=E[e];return e++,e===s&&(e=0),{value:[r++,p],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=this.toArray();return E.type=this.ArrayClass.name,E.capacity=this.capacity,Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E,s,y){if(arguments.length<3&&(y=i.guessLength(E),typeof y!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var e=new T(s,y);if(i.isArrayLike(E)){var r,p;for(r=0,p=E.length;r{var i=sa(),x=HM();function T(s,y){if(arguments.length<2)throw new Error("mnemonist/circular-buffer: expecting an Array class and a capacity.");if(typeof y!="number"||y<=0)throw new Error("mnemonist/circular-buffer: `capacity` should be a positive number.");this.ArrayClass=s,this.capacity=y,this.items=new s(this.capacity),this.clear()}function E(s){T.prototype[s]=x.prototype[s]}Object.keys(x.prototype).forEach(E),typeof Symbol<"u"&&Object.getOwnPropertySymbols(x.prototype).forEach(E),T.prototype.push=function(s){var y=this.start+this.size;return y>=this.capacity&&(y-=this.capacity),this.items[y]=s,this.size===this.capacity?(y++,y>=this.capacity?this.start=0:this.start=y,this.size):++this.size},T.prototype.unshift=function(s){var y=this.start-1;return this.start===0&&(y=this.capacity-1),this.items[y]=s,this.size===this.capacity?(this.start=y,this.size):(this.start=y,++this.size)},T.from=function(s,y,e){if(arguments.length<3&&(e=i.guessLength(s),typeof e!="number"))throw new Error("mnemonist/circular-buffer.from: could not guess iterable length. Please provide desired capacity as last argument.");var r=new T(y,e);if(i.isArrayLike(s)){var p,h;for(p=0,h=s.length;p{function i(x){if(typeof x!="function")throw new Error("mnemonist/DefaultMap.constructor: expecting a function.");this.items=new Map,this.factory=x,this.size=0}i.prototype.clear=function(){this.items.clear(),this.size=0},i.prototype.get=function(x){var T=this.items.get(x);return typeof T>"u"&&(T=this.factory(x,this.size),this.items.set(x,T),this.size++),T},i.prototype.peek=function(x){return this.items.get(x)},i.prototype.set=function(x,T){return this.items.set(x,T),this.size=this.items.size,this},i.prototype.has=function(x){return this.items.has(x)},i.prototype.delete=function(x){var T=this.items.delete(x);return this.size=this.items.size,T},i.prototype.forEach=function(x,T){T=arguments.length>1?T:this,this.items.forEach(x,T)},i.prototype.entries=function(){return this.items.entries()},i.prototype.keys=function(){return this.items.keys()},i.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(i.prototype[Symbol.iterator]=i.prototype.entries),i.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(i.prototype[Symbol.for("nodejs.util.inspect.custom")]=i.prototype.inspect),i.autoIncrement=function(){var x=0;return function(){return x++}},t.exports=i}),kF=si((g,t)=>{function i(x){if(typeof x!="function")throw new Error("mnemonist/DefaultWeakMap.constructor: expecting a function.");this.items=new WeakMap,this.factory=x}i.prototype.clear=function(){this.items=new WeakMap},i.prototype.get=function(x){var T=this.items.get(x);return typeof T>"u"&&(T=this.factory(x),this.items.set(x,T)),T},i.prototype.peek=function(x){return this.items.get(x)},i.prototype.set=function(x,T){return this.items.set(x,T),this},i.prototype.has=function(x){return this.items.has(x)},i.prototype.delete=function(x){return this.items.delete(x)},i.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(i.prototype[Symbol.for("nodejs.util.inspect.custom")]=i.prototype.inspect),t.exports=i}),KF=si((g,t)=>{var i=Is();function x(T){var E=i.getPointerArray(T),s=i.getPointerArray(Math.log2(T));this.size=T,this.dimension=T,this.parents=new E(T),this.ranks=new s(T);for(var y=0;yr?this.parents[y]=s:(this.parents[y]=s,this.ranks[s]++),this},x.prototype.connected=function(T,E){var s=this.find(T);return s===this.find(E)},x.prototype.mapping=function(){for(var T=i.getPointerArray(this.dimension),E={},s=new T(this.size),y=0,e,r=0,p=this.parents.length;r"u"?(s[r]=y,E[e]=y++):s[r]=E[e];return s},x.prototype.compile=function(){for(var T={},E=new Array(this.dimension),s=0,y,e=0,r=this.parents.length;e"u"?(E[s]=[e],T[y]=s++):E[T[y]].push(e);return E},x.prototype.inspect=function(){var T=this.compile();return Object.defineProperty(T,"constructor",{value:x,enumerable:!1}),T},typeof Symbol<"u"&&(x.prototype[Symbol.for("nodejs.util.inspect.custom")]=x.prototype.inspect),t.exports=x}),Wx=si((g,t)=>{var i=Zm(),x=Hx(),T=i.DEFAULT_COMPARATOR,E=i.reverseComparator;function s(r,p,h,a){for(var l=h,n=a,u=p[a],f=2*a+1,o;f=0&&(f=o),p[a]=p[f],a=f,f=2*a+1;p[a]=u,x.siftDown(r,p,n,a)}function y(r,p,h,a){for(var l=a,n=l,u=new r(a),f,o;n>0;)f=h[--n],n!==0&&(o=h[0],h[0]=f,s(p,h,--a,0),f=o),u[n]=f;return u}function e(r,p,h){if(arguments.length===2&&(h=p,p=null),this.ArrayClass=r,this.capacity=h,this.items=new r(h),this.clear(),this.comparator=p||T,typeof h!="number"&&h<=0)throw new Error("mnemonist/FixedReverseHeap.constructor: capacity should be a number > 0.");if(typeof this.comparator!="function")throw new Error("mnemonist/FixedReverseHeap.constructor: given comparator should be a function.");this.comparator=E(this.comparator)}e.prototype.clear=function(){this.size=0},e.prototype.push=function(r){return this.size0&&x.replace(this.comparator,this.items,r),this.size},e.prototype.peek=function(){return this.items[0]},e.prototype.consume=function(){var r=y(this.ArrayClass,this.comparator,this.items,this.size);return this.size=0,r},e.prototype.toArray=function(){return y(this.ArrayClass,this.comparator,this.items.slice(0,this.size),this.size)},e.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:e,enumerable:!1}),r},typeof Symbol<"u"&&(e.prototype[Symbol.for("nodejs.util.inspect.custom")]=e.prototype.inspect),t.exports=e}),jF=si((g,t)=>{var i=zn(),x=function(E){return E};function T(E){if(this.items=new Map,this.clear(),Array.isArray(E)?(this.writeHashFunction=E[0],this.readHashFunction=E[1]):(this.writeHashFunction=E,this.readHashFunction=E),this.writeHashFunction||(this.writeHashFunction=x),this.readHashFunction||(this.readHashFunction=x),typeof this.writeHashFunction!="function")throw new Error("mnemonist/FuzzyMap.constructor: invalid hash function given.");if(typeof this.readHashFunction!="function")throw new Error("mnemonist/FuzzyMap.constructor: invalid hash function given.")}T.prototype.clear=function(){this.items.clear(),this.size=0},T.prototype.add=function(E){var s=this.writeHashFunction(E);return this.items.set(s,E),this.size=this.items.size,this},T.prototype.set=function(E,s){return E=this.writeHashFunction(E),this.items.set(E,s),this.size=this.items.size,this},T.prototype.get=function(E){return E=this.readHashFunction(E),this.items.get(E)},T.prototype.has=function(E){return E=this.readHashFunction(E),this.items.has(E)},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this,this.items.forEach(function(y){E.call(s,y,y)})},T.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=Array.from(this.items.values());return Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E,s,y){var e=new T(s);return i(E,function(r,p){y?e.set(p,r):e.add(r)}),e},t.exports=T}),WM=si((g,t)=>{var i=Vr(),x=zn();function T(E){this.Container=E||Array,this.items=new Map,this.clear(),Object.defineProperty(this.items,"constructor",{value:T,enumerable:!1})}T.prototype.clear=function(){this.size=0,this.dimension=0,this.items.clear()},T.prototype.set=function(E,s){var y=this.items.get(E),e;return y||(this.dimension++,y=new this.Container,this.items.set(E,y)),this.Container===Set?(e=y.size,y.add(s),e"u"?0:this.Container===Set?s.size:s.length},T.prototype.count=T.prototype.multiplicity,T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;var y;function e(r){E.call(s,r,y)}this.items.forEach(function(r,p){y=p,r.forEach(e)})},T.prototype.forEachAssociation=function(E,s){s=arguments.length>1?s:this,this.items.forEach(E,s)},T.prototype.keys=function(){return this.items.keys()},T.prototype.values=function(){var E=this.items.values(),s=!1,y,e,r,p;return this.Container===Set?new i(function h(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,y=e.value.values()}return e=y.next(),e.done?(s=!1,h()):{done:!1,value:e.value}}):new i(function h(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,y=e.value,r=0,p=y.length}return r>=p?(s=!1,h()):{done:!1,value:y[r++]}})},T.prototype.entries=function(){var E=this.items.entries(),s=!1,y,e,r,p,h;return this.Container===Set?new i(function a(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,r=e.value[0],y=e.value[1].values()}return e=y.next(),e.done?(s=!1,a()):{done:!1,value:[r,e.value]}}):new i(function a(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,r=e.value[0],y=e.value[1],p=0,h=y.length}return p>=h?(s=!1,a()):{done:!1,value:[r,y[p++]]}})},T.prototype.containers=function(){return this.items.values()},T.prototype.associations=function(){return this.items.entries()},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.entries),T.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.prototype.toJSON=function(){return this.items},T.from=function(E,s){var y=new T(s);return x(E,function(e,r){y.set(r,e)}),y},t.exports=T}),ZF=si((g,t)=>{var i=WM(),x=zn(),T=function(s){return s};function E(s,y){if(this.items=new i(y),this.clear(),Array.isArray(s)?(this.writeHashFunction=s[0],this.readHashFunction=s[1]):(this.writeHashFunction=s,this.readHashFunction=s),this.writeHashFunction||(this.writeHashFunction=T),this.readHashFunction||(this.readHashFunction=T),typeof this.writeHashFunction!="function")throw new Error("mnemonist/FuzzyMultiMap.constructor: invalid hash function given.");if(typeof this.readHashFunction!="function")throw new Error("mnemonist/FuzzyMultiMap.constructor: invalid hash function given.")}E.prototype.clear=function(){this.items.clear(),this.size=0,this.dimension=0},E.prototype.add=function(s){var y=this.writeHashFunction(s);return this.items.set(y,s),this.size=this.items.size,this.dimension=this.items.dimension,this},E.prototype.set=function(s,y){return s=this.writeHashFunction(s),this.items.set(s,y),this.size=this.items.size,this.dimension=this.items.dimension,this},E.prototype.get=function(s){return s=this.readHashFunction(s),this.items.get(s)},E.prototype.has=function(s){return s=this.readHashFunction(s),this.items.has(s)},E.prototype.forEach=function(s,y){y=arguments.length>1?y:this,this.items.forEach(function(e){s.call(y,e,e)})},E.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=E.prototype.values),E.prototype.inspect=function(){var s=Array.from(this);return Object.defineProperty(s,"constructor",{value:E,enumerable:!1}),s},typeof Symbol<"u"&&(E.prototype[Symbol.for("nodejs.util.inspect.custom")]=E.prototype.inspect),E.from=function(s,y,e,r){arguments.length===3&&typeof e=="boolean"&&(r=e,e=Array);var p=new E(y,e);return x(s,function(h,a){r?p.set(a,h):p.add(h)}),p},t.exports=E}),JF=si((g,t)=>{var i=1024;function x(E){return(E&E-1)===0}function T(E,s){if(arguments.length<1)throw new Error("mnemonist/hashed-array-tree: expecting at least a byte array constructor.");var y=s||0,e=i,r=0;if(typeof s=="object"&&(y=s.initialCapacity||0,r=s.initialLength||0,e=s.blockSize||i),!e||!x(e))throw new Error("mnemonist/hashed-array-tree: block size should be a power of two.");var p=Math.max(r,y),h=Math.ceil(p/e);this.ArrayClass=E,this.length=r,this.capacity=h*e,this.blockSize=e,this.offsetMask=e-1,this.blockMask=Math.log2(e),this.blocks=new Array(h);for(var a=0;a>this.blockMask,e=E&this.offsetMask;return this.blocks[y][e]=s,this},T.prototype.get=function(E){if(!(this.length>this.blockMask,y=E&this.offsetMask;return this.blocks[s][y]}},T.prototype.grow=function(E){if(typeof E!="number"&&(E=this.capacity+this.blockSize),this.capacity>=E)return this;for(;this.capacity>this.blockMask,e=s&this.offsetMask;return this.blocks[y][e]=E,++this.length},T.prototype.pop=function(){if(this.length!==0){var E=this.blocks[this.blocks.length-1],s=--this.length&this.offsetMask;return E[s]}},T.prototype.inspect=function(){for(var E=new this.ArrayClass(this.length),s,y=0,e=this.length;y>this.blockMask,E[y]=this.blocks[s][y&this.offsetMask];return E.type=this.ArrayClass.name,E.items=this.length,E.capacity=this.capacity,E.blockSize=this.blockSize,Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),t.exports=T}),XM=si((g,t)=>{var i=Vr(),x=sa();function T(E,s){if(arguments.length<2)throw new Error("mnemonist/fixed-stack: expecting an Array class and a capacity.");if(typeof s!="number"||s<=0)throw new Error("mnemonist/fixed-stack: `capacity` should be a positive number.");this.capacity=s,this.ArrayClass=E,this.items=new this.ArrayClass(this.capacity),this.clear()}T.prototype.clear=function(){this.size=0},T.prototype.push=function(E){if(this.size===this.capacity)throw new Error("mnemonist/fixed-stack.push: stack capacity ("+this.capacity+") exceeded!");return this.items[this.size++]=E,this.size},T.prototype.pop=function(){if(this.size!==0)return this.items[--this.size]},T.prototype.peek=function(){return this.items[this.size-1]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=0,e=this.items.length;y=s)return{done:!0};var e=E[s-y-1];return y++,{value:e,done:!1}})},T.prototype.entries=function(){var E=this.items,s=this.size,y=0;return new i(function(){if(y>=s)return{done:!0};var e=E[s-y-1];return{value:[y++,e],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.toString=function(){return this.toArray().join(",")},T.prototype.toJSON=function(){return this.toArray()},T.prototype.inspect=function(){var E=this.toArray();return E.type=this.ArrayClass.name,E.capacity=this.capacity,Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E,s,y){if(arguments.length<3&&(y=x.guessLength(E),typeof y!="number"))throw new Error("mnemonist/fixed-stack.from: could not guess iterable length. Please provide desired capacity as last argument.");var e=new T(s,y);if(x.isArrayLike(E)){var r,p;for(r=0,p=E.length;r{var i=sa(),x=Is(),T=XM();function E(y,e,r,p,h,a,l,n){var u=l+(n-l)/2|0,f=~-u,o=-~u,c=r[u];p[a]=c+1;var d=e?e(y[c]):y[c][1],v=a*2+1,m=a*2+2,S=-1/0,M=-1/0;l<=f&&(S=E(y,e,r,p,h,v,l,f)),o<=n&&(M=E(y,e,r,p,h,m,o,n));var w=Math.max(d,S,M),C=c;return w===S?C=h[p[v]-1]:w===M&&(C=h[p[m]-1]),h[c]=C,w}function s(y,e){this.size=y.length,this.intervals=y;var r=null,p=null;Array.isArray(e)&&(r=e[0],p=e[1]);var h=y.length,a=x.getPointerArray(h+1),l=new a(h),n;for(n=1;nv?1:0});var u=Math.ceil(Math.log2(h+1)),f=Math.pow(2,u)-1,o=new a(f),c=new a(h);E(y,p,l,o,c,0,0,h-1),l=null,this.height=u,this.tree=o,this.augmentations=c,this.startGetter=r,this.endGetter=p,this.stack=new T(a,this.height)}s.prototype.intervalsContainingPoint=function(y){var e=[],r=this.stack;r.clear(),r.push(0);for(var p=this.tree.length,h,a,l,n,u,f,o,c,d;r.size;)h=r.pop(),a=this.tree[h]-1,l=this.intervals[a],n=this.intervals[this.augmentations[a]],o=this.endGetter?this.endGetter(n):n[1],!(y>o)&&(c=h*2+1,c=u&&y<=f&&e.push(l),!(yd)&&(v=l*2+1,v=o&&e<=c&&p.push(u),!(r{g.search=function(t,i,x,T){var E=0;x=typeof x<"u"?x:0,T=typeof T<"u"?T:t.length,T--;for(var s;x<=T;)if(E=x+T>>>1,s=t[E],s>i)T=~-E;else if(s>>1,y=t(i[T],x),y>0)s=~-T;else if(y<0)E=-~T;else return T;return-1},g.lowerBound=function(t,i,x,T){var E=0;for(x=typeof x<"u"?x:0,T=typeof T<"u"?T:t.length;x>>1,i<=t[E]?T=E:x=-~E;return x},g.lowerBoundWithComparator=function(t,i,x){for(var T=0,E=0,s=i.length;E>>1,t(x,i[T])<=0?s=T:E=-~T;return E},g.lowerBoundIndices=function(t,i,x,T,E){var s=0;for(T=typeof T<"u"?T:0,E=typeof E<"u"?E:t.length;T>>1,x<=t[i[s]]?E=s:T=-~s;return T},g.upperBound=function(t,i,x,T){var E=0;for(x=typeof x<"u"?x:0,T=typeof T<"u"?T:t.length;x>>1,i>=t[E]?x=-~E:T=E;return x},g.upperBoundWithComparator=function(t,i,x){for(var T=0,E=0,s=i.length;E>>1,t(x,i[T])>=0?E=-~T:s=T;return E}}),QF=si(g=>{var t=Is(),i=sa().isArrayLike,x=YM(),T=Vx();function E(r,p){if(r.length===0)return p.slice();if(p.length===0)return r.slice();var h;r[0]>p[0]&&(h=r,r=p,p=h);var a=r[r.length-1],l=p[0];if(a<=l)return t.isTypedArray(r)?t.concat(r,p):r.concat(p);var n=new r.constructor(r.length+p.length),u,f,o;for(u=0,f=r.length;up[0]&&(h=r,r=p,p=h);var a=r[r.length-1],l=p[0];if(ap[0]&&(h=r,r=p,p=h);var a=r[r.length-1],l=p[0];if(av?o=x.lowerBound(p,d,o+1):(n.push(d),u++,o++);return n};function y(r){var p=0,h=-1/0,a,l,n,u=[];for(l=0,n=r.length;lh&&(h=a));if(u.length===0)return new r[0].constructor(0);if(u.length===1)return u[0].slice();if(u.length===2)return E(u[0],u[1]);r=u;var f=new r[0].constructor(p),o=t.getPointerArray(h),c=new o(r.length),d=new T(function(S,M){return S=r[S][c[S]],M=r[M][c[M]],SM?1:0});for(l=0;lp&&(p=h));if(n.length===0)return new r[0].constructor(0);if(n.length===1)return n[0].slice();if(n.length===2)return s(n[0],n[1]);r=n;var u=new r[0].constructor,f=t.getPointerArray(p),o=new f(r.length),c=new T(function(m,S){return m=r[m][o[m]],S=r[S][o[S]],mS?1:0});for(a=0;ap&&(p=a),lh)return[];if(p===h)return[p];var o,c,d=r[0],v,m,S,M,w,C,A=p;for(u=1;uC?m=x.lowerBound(c,w,m+1):(d.push(w),v++,m++);if(d.length===0)return d;A=d[0]}return d},g.merge=function(){if(arguments.length===2){if(i(arguments[0]))return E(arguments[0],arguments[1])}else if(i(arguments[0]))return y(arguments);return null},g.unionUnique=function(){if(arguments.length===2){if(i(arguments[0]))return s(arguments[0],arguments[1])}else if(i(arguments[0]))return e(arguments);return null},g.intersectionUnique=function(){if(arguments.length===2){if(i(arguments[0]))return g.intersectionUniqueArrays(arguments[0],arguments[1])}else if(i(arguments[0]))return g.kWayIntersectionUniqueArrays(arguments);return null}}),_F=si((g,t)=>{var i=Vr(),x=zn(),T=QF();function E(y){return y}function s(y){if(this.clear(),Array.isArray(y)?(this.documentTokenizer=y[0],this.queryTokenizer=y[1]):(this.documentTokenizer=y,this.queryTokenizer=y),this.documentTokenizer||(this.documentTokenizer=E),this.queryTokenizer||(this.queryTokenizer=E),typeof this.documentTokenizer!="function")throw new Error("mnemonist/InvertedIndex.constructor: document tokenizer is not a function.");if(typeof this.queryTokenizer!="function")throw new Error("mnemonist/InvertedIndex.constructor: query tokenizer is not a function.")}s.prototype.clear=function(){this.items=[],this.mapping=new Map,this.size=0,this.dimension=0},s.prototype.add=function(y){this.size++;var e=this.items.length;this.items.push(y);var r=this.documentTokenizer(y);if(!Array.isArray(r))throw new Error("mnemonist/InvertedIndex.add: tokenizer function should return an array of tokens.");for(var p=new Set,h,a,l=0,n=r.length;l"u"||r.length===0)return[];if(e.length>1)for(h=1,a=e.length;h"u"||p.length===0)return[];r=T.intersectionUniqueArrays(r,p)}var l=new Array(r.length);for(h=0,a=l.length;h1?e:this;for(var r=0,p=this.documents.length;r=e)return{done:!0};var p=y[r++];return{value:p,done:!1}})},s.prototype.tokens=function(){return this.mapping.keys()},typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=s.prototype.documents),s.prototype.inspect=function(){var y=this.items.slice();return Object.defineProperty(y,"constructor",{value:s,enumerable:!1}),y},typeof Symbol<"u"&&(s.prototype[Symbol.for("nodejs.util.inspect.custom")]=s.prototype.inspect),s.from=function(y,e){var r=new s(e);return x(y,function(p){r.add(p)}),r},t.exports=s}),kM=si(g=>{var t=new Float64Array(64),i=new Float64Array(64);function x(E,s,y){var e,r,p,h,a;for(t[0]=s,i[0]=y,r=0;r>=0;)if(p=t[r],h=i[r]-1,p=e&&pi[r-1]-t[r-1]&&(a=t[r],t[r]=t[r-1],t[r-1]=a,a=i[r],i[r]=i[r-1],i[r-1]=a)}else r--;return E}g.inplaceQuickSort=x;function T(E,s,y,e){var r,p,h,a,l,n;for(t[0]=y,i[0]=e,p=0;p>=0;)if(h=t[p],a=i[p]-1,h=r&&hi[p-1]-t[p-1]&&(n=t[p],t[p]=t[p-1],t[p-1]=n,n=i[p],i[p]=i[p-1],i[p-1]=n)}else p--;return s}g.inplaceQuickSortIndices=T}),qF=si((g,t)=>{var i=sa(),x=Is(),T=Zm().createTupleComparator,E=Wx(),s=kM().inplaceQuickSortIndices;function y(l,n,u,f){var o,c=0,d;for(o=0;o>>1),P=u[A],d[D]=P,w>-1&&(C===0?v[w]=D+1:m[w]=D+1),I=(I+1)%l,A!==b&&A!==O-1&&S.push([I,A+1,O,D,1]),A!==b&&S.push([I,b,A,D,0]),D++;return{axes:n,labels:f,pivots:d,lefts:v,rights:m}}function p(l,n){this.dimensions=l,this.visited=0,this.axes=n.axes,this.labels=n.labels,this.pivots=n.pivots,this.lefts=n.lefts,this.rights=n.rights,this.size=this.labels.length}p.prototype.nearestNeighbor=function(l){var n=1/0,u=null,f=this.dimensions,o=this.axes,c=this.pivots,d=this.lefts,v=this.rights,m=0;function S(M,w){m++;var C=d[w],A=v[w],P=c[w],b=y(f,o,P,l);if(!(b0?C!==0&&S(M,C-1):A!==0&&S(M,A-1),O*O0?A!==0&&S(M,A-1):C!==0&&S(M,C-1))}}return S(0,0),this.visited=m,this.labels[u]};var h=T(3),a=T(2);p.prototype.kNearestNeighbors=function(l,n){if(l<=0)throw new Error("mnemonist/kd-tree.kNearestNeighbors: k should be a positive number.");if(l=Math.min(l,this.size),l===1)return[this.nearestNeighbor(n)];var u=new E(Array,h,l),f=this.dimensions,o=this.axes,c=this.pivots,d=this.lefts,v=this.rights,m=0;function S(C,A){var P=d[A],b=v[A],O=c[A],I=y(f,o,O,n);u.push([I,m++,O]);var D=n[C],B=o[C][O],G=D-B;C=(C+1)%f,D{var i=Vr(),x=zn();function T(){this.clear()}T.prototype.clear=function(){this.head=null,this.tail=null,this.size=0},T.prototype.first=function(){return this.head?this.head.item:void 0},T.prototype.peek=T.prototype.first,T.prototype.last=function(){return this.tail?this.tail.item:void 0},T.prototype.push=function(E){var s={item:E,next:null};return this.head?(this.tail.next=s,this.tail=s):(this.head=s,this.tail=s),this.size++,this.size},T.prototype.unshift=function(E){var s={item:E,next:null};return this.head?(this.head.next||(this.tail=this.head),s.next=this.head,this.head=s):(this.head=s,this.tail=s),this.size++,this.size},T.prototype.shift=function(){if(this.size){var E=this.head;return this.head=E.next,this.size--,E.item}},T.prototype.forEach=function(E,s){if(this.size){s=arguments.length>1?s:this;for(var y=this.head,e=0;y;)E.call(s,y.item,e,this),y=y.next,e++}},T.prototype.toArray=function(){if(!this.size)return[];for(var E=new Array(this.size),s=0,y=this.size,e=this.head;s{var i=Vr(),x=zn(),T=Is(),E=sa();function s(y,e,r){if(arguments.length<2&&(r=y,y=null,e=null),this.capacity=r,typeof this.capacity!="number"||this.capacity<=0)throw new Error("mnemonist/lru-cache: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-cache: capacity should be a finite positive integer.");var p=T.getPointerArray(r);this.forward=new p(r),this.backward=new p(r),this.K=typeof y=="function"?new y(r):new Array(r),this.V=typeof e=="function"?new e(r):new Array(r),this.size=0,this.head=0,this.tail=0,this.items={}}s.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},s.prototype.splayOnTop=function(y){var e=this.head;if(this.head===y)return this;var r=this.backward[y],p=this.forward[y];return this.tail===y?this.tail=r:this.backward[p]=r,this.forward[r]=p,this.backward[e]=y,this.head=y,this.forward[y]=e,this},s.prototype.set=function(y,e){var r=this.items[y];if(typeof r<"u"){this.splayOnTop(r),this.V[r]=e;return}this.size1?e:this;for(var r=0,p=this.size,h=this.head,a=this.K,l=this.V,n=this.forward;r=e)return{done:!0};var a=p[r];return y++,y=e)return{done:!0};var a=p[r];return y++,y=e)return{done:!0};var l=p[r],n=h[r];return y++,y{var i=Xx(),x=zn(),T=Is(),E=sa();function s(e,r,p){arguments.length<2?i.call(this,e):i.call(this,e,r,p);var h=T.getPointerArray(this.capacity);this.deleted=new h(this.capacity),this.deletedSize=0}for(y in i.prototype)s.prototype[y]=i.prototype[y];var y;typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=i.prototype[Symbol.iterator]),s.prototype.clear=function(){i.prototype.clear.call(this),this.deletedSize=0},s.prototype.set=function(e,r){var p=this.items[e];if(typeof p<"u"){this.splayOnTop(p),this.V[p]=r;return}this.size0?p=this.deleted[--this.deletedSize]:p=this.size,this.size++):(p=this.tail,this.tail=this.backward[p],delete this.items[this.K[p]]),this.items[e]=p,this.K[p]=e,this.V[p]=r,this.forward[p]=this.head,this.backward[this.head]=p,this.head=p},s.prototype.setpop=function(e,r){var p=null,h=null,a=this.items[e];return typeof a<"u"?(this.splayOnTop(a),p=this.V[a],this.V[a]=r,{evicted:!1,key:e,value:p}):(this.size0?a=this.deleted[--this.deletedSize]:a=this.size,this.size++):(a=this.tail,this.tail=this.backward[a],p=this.V[a],h=this.K[a],delete this.items[h]),this.items[e]=a,this.K[a]=e,this.V[a]=r,this.forward[a]=this.head,this.backward[this.head]=a,this.head=a,h?{evicted:!0,key:h,value:p}:null)},s.prototype.delete=function(e){var r=this.items[e];if(typeof r>"u")return!1;if(delete this.items[e],this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var p=this.backward[r],h=this.forward[r];return this.head===r&&(this.head=h),this.tail===r&&(this.tail=p),this.forward[p]=h,this.backward[h]=p,this.size--,this.deleted[this.deletedSize++]=r,!0},s.prototype.remove=function(e,r=void 0){var p=this.items[e];if(typeof p>"u")return r;var h=this.V[p];if(delete this.items[e],this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,h;var a=this.backward[p],l=this.forward[p];return this.head===p&&(this.head=l),this.tail===p&&(this.tail=a),this.forward[a]=l,this.backward[l]=a,this.size--,this.deleted[this.deletedSize++]=p,h},s.from=function(e,r,p,h){if(arguments.length<2){if(h=E.guessLength(e),typeof h!="number")throw new Error("mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.")}else arguments.length===2&&(h=r,r=null,p=null);var a=new s(r,p,h);return x(e,function(l,n){a.set(n,l)}),a},t.exports=s}),KM=si((g,t)=>{var i=Xx(),x=zn(),T=Is(),E=sa();function s(y,e,r){if(arguments.length<2&&(r=y,y=null,e=null),this.capacity=r,typeof this.capacity!="number"||this.capacity<=0)throw new Error("mnemonist/lru-map: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-map: capacity should be a finite positive integer.");var p=T.getPointerArray(r);this.forward=new p(r),this.backward=new p(r),this.K=typeof y=="function"?new y(r):new Array(r),this.V=typeof e=="function"?new e(r):new Array(r),this.size=0,this.head=0,this.tail=0,this.items=new Map}s.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items.clear()},s.prototype.set=function(y,e){var r=this.items.get(y);if(typeof r<"u"){this.splayOnTop(r),this.V[r]=e;return}this.size{var i=KM(),x=zn(),T=Is(),E=sa();function s(e,r,p){arguments.length<2?i.call(this,e):i.call(this,e,r,p);var h=T.getPointerArray(this.capacity);this.deleted=new h(this.capacity),this.deletedSize=0}for(y in i.prototype)s.prototype[y]=i.prototype[y];var y;typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=i.prototype[Symbol.iterator]),s.prototype.clear=function(){i.prototype.clear.call(this),this.deletedSize=0},s.prototype.set=function(e,r){var p=this.items.get(e);if(typeof p<"u"){this.splayOnTop(p),this.V[p]=r;return}this.size0?p=this.deleted[--this.deletedSize]:p=this.size,this.size++):(p=this.tail,this.tail=this.backward[p],this.items.delete(this.K[p])),this.items.set(e,p),this.K[p]=e,this.V[p]=r,this.forward[p]=this.head,this.backward[this.head]=p,this.head=p},s.prototype.setpop=function(e,r){var p=null,h=null,a=this.items.get(e);return typeof a<"u"?(this.splayOnTop(a),p=this.V[a],this.V[a]=r,{evicted:!1,key:e,value:p}):(this.size0?a=this.deleted[--this.deletedSize]:a=this.size,this.size++):(a=this.tail,this.tail=this.backward[a],p=this.V[a],h=this.K[a],this.items.delete(h)),this.items.set(e,a),this.K[a]=e,this.V[a]=r,this.forward[a]=this.head,this.backward[this.head]=a,this.head=a,h?{evicted:!0,key:h,value:p}:null)},s.prototype.delete=function(e){var r=this.items.get(e);if(typeof r>"u")return!1;if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var p=this.backward[r],h=this.forward[r];return this.head===r&&(this.head=h),this.tail===r&&(this.tail=p),this.forward[p]=h,this.backward[h]=p,this.size--,this.deleted[this.deletedSize++]=r,!0},s.prototype.remove=function(e,r=void 0){var p=this.items.get(e);if(typeof p>"u")return r;var h=this.V[p];if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,h;var a=this.backward[p],l=this.forward[p];return this.head===p&&(this.head=l),this.tail===p&&(this.tail=a),this.forward[a]=l,this.backward[l]=a,this.size--,this.deleted[this.deletedSize++]=p,h},s.from=function(e,r,p,h){if(arguments.length<2){if(h=E.guessLength(e),typeof h!="number")throw new Error("mnemonist/lru-map.from: could not guess iterable length. Please provide desired capacity as last argument.")}else arguments.length===2&&(h=r,r=null,p=null);var a=new s(r,p,h);return x(e,function(l,n){a.set(n,l)}),a},t.exports=s}),nO=si((g,t)=>{var i=Vr(),x=zn(),T=Wx(),E=function(y,e){return y[1]>e[1]?-1:y[1]"u"?0:e},s.prototype.get=s.prototype.multiplicity,s.prototype.count=s.prototype.multiplicity,s.prototype.frequency=function(y){if(this.size===0)return 0;var e=this.multiplicity(y);return e/this.size},s.prototype.top=function(y){if(typeof y!="number"||y<=0)throw new Error("mnemonist/multi-set.top: n must be a number > 0.");for(var e=new T(Array,E,y),r=this.items.entries(),p;p=r.next(),!p.done;)e.push(p.value);return e.consume()},s.prototype.forEach=function(y,e){e=arguments.length>1?e:this;var r;this.items.forEach(function(p,h){for(r=0;r1?e:this,this.items.forEach(y,e)},s.prototype.keys=function(){return this.items.keys()},s.prototype.values=function(){var y=this.items.entries(),e=!1,r,p,h,a;return new i(function l(){if(!e){if(r=y.next(),r.done)return{done:!0};e=!0,p=r.value[0],h=r.value[1],a=0}return a>=h?(e=!1,l()):(a++,{done:!1,value:p})})},s.prototype.multiplicities=function(){return this.items.entries()},typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=s.prototype.values),s.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(s.prototype[Symbol.for("nodejs.util.inspect.custom")]=s.prototype.inspect),s.prototype.toJSON=function(){return this.items},s.from=function(y){var e=new s;return x(y,function(r){e.add(r)}),e},s.isSubset=function(y,e){var r=y.multiplicities(),p,h,a;if(y===e)return!0;if(y.dimension>e.dimension)return!1;for(;p=r.next(),!p.done;)if(h=p.value[0],a=p.value[1],e.multiplicity(h){var i=Vr(),x=zn();function T(l,n,u){return((Math.pow(l,2)-Math.pow(Math.abs(n-u),2))/2|0)+l+1}function E(l,n){for(var u=0,f=0,o=n+1;fn.length?-1:l.lengthn?1:0}function y(l,n){var u=l+1,f=n/u|0,o=f+1,c,d,v=n-f*u,m=u-v,S=new Array(l+1);for(c=0;c 0");this.levenshtein=l,this.k=n,this.clear()}a.prototype.clear=function(){this.size=0,this.strings=[],this.invertedIndices={}},a.prototype.add=function(l){var n=l.length,u=this.size;this.strings.push(l),this.size++;var f=e(this.k,l),o=this.invertedIndices[n];typeof o>"u"&&(o={},this.invertedIndices[n]=o);var c,d,v,m,S;for(m=0,S=f.length;m"u"?(d=[u],o[v]=d):d.push(u);return this},a.prototype.search=function(l){var n=l.length,u=this.k,f=new Set,o,c,d,v,m,S,M,w,C,A,P,b,O,I,D;for(w=Math.max(0,n-u),C=n+u+1;w1?n:this;for(var u=0,f=this.strings.length;u=n)return{done:!0};var f=l[u];return u++,{value:f,done:!1}})},typeof Symbol<"u"&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.inspect=function(){var l=this.strings.slice();return Object.defineProperty(l,"constructor",{value:a,enumerable:!1}),l},typeof Symbol<"u"&&(a.prototype[Symbol.for("nodejs.util.inspect.custom")]=a.prototype.inspect),a.from=function(l,n,u){var f=new a(n,u);return x(l,function(o){f.add(o)}),f},a.countKeys=E,a.comparator=s,a.partition=y,a.segments=e,a.segmentPos=r,a.multiMatchAwareInterval=p,a.multiMatchAwareSubstrings=h,t.exports=a}),sO=si((g,t)=>{var i=Vr(),x=zn();function T(){this.clear()}T.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},T.prototype.enqueue=function(E){return this.items.push(E),++this.size},T.prototype.dequeue=function(){if(this.size){var E=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,E}},T.prototype.peek=function(){if(this.size)return this.items[this.offset]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=this.offset,e=0,r=this.items.length;y=E.length)return{done:!0};var y=E[s];return s++,{value:y,done:!1}})},T.prototype.entries=function(){var E=this.items,s=this.offset,y=0;return new i(function(){if(s>=E.length)return{done:!0};var e=E[s];return s++,{value:[y++,e],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.toString=function(){return this.toArray().join(",")},T.prototype.toJSON=function(){return this.toArray()},T.prototype.inspect=function(){var E=this.toArray();return Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E){var s=new T;return x(E,function(y){s.enqueue(y)}),s},T.of=function(){return T.from(arguments)},t.exports=T}),aO=si((g,t)=>{var i=Vr(),x=zn();function T(){this.clear()}T.prototype.clear=function(){this.items=[],this.size=0},T.prototype.push=function(E){return this.items.push(E),++this.size},T.prototype.pop=function(){if(this.size!==0)return this.size--,this.items.pop()},T.prototype.peek=function(){return this.items[this.size-1]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=0,e=this.items.length;y=s)return{done:!0};var e=E[s-y-1];return y++,{value:e,done:!1}})},T.prototype.entries=function(){var E=this.items,s=E.length,y=0;return new i(function(){if(y>=s)return{done:!0};var e=E[s-y-1];return{value:[y++,e],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.toString=function(){return this.toArray().join(",")},T.prototype.toJSON=function(){return this.toArray()},T.prototype.inspect=function(){var E=this.toArray();return Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E){var s=new T;return x(E,function(y){s.push(y)}),s},T.of=function(){return T.from(arguments)},t.exports=T}),oO=si(g=>{g.intersection=function(){if(arguments.length<2)throw new Error("mnemonist/Set.intersection: needs at least two arguments.");var t=new Set,i=1/0,x=null,T,E,s=arguments.length;for(E=0;Ei.size)return!1;for(;T=x.next(),!T.done;)if(!i.has(T.value))return!1;return!0},g.isSuperset=function(t,i){return g.isSubset(i,t)},g.add=function(t,i){for(var x=i.values(),T;T=x.next(),!T.done;)t.add(T.value)},g.subtract=function(t,i){for(var x=i.values(),T;T=x.next(),!T.done;)t.delete(T.value)},g.intersect=function(t,i){for(var x=t.values(),T;T=x.next(),!T.done;)i.has(T.value)||t.delete(T.value)},g.disjunct=function(t,i){for(var x=t.values(),T,E=[];T=x.next(),!T.done;)i.has(T.value)&&E.push(T.value);for(x=i.values();T=x.next(),!T.done;)t.has(T.value)||t.add(T.value);for(var s=0,y=E.length;si.size&&(x=t,t=i,i=x),t.size===0)return 0;if(t===i)return t.size;for(var T=t.values(),E,s=0;E=T.next(),!E.done;)i.has(E.value)&&s++;return s},g.unionSize=function(t,i){var x=g.intersectionSize(t,i);return t.size+i.size-x},g.jaccard=function(t,i){var x=g.intersectionSize(t,i);if(x===0)return 0;var T=t.size+i.size-x;return x/T},g.overlap=function(t,i){var x=g.intersectionSize(t,i);return x===0?0:x/Math.min(t.size,i.size)}}),lO=si((g,t)=>{var i=Vr(),x=Is().getPointerArray;function T(E){var s=x(E);this.start=0,this.size=0,this.capacity=E,this.dense=new s(E),this.sparse=new s(E)}T.prototype.clear=function(){this.start=0,this.size=0},T.prototype.has=function(E){if(this.size===0)return!1;var s=this.sparse[E],y=s=this.start&&s=this.start&&s1?s:this;for(var y=this.capacity,e=this.size,r=this.start,p=0;p=y)return{done:!0};var p=E[e];return e++,r++,e===s&&(e=0),{value:p,done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=[];return this.forEach(function(s){E.push(s)}),Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E.capacity=this.capacity,E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),t.exports=T}),hO=si((g,t)=>{var i=Vr(),x=Is().getPointerArray;function T(E,s){arguments.length<2&&(s=E,E=Array);var y=x(s);this.size=0,this.length=s,this.dense=new y(s),this.sparse=new y(s),this.vals=new E(s)}T.prototype.clear=function(){this.size=0},T.prototype.has=function(E){var s=this.sparse[E];return s=this.size||this.dense[s]!==E?!1:(s=this.dense[this.size-1],this.dense[this.sparse[E]]=s,this.sparse[s]=this.sparse[E],this.size--,!0)},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=0;y{var i=Vr(),x=Is().getPointerArray;function T(E){var s=x(E);this.size=0,this.length=E,this.dense=new s(E),this.sparse=new s(E)}T.prototype.clear=function(){this.size=0},T.prototype.has=function(E){var s=this.sparse[E];return s=this.size||this.dense[s]!==E?!1:(s=this.dense[this.size-1],this.dense[this.sparse[E]]=s,this.sparse[s]=this.sparse[E],this.size--,!0)},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y,e=0;e{var i=zn(),x=2,T=2,E=new Set([0,1,2]),s={0:"Returns only the top suggestion",1:"Returns suggestions with the smallest edit distance",2:"Returns every suggestion (no early termination)"};function y(n){var u=new Set;return typeof n=="number"&&u.add(n),{suggestions:u,count:0}}function e(n,u,f){return{term:n||"",distance:u||0,count:f||0}}function r(n,u,f,o){o=o||new Set,u++;var c,d=n.length,v;if(d>1)for(v=0;v0&&n[v].length-d.length>o.length-d.length&&(f.suggestions=new Set,f.count=0),(u===2||!f.suggestions.size||n[v].length-d.length>=o.length-d.length)&&f.suggestions.add(c)}function h(n,u){var f=n.length,o=u.length,c=[[]],d=f+o,v=new Map,m,S,M;for(c[0][0]=d,m=0;m<=f;m++)c[m+1]||(c[m+1]=[]),c[m+1][1]=m,c[m+1][0]=d;for(M=0;M<=o;M++)c[1][M+1]=M,c[0][M+1]=d;var w=n+u,C;for(m=0,S=w.length;mc)return[];for(var m=[d],S=new Set,M=new Set,w=[],C,A;m.length>0&&(C=m.shift(),!(f<2&&w.length>0&&v-C.length>w[0].distance));){if(A=n[C],A!==void 0){if(typeof A=="number"&&(A=y(A)),A.count>0&&!M.has(C)){M.add(C);var P=e(C,v-C.length,A.count);if(w.push(P),f<2&&v-C.length===0)break}A.suggestions.forEach(D=>{var B=u[D];if(!M.has(B)){M.add(B);var G=0;if(d!==B)if(B.length===C.length)G=v-C.length;else if(v===C.length)G=B.length-C.length;else{for(var z=0,X=0,K=B.length;z0||X>0?G=h(B.substr(z,K-z-X),d.substr(z,v-z-X)):G=h(B,d)}if(f<2&&w.length>0&&w[0].distance>G&&(w=[]),!(f<2&&w.length>0&&G>w[0].distance)&&G<=o){var Q=n[B];Q!==void 0&&w.push(e(B,G,Q.count))}}})}if(v-C.length0&&v-C.length>=w[0].distance)continue;for(var b=0,O=C.length;bthis.maxLength&&(this.maxLength=n.length)),u.count===1){var f=this.words.length;this.words.push(n);var o=r(n,0,this.maxDistance);o.forEach(c=>{var d=this.dictionary[c];d!==void 0?(typeof d=="number"&&(d=y(d),this.dictionary[c]=d),d.suggestions.has(f)||p(this.words,this.verbosity,d,n,f,c)):this.dictionary[c]=f})}return this.size++,this},l.prototype.search=function(n){return a(this.dictionary,this.words,this.verbosity,this.maxDistance,this.maxLength,n)},l.prototype.inspect=function(){var n=[];n.size=this.size,n.maxDistance=this.maxDistance,n.verbosity=this.verbosity,n.behavior=s[this.verbosity];for(var u in this.dictionary)typeof this.dictionary[u]=="object"&&this.dictionary[u].count&&n.push([u,this.dictionary[u].count]);return Object.defineProperty(n,"constructor",{value:l,enumerable:!1}),n},typeof Symbol<"u"&&(l.prototype[Symbol.for("nodejs.util.inspect.custom")]=l.prototype.inspect),l.from=function(n,u){var f=new l(u);return i(n,function(o){f.add(o)}),f},t.exports=l}),jM=si((g,t)=>{var i=zn(),x=Vr(),T="\0";function E(s){this.mode=s===Array?"array":"string",this.clear()}E.prototype.clear=function(){this.root={},this.size=0},E.prototype.set=function(s,y){for(var e=this.root,r,p=0,h=s.length;p"u")return;if(T in y)return y[T]},E.prototype.delete=function(s){var y=this.root,e=null,r=null,p,h,a,l;for(a=0,l=s.length;a"u")return!1;e!==null?Object.keys(y).length>1&&(e=null,r=null):Object.keys(y).length<2&&(e=p,r=h)}return T in y?(this.size--,e?delete e[r]:delete y[T],!0):!1},E.prototype.has=function(s){for(var y=this.root,e,r=0,p=s.length;r"u")return!1;return T in y},E.prototype.find=function(s){var y=typeof s=="string",e=this.root,r=[],p,h,a;for(h=0,a=s.length;h"u")return r;for(var l=[e],n=[s],u;l.length;){s=n.pop(),e=l.pop();for(u in e){if(u===T){r.push([s,e[T]]);continue}l.push(e[u]),n.push(y?s+u:s.concat(u))}}return r},E.prototype.values=function(s){var y=this.root,e=[],r,p,h;if(s){for(p=0,h=s.length;p"u")return x.empty()}return e.push(y),new x(function(){for(var a,l=!1,n;e.length;){a=e.pop();for(n in a){if(n===T){l=!0;continue}e.push(a[n])}if(l)return{done:!1,value:a[T]}}return{done:!0}})},E.prototype.prefixes=function(s){var y=this.root,e=[],r=[],p,h,a,l=this.mode==="string";if(s){for(h=0,a=s.length;h"u")return x.empty()}else s=l?"":[];return e.push(y),r.push(s),new x(function(){for(var n,u,f=!1,o;e.length;){n=e.pop(),u=r.pop();for(o in n){if(o===T){f=!0;continue}e.push(n[o]),r.push(l?u+o:u.concat(o))}if(f)return{done:!1,value:u}}return{done:!0}})},E.prototype.keys=E.prototype.prefixes,E.prototype.entries=function(s){var y=this.root,e=[],r=[],p,h,a,l=this.mode==="string";if(s){for(h=0,a=s.length;h"u")return x.empty()}else s=l?"":[];return e.push(y),r.push(s),new x(function(){for(var n,u,f=!1,o;e.length;){n=e.pop(),u=r.pop();for(o in n){if(o===T){f=!0;continue}e.push(n[o]),r.push(l?u+o:u.concat(o))}if(f)return{done:!1,value:[u,n[T]]}}return{done:!0}})},typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=E.prototype.entries),E.prototype.inspect=function(){for(var s=new Array(this.size),y=this.entries(),e,r=0;e=y.next(),!e.done;)s[r++]=e.value;return Object.defineProperty(s,"constructor",{value:E,enumerable:!1}),s},typeof Symbol<"u"&&(E.prototype[Symbol.for("nodejs.util.inspect.custom")]=E.prototype.inspect),E.prototype.toJSON=function(){return this.root},E.from=function(s){var y=new E;return i(s,function(e,r){y.set(r,e)}),y},E.SENTINEL=T,t.exports=E}),cO=si((g,t)=>{var i=zn(),x=jM(),T="\0";function E(y){this.mode=y===Array?"array":"string",this.clear()}for(s in x.prototype)E.prototype[s]=x.prototype[s];var s;delete E.prototype.set,delete E.prototype.get,delete E.prototype.values,delete E.prototype.entries,E.prototype.add=function(y){for(var e=this.root,r,p=0,h=y.length;p"u")return p;for(var n=[r],u=[y],f;n.length;){y=u.pop(),r=n.pop();for(f in r){if(f===T){p.push(y);continue}n.push(r[f]),u.push(e?y+f:y.concat(f))}}return p},typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=E.prototype.keys),E.prototype.inspect=function(){for(var y=new Set,e=this.keys(),r;r=e.next(),!r.done;)y.add(r.value);return Object.defineProperty(y,"constructor",{value:E,enumerable:!1}),y},typeof Symbol<"u"&&(E.prototype[Symbol.for("nodejs.util.inspect.custom")]=E.prototype.inspect),E.prototype.toJSON=function(){return this.root},E.from=function(y){var e=new E;return i(y,function(r){e.add(r)}),e},E.SENTINEL=T,t.exports=E}),dO=si((g,t)=>{var i=Vr(),x=zn(),T=sa(),E=Is(),s=function(p){return Math.max(1,Math.ceil(p*1.5))},y=function(p){var h=E.getPointerArray(p);return new h(p)};function e(p,h){if(arguments.length<1)throw new Error("mnemonist/vector: expecting at least a byte array constructor.");var a=h||0,l=s,n=0,u=!1;typeof h=="object"&&(a=h.initialCapacity||0,n=h.initialLength||0,l=h.policy||l,u=h.factory===!0),this.factory=u?p:null,this.ArrayClass=p,this.length=n,this.capacity=Math.max(n,a),this.policy=l,this.array=new p(this.capacity)}e.prototype.set=function(p,h){if(this.lengththis.capacity)if(this.factory===null?this.array=new this.ArrayClass(p):this.array=this.factory(p),E.isTypedArray(this.array))this.array.set(h,0);else for(var a=0,l=this.length;a=p)return this;for(h=this.capacity;h=h)return{done:!0};var l=p[a];return a++,{value:l,done:!1}})},e.prototype.entries=function(){var p=this.array,h=this.length,a=0;return new i(function(){if(a>=h)return{done:!0};var l=p[a];return{value:[a++,l],done:!1}})},typeof Symbol<"u"&&(e.prototype[Symbol.iterator]=e.prototype.values),e.prototype.inspect=function(){var p=this.array.slice(0,this.length);return p.type=this.array.constructor.name,p.items=this.length,p.capacity=this.capacity,Object.defineProperty(p,"constructor",{value:e,enumerable:!1}),p},typeof Symbol<"u"&&(e.prototype[Symbol.for("nodejs.util.inspect.custom")]=e.prototype.inspect),e.from=function(p,h,a){if(arguments.length<3&&(a=T.guessLength(p),typeof a!="number"))throw new Error("mnemonist/vector.from: could not guess iterable length. Please provide desired capacity as last argument.");var l=new e(h,a);return x(p,function(n){l.push(n)}),l};function r(p){var h=function(l){e.call(this,p,l)};for(var a in e.prototype)e.prototype.hasOwnProperty(a)&&(h.prototype[a]=e.prototype[a]);return h.from=function(l,n){return e.from(l,p,n)},typeof Symbol<"u"&&(h.prototype[Symbol.iterator]=h.prototype.values),h}e.Int8Vector=r(Int8Array),e.Uint8Vector=r(Uint8Array),e.Uint8ClampedVector=r(Uint8ClampedArray),e.Int16Vector=r(Int16Array),e.Uint16Vector=r(Uint16Array),e.Int32Vector=r(Int32Array),e.Uint32Vector=r(Uint32Array),e.Float32Vector=r(Float32Array),e.Float64Vector=r(Float64Array),e.PointerVector=r(y),t.exports=e}),pO=si((g,t)=>{var i=sa(),x=Is(),T=kM().inplaceQuickSortIndices,E=YM().lowerBoundIndices,s=Hx(),y=x.getPointerArray;function e(h,a){return h.distancea.distance?-1:0}function r(h,a,l){for(var n=l.length,u=y(n),f=0,o=new u(n),c=new u(n),d=new u(n),v=new Float64Array(n),m=[0,0,n],S=new Float64Array(n),M,w,C,A,P,b,O,I,D;m.length;)if(P=m.pop(),A=m.pop(),M=m.pop(),w=l[P-1],P--,D=P-A,o[M]=w,D!==0){if(D===1){O=h(a[w],a[l[A]]),v[M]=O,f++,d[M]=f,o[f]=l[A];continue}for(I=A;I0&&(f++,d[M]=f,m.push(f,b,P)),b-A>0&&(f++,c[M]=f,m.push(f,A,b))}return{nodes:o,lefts:c,rights:d,mus:v}}function p(h,a){if(typeof h!="function")throw new Error("mnemonist/VPTree.constructor: given `distance` must be a function.");if(!a)throw new Error("mnemonist/VPTree.constructor: you must provide items to the tree. A VPTree cannot be updated after its creation.");this.distance=h,this.heap=new s(e),this.D=0;var l=i.toArrayWithIndices(a);this.items=l[0];var n=l[1];this.size=n.length;var u=r(h,this.items,n);this.nodes=u.nodes,this.lefts=u.lefts,this.rights=u.rights,this.mus=u.mus}p.prototype.nearestNeighbors=function(h,a){var l=this.heap,n=[0],u=1/0,f,o,c,d,v,m,S;for(this.D=0;n.length;)f=n.pop(),o=this.nodes[f],c=this.items[o],S=this.distance(c,a),this.D++,Sh&&l.pop(),l.size>=h&&(u=l.peek().distance)),d=this.lefts[f],v=this.rights[f],!(!d&&!v)&&(m=this.mus[f],S=m-u&&n.push(v)):(v&&S>=m-u&&n.push(v),d&&S=0;w--)M[w]=l.pop();return M},p.prototype.neighbors=function(h,a){var l=[],n=[0],u,f,o,c,d,v,m;for(this.D=0;n.length;)u=n.pop(),f=this.nodes[u],o=this.items[f],m=this.distance(o,a),this.D++,m<=h&&l.push({distance:m,item:o}),c=this.lefts[u],d=this.rights[u],!(!c&&!d)&&(v=this.mus[u],m=v-h&&n.push(d)):(d&&m>=v-h&&n.push(d),c&&m{var i=Hx(),x=Vx(),T=BF();t.exports={BiMap:UF(),BitSet:zF(),BitVector:GF(),BloomFilter:HF(),BKTree:WF(),CircularBuffer:XF(),DefaultMap:YF(),DefaultWeakMap:kF(),FixedDeque:HM(),StaticDisjointSet:KF(),FibonacciHeap:x,MinFibonacciHeap:x.MinFibonacciHeap,MaxFibonacciHeap:x.MaxFibonacciHeap,FixedReverseHeap:Wx(),FuzzyMap:jF(),FuzzyMultiMap:ZF(),HashedArrayTree:JF(),Heap:i,MinHeap:i.MinHeap,MaxHeap:i.MaxHeap,StaticIntervalTree:$F(),InvertedIndex:_F(),KDTree:qF(),LinkedList:tO(),LRUCache:Xx(),LRUCacheWithDelete:eO(),LRUMap:KM(),LRUMapWithDelete:iO(),MultiMap:WM(),MultiSet:nO(),PassjoinIndex:rO(),Queue:sO(),FixedStack:XM(),Stack:aO(),SuffixArray:T,GeneralizedSuffixArray:T.GeneralizedSuffixArray,Set:oO(),SparseQueueSet:lO(),SparseMap:hO(),SparseSet:uO(),SymSpell:fO(),Trie:cO(),TrieMap:jM(),Vector:dO(),VPTree:pO()}}),Qt=class fr{static get ZERO(){return new fr(0,0)}static get ONE(){return new fr(1,1)}static get UP(){return new fr(0,-1)}static get DOWN(){return new fr(0,1)}static get LEFT(){return new fr(-1,0)}static get RIGHT(){return new fr(1,0)}static get UP_LEFT(){return new fr(-1,-1)}static get UP_RIGHT(){return new fr(1,-1)}static get DOWN_RIGHT(){return new fr(1,1)}static get DOWN_LEFT(){return new fr(-1,1)}constructor(t,i){typeof t=="number"?(this.x=t,this.y=i||0):(this.x=t.x,this.y=t.y)}clone(){return new fr(this.x,this.y)}add(t){return new fr(this.x+t.x,this.y+t.y)}multiply(t){return new fr(this.x*t.x,this.y*t.y)}divide(t){return new fr(this.x/t.x,this.y/t.y)}subtract(t){return new fr(this.x-t.x,this.y-t.y)}equals(t){return this.x===t.x&&this.y===t.y}abs(){return new fr(Math.abs(this.x),Math.abs(this.y))}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}modulo(t){return new fr(this.x%t.x,this.y%t.y)}scalarModulo(t){return new fr(this.x%t,this.y%t)}scalarMult(t){return new fr(this.x*t,this.y*t)}toPosition(){return{x:this.x,y:this.y}}toString(){return`${this.x}#${this.y}`}},Ai=class{static equal(g,t){return g.position.x===t.position.x&&g.position.y===t.position.y&&g.layer===t.layer}static copyOver(g,t){t.position.x=g.position.x,t.position.y=g.position.y,t.layer=g.layer}static clone(g){return{position:g.position.clone(),layer:g.layer}}static toString(g){return`${g.position.toString()}#${g.layer}`}static toInternal(g){return{position:new Qt(g.position.x,g.position.y),layer:g.charLayer}}static fromInternal(g){return{position:g.position.toPosition(),charLayer:g.layer}}},mO=(g=>(g.NONE="none",g.LEFT="left",g.UP_LEFT="up-left",g.UP="up",g.UP_RIGHT="up-right",g.RIGHT="right",g.DOWN_RIGHT="down-right",g.DOWN="down",g.DOWN_LEFT="down-left",g))(mO||{}),gO={up:"down",down:"up",left:"right",right:"left",none:"none","up-left":"down-right","up-right":"down-left","down-right":"up-left","down-left":"up-right"},yO={up:Qt.UP,down:Qt.DOWN,left:Qt.LEFT,right:Qt.RIGHT,none:Qt.ZERO,"up-left":Qt.UP_LEFT,"up-right":Qt.UP_RIGHT,"down-right":Qt.DOWN_RIGHT,"down-left":Qt.DOWN_LEFT},dm={up:0,"up-right":1,right:2,"down-right":3,down:4,"down-left":5,left:6,"up-left":7,none:NaN},ZM=["up","up-right","right","down-right","down","down-left","left","up-left"],xO=["down-left","down-right","up-right","up-left"];function Yx(){return["up","down","left","right","none","up-left","up-right","down-right","down-left"]}function ad(g){return xO.includes(g)}function SO(g,t=1){return g==="none"?"none":ZM[(dm[g]+8-Math.abs(t)%8)%8]}function JM(g,t=1){return g==="none"?"none":ZM[(dm[g]+t)%8]}function Cu(g){return yO[g]}function TO(g){return gO[g]}function Ma(g,t){if(g.x===t.x){if(g.y>t.y)return"up";if(g.yt.x)return"left";if(g.xt.x){if(g.yt.y)return"up-left"}else if(g.xt.y)return"up-right"}return"none"}var EO=(g=>(g[g.FOUR=4]="FOUR",g[g.EIGHT=8]="EIGHT",g))(EO||{});function If(g){return typeof g=="string"&&Yx().includes(g)}var xy=function(g,t){return xy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,x){i.__proto__=x}||function(i,x){for(var T in x)Object.prototype.hasOwnProperty.call(x,T)&&(i[T]=x[T])},xy(g,t)};function Yd(g,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");xy(g,t);function i(){this.constructor=g}g.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}function MO(g,t,i,x){function T(E){return E instanceof i?E:new i(function(s){s(E)})}return new(i||(i=Promise))(function(E,s){function y(p){try{r(x.next(p))}catch(h){s(h)}}function e(p){try{r(x.throw(p))}catch(h){s(h)}}function r(p){p.done?E(p.value):T(p.value).then(y,e)}r((x=x.apply(g,t||[])).next())})}function $M(g,t){var i={label:0,sent:function(){if(E[0]&1)throw E[1];return E[1]},trys:[],ops:[]},x,T,E,s;return s={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function y(r){return function(p){return e([r,p])}}function e(r){if(x)throw new TypeError("Generator is already executing.");for(;s&&(s=0,r[0]&&(i=0)),i;)try{if(x=1,T&&(E=r[0]&2?T.return:r[0]?T.throw||((E=T.return)&&E.call(T),0):T.next)&&!(E=E.call(T,r[1])).done)return E;switch(T=0,E&&(r=[r[0]&2,E.value]),r[0]){case 0:case 1:E=r;break;case 4:return i.label++,{value:r[1],done:!1};case 5:i.label++,T=r[1],r=[0];continue;case 7:r=i.ops.pop(),i.trys.pop();continue;default:if(E=i.trys,!(E=E.length>0&&E[E.length-1])&&(r[0]===6||r[0]===2)){i=0;continue}if(r[0]===3&&(!E||r[1]>E[0]&&r[1]=g.length&&(g=void 0),{value:g&&g[x++],done:!g}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function vd(g,t){var i=typeof Symbol=="function"&&g[Symbol.iterator];if(!i)return g;var x=i.call(g),T,E=[],s;try{for(;(t===void 0||t-- >0)&&!(T=x.next()).done;)E.push(T.value)}catch(y){s={error:y}}finally{try{T&&!T.done&&(i=x.return)&&i.call(x)}finally{if(s)throw s.error}}return E}function md(g,t,i){if(i||arguments.length===2)for(var x=0,T=t.length,E;x1||y(a,l)})})}function y(a,l){try{e(x[a](l))}catch(n){h(E[0][3],n)}}function e(a){a.value instanceof Wf?Promise.resolve(a.value.v).then(r,p):h(E[0][2],a)}function r(a){y("next",a)}function p(a){y("throw",a)}function h(a,l){a(l),E.shift(),E.length&&y(E[0][0],E[0][1])}}function wO(g){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=g[Symbol.asyncIterator],i;return t?t.call(g):(g=typeof Kf=="function"?Kf(g):g[Symbol.iterator](),i={},x("next"),x("throw"),x("return"),i[Symbol.asyncIterator]=function(){return this},i);function x(E){i[E]=g[E]&&function(s){return new Promise(function(y,e){s=g[E](s),T(y,e,s.done,s.value)})}}function T(E,s,y,e){Promise.resolve(e).then(function(r){E({value:r,done:y})},s)}}function mr(g){return typeof g=="function"}function QM(g){var t=function(x){Error.call(x),x.stack=new Error().stack},i=g(t);return i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,i}var u0=QM(function(g){return function(t){g(this),this.message=t?t.length+` errors occurred during unsubscription: + */s.exports={Format:e(27902),Pad:e(41836),RemoveAt:e(33628),Reverse:e(27671),UppercaseFirst:e(35355),UUID:e(45650)}}},x={};function T(s){var y=x[s];if(y!==void 0)return y.exports;var e=x[s]={exports:{}};return i[s](e,e.exports,T),e.exports}T.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}();var E=T(85454);return E})())})(UM);var Zm=UM.exports;const sd=Wd(Zm);var PF=Object.create,Gx=Object.defineProperty,RF=Object.defineProperties,bF=Object.getOwnPropertyDescriptor,LF=Object.getOwnPropertyDescriptors,FF=Object.getOwnPropertyNames,JS=Object.getOwnPropertySymbols,OF=Object.getPrototypeOf,zM=Object.prototype.hasOwnProperty,DF=Object.prototype.propertyIsEnumerable,$S=(g,t,i)=>t in g?Gx(g,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):g[t]=i,An=(g,t)=>{for(var i in t||(t={}))zM.call(t,i)&&$S(g,i,t[i]);if(JS)for(var i of JS(t))DF.call(t,i)&&$S(g,i,t[i]);return g},dh=(g,t)=>RF(g,LF(t)),si=(g,t)=>()=>(t||g((t={exports:{}}).exports,t),t.exports),IF=(g,t,i,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let T of FF(t))!zM.call(g,T)&&T!==i&&Gx(g,T,{get:()=>t[T],enumerable:!(x=bF(t,T))||x.enumerable});return g},GM=(g,t,i)=>(i=g!=null?PF(OF(g)):{},IF(t||!g||!g.__esModule?Gx(i,"default",{value:g,enumerable:!0}):i,g)),Jm=si(g=>{var t=function(E,s){return Es?1:0},i=function(E,s){return Es?-1:0};function x(E){return function(s,y){return E(y,s)}}function T(E){return E===2?function(s,y){return s[0]y[0]?1:s[1]y[1]?1:0}:function(s,y){for(var e=0;ey[e])return 1;e++}return 0}}g.DEFAULT_COMPARATOR=t,g.DEFAULT_REVERSE_COMPARATOR=i,g.reverseComparator=x,g.createTupleComparator=T}),NF=si(g=>{g.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",g.SYMBOL_SUPPORT=typeof Symbol<"u"}),zn=si((g,t)=>{var i=NF(),x=i.ARRAY_BUFFER_SUPPORT,T=i.SYMBOL_SUPPORT;t.exports=function(E,s){var y,e,r,p,h;if(!E)throw new Error("obliterator/forEach: invalid iterable.");if(typeof s!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(E)||x&&ArrayBuffer.isView(E)||typeof E=="string"||E.toString()==="[object Arguments]"){for(r=0,p=E.length;r{var i=Jm(),x=zn(),T=i.DEFAULT_COMPARATOR,E=i.reverseComparator;function s(u){if(this.clear(),this.comparator=u||T,typeof this.comparator!="function")throw new Error("mnemonist/FibonacciHeap.constructor: given comparator should be a function.")}s.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function y(u){return{item:u,degree:0}}function e(u,f){u.root?(f.right=u.root.right,f.left=u.root,u.root.right.left=f,u.root.right=f):u.root=f}s.prototype.push=function(u){var f=y(u);return f.left=f,f.right=f,e(this,f),(!this.min||this.comparator(f.item,this.min.item)<=0)&&(this.min=f),++this.size},s.prototype.peek=function(){return this.min?this.min.item:void 0};function r(u){for(var f=[],o=u,c=!1;!(o===u&&c);)o===u&&(c=!0),f.push(o),o=o.right;return f}function p(u,f){u.root===f&&(u.root=f.right),f.left.right=f.right,f.right.left=f.left}function h(u,f){u.child?(f.right=u.child.right,f.left=u.child,u.child.right.left=f,u.child.right=f):u.child=f}function a(u,f,o){p(u,f),f.left=f,f.right=f,h(o,f),o.degree++,f.parent=o}function l(u){var f=new Array(u.size),o=r(u.root),c,d,v,m,S,M;for(c=0,d=o.length;c0&&(M=v,v=m,m=M),a(u,m,v),f[S]=null,S++;f[S]=v}for(c=0;c{var t=Math.pow(2,8)-1,i=Math.pow(2,16)-1,x=Math.pow(2,32)-1,T=Math.pow(2,7)-1,E=Math.pow(2,15)-1,s=Math.pow(2,31)-1;g.getPointerArray=function(e){var r=e-1;if(r<=t)return Uint8Array;if(r<=i)return Uint16Array;if(r<=x)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},g.getSignedPointerArray=function(e){var r=e-1;return r<=T?Int8Array:r<=E?Int16Array:r<=s?Int32Array:Float64Array},g.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var y={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};g.getMinimalRepresentation=function(e,r){var p=null,h=0,a,l,n,u,f;for(u=0,f=e.length;uh&&(h=a,p=l);return p},g.isTypedArray=function(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)},g.concat=function(){var e=0,r,p,h;for(r=0,h=arguments.length;r{var t=zn(),i=Is();function x(y){return Array.isArray(y)||i.isTypedArray(y)}function T(y){if(typeof y.length=="number")return y.length;if(typeof y.size=="number")return y.size}function E(y){var e=T(y),r=typeof e=="number"?new Array(e):[],p=0;return t(y,function(h){r[p++]=h}),r}function s(y){var e=T(y),r=typeof e=="number"?i.getPointerArray(e):Array,p=typeof e=="number"?new Array(e):[],h=typeof e=="number"?new r(e):[],a=0;return t(y,function(l){p[a]=l,h[a]=a++}),[p,h]}g.isArrayLike=x,g.guessLength=T,g.toArray=E,g.toArrayWithIndices=s}),Hx=si((g,t)=>{var i=zn(),x=Jm(),T=sa(),E=x.DEFAULT_COMPARATOR,s=x.reverseComparator;function y(d,v,m,S){for(var M=v[S],w,C;S>m;){if(w=S-1>>1,C=v[w],d(M,C)<0){v[S]=C,S=w;continue}break}v[S]=M}function e(d,v,m){for(var S=v.length,M=m,w=v[m],C=2*m+1,A;C=0&&(C=A),v[m]=v[C],m=C,C=2*m+1;v[m]=w,y(d,v,M,m)}function r(d,v,m){v.push(m),y(d,v,0,v.length-1)}function p(d,v){var m=v.pop();if(v.length!==0){var S=v[0];return v[0]=m,e(d,v,0),S}return m}function h(d,v,m){if(v.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var S=v[0];return v[0]=m,e(d,v,0),S}function a(d,v,m){var S;return v.length!==0&&d(v[0],m)<0&&(S=v[0],v[0]=m,m=S,e(d,v,0)),m}function l(d,v){for(var m=v.length,S=m>>1,M=S;--M>=0;)e(d,v,M)}function n(d,v){for(var m=v.length,S=0,M=new Array(m);S=m.length)return m.slice().sort(d);for(P=m.slice(0,v),l(S,P),M=v,w=m.length;M0&&h(S,P,m[M]);return P.sort(d)}var b=T.guessLength(m);return b!==null&&b0&&h(S,P,O)),M++}),P.length>M&&(P.length=M),P.sort(d)}function f(d,v,m){arguments.length===2&&(m=v,v=d,d=E);var S=s(d),M,w,C,A=-1/0,P;if(v===1){if(T.isArrayLike(m)){for(M=0,w=m.length;M0)&&(A=C);return P=new m.constructor(1),P[0]=A,P}return i(m,function(O){(A===-1/0||d(O,A)>0)&&(A=O)}),[A]}if(T.isArrayLike(m)){if(v>=m.length)return m.slice().sort(S);for(P=m.slice(0,v),l(d,P),M=v,w=m.length;M0&&h(d,P,m[M]);return P.sort(S)}var b=T.guessLength(m);return b!==null&&b0&&h(d,P,O)),M++}),P.length>M&&(P.length=M),P.sort(S)}function o(d){if(this.clear(),this.comparator=d||E,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}o.prototype.clear=function(){this.items=[],this.size=0},o.prototype.push=function(d){return r(this.comparator,this.items,d),++this.size},o.prototype.peek=function(){return this.items[0]},o.prototype.pop=function(){return this.size!==0&&this.size--,p(this.comparator,this.items)},o.prototype.replace=function(d){return h(this.comparator,this.items,d)},o.prototype.pushpop=function(d){return a(this.comparator,this.items,d)},o.prototype.consume=function(){return this.size=0,n(this.comparator,this.items)},o.prototype.toArray=function(){return n(this.comparator,this.items.slice())},o.prototype.inspect=function(){var d=this.toArray();return Object.defineProperty(d,"constructor",{value:o,enumerable:!1}),d},typeof Symbol<"u"&&(o.prototype[Symbol.for("nodejs.util.inspect.custom")]=o.prototype.inspect);function c(d){if(this.clear(),this.comparator=d||E,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=s(this.comparator)}c.prototype=o.prototype,o.from=function(d,v){var m=new o(v),S;return T.isArrayLike(d)?S=d.slice():S=T.toArray(d),l(m.comparator,S),m.items=S,m.size=S.length,m},c.from=function(d,v){var m=new c(v),S;return T.isArrayLike(d)?S=d.slice():S=T.toArray(d),l(m.comparator,S),m.items=S,m.size=S.length,m},o.siftUp=e,o.siftDown=y,o.push=r,o.pop=p,o.replace=h,o.pushpop=a,o.heapify=l,o.consume=n,o.nsmallest=u,o.nlargest=f,o.MinHeap=o,o.MaxHeap=c,t.exports=o}),BF=si((g,t)=>{var i="";function x(r,p,h){for(var a=p.length,l=[],n=a,u=-1,f,o=0,c;n--;)u=Math.max(r[p[n]+h],u);for(c=u>>24&&32||u>>16&&24||u>>8&&16||8;o>o&15].push(p[n]);for(f=0;f<16;f++)for(u=l[f].length;u--;)p[++n]=l[f][u]}}function T(r,p,h,a){return r[h]-r[a]||(h%3===2?r[h+1]-r[a+1]||p[h+2]-p[a+2]:p[h+1]-p[a+1])}function E(r,p){var h=[],a=[],l=2*p/3|0,n=p-l,u=l+1>>1,f=l,o=0,c,d=[],v=[];if(p===1)return[0];for(;f--;)h[f]=(f*3>>1)+1;for(f=3;f--;)x(r,h,f);for(o=a[(h[0]/3|0)+(h[0]%3===1?0:u)]=1,f=1;fthis.firstLength&&n>this.firstLength)){for(p=Math.min(this.length-l,this.length-n),a=0;ar.length&&(r=this.text.slice(l,l+p))}return r},e.prototype.toString=function(){return this.array.join(",")},e.prototype.toJSON=function(){return this.array},e.prototype.inspect=function(){for(var r=new Array(this.length),p=0;p{var i=zn();function x(r){this.size=0,this.items=new Map,this.inverse=r}function T(){this.size=0,this.items=new Map,this.inverse=new x(this)}function E(){this.size=0,this.items.clear(),this.inverse.items.clear()}T.prototype.clear=E,x.prototype.clear=E;function s(r,p){if(this.items.has(r)){var h=this.items.get(r);if(h===p)return this;this.inverse.items.delete(h)}if(this.inverse.items.has(p)){var a=this.inverse.items.get(p);if(a===r)return this;this.items.delete(a)}return this.items.set(r,p),this.inverse.items.set(p,r),this.size=this.items.size,this.inverse.size=this.inverse.items.size,this}T.prototype.set=s,x.prototype.set=s;function y(r){if(this.items.has(r)){var p=this.items.get(r);return this.items.delete(r),this.inverse.items.delete(p),this.size=this.items.size,this.inverse.size=this.inverse.items.size,!0}return!1}T.prototype.delete=y,x.prototype.delete=y;var e=["has","get","forEach","keys","values","entries"];e.forEach(function(r){T.prototype[r]=x.prototype[r]=function(){return Map.prototype[r].apply(this.items,arguments)}}),typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.entries,x.prototype[Symbol.iterator]=x.prototype.entries),T.prototype.inspect=function(){var r={left:this.items,right:this.inverse.items};return Object.defineProperty(r,"constructor",{value:T,enumerable:!1}),r},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),x.prototype.inspect=function(){var r={left:this.inverse.items,right:this.items};return Object.defineProperty(r,"constructor",{value:x,enumerable:!1}),r},typeof Symbol<"u"&&(x.prototype[Symbol.for("nodejs.util.inspect.custom")]=x.prototype.inspect),T.from=function(r){var p=new T;return i(r,function(h,a){p.set(a,h)}),p},t.exports=T}),Vr=si((g,t)=>{function i(x){if(typeof x!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=x}typeof Symbol<"u"&&(i.prototype[Symbol.iterator]=function(){return this}),i.of=function(){var x=arguments,T=x.length,E=0;return new i(function(){return E>=T?{done:!0}:{done:!1,value:x[E++]}})},i.empty=function(){var x=new i(function(){return{done:!0}});return x},i.fromSequence=function(x){var T=0,E=x.length;return new i(function(){return T>=E?{done:!0}:{done:!1,value:x[T++]}})},i.is=function(x){return x instanceof i?!0:typeof x=="object"&&x!==null&&typeof x.next=="function"},t.exports=i}),VM=si(g=>{function t(s){return s|=s>>1,s|=s>>2,s|=s>>4,s|=s>>8,s|=s>>16,s&~(s>>1)}g.msb32=t;function i(s){return s|=s>>1,s|=s>>2,s|=s>>4,s&~(s>>1)}g.msb8=i,g.test=function(s,y){return s>>y&1},g.criticalBit8=function(s,y){return i(s^y)},g.criticalBit8Mask=function(s,y){return~i(s^y)>>>0&255},g.testCriticalBit8=function(s,y){return 1+(s|y)>>8},g.criticalBit32Mask=function(s,y){return~t(s^y)>>>0&4294967295},g.popcount=function(s){return s-=s>>1&1431655765,s=(s&858993459)+(s>>2&858993459),s=s+(s>>4)&252645135,s+=s>>8,s+=s>>16,s&127};var x=new Uint8Array(Math.pow(2,8));for(T=0,E=x.length;T>8&255]+x[s>>16&255]+x[s>>24&255]}}),zF=si((g,t)=>{var i=Vr(),x=VM();function T(E){this.length=E,this.clear()}T.prototype.clear=function(){this.size=0,this.array=new Uint32Array(Math.ceil(this.length/32))},T.prototype.set=function(E,s){var y=E>>5,e=E&31,r=this.array[y],p;return s===0||s===!1?p=this.array[y]&=~(1<>>0,p>r?this.size++:p>5,y=E&31,e=this.array[s],r;return r=this.array[s]&=~(1<>5,y=E&31,e=this.array[s],r=this.array[s]^=1<>>0,r>e?this.size++:r>5,y=E&31;return this.array[s]>>y&1},T.prototype.test=function(E){return!!this.get(E)},T.prototype.rank=function(E){if(this.size===0)return 0;for(var s=E>>5,y=E&31,e=0,r=0;r=this.length)return-1;for(var s,y=32,e=0,r=0,p=0,h=this.array.length;p>a&1,r===E)return e}},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=this.length,e,r,p=32,h=0,a=this.array.length;h>l&1,E.call(s,r,h*32+l)}},T.prototype.values=function(){var E=this.length,s=!1,y,e,r=this.array,p=r.length,h=0,a=-1,l=32;return new i(function n(){if(!s){if(h>=p)return{done:!0};h===p-1&&(l=E%32||32),y=r[h++],s=!0,a=-1}return a++,a>=l?(s=!1,n()):(e=y>>a&1,{value:e})})},T.prototype.entries=function(){var E=this.length,s=!1,y,e,r=this.array,p,h=r.length,a=0,l=-1,n=32;return new i(function u(){if(!s){if(a>=h)return{done:!0};a===h-1&&(n=E%32||32),y=r[a++],s=!0,l=-1}return l++,p=~-a*32+l,l>=n?(s=!1,u()):(e=y>>l&1,{value:[p,e]})})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=new Uint8Array(this.length);return this.forEach(function(s,y){E[y]=s}),Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.prototype.toJSON=function(){return Array.from(this.array)},t.exports=T}),GF=si((g,t)=>{var i=Vr(),x=VM(),T=function(y){return Math.max(1,Math.ceil(y*1.5))};function E(y){return new Uint32Array(Math.ceil(y/32))}function s(y){var e=y||0,r=T;typeof y=="object"&&(e=y.initialLength||y.initialCapacity||0,r=y.policy||r),this.size=0,this.length=e,this.capacity=Math.ceil(this.length/32)*32,this.policy=r,this.array=E(this.capacity)}s.prototype.set=function(y,e){if(this.length>5,p=y&31,h=this.array[r],a;return e===0||e===!1?a=this.array[r]&=~(1<>>0,a>h?this.size++:a>5,r=y&31,p=this.array[e],h;return h=this.array[e]&=~(1<>5,r=y&31,p=this.array[e],h=this.array[e]^=1<>>0,h>p?this.size++:hthis.array.length?(this.array=new Uint32Array(p),this.array.set(r,0)):this.array=r.slice(0,p),this.capacity=y,this)},s.prototype.grow=function(y){var e;if(typeof y=="number"){if(this.capacity>=y)return this;for(e=this.capacity;e>5,p=e&31;return this.array[r]|=1<>5,r=y&31;return this.array[e]>>r&1}},s.prototype.get=function(y){if(!(this.length>5,r=y&31;return this.array[e]>>r&1}},s.prototype.test=function(y){return this.length>5,r=y&31,p=0,h=0;h=this.length)return-1;for(var e,r=32,p=0,h=0,a=0,l=this.array.length;a>n&1,h===y)return p}},s.prototype.forEach=function(y,e){e=arguments.length>1?e:this;for(var r=this.length,p,h,a=32,l=0,n=this.array.length;l>u&1,y.call(e,h,l*32+u)}},s.prototype.values=function(){var y=this.length,e=!1,r,p,h=this.array,a=h.length,l=0,n=-1,u=32;return new i(function f(){if(!e){if(l>=a)return{done:!0};l===a-1&&(u=y%32||32),r=h[l++],e=!0,n=-1}return n++,n>=u?(e=!1,f()):(p=r>>n&1,{value:p})})},s.prototype.entries=function(){var y=this.length,e=!1,r,p,h=this.array,a,l=h.length,n=0,u=-1,f=32;return new i(function o(){if(!e){if(n>=l)return{done:!0};n===l-1&&(f=y%32||32),r=h[n++],e=!0,u=-1}return u++,a=~-n*32+u,u>=f?(e=!1,o()):(p=r>>u&1,{value:[a,p]})})},typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=s.prototype.values),s.prototype.inspect=function(){var y=new Uint8Array(this.length);return this.forEach(function(e,r){y[r]=e}),Object.defineProperty(y,"constructor",{value:s,enumerable:!1}),y},typeof Symbol<"u"&&(s.prototype[Symbol.for("nodejs.util.inspect.custom")]=s.prototype.inspect),s.prototype.toJSON=function(){return Array.from(this.array.slice(0,(this.length>>5)+1))},t.exports=s}),VF=si((g,t)=>{function i(E,s){return(E&65535)*s+(((E>>>16)*s&65535)<<16)&4294967295}function x(E,s){return(E&65535)+(s>>>16)+(((E>>>16)+s&65535)<<16)&4294967295}function T(E,s){return E<>>32-s}t.exports=function(E,s){var y=3432918353,e=461845907,r=15,p=13,h=5,a=1801774676,l=E,n,u,f;for(u=0,f=s.length-4;u<=f;u+=4)n=s[u]|s[u+1]<<8|s[u+2]<<16|s[u+3]<<24,n=i(n,y),n=T(n,r),n=i(n,e),l^=n,l=T(l,p),l=i(l,h),l=x(l,a);switch(n=0,s.length&3){case 3:n^=s[u+2]<<16;case 2:n^=s[u+1]<<8;case 1:n^=s[u],n=i(n,y),n=T(n,r),n=i(n,e),l^=n}return l^=s.length,l^=l>>>16,l=i(l,2246822507),l^=l>>>13,l=i(l,3266489909),l^=l>>>16,l>>>0}}),HF=si((g,t)=>{var i=VF(),x=zn(),T=Math.LN2*Math.LN2,E={errorRate:.005};function s(r){var p=new Uint16Array(r.length),h,a;for(h=0,a=r.length;h>3]|=n}return this},e.prototype.test=function(r){for(var p=s(r),h=0,a=this.hashFunctions;h>3]&1<<(7&l)))return!1}return!0},e.prototype.toJSON=function(){return this.data},e.from=function(r,p){if(!p&&(p=r.length||r.size,typeof p!="number"))throw new Error("BloomFilter.from: could not infer the filter's capacity. Try passing it as second argument.");var h=new e(p);return x(r,function(a){h.add(a)}),h},t.exports=e}),WF=si((g,t)=>{var i=zn();function x(T){if(typeof T!="function")throw new Error("mnemonist/BKTree.constructor: given `distance` should be a function.");this.distance=T,this.clear()}x.prototype.add=function(T){if(!this.root)return this.root={item:T,children:{}},this.size++,this;for(var E=this.root,s;s=this.distance(T,E.item),!!E.children[s];)E=E.children[s];return E.children[s]={item:T,children:{}},this.size++,this},x.prototype.search=function(T,E){if(!this.root)return[];for(var s=[],y=[this.root],e,r,p,h,a;y.length;)for(e=y.pop(),p=this.distance(E,e.item),p<=T&&s.push({item:e.item,distance:p}),h=p-T,a=p+T+1;h{var i=sa(),x=Vr();function T(E,s){if(arguments.length<2)throw new Error("mnemonist/fixed-deque: expecting an Array class and a capacity.");if(typeof s!="number"||s<=0)throw new Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=E,this.capacity=s,this.items=new E(this.capacity),this.clear()}T.prototype.clear=function(){this.start=0,this.size=0},T.prototype.push=function(E){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.push: deque capacity ("+this.capacity+") exceeded!");var s=this.start+this.size;return s>=this.capacity&&(s-=this.capacity),this.items[s]=E,++this.size},T.prototype.unshift=function(E){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var s=this.start-1;return this.start===0&&(s=this.capacity-1),this.items[s]=E,this.start=s,++this.size},T.prototype.pop=function(){if(this.size!==0){this.size--;var E=this.start+this.size;return E>=this.capacity&&(E-=this.capacity),this.items[E]}},T.prototype.shift=function(){if(this.size!==0){var E=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[E]}},T.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},T.prototype.peekLast=function(){if(this.size!==0){var E=this.start+this.size-1;return E>=this.capacity&&(E-=this.capacity),this.items[E]}},T.prototype.get=function(E){if(!(this.size===0||E>=this.capacity))return E=this.start+E,E>=this.capacity&&(E-=this.capacity),this.items[E]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=this.capacity,e=this.size,r=this.start,p=0;p=y)return{done:!0};var p=E[e];return e++,r++,e===s&&(e=0),{value:p,done:!1}})},T.prototype.entries=function(){var E=this.items,s=this.capacity,y=this.size,e=this.start,r=0;return new x(function(){if(r>=y)return{done:!0};var p=E[e];return e++,e===s&&(e=0),{value:[r++,p],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=this.toArray();return E.type=this.ArrayClass.name,E.capacity=this.capacity,Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E,s,y){if(arguments.length<3&&(y=i.guessLength(E),typeof y!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var e=new T(s,y);if(i.isArrayLike(E)){var r,p;for(r=0,p=E.length;r{var i=sa(),x=HM();function T(s,y){if(arguments.length<2)throw new Error("mnemonist/circular-buffer: expecting an Array class and a capacity.");if(typeof y!="number"||y<=0)throw new Error("mnemonist/circular-buffer: `capacity` should be a positive number.");this.ArrayClass=s,this.capacity=y,this.items=new s(this.capacity),this.clear()}function E(s){T.prototype[s]=x.prototype[s]}Object.keys(x.prototype).forEach(E),typeof Symbol<"u"&&Object.getOwnPropertySymbols(x.prototype).forEach(E),T.prototype.push=function(s){var y=this.start+this.size;return y>=this.capacity&&(y-=this.capacity),this.items[y]=s,this.size===this.capacity?(y++,y>=this.capacity?this.start=0:this.start=y,this.size):++this.size},T.prototype.unshift=function(s){var y=this.start-1;return this.start===0&&(y=this.capacity-1),this.items[y]=s,this.size===this.capacity?(this.start=y,this.size):(this.start=y,++this.size)},T.from=function(s,y,e){if(arguments.length<3&&(e=i.guessLength(s),typeof e!="number"))throw new Error("mnemonist/circular-buffer.from: could not guess iterable length. Please provide desired capacity as last argument.");var r=new T(y,e);if(i.isArrayLike(s)){var p,h;for(p=0,h=s.length;p{function i(x){if(typeof x!="function")throw new Error("mnemonist/DefaultMap.constructor: expecting a function.");this.items=new Map,this.factory=x,this.size=0}i.prototype.clear=function(){this.items.clear(),this.size=0},i.prototype.get=function(x){var T=this.items.get(x);return typeof T>"u"&&(T=this.factory(x,this.size),this.items.set(x,T),this.size++),T},i.prototype.peek=function(x){return this.items.get(x)},i.prototype.set=function(x,T){return this.items.set(x,T),this.size=this.items.size,this},i.prototype.has=function(x){return this.items.has(x)},i.prototype.delete=function(x){var T=this.items.delete(x);return this.size=this.items.size,T},i.prototype.forEach=function(x,T){T=arguments.length>1?T:this,this.items.forEach(x,T)},i.prototype.entries=function(){return this.items.entries()},i.prototype.keys=function(){return this.items.keys()},i.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(i.prototype[Symbol.iterator]=i.prototype.entries),i.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(i.prototype[Symbol.for("nodejs.util.inspect.custom")]=i.prototype.inspect),i.autoIncrement=function(){var x=0;return function(){return x++}},t.exports=i}),kF=si((g,t)=>{function i(x){if(typeof x!="function")throw new Error("mnemonist/DefaultWeakMap.constructor: expecting a function.");this.items=new WeakMap,this.factory=x}i.prototype.clear=function(){this.items=new WeakMap},i.prototype.get=function(x){var T=this.items.get(x);return typeof T>"u"&&(T=this.factory(x),this.items.set(x,T)),T},i.prototype.peek=function(x){return this.items.get(x)},i.prototype.set=function(x,T){return this.items.set(x,T),this},i.prototype.has=function(x){return this.items.has(x)},i.prototype.delete=function(x){return this.items.delete(x)},i.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(i.prototype[Symbol.for("nodejs.util.inspect.custom")]=i.prototype.inspect),t.exports=i}),KF=si((g,t)=>{var i=Is();function x(T){var E=i.getPointerArray(T),s=i.getPointerArray(Math.log2(T));this.size=T,this.dimension=T,this.parents=new E(T),this.ranks=new s(T);for(var y=0;yr?this.parents[y]=s:(this.parents[y]=s,this.ranks[s]++),this},x.prototype.connected=function(T,E){var s=this.find(T);return s===this.find(E)},x.prototype.mapping=function(){for(var T=i.getPointerArray(this.dimension),E={},s=new T(this.size),y=0,e,r=0,p=this.parents.length;r"u"?(s[r]=y,E[e]=y++):s[r]=E[e];return s},x.prototype.compile=function(){for(var T={},E=new Array(this.dimension),s=0,y,e=0,r=this.parents.length;e"u"?(E[s]=[e],T[y]=s++):E[T[y]].push(e);return E},x.prototype.inspect=function(){var T=this.compile();return Object.defineProperty(T,"constructor",{value:x,enumerable:!1}),T},typeof Symbol<"u"&&(x.prototype[Symbol.for("nodejs.util.inspect.custom")]=x.prototype.inspect),t.exports=x}),Wx=si((g,t)=>{var i=Jm(),x=Hx(),T=i.DEFAULT_COMPARATOR,E=i.reverseComparator;function s(r,p,h,a){for(var l=h,n=a,u=p[a],f=2*a+1,o;f=0&&(f=o),p[a]=p[f],a=f,f=2*a+1;p[a]=u,x.siftDown(r,p,n,a)}function y(r,p,h,a){for(var l=a,n=l,u=new r(a),f,o;n>0;)f=h[--n],n!==0&&(o=h[0],h[0]=f,s(p,h,--a,0),f=o),u[n]=f;return u}function e(r,p,h){if(arguments.length===2&&(h=p,p=null),this.ArrayClass=r,this.capacity=h,this.items=new r(h),this.clear(),this.comparator=p||T,typeof h!="number"&&h<=0)throw new Error("mnemonist/FixedReverseHeap.constructor: capacity should be a number > 0.");if(typeof this.comparator!="function")throw new Error("mnemonist/FixedReverseHeap.constructor: given comparator should be a function.");this.comparator=E(this.comparator)}e.prototype.clear=function(){this.size=0},e.prototype.push=function(r){return this.size0&&x.replace(this.comparator,this.items,r),this.size},e.prototype.peek=function(){return this.items[0]},e.prototype.consume=function(){var r=y(this.ArrayClass,this.comparator,this.items,this.size);return this.size=0,r},e.prototype.toArray=function(){return y(this.ArrayClass,this.comparator,this.items.slice(0,this.size),this.size)},e.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:e,enumerable:!1}),r},typeof Symbol<"u"&&(e.prototype[Symbol.for("nodejs.util.inspect.custom")]=e.prototype.inspect),t.exports=e}),jF=si((g,t)=>{var i=zn(),x=function(E){return E};function T(E){if(this.items=new Map,this.clear(),Array.isArray(E)?(this.writeHashFunction=E[0],this.readHashFunction=E[1]):(this.writeHashFunction=E,this.readHashFunction=E),this.writeHashFunction||(this.writeHashFunction=x),this.readHashFunction||(this.readHashFunction=x),typeof this.writeHashFunction!="function")throw new Error("mnemonist/FuzzyMap.constructor: invalid hash function given.");if(typeof this.readHashFunction!="function")throw new Error("mnemonist/FuzzyMap.constructor: invalid hash function given.")}T.prototype.clear=function(){this.items.clear(),this.size=0},T.prototype.add=function(E){var s=this.writeHashFunction(E);return this.items.set(s,E),this.size=this.items.size,this},T.prototype.set=function(E,s){return E=this.writeHashFunction(E),this.items.set(E,s),this.size=this.items.size,this},T.prototype.get=function(E){return E=this.readHashFunction(E),this.items.get(E)},T.prototype.has=function(E){return E=this.readHashFunction(E),this.items.has(E)},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this,this.items.forEach(function(y){E.call(s,y,y)})},T.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=Array.from(this.items.values());return Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E,s,y){var e=new T(s);return i(E,function(r,p){y?e.set(p,r):e.add(r)}),e},t.exports=T}),WM=si((g,t)=>{var i=Vr(),x=zn();function T(E){this.Container=E||Array,this.items=new Map,this.clear(),Object.defineProperty(this.items,"constructor",{value:T,enumerable:!1})}T.prototype.clear=function(){this.size=0,this.dimension=0,this.items.clear()},T.prototype.set=function(E,s){var y=this.items.get(E),e;return y||(this.dimension++,y=new this.Container,this.items.set(E,y)),this.Container===Set?(e=y.size,y.add(s),e"u"?0:this.Container===Set?s.size:s.length},T.prototype.count=T.prototype.multiplicity,T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;var y;function e(r){E.call(s,r,y)}this.items.forEach(function(r,p){y=p,r.forEach(e)})},T.prototype.forEachAssociation=function(E,s){s=arguments.length>1?s:this,this.items.forEach(E,s)},T.prototype.keys=function(){return this.items.keys()},T.prototype.values=function(){var E=this.items.values(),s=!1,y,e,r,p;return this.Container===Set?new i(function h(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,y=e.value.values()}return e=y.next(),e.done?(s=!1,h()):{done:!1,value:e.value}}):new i(function h(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,y=e.value,r=0,p=y.length}return r>=p?(s=!1,h()):{done:!1,value:y[r++]}})},T.prototype.entries=function(){var E=this.items.entries(),s=!1,y,e,r,p,h;return this.Container===Set?new i(function a(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,r=e.value[0],y=e.value[1].values()}return e=y.next(),e.done?(s=!1,a()):{done:!1,value:[r,e.value]}}):new i(function a(){if(!s){if(e=E.next(),e.done)return{done:!0};s=!0,r=e.value[0],y=e.value[1],p=0,h=y.length}return p>=h?(s=!1,a()):{done:!1,value:[r,y[p++]]}})},T.prototype.containers=function(){return this.items.values()},T.prototype.associations=function(){return this.items.entries()},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.entries),T.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.prototype.toJSON=function(){return this.items},T.from=function(E,s){var y=new T(s);return x(E,function(e,r){y.set(r,e)}),y},t.exports=T}),ZF=si((g,t)=>{var i=WM(),x=zn(),T=function(s){return s};function E(s,y){if(this.items=new i(y),this.clear(),Array.isArray(s)?(this.writeHashFunction=s[0],this.readHashFunction=s[1]):(this.writeHashFunction=s,this.readHashFunction=s),this.writeHashFunction||(this.writeHashFunction=T),this.readHashFunction||(this.readHashFunction=T),typeof this.writeHashFunction!="function")throw new Error("mnemonist/FuzzyMultiMap.constructor: invalid hash function given.");if(typeof this.readHashFunction!="function")throw new Error("mnemonist/FuzzyMultiMap.constructor: invalid hash function given.")}E.prototype.clear=function(){this.items.clear(),this.size=0,this.dimension=0},E.prototype.add=function(s){var y=this.writeHashFunction(s);return this.items.set(y,s),this.size=this.items.size,this.dimension=this.items.dimension,this},E.prototype.set=function(s,y){return s=this.writeHashFunction(s),this.items.set(s,y),this.size=this.items.size,this.dimension=this.items.dimension,this},E.prototype.get=function(s){return s=this.readHashFunction(s),this.items.get(s)},E.prototype.has=function(s){return s=this.readHashFunction(s),this.items.has(s)},E.prototype.forEach=function(s,y){y=arguments.length>1?y:this,this.items.forEach(function(e){s.call(y,e,e)})},E.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=E.prototype.values),E.prototype.inspect=function(){var s=Array.from(this);return Object.defineProperty(s,"constructor",{value:E,enumerable:!1}),s},typeof Symbol<"u"&&(E.prototype[Symbol.for("nodejs.util.inspect.custom")]=E.prototype.inspect),E.from=function(s,y,e,r){arguments.length===3&&typeof e=="boolean"&&(r=e,e=Array);var p=new E(y,e);return x(s,function(h,a){r?p.set(a,h):p.add(h)}),p},t.exports=E}),JF=si((g,t)=>{var i=1024;function x(E){return(E&E-1)===0}function T(E,s){if(arguments.length<1)throw new Error("mnemonist/hashed-array-tree: expecting at least a byte array constructor.");var y=s||0,e=i,r=0;if(typeof s=="object"&&(y=s.initialCapacity||0,r=s.initialLength||0,e=s.blockSize||i),!e||!x(e))throw new Error("mnemonist/hashed-array-tree: block size should be a power of two.");var p=Math.max(r,y),h=Math.ceil(p/e);this.ArrayClass=E,this.length=r,this.capacity=h*e,this.blockSize=e,this.offsetMask=e-1,this.blockMask=Math.log2(e),this.blocks=new Array(h);for(var a=0;a>this.blockMask,e=E&this.offsetMask;return this.blocks[y][e]=s,this},T.prototype.get=function(E){if(!(this.length>this.blockMask,y=E&this.offsetMask;return this.blocks[s][y]}},T.prototype.grow=function(E){if(typeof E!="number"&&(E=this.capacity+this.blockSize),this.capacity>=E)return this;for(;this.capacity>this.blockMask,e=s&this.offsetMask;return this.blocks[y][e]=E,++this.length},T.prototype.pop=function(){if(this.length!==0){var E=this.blocks[this.blocks.length-1],s=--this.length&this.offsetMask;return E[s]}},T.prototype.inspect=function(){for(var E=new this.ArrayClass(this.length),s,y=0,e=this.length;y>this.blockMask,E[y]=this.blocks[s][y&this.offsetMask];return E.type=this.ArrayClass.name,E.items=this.length,E.capacity=this.capacity,E.blockSize=this.blockSize,Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),t.exports=T}),XM=si((g,t)=>{var i=Vr(),x=sa();function T(E,s){if(arguments.length<2)throw new Error("mnemonist/fixed-stack: expecting an Array class and a capacity.");if(typeof s!="number"||s<=0)throw new Error("mnemonist/fixed-stack: `capacity` should be a positive number.");this.capacity=s,this.ArrayClass=E,this.items=new this.ArrayClass(this.capacity),this.clear()}T.prototype.clear=function(){this.size=0},T.prototype.push=function(E){if(this.size===this.capacity)throw new Error("mnemonist/fixed-stack.push: stack capacity ("+this.capacity+") exceeded!");return this.items[this.size++]=E,this.size},T.prototype.pop=function(){if(this.size!==0)return this.items[--this.size]},T.prototype.peek=function(){return this.items[this.size-1]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=0,e=this.items.length;y=s)return{done:!0};var e=E[s-y-1];return y++,{value:e,done:!1}})},T.prototype.entries=function(){var E=this.items,s=this.size,y=0;return new i(function(){if(y>=s)return{done:!0};var e=E[s-y-1];return{value:[y++,e],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.toString=function(){return this.toArray().join(",")},T.prototype.toJSON=function(){return this.toArray()},T.prototype.inspect=function(){var E=this.toArray();return E.type=this.ArrayClass.name,E.capacity=this.capacity,Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E,s,y){if(arguments.length<3&&(y=x.guessLength(E),typeof y!="number"))throw new Error("mnemonist/fixed-stack.from: could not guess iterable length. Please provide desired capacity as last argument.");var e=new T(s,y);if(x.isArrayLike(E)){var r,p;for(r=0,p=E.length;r{var i=sa(),x=Is(),T=XM();function E(y,e,r,p,h,a,l,n){var u=l+(n-l)/2|0,f=~-u,o=-~u,c=r[u];p[a]=c+1;var d=e?e(y[c]):y[c][1],v=a*2+1,m=a*2+2,S=-1/0,M=-1/0;l<=f&&(S=E(y,e,r,p,h,v,l,f)),o<=n&&(M=E(y,e,r,p,h,m,o,n));var w=Math.max(d,S,M),C=c;return w===S?C=h[p[v]-1]:w===M&&(C=h[p[m]-1]),h[c]=C,w}function s(y,e){this.size=y.length,this.intervals=y;var r=null,p=null;Array.isArray(e)&&(r=e[0],p=e[1]);var h=y.length,a=x.getPointerArray(h+1),l=new a(h),n;for(n=1;nv?1:0});var u=Math.ceil(Math.log2(h+1)),f=Math.pow(2,u)-1,o=new a(f),c=new a(h);E(y,p,l,o,c,0,0,h-1),l=null,this.height=u,this.tree=o,this.augmentations=c,this.startGetter=r,this.endGetter=p,this.stack=new T(a,this.height)}s.prototype.intervalsContainingPoint=function(y){var e=[],r=this.stack;r.clear(),r.push(0);for(var p=this.tree.length,h,a,l,n,u,f,o,c,d;r.size;)h=r.pop(),a=this.tree[h]-1,l=this.intervals[a],n=this.intervals[this.augmentations[a]],o=this.endGetter?this.endGetter(n):n[1],!(y>o)&&(c=h*2+1,c=u&&y<=f&&e.push(l),!(yd)&&(v=l*2+1,v=o&&e<=c&&p.push(u),!(r{g.search=function(t,i,x,T){var E=0;x=typeof x<"u"?x:0,T=typeof T<"u"?T:t.length,T--;for(var s;x<=T;)if(E=x+T>>>1,s=t[E],s>i)T=~-E;else if(s>>1,y=t(i[T],x),y>0)s=~-T;else if(y<0)E=-~T;else return T;return-1},g.lowerBound=function(t,i,x,T){var E=0;for(x=typeof x<"u"?x:0,T=typeof T<"u"?T:t.length;x>>1,i<=t[E]?T=E:x=-~E;return x},g.lowerBoundWithComparator=function(t,i,x){for(var T=0,E=0,s=i.length;E>>1,t(x,i[T])<=0?s=T:E=-~T;return E},g.lowerBoundIndices=function(t,i,x,T,E){var s=0;for(T=typeof T<"u"?T:0,E=typeof E<"u"?E:t.length;T>>1,x<=t[i[s]]?E=s:T=-~s;return T},g.upperBound=function(t,i,x,T){var E=0;for(x=typeof x<"u"?x:0,T=typeof T<"u"?T:t.length;x>>1,i>=t[E]?x=-~E:T=E;return x},g.upperBoundWithComparator=function(t,i,x){for(var T=0,E=0,s=i.length;E>>1,t(x,i[T])>=0?E=-~T:s=T;return E}}),QF=si(g=>{var t=Is(),i=sa().isArrayLike,x=YM(),T=Vx();function E(r,p){if(r.length===0)return p.slice();if(p.length===0)return r.slice();var h;r[0]>p[0]&&(h=r,r=p,p=h);var a=r[r.length-1],l=p[0];if(a<=l)return t.isTypedArray(r)?t.concat(r,p):r.concat(p);var n=new r.constructor(r.length+p.length),u,f,o;for(u=0,f=r.length;up[0]&&(h=r,r=p,p=h);var a=r[r.length-1],l=p[0];if(ap[0]&&(h=r,r=p,p=h);var a=r[r.length-1],l=p[0];if(av?o=x.lowerBound(p,d,o+1):(n.push(d),u++,o++);return n};function y(r){var p=0,h=-1/0,a,l,n,u=[];for(l=0,n=r.length;lh&&(h=a));if(u.length===0)return new r[0].constructor(0);if(u.length===1)return u[0].slice();if(u.length===2)return E(u[0],u[1]);r=u;var f=new r[0].constructor(p),o=t.getPointerArray(h),c=new o(r.length),d=new T(function(S,M){return S=r[S][c[S]],M=r[M][c[M]],SM?1:0});for(l=0;lp&&(p=h));if(n.length===0)return new r[0].constructor(0);if(n.length===1)return n[0].slice();if(n.length===2)return s(n[0],n[1]);r=n;var u=new r[0].constructor,f=t.getPointerArray(p),o=new f(r.length),c=new T(function(m,S){return m=r[m][o[m]],S=r[S][o[S]],mS?1:0});for(a=0;ap&&(p=a),lh)return[];if(p===h)return[p];var o,c,d=r[0],v,m,S,M,w,C,A=p;for(u=1;uC?m=x.lowerBound(c,w,m+1):(d.push(w),v++,m++);if(d.length===0)return d;A=d[0]}return d},g.merge=function(){if(arguments.length===2){if(i(arguments[0]))return E(arguments[0],arguments[1])}else if(i(arguments[0]))return y(arguments);return null},g.unionUnique=function(){if(arguments.length===2){if(i(arguments[0]))return s(arguments[0],arguments[1])}else if(i(arguments[0]))return e(arguments);return null},g.intersectionUnique=function(){if(arguments.length===2){if(i(arguments[0]))return g.intersectionUniqueArrays(arguments[0],arguments[1])}else if(i(arguments[0]))return g.kWayIntersectionUniqueArrays(arguments);return null}}),_F=si((g,t)=>{var i=Vr(),x=zn(),T=QF();function E(y){return y}function s(y){if(this.clear(),Array.isArray(y)?(this.documentTokenizer=y[0],this.queryTokenizer=y[1]):(this.documentTokenizer=y,this.queryTokenizer=y),this.documentTokenizer||(this.documentTokenizer=E),this.queryTokenizer||(this.queryTokenizer=E),typeof this.documentTokenizer!="function")throw new Error("mnemonist/InvertedIndex.constructor: document tokenizer is not a function.");if(typeof this.queryTokenizer!="function")throw new Error("mnemonist/InvertedIndex.constructor: query tokenizer is not a function.")}s.prototype.clear=function(){this.items=[],this.mapping=new Map,this.size=0,this.dimension=0},s.prototype.add=function(y){this.size++;var e=this.items.length;this.items.push(y);var r=this.documentTokenizer(y);if(!Array.isArray(r))throw new Error("mnemonist/InvertedIndex.add: tokenizer function should return an array of tokens.");for(var p=new Set,h,a,l=0,n=r.length;l"u"||r.length===0)return[];if(e.length>1)for(h=1,a=e.length;h"u"||p.length===0)return[];r=T.intersectionUniqueArrays(r,p)}var l=new Array(r.length);for(h=0,a=l.length;h1?e:this;for(var r=0,p=this.documents.length;r=e)return{done:!0};var p=y[r++];return{value:p,done:!1}})},s.prototype.tokens=function(){return this.mapping.keys()},typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=s.prototype.documents),s.prototype.inspect=function(){var y=this.items.slice();return Object.defineProperty(y,"constructor",{value:s,enumerable:!1}),y},typeof Symbol<"u"&&(s.prototype[Symbol.for("nodejs.util.inspect.custom")]=s.prototype.inspect),s.from=function(y,e){var r=new s(e);return x(y,function(p){r.add(p)}),r},t.exports=s}),kM=si(g=>{var t=new Float64Array(64),i=new Float64Array(64);function x(E,s,y){var e,r,p,h,a;for(t[0]=s,i[0]=y,r=0;r>=0;)if(p=t[r],h=i[r]-1,p=e&&pi[r-1]-t[r-1]&&(a=t[r],t[r]=t[r-1],t[r-1]=a,a=i[r],i[r]=i[r-1],i[r-1]=a)}else r--;return E}g.inplaceQuickSort=x;function T(E,s,y,e){var r,p,h,a,l,n;for(t[0]=y,i[0]=e,p=0;p>=0;)if(h=t[p],a=i[p]-1,h=r&&hi[p-1]-t[p-1]&&(n=t[p],t[p]=t[p-1],t[p-1]=n,n=i[p],i[p]=i[p-1],i[p-1]=n)}else p--;return s}g.inplaceQuickSortIndices=T}),qF=si((g,t)=>{var i=sa(),x=Is(),T=Jm().createTupleComparator,E=Wx(),s=kM().inplaceQuickSortIndices;function y(l,n,u,f){var o,c=0,d;for(o=0;o>>1),P=u[A],d[D]=P,w>-1&&(C===0?v[w]=D+1:m[w]=D+1),I=(I+1)%l,A!==b&&A!==O-1&&S.push([I,A+1,O,D,1]),A!==b&&S.push([I,b,A,D,0]),D++;return{axes:n,labels:f,pivots:d,lefts:v,rights:m}}function p(l,n){this.dimensions=l,this.visited=0,this.axes=n.axes,this.labels=n.labels,this.pivots=n.pivots,this.lefts=n.lefts,this.rights=n.rights,this.size=this.labels.length}p.prototype.nearestNeighbor=function(l){var n=1/0,u=null,f=this.dimensions,o=this.axes,c=this.pivots,d=this.lefts,v=this.rights,m=0;function S(M,w){m++;var C=d[w],A=v[w],P=c[w],b=y(f,o,P,l);if(!(b0?C!==0&&S(M,C-1):A!==0&&S(M,A-1),O*O0?A!==0&&S(M,A-1):C!==0&&S(M,C-1))}}return S(0,0),this.visited=m,this.labels[u]};var h=T(3),a=T(2);p.prototype.kNearestNeighbors=function(l,n){if(l<=0)throw new Error("mnemonist/kd-tree.kNearestNeighbors: k should be a positive number.");if(l=Math.min(l,this.size),l===1)return[this.nearestNeighbor(n)];var u=new E(Array,h,l),f=this.dimensions,o=this.axes,c=this.pivots,d=this.lefts,v=this.rights,m=0;function S(C,A){var P=d[A],b=v[A],O=c[A],I=y(f,o,O,n);u.push([I,m++,O]);var D=n[C],B=o[C][O],G=D-B;C=(C+1)%f,D{var i=Vr(),x=zn();function T(){this.clear()}T.prototype.clear=function(){this.head=null,this.tail=null,this.size=0},T.prototype.first=function(){return this.head?this.head.item:void 0},T.prototype.peek=T.prototype.first,T.prototype.last=function(){return this.tail?this.tail.item:void 0},T.prototype.push=function(E){var s={item:E,next:null};return this.head?(this.tail.next=s,this.tail=s):(this.head=s,this.tail=s),this.size++,this.size},T.prototype.unshift=function(E){var s={item:E,next:null};return this.head?(this.head.next||(this.tail=this.head),s.next=this.head,this.head=s):(this.head=s,this.tail=s),this.size++,this.size},T.prototype.shift=function(){if(this.size){var E=this.head;return this.head=E.next,this.size--,E.item}},T.prototype.forEach=function(E,s){if(this.size){s=arguments.length>1?s:this;for(var y=this.head,e=0;y;)E.call(s,y.item,e,this),y=y.next,e++}},T.prototype.toArray=function(){if(!this.size)return[];for(var E=new Array(this.size),s=0,y=this.size,e=this.head;s{var i=Vr(),x=zn(),T=Is(),E=sa();function s(y,e,r){if(arguments.length<2&&(r=y,y=null,e=null),this.capacity=r,typeof this.capacity!="number"||this.capacity<=0)throw new Error("mnemonist/lru-cache: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-cache: capacity should be a finite positive integer.");var p=T.getPointerArray(r);this.forward=new p(r),this.backward=new p(r),this.K=typeof y=="function"?new y(r):new Array(r),this.V=typeof e=="function"?new e(r):new Array(r),this.size=0,this.head=0,this.tail=0,this.items={}}s.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},s.prototype.splayOnTop=function(y){var e=this.head;if(this.head===y)return this;var r=this.backward[y],p=this.forward[y];return this.tail===y?this.tail=r:this.backward[p]=r,this.forward[r]=p,this.backward[e]=y,this.head=y,this.forward[y]=e,this},s.prototype.set=function(y,e){var r=this.items[y];if(typeof r<"u"){this.splayOnTop(r),this.V[r]=e;return}this.size1?e:this;for(var r=0,p=this.size,h=this.head,a=this.K,l=this.V,n=this.forward;r=e)return{done:!0};var a=p[r];return y++,y=e)return{done:!0};var a=p[r];return y++,y=e)return{done:!0};var l=p[r],n=h[r];return y++,y{var i=Xx(),x=zn(),T=Is(),E=sa();function s(e,r,p){arguments.length<2?i.call(this,e):i.call(this,e,r,p);var h=T.getPointerArray(this.capacity);this.deleted=new h(this.capacity),this.deletedSize=0}for(y in i.prototype)s.prototype[y]=i.prototype[y];var y;typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=i.prototype[Symbol.iterator]),s.prototype.clear=function(){i.prototype.clear.call(this),this.deletedSize=0},s.prototype.set=function(e,r){var p=this.items[e];if(typeof p<"u"){this.splayOnTop(p),this.V[p]=r;return}this.size0?p=this.deleted[--this.deletedSize]:p=this.size,this.size++):(p=this.tail,this.tail=this.backward[p],delete this.items[this.K[p]]),this.items[e]=p,this.K[p]=e,this.V[p]=r,this.forward[p]=this.head,this.backward[this.head]=p,this.head=p},s.prototype.setpop=function(e,r){var p=null,h=null,a=this.items[e];return typeof a<"u"?(this.splayOnTop(a),p=this.V[a],this.V[a]=r,{evicted:!1,key:e,value:p}):(this.size0?a=this.deleted[--this.deletedSize]:a=this.size,this.size++):(a=this.tail,this.tail=this.backward[a],p=this.V[a],h=this.K[a],delete this.items[h]),this.items[e]=a,this.K[a]=e,this.V[a]=r,this.forward[a]=this.head,this.backward[this.head]=a,this.head=a,h?{evicted:!0,key:h,value:p}:null)},s.prototype.delete=function(e){var r=this.items[e];if(typeof r>"u")return!1;if(delete this.items[e],this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var p=this.backward[r],h=this.forward[r];return this.head===r&&(this.head=h),this.tail===r&&(this.tail=p),this.forward[p]=h,this.backward[h]=p,this.size--,this.deleted[this.deletedSize++]=r,!0},s.prototype.remove=function(e,r=void 0){var p=this.items[e];if(typeof p>"u")return r;var h=this.V[p];if(delete this.items[e],this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,h;var a=this.backward[p],l=this.forward[p];return this.head===p&&(this.head=l),this.tail===p&&(this.tail=a),this.forward[a]=l,this.backward[l]=a,this.size--,this.deleted[this.deletedSize++]=p,h},s.from=function(e,r,p,h){if(arguments.length<2){if(h=E.guessLength(e),typeof h!="number")throw new Error("mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.")}else arguments.length===2&&(h=r,r=null,p=null);var a=new s(r,p,h);return x(e,function(l,n){a.set(n,l)}),a},t.exports=s}),KM=si((g,t)=>{var i=Xx(),x=zn(),T=Is(),E=sa();function s(y,e,r){if(arguments.length<2&&(r=y,y=null,e=null),this.capacity=r,typeof this.capacity!="number"||this.capacity<=0)throw new Error("mnemonist/lru-map: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-map: capacity should be a finite positive integer.");var p=T.getPointerArray(r);this.forward=new p(r),this.backward=new p(r),this.K=typeof y=="function"?new y(r):new Array(r),this.V=typeof e=="function"?new e(r):new Array(r),this.size=0,this.head=0,this.tail=0,this.items=new Map}s.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items.clear()},s.prototype.set=function(y,e){var r=this.items.get(y);if(typeof r<"u"){this.splayOnTop(r),this.V[r]=e;return}this.size{var i=KM(),x=zn(),T=Is(),E=sa();function s(e,r,p){arguments.length<2?i.call(this,e):i.call(this,e,r,p);var h=T.getPointerArray(this.capacity);this.deleted=new h(this.capacity),this.deletedSize=0}for(y in i.prototype)s.prototype[y]=i.prototype[y];var y;typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=i.prototype[Symbol.iterator]),s.prototype.clear=function(){i.prototype.clear.call(this),this.deletedSize=0},s.prototype.set=function(e,r){var p=this.items.get(e);if(typeof p<"u"){this.splayOnTop(p),this.V[p]=r;return}this.size0?p=this.deleted[--this.deletedSize]:p=this.size,this.size++):(p=this.tail,this.tail=this.backward[p],this.items.delete(this.K[p])),this.items.set(e,p),this.K[p]=e,this.V[p]=r,this.forward[p]=this.head,this.backward[this.head]=p,this.head=p},s.prototype.setpop=function(e,r){var p=null,h=null,a=this.items.get(e);return typeof a<"u"?(this.splayOnTop(a),p=this.V[a],this.V[a]=r,{evicted:!1,key:e,value:p}):(this.size0?a=this.deleted[--this.deletedSize]:a=this.size,this.size++):(a=this.tail,this.tail=this.backward[a],p=this.V[a],h=this.K[a],this.items.delete(h)),this.items.set(e,a),this.K[a]=e,this.V[a]=r,this.forward[a]=this.head,this.backward[this.head]=a,this.head=a,h?{evicted:!0,key:h,value:p}:null)},s.prototype.delete=function(e){var r=this.items.get(e);if(typeof r>"u")return!1;if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var p=this.backward[r],h=this.forward[r];return this.head===r&&(this.head=h),this.tail===r&&(this.tail=p),this.forward[p]=h,this.backward[h]=p,this.size--,this.deleted[this.deletedSize++]=r,!0},s.prototype.remove=function(e,r=void 0){var p=this.items.get(e);if(typeof p>"u")return r;var h=this.V[p];if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,h;var a=this.backward[p],l=this.forward[p];return this.head===p&&(this.head=l),this.tail===p&&(this.tail=a),this.forward[a]=l,this.backward[l]=a,this.size--,this.deleted[this.deletedSize++]=p,h},s.from=function(e,r,p,h){if(arguments.length<2){if(h=E.guessLength(e),typeof h!="number")throw new Error("mnemonist/lru-map.from: could not guess iterable length. Please provide desired capacity as last argument.")}else arguments.length===2&&(h=r,r=null,p=null);var a=new s(r,p,h);return x(e,function(l,n){a.set(n,l)}),a},t.exports=s}),nO=si((g,t)=>{var i=Vr(),x=zn(),T=Wx(),E=function(y,e){return y[1]>e[1]?-1:y[1]"u"?0:e},s.prototype.get=s.prototype.multiplicity,s.prototype.count=s.prototype.multiplicity,s.prototype.frequency=function(y){if(this.size===0)return 0;var e=this.multiplicity(y);return e/this.size},s.prototype.top=function(y){if(typeof y!="number"||y<=0)throw new Error("mnemonist/multi-set.top: n must be a number > 0.");for(var e=new T(Array,E,y),r=this.items.entries(),p;p=r.next(),!p.done;)e.push(p.value);return e.consume()},s.prototype.forEach=function(y,e){e=arguments.length>1?e:this;var r;this.items.forEach(function(p,h){for(r=0;r1?e:this,this.items.forEach(y,e)},s.prototype.keys=function(){return this.items.keys()},s.prototype.values=function(){var y=this.items.entries(),e=!1,r,p,h,a;return new i(function l(){if(!e){if(r=y.next(),r.done)return{done:!0};e=!0,p=r.value[0],h=r.value[1],a=0}return a>=h?(e=!1,l()):(a++,{done:!1,value:p})})},s.prototype.multiplicities=function(){return this.items.entries()},typeof Symbol<"u"&&(s.prototype[Symbol.iterator]=s.prototype.values),s.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(s.prototype[Symbol.for("nodejs.util.inspect.custom")]=s.prototype.inspect),s.prototype.toJSON=function(){return this.items},s.from=function(y){var e=new s;return x(y,function(r){e.add(r)}),e},s.isSubset=function(y,e){var r=y.multiplicities(),p,h,a;if(y===e)return!0;if(y.dimension>e.dimension)return!1;for(;p=r.next(),!p.done;)if(h=p.value[0],a=p.value[1],e.multiplicity(h){var i=Vr(),x=zn();function T(l,n,u){return((Math.pow(l,2)-Math.pow(Math.abs(n-u),2))/2|0)+l+1}function E(l,n){for(var u=0,f=0,o=n+1;fn.length?-1:l.lengthn?1:0}function y(l,n){var u=l+1,f=n/u|0,o=f+1,c,d,v=n-f*u,m=u-v,S=new Array(l+1);for(c=0;c 0");this.levenshtein=l,this.k=n,this.clear()}a.prototype.clear=function(){this.size=0,this.strings=[],this.invertedIndices={}},a.prototype.add=function(l){var n=l.length,u=this.size;this.strings.push(l),this.size++;var f=e(this.k,l),o=this.invertedIndices[n];typeof o>"u"&&(o={},this.invertedIndices[n]=o);var c,d,v,m,S;for(m=0,S=f.length;m"u"?(d=[u],o[v]=d):d.push(u);return this},a.prototype.search=function(l){var n=l.length,u=this.k,f=new Set,o,c,d,v,m,S,M,w,C,A,P,b,O,I,D;for(w=Math.max(0,n-u),C=n+u+1;w1?n:this;for(var u=0,f=this.strings.length;u=n)return{done:!0};var f=l[u];return u++,{value:f,done:!1}})},typeof Symbol<"u"&&(a.prototype[Symbol.iterator]=a.prototype.values),a.prototype.inspect=function(){var l=this.strings.slice();return Object.defineProperty(l,"constructor",{value:a,enumerable:!1}),l},typeof Symbol<"u"&&(a.prototype[Symbol.for("nodejs.util.inspect.custom")]=a.prototype.inspect),a.from=function(l,n,u){var f=new a(n,u);return x(l,function(o){f.add(o)}),f},a.countKeys=E,a.comparator=s,a.partition=y,a.segments=e,a.segmentPos=r,a.multiMatchAwareInterval=p,a.multiMatchAwareSubstrings=h,t.exports=a}),sO=si((g,t)=>{var i=Vr(),x=zn();function T(){this.clear()}T.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},T.prototype.enqueue=function(E){return this.items.push(E),++this.size},T.prototype.dequeue=function(){if(this.size){var E=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,E}},T.prototype.peek=function(){if(this.size)return this.items[this.offset]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=this.offset,e=0,r=this.items.length;y=E.length)return{done:!0};var y=E[s];return s++,{value:y,done:!1}})},T.prototype.entries=function(){var E=this.items,s=this.offset,y=0;return new i(function(){if(s>=E.length)return{done:!0};var e=E[s];return s++,{value:[y++,e],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.toString=function(){return this.toArray().join(",")},T.prototype.toJSON=function(){return this.toArray()},T.prototype.inspect=function(){var E=this.toArray();return Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E){var s=new T;return x(E,function(y){s.enqueue(y)}),s},T.of=function(){return T.from(arguments)},t.exports=T}),aO=si((g,t)=>{var i=Vr(),x=zn();function T(){this.clear()}T.prototype.clear=function(){this.items=[],this.size=0},T.prototype.push=function(E){return this.items.push(E),++this.size},T.prototype.pop=function(){if(this.size!==0)return this.size--,this.items.pop()},T.prototype.peek=function(){return this.items[this.size-1]},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=0,e=this.items.length;y=s)return{done:!0};var e=E[s-y-1];return y++,{value:e,done:!1}})},T.prototype.entries=function(){var E=this.items,s=E.length,y=0;return new i(function(){if(y>=s)return{done:!0};var e=E[s-y-1];return{value:[y++,e],done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.toString=function(){return this.toArray().join(",")},T.prototype.toJSON=function(){return this.toArray()},T.prototype.inspect=function(){var E=this.toArray();return Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),T.from=function(E){var s=new T;return x(E,function(y){s.push(y)}),s},T.of=function(){return T.from(arguments)},t.exports=T}),oO=si(g=>{g.intersection=function(){if(arguments.length<2)throw new Error("mnemonist/Set.intersection: needs at least two arguments.");var t=new Set,i=1/0,x=null,T,E,s=arguments.length;for(E=0;Ei.size)return!1;for(;T=x.next(),!T.done;)if(!i.has(T.value))return!1;return!0},g.isSuperset=function(t,i){return g.isSubset(i,t)},g.add=function(t,i){for(var x=i.values(),T;T=x.next(),!T.done;)t.add(T.value)},g.subtract=function(t,i){for(var x=i.values(),T;T=x.next(),!T.done;)t.delete(T.value)},g.intersect=function(t,i){for(var x=t.values(),T;T=x.next(),!T.done;)i.has(T.value)||t.delete(T.value)},g.disjunct=function(t,i){for(var x=t.values(),T,E=[];T=x.next(),!T.done;)i.has(T.value)&&E.push(T.value);for(x=i.values();T=x.next(),!T.done;)t.has(T.value)||t.add(T.value);for(var s=0,y=E.length;si.size&&(x=t,t=i,i=x),t.size===0)return 0;if(t===i)return t.size;for(var T=t.values(),E,s=0;E=T.next(),!E.done;)i.has(E.value)&&s++;return s},g.unionSize=function(t,i){var x=g.intersectionSize(t,i);return t.size+i.size-x},g.jaccard=function(t,i){var x=g.intersectionSize(t,i);if(x===0)return 0;var T=t.size+i.size-x;return x/T},g.overlap=function(t,i){var x=g.intersectionSize(t,i);return x===0?0:x/Math.min(t.size,i.size)}}),lO=si((g,t)=>{var i=Vr(),x=Is().getPointerArray;function T(E){var s=x(E);this.start=0,this.size=0,this.capacity=E,this.dense=new s(E),this.sparse=new s(E)}T.prototype.clear=function(){this.start=0,this.size=0},T.prototype.has=function(E){if(this.size===0)return!1;var s=this.sparse[E],y=s=this.start&&s=this.start&&s1?s:this;for(var y=this.capacity,e=this.size,r=this.start,p=0;p=y)return{done:!0};var p=E[e];return e++,r++,e===s&&(e=0),{value:p,done:!1}})},typeof Symbol<"u"&&(T.prototype[Symbol.iterator]=T.prototype.values),T.prototype.inspect=function(){var E=[];return this.forEach(function(s){E.push(s)}),Object.defineProperty(E,"constructor",{value:T,enumerable:!1}),E.capacity=this.capacity,E},typeof Symbol<"u"&&(T.prototype[Symbol.for("nodejs.util.inspect.custom")]=T.prototype.inspect),t.exports=T}),hO=si((g,t)=>{var i=Vr(),x=Is().getPointerArray;function T(E,s){arguments.length<2&&(s=E,E=Array);var y=x(s);this.size=0,this.length=s,this.dense=new y(s),this.sparse=new y(s),this.vals=new E(s)}T.prototype.clear=function(){this.size=0},T.prototype.has=function(E){var s=this.sparse[E];return s=this.size||this.dense[s]!==E?!1:(s=this.dense[this.size-1],this.dense[this.sparse[E]]=s,this.sparse[s]=this.sparse[E],this.size--,!0)},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y=0;y{var i=Vr(),x=Is().getPointerArray;function T(E){var s=x(E);this.size=0,this.length=E,this.dense=new s(E),this.sparse=new s(E)}T.prototype.clear=function(){this.size=0},T.prototype.has=function(E){var s=this.sparse[E];return s=this.size||this.dense[s]!==E?!1:(s=this.dense[this.size-1],this.dense[this.sparse[E]]=s,this.sparse[s]=this.sparse[E],this.size--,!0)},T.prototype.forEach=function(E,s){s=arguments.length>1?s:this;for(var y,e=0;e{var i=zn(),x=2,T=2,E=new Set([0,1,2]),s={0:"Returns only the top suggestion",1:"Returns suggestions with the smallest edit distance",2:"Returns every suggestion (no early termination)"};function y(n){var u=new Set;return typeof n=="number"&&u.add(n),{suggestions:u,count:0}}function e(n,u,f){return{term:n||"",distance:u||0,count:f||0}}function r(n,u,f,o){o=o||new Set,u++;var c,d=n.length,v;if(d>1)for(v=0;v0&&n[v].length-d.length>o.length-d.length&&(f.suggestions=new Set,f.count=0),(u===2||!f.suggestions.size||n[v].length-d.length>=o.length-d.length)&&f.suggestions.add(c)}function h(n,u){var f=n.length,o=u.length,c=[[]],d=f+o,v=new Map,m,S,M;for(c[0][0]=d,m=0;m<=f;m++)c[m+1]||(c[m+1]=[]),c[m+1][1]=m,c[m+1][0]=d;for(M=0;M<=o;M++)c[1][M+1]=M,c[0][M+1]=d;var w=n+u,C;for(m=0,S=w.length;mc)return[];for(var m=[d],S=new Set,M=new Set,w=[],C,A;m.length>0&&(C=m.shift(),!(f<2&&w.length>0&&v-C.length>w[0].distance));){if(A=n[C],A!==void 0){if(typeof A=="number"&&(A=y(A)),A.count>0&&!M.has(C)){M.add(C);var P=e(C,v-C.length,A.count);if(w.push(P),f<2&&v-C.length===0)break}A.suggestions.forEach(D=>{var B=u[D];if(!M.has(B)){M.add(B);var G=0;if(d!==B)if(B.length===C.length)G=v-C.length;else if(v===C.length)G=B.length-C.length;else{for(var z=0,X=0,K=B.length;z0||X>0?G=h(B.substr(z,K-z-X),d.substr(z,v-z-X)):G=h(B,d)}if(f<2&&w.length>0&&w[0].distance>G&&(w=[]),!(f<2&&w.length>0&&G>w[0].distance)&&G<=o){var Q=n[B];Q!==void 0&&w.push(e(B,G,Q.count))}}})}if(v-C.length0&&v-C.length>=w[0].distance)continue;for(var b=0,O=C.length;bthis.maxLength&&(this.maxLength=n.length)),u.count===1){var f=this.words.length;this.words.push(n);var o=r(n,0,this.maxDistance);o.forEach(c=>{var d=this.dictionary[c];d!==void 0?(typeof d=="number"&&(d=y(d),this.dictionary[c]=d),d.suggestions.has(f)||p(this.words,this.verbosity,d,n,f,c)):this.dictionary[c]=f})}return this.size++,this},l.prototype.search=function(n){return a(this.dictionary,this.words,this.verbosity,this.maxDistance,this.maxLength,n)},l.prototype.inspect=function(){var n=[];n.size=this.size,n.maxDistance=this.maxDistance,n.verbosity=this.verbosity,n.behavior=s[this.verbosity];for(var u in this.dictionary)typeof this.dictionary[u]=="object"&&this.dictionary[u].count&&n.push([u,this.dictionary[u].count]);return Object.defineProperty(n,"constructor",{value:l,enumerable:!1}),n},typeof Symbol<"u"&&(l.prototype[Symbol.for("nodejs.util.inspect.custom")]=l.prototype.inspect),l.from=function(n,u){var f=new l(u);return i(n,function(o){f.add(o)}),f},t.exports=l}),jM=si((g,t)=>{var i=zn(),x=Vr(),T="\0";function E(s){this.mode=s===Array?"array":"string",this.clear()}E.prototype.clear=function(){this.root={},this.size=0},E.prototype.set=function(s,y){for(var e=this.root,r,p=0,h=s.length;p"u")return;if(T in y)return y[T]},E.prototype.delete=function(s){var y=this.root,e=null,r=null,p,h,a,l;for(a=0,l=s.length;a"u")return!1;e!==null?Object.keys(y).length>1&&(e=null,r=null):Object.keys(y).length<2&&(e=p,r=h)}return T in y?(this.size--,e?delete e[r]:delete y[T],!0):!1},E.prototype.has=function(s){for(var y=this.root,e,r=0,p=s.length;r"u")return!1;return T in y},E.prototype.find=function(s){var y=typeof s=="string",e=this.root,r=[],p,h,a;for(h=0,a=s.length;h"u")return r;for(var l=[e],n=[s],u;l.length;){s=n.pop(),e=l.pop();for(u in e){if(u===T){r.push([s,e[T]]);continue}l.push(e[u]),n.push(y?s+u:s.concat(u))}}return r},E.prototype.values=function(s){var y=this.root,e=[],r,p,h;if(s){for(p=0,h=s.length;p"u")return x.empty()}return e.push(y),new x(function(){for(var a,l=!1,n;e.length;){a=e.pop();for(n in a){if(n===T){l=!0;continue}e.push(a[n])}if(l)return{done:!1,value:a[T]}}return{done:!0}})},E.prototype.prefixes=function(s){var y=this.root,e=[],r=[],p,h,a,l=this.mode==="string";if(s){for(h=0,a=s.length;h"u")return x.empty()}else s=l?"":[];return e.push(y),r.push(s),new x(function(){for(var n,u,f=!1,o;e.length;){n=e.pop(),u=r.pop();for(o in n){if(o===T){f=!0;continue}e.push(n[o]),r.push(l?u+o:u.concat(o))}if(f)return{done:!1,value:u}}return{done:!0}})},E.prototype.keys=E.prototype.prefixes,E.prototype.entries=function(s){var y=this.root,e=[],r=[],p,h,a,l=this.mode==="string";if(s){for(h=0,a=s.length;h"u")return x.empty()}else s=l?"":[];return e.push(y),r.push(s),new x(function(){for(var n,u,f=!1,o;e.length;){n=e.pop(),u=r.pop();for(o in n){if(o===T){f=!0;continue}e.push(n[o]),r.push(l?u+o:u.concat(o))}if(f)return{done:!1,value:[u,n[T]]}}return{done:!0}})},typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=E.prototype.entries),E.prototype.inspect=function(){for(var s=new Array(this.size),y=this.entries(),e,r=0;e=y.next(),!e.done;)s[r++]=e.value;return Object.defineProperty(s,"constructor",{value:E,enumerable:!1}),s},typeof Symbol<"u"&&(E.prototype[Symbol.for("nodejs.util.inspect.custom")]=E.prototype.inspect),E.prototype.toJSON=function(){return this.root},E.from=function(s){var y=new E;return i(s,function(e,r){y.set(r,e)}),y},E.SENTINEL=T,t.exports=E}),cO=si((g,t)=>{var i=zn(),x=jM(),T="\0";function E(y){this.mode=y===Array?"array":"string",this.clear()}for(s in x.prototype)E.prototype[s]=x.prototype[s];var s;delete E.prototype.set,delete E.prototype.get,delete E.prototype.values,delete E.prototype.entries,E.prototype.add=function(y){for(var e=this.root,r,p=0,h=y.length;p"u")return p;for(var n=[r],u=[y],f;n.length;){y=u.pop(),r=n.pop();for(f in r){if(f===T){p.push(y);continue}n.push(r[f]),u.push(e?y+f:y.concat(f))}}return p},typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=E.prototype.keys),E.prototype.inspect=function(){for(var y=new Set,e=this.keys(),r;r=e.next(),!r.done;)y.add(r.value);return Object.defineProperty(y,"constructor",{value:E,enumerable:!1}),y},typeof Symbol<"u"&&(E.prototype[Symbol.for("nodejs.util.inspect.custom")]=E.prototype.inspect),E.prototype.toJSON=function(){return this.root},E.from=function(y){var e=new E;return i(y,function(r){e.add(r)}),e},E.SENTINEL=T,t.exports=E}),dO=si((g,t)=>{var i=Vr(),x=zn(),T=sa(),E=Is(),s=function(p){return Math.max(1,Math.ceil(p*1.5))},y=function(p){var h=E.getPointerArray(p);return new h(p)};function e(p,h){if(arguments.length<1)throw new Error("mnemonist/vector: expecting at least a byte array constructor.");var a=h||0,l=s,n=0,u=!1;typeof h=="object"&&(a=h.initialCapacity||0,n=h.initialLength||0,l=h.policy||l,u=h.factory===!0),this.factory=u?p:null,this.ArrayClass=p,this.length=n,this.capacity=Math.max(n,a),this.policy=l,this.array=new p(this.capacity)}e.prototype.set=function(p,h){if(this.lengththis.capacity)if(this.factory===null?this.array=new this.ArrayClass(p):this.array=this.factory(p),E.isTypedArray(this.array))this.array.set(h,0);else for(var a=0,l=this.length;a=p)return this;for(h=this.capacity;h=h)return{done:!0};var l=p[a];return a++,{value:l,done:!1}})},e.prototype.entries=function(){var p=this.array,h=this.length,a=0;return new i(function(){if(a>=h)return{done:!0};var l=p[a];return{value:[a++,l],done:!1}})},typeof Symbol<"u"&&(e.prototype[Symbol.iterator]=e.prototype.values),e.prototype.inspect=function(){var p=this.array.slice(0,this.length);return p.type=this.array.constructor.name,p.items=this.length,p.capacity=this.capacity,Object.defineProperty(p,"constructor",{value:e,enumerable:!1}),p},typeof Symbol<"u"&&(e.prototype[Symbol.for("nodejs.util.inspect.custom")]=e.prototype.inspect),e.from=function(p,h,a){if(arguments.length<3&&(a=T.guessLength(p),typeof a!="number"))throw new Error("mnemonist/vector.from: could not guess iterable length. Please provide desired capacity as last argument.");var l=new e(h,a);return x(p,function(n){l.push(n)}),l};function r(p){var h=function(l){e.call(this,p,l)};for(var a in e.prototype)e.prototype.hasOwnProperty(a)&&(h.prototype[a]=e.prototype[a]);return h.from=function(l,n){return e.from(l,p,n)},typeof Symbol<"u"&&(h.prototype[Symbol.iterator]=h.prototype.values),h}e.Int8Vector=r(Int8Array),e.Uint8Vector=r(Uint8Array),e.Uint8ClampedVector=r(Uint8ClampedArray),e.Int16Vector=r(Int16Array),e.Uint16Vector=r(Uint16Array),e.Int32Vector=r(Int32Array),e.Uint32Vector=r(Uint32Array),e.Float32Vector=r(Float32Array),e.Float64Vector=r(Float64Array),e.PointerVector=r(y),t.exports=e}),pO=si((g,t)=>{var i=sa(),x=Is(),T=kM().inplaceQuickSortIndices,E=YM().lowerBoundIndices,s=Hx(),y=x.getPointerArray;function e(h,a){return h.distancea.distance?-1:0}function r(h,a,l){for(var n=l.length,u=y(n),f=0,o=new u(n),c=new u(n),d=new u(n),v=new Float64Array(n),m=[0,0,n],S=new Float64Array(n),M,w,C,A,P,b,O,I,D;m.length;)if(P=m.pop(),A=m.pop(),M=m.pop(),w=l[P-1],P--,D=P-A,o[M]=w,D!==0){if(D===1){O=h(a[w],a[l[A]]),v[M]=O,f++,d[M]=f,o[f]=l[A];continue}for(I=A;I0&&(f++,d[M]=f,m.push(f,b,P)),b-A>0&&(f++,c[M]=f,m.push(f,A,b))}return{nodes:o,lefts:c,rights:d,mus:v}}function p(h,a){if(typeof h!="function")throw new Error("mnemonist/VPTree.constructor: given `distance` must be a function.");if(!a)throw new Error("mnemonist/VPTree.constructor: you must provide items to the tree. A VPTree cannot be updated after its creation.");this.distance=h,this.heap=new s(e),this.D=0;var l=i.toArrayWithIndices(a);this.items=l[0];var n=l[1];this.size=n.length;var u=r(h,this.items,n);this.nodes=u.nodes,this.lefts=u.lefts,this.rights=u.rights,this.mus=u.mus}p.prototype.nearestNeighbors=function(h,a){var l=this.heap,n=[0],u=1/0,f,o,c,d,v,m,S;for(this.D=0;n.length;)f=n.pop(),o=this.nodes[f],c=this.items[o],S=this.distance(c,a),this.D++,Sh&&l.pop(),l.size>=h&&(u=l.peek().distance)),d=this.lefts[f],v=this.rights[f],!(!d&&!v)&&(m=this.mus[f],S=m-u&&n.push(v)):(v&&S>=m-u&&n.push(v),d&&S=0;w--)M[w]=l.pop();return M},p.prototype.neighbors=function(h,a){var l=[],n=[0],u,f,o,c,d,v,m;for(this.D=0;n.length;)u=n.pop(),f=this.nodes[u],o=this.items[f],m=this.distance(o,a),this.D++,m<=h&&l.push({distance:m,item:o}),c=this.lefts[u],d=this.rights[u],!(!c&&!d)&&(v=this.mus[u],m=v-h&&n.push(d)):(d&&m>=v-h&&n.push(d),c&&m{var i=Hx(),x=Vx(),T=BF();t.exports={BiMap:UF(),BitSet:zF(),BitVector:GF(),BloomFilter:HF(),BKTree:WF(),CircularBuffer:XF(),DefaultMap:YF(),DefaultWeakMap:kF(),FixedDeque:HM(),StaticDisjointSet:KF(),FibonacciHeap:x,MinFibonacciHeap:x.MinFibonacciHeap,MaxFibonacciHeap:x.MaxFibonacciHeap,FixedReverseHeap:Wx(),FuzzyMap:jF(),FuzzyMultiMap:ZF(),HashedArrayTree:JF(),Heap:i,MinHeap:i.MinHeap,MaxHeap:i.MaxHeap,StaticIntervalTree:$F(),InvertedIndex:_F(),KDTree:qF(),LinkedList:tO(),LRUCache:Xx(),LRUCacheWithDelete:eO(),LRUMap:KM(),LRUMapWithDelete:iO(),MultiMap:WM(),MultiSet:nO(),PassjoinIndex:rO(),Queue:sO(),FixedStack:XM(),Stack:aO(),SuffixArray:T,GeneralizedSuffixArray:T.GeneralizedSuffixArray,Set:oO(),SparseQueueSet:lO(),SparseMap:hO(),SparseSet:uO(),SymSpell:fO(),Trie:cO(),TrieMap:jM(),Vector:dO(),VPTree:pO()}}),Qt=class fr{static get ZERO(){return new fr(0,0)}static get ONE(){return new fr(1,1)}static get UP(){return new fr(0,-1)}static get DOWN(){return new fr(0,1)}static get LEFT(){return new fr(-1,0)}static get RIGHT(){return new fr(1,0)}static get UP_LEFT(){return new fr(-1,-1)}static get UP_RIGHT(){return new fr(1,-1)}static get DOWN_RIGHT(){return new fr(1,1)}static get DOWN_LEFT(){return new fr(-1,1)}constructor(t,i){typeof t=="number"?(this.x=t,this.y=i||0):(this.x=t.x,this.y=t.y)}clone(){return new fr(this.x,this.y)}add(t){return new fr(this.x+t.x,this.y+t.y)}multiply(t){return new fr(this.x*t.x,this.y*t.y)}divide(t){return new fr(this.x/t.x,this.y/t.y)}subtract(t){return new fr(this.x-t.x,this.y-t.y)}equals(t){return this.x===t.x&&this.y===t.y}abs(){return new fr(Math.abs(this.x),Math.abs(this.y))}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}modulo(t){return new fr(this.x%t.x,this.y%t.y)}scalarModulo(t){return new fr(this.x%t,this.y%t)}scalarMult(t){return new fr(this.x*t,this.y*t)}toPosition(){return{x:this.x,y:this.y}}toString(){return`${this.x}#${this.y}`}},Ai=class{static equal(g,t){return g.position.x===t.position.x&&g.position.y===t.position.y&&g.layer===t.layer}static copyOver(g,t){t.position.x=g.position.x,t.position.y=g.position.y,t.layer=g.layer}static clone(g){return{position:g.position.clone(),layer:g.layer}}static toString(g){return`${g.position.toString()}#${g.layer}`}static toInternal(g){return{position:new Qt(g.position.x,g.position.y),layer:g.charLayer}}static fromInternal(g){return{position:g.position.toPosition(),charLayer:g.layer}}},mO=(g=>(g.NONE="none",g.LEFT="left",g.UP_LEFT="up-left",g.UP="up",g.UP_RIGHT="up-right",g.RIGHT="right",g.DOWN_RIGHT="down-right",g.DOWN="down",g.DOWN_LEFT="down-left",g))(mO||{}),gO={up:"down",down:"up",left:"right",right:"left",none:"none","up-left":"down-right","up-right":"down-left","down-right":"up-left","down-left":"up-right"},yO={up:Qt.UP,down:Qt.DOWN,left:Qt.LEFT,right:Qt.RIGHT,none:Qt.ZERO,"up-left":Qt.UP_LEFT,"up-right":Qt.UP_RIGHT,"down-right":Qt.DOWN_RIGHT,"down-left":Qt.DOWN_LEFT},pm={up:0,"up-right":1,right:2,"down-right":3,down:4,"down-left":5,left:6,"up-left":7,none:NaN},ZM=["up","up-right","right","down-right","down","down-left","left","up-left"],xO=["down-left","down-right","up-right","up-left"];function Yx(){return["up","down","left","right","none","up-left","up-right","down-right","down-left"]}function ad(g){return xO.includes(g)}function SO(g,t=1){return g==="none"?"none":ZM[(pm[g]+8-Math.abs(t)%8)%8]}function JM(g,t=1){return g==="none"?"none":ZM[(pm[g]+t)%8]}function Cu(g){return yO[g]}function TO(g){return gO[g]}function Ma(g,t){if(g.x===t.x){if(g.y>t.y)return"up";if(g.yt.x)return"left";if(g.xt.x){if(g.yt.y)return"up-left"}else if(g.xt.y)return"up-right"}return"none"}var EO=(g=>(g[g.FOUR=4]="FOUR",g[g.EIGHT=8]="EIGHT",g))(EO||{});function If(g){return typeof g=="string"&&Yx().includes(g)}var Sy=function(g,t){return Sy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,x){i.__proto__=x}||function(i,x){for(var T in x)Object.prototype.hasOwnProperty.call(x,T)&&(i[T]=x[T])},Sy(g,t)};function Yd(g,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Sy(g,t);function i(){this.constructor=g}g.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}function MO(g,t,i,x){function T(E){return E instanceof i?E:new i(function(s){s(E)})}return new(i||(i=Promise))(function(E,s){function y(p){try{r(x.next(p))}catch(h){s(h)}}function e(p){try{r(x.throw(p))}catch(h){s(h)}}function r(p){p.done?E(p.value):T(p.value).then(y,e)}r((x=x.apply(g,t||[])).next())})}function $M(g,t){var i={label:0,sent:function(){if(E[0]&1)throw E[1];return E[1]},trys:[],ops:[]},x,T,E,s;return s={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function y(r){return function(p){return e([r,p])}}function e(r){if(x)throw new TypeError("Generator is already executing.");for(;s&&(s=0,r[0]&&(i=0)),i;)try{if(x=1,T&&(E=r[0]&2?T.return:r[0]?T.throw||((E=T.return)&&E.call(T),0):T.next)&&!(E=E.call(T,r[1])).done)return E;switch(T=0,E&&(r=[r[0]&2,E.value]),r[0]){case 0:case 1:E=r;break;case 4:return i.label++,{value:r[1],done:!1};case 5:i.label++,T=r[1],r=[0];continue;case 7:r=i.ops.pop(),i.trys.pop();continue;default:if(E=i.trys,!(E=E.length>0&&E[E.length-1])&&(r[0]===6||r[0]===2)){i=0;continue}if(r[0]===3&&(!E||r[1]>E[0]&&r[1]=g.length&&(g=void 0),{value:g&&g[x++],done:!g}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function vd(g,t){var i=typeof Symbol=="function"&&g[Symbol.iterator];if(!i)return g;var x=i.call(g),T,E=[],s;try{for(;(t===void 0||t-- >0)&&!(T=x.next()).done;)E.push(T.value)}catch(y){s={error:y}}finally{try{T&&!T.done&&(i=x.return)&&i.call(x)}finally{if(s)throw s.error}}return E}function md(g,t,i){if(i||arguments.length===2)for(var x=0,T=t.length,E;x1||y(a,l)})})}function y(a,l){try{e(x[a](l))}catch(n){h(E[0][3],n)}}function e(a){a.value instanceof Wf?Promise.resolve(a.value.v).then(r,p):h(E[0][2],a)}function r(a){y("next",a)}function p(a){y("throw",a)}function h(a,l){a(l),E.shift(),E.length&&y(E[0][0],E[0][1])}}function wO(g){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=g[Symbol.asyncIterator],i;return t?t.call(g):(g=typeof Kf=="function"?Kf(g):g[Symbol.iterator](),i={},x("next"),x("throw"),x("return"),i[Symbol.asyncIterator]=function(){return this},i);function x(E){i[E]=g[E]&&function(s){return new Promise(function(y,e){s=g[E](s),T(y,e,s.done,s.value)})}}function T(E,s,y,e){Promise.resolve(e).then(function(r){E({value:r,done:y})},s)}}function mr(g){return typeof g=="function"}function QM(g){var t=function(x){Error.call(x),x.stack=new Error().stack},i=g(t);return i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,i}var f0=QM(function(g){return function(t){g(this),this.message=t?t.length+` errors occurred during unsubscription: `+t.map(function(i,x){return x+1+") "+i.toString()}).join(` - `):"",this.name="UnsubscriptionError",this.errors=t}});function Sy(g,t){if(g){var i=g.indexOf(t);0<=i&&g.splice(i,1)}}var Jm=function(){function g(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return g.prototype.unsubscribe=function(){var t,i,x,T,E;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var y=Kf(s),e=y.next();!e.done;e=y.next()){var r=e.value;r.remove(this)}}catch(u){t={error:u}}finally{try{e&&!e.done&&(i=y.return)&&i.call(y)}finally{if(t)throw t.error}}else s.remove(this);var p=this.initialTeardown;if(mr(p))try{p()}catch(u){E=u instanceof u0?u.errors:[u]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var a=Kf(h),l=a.next();!l.done;l=a.next()){var n=l.value;try{QS(n)}catch(u){E=E??[],u instanceof u0?E=md(md([],vd(E)),vd(u.errors)):E.push(u)}}}catch(u){x={error:u}}finally{try{l&&!l.done&&(T=a.return)&&T.call(a)}finally{if(x)throw x.error}}}if(E)throw new u0(E)}},g.prototype.add=function(t){var i;if(t&&t!==this)if(this.closed)QS(t);else{if(t instanceof g){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(i=this._finalizers)!==null&&i!==void 0?i:[]).push(t)}},g.prototype._hasParent=function(t){var i=this._parentage;return i===t||Array.isArray(i)&&i.includes(t)},g.prototype._addParent=function(t){var i=this._parentage;this._parentage=Array.isArray(i)?(i.push(t),i):i?[i,t]:t},g.prototype._removeParent=function(t){var i=this._parentage;i===t?this._parentage=null:Array.isArray(i)&&Sy(i,t)},g.prototype.remove=function(t){var i=this._finalizers;i&&Sy(i,t),t instanceof g&&t._removeParent(this)},g.EMPTY=function(){var t=new g;return t.closed=!0,t}(),g}(),_M=Jm.EMPTY;function qM(g){return g instanceof Jm||g&&"closed"in g&&mr(g.remove)&&mr(g.add)&&mr(g.unsubscribe)}function QS(g){mr(g)?g():g.unsubscribe()}var tC={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},AO={setTimeout:function(g,t){for(var i=[],x=2;x0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(i){return this._throwIfClosed(),g.prototype._trySubscribe.call(this,i)},t.prototype._subscribe=function(i){return this._throwIfClosed(),this._checkFinalizedStatuses(i),this._innerSubscribe(i)},t.prototype._innerSubscribe=function(i){var x=this,T=this,E=T.hasError,s=T.isStopped,y=T.observers;return E||s?_M:(this.currentObservers=null,y.push(i),new Jm(function(){x.currentObservers=null,Sy(y,i)}))},t.prototype._checkFinalizedStatuses=function(i){var x=this,T=x.hasError,E=x.thrownError,s=x.isStopped;T?i.error(E):s&&i.complete()},t.prototype.asObservable=function(){var i=new wa;return i.source=this,i},t.create=function(i,x){return new qS(i,x)},t}(wa),qS=function(g){Yd(t,g);function t(i,x){var T=g.call(this)||this;return T.destination=i,T.source=x,T}return t.prototype.next=function(i){var x,T;(T=(x=this.destination)===null||x===void 0?void 0:x.next)===null||T===void 0||T.call(x,i)},t.prototype.error=function(i){var x,T;(T=(x=this.destination)===null||x===void 0?void 0:x.error)===null||T===void 0||T.call(x,i)},t.prototype.complete=function(){var i,x;(x=(i=this.destination)===null||i===void 0?void 0:i.complete)===null||x===void 0||x.call(i)},t.prototype._subscribe=function(i){var x,T;return(T=(x=this.source)===null||x===void 0?void 0:x.subscribe(i))!==null&&T!==void 0?T:_M},t}(In),rC=new wa(function(g){return g.complete()});function UO(g){return g&&mr(g.schedule)}function sC(g){return g[g.length-1]}function aC(g){return UO(sC(g))?g.pop():void 0}function oC(g,t){return typeof sC(g)=="number"?g.pop():t}var lC=function(g){return g&&typeof g.length=="number"&&typeof g!="function"};function hC(g){return mr(g?.then)}function uC(g){return mr(g[Kx])}function fC(g){return Symbol.asyncIterator&&mr(g?.[Symbol.asyncIterator])}function cC(g){return new TypeError("You provided "+(g!==null&&typeof g=="object"?"an invalid object":"'"+g+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function zO(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var dC=zO();function pC(g){return mr(g?.[dC])}function vC(g){return CO(this,arguments,function(){var t,i,x,T;return $M(this,function(E){switch(E.label){case 0:t=g.getReader(),E.label=1;case 1:E.trys.push([1,,9,10]),E.label=2;case 2:return[4,Wf(t.read())];case 3:return i=E.sent(),x=i.value,T=i.done,T?[4,Wf(void 0)]:[3,5];case 4:return[2,E.sent()];case 5:return[4,Wf(x)];case 6:return[4,E.sent()];case 7:return E.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function mC(g){return mr(g?.getReader)}function Lu(g){if(g instanceof wa)return g;if(g!=null){if(uC(g))return GO(g);if(lC(g))return VO(g);if(hC(g))return HO(g);if(fC(g))return gC(g);if(pC(g))return WO(g);if(mC(g))return XO(g)}throw cC(g)}function GO(g){return new wa(function(t){var i=g[Kx]();if(mr(i.subscribe))return i.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function VO(g){return new wa(function(t){for(var i=0;i{let T=this.tilePosInDirection(new Qt(i,x),g);return this.tilemap.hasBlockingTile(T,t,TO(g),this.ignoreMissingTiles)})}isCharBlocking(g,t){return this.someCharTile((i,x)=>{let T=this.tilePosInDirection(new Qt(i,x),g);return this.tilemap.hasBlockingChar(T,t,this.getCollisionGroups(),new Set([this.getId()]),this.ignoreCollisionGroups)})}isMoving(){return this.movementDirection!="none"}turnTowards(g){this.isMoving()||g!="none"&&this.changeFacingDirection(g)}changeFacingDirection(g){this.facingDirection!==g&&(this.facingDirection=g,this.directionChanged$.next(g))}getFacingDirection(){return this.facingDirection}getFacingPosition(){return this._tilePos.position.add(Cu(this.facingDirection))}addCollisionGroup(g){this.collisionGroups.add(g)}setCollisionGroups(g){this.collisionGroups=new Set(g)}setIgnoreCollisionGroups(g){this.ignoreCollisionGroups=new Set(g)}getCollisionGroups(){return Array.from(this.collisionGroups)}getIgnoreCollisionGroups(){return Array.from(this.ignoreCollisionGroups)}hasCollisionGroup(g){return this.collisionGroups.has(g)}removeCollisionGroup(g){this.collisionGroups.delete(g)}removeAllCollisionGroups(){this.collisionGroups.clear()}addLabels(g){for(let t of g)this.labels.add(t)}getLabels(){return[...this.labels.values()]}hasLabel(g){return this.labels.has(g)}clearLabels(){this.labels.clear()}removeLabels(g){for(let t of g)this.labels.delete(t)}getNumberOfDirections(){return this.numberOfDirections}movementStarted(){return this.movementStarted$}movementStopped(){return this.movementStopped$}directionChanged(){return this.directionChanged$}tilePositionSet(){return this.tilePositionSet$}positionChangeStarted(){return this.positionChangeStarted$}positionChangeFinished(){return this.positionChangeFinished$}autoMovementSet(){return this.autoMovementSet$}depthChanged(){return this.depthChanged$}getMovementProgress(){return this.movementProgress}setMovementProgress(g){let t=Math.max(0,Math.min(au,g));this.movementProgress=t}hasWalkedHalfATile(){return this.movementProgress>au/2}willCrossTileBorderThisUpdate(g){return this.movementProgress+this.maxProgressForDelta(g)>=au}updateCharacterPosition(g){let t=this.willCrossTileBorderThisUpdate(g),i=1-(t?au-this.movementProgress:this.maxProgressForDelta(g))/this.maxProgressForDelta(g);this.movementProgress=Math.min(this.movementProgress+this.maxProgressForDelta(g),au),t&&(this.movementProgress=0,this.shouldContinueMoving()?(this.fire(this.positionChangeFinished$,this.tilePos,this.getNextTilePos()),this.tilePos=this.getNextTilePos(),this.startMoving(this.lastMovementImpulse),i>0&&this.updateCharacterPosition(g*i)):this.stopMoving())}maxProgressForDelta(g){let t=g/1e3;return Math.floor(t*this.speed*au)}get tilePos(){return Ai.clone(this._tilePos)}set tilePos(g){Ai.copyOver(g,this._tilePos)}startMoving(g){g!=="none"&&(g!=this.movementDirection&&this.movementStarted$.next(g),this.movementDirection=g,this.facingDirection=g,this.fire(this.positionChangeStarted$,this.tilePos,this.getNextTilePos()))}tilePosInDirection(g,t){return g.add(Cu(this.tilemap.toMapDirection(t)))}shouldContinueMoving(){return this.lastMovementImpulse!=="none"&&!this.isBlockingDirection(this.lastMovementImpulse)}stopMoving(){if(this.movementDirection==="none")return;let g=this.tilePos,t=this.getNextTilePos(),i=this.movementDirection;this.tilePos=this.getNextTilePos(),this.movementDirection="none",this.movementStopped$.next(i),this.fire(this.positionChangeFinished$,g,t)}fire(g,{position:t,layer:i},{position:x,layer:T}){g.next({exitTile:t,enterTile:x,exitLayer:i,enterLayer:T})}someCharTile(g){let t=this.getNextTilePos().position;for(let i=t.x;ithis.isLayerAlwaysOnTop(T));this.tilemap.layers.filter(T=>!this.isLayerAlwaysOnTop(T)).forEach(T=>{this.hasLayerProp(T,ou.HEIGHT_SHIFT_PROP_NAME)?(this.createHeightShiftLayers(T,i),t.push(T.tilemapLayer)):this.setDepth(T,++i)}),this.charLayerDepths.set(void 0,i),x.forEach((T,E)=>{T.tilemapLayer.setDepth(E+1+i)}),t.forEach(T=>T.destroy())}setDepth(t,i){t.tilemapLayer.setDepth(i),this.isCharLayer(t)&&this.charLayerDepths.set(this.getLayerProp(t,ou.CHAR_LAYER_PROP_NAME),i)}createHeightShiftLayers(t,i){let x=this.getLayerProp(t,ou.HEIGHT_SHIFT_PROP_NAME);isNaN(x)&&(x=0);let T=1;for(let E=0;ET.name==i);return x?.value}hasLayerProp(t,i){return this.getLayerProp(t,i)!=null}copyLayer(t,i){let x=`${t.name}#${i}`,T=this.tilemap.createBlankLayer(x,t.tilemapLayer.tileset);if(T){if(T.name=x,this.isIsometric())for(let E=i;E>=0;E--){let s=i-E;T.putTileAt(t.data[E][s],s,E)}else for(let E=0;Ey===this.charData.id)).subscribe(({direction:y})=>{var e;(e=this.animation)==null||e.setStandingFrame(y)}),this.sprite&&(this.sprite.setOrigin(0,0),this.resetAnimation(this.sprite),this.updateOverlaySprite(),this.updateGridChar())}destroy(){this.destroy$.next(),this.destroy$.complete(),this.newSpriteSet$.complete()}setSprite(g){g?(this.sprite&&(g.x=this.sprite.x,g.y=this.sprite.y),this.sprite=g,this.newSpriteSet$.next(),this.layerOverlaySprite=this.layerOverlaySprite?this.scene.add.sprite(0,0,this.sprite.texture):void 0,this.updateOverlaySprite(),this.resetAnimation(this.sprite),this.updateDepth()):(this.layerOverlaySprite=void 0,this.sprite=void 0)}getSprite(){return this.sprite}getLayerOverlaySprite(){return this.layerOverlaySprite}setContainer(g){var t;this.container=g,this.cachedContainerHeight=(t=g?.getBounds().height)!=null?t:0}getContainer(){return this.container}getOffsetX(){return this.customOffset.x}setOffsetX(g){this.customOffset.x=g}getOffsetY(){return this.customOffset.y}setOffsetY(g){this.customOffset.y=g}getWalkingAnimationMapping(){return this.walkingAnimationMapping}turnTowards(g){var t;this.geHeadless.isMoving(this.charData.id)||g!="none"&&(this.geHeadless.turnTowards(this.charData.id,g),(t=this.animation)==null||t.setStandingFrame(g))}getAnimation(){return this.animation}setAnimation(g){this.animation=g}update(g){this.updateGridChar()}getEngineOffset(){var g,t,i,x;if(!this.sprite)return Qt.ZERO;let T=this.tilemap.getTileWidth()/2-Math.floor(((t=(g=this.sprite)==null?void 0:g.displayWidth)!=null?t:0)/2),E=-((x=(i=this.sprite)==null?void 0:i.displayHeight)!=null?x:0)+this.tilemap.getTileHeight();return new Qt(T,E)}updatePixelPos(){let g=new Qt(this.geHeadless.getPosition(this.charData.id)),t=this.geHeadless.getMovementProgress(this.charData.id)/1e3,i=this.tilemap.tilePosToPixelPos(g).add(this.getEngineOffset()).add(this.customOffset).add(Cu(this.geHeadless.getFacingDirection(this.charData.id)).multiply(this.tilemap.getTileDistance(this.geHeadless.getFacingDirection(this.charData.id)).scalarMult(t))),x=this.getGameObj();x&&(x.x=Math.floor(i.x),x.y=Math.floor(i.y))}getGameObj(){return this.container||this.sprite}updateGridChar(){var g;if(this.updatePixelPos(),this.sprite&&this.geHeadless.isMoving(this.charData.id)){let t=this.geHeadless.getMovementProgress(this.charData.id)>au/2;(g=this.getAnimation())==null||g.updateCharacterFrame(this.geHeadless.getFacingDirection(this.charData.id),t,Number(this.sprite.frame.name))}this.updateDepth()}resetAnimation(g){let t=new tT(this.walkingAnimationMapping,g.texture.source[0].width/g.width/tT.FRAMES_CHAR_ROW);this.setAnimation(t),t.frameChange().pipe(Ta(this.newSpriteSet$)).subscribe(i=>{g?.setFrame(i)}),t.setIsEnabled(this.walkingAnimationMapping!==void 0),t.setStandingFrame(this.geHeadless.getFacingDirection(this.charData.id))}updateOverlaySprite(){if(!this.layerOverlaySprite||!this.sprite)return;this.layerOverlaySprite.scale=this.sprite.scale;let g=this.tilemap.getTileHeight()/this.layerOverlaySprite.scale;this.layerOverlaySprite.setCrop(0,0,this.layerOverlaySprite.displayWidth,this.sprite.height-g),this.layerOverlaySprite.setOrigin(0,0)}updateDepth(){if(!this.getGameObj())return;let g=new Qt(this.geHeadless.getPosition(this.charData.id)),t=this.geHeadless.getCharLayer(this.charData.id);this.container?this.setContainerDepth(this.container,{position:g,layer:t}):this.sprite&&this.setSpriteDepth(this.sprite,{position:g,layer:t});let i=this.getLayerOverlaySprite();if(i){let x=new Qt(dh(An({},g),{y:g.y-1}));this.setSpriteDepth(i,{position:x,layer:t})}}setSpriteDepth(g,t){g.setDepth(this.tilemap.getDepthOfCharLayer(this.getTransitionLayer(t))+this.getPaddedPixelDepthSprite(g))}setContainerDepth(g,t){g.setDepth(this.tilemap.getDepthOfCharLayer(this.getTransitionLayer(t))+this.getPaddedPixelDepthContainer(g))}getPaddedPixelDepthContainer(g){return Cy.shiftPad(g.y+this.cachedContainerHeight,Ay.Z_INDEX_PADDING)}getPaddedPixelDepthSprite(g){return Cy.shiftPad(g.y+g.displayHeight,Ay.Z_INDEX_PADDING)}getTransitionLayer(g){if(g.layer)return this.geHeadless.getTransition(g.position,g.layer)||g.layer}},s4=(g=>(g.DONT_BLOCK="DONT_BLOCK",g.BLOCK_TWO_TILES="BLOCK_TWO_TILES",g.BLOCK_ONE_TILE_AHEAD="BLOCK_ONE_TILE_AHEAD",g.BLOCK_ONE_TILE_BEHIND="BLOCK_ONE_TILE_BEHIND",g))(s4||{}),CC=(g=>(g.STOP="STOP",g.CLOSEST_REACHABLE="CLOSEST_REACHABLE",g.RETRY="RETRY",g.ALTERNATIVE_TARGETS="ALTERNATIVE_TARGETS",g))(CC||{}),a4=class{distance(g,t){return eo.manhattanDistance(g,t)}direction(g,t){if(eo.equal(g,t))return"none";let i=g.clone().subtract(t);return Math.abs(i.x)>Math.abs(i.y)?i.x>0?"left":"right":i.y>0?"up":"down"}neighbors(g){return[new Qt(g.x,g.y+1),new Qt(g.x+1,g.y),new Qt(g.x-1,g.y),new Qt(g.x,g.y-1)]}getDirections(){return["up","right","down","left"]}},o4=class{distance(g,t){return eo.chebyshevDistance(g,t)}neighbors(g){let t=[new Qt(g.x,g.y+1),new Qt(g.x+1,g.y),new Qt(g.x-1,g.y),new Qt(g.x,g.y-1)],i=[new Qt(g.x+1,g.y+1),new Qt(g.x+1,g.y-1),new Qt(g.x-1,g.y+1),new Qt(g.x-1,g.y-1)];return[...t,...i]}direction(g,t){return t.x>g.x?t.y>g.y?"down-right":t.yg.y?"down-left":t.yg.y?"down":"none"}getDirections(){return["up","right","down","left","down-left","down-right","up-right","up-left"]}},gd=class{static create(g){switch(g){case 4:return new a4;case 8:return new o4}}},eT=class{constructor(g,t,i){this.backoffMs=g,this.maxRetries=t,this.onFinished=i,this.retries=0,this.elapsed=0}retry(g,t){this.shouldRetry()?(this.elapsed+=g,this.elapsed>=this.backoffMs&&(this.elapsed=0,this.retries++,t())):this.onFinished()}reset(){this.retries=0,this.elapsed=0}getMaxRetries(){return this.maxRetries}getBackoffMs(){return this.backoffMs}shouldRetry(){return this.maxRetries===-1||this.retries(g.WAIT="WAIT",g.RETRY="RETRY",g.STOP="STOP",g))(wC||{}),$m=class{constructor(g,{shortestPathAlgorithm:t="BFS",pathWidth:i=1,pathHeight:x=1,numberOfDirections:T=4,isPositionAllowed:E=(u,f)=>!0,collisionGroups:s=[],ignoredChars:y=[],ignoreTiles:e=!1,ignoreMapBounds:r=!1,ignoreBlockedTarget:p=!1,maxPathLength:h=1/0,ignoreLayers:a=!1,considerCosts:l=!1,calculateClosestToTarget:n=!0}={}){this.gridTilemap=g,this.options={shortestPathAlgorithm:t,pathWidth:i,pathHeight:x,numberOfDirections:T,isPositionAllowed:E,collisionGroups:s,ignoredChars:y,ignoreTiles:e,ignoreMapBounds:r,ignoreBlockedTarget:p,maxPathLength:h,ignoreLayers:a,considerCosts:l,calculateClosestToTarget:n},this.ignoredCharsSet=new Set(y)}findShortestPath(g,t){this.options.ignoreLayers&&(this.gridTilemap.fixCacheLayer(g.layer),t.layer=g.layer);let i=this.findShortestPathImpl(g,t);return this.gridTilemap.unfixCacheLayers(),i}getNeighbors(g,t){var i;return gd.create((i=this.options.numberOfDirections)!=null?i:4).neighbors(g.position).map(x=>{let T=g.layer;return this.options.ignoreLayers||(T=this.gridTilemap.getTransition(x,g.layer)),{position:x,layer:T||g.layer}}).filter(x=>!this.isBlocking(g,x)||this.options.ignoreBlockedTarget&&Ai.equal(x,t))}getTransition(g,t){if(!this.options.ignoreLayers)return this.gridTilemap.getTransition(g,t)}getCosts(g,t){if(!this.options.considerCosts)return 1;let i=Ma(t.position,g);return this.gridTilemap.getTileCosts(t,i)}isBlocking(g,t){return!(this.options.ignoreMapBounds||this.gridTilemap.isInRange(t.position))||!this.options.isPositionAllowed(t.position,t.layer)||!this.options.ignoreTiles&&this.hasBlockingTileFrom(g,t,this.options.pathWidth,this.options.pathHeight,this.options.ignoreMapBounds,this.gridTilemap)?!0:this.hasBlockingCharFrom(g,t,this.options.pathWidth,this.options.pathHeight,this.options.collisionGroups,this.ignoredCharsSet,this.gridTilemap)}distance(g,t){return(this.options.numberOfDirections===4?eo.manhattanDistance:eo.chebyshevDistance)(g,t)}getTilePosInDir(g,t){return this.options.ignoreLayers?{position:g.position.add(Cu(this.gridTilemap.toMapDirection(t))),layer:g.layer}:this.gridTilemap.getTilePosInDirection(g,t)}getReverseNeighbors(g,t){var i;let x=gd.create((i=this.options.numberOfDirections)!=null?i:4).neighbors(g.position),T;if(!this.options.ignoreLayers){let E=this.gridTilemap.getReverseTransitions(g.position,g.layer);T=E?[...E]:void 0}return x.map(E=>T?T.map(s=>({position:E,layer:s||g.layer})):[{position:E,layer:g.layer}]).flat().filter(E=>!this.isBlocking(E,g)||this.options.ignoreBlockedTarget&&Ai.equal(g,t))}hasBlockingCharFrom(g,t,i,x,T,E,s){if(i===1&&x===1)return s.hasBlockingChar(t.position,t.layer,T,E);let y=r=>s.hasBlockingChar(r,t.layer,T,E),e=Ma(g.position,t.position);return this.isBlockingMultiTile(g,e,i,x,y)}hasBlockingTileFrom(g,t,i,x,T,E){if(i===1&&x===1)return E.hasBlockingTile(t.position,t.layer,Ma(t.position,g.position),T);let s=Ma(g.position,t.position),y=e=>E.hasBlockingTile(e,t.layer,s,T);return this.isBlockingMultiTile(g,s,i,x,y)}isBlockingMultiTile(g,t,i,x,T){let E={src:new Qt(g.position.x+i,g.position.y),dest:new Qt(g.position.x+i,g.position.y+x-1)},s={src:new Qt(g.position.x-1,g.position.y),dest:new Qt(g.position.x-1,g.position.y+x-1)},y={src:new Qt(g.position.x,g.position.y-1),dest:new Qt(g.position.x+i-1,g.position.y-1)},e={src:new Qt(g.position.x,g.position.y+x),dest:new Qt(g.position.x+i-1,g.position.y+x)};switch(t){case"right":return this.checkLine(E,T);case"left":return this.checkLine(s,T);case"up":return this.checkLine(y,T);case"down":return this.checkLine(e,T);case"up-left":return this.checkLine({src:y.src,dest:new Qt(y.dest.x-1,y.dest.y)},T)||this.checkLine({src:new Qt(s.src.x,s.src.y-1),dest:new Qt(s.dest.x,s.dest.y-1)},T);case"up-right":return this.checkLine({src:new Qt(y.src.x+1,y.src.y),dest:y.dest},T)||this.checkLine({src:new Qt(E.src.x,E.src.y-1),dest:new Qt(E.dest.x,E.dest.y-1)},T);case"down-left":return this.checkLine({src:new Qt(s.src.x,s.src.y+1),dest:new Qt(s.dest.x,s.dest.y+1)},T)||this.checkLine({src:e.src,dest:new Qt(e.dest.x-1,e.dest.y)},T);case"down-right":return this.checkLine({src:new Qt(e.src.x+1,e.src.y),dest:e.dest},T)||this.checkLine({src:new Qt(E.src.x,E.src.y+1),dest:new Qt(E.dest.x,E.dest.y+1)},T)}return!1}checkLine(g,t){for(let i=g.src.x;i<=g.dest.x;i++)for(let x=g.src.y;x<=g.dest.y;x++)if(t(new Qt(i,x)))return!0;return!1}},l4=GM(Vx(),1),h4=class extends $m{findShortestPathImpl(g,t){let i=this.shortestPathBfs(g,t);return{path:this.returnPath(i.previous,g,t),closestToTarget:i.closestToTarget,steps:i.steps,maxPathLengthReached:i.maxPathLengthReached,algorithmUsed:"A_STAR"}}shortestPathBfs(g,t){let i=new Map,x=new Map,T=new Map,E=new l4.MinFibonacciHeap((r,p)=>Gc(T,r)-Gc(T,p)),s=g,y=this.distance(g.position,t.position),e=0;for(E.push(g),x.set(Ai.toString(g),0),T.set(Ai.toString(g),this.distance(g.position,t.position));E.size>0;){let r=E.pop();if(!r)break;e++;let p=this.distance(r.position,t.position);if(pthis.options.maxPathLength)return{previous:new Map,closestToTarget:s,steps:e,maxPathLengthReached:!0};for(let h of this.getNeighbors(r,t)){let a=Gc(x,r)+this.getCosts(r.position,h),l=Ai.toString(h);(!x.has(l)||a0;){let e=T.dequeue();if(y++,!e)break;let{node:r,dist:p}=e;if(p>this.options.maxPathLength)return{previous:new Map,closestToTarget:E,steps:y,maxPathLengthReached:!0};let h=this.distance(r.position,t.position);if(hthis.lastDist)}step(g,t,i){var x;this.lastDist=i;for(let T of g){let E=Ai.toString(T);if(!this.visited.has(E)){this.previous.set(E,t),this.queue.enqueue({node:T,dist:i+1}),this.visited.set(E,i+1);let s=(x=this.otherBfs)==null?void 0:x.visited.get(E);s!==void 0&&s0,T.queue.size()>0);){let e=x.queue.dequeue();if(!e)break;let{node:r,dist:p}=e;if(p+1+(((i=T.queue.peek())==null?void 0:i.dist)||0)>this.options.maxPathLength)return{previous:x.previous,previous2:T.previous,closestToTarget:this.maybeClosestToTarget(s),steps:E,maxPathLengthReached:!0};let h=this.distance(r.position,t.position);if(hVc(this.f,T)-Vc(this.f,E)),this.openSet.push(g);let x=Ai.toString(g);for(this.g.set(x,0),this.f.set(x,this.distance(g.position,t.position)),this.maxFrontierSize=Math.max(this.maxFrontierSize,this.openSet.size);this.openSet.size>0;){let T=this.openSet.pop();if(!T)break;if(this.steps++,Ai.equal(T,t))return{previous:i,closestToTarget:t,steps:this.steps,maxPathLengthReached:!1};if(Vc(this.g,T)+1>this.options.maxPathLength)return{previous:new Map,closestToTarget:this.closestToTarget,steps:this.steps,maxPathLengthReached:!0};this.updateClosestToTarget(T,t);for(let E of this.getNeighborsInternal(T,i.get(Ai.toString(T)),t)){let s=Ai.toString(E.p),y=Vc(this.g,T)+E.dist;(!this.g.has(s)||y({p:E,dist:1}));let x=this.prune(t,g).filter(E=>!this.isBlockingIgnoreTarget(g,E,i)).map(E=>{let s=this.getTransition(E.position,g.layer);return{position:E.position,layer:s||g.layer}}),T=[];for(let E of x)if(this.isHorizontal(g.position,E.position))T.push({p:E,dist:1});else{let s=this.jump(g,E,i,1,Ma(g.position,E.position));s&&T.push(s)}return T}isBlockingIgnoreTarget(g,t,i){return this.isBlocking(g,t)&&!(this.options.ignoreBlockedTarget&&Ai.equal(t,i))}jump(g,t,i,x,T){if(!this.isBlockingIgnoreTarget(g,t,i))return Ai.equal(t,i)?{p:t,dist:x}:x>=this.maxJumpSize?{p:t,dist:x}:this.getTransition(t.position,g.layer)!==void 0?{p:t,dist:x}:this.hasForced(g,t)?{p:t,dist:x}:(this.updateClosestToTarget(t,i),this.jump(t,this.getTilePosInDir(t,T),i,x+1,T))}isHorizontal(g,t){return g.y===t.y}getForced(g,t,i,x,T,E){let s=[],y=g;return(this.blockOrTrans(y,i)||this.blockOrTrans(i,x))&&this.addIfNotBlocked(s,t,x),(this.blockOrTrans(y,T)||this.blockOrTrans(T,E))&&this.addIfNotBlocked(s,t,E),s}hasForced(g,t){let{topLeft:i,downLeft:x,top:T,bottom:E}=this.normalizedPositions(g,t);return!!((this.blockOrTrans(g,x)||this.blockOrTrans(x,E))&&!this.blockOrTrans(t,E)||(this.blockOrTrans(g,i)||this.blockOrTrans(i,T))&&!this.blockOrTrans(t,T))}prune(g,t){let{right:i,top:x,bottom:T,downLeft:E,topLeft:s}=this.normalizedPositions(g,t);return this.isHorizontal(g.position,t.position)?[i,x,T]:[i,...this.getForced(g,t,E,T,s,x)]}normalizedPositions(g,t){return g.position.xt.position.x?{topLeft:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},downLeft:{position:new Qt(t.position.x+1,t.position.y-1),layer:t.layer},top:{position:new Qt(t.position.x,t.position.y+1),layer:t.layer},bottom:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},right:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer}}:g.position.y1?this.fillPath(T,E,x):x.push(E),T=E}return x.reverse()}fillPath(g,t,i){let x=g;do{let T=Ma(x.position,t.position);x=this.getTilePosInDir(x,T),i.push(x)}while(!eo.equal(x.position,t.position))}};function Vc(g,t){var i;return(i=g.get(Ai.toString(t)))!=null?i:Number.MAX_VALUE}var f4=class{constructor(g,t,i,x={}){this.character=g,this.gridTilemap=t,this.charToFollow=i;let T={distance:0,noPathFoundStrategy:"STOP",maxPathLength:1/0,shortestPathAlgorithm:"BIDIRECTIONAL_SEARCH",ignoreLayers:!1,considerCosts:x.considerCosts||!1,facingDirection:"none"};this.options=An(An({},T),x),this.options.considerCosts&&this.options.shortestPathAlgorithm!=="A_STAR"&&console.warn(`GridEngine: Pathfinding option 'considerCosts' cannot be used with algorithm '${this.options.shortestPathAlgorithm}'. It can only be used with A* algorithm.`),this.options.shortestPathAlgorithm==="JPS"&&(this.character.getTileWidth()>1||this.character.getTileHeight()>1)&&console.warn("GridEngine: Pathfinding algorithm 'JPS' can only be used for characters with 'tileWidth' and 'tileHeight' of 1"),this.character=g,this.updateTarget(this.charToFollow.getTilePos().position,this.charToFollow.getTilePos().layer),this.charToFollow.positionChangeStarted().pipe(Ta(this.character.autoMovementSet().pipe(ph(E=>E!==this),qf(1)))).subscribe(({enterTile:E,enterLayer:s})=>{this.updateTarget(E,s)})}update(g){var t;(t=this.targetMovement)==null||t.update(g)}getInfo(){return{type:"Follow",config:{charToFollow:this.charToFollow.getId(),distance:this.options.distance,noPathFoundStrategy:this.options.noPathFoundStrategy,maxPathLength:this.options.maxPathLength,ignoreLayers:this.options.ignoreLayers,facingDirection:this.options.facingDirection,shortestPathAlgorithm:this.options.shortestPathAlgorithm}}}getFacingPos(){let g=dm[this.options.facingDirection]+dm[this.charToFollow.getFacingDirection()],t=JM("up",g),i={x:this.charToFollow.getTilePos().position.x,y:this.charToFollow.getTilePos().position.y};return t==="right"?i.x+=this.charToFollow.getTileWidth()-1:t==="down"?i.y+=this.charToFollow.getTileWidth()-1:t==="down-left"?i.y+=this.charToFollow.getTileWidth()-1:t==="down-right"?(i.y+=this.charToFollow.getTileWidth()-1,i.x+=this.charToFollow.getTileWidth()-1):t==="up-right"&&(i.x+=this.charToFollow.getTileWidth()-1),this.gridTilemap.getTilePosInDirection({position:new Qt(i),layer:this.charToFollow.getTilePos().layer},t).position}updateTarget(g,t){let i=this.options.facingDirection!=="none"&&this.options.distance===0;i&&(g=this.getFacingPos()),this.targetMovement=new OC(this.character,this.gridTilemap,{position:new Qt(g),layer:t},{distance:i?0:this.options.distance+1,config:{algorithm:this.options.shortestPathAlgorithm,noPathFoundStrategy:this.options.noPathFoundStrategy,maxPathLength:this.options.maxPathLength,ignoreLayers:this.options.ignoreLayers,considerCosts:this.options.considerCosts,ignoredChars:[this.charToFollow.getId()]}})}},aT=class{static getRandomInt(g){return Math.floor(Math.random()*Math.floor(g))}},c4=class{constructor(g,t=0,i=-1){this.character=g,this.delay=t,this.radius=i,this.stepSize=0,this.delayLeft=this.delay,this.initialRow=g.getNextTilePos().position.y,this.initialCol=g.getNextTilePos().position.x,this.randomizeStepSize(),this.stepsWalked=0,this.currentMovementDirection="none",this.character.positionChangeStarted().pipe(Ta(this.character.autoMovementSet().pipe(ph(x=>x!==this),qf(1)))).subscribe(()=>{this.stepsWalked++}),this.distanceUtils=gd.create(g.getNumberOfDirections())}update(g){if(this.shouldContinueWalkingCurrentDirection())this.character.move(this.currentMovementDirection);else if(this.delayLeft-=g,this.delayLeft<=0){this.delayLeft=this.delay;let t=this.getFreeRandomDirection();this.stepsWalked=0,this.character.move(t),this.currentMovementDirection=t,this.randomizeStepSize()}}getInfo(){return{type:"Random",config:{delay:this.delay,radius:this.radius}}}shouldContinueWalkingCurrentDirection(){return this.stepsWalked!this.character.isBlockingDirection(g)).filter(g=>this.isWithinRadius(g))}isWithinRadius(g){return this.radius==-1?!0:this.getDist(g)<=this.radius}getDist(g){return this.distanceUtils.distance(this.character.getNextTilePos().position.add(Cu(g)),new Qt(this.initialCol,this.initialRow))}getFreeRandomDirection(){let g=this.getFreeDirections();return g.length==0?"none":g[aT.getRandomInt(g.length)]}randomizeStepSize(){this.stepSize=aT.getRandomInt(this.radius)+1}};function d4(g,t){return g.filter(i=>{var x,T,E,s,y,e;return(x=t.labels)!=null&&x.withAllLabels?(T=t.labels)==null?void 0:T.withAllLabels.every(r=>i.hasLabel(r)):(E=t.labels)!=null&&E.withOneOfLabels?(s=t.labels)==null?void 0:s.withOneOfLabels.some(r=>i.hasLabel(r)):(y=t.labels)!=null&&y.withNoneLabels?!((e=t.labels)!=null&&e.withNoneLabels.some(r=>i.hasLabel(r))):!0})}var RC="2.44.6",p4=class{constructor(g,t){this.collistionStrategy=g,this.collisionGroupRelation=t,this.tilePosToCharacters=new v4,this.charRemoved$=new In}isCharBlockingAt(g,t,i,x=new Set,T=new Set){if(i.length===0)return!1;let E=this.tilePosToCharacters.get(g,t);return!!(E&&E.size>0&&[...E].filter(s=>!x.has(s.getId())).filter(s=>!this.doIntersect(s.getCollisionGroups(),T)).some(s=>i.some(y=>s.getCollisionGroups().some(e=>this.collidesWith(y,e)))))}doIntersect(g,t){for(let i of g)if(t.has(i))return!0;return!1}collidesWith(g,t){return this.collisionGroupRelation?(this.collisionGroupRelation.get(g)||new Set).has(t):g===t}getCharactersAt(g,t){return this.tilePosToCharacters.get(g,t)||new Set}addCharacter(g){this.addTilePositions(g.getTilePos(),g),this.addTilePositions(g.getNextTilePos(),g),this.addPositionChangeSub(g),this.addPositionChangeFinishedSub(g),this.addTilePosSetSub(g)}removeCharacter(g){let t=g.getId();this.charRemoved$.next(t),this.deleteTilePositions(g.getTilePos(),g),this.deleteTilePositions(g.getNextTilePos(),g)}add(g,t,i){let x=this.tilePosToCharacters.get(g,t);x||this.tilePosToCharacters.set(g,t,new Set([i])),x?.add(i)}addTilePosSetSub(g){g.tilePositionSet().pipe(Ta(this.charRemoved(g.getId()))).subscribe(t=>{this.deleteTilePositions(g.getNextTilePos(),g),this.addTilePositions(t,g)})}charRemoved(g){var t;return(t=this.charRemoved$)==null?void 0:t.pipe(qf(1),ph(i=>i==g))}addPositionChangeSub(g){g.positionChangeStarted().pipe(Ta(this.charRemoved(g.getId())),this.posChangeToLayerPos()).subscribe(t=>{this.collistionStrategy==="BLOCK_ONE_TILE_AHEAD"&&this.deleteTilePositions(t.exit,g),this.addTilePositions(t.enter,g)})}addPositionChangeFinishedSub(g){g.positionChangeFinished().pipe(Ta(this.charRemoved(g.getId())),this.posChangeToLayerPos()).subscribe(t=>{this.deleteTilePositions(t.exit,g),this.addTilePositions(t.enter,g)})}addTilePositions(g,t){this.forEachCharTile(g,t,(i,x)=>{this.add(new Qt(i,x),g.layer,t)})}deleteTilePositions(g,t){this.forEachCharTile(g,t,(i,x)=>{var T;(T=this.tilePosToCharacters.get(new Qt(i,x),g.layer))==null||T.delete(t)})}forEachCharTile(g,t,i){let x=g.position;for(let T=x.x;T({enter:{position:new Qt(g.enterTile),layer:g.enterLayer},exit:{position:new Qt(g.exitTile),layer:g.exitLayer}})))}posToString(g,t){return`${g.x}#${g.y}#${t}`}},v4=class{constructor(){this.memo=new Map}set(g,t,i){let x=this.memo.get(g.x);x||(x=new Map,this.memo.set(g.x,x));let T=x.get(g.y);T||(T=new Map,x.set(g.y,T)),T.set(t,i)}get(g,t){let i=this.memo.get(g.x);if(!i)return;let x=i.get(g.y);if(x)return x.get(t)}},jx=class{constructor(g,t,i,x){this.x=g,this.y=t,this.width=i,this.height=x}getX(){return this.x}getY(){return this.y}getWidth(){return this.width}getHeight(){return this.height}isInRange(g){return g.x>=this.x&&g.x=this.y&&g.yi.isCharLayer());for(let i of[...t,void 0]){let x=this.tileCollisionCache.get(i?.getName());if(x===void 0){x=new Array(this.tilemap.getWidth());for(let T=0;T>t&1)==1}var lT="ge_cost",bC=class LC{constructor(t,i,x,T=void 0,E=!1){this.tilemap=t,this.collisionTilePropertyName=i,this.useTileCollisionCache=E,this.characters=new Map,this.transitions=new Map,this.reverseTransitions=new Map,this.collidesPropNames=new Map,this.tileCostPropNames=new Map,this.collisionRelevantLayersFrameCache=new Map,this.charBlockCache=new p4(x,T);for(let s of Yx())this.collidesPropNames.set(s,LC.ONE_WAY_COLLIDE_PROP_PREFIX+s),this.tileCostPropNames.set(s,`${lT}_${s}`);this.useTileCollisionCache&&(this.tileCollisionCache=new g4(t,this),this.tileCollisionCache.rebuild())}fixCacheLayer(t){var i;(i=this.tileCollisionCache)==null||i.fixLayer(t)}unfixCacheLayers(){var t;(t=this.tileCollisionCache)==null||t.unfixLayers()}addCharacter(t){this.characters.set(t.getId(),t);let i=t.getNextTilePos().layer;i===void 0?t.setTilePosition(dh(An({},t.getNextTilePos()),{layer:this.getLowestCharLayer()})):this.getCharLayerNames().includes(i)||console.warn(`Char layer '${i}' of character '${t.getId()}' is unknown.`),this.charBlockCache.addCharacter(t)}removeCharacter(t){let i=this.characters.get(t);i&&(this.charBlockCache.removeCharacter(i),this.characters.delete(t))}getCharacters(){return[...this.characters.values()]}getCharactersAt(t,i){return this.charBlockCache.getCharactersAt(t,i)}rebuildTileCollisionCache(t){var i;(i=this.tileCollisionCache)==null||i.rebuild(t)}hasBlockingTileUncached(t,i,x,T){if(!T&&this.hasNoTileUncached(t,i))return!0;let E=this.getCollisionRelevantLayers(i);for(let s of E)if(this.isLayerBlockingAt(s.getName(),t,x))return!0;return!1}hasBlockingTile(t,i,x,T){var E;let s=(E=this.tileCollisionCache)==null?void 0:E.isBlockingFrom(t.x,t.y,i,x,T);return s!==void 0?s:this.hasBlockingTileUncached(t,i,x,T)}getTransition(t,i){let x=this.transitions.get(t.toString());if(x)return x.get(i)}getReverseTransitions(t,i){let x=this.reverseTransitions.get(t.toString());if(x)return x.get(i)}setTransition(t,i,x){var T,E,s,y,e;this.transitions.has(t.toString())||this.transitions.set(t.toString(),new Map),this.reverseTransitions.has(t.toString())||this.reverseTransitions.set(t.toString(),new Map),(T=this.transitions.get(t.toString()))==null||T.set(i,x),(E=this.reverseTransitions.get(t.toString()))!=null&&E.has(x)||(s=this.reverseTransitions.get(t.toString()))==null||s.set(x,new Set),(e=(y=this.reverseTransitions.get(t.toString()))==null?void 0:y.get(x))==null||e.add(i)}getTransitions(){return new Map([...this.transitions].map(([t,i])=>[t,new Map(i)]))}getTileCosts(t,i){let x=this.getCollisionRelevantLayers(t.layer),T=1;for(let E of x)T=Math.max(T,this.getTileCostsForLayer(dh(An({},t),{layer:E.getName()}),i));return T}getTileCostsForLayer(t,i){let x=this.tilemap.getTileAt(t.position.x,t.position.y,t.layer);return i&&x?.getProperty(this.tileCostPropNames.get(i)||"")||x?.getProperty(lT)||1}hasNoTileUncached(t,i){return!this.getCollisionRelevantLayers(i).some(x=>this.tilemap.hasTileAt(t.x,t.y,x.getName()))}hasNoTile(t,i){var x;let T=(x=this.tileCollisionCache)==null?void 0:x.hasTileAt(t.x,t.y,i);return T!==void 0?T:this.hasNoTileUncached(t,i)}hasBlockingChar(t,i,x,T=new Set,E=new Set){return this.charBlockCache.isCharBlockingAt(t,i,x,T,E)}isInRange(t){return new jx(0,0,this.tilemap.getWidth(),this.tilemap.getHeight()).isInRange(t)}toMapDirection(t){return this.isIsometric()?SO(t):t}fromMapDirection(t){return this.isIsometric()?JM(t):t}isIsometric(){return this.tilemap.getOrientation()==="isometric"}getTilePosInDirection(t,i){let x=t.position.add(Cu(this.toMapDirection(i))),T=this.getTransition(x,t.layer)||t.layer;return{position:x,layer:T}}invalidateFrameCache(){this.collisionRelevantLayersFrameCache.clear()}isLayerBlockingAt(t,i,x){let T=this.tilemap.getTileAt(i.x,i.y,t);return T?!!(T.getProperty(this.collisionTilePropertyName)||x&&T.getProperty(this.collidesPropNames.get(x)||"")):!1}getCharLayerIndexes(){return this.tilemap.getLayers().map((t,i)=>({layer:t,index:i})).filter(({layer:t})=>t.isCharLayer()).map(({index:t})=>t)}findPrevAndCharLayer(t){let i=this.getCharLayerIndexes(),x=this.tilemap.getLayers(),T=i.findIndex(E=>x[E].getProperty(Qv)==t);return T==0?{prevIndex:-1,charLayerIndex:i[T]}:{prevIndex:i[T-1],charLayerIndex:i[T]}}getCollisionRelevantLayers(t){if(!t)return this.tilemap.getLayers();let i=this.collisionRelevantLayersFrameCache.get(t);if(i)return i;let{prevIndex:x,charLayerIndex:T}=this.findPrevAndCharLayer(t),E=this.tilemap.getLayers().slice(x+1,T+1);return this.collisionRelevantLayersFrameCache.set(t,E),E}getLowestCharLayer(){for(let t of this.tilemap.getLayers())if(t.isCharLayer())return t.getProperty(Qv)}getCharLayerNames(){return this.tilemap.getLayers().filter(t=>t.isCharLayer()).map(t=>t.getProperty(Qv)).filter(x4)}};bC.ONE_WAY_COLLIDE_PROP_PREFIX="ge_collide_";var y4=bC;function x4(g){return g!=null}var S4=(g=>(g.REMOVED="REMOVED",g.ADDED="ADDED",g))(S4||{}),T4=(g=>(g.WAIT="WAIT",g.SKIP="SKIP",g.STOP="STOP",g))(T4||{}),E4=class{constructor(g,t){this.character=g,this.tilemap=t,this.queue=new pm,this.finished$=new In,this.pathBlockedWaitElapsed=0,this.distanceUtils=gd.create(g.getNumberOfDirections()),this.character.autoMovementSet().pipe(ph(i=>i!==this),qf(1)).subscribe(()=>{this.queue.size()>0&&this.finishMovementTerminated(),this.finished$.complete()})}update(g){(!this.character.isMoving()||this.character.willCrossTileBorderThisUpdate(g))&&this.queue.size()>0&&this.moveCharOnPath(g)}getInfo(){return{type:"Queue"}}enqueue(g,t={}){var i,x,T;let E={pathBlockedStrategy:(i=t.pathBlockedStrategy)!=null?i:"STOP",pathBlockedWaitTimeoutMs:t?.pathBlockedWaitTimeoutMs||-1,ignoreInvalidPositions:(x=t.ignoreInvalidPositions)!=null?x:!1,skipInvalidPositions:(T=t.skipInvalidPositions)!=null?T:!1};for(let s of g){let y={command:s,config:E};if(If(s)){this.queue.enqueue(y);continue}let e=this.queue.peekEnd(),r=e?.command;if(r||(r=this.character.getNextTilePos()),If(r)){this.queue.enqueue(y);continue}let p=this.distanceUtils.distance(r.position,s.position)===1;(!t.ignoreInvalidPositions||p)&&this.queue.enqueue(y)}}peekAll(){return this.queue.peekAll()}size(){return this.queue.size()}finished(){return this.finished$}clear(){this.queue.clear()}moveCharOnPath(g){let t=this.queue.peek();if(!t)return;let i=t.command,x=t.config;if(If(i)&&(i=this.tilemap.getTilePosInDirection(this.character.getNextTilePos(),i)),x.skipInvalidPositions){if(i=this.getNextValidPosition(),!i){this.finishInvalidNextPos(i);return}}else if(!this.isNeighborPos(i)){this.finishInvalidNextPos(i);return}if(this.character.isBlockingDirection(Ma(this.character.getNextTilePos().position,i.position))){if(x.pathBlockedStrategy==="STOP")this.finishPathBlocked(i);else if(x.pathBlockedStrategy==="SKIP"){this.queue.dequeue(),this.moveCharOnPath(g);return}else x.pathBlockedStrategy==="WAIT"&&x.pathBlockedWaitTimeoutMs>-1&&(this.pathBlockedWaitElapsed+=g,this.pathBlockedWaitElapsed>=x.pathBlockedWaitTimeoutMs&&this.finishBlockedWaitTimeout(i,x.pathBlockedWaitTimeoutMs));return}this.pathBlockedWaitElapsed=0,this.queue.dequeue(),this.character.move(this.getDir(this.character.getNextTilePos().position,i.position)),this.isLastMovement()&&this.finish("SUCCESS","",i)}getNextValidPosition(){for(var g;this.queue.size()>0;){let t=(g=this.queue.peek())==null?void 0:g.command;if(If(t)&&(t=this.tilemap.getTilePosInDirection(this.character.getNextTilePos(),t)),t&&this.isNeighborPos(t))return t;this.queue.dequeue()}}isLastMovement(){return this.queue.size()===0}isNeighborPos(g){let t=this.distanceUtils.distance(this.character.getNextTilePos().position,g.position)===1,i=this.tilemap.getTransition(g.position,this.character.getNextTilePos().layer);if(this.character.getNextTilePos().layer!==g.layer)return t&&i===g.layer;let x=i!==void 0&&i!==g.layer;return t&&!x}finishMovementTerminated(){this.finish("MOVEMENT_TERMINATED","New automatic movement has been set to character.")}finishInvalidNextPos(g){g?this.finish("INVALID_NEXT_POS",`Position ${this.posToStr(g)} is not reachable from ${this.posToStr(this.character.getNextTilePos())}.`):this.finish("INVALID_NEXT_POS",`No enqueued position is reachable from ${this.posToStr(this.character.getNextTilePos())}.`)}finishPathBlocked(g){this.finish("PATH_BLOCKED",`Position ${this.posToStr(g)} is blocked.`)}finishBlockedWaitTimeout(g,t){this.finish("PATH_BLOCKED_WAIT_TIMEOUT",`Position ${this.posToStr(g)} is blocked and the wait timeout of ${t} ms has been exceeded.`)}finish(g,t="",i=this.character.getNextTilePos()){this.queue=new pm,this.finished$.next({position:i.position,result:g,description:t,layer:i.layer})}getDir(g,t){return this.tilemap.fromMapDirection(Ma(g,t))}posToStr(g){return`(${g.position.x}, ${g.position.y}, ${g.layer})`}},M4=class{constructor(g=!0){this.isCreatedInternal=!1,g&&console.log(`Using GridEngine v${RC}`)}getCharLayer(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getTilePos().layer}getTransition(g,t){var i;return this.initGuard(),(i=this.gridTilemap)==null?void 0:i.getTransition(new Qt(g),t)}setTransition(g,t,i){var x;return this.initGuard(),(x=this.gridTilemap)==null?void 0:x.setTransition(new Qt(g),t,i)}create(g,t){this.isCreatedInternal=!0,this.gridCharacters=new Map;let i=this.setConfigDefaults(t);this.config=i,this.movementStopped$=new In,this.movementStarted$=new In,this.directionChanged$=new In,this.positionChangeStarted$=new In,this.positionChangeFinished$=new In,this.queueMovementFinished$=new In,this.charRemoved$=new In,this.charAdded$=new In,this.gridTilemap=new y4(g,this.config.collisionTilePropertyName,this.config.characterCollisionStrategy,this.recordToMap(this.config.collisionGroupRelation),this.config.cacheTileCollisions),this.addCharacters()}recordToMap(g){return g?new Map(Object.entries(g).map(([t,i])=>[t,new Set(i)])):void 0}getPosition(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getTilePos().position}move(g,t){this.moveChar(g,t)}moveRandomly(g,t=0,i=-1){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(g);if(!T)throw this.createCharUnknownErr(g);let E=new c4(T,t,i);T.setMovement(E)}getMovement(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);let x=i.getMovement();return x?x.getInfo():{type:"None"}}moveTo(g,t,i){var x;let T=this.assembleMoveToConfig(i);this.initGuard();let E=(x=this.gridCharacters)==null?void 0:x.get(g);if(!E)throw this.createCharUnknownErr(g);if(!this.gridTilemap)throw this.createUninitializedErr();let s=new OC(E,this.gridTilemap,{position:new Qt(t),layer:i?.targetLayer||E.getNextTilePos().layer},{distance:0,config:T});return E.setMovement(s),s.finishedObs().pipe(od(y=>({charId:g,position:y.position,result:y.result,description:y.description,layer:y.layer})))}stopMovement(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);i.setMovement(void 0)}setSpeed(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.setSpeed(t)}getSpeed(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getSpeed()}collidesWithTiles(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.collidesWithTiles()}update(g,t){var i;if(this.isCreatedInternal&&this.gridCharacters)for(let[x,T]of this.gridCharacters)T.update(t);(i=this.gridTilemap)==null||i.invalidateFrameCache()}addCharacter(g){var t,i,x,T,E;if(!this.gridTilemap)throw this.createUninitializedErr();if(!this.config)throw this.createUninitializedErr();let s={speed:g.speed||4,tilemap:this.gridTilemap,collidesWithTiles:!0,collisionGroups:["geDefault"],ignoreCollisionGroups:[],charLayer:g.charLayer,facingDirection:g.facingDirection,labels:g.labels,numberOfDirections:(t=g.numberOfDirections)!=null?t:this.config.numberOfDirections,tileWidth:g.tileWidth,tileHeight:g.tileHeight};typeof g.collides=="boolean"?g.collides===!1&&(s.collidesWithTiles=!1,s.collisionGroups=[]):g.collides!==void 0&&(g.collides.collidesWithTiles===!1&&(s.collidesWithTiles=!1),g.collides.collisionGroups&&(s.collisionGroups=g.collides.collisionGroups),g.collides.ignoreCollisionGroups&&(s.ignoreCollisionGroups=g.collides.ignoreCollisionGroups),s.ignoreMissingTiles=(x=(i=g.collides)==null?void 0:i.ignoreMissingTiles)!=null?x:!1);let y=new n4(g.id,s);g.startPosition&&y.setTilePosition({position:new Qt(g.startPosition),layer:y.getTilePos().layer}),(T=this.gridCharacters)==null||T.set(g.id,y),this.gridTilemap.addCharacter(y);let e=y.getId();y.movementStopped().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.movementStopped$)==null||p.next({charId:e,direction:r})}),y.movementStarted().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.movementStarted$)==null||p.next({charId:e,direction:r})}),y.directionChanged().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.directionChanged$)==null||p.next({charId:e,direction:r})}),y.positionChangeStarted().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.positionChangeStarted$)==null||p.next(An({charId:e},r))}),y.positionChangeFinished().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.positionChangeFinished$)==null||p.next(An({charId:e},r))}),(E=this.charAdded$)==null||E.next(e)}hasCharacter(g){var t;return this.initGuard(),!!((t=this.gridCharacters)!=null&&t.has(g))}removeCharacter(g){var t,i,x,T;if(this.initGuard(),!((t=this.gridCharacters)!=null&&t.get(g)))throw this.createCharUnknownErr(g);(i=this.gridTilemap)==null||i.removeCharacter(g),(x=this.gridCharacters)==null||x.delete(g),(T=this.charRemoved$)==null||T.next(g)}removeAllCharacters(){if(this.initGuard(),!!this.gridCharacters)for(let g of this.gridCharacters.keys())this.removeCharacter(g)}getAllCharacters(g){if(this.initGuard(),!this.gridCharacters)return[];let t=[...this.gridCharacters.values()];return(g?d4(t,g):t).map(i=>i.getId())}getLabels(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getLabels()}addLabels(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.addLabels(t)}removeLabels(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.removeLabels(t)}clearLabels(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);i.clearLabels()}follow(g,t,i,x){var T,E,s,y,e,r;let p;i===void 0?p={distance:0,closestPointIfBlocked:!1}:typeof i=="number"?(p={distance:i,closestPointIfBlocked:!1},x&&(p.closestPointIfBlocked=!0)):p=i,this.initGuard();let h=(T=this.gridCharacters)==null?void 0:T.get(g),a=(E=this.gridCharacters)==null?void 0:E.get(t);if(!h)throw this.createCharUnknownErr(g);if(!a)throw this.createCharUnknownErr(t);if(!this.gridTilemap)throw this.createUninitializedErr();let l=new f4(h,this.gridTilemap,a,{distance:(s=p.distance)!=null?s:0,noPathFoundStrategy:p.closestPointIfBlocked?"CLOSEST_REACHABLE":"STOP",maxPathLength:(y=p.maxPathLength)!=null?y:1/0,shortestPathAlgorithm:(e=p.algorithm)!=null?e:"BIDIRECTIONAL_SEARCH",ignoreLayers:!!p.ignoreLayers,facingDirection:(r=p.facingDirection)!=null?r:"none"});h.setMovement(l)}isMoving(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.isMoving()}getFacingDirection(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getFacingDirection()}getFacingPosition(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);let x=i.getFacingPosition();return{x:x.x,y:x.y}}turnTowards(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);return x.turnTowards(t)}getCharactersAt(g,t){if(this.initGuard(),!this.gridTilemap)return[];let i=this.gridTilemap.getCharactersAt(new Qt(g),t);return Array.from(i).map(x=>x.getId())}setPosition(g,t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(g);if(!T)throw this.createCharUnknownErr(g);i||T.setTilePosition({position:new Qt(t),layer:T.getTilePos().layer}),T.setTilePosition({position:new Qt(t),layer:i})}isBlocked(g,t,i=["geDefault"]){var x,T;this.initGuard();let E=new Qt(g);return!!((x=this.gridTilemap)!=null&&x.hasBlockingTile(E,t)||(T=this.gridTilemap)!=null&&T.hasBlockingChar(E,t,i))}isTileBlocked(g,t){var i;return this.initGuard(),!!((i=this.gridTilemap)!=null&&i.hasBlockingTile(new Qt(g),t))}getCollisionGroups(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getCollisionGroups()||[]}setCollisionGroups(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.setCollisionGroups(t)}getIgnoreCollisionGroups(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getIgnoreCollisionGroups()||[]}setIgnoreCollisionGroups(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.setIgnoreCollisionGroups(t)}getTilePosInDirection(g,t,i){if(!this.gridTilemap)throw this.createUninitializedErr();let x=this.gridTilemap.getTilePosInDirection({position:new Qt(g),layer:t},i);return{position:x.position.toPosition(),charLayer:x.layer}}findShortestPath(g,t,i={}){if(!this.gridTilemap)throw this.createUninitializedErr();let x=i.shortestPathAlgorithm||"BFS";i.considerCosts&&x!=="A_STAR"&&console.warn(`GridEngine: Pathfinding option 'considerCosts' cannot be used with algorithm '${x}'. It can only be used with A* algorithm.`);let T=i.pathWidth!==void 0&&i.pathWidth!==1,E=i.pathHeight!==void 0&&i.pathHeight!==1;(T||E)&&x==="JPS"&&console.warn("GridEngine: Pathfinding options 'pathWidth' and 'pathHeight' > 1 cannot be used with algorithm 'JPS'.");let s=new FC(this.gridTilemap).findShortestPath(Ai.toInternal(g),Ai.toInternal(t),dh(An({},i),{shortestPathAlgorithm:x}));return{path:s.path.map(Ai.fromInternal),closestToTarget:s.closestToTarget?Ai.fromInternal(s.closestToTarget):void 0,reachedMaxPathLength:!1,steps:s.steps}}steppedOn(g,t,i){return this.positionChangeFinished().pipe(ph(x=>g.includes(x.charId)&&t.some(T=>T.x===x.enterTile.x&&T.y===x.enterTile.y)&&(i===void 0||i.includes(x.enterLayer))))}characterShifted(){if(!this.charAdded$||!this.charRemoved$)throw this.createUninitializedErr();return this.charAdded$.pipe(od(g=>({charId:g,action:"ADDED"})),i4(this.charRemoved$.pipe(od(g=>({charId:g,action:"REMOVED"})))))}movementStarted(){if(!this.movementStarted$)throw this.createUninitializedErr();return this.movementStarted$}movementStopped(){if(!this.movementStopped$)throw this.createUninitializedErr();return this.movementStopped$}directionChanged(){if(!this.directionChanged$)throw this.createUninitializedErr();return this.directionChanged$}positionChangeStarted(){if(!this.positionChangeStarted$)throw this.createUninitializedErr();return this.positionChangeStarted$}positionChangeFinished(){if(!this.positionChangeFinished$)throw this.createUninitializedErr();return this.positionChangeFinished$}getMovementProgress(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getMovementProgress()}rebuildTileCollisionCache(g,t,i,x){var T;(T=this.gridTilemap)==null||T.rebuildTileCollisionCache(new jx(g,t,i,x))}addQueueMovements(g,t,i){var x,T;this.initGuard();let E=(x=this.gridCharacters)==null?void 0:x.get(g);if(!E)throw this.createCharUnknownErr(g);if(!this.gridTilemap)throw this.createUninitializedErr();let s;((T=E?.getMovement())==null?void 0:T.getInfo().type)==="Queue"?s=E.getMovement():(s=new E4(E,this.gridTilemap),E.setMovement(s),s.finished().pipe(Ta(_O(this.charRemoved(g),E.autoMovementSet()))).subscribe(y=>{var e;(e=this.queueMovementFinished$)==null||e.next(An({charId:g},y))})),s.enqueue(t.map(y=>If(y)?y:{position:new Qt(y.position),layer:y.charLayer}),i)}queueMovementFinished(){if(!this.queueMovementFinished$)throw this.createUninitializedErr();return this.queueMovementFinished$}getEnqueuedMovements(g){var t,i;this.initGuard();let x=(t=this.gridCharacters)==null?void 0:t.get(g);if(!x)throw this.createCharUnknownErr(g);return((i=x.getMovement())==null?void 0:i.getInfo().type)==="Queue"?x.getMovement().peekAll().map(T=>({command:If(T.command)?T.command:Ai.fromInternal(T.command),config:T.config})):[]}clearEnqueuedMovements(g){var t,i;this.initGuard();let x=(t=this.gridCharacters)==null?void 0:t.get(g);if(!x)throw this.createCharUnknownErr(g);((i=x.getMovement())==null?void 0:i.getInfo().type)==="Queue"&&x.getMovement().clear()}getTileCost(g,t,i){var x,T;return this.initGuard(),(T=(x=this.gridTilemap)==null?void 0:x.getTileCosts({position:new Qt(g),layer:t},i))!=null?T:1}getState(){let g=[];if(this.gridCharacters)for(let[t,i]of this.gridCharacters.entries())g.push({id:t,position:Ai.fromInternal(i.getTilePos()),facingDirection:i.getFacingDirection(),speed:i.getSpeed(),labels:i.getLabels(),movementProgress:i.getMovementProgress(),collisionConfig:{collisionGroups:i.getCollisionGroups(),ignoreCollisionGroups:i.getIgnoreCollisionGroups(),collidesWithTiles:i.collidesWithTiles(),ignoreMissingTiles:i.getIgnoreMissingTiles()}});return{characters:g}}setState(g){if(this.gridCharacters)for(let t of g.characters){let i=this.gridCharacters.get(t.id);if(i){let x=i.getTilePos();Ai.equal(x,Ai.toInternal(t.position))||i.setTilePosition(Ai.toInternal(t.position)),i.setSpeed(t.speed),i.turnTowards(t.facingDirection),t.collisionConfig.collisionGroups&&i.setCollisionGroups(t.collisionConfig.collisionGroups),t.collisionConfig.collidesWithTiles!==void 0&&i.setCollidesWithTiles(t.collisionConfig.collidesWithTiles),t.collisionConfig.ignoreMissingTiles!==void 0&&i.setIgnoreMissingTiles(t.collisionConfig.ignoreMissingTiles),i.setMovementProgress(t.movementProgress),i.clearLabels(),i.addLabels(t.labels)}}}charRemoved(g){var t;if(!this.charRemoved$)throw this.createUninitializedErr();return(t=this.charRemoved$)==null?void 0:t.pipe(qf(1),ph(i=>i==g))}initGuard(){if(!this.isCreatedInternal)throw this.createUninitializedErr()}createUninitializedErr(){throw new Error("GridEngine not initialized. You need to call create() first.")}addCharacters(){var g;(g=this.config)==null||g.characters.forEach(t=>this.addCharacter(t))}moveChar(g,t){var i,x,T;this.initGuard();let E=(i=this.gridCharacters)==null?void 0:i.get(g);if(!E)throw this.createCharUnknownErr(g);if(E.getNumberOfDirections()===4){if(!((x=this.gridTilemap)!=null&&x.isIsometric())&&ad(t)){console.warn(`GridEngine: Character '${g}' can't be moved '${t}' in 4 direction mode.`);return}else if((T=this.gridTilemap)!=null&&T.isIsometric()&&!ad(t)){console.warn(`GridEngine: Character '${g}' can't be moved '${t}' in 4 direction isometric mode.`);return}}E.move(t)}createCharUnknownErr(g){return new Error(`Character unknown: ${g}`)}assembleMoveToConfig(g={}){let t=dh(An({},g),{noPathFoundStrategy:"STOP",pathBlockedStrategy:"WAIT"});return g!=null&&g.noPathFoundStrategy&&(Object.values(CC).includes(g.noPathFoundStrategy)?t.noPathFoundStrategy=g.noPathFoundStrategy:console.warn(`GridEngine: Unknown NoPathFoundStrategy '${g.noPathFoundStrategy}'. Falling back to 'STOP'`)),g!=null&&g.pathBlockedStrategy&&(Object.values(wC).includes(g.pathBlockedStrategy)?t.pathBlockedStrategy=g.pathBlockedStrategy:console.warn(`GridEngine: Unknown PathBlockedStrategy '${g.pathBlockedStrategy}'. Falling back to 'WAIT'`)),t}setConfigDefaults(g){return An({collisionTilePropertyName:"ge_collide",numberOfDirections:4,characterCollisionStrategy:"BLOCK_TWO_TILES",cacheTileCollisions:!1},g)}},C4=class extends PC{constructor(g,t={}){super(g,t),this.jumpCache=new hT}findShortestPathImpl(g,t){return this.jumpCache=new hT,super.findShortestPathImpl(g,t)}getNeighborsInternal(g,t,i){if(!t||g.layer!==t.layer)return this.getNeighbors(g,i).map(E=>({p:E,dist:1}));let x=this.prune(t,g).map(E=>{let s=this.getTransition(E.position,g.layer);return{position:E.position,layer:s||g.layer}}),T=[];for(let E of x){let s=this.jump(g,E,i,1,Ma(g.position,E.position));s&&(s.dist=this.distance(g.position,s.p.position),T.push(s))}return T}getForced(g,t){let i=[],{topLeft:x,downLeft:T,top:E,bottom:s,topRight:y,downRight:e}=this.normalizedPositions(g,t),r=Ma(g.position,t.position);return ad(r)?(this.blockOrTrans(g,x)&&(this.addIfNotBlocked(i,t,E),this.addIfNotBlocked(i,t,y),this.blockOrTrans(T,x)&&this.addIfNotBlocked(i,t,x)),this.blockOrTrans(g,T)&&(this.addIfNotBlocked(i,t,s),this.addIfNotBlocked(i,t,e),this.blockOrTrans(x,T)&&this.addIfNotBlocked(i,t,T)),this.blockOrTrans(x,E)&&this.addIfNotBlocked(i,t,E),this.blockOrTrans(T,s)&&this.addIfNotBlocked(i,t,s),this.blockOrTrans(x,y)&&this.addIfNotBlocked(i,t,y),this.blockOrTrans(T,e)&&this.addIfNotBlocked(i,t,e)):((this.blockOrTrans(g,E)||this.blockOrTrans(E,y))&&this.addIfNotBlocked(i,t,y),(this.blockOrTrans(g,s)||this.blockOrTrans(s,e))&&this.addIfNotBlocked(i,t,e),this.blockOrTrans(g,x)&&this.blockOrTrans(g,E)&&(this.addIfNotBlocked(i,t,E),this.addIfNotBlocked(i,t,x)),this.blockOrTrans(g,T)&&this.blockOrTrans(g,s)&&(this.addIfNotBlocked(i,t,s),this.addIfNotBlocked(i,t,T)),this.blockOrTrans(x,E)&&this.blockOrTrans(g,E)&&this.addIfNotBlocked(i,t,E),this.blockOrTrans(T,s)&&this.blockOrTrans(g,s)&&this.addIfNotBlocked(i,t,s)),i}hasForced(g,t){let{topLeft:i,downLeft:x,top:T,bottom:E,topRight:s,downRight:y}=this.normalizedPositions(g,t),e=Ma(g.position,t.position);if(ad(e)){if(this.blockOrTrans(g,i)&&(!this.blockOrTrans(t,T)||!this.blockOrTrans(t,s)||this.blockOrTrans(x,i)&&!this.blockOrTrans(t,i))||this.blockOrTrans(g,x)&&(!this.blockOrTrans(t,E)||!this.blockOrTrans(t,y)||this.blockOrTrans(i,x)&&!this.blockOrTrans(t,x))||this.blockOrTrans(i,T)&&!this.blockOrTrans(t,T)||this.blockOrTrans(x,E)&&!this.blockOrTrans(t,E)||this.blockOrTrans(i,s)&&!this.blockOrTrans(t,s)||this.blockOrTrans(x,y)&&!this.blockOrTrans(t,y))return!0}else if((this.blockOrTrans(g,T)||this.blockOrTrans(T,s))&&!this.blockOrTrans(t,s)||(this.blockOrTrans(g,E)||this.blockOrTrans(E,y))&&!this.blockOrTrans(t,y)||this.blockOrTrans(g,i)&&this.blockOrTrans(g,T)&&(!this.blockOrTrans(t,T)||!this.blockOrTrans(t,i))||this.blockOrTrans(g,x)&&this.blockOrTrans(g,E)&&(!this.blockOrTrans(t,E)||!this.blockOrTrans(t,x))||this.blockOrTrans(i,T)&&this.blockOrTrans(g,T)&&!this.blockOrTrans(t,T)||this.blockOrTrans(x,E)&&this.blockOrTrans(g,E)&&!this.blockOrTrans(t,E))return!0;return!1}prune(g,t){let{top:i,right:x,topRight:T,downRight:E,bottom:s}=this.normalizedPositions(g,t),y=this.getForced(g,t),e=Ma(g.position,t.position);return ad(e)?[i,x,T,E,s,...y]:[x,...y]}jump(g,t,i,x,T){let E=this.jumpCache.get(g,t);if(E!==null)return E;if(this.isBlocking(g,t)&&!(Ai.equal(t,i)&&this.options.ignoreBlockedTarget)){this.jumpCache.set(g,t,void 0);return}if(Ai.equal(t,i))return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(x>=this.maxJumpSize)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.getTransition(t.position,g.layer)!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.hasForced(g,t))return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.updateClosestToTarget(t,i),T==="up-left"){if(this.jump(t,this.getTilePosInDir(t,"up"),i,x+1,"up")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"left"),i,x+1,"left")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}else if(T==="down-left"){if(this.jump(t,this.getTilePosInDir(t,"down"),i,x+1,"down")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"left"),i,x+1,"left")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}else if(T==="up-right"){if(this.jump(t,this.getTilePosInDir(t,"up"),i,x+1,"up")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"right"),i,x+1,"right")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}else if(T==="down-right"){if(this.jump(t,this.getTilePosInDir(t,"down"),i,x+1,"down")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"right"),i,x+1,"right")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}let s=this.jump(t,this.getTilePosInDir(t,T),i,x+1,T);return this.jumpCache.set(g,t,s),s}normalizedPositions(g,t){return g.position.xt.position.x&&g.position.y===t.position.y?{topLeft:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},downLeft:{position:new Qt(t.position.x+1,t.position.y-1),layer:t.layer},top:{position:new Qt(t.position.x,t.position.y+1),layer:t.layer},bottom:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},right:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer},topRight:{position:new Qt(t.position.x-1,t.position.y+1),layer:t.layer},downRight:{position:new Qt(t.position.x-1,t.position.y-1),layer:t.layer}}:g.position.yt.position.y&&g.position.x===t.position.x?{topLeft:{position:new Qt(t.position.x-1,t.position.y+1),layer:t.layer},downLeft:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},top:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer},bottom:{position:new Qt(t.position.x+1,t.position.y),layer:t.layer},right:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},topRight:{position:new Qt(t.position.x-1,t.position.y-1),layer:t.layer},downRight:{position:new Qt(t.position.x+1,t.position.y-1),layer:t.layer}}:g.position.yt.position.x?{topLeft:{position:new Qt(t.position.x+1,t.position.y),layer:t.layer},downLeft:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},top:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},bottom:{position:new Qt(t.position.x-1,t.position.y-1),layer:t.layer},right:{position:new Qt(t.position.x-1,t.position.y+1),layer:t.layer},topRight:{position:new Qt(t.position.x,t.position.y+1),layer:t.layer},downRight:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer}}:g.position.y>t.position.y&&g.position.x(g.SUCCESS="SUCCESS",g.NO_PATH_FOUND_MAX_RETRIES_EXCEEDED="NO_PATH_FOUND_MAX_RETRIES_EXCEEDED",g.PATH_BLOCKED_MAX_RETRIES_EXCEEDED="PATH_BLOCKED_MAX_RETRIES_EXCEEDED",g.PATH_BLOCKED="PATH_BLOCKED",g.NO_PATH_FOUND="NO_PATH_FOUND",g.PATH_BLOCKED_WAIT_TIMEOUT="PATH_BLOCKED_WAIT_TIMEOUT",g.MOVEMENT_TERMINATED="MOVEMENT_TERMINATED",g.MAX_PATH_LENGTH_REACHED="MAX_PATH_LENGTH_REACHED",g))(A4||{}),OC=class{constructor(g,t,i,{config:x,ignoreBlockedTarget:T=!1,distance:E=0}={}){this.character=g,this.tilemap=t,this.targetPos=i,this.shortestPath=[],this.distOffset=0,this.posOnPath=0,this.stopped=!1,this.pathBlockedWaitElapsed=0,this.isPositionAllowed=()=>!0,this.shortestPathAlgorithm="BIDIRECTIONAL_SEARCH",this.maxPathLength=1/0,this.considerCosts=!1,this.ignoredChars=[],this.isBlocking=(e,r)=>e?new AC(this.tilemap,this.getPathfindingOptions()).isBlocking(this.character.getTilePos(),{position:e,layer:r}):!0;var s,y;this.shortestPathAlgorithm=(s=x?.algorithm)!=null?s:this.shortestPathAlgorithm,this.ignoreBlockedTarget=T,this.distance=E,this.noPathFoundStrategy=x?.noPathFoundStrategy||"STOP",this.pathBlockedStrategy=x?.pathBlockedStrategy||"WAIT",this.noPathFoundRetryable=new eT(x?.noPathFoundRetryBackoffMs||200,x?.noPathFoundMaxRetries||-1,()=>{this.stop("NO_PATH_FOUND_MAX_RETRIES_EXCEEDED")}),this.pathBlockedRetryable=new eT(x?.pathBlockedRetryBackoffMs||200,x?.pathBlockedMaxRetries||-1,()=>{this.stop("PATH_BLOCKED_MAX_RETRIES_EXCEEDED")}),x!=null&&x.isPositionAllowedFn&&(this.isPositionAllowed=x.isPositionAllowedFn),x!=null&&x.maxPathLength&&(this.maxPathLength=x.maxPathLength),this.alternativeTargets=x?.alternativeTargets,this.noPathFoundAlternativeTargetsFallbackStrategy=x?.noPathFoundAlternativeTargetsFallbackStrategy,x!=null&&x.considerCosts&&this.shortestPathAlgorithm!=="A_STAR"&&console.warn(`GridEngine: Pathfinding option 'considerCosts' cannot be used with algorithm '${this.shortestPathAlgorithm}'. It can only be used with A* algorithm.`),this.shortestPathAlgorithm==="JPS"&&(this.character.getTileWidth()>1||this.character.getTileHeight()>1)&&console.warn("GridEngine: Pathfinding algorithm 'JPS' can only be used for characters with 'tileWidth' and 'tileHeight' of 1"),this.considerCosts=x?.considerCosts||!1,this.ignoreLayers=!!(x!=null&&x.ignoreLayers),this.distanceUtils=gd.create(g.getNumberOfDirections()),this.pathBlockedWaitTimeoutMs=x?.pathBlockedWaitTimeoutMs||-1,this.ignoredChars=(y=x?.ignoredChars)!=null?y:[],this.finished$=new In,this.setCharacter(g)}setPathBlockedStrategy(g){this.pathBlockedStrategy=g}getPathBlockedStrategy(){return this.pathBlockedStrategy}setCharacter(g){this.character=g,this.noPathFoundRetryable.reset(),this.pathBlockedRetryable.reset(),this.pathBlockedWaitElapsed=0,this.calcShortestPath(),this.character.autoMovementSet().pipe(ph(t=>t!==this),qf(1)).subscribe(()=>{this.stop("MOVEMENT_TERMINATED")})}getPathfindingOptions(){return{shortestPathAlgorithm:this.shortestPathAlgorithm,pathWidth:this.character.getTileWidth(),pathHeight:this.character.getTileHeight(),numberOfDirections:this.character.getNumberOfDirections(),isPositionAllowed:this.isPositionAllowed,collisionGroups:this.character.getCollisionGroups(),ignoredChars:[this.character.getId(),...this.ignoredChars],ignoreTiles:!this.character.collidesWithTiles(),ignoreMapBounds:this.character.getIgnoreMissingTiles(),ignoreBlockedTarget:this.ignoreBlockedTarget,maxPathLength:this.maxPathLength,ignoreLayers:this.ignoreLayers,considerCosts:this.considerCosts,calculateClosestToTarget:!0}}update(g){var t,i,x,T;this.stopped||(this.noPathFound()&&(this.noPathFoundStrategy==="RETRY"?this.noPathFoundRetryable.retry(g,()=>this.calcShortestPath()):this.noPathFoundStrategy==="STOP"&&this.stop("NO_PATH_FOUND")),this.updatePosOnPath(),this.isBlocking((t=this.nextTileOnPath())==null?void 0:t.position,(i=this.character)==null?void 0:i.getNextTilePos().layer)?this.applyPathBlockedStrategy(g):this.pathBlockedWaitElapsed=0,this.hasArrived()?(this.stop("SUCCESS"),this.existsDistToTarget()&&this.turnTowardsTarget()):this.isBlocking((x=this.nextTileOnPath())==null?void 0:x.position,(T=this.character)==null?void 0:T.getNextTilePos().layer)||this.moveCharOnPath())}finishedObs(){return this.finished$}getInfo(){return{type:"Target",state:{pathAhead:this.shortestPath.slice(this.posOnPath).map(g=>Ai.fromInternal(g))},config:{algorithm:this.shortestPathAlgorithm,ignoreBlockedTarget:this.ignoreBlockedTarget,distance:this.distance,targetPos:Ai.fromInternal(this.targetPos),noPathFoundStrategy:this.noPathFoundStrategy,pathBlockedStrategy:this.pathBlockedStrategy,noPathFoundRetryBackoffMs:this.noPathFoundRetryable.getBackoffMs(),noPathFoundMaxRetries:this.noPathFoundRetryable.getMaxRetries()}}}resultToReason(g){switch(g){case"SUCCESS":return"Successfully arrived.";case"MOVEMENT_TERMINATED":return"Movement of character has been replaced before destination was reached.";case"PATH_BLOCKED":return"PathBlockedStrategy STOP: Path blocked.";case"NO_PATH_FOUND_MAX_RETRIES_EXCEEDED":return`NoPathFoundStrategy RETRY: Maximum retries of ${this.noPathFoundRetryable.getMaxRetries()} exceeded.`;case"NO_PATH_FOUND":return"NoPathFoundStrategy STOP: No path found.";case"PATH_BLOCKED_MAX_RETRIES_EXCEEDED":return`PathBlockedStrategy RETRY: Maximum retries of ${this.pathBlockedRetryable.getMaxRetries()} exceeded.`;case"PATH_BLOCKED_WAIT_TIMEOUT":return`PathBlockedStrategy WAIT: Wait timeout of ${this.pathBlockedWaitTimeoutMs}ms exceeded.`}}applyPathBlockedStrategy(g){this.pathBlockedStrategy==="RETRY"?this.pathBlockedRetryable.retry(g,()=>{let t=this.getShortestPath();t.path.length>0&&this.calcShortestPath(t)}):this.pathBlockedStrategy==="STOP"?this.stop("PATH_BLOCKED"):this.pathBlockedStrategy==="WAIT"&&this.pathBlockedWaitTimeoutMs>-1&&(this.pathBlockedWaitElapsed+=g,this.pathBlockedWaitElapsed>=this.pathBlockedWaitTimeoutMs&&this.stop("PATH_BLOCKED_WAIT_TIMEOUT"))}moveCharOnPath(){let g=this.nextTileOnPath();if(!g)return;let t=this.getDir(this.character.getNextTilePos().position,g.position);this.character.move(t)}nextTileOnPath(){return this.shortestPath[this.posOnPath+1]}stop(g){this.finished$.next({position:this.character.getTilePos().position,result:g,description:this.resultToReason(g),layer:this.character.getTilePos().layer}),this.finished$.complete(),this.stopped=!0}turnTowardsTarget(){let g=this.shortestPath[this.posOnPath+1],t=this.getDir(this.character.getNextTilePos().position,g.position);this.character.turnTowards(t)}existsDistToTarget(){return this.posOnPath=this.shortestPath.length-1}updatePosOnPath(){let g=this.shortestPath[this.posOnPath];for(;this.posOnPath0)return{path:E,distOffset:s}}return this.noPathFoundStrategy=this.noPathFoundAlternativeTargetsFallbackStrategy||"STOP",this.getShortestPath()}}return{path:i,distOffset:0}}pathToAlternativeTarget(g,t){let i=t.findShortestPath(this.character.getNextTilePos(),g,this.getPathfindingOptions()).path,x=this.distanceUtils.distance(g.position,this.targetPos.position);return{path:i,distOffset:x}}getDir(g,t){return this.tilemap.fromMapDirection(this.distanceUtils.direction(g,t))}},P4=Object.create,DC=Object.defineProperty,R4=Object.getOwnPropertyDescriptor,b4=Object.getOwnPropertyNames,L4=Object.getPrototypeOf,F4=Object.prototype.hasOwnProperty,O4=(g,t)=>()=>(t||g((t={exports:{}}).exports,t),t.exports),D4=(g,t,i,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let T of b4(t))!F4.call(g,T)&&T!==i&&DC(g,T,{get:()=>t[T],enumerable:!(x=R4(t,T))||x.enumerable});return g},Zx=(g,t,i)=>(i=g!=null?P4(L4(g)):{},D4(t||!g||!g.__esModule?DC(i,"default",{value:g,enumerable:!0}):i,g)),Jx=O4((g,t)=>{(function(){var i,x="4.17.21",T=200,E="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",y="Invalid `variable` option passed into `_.template`",e="__lodash_hash_undefined__",r=500,p="__lodash_placeholder__",h=1,a=2,l=4,n=1,u=2,f=1,o=2,c=4,d=8,v=16,m=32,S=64,M=128,w=256,C=512,A=30,P="...",b=800,O=16,I=1,D=2,B=3,G=1/0,z=9007199254740991,X=17976931348623157e292,K=NaN,Q=4294967295,tt=Q-1,Y=Q>>>1,Z=[["ary",M],["bind",f],["bindKey",o],["curry",d],["curryRight",v],["flip",C],["partial",m],["partialRight",S],["rearg",w]],U="[object Arguments]",H="[object Array]",J="[object AsyncFunction]",_="[object Boolean]",q="[object Date]",at="[object DOMException]",ot="[object Error]",rt="[object Function]",gt="[object GeneratorFunction]",yt="[object Map]",Et="[object Number]",At="[object Null]",Pt="[object Object]",Vt="[object Promise]",dt="[object Proxy]",ut="[object RegExp]",Rt="[object Set]",Dt="[object String]",Ht="[object Symbol]",Bt="[object Undefined]",ne="[object WeakMap]",oe="[object WeakSet]",ge="[object ArrayBuffer]",xe="[object DataView]",Ae="[object Float32Array]",qt="[object Float64Array]",Ge="[object Int8Array]",Oe="[object Int16Array]",Be="[object Int32Array]",Le="[object Uint8Array]",ie="[object Uint8ClampedArray]",Ke="[object Uint16Array]",ri="[object Uint32Array]",Ti=/\b__p \+= '';/g,le=/\b(__p \+=) '' \+/g,xi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bt=/&(?:amp|lt|gt|quot|#39);/g,Me=/[&<>"']/g,Ce=RegExp(bt.source),Ve=RegExp(Me.source),Je=/<%-([\s\S]+?)%>/g,zi=/<%([\s\S]+?)%>/g,Di=/<%=([\s\S]+?)%>/g,en=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zn=/^\w*$/,Gi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,di=/[\\^$.*+?()[\]{}|]/g,Wi=RegExp(di.source),Pa=/^\s+/,aa=/\s/,Bs=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Qr=/\{\n\/\* \[wrapped with (.+)\] \*/,ao=/,? & /,_r=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Us=/[()=,{}\[\]\/\s]/,xs=/\\(\\)?/g,oo=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Rl=/\w*$/,Tt=/^[-+]0x[0-9a-f]+$/i,jt=/^0b[01]+$/i,_t=/^\[object .+?Constructor\]$/,ee=/^0o[0-7]+$/i,te=/^(?:0|[1-9]\d*)$/,Te=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ue=/($^)/,We=/['\n\r\u2028\u2029\\]/g,$e="\\ud800-\\udfff",qe="\\u0300-\\u036f",ii="\\ufe20-\\ufe2f",ai="\\u20d0-\\u20ff",Ji=qe+ii+ai,hn="\\u2700-\\u27bf",ki="a-z\\xdf-\\xf6\\xf8-\\xff",mn="\\xac\\xb1\\xd7\\xf7",ti="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Se="\\u2000-\\u206f",Nr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",mi="A-Z\\xc0-\\xd6\\xd8-\\xde",un="\\ufe0e\\ufe0f",Ii=mn+ti+Se+Nr,Gn="['’]",pn="["+$e+"]",Ki="["+Ii+"]",dr="["+Ji+"]",zs="\\d+",Tn="["+hn+"]",oa="["+ki+"]",Jn="[^"+$e+Ii+zs+hn+ki+mi+"]",Ra="\\ud83c[\\udffb-\\udfff]",Gs="(?:"+dr+"|"+Ra+")",lo="[^"+$e+"]",ba="(?:\\ud83c[\\udde6-\\uddff]){2}",ho="[\\ud800-\\udbff][\\udc00-\\udfff]",gi="["+mi+"]",La="\\u200d",Bu="(?:"+oa+"|"+Jn+")",oc="(?:"+gi+"|"+Jn+")",rr="(?:"+Gn+"(?:d|ll|m|re|s|t|ve))?",Vs="(?:"+Gn+"(?:D|LL|M|RE|S|T|VE))?",Hs=Gs+"?",Ws="["+un+"]?",bl="(?:"+La+"(?:"+[lo,ba,ho].join("|")+")"+Ws+Hs+")*",Ni="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pn="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Br=Ws+Hs+bl,uo="(?:"+[Tn,ba,ho].join("|")+")"+Br,Wo="(?:"+[lo+dr+"?",dr,ba,ho,pn].join("|")+")",Eh=RegExp(Gn,"g"),nn=RegExp(dr,"g"),Xo=RegExp(Ra+"(?="+Ra+")|"+Wo+Br,"g"),Ss=RegExp([gi+"?"+oa+"+"+rr+"(?="+[Ki,gi,"$"].join("|")+")",oc+"+"+Vs+"(?="+[Ki,gi+Bu,"$"].join("|")+")",gi+"?"+Bu+"+"+rr,gi+"+"+Vs,Pn,Ni,zs,uo].join("|"),"g"),Yo=RegExp("["+La+$e+Ji+un+"]"),Uu=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fo=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xr=-1,ji={};ji[Ae]=ji[qt]=ji[Ge]=ji[Oe]=ji[Be]=ji[Le]=ji[ie]=ji[Ke]=ji[ri]=!0,ji[U]=ji[H]=ji[ge]=ji[_]=ji[xe]=ji[q]=ji[ot]=ji[rt]=ji[yt]=ji[Et]=ji[Pt]=ji[ut]=ji[Rt]=ji[Dt]=ji[ne]=!1;var Zi={};Zi[U]=Zi[H]=Zi[ge]=Zi[xe]=Zi[_]=Zi[q]=Zi[Ae]=Zi[qt]=Zi[Ge]=Zi[Oe]=Zi[Be]=Zi[yt]=Zi[Et]=Zi[Pt]=Zi[ut]=Zi[Rt]=Zi[Dt]=Zi[Ht]=Zi[Le]=Zi[ie]=Zi[Ke]=Zi[ri]=!0,Zi[ot]=Zi[rt]=Zi[ne]=!1;var Ts={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Ur={"&":"&","<":"<",">":">",'"':""","'":"'"},Ll={"&":"&","<":"<",">":">",""":'"',"'":"'"},Mh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ko=parseFloat,Fl=parseInt,zr=typeof global=="object"&&global&&global.Object===Object&&global,lc=typeof self=="object"&&self&&self.Object===Object&&self,gn=zr||lc||Function("return this")(),Ch=typeof g=="object"&&g&&!g.nodeType&&g,Rn=Ch&&typeof t=="object"&&t&&!t.nodeType&&t,Fa=Rn&&Rn.exports===Ch,Oa=Fa&&zr.process,En=function(){try{var ct=Rn&&Rn.require&&Rn.require("util").types;return ct||Oa&&Oa.binding&&Oa.binding("util")}catch{}}(),Da=En&&En.isArrayBuffer,Ia=En&&En.isDate,Ol=En&&En.isMap,Dl=En&&En.isRegExp,Na=En&&En.isSet,Xs=En&&En.isTypedArray;function $i(ct,St,vt){switch(vt.length){case 0:return ct.call(St);case 1:return ct.call(St,vt[0]);case 2:return ct.call(St,vt[0],vt[1]);case 3:return ct.call(St,vt[0],vt[1],vt[2])}return ct.apply(St,vt)}function Wr(ct,St,vt,Ft){for(var Lt=-1,Ut=ct==null?0:ct.length;++Lt-1}function la(ct,St,vt){for(var Ft=-1,Lt=ct==null?0:ct.length;++Ft-1;);return vt}function po(ct,St){for(var vt=ct.length;vt--&&ts(St,ct[vt],0)>-1;);return vt}function is(ct,St){for(var vt=ct.length,Ft=0;vt--;)ct[vt]===St&&++Ft;return Ft}var zu=ar(Ts),Jo=ar(Ur);function ns(ct){return"\\"+Mh[ct]}function cn(ct,St){return ct==null?i:ct[St]}function Cs(ct){return Yo.test(ct)}function lr(ct){return Uu.test(ct)}function vo(ct){for(var St,vt=[];!(St=ct.next()).done;)vt.push(St.value);return vt}function Ga(ct){var St=-1,vt=Array(ct.size);return ct.forEach(function(Ft,Lt){vt[++St]=[Lt,Ft]}),vt}function Va(ct,St){return function(vt){return ct(St(vt))}}function Qn(ct,St){for(var vt=-1,Ft=ct.length,Lt=0,Ut=[];++vt-1}function Vu(R,N){var k=this.__data__,nt=To(k,R);return nt<0?(++this.size,k.push([R,N])):k[nt][1]=N,this}ks.prototype.clear=Tp,ks.prototype.delete=dc,ks.prototype.get=Ep,ks.prototype.has=Mp,ks.prototype.set=Vu;function ws(R){var N=-1,k=R==null?0:R.length;for(this.clear();++N=N?R:N)),R}function ss(R,N,k,nt,ft,xt){var Ot,Gt=N&h,kt=N&a,fe=N&l;if(k&&(Ot=ft?k(R,nt,ft,xt):k(R)),Ot!==i)return Ot;if(!Dn(R))return R;var ce=Si(R);if(ce){if(Ot=qA(R),!Gt)return Rr(R,Ot)}else{var ye=Yr(R),Ie=ye==rt||ye==gt;if($l(R))return Dc(R,Gt);if(ye==Pt||ye==U||Ie&&!ft){if(Ot=kt||Ie?{}:Z1(R),!Gt)return kt?Gp(R,bp(Ot,R)):Gg(R,xc(Ot,R))}else{if(!Zi[ye])return ft?R:{};Ot=tP(R,ye,Gt)}}xt||(xt=new qn);var je=xt.get(R);if(je)return je;xt.set(R,Ot),MS(R)?R.forEach(function(hi){Ot.add(ss(hi,N,k,hi,R,xt))}):TS(R)&&R.forEach(function(hi,Bi){Ot.set(Bi,ss(hi,N,k,Bi,R,xt))});var li=fe?kt?Ui:Yn:kt?Ls:Lr,Fi=ce?i:li(R);return yn(Fi||R,function(hi,Bi){Fi&&(Bi=hi,hi=R[Bi]),Ks(Ot,Bi,ss(hi,N,k,Bi,R,xt))}),Ot}function Sc(R){var N=Lr(R);return function(k){return Yu(k,R,N)}}function Yu(R,N,k){var nt=k.length;if(R==null)return!nt;for(R=It(R);nt--;){var ft=k[nt],xt=N[ft],Ot=R[ft];if(Ot===i&&!(ft in R)||!xt(Ot))return!1}return!0}function Tc(R,N,k){if(typeof R!="function")throw new $t(s);return Uc(function(){R.apply(i,k)},N)}function tl(R,N,k,nt){var ft=-1,xt=Sr,Ot=!0,Gt=R.length,kt=[],fe=N.length;if(!Gt)return kt;k&&(N=Qi(N,or(k))),nt?(xt=la,Ot=!1):N.length>=T&&(xt=Hn,Ot=!1,N=new So(N));t:for(;++ftft?0:ft+k),nt=nt===i||nt>ft?ft:Ri(nt),nt<0&&(nt+=ft),nt=k>nt?0:wS(nt);k0&&k(Gt)?N>1?hr(Gt,N-1,k,nt,ft):Xr(ft,Gt):nt||(ft[ft.length]=Gt)}return ft}var Hl=nf(),Bh=nf(!0);function as(R,N){return R&&Hl(R,N,Lr)}function Wl(R,N){return R&&Bh(R,N,Lr)}function el(R,N){return Mn(N,function(k){return al(R[k])})}function Zs(R,N){N=Po(N,R);for(var k=0,nt=N.length;R!=null&&kN}function Op(R,N){return R!=null&&me.call(R,N)}function Mc(R,N){return R!=null&&N in It(R)}function Ug(R,N,k){return R>=Er(N,k)&&R<_n(N,k)}function Xl(R,N,k){for(var nt=k?la:Sr,ft=R[0].length,xt=R.length,Ot=xt,Gt=vt(xt),kt=1/0,fe=[];Ot--;){var ce=R[Ot];Ot&&N&&(ce=Qi(ce,or(N))),kt=Er(ce.length,kt),Gt[Ot]=!k&&(N||ft>=120&&ce.length>=120)?new So(Ot&&ce):i}ce=R[0];var ye=-1,Ie=Gt[0];t:for(;++ye-1;)Gt!==R&&yo.call(Gt,kt,1),yo.call(R,kt,1);return R}function wr(R,N){for(var k=R?N.length:0,nt=k-1;k--;){var ft=N[k];if(k==nt||ft!==xt){var xt=ft;sl(ft)?yo.call(R,ft,1):Lc(R,ft)}}return R}function va(R,N){return R+bh(fc()*(N-R+1))}function As(R,N,k,nt){for(var ft=-1,xt=_n(Rh((N-R)/(k||1)),0),Ot=vt(xt);xt--;)Ot[nt?xt:++ft]=R,R+=k;return Ot}function Jl(R,N){var k="";if(!R||N<1||N>z)return k;do N%2&&(k+=R),N=bh(N/2),N&&(R+=R);while(N);return k}function ei(R,N){return Kg(Q1(R,N,Fs),R+"")}function Dp(R){return Ih(of(R))}function Pc(R,N){var k=of(R);return Wp(k,Eo(N,0,k.length))}function nl(R,N,k,nt){if(!Dn(R))return R;N=Po(N,R);for(var ft=-1,xt=N.length,Ot=xt-1,Gt=R;Gt!=null&&++ftft?0:ft+N),k=k>ft?ft:k,k<0&&(k+=ft),ft=N>k?0:k-N>>>0,N>>>=0;for(var xt=vt(ft);++nt>>1,Ot=R[xt];Ot!==null&&!$s(Ot)&&(k?Ot<=N:Ot=T){var fe=N?null:br(R);if(fe)return Ha(fe);Ot=!1,ft=Hn,kt=new So}else kt=N?[]:Gt;t:for(;++nt=nt?R:ls(R,N,k)}var Up=Ph||function(R){return gn.clearTimeout(R)};function Dc(R,N){if(N)return R.slice();var k=R.length,nt=mo?mo(k):new R.constructor(k);return R.copy(nt),nt}function tf(R){var N=new R.constructor(R.byteLength);return new Cn(N).set(new Cn(R)),N}function zg(R,N){var k=N?tf(R.buffer):R.buffer;return new R.constructor(k,R.byteOffset,R.byteLength)}function Ps(R){var N=new R.constructor(R.source,Rl.exec(R));return N.lastIndex=R.lastIndex,N}function Ic(R){return Xa?It(Xa.call(R)):{}}function zp(R,N){var k=N?tf(R.buffer):R.buffer;return new R.constructor(k,R.byteOffset,R.length)}function Ka(R,N){if(R!==N){var k=R!==i,nt=R===null,ft=R===R,xt=$s(R),Ot=N!==i,Gt=N===null,kt=N===N,fe=$s(N);if(!Gt&&!fe&&!xt&&R>N||xt&&Ot&&kt&&!Gt&&!fe||nt&&Ot&&kt||!k&&kt||!ft)return 1;if(!nt&&!xt&&!fe&&R=Gt)return kt;var fe=k[nt];return kt*(fe=="desc"?-1:1)}}return R.index-N.index}function bo(R,N,k,nt){for(var ft=-1,xt=R.length,Ot=k.length,Gt=-1,kt=N.length,fe=_n(xt-Ot,0),ce=vt(kt+fe),ye=!nt;++Gt1?k[ft-1]:i,Ot=ft>2?k[2]:i;for(xt=R.length>3&&typeof xt=="function"?(ft--,xt):i,Ot&&us(k[0],k[1],Ot)&&(xt=ft<3?i:xt,ft=1),N=It(N);++nt-1?ft[xt?N[Ot]:Ot]:i}}function it(R){return Ci(function(N){var k=N.length,nt=k,ft=Mr.prototype.thru;for(R&&N.reverse();nt--;){var xt=N[nt];if(typeof xt!="function")throw new $t(s);if(ft&&!Ot&&rf(xt)=="wrapper")var Ot=new Mr([],!0)}for(nt=Ot?nt:k;++nt1&&Vi.reverse(),ce&&ktGt))return!1;var fe=xt.get(R),ce=xt.get(N);if(fe&&ce)return fe==N&&ce==R;var ye=-1,Ie=!0,je=k&u?new So:i;for(xt.set(R,N),xt.set(N,R);++ye1?"& ":"")+N[nt],N=N.join(k>2?", ":" "),R.replace(Bs,`{ + `):"",this.name="UnsubscriptionError",this.errors=t}});function Ty(g,t){if(g){var i=g.indexOf(t);0<=i&&g.splice(i,1)}}var $m=function(){function g(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return g.prototype.unsubscribe=function(){var t,i,x,T,E;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var y=Kf(s),e=y.next();!e.done;e=y.next()){var r=e.value;r.remove(this)}}catch(u){t={error:u}}finally{try{e&&!e.done&&(i=y.return)&&i.call(y)}finally{if(t)throw t.error}}else s.remove(this);var p=this.initialTeardown;if(mr(p))try{p()}catch(u){E=u instanceof f0?u.errors:[u]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var a=Kf(h),l=a.next();!l.done;l=a.next()){var n=l.value;try{QS(n)}catch(u){E=E??[],u instanceof f0?E=md(md([],vd(E)),vd(u.errors)):E.push(u)}}}catch(u){x={error:u}}finally{try{l&&!l.done&&(T=a.return)&&T.call(a)}finally{if(x)throw x.error}}}if(E)throw new f0(E)}},g.prototype.add=function(t){var i;if(t&&t!==this)if(this.closed)QS(t);else{if(t instanceof g){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(i=this._finalizers)!==null&&i!==void 0?i:[]).push(t)}},g.prototype._hasParent=function(t){var i=this._parentage;return i===t||Array.isArray(i)&&i.includes(t)},g.prototype._addParent=function(t){var i=this._parentage;this._parentage=Array.isArray(i)?(i.push(t),i):i?[i,t]:t},g.prototype._removeParent=function(t){var i=this._parentage;i===t?this._parentage=null:Array.isArray(i)&&Ty(i,t)},g.prototype.remove=function(t){var i=this._finalizers;i&&Ty(i,t),t instanceof g&&t._removeParent(this)},g.EMPTY=function(){var t=new g;return t.closed=!0,t}(),g}(),_M=$m.EMPTY;function qM(g){return g instanceof $m||g&&"closed"in g&&mr(g.remove)&&mr(g.add)&&mr(g.unsubscribe)}function QS(g){mr(g)?g():g.unsubscribe()}var tC={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},AO={setTimeout:function(g,t){for(var i=[],x=2;x0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(i){return this._throwIfClosed(),g.prototype._trySubscribe.call(this,i)},t.prototype._subscribe=function(i){return this._throwIfClosed(),this._checkFinalizedStatuses(i),this._innerSubscribe(i)},t.prototype._innerSubscribe=function(i){var x=this,T=this,E=T.hasError,s=T.isStopped,y=T.observers;return E||s?_M:(this.currentObservers=null,y.push(i),new $m(function(){x.currentObservers=null,Ty(y,i)}))},t.prototype._checkFinalizedStatuses=function(i){var x=this,T=x.hasError,E=x.thrownError,s=x.isStopped;T?i.error(E):s&&i.complete()},t.prototype.asObservable=function(){var i=new wa;return i.source=this,i},t.create=function(i,x){return new qS(i,x)},t}(wa),qS=function(g){Yd(t,g);function t(i,x){var T=g.call(this)||this;return T.destination=i,T.source=x,T}return t.prototype.next=function(i){var x,T;(T=(x=this.destination)===null||x===void 0?void 0:x.next)===null||T===void 0||T.call(x,i)},t.prototype.error=function(i){var x,T;(T=(x=this.destination)===null||x===void 0?void 0:x.error)===null||T===void 0||T.call(x,i)},t.prototype.complete=function(){var i,x;(x=(i=this.destination)===null||i===void 0?void 0:i.complete)===null||x===void 0||x.call(i)},t.prototype._subscribe=function(i){var x,T;return(T=(x=this.source)===null||x===void 0?void 0:x.subscribe(i))!==null&&T!==void 0?T:_M},t}(In),rC=new wa(function(g){return g.complete()});function UO(g){return g&&mr(g.schedule)}function sC(g){return g[g.length-1]}function aC(g){return UO(sC(g))?g.pop():void 0}function oC(g,t){return typeof sC(g)=="number"?g.pop():t}var lC=function(g){return g&&typeof g.length=="number"&&typeof g!="function"};function hC(g){return mr(g?.then)}function uC(g){return mr(g[Kx])}function fC(g){return Symbol.asyncIterator&&mr(g?.[Symbol.asyncIterator])}function cC(g){return new TypeError("You provided "+(g!==null&&typeof g=="object"?"an invalid object":"'"+g+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function zO(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var dC=zO();function pC(g){return mr(g?.[dC])}function vC(g){return CO(this,arguments,function(){var t,i,x,T;return $M(this,function(E){switch(E.label){case 0:t=g.getReader(),E.label=1;case 1:E.trys.push([1,,9,10]),E.label=2;case 2:return[4,Wf(t.read())];case 3:return i=E.sent(),x=i.value,T=i.done,T?[4,Wf(void 0)]:[3,5];case 4:return[2,E.sent()];case 5:return[4,Wf(x)];case 6:return[4,E.sent()];case 7:return E.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function mC(g){return mr(g?.getReader)}function Lu(g){if(g instanceof wa)return g;if(g!=null){if(uC(g))return GO(g);if(lC(g))return VO(g);if(hC(g))return HO(g);if(fC(g))return gC(g);if(pC(g))return WO(g);if(mC(g))return XO(g)}throw cC(g)}function GO(g){return new wa(function(t){var i=g[Kx]();if(mr(i.subscribe))return i.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function VO(g){return new wa(function(t){for(var i=0;i{let T=this.tilePosInDirection(new Qt(i,x),g);return this.tilemap.hasBlockingTile(T,t,TO(g),this.ignoreMissingTiles)})}isCharBlocking(g,t){return this.someCharTile((i,x)=>{let T=this.tilePosInDirection(new Qt(i,x),g);return this.tilemap.hasBlockingChar(T,t,this.getCollisionGroups(),new Set([this.getId()]),this.ignoreCollisionGroups)})}isMoving(){return this.movementDirection!="none"}turnTowards(g){this.isMoving()||g!="none"&&this.changeFacingDirection(g)}changeFacingDirection(g){this.facingDirection!==g&&(this.facingDirection=g,this.directionChanged$.next(g))}getFacingDirection(){return this.facingDirection}getFacingPosition(){return this._tilePos.position.add(Cu(this.facingDirection))}addCollisionGroup(g){this.collisionGroups.add(g)}setCollisionGroups(g){this.collisionGroups=new Set(g)}setIgnoreCollisionGroups(g){this.ignoreCollisionGroups=new Set(g)}getCollisionGroups(){return Array.from(this.collisionGroups)}getIgnoreCollisionGroups(){return Array.from(this.ignoreCollisionGroups)}hasCollisionGroup(g){return this.collisionGroups.has(g)}removeCollisionGroup(g){this.collisionGroups.delete(g)}removeAllCollisionGroups(){this.collisionGroups.clear()}addLabels(g){for(let t of g)this.labels.add(t)}getLabels(){return[...this.labels.values()]}hasLabel(g){return this.labels.has(g)}clearLabels(){this.labels.clear()}removeLabels(g){for(let t of g)this.labels.delete(t)}getNumberOfDirections(){return this.numberOfDirections}movementStarted(){return this.movementStarted$}movementStopped(){return this.movementStopped$}directionChanged(){return this.directionChanged$}tilePositionSet(){return this.tilePositionSet$}positionChangeStarted(){return this.positionChangeStarted$}positionChangeFinished(){return this.positionChangeFinished$}autoMovementSet(){return this.autoMovementSet$}depthChanged(){return this.depthChanged$}getMovementProgress(){return this.movementProgress}setMovementProgress(g){let t=Math.max(0,Math.min(au,g));this.movementProgress=t}hasWalkedHalfATile(){return this.movementProgress>au/2}willCrossTileBorderThisUpdate(g){return this.movementProgress+this.maxProgressForDelta(g)>=au}updateCharacterPosition(g){let t=this.willCrossTileBorderThisUpdate(g),i=1-(t?au-this.movementProgress:this.maxProgressForDelta(g))/this.maxProgressForDelta(g);this.movementProgress=Math.min(this.movementProgress+this.maxProgressForDelta(g),au),t&&(this.movementProgress=0,this.shouldContinueMoving()?(this.fire(this.positionChangeFinished$,this.tilePos,this.getNextTilePos()),this.tilePos=this.getNextTilePos(),this.startMoving(this.lastMovementImpulse),i>0&&this.updateCharacterPosition(g*i)):this.stopMoving())}maxProgressForDelta(g){let t=g/1e3;return Math.floor(t*this.speed*au)}get tilePos(){return Ai.clone(this._tilePos)}set tilePos(g){Ai.copyOver(g,this._tilePos)}startMoving(g){g!=="none"&&(g!=this.movementDirection&&this.movementStarted$.next(g),this.movementDirection=g,this.facingDirection=g,this.fire(this.positionChangeStarted$,this.tilePos,this.getNextTilePos()))}tilePosInDirection(g,t){return g.add(Cu(this.tilemap.toMapDirection(t)))}shouldContinueMoving(){return this.lastMovementImpulse!=="none"&&!this.isBlockingDirection(this.lastMovementImpulse)}stopMoving(){if(this.movementDirection==="none")return;let g=this.tilePos,t=this.getNextTilePos(),i=this.movementDirection;this.tilePos=this.getNextTilePos(),this.movementDirection="none",this.movementStopped$.next(i),this.fire(this.positionChangeFinished$,g,t)}fire(g,{position:t,layer:i},{position:x,layer:T}){g.next({exitTile:t,enterTile:x,exitLayer:i,enterLayer:T})}someCharTile(g){let t=this.getNextTilePos().position;for(let i=t.x;ithis.isLayerAlwaysOnTop(T));this.tilemap.layers.filter(T=>!this.isLayerAlwaysOnTop(T)).forEach(T=>{this.hasLayerProp(T,ou.HEIGHT_SHIFT_PROP_NAME)?(this.createHeightShiftLayers(T,i),t.push(T.tilemapLayer)):this.setDepth(T,++i)}),this.charLayerDepths.set(void 0,i),x.forEach((T,E)=>{T.tilemapLayer.setDepth(E+1+i)}),t.forEach(T=>T.destroy())}setDepth(t,i){t.tilemapLayer.setDepth(i),this.isCharLayer(t)&&this.charLayerDepths.set(this.getLayerProp(t,ou.CHAR_LAYER_PROP_NAME),i)}createHeightShiftLayers(t,i){let x=this.getLayerProp(t,ou.HEIGHT_SHIFT_PROP_NAME);isNaN(x)&&(x=0);let T=1;for(let E=0;ET.name==i);return x?.value}hasLayerProp(t,i){return this.getLayerProp(t,i)!=null}copyLayer(t,i){let x=`${t.name}#${i}`,T=this.tilemap.createBlankLayer(x,t.tilemapLayer.tileset);if(T){if(T.name=x,this.isIsometric())for(let E=i;E>=0;E--){let s=i-E;T.putTileAt(t.data[E][s],s,E)}else for(let E=0;Ey===this.charData.id)).subscribe(({direction:y})=>{var e;(e=this.animation)==null||e.setStandingFrame(y)}),this.sprite&&(this.sprite.setOrigin(0,0),this.resetAnimation(this.sprite),this.updateOverlaySprite(),this.updateGridChar())}destroy(){this.destroy$.next(),this.destroy$.complete(),this.newSpriteSet$.complete()}setSprite(g){g?(this.sprite&&(g.x=this.sprite.x,g.y=this.sprite.y),this.sprite=g,this.newSpriteSet$.next(),this.layerOverlaySprite=this.layerOverlaySprite?this.scene.add.sprite(0,0,this.sprite.texture):void 0,this.updateOverlaySprite(),this.resetAnimation(this.sprite),this.updateDepth()):(this.layerOverlaySprite=void 0,this.sprite=void 0)}getSprite(){return this.sprite}getLayerOverlaySprite(){return this.layerOverlaySprite}setContainer(g){var t;this.container=g,this.cachedContainerHeight=(t=g?.getBounds().height)!=null?t:0}getContainer(){return this.container}getOffsetX(){return this.customOffset.x}setOffsetX(g){this.customOffset.x=g}getOffsetY(){return this.customOffset.y}setOffsetY(g){this.customOffset.y=g}getWalkingAnimationMapping(){return this.walkingAnimationMapping}turnTowards(g){var t;this.geHeadless.isMoving(this.charData.id)||g!="none"&&(this.geHeadless.turnTowards(this.charData.id,g),(t=this.animation)==null||t.setStandingFrame(g))}getAnimation(){return this.animation}setAnimation(g){this.animation=g}update(g){this.updateGridChar()}getEngineOffset(){var g,t,i,x;if(!this.sprite)return Qt.ZERO;let T=this.tilemap.getTileWidth()/2-Math.floor(((t=(g=this.sprite)==null?void 0:g.displayWidth)!=null?t:0)/2),E=-((x=(i=this.sprite)==null?void 0:i.displayHeight)!=null?x:0)+this.tilemap.getTileHeight();return new Qt(T,E)}updatePixelPos(){let g=new Qt(this.geHeadless.getPosition(this.charData.id)),t=this.geHeadless.getMovementProgress(this.charData.id)/1e3,i=this.tilemap.tilePosToPixelPos(g).add(this.getEngineOffset()).add(this.customOffset).add(Cu(this.geHeadless.getFacingDirection(this.charData.id)).multiply(this.tilemap.getTileDistance(this.geHeadless.getFacingDirection(this.charData.id)).scalarMult(t))),x=this.getGameObj();x&&(x.x=Math.floor(i.x),x.y=Math.floor(i.y))}getGameObj(){return this.container||this.sprite}updateGridChar(){var g;if(this.updatePixelPos(),this.sprite&&this.geHeadless.isMoving(this.charData.id)){let t=this.geHeadless.getMovementProgress(this.charData.id)>au/2;(g=this.getAnimation())==null||g.updateCharacterFrame(this.geHeadless.getFacingDirection(this.charData.id),t,Number(this.sprite.frame.name))}this.updateDepth()}resetAnimation(g){let t=new tT(this.walkingAnimationMapping,g.texture.source[0].width/g.width/tT.FRAMES_CHAR_ROW);this.setAnimation(t),t.frameChange().pipe(Ta(this.newSpriteSet$)).subscribe(i=>{g?.setFrame(i)}),t.setIsEnabled(this.walkingAnimationMapping!==void 0),t.setStandingFrame(this.geHeadless.getFacingDirection(this.charData.id))}updateOverlaySprite(){if(!this.layerOverlaySprite||!this.sprite)return;this.layerOverlaySprite.scale=this.sprite.scale;let g=this.tilemap.getTileHeight()/this.layerOverlaySprite.scale;this.layerOverlaySprite.setCrop(0,0,this.layerOverlaySprite.displayWidth,this.sprite.height-g),this.layerOverlaySprite.setOrigin(0,0)}updateDepth(){if(!this.getGameObj())return;let g=new Qt(this.geHeadless.getPosition(this.charData.id)),t=this.geHeadless.getCharLayer(this.charData.id);this.container?this.setContainerDepth(this.container,{position:g,layer:t}):this.sprite&&this.setSpriteDepth(this.sprite,{position:g,layer:t});let i=this.getLayerOverlaySprite();if(i){let x=new Qt(dh(An({},g),{y:g.y-1}));this.setSpriteDepth(i,{position:x,layer:t})}}setSpriteDepth(g,t){g.setDepth(this.tilemap.getDepthOfCharLayer(this.getTransitionLayer(t))+this.getPaddedPixelDepthSprite(g))}setContainerDepth(g,t){g.setDepth(this.tilemap.getDepthOfCharLayer(this.getTransitionLayer(t))+this.getPaddedPixelDepthContainer(g))}getPaddedPixelDepthContainer(g){return wy.shiftPad(g.y+this.cachedContainerHeight,Py.Z_INDEX_PADDING)}getPaddedPixelDepthSprite(g){return wy.shiftPad(g.y+g.displayHeight,Py.Z_INDEX_PADDING)}getTransitionLayer(g){if(g.layer)return this.geHeadless.getTransition(g.position,g.layer)||g.layer}},s4=(g=>(g.DONT_BLOCK="DONT_BLOCK",g.BLOCK_TWO_TILES="BLOCK_TWO_TILES",g.BLOCK_ONE_TILE_AHEAD="BLOCK_ONE_TILE_AHEAD",g.BLOCK_ONE_TILE_BEHIND="BLOCK_ONE_TILE_BEHIND",g))(s4||{}),CC=(g=>(g.STOP="STOP",g.CLOSEST_REACHABLE="CLOSEST_REACHABLE",g.RETRY="RETRY",g.ALTERNATIVE_TARGETS="ALTERNATIVE_TARGETS",g))(CC||{}),a4=class{distance(g,t){return eo.manhattanDistance(g,t)}direction(g,t){if(eo.equal(g,t))return"none";let i=g.clone().subtract(t);return Math.abs(i.x)>Math.abs(i.y)?i.x>0?"left":"right":i.y>0?"up":"down"}neighbors(g){return[new Qt(g.x,g.y+1),new Qt(g.x+1,g.y),new Qt(g.x-1,g.y),new Qt(g.x,g.y-1)]}getDirections(){return["up","right","down","left"]}},o4=class{distance(g,t){return eo.chebyshevDistance(g,t)}neighbors(g){let t=[new Qt(g.x,g.y+1),new Qt(g.x+1,g.y),new Qt(g.x-1,g.y),new Qt(g.x,g.y-1)],i=[new Qt(g.x+1,g.y+1),new Qt(g.x+1,g.y-1),new Qt(g.x-1,g.y+1),new Qt(g.x-1,g.y-1)];return[...t,...i]}direction(g,t){return t.x>g.x?t.y>g.y?"down-right":t.yg.y?"down-left":t.yg.y?"down":"none"}getDirections(){return["up","right","down","left","down-left","down-right","up-right","up-left"]}},gd=class{static create(g){switch(g){case 4:return new a4;case 8:return new o4}}},eT=class{constructor(g,t,i){this.backoffMs=g,this.maxRetries=t,this.onFinished=i,this.retries=0,this.elapsed=0}retry(g,t){this.shouldRetry()?(this.elapsed+=g,this.elapsed>=this.backoffMs&&(this.elapsed=0,this.retries++,t())):this.onFinished()}reset(){this.retries=0,this.elapsed=0}getMaxRetries(){return this.maxRetries}getBackoffMs(){return this.backoffMs}shouldRetry(){return this.maxRetries===-1||this.retries(g.WAIT="WAIT",g.RETRY="RETRY",g.STOP="STOP",g))(wC||{}),Qm=class{constructor(g,{shortestPathAlgorithm:t="BFS",pathWidth:i=1,pathHeight:x=1,numberOfDirections:T=4,isPositionAllowed:E=(u,f)=>!0,collisionGroups:s=[],ignoredChars:y=[],ignoreTiles:e=!1,ignoreMapBounds:r=!1,ignoreBlockedTarget:p=!1,maxPathLength:h=1/0,ignoreLayers:a=!1,considerCosts:l=!1,calculateClosestToTarget:n=!0}={}){this.gridTilemap=g,this.options={shortestPathAlgorithm:t,pathWidth:i,pathHeight:x,numberOfDirections:T,isPositionAllowed:E,collisionGroups:s,ignoredChars:y,ignoreTiles:e,ignoreMapBounds:r,ignoreBlockedTarget:p,maxPathLength:h,ignoreLayers:a,considerCosts:l,calculateClosestToTarget:n},this.ignoredCharsSet=new Set(y)}findShortestPath(g,t){this.options.ignoreLayers&&(this.gridTilemap.fixCacheLayer(g.layer),t.layer=g.layer);let i=this.findShortestPathImpl(g,t);return this.gridTilemap.unfixCacheLayers(),i}getNeighbors(g,t){var i;return gd.create((i=this.options.numberOfDirections)!=null?i:4).neighbors(g.position).map(x=>{let T=g.layer;return this.options.ignoreLayers||(T=this.gridTilemap.getTransition(x,g.layer)),{position:x,layer:T||g.layer}}).filter(x=>!this.isBlocking(g,x)||this.options.ignoreBlockedTarget&&Ai.equal(x,t))}getTransition(g,t){if(!this.options.ignoreLayers)return this.gridTilemap.getTransition(g,t)}getCosts(g,t){if(!this.options.considerCosts)return 1;let i=Ma(t.position,g);return this.gridTilemap.getTileCosts(t,i)}isBlocking(g,t){return!(this.options.ignoreMapBounds||this.gridTilemap.isInRange(t.position))||!this.options.isPositionAllowed(t.position,t.layer)||!this.options.ignoreTiles&&this.hasBlockingTileFrom(g,t,this.options.pathWidth,this.options.pathHeight,this.options.ignoreMapBounds,this.gridTilemap)?!0:this.hasBlockingCharFrom(g,t,this.options.pathWidth,this.options.pathHeight,this.options.collisionGroups,this.ignoredCharsSet,this.gridTilemap)}distance(g,t){return(this.options.numberOfDirections===4?eo.manhattanDistance:eo.chebyshevDistance)(g,t)}getTilePosInDir(g,t){return this.options.ignoreLayers?{position:g.position.add(Cu(this.gridTilemap.toMapDirection(t))),layer:g.layer}:this.gridTilemap.getTilePosInDirection(g,t)}getReverseNeighbors(g,t){var i;let x=gd.create((i=this.options.numberOfDirections)!=null?i:4).neighbors(g.position),T;if(!this.options.ignoreLayers){let E=this.gridTilemap.getReverseTransitions(g.position,g.layer);T=E?[...E]:void 0}return x.map(E=>T?T.map(s=>({position:E,layer:s||g.layer})):[{position:E,layer:g.layer}]).flat().filter(E=>!this.isBlocking(E,g)||this.options.ignoreBlockedTarget&&Ai.equal(g,t))}hasBlockingCharFrom(g,t,i,x,T,E,s){if(i===1&&x===1)return s.hasBlockingChar(t.position,t.layer,T,E);let y=r=>s.hasBlockingChar(r,t.layer,T,E),e=Ma(g.position,t.position);return this.isBlockingMultiTile(g,e,i,x,y)}hasBlockingTileFrom(g,t,i,x,T,E){if(i===1&&x===1)return E.hasBlockingTile(t.position,t.layer,Ma(t.position,g.position),T);let s=Ma(g.position,t.position),y=e=>E.hasBlockingTile(e,t.layer,s,T);return this.isBlockingMultiTile(g,s,i,x,y)}isBlockingMultiTile(g,t,i,x,T){let E={src:new Qt(g.position.x+i,g.position.y),dest:new Qt(g.position.x+i,g.position.y+x-1)},s={src:new Qt(g.position.x-1,g.position.y),dest:new Qt(g.position.x-1,g.position.y+x-1)},y={src:new Qt(g.position.x,g.position.y-1),dest:new Qt(g.position.x+i-1,g.position.y-1)},e={src:new Qt(g.position.x,g.position.y+x),dest:new Qt(g.position.x+i-1,g.position.y+x)};switch(t){case"right":return this.checkLine(E,T);case"left":return this.checkLine(s,T);case"up":return this.checkLine(y,T);case"down":return this.checkLine(e,T);case"up-left":return this.checkLine({src:y.src,dest:new Qt(y.dest.x-1,y.dest.y)},T)||this.checkLine({src:new Qt(s.src.x,s.src.y-1),dest:new Qt(s.dest.x,s.dest.y-1)},T);case"up-right":return this.checkLine({src:new Qt(y.src.x+1,y.src.y),dest:y.dest},T)||this.checkLine({src:new Qt(E.src.x,E.src.y-1),dest:new Qt(E.dest.x,E.dest.y-1)},T);case"down-left":return this.checkLine({src:new Qt(s.src.x,s.src.y+1),dest:new Qt(s.dest.x,s.dest.y+1)},T)||this.checkLine({src:e.src,dest:new Qt(e.dest.x-1,e.dest.y)},T);case"down-right":return this.checkLine({src:new Qt(e.src.x+1,e.src.y),dest:e.dest},T)||this.checkLine({src:new Qt(E.src.x,E.src.y+1),dest:new Qt(E.dest.x,E.dest.y+1)},T)}return!1}checkLine(g,t){for(let i=g.src.x;i<=g.dest.x;i++)for(let x=g.src.y;x<=g.dest.y;x++)if(t(new Qt(i,x)))return!0;return!1}},l4=GM(Vx(),1),h4=class extends Qm{findShortestPathImpl(g,t){let i=this.shortestPathBfs(g,t);return{path:this.returnPath(i.previous,g,t),closestToTarget:i.closestToTarget,steps:i.steps,maxPathLengthReached:i.maxPathLengthReached,algorithmUsed:"A_STAR"}}shortestPathBfs(g,t){let i=new Map,x=new Map,T=new Map,E=new l4.MinFibonacciHeap((r,p)=>Gc(T,r)-Gc(T,p)),s=g,y=this.distance(g.position,t.position),e=0;for(E.push(g),x.set(Ai.toString(g),0),T.set(Ai.toString(g),this.distance(g.position,t.position));E.size>0;){let r=E.pop();if(!r)break;e++;let p=this.distance(r.position,t.position);if(pthis.options.maxPathLength)return{previous:new Map,closestToTarget:s,steps:e,maxPathLengthReached:!0};for(let h of this.getNeighbors(r,t)){let a=Gc(x,r)+this.getCosts(r.position,h),l=Ai.toString(h);(!x.has(l)||a0;){let e=T.dequeue();if(y++,!e)break;let{node:r,dist:p}=e;if(p>this.options.maxPathLength)return{previous:new Map,closestToTarget:E,steps:y,maxPathLengthReached:!0};let h=this.distance(r.position,t.position);if(hthis.lastDist)}step(g,t,i){var x;this.lastDist=i;for(let T of g){let E=Ai.toString(T);if(!this.visited.has(E)){this.previous.set(E,t),this.queue.enqueue({node:T,dist:i+1}),this.visited.set(E,i+1);let s=(x=this.otherBfs)==null?void 0:x.visited.get(E);s!==void 0&&s0,T.queue.size()>0);){let e=x.queue.dequeue();if(!e)break;let{node:r,dist:p}=e;if(p+1+(((i=T.queue.peek())==null?void 0:i.dist)||0)>this.options.maxPathLength)return{previous:x.previous,previous2:T.previous,closestToTarget:this.maybeClosestToTarget(s),steps:E,maxPathLengthReached:!0};let h=this.distance(r.position,t.position);if(hVc(this.f,T)-Vc(this.f,E)),this.openSet.push(g);let x=Ai.toString(g);for(this.g.set(x,0),this.f.set(x,this.distance(g.position,t.position)),this.maxFrontierSize=Math.max(this.maxFrontierSize,this.openSet.size);this.openSet.size>0;){let T=this.openSet.pop();if(!T)break;if(this.steps++,Ai.equal(T,t))return{previous:i,closestToTarget:t,steps:this.steps,maxPathLengthReached:!1};if(Vc(this.g,T)+1>this.options.maxPathLength)return{previous:new Map,closestToTarget:this.closestToTarget,steps:this.steps,maxPathLengthReached:!0};this.updateClosestToTarget(T,t);for(let E of this.getNeighborsInternal(T,i.get(Ai.toString(T)),t)){let s=Ai.toString(E.p),y=Vc(this.g,T)+E.dist;(!this.g.has(s)||y({p:E,dist:1}));let x=this.prune(t,g).filter(E=>!this.isBlockingIgnoreTarget(g,E,i)).map(E=>{let s=this.getTransition(E.position,g.layer);return{position:E.position,layer:s||g.layer}}),T=[];for(let E of x)if(this.isHorizontal(g.position,E.position))T.push({p:E,dist:1});else{let s=this.jump(g,E,i,1,Ma(g.position,E.position));s&&T.push(s)}return T}isBlockingIgnoreTarget(g,t,i){return this.isBlocking(g,t)&&!(this.options.ignoreBlockedTarget&&Ai.equal(t,i))}jump(g,t,i,x,T){if(!this.isBlockingIgnoreTarget(g,t,i))return Ai.equal(t,i)?{p:t,dist:x}:x>=this.maxJumpSize?{p:t,dist:x}:this.getTransition(t.position,g.layer)!==void 0?{p:t,dist:x}:this.hasForced(g,t)?{p:t,dist:x}:(this.updateClosestToTarget(t,i),this.jump(t,this.getTilePosInDir(t,T),i,x+1,T))}isHorizontal(g,t){return g.y===t.y}getForced(g,t,i,x,T,E){let s=[],y=g;return(this.blockOrTrans(y,i)||this.blockOrTrans(i,x))&&this.addIfNotBlocked(s,t,x),(this.blockOrTrans(y,T)||this.blockOrTrans(T,E))&&this.addIfNotBlocked(s,t,E),s}hasForced(g,t){let{topLeft:i,downLeft:x,top:T,bottom:E}=this.normalizedPositions(g,t);return!!((this.blockOrTrans(g,x)||this.blockOrTrans(x,E))&&!this.blockOrTrans(t,E)||(this.blockOrTrans(g,i)||this.blockOrTrans(i,T))&&!this.blockOrTrans(t,T))}prune(g,t){let{right:i,top:x,bottom:T,downLeft:E,topLeft:s}=this.normalizedPositions(g,t);return this.isHorizontal(g.position,t.position)?[i,x,T]:[i,...this.getForced(g,t,E,T,s,x)]}normalizedPositions(g,t){return g.position.xt.position.x?{topLeft:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},downLeft:{position:new Qt(t.position.x+1,t.position.y-1),layer:t.layer},top:{position:new Qt(t.position.x,t.position.y+1),layer:t.layer},bottom:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},right:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer}}:g.position.y1?this.fillPath(T,E,x):x.push(E),T=E}return x.reverse()}fillPath(g,t,i){let x=g;do{let T=Ma(x.position,t.position);x=this.getTilePosInDir(x,T),i.push(x)}while(!eo.equal(x.position,t.position))}};function Vc(g,t){var i;return(i=g.get(Ai.toString(t)))!=null?i:Number.MAX_VALUE}var f4=class{constructor(g,t,i,x={}){this.character=g,this.gridTilemap=t,this.charToFollow=i;let T={distance:0,noPathFoundStrategy:"STOP",maxPathLength:1/0,shortestPathAlgorithm:"BIDIRECTIONAL_SEARCH",ignoreLayers:!1,considerCosts:x.considerCosts||!1,facingDirection:"none"};this.options=An(An({},T),x),this.options.considerCosts&&this.options.shortestPathAlgorithm!=="A_STAR"&&console.warn(`GridEngine: Pathfinding option 'considerCosts' cannot be used with algorithm '${this.options.shortestPathAlgorithm}'. It can only be used with A* algorithm.`),this.options.shortestPathAlgorithm==="JPS"&&(this.character.getTileWidth()>1||this.character.getTileHeight()>1)&&console.warn("GridEngine: Pathfinding algorithm 'JPS' can only be used for characters with 'tileWidth' and 'tileHeight' of 1"),this.character=g,this.updateTarget(this.charToFollow.getTilePos().position,this.charToFollow.getTilePos().layer),this.charToFollow.positionChangeStarted().pipe(Ta(this.character.autoMovementSet().pipe(ph(E=>E!==this),qf(1)))).subscribe(({enterTile:E,enterLayer:s})=>{this.updateTarget(E,s)})}update(g){var t;(t=this.targetMovement)==null||t.update(g)}getInfo(){return{type:"Follow",config:{charToFollow:this.charToFollow.getId(),distance:this.options.distance,noPathFoundStrategy:this.options.noPathFoundStrategy,maxPathLength:this.options.maxPathLength,ignoreLayers:this.options.ignoreLayers,facingDirection:this.options.facingDirection,shortestPathAlgorithm:this.options.shortestPathAlgorithm}}}getFacingPos(){let g=pm[this.options.facingDirection]+pm[this.charToFollow.getFacingDirection()],t=JM("up",g),i={x:this.charToFollow.getTilePos().position.x,y:this.charToFollow.getTilePos().position.y};return t==="right"?i.x+=this.charToFollow.getTileWidth()-1:t==="down"?i.y+=this.charToFollow.getTileWidth()-1:t==="down-left"?i.y+=this.charToFollow.getTileWidth()-1:t==="down-right"?(i.y+=this.charToFollow.getTileWidth()-1,i.x+=this.charToFollow.getTileWidth()-1):t==="up-right"&&(i.x+=this.charToFollow.getTileWidth()-1),this.gridTilemap.getTilePosInDirection({position:new Qt(i),layer:this.charToFollow.getTilePos().layer},t).position}updateTarget(g,t){let i=this.options.facingDirection!=="none"&&this.options.distance===0;i&&(g=this.getFacingPos()),this.targetMovement=new OC(this.character,this.gridTilemap,{position:new Qt(g),layer:t},{distance:i?0:this.options.distance+1,config:{algorithm:this.options.shortestPathAlgorithm,noPathFoundStrategy:this.options.noPathFoundStrategy,maxPathLength:this.options.maxPathLength,ignoreLayers:this.options.ignoreLayers,considerCosts:this.options.considerCosts,ignoredChars:[this.charToFollow.getId()]}})}},aT=class{static getRandomInt(g){return Math.floor(Math.random()*Math.floor(g))}},c4=class{constructor(g,t=0,i=-1){this.character=g,this.delay=t,this.radius=i,this.stepSize=0,this.delayLeft=this.delay,this.initialRow=g.getNextTilePos().position.y,this.initialCol=g.getNextTilePos().position.x,this.randomizeStepSize(),this.stepsWalked=0,this.currentMovementDirection="none",this.character.positionChangeStarted().pipe(Ta(this.character.autoMovementSet().pipe(ph(x=>x!==this),qf(1)))).subscribe(()=>{this.stepsWalked++}),this.distanceUtils=gd.create(g.getNumberOfDirections())}update(g){if(this.shouldContinueWalkingCurrentDirection())this.character.move(this.currentMovementDirection);else if(this.delayLeft-=g,this.delayLeft<=0){this.delayLeft=this.delay;let t=this.getFreeRandomDirection();this.stepsWalked=0,this.character.move(t),this.currentMovementDirection=t,this.randomizeStepSize()}}getInfo(){return{type:"Random",config:{delay:this.delay,radius:this.radius}}}shouldContinueWalkingCurrentDirection(){return this.stepsWalked!this.character.isBlockingDirection(g)).filter(g=>this.isWithinRadius(g))}isWithinRadius(g){return this.radius==-1?!0:this.getDist(g)<=this.radius}getDist(g){return this.distanceUtils.distance(this.character.getNextTilePos().position.add(Cu(g)),new Qt(this.initialCol,this.initialRow))}getFreeRandomDirection(){let g=this.getFreeDirections();return g.length==0?"none":g[aT.getRandomInt(g.length)]}randomizeStepSize(){this.stepSize=aT.getRandomInt(this.radius)+1}};function d4(g,t){return g.filter(i=>{var x,T,E,s,y,e;return(x=t.labels)!=null&&x.withAllLabels?(T=t.labels)==null?void 0:T.withAllLabels.every(r=>i.hasLabel(r)):(E=t.labels)!=null&&E.withOneOfLabels?(s=t.labels)==null?void 0:s.withOneOfLabels.some(r=>i.hasLabel(r)):(y=t.labels)!=null&&y.withNoneLabels?!((e=t.labels)!=null&&e.withNoneLabels.some(r=>i.hasLabel(r))):!0})}var RC="2.44.6",p4=class{constructor(g,t){this.collistionStrategy=g,this.collisionGroupRelation=t,this.tilePosToCharacters=new v4,this.charRemoved$=new In}isCharBlockingAt(g,t,i,x=new Set,T=new Set){if(i.length===0)return!1;let E=this.tilePosToCharacters.get(g,t);return!!(E&&E.size>0&&[...E].filter(s=>!x.has(s.getId())).filter(s=>!this.doIntersect(s.getCollisionGroups(),T)).some(s=>i.some(y=>s.getCollisionGroups().some(e=>this.collidesWith(y,e)))))}doIntersect(g,t){for(let i of g)if(t.has(i))return!0;return!1}collidesWith(g,t){return this.collisionGroupRelation?(this.collisionGroupRelation.get(g)||new Set).has(t):g===t}getCharactersAt(g,t){return this.tilePosToCharacters.get(g,t)||new Set}addCharacter(g){this.addTilePositions(g.getTilePos(),g),this.addTilePositions(g.getNextTilePos(),g),this.addPositionChangeSub(g),this.addPositionChangeFinishedSub(g),this.addTilePosSetSub(g)}removeCharacter(g){let t=g.getId();this.charRemoved$.next(t),this.deleteTilePositions(g.getTilePos(),g),this.deleteTilePositions(g.getNextTilePos(),g)}add(g,t,i){let x=this.tilePosToCharacters.get(g,t);x||this.tilePosToCharacters.set(g,t,new Set([i])),x?.add(i)}addTilePosSetSub(g){g.tilePositionSet().pipe(Ta(this.charRemoved(g.getId()))).subscribe(t=>{this.deleteTilePositions(g.getNextTilePos(),g),this.addTilePositions(t,g)})}charRemoved(g){var t;return(t=this.charRemoved$)==null?void 0:t.pipe(qf(1),ph(i=>i==g))}addPositionChangeSub(g){g.positionChangeStarted().pipe(Ta(this.charRemoved(g.getId())),this.posChangeToLayerPos()).subscribe(t=>{this.collistionStrategy==="BLOCK_ONE_TILE_AHEAD"&&this.deleteTilePositions(t.exit,g),this.addTilePositions(t.enter,g)})}addPositionChangeFinishedSub(g){g.positionChangeFinished().pipe(Ta(this.charRemoved(g.getId())),this.posChangeToLayerPos()).subscribe(t=>{this.deleteTilePositions(t.exit,g),this.addTilePositions(t.enter,g)})}addTilePositions(g,t){this.forEachCharTile(g,t,(i,x)=>{this.add(new Qt(i,x),g.layer,t)})}deleteTilePositions(g,t){this.forEachCharTile(g,t,(i,x)=>{var T;(T=this.tilePosToCharacters.get(new Qt(i,x),g.layer))==null||T.delete(t)})}forEachCharTile(g,t,i){let x=g.position;for(let T=x.x;T({enter:{position:new Qt(g.enterTile),layer:g.enterLayer},exit:{position:new Qt(g.exitTile),layer:g.exitLayer}})))}posToString(g,t){return`${g.x}#${g.y}#${t}`}},v4=class{constructor(){this.memo=new Map}set(g,t,i){let x=this.memo.get(g.x);x||(x=new Map,this.memo.set(g.x,x));let T=x.get(g.y);T||(T=new Map,x.set(g.y,T)),T.set(t,i)}get(g,t){let i=this.memo.get(g.x);if(!i)return;let x=i.get(g.y);if(x)return x.get(t)}},jx=class{constructor(g,t,i,x){this.x=g,this.y=t,this.width=i,this.height=x}getX(){return this.x}getY(){return this.y}getWidth(){return this.width}getHeight(){return this.height}isInRange(g){return g.x>=this.x&&g.x=this.y&&g.yi.isCharLayer());for(let i of[...t,void 0]){let x=this.tileCollisionCache.get(i?.getName());if(x===void 0){x=new Array(this.tilemap.getWidth());for(let T=0;T>t&1)==1}var lT="ge_cost",bC=class LC{constructor(t,i,x,T=void 0,E=!1){this.tilemap=t,this.collisionTilePropertyName=i,this.useTileCollisionCache=E,this.characters=new Map,this.transitions=new Map,this.reverseTransitions=new Map,this.collidesPropNames=new Map,this.tileCostPropNames=new Map,this.collisionRelevantLayersFrameCache=new Map,this.charBlockCache=new p4(x,T);for(let s of Yx())this.collidesPropNames.set(s,LC.ONE_WAY_COLLIDE_PROP_PREFIX+s),this.tileCostPropNames.set(s,`${lT}_${s}`);this.useTileCollisionCache&&(this.tileCollisionCache=new g4(t,this),this.tileCollisionCache.rebuild())}fixCacheLayer(t){var i;(i=this.tileCollisionCache)==null||i.fixLayer(t)}unfixCacheLayers(){var t;(t=this.tileCollisionCache)==null||t.unfixLayers()}addCharacter(t){this.characters.set(t.getId(),t);let i=t.getNextTilePos().layer;i===void 0?t.setTilePosition(dh(An({},t.getNextTilePos()),{layer:this.getLowestCharLayer()})):this.getCharLayerNames().includes(i)||console.warn(`Char layer '${i}' of character '${t.getId()}' is unknown.`),this.charBlockCache.addCharacter(t)}removeCharacter(t){let i=this.characters.get(t);i&&(this.charBlockCache.removeCharacter(i),this.characters.delete(t))}getCharacters(){return[...this.characters.values()]}getCharactersAt(t,i){return this.charBlockCache.getCharactersAt(t,i)}rebuildTileCollisionCache(t){var i;(i=this.tileCollisionCache)==null||i.rebuild(t)}hasBlockingTileUncached(t,i,x,T){if(!T&&this.hasNoTileUncached(t,i))return!0;let E=this.getCollisionRelevantLayers(i);for(let s of E)if(this.isLayerBlockingAt(s.getName(),t,x))return!0;return!1}hasBlockingTile(t,i,x,T){var E;let s=(E=this.tileCollisionCache)==null?void 0:E.isBlockingFrom(t.x,t.y,i,x,T);return s!==void 0?s:this.hasBlockingTileUncached(t,i,x,T)}getTransition(t,i){let x=this.transitions.get(t.toString());if(x)return x.get(i)}getReverseTransitions(t,i){let x=this.reverseTransitions.get(t.toString());if(x)return x.get(i)}setTransition(t,i,x){var T,E,s,y,e;this.transitions.has(t.toString())||this.transitions.set(t.toString(),new Map),this.reverseTransitions.has(t.toString())||this.reverseTransitions.set(t.toString(),new Map),(T=this.transitions.get(t.toString()))==null||T.set(i,x),(E=this.reverseTransitions.get(t.toString()))!=null&&E.has(x)||(s=this.reverseTransitions.get(t.toString()))==null||s.set(x,new Set),(e=(y=this.reverseTransitions.get(t.toString()))==null?void 0:y.get(x))==null||e.add(i)}getTransitions(){return new Map([...this.transitions].map(([t,i])=>[t,new Map(i)]))}getTileCosts(t,i){let x=this.getCollisionRelevantLayers(t.layer),T=1;for(let E of x)T=Math.max(T,this.getTileCostsForLayer(dh(An({},t),{layer:E.getName()}),i));return T}getTileCostsForLayer(t,i){let x=this.tilemap.getTileAt(t.position.x,t.position.y,t.layer);return i&&x?.getProperty(this.tileCostPropNames.get(i)||"")||x?.getProperty(lT)||1}hasNoTileUncached(t,i){return!this.getCollisionRelevantLayers(i).some(x=>this.tilemap.hasTileAt(t.x,t.y,x.getName()))}hasNoTile(t,i){var x;let T=(x=this.tileCollisionCache)==null?void 0:x.hasTileAt(t.x,t.y,i);return T!==void 0?T:this.hasNoTileUncached(t,i)}hasBlockingChar(t,i,x,T=new Set,E=new Set){return this.charBlockCache.isCharBlockingAt(t,i,x,T,E)}isInRange(t){return new jx(0,0,this.tilemap.getWidth(),this.tilemap.getHeight()).isInRange(t)}toMapDirection(t){return this.isIsometric()?SO(t):t}fromMapDirection(t){return this.isIsometric()?JM(t):t}isIsometric(){return this.tilemap.getOrientation()==="isometric"}getTilePosInDirection(t,i){let x=t.position.add(Cu(this.toMapDirection(i))),T=this.getTransition(x,t.layer)||t.layer;return{position:x,layer:T}}invalidateFrameCache(){this.collisionRelevantLayersFrameCache.clear()}isLayerBlockingAt(t,i,x){let T=this.tilemap.getTileAt(i.x,i.y,t);return T?!!(T.getProperty(this.collisionTilePropertyName)||x&&T.getProperty(this.collidesPropNames.get(x)||"")):!1}getCharLayerIndexes(){return this.tilemap.getLayers().map((t,i)=>({layer:t,index:i})).filter(({layer:t})=>t.isCharLayer()).map(({index:t})=>t)}findPrevAndCharLayer(t){let i=this.getCharLayerIndexes(),x=this.tilemap.getLayers(),T=i.findIndex(E=>x[E].getProperty(Qv)==t);return T==0?{prevIndex:-1,charLayerIndex:i[T]}:{prevIndex:i[T-1],charLayerIndex:i[T]}}getCollisionRelevantLayers(t){if(!t)return this.tilemap.getLayers();let i=this.collisionRelevantLayersFrameCache.get(t);if(i)return i;let{prevIndex:x,charLayerIndex:T}=this.findPrevAndCharLayer(t),E=this.tilemap.getLayers().slice(x+1,T+1);return this.collisionRelevantLayersFrameCache.set(t,E),E}getLowestCharLayer(){for(let t of this.tilemap.getLayers())if(t.isCharLayer())return t.getProperty(Qv)}getCharLayerNames(){return this.tilemap.getLayers().filter(t=>t.isCharLayer()).map(t=>t.getProperty(Qv)).filter(x4)}};bC.ONE_WAY_COLLIDE_PROP_PREFIX="ge_collide_";var y4=bC;function x4(g){return g!=null}var S4=(g=>(g.REMOVED="REMOVED",g.ADDED="ADDED",g))(S4||{}),T4=(g=>(g.WAIT="WAIT",g.SKIP="SKIP",g.STOP="STOP",g))(T4||{}),E4=class{constructor(g,t){this.character=g,this.tilemap=t,this.queue=new vm,this.finished$=new In,this.pathBlockedWaitElapsed=0,this.distanceUtils=gd.create(g.getNumberOfDirections()),this.character.autoMovementSet().pipe(ph(i=>i!==this),qf(1)).subscribe(()=>{this.queue.size()>0&&this.finishMovementTerminated(),this.finished$.complete()})}update(g){(!this.character.isMoving()||this.character.willCrossTileBorderThisUpdate(g))&&this.queue.size()>0&&this.moveCharOnPath(g)}getInfo(){return{type:"Queue"}}enqueue(g,t={}){var i,x,T;let E={pathBlockedStrategy:(i=t.pathBlockedStrategy)!=null?i:"STOP",pathBlockedWaitTimeoutMs:t?.pathBlockedWaitTimeoutMs||-1,ignoreInvalidPositions:(x=t.ignoreInvalidPositions)!=null?x:!1,skipInvalidPositions:(T=t.skipInvalidPositions)!=null?T:!1};for(let s of g){let y={command:s,config:E};if(If(s)){this.queue.enqueue(y);continue}let e=this.queue.peekEnd(),r=e?.command;if(r||(r=this.character.getNextTilePos()),If(r)){this.queue.enqueue(y);continue}let p=this.distanceUtils.distance(r.position,s.position)===1;(!t.ignoreInvalidPositions||p)&&this.queue.enqueue(y)}}peekAll(){return this.queue.peekAll()}size(){return this.queue.size()}finished(){return this.finished$}clear(){this.queue.clear()}moveCharOnPath(g){let t=this.queue.peek();if(!t)return;let i=t.command,x=t.config;if(If(i)&&(i=this.tilemap.getTilePosInDirection(this.character.getNextTilePos(),i)),x.skipInvalidPositions){if(i=this.getNextValidPosition(),!i){this.finishInvalidNextPos(i);return}}else if(!this.isNeighborPos(i)){this.finishInvalidNextPos(i);return}if(this.character.isBlockingDirection(Ma(this.character.getNextTilePos().position,i.position))){if(x.pathBlockedStrategy==="STOP")this.finishPathBlocked(i);else if(x.pathBlockedStrategy==="SKIP"){this.queue.dequeue(),this.moveCharOnPath(g);return}else x.pathBlockedStrategy==="WAIT"&&x.pathBlockedWaitTimeoutMs>-1&&(this.pathBlockedWaitElapsed+=g,this.pathBlockedWaitElapsed>=x.pathBlockedWaitTimeoutMs&&this.finishBlockedWaitTimeout(i,x.pathBlockedWaitTimeoutMs));return}this.pathBlockedWaitElapsed=0,this.queue.dequeue(),this.character.move(this.getDir(this.character.getNextTilePos().position,i.position)),this.isLastMovement()&&this.finish("SUCCESS","",i)}getNextValidPosition(){for(var g;this.queue.size()>0;){let t=(g=this.queue.peek())==null?void 0:g.command;if(If(t)&&(t=this.tilemap.getTilePosInDirection(this.character.getNextTilePos(),t)),t&&this.isNeighborPos(t))return t;this.queue.dequeue()}}isLastMovement(){return this.queue.size()===0}isNeighborPos(g){let t=this.distanceUtils.distance(this.character.getNextTilePos().position,g.position)===1,i=this.tilemap.getTransition(g.position,this.character.getNextTilePos().layer);if(this.character.getNextTilePos().layer!==g.layer)return t&&i===g.layer;let x=i!==void 0&&i!==g.layer;return t&&!x}finishMovementTerminated(){this.finish("MOVEMENT_TERMINATED","New automatic movement has been set to character.")}finishInvalidNextPos(g){g?this.finish("INVALID_NEXT_POS",`Position ${this.posToStr(g)} is not reachable from ${this.posToStr(this.character.getNextTilePos())}.`):this.finish("INVALID_NEXT_POS",`No enqueued position is reachable from ${this.posToStr(this.character.getNextTilePos())}.`)}finishPathBlocked(g){this.finish("PATH_BLOCKED",`Position ${this.posToStr(g)} is blocked.`)}finishBlockedWaitTimeout(g,t){this.finish("PATH_BLOCKED_WAIT_TIMEOUT",`Position ${this.posToStr(g)} is blocked and the wait timeout of ${t} ms has been exceeded.`)}finish(g,t="",i=this.character.getNextTilePos()){this.queue=new vm,this.finished$.next({position:i.position,result:g,description:t,layer:i.layer})}getDir(g,t){return this.tilemap.fromMapDirection(Ma(g,t))}posToStr(g){return`(${g.position.x}, ${g.position.y}, ${g.layer})`}},M4=class{constructor(g=!0){this.isCreatedInternal=!1,g&&console.log(`Using GridEngine v${RC}`)}getCharLayer(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getTilePos().layer}getTransition(g,t){var i;return this.initGuard(),(i=this.gridTilemap)==null?void 0:i.getTransition(new Qt(g),t)}setTransition(g,t,i){var x;return this.initGuard(),(x=this.gridTilemap)==null?void 0:x.setTransition(new Qt(g),t,i)}create(g,t){this.isCreatedInternal=!0,this.gridCharacters=new Map;let i=this.setConfigDefaults(t);this.config=i,this.movementStopped$=new In,this.movementStarted$=new In,this.directionChanged$=new In,this.positionChangeStarted$=new In,this.positionChangeFinished$=new In,this.queueMovementFinished$=new In,this.charRemoved$=new In,this.charAdded$=new In,this.gridTilemap=new y4(g,this.config.collisionTilePropertyName,this.config.characterCollisionStrategy,this.recordToMap(this.config.collisionGroupRelation),this.config.cacheTileCollisions),this.addCharacters()}recordToMap(g){return g?new Map(Object.entries(g).map(([t,i])=>[t,new Set(i)])):void 0}getPosition(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getTilePos().position}move(g,t){this.moveChar(g,t)}moveRandomly(g,t=0,i=-1){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(g);if(!T)throw this.createCharUnknownErr(g);let E=new c4(T,t,i);T.setMovement(E)}getMovement(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);let x=i.getMovement();return x?x.getInfo():{type:"None"}}moveTo(g,t,i){var x;let T=this.assembleMoveToConfig(i);this.initGuard();let E=(x=this.gridCharacters)==null?void 0:x.get(g);if(!E)throw this.createCharUnknownErr(g);if(!this.gridTilemap)throw this.createUninitializedErr();let s=new OC(E,this.gridTilemap,{position:new Qt(t),layer:i?.targetLayer||E.getNextTilePos().layer},{distance:0,config:T});return E.setMovement(s),s.finishedObs().pipe(od(y=>({charId:g,position:y.position,result:y.result,description:y.description,layer:y.layer})))}stopMovement(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);i.setMovement(void 0)}setSpeed(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.setSpeed(t)}getSpeed(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getSpeed()}collidesWithTiles(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.collidesWithTiles()}update(g,t){var i;if(this.isCreatedInternal&&this.gridCharacters)for(let[x,T]of this.gridCharacters)T.update(t);(i=this.gridTilemap)==null||i.invalidateFrameCache()}addCharacter(g){var t,i,x,T,E;if(!this.gridTilemap)throw this.createUninitializedErr();if(!this.config)throw this.createUninitializedErr();let s={speed:g.speed||4,tilemap:this.gridTilemap,collidesWithTiles:!0,collisionGroups:["geDefault"],ignoreCollisionGroups:[],charLayer:g.charLayer,facingDirection:g.facingDirection,labels:g.labels,numberOfDirections:(t=g.numberOfDirections)!=null?t:this.config.numberOfDirections,tileWidth:g.tileWidth,tileHeight:g.tileHeight};typeof g.collides=="boolean"?g.collides===!1&&(s.collidesWithTiles=!1,s.collisionGroups=[]):g.collides!==void 0&&(g.collides.collidesWithTiles===!1&&(s.collidesWithTiles=!1),g.collides.collisionGroups&&(s.collisionGroups=g.collides.collisionGroups),g.collides.ignoreCollisionGroups&&(s.ignoreCollisionGroups=g.collides.ignoreCollisionGroups),s.ignoreMissingTiles=(x=(i=g.collides)==null?void 0:i.ignoreMissingTiles)!=null?x:!1);let y=new n4(g.id,s);g.startPosition&&y.setTilePosition({position:new Qt(g.startPosition),layer:y.getTilePos().layer}),(T=this.gridCharacters)==null||T.set(g.id,y),this.gridTilemap.addCharacter(y);let e=y.getId();y.movementStopped().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.movementStopped$)==null||p.next({charId:e,direction:r})}),y.movementStarted().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.movementStarted$)==null||p.next({charId:e,direction:r})}),y.directionChanged().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.directionChanged$)==null||p.next({charId:e,direction:r})}),y.positionChangeStarted().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.positionChangeStarted$)==null||p.next(An({charId:e},r))}),y.positionChangeFinished().pipe(Ta(this.charRemoved(e))).subscribe(r=>{var p;(p=this.positionChangeFinished$)==null||p.next(An({charId:e},r))}),(E=this.charAdded$)==null||E.next(e)}hasCharacter(g){var t;return this.initGuard(),!!((t=this.gridCharacters)!=null&&t.has(g))}removeCharacter(g){var t,i,x,T;if(this.initGuard(),!((t=this.gridCharacters)!=null&&t.get(g)))throw this.createCharUnknownErr(g);(i=this.gridTilemap)==null||i.removeCharacter(g),(x=this.gridCharacters)==null||x.delete(g),(T=this.charRemoved$)==null||T.next(g)}removeAllCharacters(){if(this.initGuard(),!!this.gridCharacters)for(let g of this.gridCharacters.keys())this.removeCharacter(g)}getAllCharacters(g){if(this.initGuard(),!this.gridCharacters)return[];let t=[...this.gridCharacters.values()];return(g?d4(t,g):t).map(i=>i.getId())}getLabels(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getLabels()}addLabels(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.addLabels(t)}removeLabels(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.removeLabels(t)}clearLabels(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);i.clearLabels()}follow(g,t,i,x){var T,E,s,y,e,r;let p;i===void 0?p={distance:0,closestPointIfBlocked:!1}:typeof i=="number"?(p={distance:i,closestPointIfBlocked:!1},x&&(p.closestPointIfBlocked=!0)):p=i,this.initGuard();let h=(T=this.gridCharacters)==null?void 0:T.get(g),a=(E=this.gridCharacters)==null?void 0:E.get(t);if(!h)throw this.createCharUnknownErr(g);if(!a)throw this.createCharUnknownErr(t);if(!this.gridTilemap)throw this.createUninitializedErr();let l=new f4(h,this.gridTilemap,a,{distance:(s=p.distance)!=null?s:0,noPathFoundStrategy:p.closestPointIfBlocked?"CLOSEST_REACHABLE":"STOP",maxPathLength:(y=p.maxPathLength)!=null?y:1/0,shortestPathAlgorithm:(e=p.algorithm)!=null?e:"BIDIRECTIONAL_SEARCH",ignoreLayers:!!p.ignoreLayers,facingDirection:(r=p.facingDirection)!=null?r:"none"});h.setMovement(l)}isMoving(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.isMoving()}getFacingDirection(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getFacingDirection()}getFacingPosition(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);let x=i.getFacingPosition();return{x:x.x,y:x.y}}turnTowards(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);return x.turnTowards(t)}getCharactersAt(g,t){if(this.initGuard(),!this.gridTilemap)return[];let i=this.gridTilemap.getCharactersAt(new Qt(g),t);return Array.from(i).map(x=>x.getId())}setPosition(g,t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(g);if(!T)throw this.createCharUnknownErr(g);i||T.setTilePosition({position:new Qt(t),layer:T.getTilePos().layer}),T.setTilePosition({position:new Qt(t),layer:i})}isBlocked(g,t,i=["geDefault"]){var x,T;this.initGuard();let E=new Qt(g);return!!((x=this.gridTilemap)!=null&&x.hasBlockingTile(E,t)||(T=this.gridTilemap)!=null&&T.hasBlockingChar(E,t,i))}isTileBlocked(g,t){var i;return this.initGuard(),!!((i=this.gridTilemap)!=null&&i.hasBlockingTile(new Qt(g),t))}getCollisionGroups(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getCollisionGroups()||[]}setCollisionGroups(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.setCollisionGroups(t)}getIgnoreCollisionGroups(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getIgnoreCollisionGroups()||[]}setIgnoreCollisionGroups(g,t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(g);if(!x)throw this.createCharUnknownErr(g);x.setIgnoreCollisionGroups(t)}getTilePosInDirection(g,t,i){if(!this.gridTilemap)throw this.createUninitializedErr();let x=this.gridTilemap.getTilePosInDirection({position:new Qt(g),layer:t},i);return{position:x.position.toPosition(),charLayer:x.layer}}findShortestPath(g,t,i={}){if(!this.gridTilemap)throw this.createUninitializedErr();let x=i.shortestPathAlgorithm||"BFS";i.considerCosts&&x!=="A_STAR"&&console.warn(`GridEngine: Pathfinding option 'considerCosts' cannot be used with algorithm '${x}'. It can only be used with A* algorithm.`);let T=i.pathWidth!==void 0&&i.pathWidth!==1,E=i.pathHeight!==void 0&&i.pathHeight!==1;(T||E)&&x==="JPS"&&console.warn("GridEngine: Pathfinding options 'pathWidth' and 'pathHeight' > 1 cannot be used with algorithm 'JPS'.");let s=new FC(this.gridTilemap).findShortestPath(Ai.toInternal(g),Ai.toInternal(t),dh(An({},i),{shortestPathAlgorithm:x}));return{path:s.path.map(Ai.fromInternal),closestToTarget:s.closestToTarget?Ai.fromInternal(s.closestToTarget):void 0,reachedMaxPathLength:!1,steps:s.steps}}steppedOn(g,t,i){return this.positionChangeFinished().pipe(ph(x=>g.includes(x.charId)&&t.some(T=>T.x===x.enterTile.x&&T.y===x.enterTile.y)&&(i===void 0||i.includes(x.enterLayer))))}characterShifted(){if(!this.charAdded$||!this.charRemoved$)throw this.createUninitializedErr();return this.charAdded$.pipe(od(g=>({charId:g,action:"ADDED"})),i4(this.charRemoved$.pipe(od(g=>({charId:g,action:"REMOVED"})))))}movementStarted(){if(!this.movementStarted$)throw this.createUninitializedErr();return this.movementStarted$}movementStopped(){if(!this.movementStopped$)throw this.createUninitializedErr();return this.movementStopped$}directionChanged(){if(!this.directionChanged$)throw this.createUninitializedErr();return this.directionChanged$}positionChangeStarted(){if(!this.positionChangeStarted$)throw this.createUninitializedErr();return this.positionChangeStarted$}positionChangeFinished(){if(!this.positionChangeFinished$)throw this.createUninitializedErr();return this.positionChangeFinished$}getMovementProgress(g){var t;this.initGuard();let i=(t=this.gridCharacters)==null?void 0:t.get(g);if(!i)throw this.createCharUnknownErr(g);return i.getMovementProgress()}rebuildTileCollisionCache(g,t,i,x){var T;(T=this.gridTilemap)==null||T.rebuildTileCollisionCache(new jx(g,t,i,x))}addQueueMovements(g,t,i){var x,T;this.initGuard();let E=(x=this.gridCharacters)==null?void 0:x.get(g);if(!E)throw this.createCharUnknownErr(g);if(!this.gridTilemap)throw this.createUninitializedErr();let s;((T=E?.getMovement())==null?void 0:T.getInfo().type)==="Queue"?s=E.getMovement():(s=new E4(E,this.gridTilemap),E.setMovement(s),s.finished().pipe(Ta(_O(this.charRemoved(g),E.autoMovementSet()))).subscribe(y=>{var e;(e=this.queueMovementFinished$)==null||e.next(An({charId:g},y))})),s.enqueue(t.map(y=>If(y)?y:{position:new Qt(y.position),layer:y.charLayer}),i)}queueMovementFinished(){if(!this.queueMovementFinished$)throw this.createUninitializedErr();return this.queueMovementFinished$}getEnqueuedMovements(g){var t,i;this.initGuard();let x=(t=this.gridCharacters)==null?void 0:t.get(g);if(!x)throw this.createCharUnknownErr(g);return((i=x.getMovement())==null?void 0:i.getInfo().type)==="Queue"?x.getMovement().peekAll().map(T=>({command:If(T.command)?T.command:Ai.fromInternal(T.command),config:T.config})):[]}clearEnqueuedMovements(g){var t,i;this.initGuard();let x=(t=this.gridCharacters)==null?void 0:t.get(g);if(!x)throw this.createCharUnknownErr(g);((i=x.getMovement())==null?void 0:i.getInfo().type)==="Queue"&&x.getMovement().clear()}getTileCost(g,t,i){var x,T;return this.initGuard(),(T=(x=this.gridTilemap)==null?void 0:x.getTileCosts({position:new Qt(g),layer:t},i))!=null?T:1}getState(){let g=[];if(this.gridCharacters)for(let[t,i]of this.gridCharacters.entries())g.push({id:t,position:Ai.fromInternal(i.getTilePos()),facingDirection:i.getFacingDirection(),speed:i.getSpeed(),labels:i.getLabels(),movementProgress:i.getMovementProgress(),collisionConfig:{collisionGroups:i.getCollisionGroups(),ignoreCollisionGroups:i.getIgnoreCollisionGroups(),collidesWithTiles:i.collidesWithTiles(),ignoreMissingTiles:i.getIgnoreMissingTiles()}});return{characters:g}}setState(g){if(this.gridCharacters)for(let t of g.characters){let i=this.gridCharacters.get(t.id);if(i){let x=i.getTilePos();Ai.equal(x,Ai.toInternal(t.position))||i.setTilePosition(Ai.toInternal(t.position)),i.setSpeed(t.speed),i.turnTowards(t.facingDirection),t.collisionConfig.collisionGroups&&i.setCollisionGroups(t.collisionConfig.collisionGroups),t.collisionConfig.collidesWithTiles!==void 0&&i.setCollidesWithTiles(t.collisionConfig.collidesWithTiles),t.collisionConfig.ignoreMissingTiles!==void 0&&i.setIgnoreMissingTiles(t.collisionConfig.ignoreMissingTiles),i.setMovementProgress(t.movementProgress),i.clearLabels(),i.addLabels(t.labels)}}}charRemoved(g){var t;if(!this.charRemoved$)throw this.createUninitializedErr();return(t=this.charRemoved$)==null?void 0:t.pipe(qf(1),ph(i=>i==g))}initGuard(){if(!this.isCreatedInternal)throw this.createUninitializedErr()}createUninitializedErr(){throw new Error("GridEngine not initialized. You need to call create() first.")}addCharacters(){var g;(g=this.config)==null||g.characters.forEach(t=>this.addCharacter(t))}moveChar(g,t){var i,x,T;this.initGuard();let E=(i=this.gridCharacters)==null?void 0:i.get(g);if(!E)throw this.createCharUnknownErr(g);if(E.getNumberOfDirections()===4){if(!((x=this.gridTilemap)!=null&&x.isIsometric())&&ad(t)){console.warn(`GridEngine: Character '${g}' can't be moved '${t}' in 4 direction mode.`);return}else if((T=this.gridTilemap)!=null&&T.isIsometric()&&!ad(t)){console.warn(`GridEngine: Character '${g}' can't be moved '${t}' in 4 direction isometric mode.`);return}}E.move(t)}createCharUnknownErr(g){return new Error(`Character unknown: ${g}`)}assembleMoveToConfig(g={}){let t=dh(An({},g),{noPathFoundStrategy:"STOP",pathBlockedStrategy:"WAIT"});return g!=null&&g.noPathFoundStrategy&&(Object.values(CC).includes(g.noPathFoundStrategy)?t.noPathFoundStrategy=g.noPathFoundStrategy:console.warn(`GridEngine: Unknown NoPathFoundStrategy '${g.noPathFoundStrategy}'. Falling back to 'STOP'`)),g!=null&&g.pathBlockedStrategy&&(Object.values(wC).includes(g.pathBlockedStrategy)?t.pathBlockedStrategy=g.pathBlockedStrategy:console.warn(`GridEngine: Unknown PathBlockedStrategy '${g.pathBlockedStrategy}'. Falling back to 'WAIT'`)),t}setConfigDefaults(g){return An({collisionTilePropertyName:"ge_collide",numberOfDirections:4,characterCollisionStrategy:"BLOCK_TWO_TILES",cacheTileCollisions:!1},g)}},C4=class extends PC{constructor(g,t={}){super(g,t),this.jumpCache=new hT}findShortestPathImpl(g,t){return this.jumpCache=new hT,super.findShortestPathImpl(g,t)}getNeighborsInternal(g,t,i){if(!t||g.layer!==t.layer)return this.getNeighbors(g,i).map(E=>({p:E,dist:1}));let x=this.prune(t,g).map(E=>{let s=this.getTransition(E.position,g.layer);return{position:E.position,layer:s||g.layer}}),T=[];for(let E of x){let s=this.jump(g,E,i,1,Ma(g.position,E.position));s&&(s.dist=this.distance(g.position,s.p.position),T.push(s))}return T}getForced(g,t){let i=[],{topLeft:x,downLeft:T,top:E,bottom:s,topRight:y,downRight:e}=this.normalizedPositions(g,t),r=Ma(g.position,t.position);return ad(r)?(this.blockOrTrans(g,x)&&(this.addIfNotBlocked(i,t,E),this.addIfNotBlocked(i,t,y),this.blockOrTrans(T,x)&&this.addIfNotBlocked(i,t,x)),this.blockOrTrans(g,T)&&(this.addIfNotBlocked(i,t,s),this.addIfNotBlocked(i,t,e),this.blockOrTrans(x,T)&&this.addIfNotBlocked(i,t,T)),this.blockOrTrans(x,E)&&this.addIfNotBlocked(i,t,E),this.blockOrTrans(T,s)&&this.addIfNotBlocked(i,t,s),this.blockOrTrans(x,y)&&this.addIfNotBlocked(i,t,y),this.blockOrTrans(T,e)&&this.addIfNotBlocked(i,t,e)):((this.blockOrTrans(g,E)||this.blockOrTrans(E,y))&&this.addIfNotBlocked(i,t,y),(this.blockOrTrans(g,s)||this.blockOrTrans(s,e))&&this.addIfNotBlocked(i,t,e),this.blockOrTrans(g,x)&&this.blockOrTrans(g,E)&&(this.addIfNotBlocked(i,t,E),this.addIfNotBlocked(i,t,x)),this.blockOrTrans(g,T)&&this.blockOrTrans(g,s)&&(this.addIfNotBlocked(i,t,s),this.addIfNotBlocked(i,t,T)),this.blockOrTrans(x,E)&&this.blockOrTrans(g,E)&&this.addIfNotBlocked(i,t,E),this.blockOrTrans(T,s)&&this.blockOrTrans(g,s)&&this.addIfNotBlocked(i,t,s)),i}hasForced(g,t){let{topLeft:i,downLeft:x,top:T,bottom:E,topRight:s,downRight:y}=this.normalizedPositions(g,t),e=Ma(g.position,t.position);if(ad(e)){if(this.blockOrTrans(g,i)&&(!this.blockOrTrans(t,T)||!this.blockOrTrans(t,s)||this.blockOrTrans(x,i)&&!this.blockOrTrans(t,i))||this.blockOrTrans(g,x)&&(!this.blockOrTrans(t,E)||!this.blockOrTrans(t,y)||this.blockOrTrans(i,x)&&!this.blockOrTrans(t,x))||this.blockOrTrans(i,T)&&!this.blockOrTrans(t,T)||this.blockOrTrans(x,E)&&!this.blockOrTrans(t,E)||this.blockOrTrans(i,s)&&!this.blockOrTrans(t,s)||this.blockOrTrans(x,y)&&!this.blockOrTrans(t,y))return!0}else if((this.blockOrTrans(g,T)||this.blockOrTrans(T,s))&&!this.blockOrTrans(t,s)||(this.blockOrTrans(g,E)||this.blockOrTrans(E,y))&&!this.blockOrTrans(t,y)||this.blockOrTrans(g,i)&&this.blockOrTrans(g,T)&&(!this.blockOrTrans(t,T)||!this.blockOrTrans(t,i))||this.blockOrTrans(g,x)&&this.blockOrTrans(g,E)&&(!this.blockOrTrans(t,E)||!this.blockOrTrans(t,x))||this.blockOrTrans(i,T)&&this.blockOrTrans(g,T)&&!this.blockOrTrans(t,T)||this.blockOrTrans(x,E)&&this.blockOrTrans(g,E)&&!this.blockOrTrans(t,E))return!0;return!1}prune(g,t){let{top:i,right:x,topRight:T,downRight:E,bottom:s}=this.normalizedPositions(g,t),y=this.getForced(g,t),e=Ma(g.position,t.position);return ad(e)?[i,x,T,E,s,...y]:[x,...y]}jump(g,t,i,x,T){let E=this.jumpCache.get(g,t);if(E!==null)return E;if(this.isBlocking(g,t)&&!(Ai.equal(t,i)&&this.options.ignoreBlockedTarget)){this.jumpCache.set(g,t,void 0);return}if(Ai.equal(t,i))return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(x>=this.maxJumpSize)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.getTransition(t.position,g.layer)!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.hasForced(g,t))return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.updateClosestToTarget(t,i),T==="up-left"){if(this.jump(t,this.getTilePosInDir(t,"up"),i,x+1,"up")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"left"),i,x+1,"left")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}else if(T==="down-left"){if(this.jump(t,this.getTilePosInDir(t,"down"),i,x+1,"down")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"left"),i,x+1,"left")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}else if(T==="up-right"){if(this.jump(t,this.getTilePosInDir(t,"up"),i,x+1,"up")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"right"),i,x+1,"right")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}else if(T==="down-right"){if(this.jump(t,this.getTilePosInDir(t,"down"),i,x+1,"down")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0};if(this.jump(t,this.getTilePosInDir(t,"right"),i,x+1,"right")!==void 0)return this.jumpCache.set(g,t,{p:t,dist:0}),{p:t,dist:0}}let s=this.jump(t,this.getTilePosInDir(t,T),i,x+1,T);return this.jumpCache.set(g,t,s),s}normalizedPositions(g,t){return g.position.xt.position.x&&g.position.y===t.position.y?{topLeft:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},downLeft:{position:new Qt(t.position.x+1,t.position.y-1),layer:t.layer},top:{position:new Qt(t.position.x,t.position.y+1),layer:t.layer},bottom:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},right:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer},topRight:{position:new Qt(t.position.x-1,t.position.y+1),layer:t.layer},downRight:{position:new Qt(t.position.x-1,t.position.y-1),layer:t.layer}}:g.position.yt.position.y&&g.position.x===t.position.x?{topLeft:{position:new Qt(t.position.x-1,t.position.y+1),layer:t.layer},downLeft:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},top:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer},bottom:{position:new Qt(t.position.x+1,t.position.y),layer:t.layer},right:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},topRight:{position:new Qt(t.position.x-1,t.position.y-1),layer:t.layer},downRight:{position:new Qt(t.position.x+1,t.position.y-1),layer:t.layer}}:g.position.yt.position.x?{topLeft:{position:new Qt(t.position.x+1,t.position.y),layer:t.layer},downLeft:{position:new Qt(t.position.x,t.position.y-1),layer:t.layer},top:{position:new Qt(t.position.x+1,t.position.y+1),layer:t.layer},bottom:{position:new Qt(t.position.x-1,t.position.y-1),layer:t.layer},right:{position:new Qt(t.position.x-1,t.position.y+1),layer:t.layer},topRight:{position:new Qt(t.position.x,t.position.y+1),layer:t.layer},downRight:{position:new Qt(t.position.x-1,t.position.y),layer:t.layer}}:g.position.y>t.position.y&&g.position.x(g.SUCCESS="SUCCESS",g.NO_PATH_FOUND_MAX_RETRIES_EXCEEDED="NO_PATH_FOUND_MAX_RETRIES_EXCEEDED",g.PATH_BLOCKED_MAX_RETRIES_EXCEEDED="PATH_BLOCKED_MAX_RETRIES_EXCEEDED",g.PATH_BLOCKED="PATH_BLOCKED",g.NO_PATH_FOUND="NO_PATH_FOUND",g.PATH_BLOCKED_WAIT_TIMEOUT="PATH_BLOCKED_WAIT_TIMEOUT",g.MOVEMENT_TERMINATED="MOVEMENT_TERMINATED",g.MAX_PATH_LENGTH_REACHED="MAX_PATH_LENGTH_REACHED",g))(A4||{}),OC=class{constructor(g,t,i,{config:x,ignoreBlockedTarget:T=!1,distance:E=0}={}){this.character=g,this.tilemap=t,this.targetPos=i,this.shortestPath=[],this.distOffset=0,this.posOnPath=0,this.stopped=!1,this.pathBlockedWaitElapsed=0,this.isPositionAllowed=()=>!0,this.shortestPathAlgorithm="BIDIRECTIONAL_SEARCH",this.maxPathLength=1/0,this.considerCosts=!1,this.ignoredChars=[],this.isBlocking=(e,r)=>e?new AC(this.tilemap,this.getPathfindingOptions()).isBlocking(this.character.getTilePos(),{position:e,layer:r}):!0;var s,y;this.shortestPathAlgorithm=(s=x?.algorithm)!=null?s:this.shortestPathAlgorithm,this.ignoreBlockedTarget=T,this.distance=E,this.noPathFoundStrategy=x?.noPathFoundStrategy||"STOP",this.pathBlockedStrategy=x?.pathBlockedStrategy||"WAIT",this.noPathFoundRetryable=new eT(x?.noPathFoundRetryBackoffMs||200,x?.noPathFoundMaxRetries||-1,()=>{this.stop("NO_PATH_FOUND_MAX_RETRIES_EXCEEDED")}),this.pathBlockedRetryable=new eT(x?.pathBlockedRetryBackoffMs||200,x?.pathBlockedMaxRetries||-1,()=>{this.stop("PATH_BLOCKED_MAX_RETRIES_EXCEEDED")}),x!=null&&x.isPositionAllowedFn&&(this.isPositionAllowed=x.isPositionAllowedFn),x!=null&&x.maxPathLength&&(this.maxPathLength=x.maxPathLength),this.alternativeTargets=x?.alternativeTargets,this.noPathFoundAlternativeTargetsFallbackStrategy=x?.noPathFoundAlternativeTargetsFallbackStrategy,x!=null&&x.considerCosts&&this.shortestPathAlgorithm!=="A_STAR"&&console.warn(`GridEngine: Pathfinding option 'considerCosts' cannot be used with algorithm '${this.shortestPathAlgorithm}'. It can only be used with A* algorithm.`),this.shortestPathAlgorithm==="JPS"&&(this.character.getTileWidth()>1||this.character.getTileHeight()>1)&&console.warn("GridEngine: Pathfinding algorithm 'JPS' can only be used for characters with 'tileWidth' and 'tileHeight' of 1"),this.considerCosts=x?.considerCosts||!1,this.ignoreLayers=!!(x!=null&&x.ignoreLayers),this.distanceUtils=gd.create(g.getNumberOfDirections()),this.pathBlockedWaitTimeoutMs=x?.pathBlockedWaitTimeoutMs||-1,this.ignoredChars=(y=x?.ignoredChars)!=null?y:[],this.finished$=new In,this.setCharacter(g)}setPathBlockedStrategy(g){this.pathBlockedStrategy=g}getPathBlockedStrategy(){return this.pathBlockedStrategy}setCharacter(g){this.character=g,this.noPathFoundRetryable.reset(),this.pathBlockedRetryable.reset(),this.pathBlockedWaitElapsed=0,this.calcShortestPath(),this.character.autoMovementSet().pipe(ph(t=>t!==this),qf(1)).subscribe(()=>{this.stop("MOVEMENT_TERMINATED")})}getPathfindingOptions(){return{shortestPathAlgorithm:this.shortestPathAlgorithm,pathWidth:this.character.getTileWidth(),pathHeight:this.character.getTileHeight(),numberOfDirections:this.character.getNumberOfDirections(),isPositionAllowed:this.isPositionAllowed,collisionGroups:this.character.getCollisionGroups(),ignoredChars:[this.character.getId(),...this.ignoredChars],ignoreTiles:!this.character.collidesWithTiles(),ignoreMapBounds:this.character.getIgnoreMissingTiles(),ignoreBlockedTarget:this.ignoreBlockedTarget,maxPathLength:this.maxPathLength,ignoreLayers:this.ignoreLayers,considerCosts:this.considerCosts,calculateClosestToTarget:!0}}update(g){var t,i,x,T;this.stopped||(this.noPathFound()&&(this.noPathFoundStrategy==="RETRY"?this.noPathFoundRetryable.retry(g,()=>this.calcShortestPath()):this.noPathFoundStrategy==="STOP"&&this.stop("NO_PATH_FOUND")),this.updatePosOnPath(),this.isBlocking((t=this.nextTileOnPath())==null?void 0:t.position,(i=this.character)==null?void 0:i.getNextTilePos().layer)?this.applyPathBlockedStrategy(g):this.pathBlockedWaitElapsed=0,this.hasArrived()?(this.stop("SUCCESS"),this.existsDistToTarget()&&this.turnTowardsTarget()):this.isBlocking((x=this.nextTileOnPath())==null?void 0:x.position,(T=this.character)==null?void 0:T.getNextTilePos().layer)||this.moveCharOnPath())}finishedObs(){return this.finished$}getInfo(){return{type:"Target",state:{pathAhead:this.shortestPath.slice(this.posOnPath).map(g=>Ai.fromInternal(g))},config:{algorithm:this.shortestPathAlgorithm,ignoreBlockedTarget:this.ignoreBlockedTarget,distance:this.distance,targetPos:Ai.fromInternal(this.targetPos),noPathFoundStrategy:this.noPathFoundStrategy,pathBlockedStrategy:this.pathBlockedStrategy,noPathFoundRetryBackoffMs:this.noPathFoundRetryable.getBackoffMs(),noPathFoundMaxRetries:this.noPathFoundRetryable.getMaxRetries()}}}resultToReason(g){switch(g){case"SUCCESS":return"Successfully arrived.";case"MOVEMENT_TERMINATED":return"Movement of character has been replaced before destination was reached.";case"PATH_BLOCKED":return"PathBlockedStrategy STOP: Path blocked.";case"NO_PATH_FOUND_MAX_RETRIES_EXCEEDED":return`NoPathFoundStrategy RETRY: Maximum retries of ${this.noPathFoundRetryable.getMaxRetries()} exceeded.`;case"NO_PATH_FOUND":return"NoPathFoundStrategy STOP: No path found.";case"PATH_BLOCKED_MAX_RETRIES_EXCEEDED":return`PathBlockedStrategy RETRY: Maximum retries of ${this.pathBlockedRetryable.getMaxRetries()} exceeded.`;case"PATH_BLOCKED_WAIT_TIMEOUT":return`PathBlockedStrategy WAIT: Wait timeout of ${this.pathBlockedWaitTimeoutMs}ms exceeded.`}}applyPathBlockedStrategy(g){this.pathBlockedStrategy==="RETRY"?this.pathBlockedRetryable.retry(g,()=>{let t=this.getShortestPath();t.path.length>0&&this.calcShortestPath(t)}):this.pathBlockedStrategy==="STOP"?this.stop("PATH_BLOCKED"):this.pathBlockedStrategy==="WAIT"&&this.pathBlockedWaitTimeoutMs>-1&&(this.pathBlockedWaitElapsed+=g,this.pathBlockedWaitElapsed>=this.pathBlockedWaitTimeoutMs&&this.stop("PATH_BLOCKED_WAIT_TIMEOUT"))}moveCharOnPath(){let g=this.nextTileOnPath();if(!g)return;let t=this.getDir(this.character.getNextTilePos().position,g.position);this.character.move(t)}nextTileOnPath(){return this.shortestPath[this.posOnPath+1]}stop(g){this.finished$.next({position:this.character.getTilePos().position,result:g,description:this.resultToReason(g),layer:this.character.getTilePos().layer}),this.finished$.complete(),this.stopped=!0}turnTowardsTarget(){let g=this.shortestPath[this.posOnPath+1],t=this.getDir(this.character.getNextTilePos().position,g.position);this.character.turnTowards(t)}existsDistToTarget(){return this.posOnPath=this.shortestPath.length-1}updatePosOnPath(){let g=this.shortestPath[this.posOnPath];for(;this.posOnPath0)return{path:E,distOffset:s}}return this.noPathFoundStrategy=this.noPathFoundAlternativeTargetsFallbackStrategy||"STOP",this.getShortestPath()}}return{path:i,distOffset:0}}pathToAlternativeTarget(g,t){let i=t.findShortestPath(this.character.getNextTilePos(),g,this.getPathfindingOptions()).path,x=this.distanceUtils.distance(g.position,this.targetPos.position);return{path:i,distOffset:x}}getDir(g,t){return this.tilemap.fromMapDirection(this.distanceUtils.direction(g,t))}},P4=Object.create,DC=Object.defineProperty,R4=Object.getOwnPropertyDescriptor,b4=Object.getOwnPropertyNames,L4=Object.getPrototypeOf,F4=Object.prototype.hasOwnProperty,O4=(g,t)=>()=>(t||g((t={exports:{}}).exports,t),t.exports),D4=(g,t,i,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let T of b4(t))!F4.call(g,T)&&T!==i&&DC(g,T,{get:()=>t[T],enumerable:!(x=R4(t,T))||x.enumerable});return g},Zx=(g,t,i)=>(i=g!=null?P4(L4(g)):{},D4(t||!g||!g.__esModule?DC(i,"default",{value:g,enumerable:!0}):i,g)),Jx=O4((g,t)=>{(function(){var i,x="4.17.21",T=200,E="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",y="Invalid `variable` option passed into `_.template`",e="__lodash_hash_undefined__",r=500,p="__lodash_placeholder__",h=1,a=2,l=4,n=1,u=2,f=1,o=2,c=4,d=8,v=16,m=32,S=64,M=128,w=256,C=512,A=30,P="...",b=800,O=16,I=1,D=2,B=3,G=1/0,z=9007199254740991,X=17976931348623157e292,K=NaN,Q=4294967295,tt=Q-1,Y=Q>>>1,Z=[["ary",M],["bind",f],["bindKey",o],["curry",d],["curryRight",v],["flip",C],["partial",m],["partialRight",S],["rearg",w]],U="[object Arguments]",H="[object Array]",J="[object AsyncFunction]",_="[object Boolean]",q="[object Date]",at="[object DOMException]",ot="[object Error]",rt="[object Function]",gt="[object GeneratorFunction]",yt="[object Map]",Et="[object Number]",At="[object Null]",Pt="[object Object]",Vt="[object Promise]",dt="[object Proxy]",ut="[object RegExp]",Rt="[object Set]",Dt="[object String]",Ht="[object Symbol]",Bt="[object Undefined]",ne="[object WeakMap]",oe="[object WeakSet]",ge="[object ArrayBuffer]",xe="[object DataView]",Ae="[object Float32Array]",qt="[object Float64Array]",Ge="[object Int8Array]",Oe="[object Int16Array]",Be="[object Int32Array]",Le="[object Uint8Array]",ie="[object Uint8ClampedArray]",Ke="[object Uint16Array]",ri="[object Uint32Array]",Ti=/\b__p \+= '';/g,le=/\b(__p \+=) '' \+/g,xi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bt=/&(?:amp|lt|gt|quot|#39);/g,Me=/[&<>"']/g,Ce=RegExp(bt.source),Ve=RegExp(Me.source),Je=/<%-([\s\S]+?)%>/g,zi=/<%([\s\S]+?)%>/g,Di=/<%=([\s\S]+?)%>/g,en=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zn=/^\w*$/,Gi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,di=/[\\^$.*+?()[\]{}|]/g,Wi=RegExp(di.source),Pa=/^\s+/,aa=/\s/,Bs=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Qr=/\{\n\/\* \[wrapped with (.+)\] \*/,ao=/,? & /,_r=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Us=/[()=,{}\[\]\/\s]/,xs=/\\(\\)?/g,oo=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Rl=/\w*$/,Tt=/^[-+]0x[0-9a-f]+$/i,jt=/^0b[01]+$/i,_t=/^\[object .+?Constructor\]$/,ee=/^0o[0-7]+$/i,te=/^(?:0|[1-9]\d*)$/,Te=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ue=/($^)/,We=/['\n\r\u2028\u2029\\]/g,$e="\\ud800-\\udfff",qe="\\u0300-\\u036f",ii="\\ufe20-\\ufe2f",ai="\\u20d0-\\u20ff",Ji=qe+ii+ai,hn="\\u2700-\\u27bf",ki="a-z\\xdf-\\xf6\\xf8-\\xff",gn="\\xac\\xb1\\xd7\\xf7",ti="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Se="\\u2000-\\u206f",Nr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",mi="A-Z\\xc0-\\xd6\\xd8-\\xde",un="\\ufe0e\\ufe0f",Ii=gn+ti+Se+Nr,Gn="['’]",pn="["+$e+"]",Ki="["+Ii+"]",dr="["+Ji+"]",zs="\\d+",Tn="["+hn+"]",oa="["+ki+"]",Jn="[^"+$e+Ii+zs+hn+ki+mi+"]",Ra="\\ud83c[\\udffb-\\udfff]",Gs="(?:"+dr+"|"+Ra+")",lo="[^"+$e+"]",ba="(?:\\ud83c[\\udde6-\\uddff]){2}",ho="[\\ud800-\\udbff][\\udc00-\\udfff]",gi="["+mi+"]",La="\\u200d",Bu="(?:"+oa+"|"+Jn+")",oc="(?:"+gi+"|"+Jn+")",rr="(?:"+Gn+"(?:d|ll|m|re|s|t|ve))?",Vs="(?:"+Gn+"(?:D|LL|M|RE|S|T|VE))?",Hs=Gs+"?",Ws="["+un+"]?",bl="(?:"+La+"(?:"+[lo,ba,ho].join("|")+")"+Ws+Hs+")*",Ni="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pn="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Br=Ws+Hs+bl,uo="(?:"+[Tn,ba,ho].join("|")+")"+Br,Wo="(?:"+[lo+dr+"?",dr,ba,ho,pn].join("|")+")",Eh=RegExp(Gn,"g"),nn=RegExp(dr,"g"),Xo=RegExp(Ra+"(?="+Ra+")|"+Wo+Br,"g"),Ss=RegExp([gi+"?"+oa+"+"+rr+"(?="+[Ki,gi,"$"].join("|")+")",oc+"+"+Vs+"(?="+[Ki,gi+Bu,"$"].join("|")+")",gi+"?"+Bu+"+"+rr,gi+"+"+Vs,Pn,Ni,zs,uo].join("|"),"g"),Yo=RegExp("["+La+$e+Ji+un+"]"),Uu=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fo=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],xr=-1,ji={};ji[Ae]=ji[qt]=ji[Ge]=ji[Oe]=ji[Be]=ji[Le]=ji[ie]=ji[Ke]=ji[ri]=!0,ji[U]=ji[H]=ji[ge]=ji[_]=ji[xe]=ji[q]=ji[ot]=ji[rt]=ji[yt]=ji[Et]=ji[Pt]=ji[ut]=ji[Rt]=ji[Dt]=ji[ne]=!1;var Zi={};Zi[U]=Zi[H]=Zi[ge]=Zi[xe]=Zi[_]=Zi[q]=Zi[Ae]=Zi[qt]=Zi[Ge]=Zi[Oe]=Zi[Be]=Zi[yt]=Zi[Et]=Zi[Pt]=Zi[ut]=Zi[Rt]=Zi[Dt]=Zi[Ht]=Zi[Le]=Zi[ie]=Zi[Ke]=Zi[ri]=!0,Zi[ot]=Zi[rt]=Zi[ne]=!1;var Ts={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Ur={"&":"&","<":"<",">":">",'"':""","'":"'"},Ll={"&":"&","<":"<",">":">",""":'"',"'":"'"},Mh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ko=parseFloat,Fl=parseInt,zr=typeof global=="object"&&global&&global.Object===Object&&global,lc=typeof self=="object"&&self&&self.Object===Object&&self,yn=zr||lc||Function("return this")(),Ch=typeof g=="object"&&g&&!g.nodeType&&g,Rn=Ch&&typeof t=="object"&&t&&!t.nodeType&&t,Fa=Rn&&Rn.exports===Ch,Oa=Fa&&zr.process,En=function(){try{var ct=Rn&&Rn.require&&Rn.require("util").types;return ct||Oa&&Oa.binding&&Oa.binding("util")}catch{}}(),Da=En&&En.isArrayBuffer,Ia=En&&En.isDate,Ol=En&&En.isMap,Dl=En&&En.isRegExp,Na=En&&En.isSet,Xs=En&&En.isTypedArray;function $i(ct,St,vt){switch(vt.length){case 0:return ct.call(St);case 1:return ct.call(St,vt[0]);case 2:return ct.call(St,vt[0],vt[1]);case 3:return ct.call(St,vt[0],vt[1],vt[2])}return ct.apply(St,vt)}function Wr(ct,St,vt,Ft){for(var Lt=-1,Ut=ct==null?0:ct.length;++Lt-1}function la(ct,St,vt){for(var Ft=-1,Lt=ct==null?0:ct.length;++Ft-1;);return vt}function po(ct,St){for(var vt=ct.length;vt--&&ts(St,ct[vt],0)>-1;);return vt}function is(ct,St){for(var vt=ct.length,Ft=0;vt--;)ct[vt]===St&&++Ft;return Ft}var zu=ar(Ts),Jo=ar(Ur);function ns(ct){return"\\"+Mh[ct]}function cn(ct,St){return ct==null?i:ct[St]}function Cs(ct){return Yo.test(ct)}function lr(ct){return Uu.test(ct)}function vo(ct){for(var St,vt=[];!(St=ct.next()).done;)vt.push(St.value);return vt}function Ga(ct){var St=-1,vt=Array(ct.size);return ct.forEach(function(Ft,Lt){vt[++St]=[Lt,Ft]}),vt}function Va(ct,St){return function(vt){return ct(St(vt))}}function Qn(ct,St){for(var vt=-1,Ft=ct.length,Lt=0,Ut=[];++vt-1}function Vu(R,N){var k=this.__data__,nt=To(k,R);return nt<0?(++this.size,k.push([R,N])):k[nt][1]=N,this}ks.prototype.clear=Tp,ks.prototype.delete=dc,ks.prototype.get=Ep,ks.prototype.has=Mp,ks.prototype.set=Vu;function ws(R){var N=-1,k=R==null?0:R.length;for(this.clear();++N=N?R:N)),R}function ss(R,N,k,nt,ft,xt){var Ot,Gt=N&h,kt=N&a,fe=N&l;if(k&&(Ot=ft?k(R,nt,ft,xt):k(R)),Ot!==i)return Ot;if(!Dn(R))return R;var ce=Si(R);if(ce){if(Ot=qA(R),!Gt)return Rr(R,Ot)}else{var ye=Yr(R),Ie=ye==rt||ye==gt;if($l(R))return Dc(R,Gt);if(ye==Pt||ye==U||Ie&&!ft){if(Ot=kt||Ie?{}:Z1(R),!Gt)return kt?Gp(R,bp(Ot,R)):Vg(R,xc(Ot,R))}else{if(!Zi[ye])return ft?R:{};Ot=tP(R,ye,Gt)}}xt||(xt=new qn);var je=xt.get(R);if(je)return je;xt.set(R,Ot),MS(R)?R.forEach(function(hi){Ot.add(ss(hi,N,k,hi,R,xt))}):TS(R)&&R.forEach(function(hi,Bi){Ot.set(Bi,ss(hi,N,k,Bi,R,xt))});var li=fe?kt?Ui:Yn:kt?Ls:Lr,Fi=ce?i:li(R);return xn(Fi||R,function(hi,Bi){Fi&&(Bi=hi,hi=R[Bi]),Ks(Ot,Bi,ss(hi,N,k,Bi,R,xt))}),Ot}function Sc(R){var N=Lr(R);return function(k){return Yu(k,R,N)}}function Yu(R,N,k){var nt=k.length;if(R==null)return!nt;for(R=It(R);nt--;){var ft=k[nt],xt=N[ft],Ot=R[ft];if(Ot===i&&!(ft in R)||!xt(Ot))return!1}return!0}function Tc(R,N,k){if(typeof R!="function")throw new $t(s);return Uc(function(){R.apply(i,k)},N)}function tl(R,N,k,nt){var ft=-1,xt=Sr,Ot=!0,Gt=R.length,kt=[],fe=N.length;if(!Gt)return kt;k&&(N=Qi(N,or(k))),nt?(xt=la,Ot=!1):N.length>=T&&(xt=Hn,Ot=!1,N=new So(N));t:for(;++ftft?0:ft+k),nt=nt===i||nt>ft?ft:Ri(nt),nt<0&&(nt+=ft),nt=k>nt?0:wS(nt);k0&&k(Gt)?N>1?hr(Gt,N-1,k,nt,ft):Xr(ft,Gt):nt||(ft[ft.length]=Gt)}return ft}var Hl=nf(),Bh=nf(!0);function as(R,N){return R&&Hl(R,N,Lr)}function Wl(R,N){return R&&Bh(R,N,Lr)}function el(R,N){return Mn(N,function(k){return al(R[k])})}function Zs(R,N){N=Po(N,R);for(var k=0,nt=N.length;R!=null&&kN}function Op(R,N){return R!=null&&me.call(R,N)}function Mc(R,N){return R!=null&&N in It(R)}function zg(R,N,k){return R>=Er(N,k)&&R<_n(N,k)}function Xl(R,N,k){for(var nt=k?la:Sr,ft=R[0].length,xt=R.length,Ot=xt,Gt=vt(xt),kt=1/0,fe=[];Ot--;){var ce=R[Ot];Ot&&N&&(ce=Qi(ce,or(N))),kt=Er(ce.length,kt),Gt[Ot]=!k&&(N||ft>=120&&ce.length>=120)?new So(Ot&&ce):i}ce=R[0];var ye=-1,Ie=Gt[0];t:for(;++ye-1;)Gt!==R&&yo.call(Gt,kt,1),yo.call(R,kt,1);return R}function wr(R,N){for(var k=R?N.length:0,nt=k-1;k--;){var ft=N[k];if(k==nt||ft!==xt){var xt=ft;sl(ft)?yo.call(R,ft,1):Lc(R,ft)}}return R}function va(R,N){return R+bh(fc()*(N-R+1))}function As(R,N,k,nt){for(var ft=-1,xt=_n(Rh((N-R)/(k||1)),0),Ot=vt(xt);xt--;)Ot[nt?xt:++ft]=R,R+=k;return Ot}function Jl(R,N){var k="";if(!R||N<1||N>z)return k;do N%2&&(k+=R),N=bh(N/2),N&&(R+=R);while(N);return k}function ei(R,N){return jg(Q1(R,N,Fs),R+"")}function Dp(R){return Ih(of(R))}function Pc(R,N){var k=of(R);return Wp(k,Eo(N,0,k.length))}function nl(R,N,k,nt){if(!Dn(R))return R;N=Po(N,R);for(var ft=-1,xt=N.length,Ot=xt-1,Gt=R;Gt!=null&&++ftft?0:ft+N),k=k>ft?ft:k,k<0&&(k+=ft),ft=N>k?0:k-N>>>0,N>>>=0;for(var xt=vt(ft);++nt>>1,Ot=R[xt];Ot!==null&&!$s(Ot)&&(k?Ot<=N:Ot=T){var fe=N?null:br(R);if(fe)return Ha(fe);Ot=!1,ft=Hn,kt=new So}else kt=N?[]:Gt;t:for(;++nt=nt?R:ls(R,N,k)}var Up=Ph||function(R){return yn.clearTimeout(R)};function Dc(R,N){if(N)return R.slice();var k=R.length,nt=mo?mo(k):new R.constructor(k);return R.copy(nt),nt}function tf(R){var N=new R.constructor(R.byteLength);return new Cn(N).set(new Cn(R)),N}function Gg(R,N){var k=N?tf(R.buffer):R.buffer;return new R.constructor(k,R.byteOffset,R.byteLength)}function Ps(R){var N=new R.constructor(R.source,Rl.exec(R));return N.lastIndex=R.lastIndex,N}function Ic(R){return Xa?It(Xa.call(R)):{}}function zp(R,N){var k=N?tf(R.buffer):R.buffer;return new R.constructor(k,R.byteOffset,R.length)}function Ka(R,N){if(R!==N){var k=R!==i,nt=R===null,ft=R===R,xt=$s(R),Ot=N!==i,Gt=N===null,kt=N===N,fe=$s(N);if(!Gt&&!fe&&!xt&&R>N||xt&&Ot&&kt&&!Gt&&!fe||nt&&Ot&&kt||!k&&kt||!ft)return 1;if(!nt&&!xt&&!fe&&R=Gt)return kt;var fe=k[nt];return kt*(fe=="desc"?-1:1)}}return R.index-N.index}function bo(R,N,k,nt){for(var ft=-1,xt=R.length,Ot=k.length,Gt=-1,kt=N.length,fe=_n(xt-Ot,0),ce=vt(kt+fe),ye=!nt;++Gt1?k[ft-1]:i,Ot=ft>2?k[2]:i;for(xt=R.length>3&&typeof xt=="function"?(ft--,xt):i,Ot&&us(k[0],k[1],Ot)&&(xt=ft<3?i:xt,ft=1),N=It(N);++nt-1?ft[xt?N[Ot]:Ot]:i}}function it(R){return Ci(function(N){var k=N.length,nt=k,ft=Mr.prototype.thru;for(R&&N.reverse();nt--;){var xt=N[nt];if(typeof xt!="function")throw new $t(s);if(ft&&!Ot&&rf(xt)=="wrapper")var Ot=new Mr([],!0)}for(nt=Ot?nt:k;++nt1&&Vi.reverse(),ce&&ktGt))return!1;var fe=xt.get(R),ce=xt.get(N);if(fe&&ce)return fe==N&&ce==R;var ye=-1,Ie=!0,je=k&u?new So:i;for(xt.set(R,N),xt.set(N,R);++ye1?"& ":"")+N[nt],N=N.join(k>2?", ":" "),R.replace(Bs,`{ /* [wrapped with `+N+`] */ -`)}function iP(R){return Si(R)||jh(R)||!!(hc&&R&&R[hc])}function sl(R,N){var k=typeof R;return N=N??z,!!N&&(k=="number"||k!="symbol"&&te.test(R))&&R>-1&&R%1==0&&R0){if(++N>=b)return arguments[0]}else N=0;return R.apply(i,arguments)}}function Wp(R,N){var k=-1,nt=R.length,ft=nt-1;for(N=N===i?nt:N;++k1?R[N-1]:i;return k=typeof k=="function"?(R.pop(),k):i,hS(R,k)});function uS(R){var N=mt(R);return N.__chain__=!0,N}function dR(R,N){return N(R),R}function Xp(R,N){return N(R)}var pR=Ci(function(R){var N=R.length,k=N?R[0]:0,nt=this.__wrapped__,ft=function(xt){return Xu(xt,R)};return N>1||this.__actions__.length||!(nt instanceof ni)||!sl(k)?this.thru(ft):(nt=nt.slice(k,+k+(N?1:0)),nt.__actions__.push({func:Xp,args:[ft],thisArg:i}),new Mr(nt,this.__chain__).thru(function(xt){return N&&!xt.length&&xt.push(i),xt}))});function vR(){return uS(this)}function mR(){return new Mr(this.value(),this.__chain__)}function gR(){this.__values__===i&&(this.__values__=CS(this.value()));var R=this.__index__>=this.__values__.length,N=R?i:this.__values__[this.__index__++];return{done:R,value:N}}function yR(){return this}function xR(R){for(var N,k=this;k instanceof Dh;){var nt=nS(k);nt.__index__=0,nt.__values__=i,N?ft.__wrapped__=nt:N=nt;var ft=nt;k=k.__wrapped__}return ft.__wrapped__=R,N}function SR(){var R=this.__wrapped__;if(R instanceof ni){var N=R;return this.__actions__.length&&(N=new ni(this)),N=N.reverse(),N.__actions__.push({func:Xp,args:[jg],thisArg:i}),new Mr(N,this.__chain__)}return this.thru(jg)}function TR(){return wo(this.__wrapped__,this.__actions__)}var ER=Yh(function(R,N,k){me.call(R,k)?++R[k]:pa(R,k,1)});function MR(R,N,k){var nt=Si(R)?Ba:Bg;return k&&us(R,N,k)&&(N=i),nt(R,oi(N,3))}function CR(R,N){var k=Si(R)?Mn:Ec;return k(R,oi(N,3))}var wR=$(rS),AR=$(sS);function PR(R,N){return hr(Yp(R,N),1)}function RR(R,N){return hr(Yp(R,N),G)}function bR(R,N,k){return k=k===i?1:Ri(k),hr(Yp(R,N),k)}function fS(R,N){var k=Si(R)?yn:js;return k(R,oi(N,3))}function cS(R,N){var k=Si(R)?Vn:Lp;return k(R,oi(N,3))}var LR=Yh(function(R,N,k){me.call(R,k)?R[k].push(N):pa(R,k,[N])});function FR(R,N,k,nt){R=bs(R)?R:of(R),k=k&&!nt?Ri(k):0;var ft=R.length;return k<0&&(k=_n(ft+k,0)),Jp(R)?k<=ft&&R.indexOf(N,k)>-1:!!ft&&ts(R,N,k)>-1}var OR=ei(function(R,N,k){var nt=-1,ft=typeof N=="function",xt=bs(R)?vt(R.length):[];return js(R,function(Ot){xt[++nt]=ft?$i(N,Ot,k):dn(Ot,N,k)}),xt}),DR=Yh(function(R,N,k){pa(R,k,N)});function Yp(R,N){var k=Si(R)?Qi:il;return k(R,oi(N,3))}function IR(R,N,k,nt){return R==null?[]:(Si(N)||(N=N==null?[]:[N]),k=nt?i:k,Si(k)||(k=k==null?[]:[k]),Vh(R,N,k))}var NR=Yh(function(R,N,k){R[k?0:1].push(N)},function(){return[[],[]]});function BR(R,N,k){var nt=Si(R)?Ua:fa,ft=arguments.length<3;return nt(R,oi(N,4),k,ft,js)}function UR(R,N,k){var nt=Si(R)?Il:fa,ft=arguments.length<3;return nt(R,oi(N,4),k,ft,Lp)}function zR(R,N){var k=Si(R)?Mn:Ec;return k(R,jp(oi(N,3)))}function GR(R){var N=Si(R)?Ih:Dp;return N(R)}function VR(R,N,k){(k?us(R,N,k):N===i)?N=1:N=Ri(N);var nt=Si(R)?mc:Pc;return nt(R,N)}function HR(R){var N=Si(R)?Rp:Np;return N(R)}function WR(R){if(R==null)return 0;if(bs(R))return Jp(R)?V(R):R.length;var N=Yr(R);return N==yt||N==Rt?R.size:Cr(R).length}function XR(R,N,k){var nt=Si(R)?qr:Rc;return k&&us(R,N,k)&&(N=i),nt(R,oi(N,3))}var YR=ei(function(R,N){if(R==null)return[];var k=N.length;return k>1&&us(R,N[0],N[1])?N=[]:k>2&&us(N[0],N[1],N[2])&&(N=[N[0]]),Vh(R,hr(N,1),[])}),kp=sp||function(){return gn.Date.now()};function kR(R,N){if(typeof N!="function")throw new $t(s);return R=Ri(R),function(){if(--R<1)return N.apply(this,arguments)}}function dS(R,N,k){return N=k?i:N,N=R&&N==null?R.length:N,Jt(R,M,i,i,i,i,N)}function pS(R,N){var k;if(typeof N!="function")throw new $t(s);return R=Ri(R),function(){return--R>0&&(k=N.apply(this,arguments)),R<=1&&(N=i),k}}var Jg=ei(function(R,N,k){var nt=f;if(k.length){var ft=Qn(k,sf(Jg));nt|=m}return Jt(R,nt,N,k,ft)}),vS=ei(function(R,N,k){var nt=f|o;if(k.length){var ft=Qn(k,sf(vS));nt|=m}return Jt(N,nt,R,k,ft)});function mS(R,N,k){N=k?i:N;var nt=Jt(R,d,i,i,i,i,i,N);return nt.placeholder=mS.placeholder,nt}function gS(R,N,k){N=k?i:N;var nt=Jt(R,v,i,i,i,i,i,N);return nt.placeholder=gS.placeholder,nt}function yS(R,N,k){var nt,ft,xt,Ot,Gt,kt,fe=0,ce=!1,ye=!1,Ie=!0;if(typeof R!="function")throw new $t(s);N=xa(N)||0,Dn(k)&&(ce=!!k.leading,ye="maxWait"in k,xt=ye?_n(xa(k.maxWait)||0,N):xt,Ie="trailing"in k?!!k.trailing:Ie);function je(er){var Za=nt,ll=ft;return nt=ft=i,fe=er,Ot=R.apply(ll,Za),Ot}function li(er){return fe=er,Gt=Uc(Bi,N),ce?je(er):Ot}function Fi(er){var Za=er-kt,ll=er-fe,US=N-Za;return ye?Er(US,xt-ll):US}function hi(er){var Za=er-kt,ll=er-fe;return kt===i||Za>=N||Za<0||ye&&ll>=xt}function Bi(){var er=kp();if(hi(er))return Vi(er);Gt=Uc(Bi,Fi(er))}function Vi(er){return Gt=i,Ie&&nt?je(er):(nt=ft=i,Ot)}function Qs(){Gt!==i&&Up(Gt),fe=0,nt=kt=ft=Gt=i}function fs(){return Gt===i?Ot:Vi(kp())}function _s(){var er=kp(),Za=hi(er);if(nt=arguments,ft=this,kt=er,Za){if(Gt===i)return li(kt);if(ye)return Up(Gt),Gt=Uc(Bi,N),je(kt)}return Gt===i&&(Gt=Uc(Bi,N)),Ot}return _s.cancel=Qs,_s.flush=fs,_s}var KR=ei(function(R,N){return Tc(R,1,N)}),jR=ei(function(R,N,k){return Tc(R,xa(N)||0,k)});function ZR(R){return Jt(R,C)}function Kp(R,N){if(typeof R!="function"||N!=null&&typeof N!="function")throw new $t(s);var k=function(){var nt=arguments,ft=N?N.apply(this,nt):nt[0],xt=k.cache;if(xt.has(ft))return xt.get(ft);var Ot=R.apply(this,nt);return k.cache=xt.set(ft,Ot)||xt,Ot};return k.cache=new(Kp.Cache||ws),k}Kp.Cache=ws;function jp(R){if(typeof R!="function")throw new $t(s);return function(){var N=arguments;switch(N.length){case 0:return!R.call(this);case 1:return!R.call(this,N[0]);case 2:return!R.call(this,N[0],N[1]);case 3:return!R.call(this,N[0],N[1],N[2])}return!R.apply(this,N)}}function JR(R){return pS(2,R)}var $R=Bp(function(R,N){N=N.length==1&&Si(N[0])?Qi(N[0],or(oi())):Qi(hr(N,1),or(oi()));var k=N.length;return ei(function(nt){for(var ft=-1,xt=Er(nt.length,k);++ft=N}),jh=Ei(function(){return arguments}())?Ei:function(R){return kn(R)&&me.call(R,"callee")&&!go.call(R,"callee")},Si=vt.isArray,f3=Da?or(Da):Wn;function bs(R){return R!=null&&Zp(R.length)&&!al(R)}function tr(R){return kn(R)&&bs(R)}function c3(R){return R===!0||R===!1||kn(R)&&pr(R)==_}var $l=op||o0,d3=Ia?or(Ia):Xn;function p3(R){return kn(R)&&R.nodeType===1&&!zc(R)}function v3(R){if(R==null)return!0;if(bs(R)&&(Si(R)||typeof R=="string"||typeof R.splice=="function"||$l(R)||af(R)||jh(R)))return!R.length;var N=Yr(R);if(N==yt||N==Rt)return!R.size;if(Bc(R))return!Cr(R).length;for(var k in R)if(me.call(R,k))return!1;return!0}function m3(R,N){return Fn(R,N)}function g3(R,N,k){k=typeof k=="function"?k:i;var nt=k?k(R,N):i;return nt===i?Fn(R,N,i,k):!!nt}function Qg(R){if(!kn(R))return!1;var N=pr(R);return N==ot||N==at||typeof R.message=="string"&&typeof R.name=="string"&&!zc(R)}function y3(R){return typeof R=="number"&&uc(R)}function al(R){if(!Dn(R))return!1;var N=pr(R);return N==rt||N==gt||N==J||N==dt}function SS(R){return typeof R=="number"&&R==Ri(R)}function Zp(R){return typeof R=="number"&&R>-1&&R%1==0&&R<=z}function Dn(R){var N=typeof R;return R!=null&&(N=="object"||N=="function")}function kn(R){return R!=null&&typeof R=="object"}var TS=Ol?or(Ol):Yl;function x3(R,N){return R===N||On(R,N,Hg(N))}function S3(R,N,k){return k=typeof k=="function"?k:i,On(R,N,Hg(N),k)}function T3(R){return ES(R)&&R!=+R}function E3(R){if(sP(R))throw new Lt(E);return kl(R)}function M3(R){return R===null}function C3(R){return R==null}function ES(R){return typeof R=="number"||kn(R)&&pr(R)==Et}function zc(R){if(!kn(R)||pr(R)!=Pt)return!1;var N=bn(R);if(N===null)return!0;var k=me.call(N,"constructor")&&N.constructor;return typeof k=="function"&&k instanceof k&&we.call(k)==ui}var _g=Dl?or(Dl):Kl;function w3(R){return SS(R)&&R>=-z&&R<=z}var MS=Na?or(Na):Ku;function Jp(R){return typeof R=="string"||!Si(R)&&kn(R)&&pr(R)==Dt}function $s(R){return typeof R=="symbol"||kn(R)&&pr(R)==Ht}var af=Xs?or(Xs):wc;function A3(R){return R===i}function P3(R){return kn(R)&&Yr(R)==ne}function R3(R){return kn(R)&&pr(R)==oe}var b3=Qe(zh),L3=Qe(function(R,N){return R<=N});function CS(R){if(!R)return[];if(bs(R))return Jp(R)?j(R):Rr(R);if(xo&&R[xo])return vo(R[xo]());var N=Yr(R),k=N==yt?Ga:N==Rt?Ha:of;return k(R)}function ol(R){if(!R)return R===0?R:0;if(R=xa(R),R===G||R===-G){var N=R<0?-1:1;return N*X}return R===R?R:0}function Ri(R){var N=ol(R),k=N%1;return N===N?k?N-k:N:0}function wS(R){return R?Eo(Ri(R),0,Q):0}function xa(R){if(typeof R=="number")return R;if($s(R))return K;if(Dn(R)){var N=typeof R.valueOf=="function"?R.valueOf():R;R=Dn(N)?N+"":N}if(typeof R!="string")return R===0?R:+R;R=Bl(R);var k=jt.test(R);return k||ee.test(R)?Fl(R.slice(2),k?2:8):Tt.test(R)?K:+R}function AS(R){return Rs(R,Ls(R))}function F3(R){return R?Eo(Ri(R),-z,z):R===0?R:0}function tn(R){return R==null?"":Ar(R)}var O3=rl(function(R,N){if(Bc(N)||bs(N)){Rs(N,Lr(N),R);return}for(var k in N)me.call(N,k)&&Ks(R,k,N[k])}),PS=rl(function(R,N){Rs(N,Ls(N),R)}),$p=rl(function(R,N,k,nt){Rs(N,Ls(N),R,nt)}),D3=rl(function(R,N,k,nt){Rs(N,Lr(N),R,nt)}),I3=Ci(Xu);function N3(R,N){var k=Ya(R);return N==null?k:xc(k,N)}var B3=ei(function(R,N){R=It(R);var k=-1,nt=N.length,ft=nt>2?N[2]:i;for(ft&&us(N[0],N[1],ft)&&(nt=1);++k1),xt}),Rs(R,Ui(R),k),nt&&(k=ss(k,h|a|l,Ne));for(var ft=N.length;ft--;)Lc(k,N[ft]);return k});function tb(R,N){return bS(R,jp(oi(N)))}var eb=Ci(function(R,N){return R==null?{}:Hh(R,N)});function bS(R,N){if(R==null)return{};var k=Qi(Ui(R),function(nt){return[nt]});return N=oi(N),Ju(R,k,function(nt,ft){return N(nt,ft[0])})}function ib(R,N,k){N=Po(N,R);var nt=-1,ft=N.length;for(ft||(ft=1,R=i);++ntN){var nt=R;R=N,N=nt}if(k||R%1||N%1){var ft=fc();return Er(R+ft*(N-R+ko("1e-"+((ft+"").length-1))),N)}return va(R,N)}var db=L(function(R,N,k){return N=N.toLowerCase(),R+(k?OS(N):N)});function OS(R){return e0(tn(R).toLowerCase())}function DS(R){return R=tn(R),R&&R.replace(Te,zu).replace(nn,"")}function pb(R,N,k){R=tn(R),N=Ar(N);var nt=R.length;k=k===i?nt:Eo(Ri(k),0,nt);var ft=k;return k-=N.length,k>=0&&R.slice(k,ft)==N}function vb(R){return R=tn(R),R&&Ve.test(R)?R.replace(Me,Jo):R}function mb(R){return R=tn(R),R&&Wi.test(R)?R.replace(di,"\\$&"):R}var gb=L(function(R,N,k){return R+(k?"-":"")+N.toLowerCase()}),yb=L(function(R,N,k){return R+(k?" ":"")+N.toLowerCase()}),xb=Vp("toLowerCase");function Sb(R,N,k){R=tn(R),N=Ri(N);var nt=N?V(R):0;if(!N||nt>=N)return R;var ft=(N-nt)/2;return Ee(bh(ft),k)+R+Ee(Rh(ft),k)}function Tb(R,N,k){R=tn(R),N=Ri(N);var nt=N?V(R):0;return N&&nt>>0,k?(R=tn(R),R&&(typeof N=="string"||N!=null&&!_g(N))&&(N=Ar(N),!N&&Cs(R))?Ro(j(R),0,k):R.split(N,k)):[]}var Rb=L(function(R,N,k){return R+(k?" ":"")+e0(N)});function bb(R,N,k){return R=tn(R),k=k==null?0:Eo(Ri(k),0,R.length),N=Ar(N),R.slice(k,k+N.length)==N}function Lb(R,N,k){var nt=mt.templateSettings;k&&us(R,N,k)&&(N=i),R=tn(R),N=$p({},N,nt,Yt);var ft=$p({},N.imports,nt.imports,Yt),xt=Lr(ft),Ot=$n(ft,xt),Gt,kt,fe=0,ce=N.interpolate||Ue,ye="__p += '",Ie=Kt((N.escape||Ue).source+"|"+ce.source+"|"+(ce===Di?oo:Ue).source+"|"+(N.evaluate||Ue).source+"|$","g"),je="//# sourceURL="+(me.call(N,"sourceURL")?(N.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++xr+"]")+` +`)}function iP(R){return Si(R)||jh(R)||!!(hc&&R&&R[hc])}function sl(R,N){var k=typeof R;return N=N??z,!!N&&(k=="number"||k!="symbol"&&te.test(R))&&R>-1&&R%1==0&&R0){if(++N>=b)return arguments[0]}else N=0;return R.apply(i,arguments)}}function Wp(R,N){var k=-1,nt=R.length,ft=nt-1;for(N=N===i?nt:N;++k1?R[N-1]:i;return k=typeof k=="function"?(R.pop(),k):i,hS(R,k)});function uS(R){var N=mt(R);return N.__chain__=!0,N}function dR(R,N){return N(R),R}function Xp(R,N){return N(R)}var pR=Ci(function(R){var N=R.length,k=N?R[0]:0,nt=this.__wrapped__,ft=function(xt){return Xu(xt,R)};return N>1||this.__actions__.length||!(nt instanceof ni)||!sl(k)?this.thru(ft):(nt=nt.slice(k,+k+(N?1:0)),nt.__actions__.push({func:Xp,args:[ft],thisArg:i}),new Mr(nt,this.__chain__).thru(function(xt){return N&&!xt.length&&xt.push(i),xt}))});function vR(){return uS(this)}function mR(){return new Mr(this.value(),this.__chain__)}function gR(){this.__values__===i&&(this.__values__=CS(this.value()));var R=this.__index__>=this.__values__.length,N=R?i:this.__values__[this.__index__++];return{done:R,value:N}}function yR(){return this}function xR(R){for(var N,k=this;k instanceof Dh;){var nt=nS(k);nt.__index__=0,nt.__values__=i,N?ft.__wrapped__=nt:N=nt;var ft=nt;k=k.__wrapped__}return ft.__wrapped__=R,N}function SR(){var R=this.__wrapped__;if(R instanceof ni){var N=R;return this.__actions__.length&&(N=new ni(this)),N=N.reverse(),N.__actions__.push({func:Xp,args:[Zg],thisArg:i}),new Mr(N,this.__chain__)}return this.thru(Zg)}function TR(){return wo(this.__wrapped__,this.__actions__)}var ER=Yh(function(R,N,k){me.call(R,k)?++R[k]:pa(R,k,1)});function MR(R,N,k){var nt=Si(R)?Ba:Ug;return k&&us(R,N,k)&&(N=i),nt(R,oi(N,3))}function CR(R,N){var k=Si(R)?Mn:Ec;return k(R,oi(N,3))}var wR=$(rS),AR=$(sS);function PR(R,N){return hr(Yp(R,N),1)}function RR(R,N){return hr(Yp(R,N),G)}function bR(R,N,k){return k=k===i?1:Ri(k),hr(Yp(R,N),k)}function fS(R,N){var k=Si(R)?xn:js;return k(R,oi(N,3))}function cS(R,N){var k=Si(R)?Vn:Lp;return k(R,oi(N,3))}var LR=Yh(function(R,N,k){me.call(R,k)?R[k].push(N):pa(R,k,[N])});function FR(R,N,k,nt){R=bs(R)?R:of(R),k=k&&!nt?Ri(k):0;var ft=R.length;return k<0&&(k=_n(ft+k,0)),Jp(R)?k<=ft&&R.indexOf(N,k)>-1:!!ft&&ts(R,N,k)>-1}var OR=ei(function(R,N,k){var nt=-1,ft=typeof N=="function",xt=bs(R)?vt(R.length):[];return js(R,function(Ot){xt[++nt]=ft?$i(N,Ot,k):dn(Ot,N,k)}),xt}),DR=Yh(function(R,N,k){pa(R,k,N)});function Yp(R,N){var k=Si(R)?Qi:il;return k(R,oi(N,3))}function IR(R,N,k,nt){return R==null?[]:(Si(N)||(N=N==null?[]:[N]),k=nt?i:k,Si(k)||(k=k==null?[]:[k]),Vh(R,N,k))}var NR=Yh(function(R,N,k){R[k?0:1].push(N)},function(){return[[],[]]});function BR(R,N,k){var nt=Si(R)?Ua:fa,ft=arguments.length<3;return nt(R,oi(N,4),k,ft,js)}function UR(R,N,k){var nt=Si(R)?Il:fa,ft=arguments.length<3;return nt(R,oi(N,4),k,ft,Lp)}function zR(R,N){var k=Si(R)?Mn:Ec;return k(R,jp(oi(N,3)))}function GR(R){var N=Si(R)?Ih:Dp;return N(R)}function VR(R,N,k){(k?us(R,N,k):N===i)?N=1:N=Ri(N);var nt=Si(R)?mc:Pc;return nt(R,N)}function HR(R){var N=Si(R)?Rp:Np;return N(R)}function WR(R){if(R==null)return 0;if(bs(R))return Jp(R)?V(R):R.length;var N=Yr(R);return N==yt||N==Rt?R.size:Cr(R).length}function XR(R,N,k){var nt=Si(R)?qr:Rc;return k&&us(R,N,k)&&(N=i),nt(R,oi(N,3))}var YR=ei(function(R,N){if(R==null)return[];var k=N.length;return k>1&&us(R,N[0],N[1])?N=[]:k>2&&us(N[0],N[1],N[2])&&(N=[N[0]]),Vh(R,hr(N,1),[])}),kp=sp||function(){return yn.Date.now()};function kR(R,N){if(typeof N!="function")throw new $t(s);return R=Ri(R),function(){if(--R<1)return N.apply(this,arguments)}}function dS(R,N,k){return N=k?i:N,N=R&&N==null?R.length:N,Jt(R,M,i,i,i,i,N)}function pS(R,N){var k;if(typeof N!="function")throw new $t(s);return R=Ri(R),function(){return--R>0&&(k=N.apply(this,arguments)),R<=1&&(N=i),k}}var $g=ei(function(R,N,k){var nt=f;if(k.length){var ft=Qn(k,sf($g));nt|=m}return Jt(R,nt,N,k,ft)}),vS=ei(function(R,N,k){var nt=f|o;if(k.length){var ft=Qn(k,sf(vS));nt|=m}return Jt(N,nt,R,k,ft)});function mS(R,N,k){N=k?i:N;var nt=Jt(R,d,i,i,i,i,i,N);return nt.placeholder=mS.placeholder,nt}function gS(R,N,k){N=k?i:N;var nt=Jt(R,v,i,i,i,i,i,N);return nt.placeholder=gS.placeholder,nt}function yS(R,N,k){var nt,ft,xt,Ot,Gt,kt,fe=0,ce=!1,ye=!1,Ie=!0;if(typeof R!="function")throw new $t(s);N=xa(N)||0,Dn(k)&&(ce=!!k.leading,ye="maxWait"in k,xt=ye?_n(xa(k.maxWait)||0,N):xt,Ie="trailing"in k?!!k.trailing:Ie);function je(er){var Za=nt,ll=ft;return nt=ft=i,fe=er,Ot=R.apply(ll,Za),Ot}function li(er){return fe=er,Gt=Uc(Bi,N),ce?je(er):Ot}function Fi(er){var Za=er-kt,ll=er-fe,US=N-Za;return ye?Er(US,xt-ll):US}function hi(er){var Za=er-kt,ll=er-fe;return kt===i||Za>=N||Za<0||ye&&ll>=xt}function Bi(){var er=kp();if(hi(er))return Vi(er);Gt=Uc(Bi,Fi(er))}function Vi(er){return Gt=i,Ie&&nt?je(er):(nt=ft=i,Ot)}function Qs(){Gt!==i&&Up(Gt),fe=0,nt=kt=ft=Gt=i}function fs(){return Gt===i?Ot:Vi(kp())}function _s(){var er=kp(),Za=hi(er);if(nt=arguments,ft=this,kt=er,Za){if(Gt===i)return li(kt);if(ye)return Up(Gt),Gt=Uc(Bi,N),je(kt)}return Gt===i&&(Gt=Uc(Bi,N)),Ot}return _s.cancel=Qs,_s.flush=fs,_s}var KR=ei(function(R,N){return Tc(R,1,N)}),jR=ei(function(R,N,k){return Tc(R,xa(N)||0,k)});function ZR(R){return Jt(R,C)}function Kp(R,N){if(typeof R!="function"||N!=null&&typeof N!="function")throw new $t(s);var k=function(){var nt=arguments,ft=N?N.apply(this,nt):nt[0],xt=k.cache;if(xt.has(ft))return xt.get(ft);var Ot=R.apply(this,nt);return k.cache=xt.set(ft,Ot)||xt,Ot};return k.cache=new(Kp.Cache||ws),k}Kp.Cache=ws;function jp(R){if(typeof R!="function")throw new $t(s);return function(){var N=arguments;switch(N.length){case 0:return!R.call(this);case 1:return!R.call(this,N[0]);case 2:return!R.call(this,N[0],N[1]);case 3:return!R.call(this,N[0],N[1],N[2])}return!R.apply(this,N)}}function JR(R){return pS(2,R)}var $R=Bp(function(R,N){N=N.length==1&&Si(N[0])?Qi(N[0],or(oi())):Qi(hr(N,1),or(oi()));var k=N.length;return ei(function(nt){for(var ft=-1,xt=Er(nt.length,k);++ft=N}),jh=Ei(function(){return arguments}())?Ei:function(R){return kn(R)&&me.call(R,"callee")&&!go.call(R,"callee")},Si=vt.isArray,f3=Da?or(Da):Wn;function bs(R){return R!=null&&Zp(R.length)&&!al(R)}function tr(R){return kn(R)&&bs(R)}function c3(R){return R===!0||R===!1||kn(R)&&pr(R)==_}var $l=op||l0,d3=Ia?or(Ia):Xn;function p3(R){return kn(R)&&R.nodeType===1&&!zc(R)}function v3(R){if(R==null)return!0;if(bs(R)&&(Si(R)||typeof R=="string"||typeof R.splice=="function"||$l(R)||af(R)||jh(R)))return!R.length;var N=Yr(R);if(N==yt||N==Rt)return!R.size;if(Bc(R))return!Cr(R).length;for(var k in R)if(me.call(R,k))return!1;return!0}function m3(R,N){return Fn(R,N)}function g3(R,N,k){k=typeof k=="function"?k:i;var nt=k?k(R,N):i;return nt===i?Fn(R,N,i,k):!!nt}function _g(R){if(!kn(R))return!1;var N=pr(R);return N==ot||N==at||typeof R.message=="string"&&typeof R.name=="string"&&!zc(R)}function y3(R){return typeof R=="number"&&uc(R)}function al(R){if(!Dn(R))return!1;var N=pr(R);return N==rt||N==gt||N==J||N==dt}function SS(R){return typeof R=="number"&&R==Ri(R)}function Zp(R){return typeof R=="number"&&R>-1&&R%1==0&&R<=z}function Dn(R){var N=typeof R;return R!=null&&(N=="object"||N=="function")}function kn(R){return R!=null&&typeof R=="object"}var TS=Ol?or(Ol):Yl;function x3(R,N){return R===N||On(R,N,Wg(N))}function S3(R,N,k){return k=typeof k=="function"?k:i,On(R,N,Wg(N),k)}function T3(R){return ES(R)&&R!=+R}function E3(R){if(sP(R))throw new Lt(E);return kl(R)}function M3(R){return R===null}function C3(R){return R==null}function ES(R){return typeof R=="number"||kn(R)&&pr(R)==Et}function zc(R){if(!kn(R)||pr(R)!=Pt)return!1;var N=bn(R);if(N===null)return!0;var k=me.call(N,"constructor")&&N.constructor;return typeof k=="function"&&k instanceof k&&we.call(k)==ui}var qg=Dl?or(Dl):Kl;function w3(R){return SS(R)&&R>=-z&&R<=z}var MS=Na?or(Na):Ku;function Jp(R){return typeof R=="string"||!Si(R)&&kn(R)&&pr(R)==Dt}function $s(R){return typeof R=="symbol"||kn(R)&&pr(R)==Ht}var af=Xs?or(Xs):wc;function A3(R){return R===i}function P3(R){return kn(R)&&Yr(R)==ne}function R3(R){return kn(R)&&pr(R)==oe}var b3=Qe(zh),L3=Qe(function(R,N){return R<=N});function CS(R){if(!R)return[];if(bs(R))return Jp(R)?j(R):Rr(R);if(xo&&R[xo])return vo(R[xo]());var N=Yr(R),k=N==yt?Ga:N==Rt?Ha:of;return k(R)}function ol(R){if(!R)return R===0?R:0;if(R=xa(R),R===G||R===-G){var N=R<0?-1:1;return N*X}return R===R?R:0}function Ri(R){var N=ol(R),k=N%1;return N===N?k?N-k:N:0}function wS(R){return R?Eo(Ri(R),0,Q):0}function xa(R){if(typeof R=="number")return R;if($s(R))return K;if(Dn(R)){var N=typeof R.valueOf=="function"?R.valueOf():R;R=Dn(N)?N+"":N}if(typeof R!="string")return R===0?R:+R;R=Bl(R);var k=jt.test(R);return k||ee.test(R)?Fl(R.slice(2),k?2:8):Tt.test(R)?K:+R}function AS(R){return Rs(R,Ls(R))}function F3(R){return R?Eo(Ri(R),-z,z):R===0?R:0}function tn(R){return R==null?"":Ar(R)}var O3=rl(function(R,N){if(Bc(N)||bs(N)){Rs(N,Lr(N),R);return}for(var k in N)me.call(N,k)&&Ks(R,k,N[k])}),PS=rl(function(R,N){Rs(N,Ls(N),R)}),$p=rl(function(R,N,k,nt){Rs(N,Ls(N),R,nt)}),D3=rl(function(R,N,k,nt){Rs(N,Lr(N),R,nt)}),I3=Ci(Xu);function N3(R,N){var k=Ya(R);return N==null?k:xc(k,N)}var B3=ei(function(R,N){R=It(R);var k=-1,nt=N.length,ft=nt>2?N[2]:i;for(ft&&us(N[0],N[1],ft)&&(nt=1);++k1),xt}),Rs(R,Ui(R),k),nt&&(k=ss(k,h|a|l,Ne));for(var ft=N.length;ft--;)Lc(k,N[ft]);return k});function tb(R,N){return bS(R,jp(oi(N)))}var eb=Ci(function(R,N){return R==null?{}:Hh(R,N)});function bS(R,N){if(R==null)return{};var k=Qi(Ui(R),function(nt){return[nt]});return N=oi(N),Ju(R,k,function(nt,ft){return N(nt,ft[0])})}function ib(R,N,k){N=Po(N,R);var nt=-1,ft=N.length;for(ft||(ft=1,R=i);++ntN){var nt=R;R=N,N=nt}if(k||R%1||N%1){var ft=fc();return Er(R+ft*(N-R+ko("1e-"+((ft+"").length-1))),N)}return va(R,N)}var db=L(function(R,N,k){return N=N.toLowerCase(),R+(k?OS(N):N)});function OS(R){return i0(tn(R).toLowerCase())}function DS(R){return R=tn(R),R&&R.replace(Te,zu).replace(nn,"")}function pb(R,N,k){R=tn(R),N=Ar(N);var nt=R.length;k=k===i?nt:Eo(Ri(k),0,nt);var ft=k;return k-=N.length,k>=0&&R.slice(k,ft)==N}function vb(R){return R=tn(R),R&&Ve.test(R)?R.replace(Me,Jo):R}function mb(R){return R=tn(R),R&&Wi.test(R)?R.replace(di,"\\$&"):R}var gb=L(function(R,N,k){return R+(k?"-":"")+N.toLowerCase()}),yb=L(function(R,N,k){return R+(k?" ":"")+N.toLowerCase()}),xb=Vp("toLowerCase");function Sb(R,N,k){R=tn(R),N=Ri(N);var nt=N?V(R):0;if(!N||nt>=N)return R;var ft=(N-nt)/2;return Ee(bh(ft),k)+R+Ee(Rh(ft),k)}function Tb(R,N,k){R=tn(R),N=Ri(N);var nt=N?V(R):0;return N&&nt>>0,k?(R=tn(R),R&&(typeof N=="string"||N!=null&&!qg(N))&&(N=Ar(N),!N&&Cs(R))?Ro(j(R),0,k):R.split(N,k)):[]}var Rb=L(function(R,N,k){return R+(k?" ":"")+i0(N)});function bb(R,N,k){return R=tn(R),k=k==null?0:Eo(Ri(k),0,R.length),N=Ar(N),R.slice(k,k+N.length)==N}function Lb(R,N,k){var nt=mt.templateSettings;k&&us(R,N,k)&&(N=i),R=tn(R),N=$p({},N,nt,Yt);var ft=$p({},N.imports,nt.imports,Yt),xt=Lr(ft),Ot=$n(ft,xt),Gt,kt,fe=0,ce=N.interpolate||Ue,ye="__p += '",Ie=Kt((N.escape||Ue).source+"|"+ce.source+"|"+(ce===Di?oo:Ue).source+"|"+(N.evaluate||Ue).source+"|$","g"),je="//# sourceURL="+(me.call(N,"sourceURL")?(N.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++xr+"]")+` `;R.replace(Ie,function(hi,Bi,Vi,Qs,fs,_s){return Vi||(Vi=Qs),ye+=R.slice(fe,_s).replace(We,ns),Bi&&(Gt=!0,ye+=`' + __e(`+Bi+`) + '`),fs&&(kt=!0,ye+=`'; @@ -6381,7 +6381,7 @@ __p += '`),Vi&&(ye+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+ye+`return __p -}`;var Fi=NS(function(){return Ut(xt,je+"return "+ye).apply(i,Ot)});if(Fi.source=ye,Qg(Fi))throw Fi;return Fi}function Fb(R){return tn(R).toLowerCase()}function Ob(R){return tn(R).toUpperCase()}function Db(R,N,k){if(R=tn(R),R&&(k||N===i))return Bl(R);if(!R||!(N=Ar(N)))return R;var nt=j(R),ft=j(N),xt=_i(nt,ft),Ot=po(nt,ft)+1;return Ro(nt,xt,Ot).join("")}function Ib(R,N,k){if(R=tn(R),R&&(k||N===i))return R.slice(0,et(R)+1);if(!R||!(N=Ar(N)))return R;var nt=j(R),ft=po(nt,j(N))+1;return Ro(nt,0,ft).join("")}function Nb(R,N,k){if(R=tn(R),R&&(k||N===i))return R.replace(Pa,"");if(!R||!(N=Ar(N)))return R;var nt=j(R),ft=_i(nt,j(N));return Ro(nt,ft).join("")}function Bb(R,N){var k=A,nt=P;if(Dn(N)){var ft="separator"in N?N.separator:ft;k="length"in N?Ri(N.length):k,nt="omission"in N?Ar(N.omission):nt}R=tn(R);var xt=R.length;if(Cs(R)){var Ot=j(R);xt=Ot.length}if(k>=xt)return R;var Gt=k-V(nt);if(Gt<1)return nt;var kt=Ot?Ro(Ot,0,Gt).join(""):R.slice(0,Gt);if(ft===i)return kt+nt;if(Ot&&(Gt+=kt.length-Gt),_g(ft)){if(R.slice(Gt).search(ft)){var fe,ce=kt;for(ft.global||(ft=Kt(ft.source,tn(Rl.exec(ft))+"g")),ft.lastIndex=0;fe=ft.exec(ce);)var ye=fe.index;kt=kt.slice(0,ye===i?Gt:ye)}}else if(R.indexOf(Ar(ft),Gt)!=Gt){var Ie=kt.lastIndexOf(ft);Ie>-1&&(kt=kt.slice(0,Ie))}return kt+nt}function Ub(R){return R=tn(R),R&&Ce.test(R)?R.replace(bt,st):R}var zb=L(function(R,N,k){return R+(k?" ":"")+N.toUpperCase()}),e0=Vp("toUpperCase");function IS(R,N,k){return R=tn(R),N=k?i:N,N===i?lr(R)?Mt(R):Ko(R):R.match(N)||[]}var NS=ei(function(R,N){try{return $i(R,i,N)}catch(k){return Qg(k)?k:new Lt(k)}}),Gb=Ci(function(R,N){return yn(N,function(k){k=Lo(k),pa(R,k,Jg(R[k],R))}),R});function Vb(R){var N=R==null?0:R.length,k=oi();return R=N?Qi(R,function(nt){if(typeof nt[1]!="function")throw new $t(s);return[k(nt[0]),nt[1]]}):[],ei(function(nt){for(var ft=-1;++ftz)return[];var k=Q,nt=Er(R,Q);N=oi(N),R-=Q;for(var ft=Ms(nt,N);++k0||N<0)?new ni(k):(R<0?k=k.takeRight(-R):R&&(k=k.drop(R)),N!==i&&(N=Ri(N),k=N<0?k.dropRight(-N):k.take(N-R)),k)},ni.prototype.takeRightWhile=function(R){return this.reverse().takeWhile(R).reverse()},ni.prototype.toArray=function(){return this.take(Q)},as(ni.prototype,function(R,N){var k=/^(?:filter|find|map|reject)|While$/.test(N),nt=/^(?:head|last)$/.test(N),ft=mt[nt?"take"+(N=="last"?"Right":""):N],xt=nt||/^find/.test(N);ft&&(mt.prototype[N]=function(){var Ot=this.__wrapped__,Gt=nt?[1]:arguments,kt=Ot instanceof ni,fe=Gt[0],ce=kt||Si(Ot),ye=function(Bi){var Vi=ft.apply(mt,Xr([Bi],Gt));return nt&&Ie?Vi[0]:Vi};ce&&k&&typeof fe=="function"&&fe.length!=1&&(kt=ce=!1);var Ie=this.__chain__,je=!!this.__actions__.length,li=xt&&!Ie,Fi=kt&&!je;if(!xt&&ce){Ot=Fi?Ot:new ni(this);var hi=R.apply(Ot,Gt);return hi.__actions__.push({func:Xp,args:[ye],thisArg:i}),new Mr(hi,Ie)}return li&&Fi?R.apply(this,Gt):(hi=this.thru(ye),li?nt?hi.value()[0]:hi.value():hi)})}),yn(["pop","push","shift","sort","splice","unshift"],function(R){var N=se[R],k=/^(?:push|sort|unshift)$/.test(R)?"tap":"thru",nt=/^(?:pop|shift)$/.test(R);mt.prototype[R]=function(){var ft=arguments;if(nt&&!this.__chain__){var xt=this.value();return N.apply(Si(xt)?xt:[],ft)}return this[k](function(Ot){return N.apply(Si(Ot)?Ot:[],ft)})}}),as(ni.prototype,function(R,N){var k=mt[N];if(k){var nt=k.name+"";me.call(_o,nt)||(_o[nt]=[]),_o[nt].push({name:N,func:k})}}),_o[lt(i,o).name]=[{name:"wrapper",func:i}],ni.prototype.clone=Fg,ni.prototype.reverse=Og,ni.prototype.value=rs,mt.prototype.at=pR,mt.prototype.chain=vR,mt.prototype.commit=mR,mt.prototype.next=gR,mt.prototype.plant=xR,mt.prototype.reverse=SR,mt.prototype.toJSON=mt.prototype.valueOf=mt.prototype.value=TR,mt.prototype.first=mt.prototype.head,xo&&(mt.prototype[xo]=yR),mt},zt=Nt();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(gn._=zt,define(function(){return zt})):Rn?((Rn.exports=zt)._=zt,Ch._=zt):gn._=zt}).call(g)}),IC=class extends Set{constructor(g,t=!1){super(g),this.valuesAsFlags=t}};function ld(g){if(g instanceof Map)return Object.fromEntries([...g.entries()].map(([t,i])=>[t,ld(i)]));if(g instanceof Set)return Array.from(g.values()).map(ld);if(g instanceof IC)return{values:[...g.values()],valuesAsFlags:g.valuesAsFlags};if(typeof g=="object"){let t={};return Object.entries(g).forEach(([i,x])=>{t[i]=ld(x)}),t}else return g}Zx(Jx(),1);var I4=Zx(Jx(),1);function lu(g,t){if(typeof g!="object")throw new Error(`Cannot merge into non-object objectToMergeWith. Received: ${JSON.stringify(g)}`);if(typeof t!="object")throw new Error(`Cannot merge using non-object objectToMergeWith. Received: ${JSON.stringify(t)}`);let i=(0,I4.cloneDeep)(g);for(let[x,T]of Object.entries(t))typeof T!="object"||T instanceof Set||i[x]===void 0?i[x]=T:i[x]=lu(i[x],T);return i}function NC(g,t){if(!(g===void 0||typeof g!="object"))for(let i of Object.keys(g)){if(i===t)return g[i];let x=g[i];if(typeof x=="object"){let T=NC(x,t);if(T!==void 0)return T}}}var p0="@composite:",N4="@inherit:",B4=class{constructor(g,t,i){this.tiledClassToMembersMap=g,this.enumNameToValuesMap=t,this.parserOptions=i,this.memoiser=new Map}flattenMembers(g,t){return this.memoiser.has(g)?{[g]:this.memoiser.get(g)}:(this.memoiser.set(g,t.reduce((i,x)=>An(An({},i),this.flattenMemberProperty(x)),{})),{[g]:this.memoiser.get(g)})}flattenMemberProperty(g){var t;let i=(t=g.propertyType)!=null?t:g.propertytype;if(g.type==="class"){if(!this.memoiser.has(i)){let E=this.tiledClassToMembersMap.get(i).reduce((s,y)=>lu(this.flattenMemberProperty(y),s),{});this.memoiser.set(i,E)}let x=this.memoiser.get(i),T=lu(x,this.flattenValue(g.value,x));return this.checkIfShouldFlatten(g.name)?T:{[g.name.replace(p0,"")]:T}}else return this.enumNameToValuesMap.has(i)?this.enumNameToValuesMap.get(i).valuesAsFlags?{[g.name]:new Set(g.value.split(",").filter(x=>x!==""))}:{[g.name]:g.value}:{[g.name]:g.value}}get memoisedFlattenedProperties(){return this.memoiser}flattenValue(g,t){return Object.entries(g).reduce((i,[x,T])=>{if(typeof T!="object")return NC(t,x)instanceof Set?lu({[x]:new Set(T.split(",").filter(E=>E!==""))},i):lu({[x]:T},i);if(this.checkIfShouldFlatten(x))return lu(this.flattenValue(T,t),i);{let E=x.replace(p0,"");return lu({[E]:this.flattenValue(T,t)},i)}},{})}checkIfShouldFlatten(g){var t;return((t=this.parserOptions)==null?void 0:t.defaultComposite)===!0?g.startsWith(N4):!g.startsWith(p0)}},uT=Zx(Jx(),1),U4=class{constructor(g){this.flattener=g}flattenPropertiesOnObject(g){var t,i,x,T;return dh(An(An({},this.flattener.memoisedFlattenedProperties.get((t=g.class)!=null?t:g.type)),(i=g.properties)==null?void 0:i.reduce((E,s)=>An(An({},E),this.flattener.flattenMemberProperty(s)),{})),{name:g.name,id:g.id,class:(T=(x=g.class)!=null?x:g.type)!=null?T:null,x:g.x,y:g.y})}flattenPropertiesOnTile(g){var t,i,x,T;return dh(An(An({},this.flattener.memoisedFlattenedProperties.get((t=g.class)!=null?t:g.type)),(i=g.properties)==null?void 0:i.reduce((E,s)=>An(An({},E),this.flattener.flattenMemberProperty(s)),{})),{id:g.id,class:(T=(x=g.class)!=null?x:g.type)!=null?T:null})}getCustomTypesMap(){return new Map([...this.flattener.memoisedFlattenedProperties.entries()].map(([g,t])=>[g,(0,uT.cloneDeep)(t)]))}getEnumsMap(){return new Map([...this.flattener.enumNameToValuesMap.entries()].map(([g,t])=>[g,(0,uT.cloneDeep)(t)]))}toJSON(){return JSON.stringify({customTypes:ld(this.getCustomTypesMap()),enums:ld(this.getEnumsMap())},null,4)}};function z4(g,t){let i=new Map(g.propertyTypes.filter(E=>E.type==="enum").map(E=>[E.name,new IC(E.values,E.valuesAsFlags)])),x=new Map(g.propertyTypes.filter(E=>E.type==="class").map(E=>[E.name,E.members])),T=new B4(x,i,t);return x.forEach((E,s)=>{T.flattenMembers(s,E)}),new U4(T)}var G4={parse:z4},BC=class{constructor(g,t){this.phaserTile=g,this.tiledProject=t}getProperty(g){var t,i;let x={};if(this.tiledProject){let T=G4.parse(this.tiledProject),E=this.getType();if(E){let s=(t=T.getCustomTypesMap())==null?void 0:t.get(E);if(s)for(let[y,e]of Object.entries(s))x[y]=e}}return(i=this.phaserTile.properties[g])!=null?i:x[g]}hasProperty(g){return this.getProperty(g)!=null}getType(){var g,t;return(t=(g=this.phaserTile.tileset)==null?void 0:g.tileData[this.phaserTile.index-1])==null?void 0:t.type}},V4=class{constructor(g,t){this.phaserTilemapLayer=g,this.tiledProject=t}getName(){return this.phaserTilemapLayer.layer.name}getProperty(g){let t=this.phaserTilemapLayer.layer.properties,i=t?.find(x=>x.name==g);return i?.value}hasProperty(g){return this.getProperty(g)!=null}isCharLayer(){return this.hasProperty(Qv)}getData(){return this.phaserTilemapLayer.layer.data.map(g=>g.map(t=>new BC(t,this.tiledProject)))}},H4=class{constructor(g,t){this.phaserTilemap=g,this.tiledProject=t;for(let i of this.phaserTilemap.layers)if(i.tilemapLayer==null)throw new Error(`Error initializing tilemap. Layer '${i.name}' has no 'tilemapLayer'. This can happen if you call 'createLayer' with the wrong layer ID.`)}getTileWidth(){return this.phaserTilemap.tileWidth}getTileHeight(){return this.phaserTilemap.tileHeight}getWidth(){return this.phaserTilemap.width}getHeight(){return this.phaserTilemap.height}getOrientation(){return this.phaserTilemap.orientation==Phaser.Tilemaps.Orientation.ISOMETRIC.toString()?"isometric":"orthogonal"}getLayers(){return this.phaserTilemap.layers.map(g=>new V4(g.tilemapLayer,this.tiledProject))}hasTileAt(g,t,i){return!!this.phaserTilemap.hasTileAt(g,t,i)}getTileAt(g,t,i){let x=this.phaserTilemap.getTileAt(g,t,!1,i);if(x)return new BC(x,this.tiledProject)}},UC=class Py{constructor(t){this.scene=t,this.geHeadless=new M4(!1),this.isCreatedInternal=!1,Py.welcomeMessagePrinted||(console.log(`Using GridEngine Phaser Plugin v${RC}`),Py.welcomeMessagePrinted=!0),this.scene.sys.events.once("boot",this.boot,this)}boot(){this.scene.sys.events.on("update",this.update,this)}getCharLayer(t){return this.geHeadless.getCharLayer(t)}getTransition(t,i){return this.geHeadless.getTransition(t,i)}setTransition(t,i,x){this.geHeadless.setTransition(t,i,x)}create(t,i){this.geHeadless.create(new H4(t,i.tiledProject),i),this.isCreatedInternal=!0,this.gridCharacters=new Map;let x=this.setConfigDefaults(i);this.config=x,this.gridTilemap=new Ay(t),this.addCharacters()}getPosition(t){return this.geHeadless.getPosition(t)}move(t,i){this.geHeadless.move(t,i)}moveRandomly(t,i=0,x=-1){this.geHeadless.moveRandomly(t,i,x)}getMovement(t){return this.geHeadless.getMovement(t)}moveTo(t,i,x){return this.geHeadless.moveTo(t,i,x)}stopMovement(t){this.geHeadless.stopMovement(t)}setSpeed(t,i){this.geHeadless.setSpeed(t,i)}getSpeed(t){return this.geHeadless.getSpeed(t)}setContainer(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.setContainer(i)}getContainer(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getContainer()}getOffsetX(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getOffsetX()}setOffsetX(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.setOffsetX(i)}getOffsetY(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getOffsetY()}setOffsetY(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.setOffsetY(i)}collidesWithTiles(t){return this.geHeadless.collidesWithTiles(t)}getWalkingAnimationMapping(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);let T=x.getAnimation();return T?.getWalkingAnimationMapping()}hasLayerOverlay(){var t;return this.initGuard(),!!((t=this.config)!=null&&t.layerOverlay)}setWalkingAnimationMapping(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);let E=T.getAnimation();E?.setWalkingAnimationMapping(i)}update(t,i){if(this.isCreatedInternal&&this.gridCharacters)for(let[x,T]of this.gridCharacters)T.update(i);this.geHeadless.update(t,i)}addCharacter(t){this.geHeadless.addCharacter(t),this.addCharacterInternal(t)}hasCharacter(t){return this.geHeadless.hasCharacter(t)}removeCharacter(t){var i,x;this.initGuard();let T=(i=this.gridCharacters)==null?void 0:i.get(t);if(!T)throw this.createCharUnknownErr(t);T.destroy(),(x=this.gridCharacters)==null||x.delete(t),this.geHeadless.removeCharacter(t)}removeAllCharacters(){if(this.initGuard(),!!this.gridCharacters){for(let t of this.gridCharacters.keys())this.removeCharacter(t);this.geHeadless.removeAllCharacters()}}getAllCharacters(t){return this.geHeadless.getAllCharacters(t)}getLabels(t){return this.geHeadless.getLabels(t)}addLabels(t,i){this.geHeadless.addLabels(t,i)}removeLabels(t,i){this.geHeadless.removeLabels(t,i)}clearLabels(t){this.geHeadless.clearLabels(t)}follow(t,i,x,T){let E;x===void 0?E={distance:0,closestPointIfBlocked:!1}:typeof x=="number"?(E={distance:x,closestPointIfBlocked:!1},T&&(E.closestPointIfBlocked=!0)):E=x,this.geHeadless.follow(t,i,E)}isMoving(t){return this.geHeadless.isMoving(t)}getFacingDirection(t){return this.geHeadless.getFacingDirection(t)}getFacingPosition(t){return this.geHeadless.getFacingPosition(t)}turnTowards(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.turnTowards(i),this.geHeadless.turnTowards(t,i)}getCharactersAt(t,i){return this.geHeadless.getCharactersAt(t,i)}setPosition(t,i,x){this.geHeadless.setPosition(t,i,x)}getSprite(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getSprite()}setSprite(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);i.setOrigin(0,0),T.setSprite(i)}isBlocked(t,i,x=["geDefault"]){return this.geHeadless.isBlocked(t,i,x)}isTileBlocked(t,i){return this.geHeadless.isTileBlocked(t,i)}getCollisionGroups(t){return this.geHeadless.getCollisionGroups(t)}setCollisionGroups(t,i){this.geHeadless.setCollisionGroups(t,i)}getIgnoreCollisionGroups(t){return this.geHeadless.getIgnoreCollisionGroups(t)}setIgnoreCollisionGroups(t,i){this.geHeadless.setIgnoreCollisionGroups(t,i)}getTilePosInDirection(t,i,x){return this.geHeadless.getTilePosInDirection(t,i,x)}findShortestPath(t,i,x={}){return this.geHeadless.findShortestPath(t,i,x)}steppedOn(t,i,x){return this.geHeadless.steppedOn(t,i,x)}characterShifted(){return this.geHeadless.characterShifted()}movementStarted(){return this.geHeadless.movementStarted()}movementStopped(){return this.geHeadless.movementStopped()}directionChanged(){return this.geHeadless.directionChanged()}positionChangeStarted(){return this.geHeadless.positionChangeStarted()}positionChangeFinished(){return this.geHeadless.positionChangeFinished()}getMovementProgress(t){return this.geHeadless.getMovementProgress(t)}rebuildTileCollisionCache(t,i,x,T){this.geHeadless.rebuildTileCollisionCache(t,i,x,T)}addQueueMovements(t,i,x){this.geHeadless.addQueueMovements(t,i,x)}getEnqueuedMovements(t){return this.geHeadless.getEnqueuedMovements(t)}queueMovementFinished(){return this.geHeadless.queueMovementFinished()}clearEnqueuedMovements(t){return this.geHeadless.clearEnqueuedMovements(t)}getState(){return{characters:this.geHeadless.getState().characters.map(t=>dh(An({},t),{offsetX:this.getOffsetX(t.id),offsetY:this.getOffsetY(t.id)}))}}setState(t){if(this.geHeadless.setState(t),this.gridCharacters)for(let i of t.characters){let x=this.gridCharacters.get(i.id);x&&(x.setOffsetX(i.offsetX),x.setOffsetY(i.offsetY))}}getTileCost(t,i,x){return this.initGuard(),this.geHeadless.getTileCost(t,i,x)}setConfigDefaults(t){return An({collisionTilePropertyName:"ge_collide",numberOfDirections:4,characterCollisionStrategy:"BLOCK_TWO_TILES",layerOverlay:!1,cacheTileCollisions:!1},t)}initGuard(){if(!this.isCreatedInternal)throw this.createUninitializedErr()}createUninitializedErr(){throw new Error("GridEngine not initialized. You need to call create() first.")}addCharacters(){var t;(t=this.config)==null||t.characters.forEach(i=>this.addCharacterInternal(i))}createCharUnknownErr(t){return new Error(`Character unknown: ${t}`)}addCharacterInternal(t){var i;if(this.initGuard(),!this.gridTilemap)throw this.createUninitializedErr();if(!this.config)throw this.createUninitializedErr();let x=new r4(t,this.scene,this.gridTilemap,this.config.layerOverlay,this.geHeadless);(i=this.gridCharacters)==null||i.set(t.id,x)}};UC.welcomeMessagePrinted=!1;var W4=UC,X4=W4;/*! Bundled license information: +}`;var Fi=NS(function(){return Ut(xt,je+"return "+ye).apply(i,Ot)});if(Fi.source=ye,_g(Fi))throw Fi;return Fi}function Fb(R){return tn(R).toLowerCase()}function Ob(R){return tn(R).toUpperCase()}function Db(R,N,k){if(R=tn(R),R&&(k||N===i))return Bl(R);if(!R||!(N=Ar(N)))return R;var nt=j(R),ft=j(N),xt=_i(nt,ft),Ot=po(nt,ft)+1;return Ro(nt,xt,Ot).join("")}function Ib(R,N,k){if(R=tn(R),R&&(k||N===i))return R.slice(0,et(R)+1);if(!R||!(N=Ar(N)))return R;var nt=j(R),ft=po(nt,j(N))+1;return Ro(nt,0,ft).join("")}function Nb(R,N,k){if(R=tn(R),R&&(k||N===i))return R.replace(Pa,"");if(!R||!(N=Ar(N)))return R;var nt=j(R),ft=_i(nt,j(N));return Ro(nt,ft).join("")}function Bb(R,N){var k=A,nt=P;if(Dn(N)){var ft="separator"in N?N.separator:ft;k="length"in N?Ri(N.length):k,nt="omission"in N?Ar(N.omission):nt}R=tn(R);var xt=R.length;if(Cs(R)){var Ot=j(R);xt=Ot.length}if(k>=xt)return R;var Gt=k-V(nt);if(Gt<1)return nt;var kt=Ot?Ro(Ot,0,Gt).join(""):R.slice(0,Gt);if(ft===i)return kt+nt;if(Ot&&(Gt+=kt.length-Gt),qg(ft)){if(R.slice(Gt).search(ft)){var fe,ce=kt;for(ft.global||(ft=Kt(ft.source,tn(Rl.exec(ft))+"g")),ft.lastIndex=0;fe=ft.exec(ce);)var ye=fe.index;kt=kt.slice(0,ye===i?Gt:ye)}}else if(R.indexOf(Ar(ft),Gt)!=Gt){var Ie=kt.lastIndexOf(ft);Ie>-1&&(kt=kt.slice(0,Ie))}return kt+nt}function Ub(R){return R=tn(R),R&&Ce.test(R)?R.replace(bt,st):R}var zb=L(function(R,N,k){return R+(k?" ":"")+N.toUpperCase()}),i0=Vp("toUpperCase");function IS(R,N,k){return R=tn(R),N=k?i:N,N===i?lr(R)?Mt(R):Ko(R):R.match(N)||[]}var NS=ei(function(R,N){try{return $i(R,i,N)}catch(k){return _g(k)?k:new Lt(k)}}),Gb=Ci(function(R,N){return xn(N,function(k){k=Lo(k),pa(R,k,$g(R[k],R))}),R});function Vb(R){var N=R==null?0:R.length,k=oi();return R=N?Qi(R,function(nt){if(typeof nt[1]!="function")throw new $t(s);return[k(nt[0]),nt[1]]}):[],ei(function(nt){for(var ft=-1;++ftz)return[];var k=Q,nt=Er(R,Q);N=oi(N),R-=Q;for(var ft=Ms(nt,N);++k0||N<0)?new ni(k):(R<0?k=k.takeRight(-R):R&&(k=k.drop(R)),N!==i&&(N=Ri(N),k=N<0?k.dropRight(-N):k.take(N-R)),k)},ni.prototype.takeRightWhile=function(R){return this.reverse().takeWhile(R).reverse()},ni.prototype.toArray=function(){return this.take(Q)},as(ni.prototype,function(R,N){var k=/^(?:filter|find|map|reject)|While$/.test(N),nt=/^(?:head|last)$/.test(N),ft=mt[nt?"take"+(N=="last"?"Right":""):N],xt=nt||/^find/.test(N);ft&&(mt.prototype[N]=function(){var Ot=this.__wrapped__,Gt=nt?[1]:arguments,kt=Ot instanceof ni,fe=Gt[0],ce=kt||Si(Ot),ye=function(Bi){var Vi=ft.apply(mt,Xr([Bi],Gt));return nt&&Ie?Vi[0]:Vi};ce&&k&&typeof fe=="function"&&fe.length!=1&&(kt=ce=!1);var Ie=this.__chain__,je=!!this.__actions__.length,li=xt&&!Ie,Fi=kt&&!je;if(!xt&&ce){Ot=Fi?Ot:new ni(this);var hi=R.apply(Ot,Gt);return hi.__actions__.push({func:Xp,args:[ye],thisArg:i}),new Mr(hi,Ie)}return li&&Fi?R.apply(this,Gt):(hi=this.thru(ye),li?nt?hi.value()[0]:hi.value():hi)})}),xn(["pop","push","shift","sort","splice","unshift"],function(R){var N=se[R],k=/^(?:push|sort|unshift)$/.test(R)?"tap":"thru",nt=/^(?:pop|shift)$/.test(R);mt.prototype[R]=function(){var ft=arguments;if(nt&&!this.__chain__){var xt=this.value();return N.apply(Si(xt)?xt:[],ft)}return this[k](function(Ot){return N.apply(Si(Ot)?Ot:[],ft)})}}),as(ni.prototype,function(R,N){var k=mt[N];if(k){var nt=k.name+"";me.call(_o,nt)||(_o[nt]=[]),_o[nt].push({name:N,func:k})}}),_o[lt(i,o).name]=[{name:"wrapper",func:i}],ni.prototype.clone=Og,ni.prototype.reverse=Dg,ni.prototype.value=rs,mt.prototype.at=pR,mt.prototype.chain=vR,mt.prototype.commit=mR,mt.prototype.next=gR,mt.prototype.plant=xR,mt.prototype.reverse=SR,mt.prototype.toJSON=mt.prototype.valueOf=mt.prototype.value=TR,mt.prototype.first=mt.prototype.head,xo&&(mt.prototype[xo]=yR),mt},zt=Nt();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(yn._=zt,define(function(){return zt})):Rn?((Rn.exports=zt)._=zt,Ch._=zt):yn._=zt}).call(g)}),IC=class extends Set{constructor(g,t=!1){super(g),this.valuesAsFlags=t}};function ld(g){if(g instanceof Map)return Object.fromEntries([...g.entries()].map(([t,i])=>[t,ld(i)]));if(g instanceof Set)return Array.from(g.values()).map(ld);if(g instanceof IC)return{values:[...g.values()],valuesAsFlags:g.valuesAsFlags};if(typeof g=="object"){let t={};return Object.entries(g).forEach(([i,x])=>{t[i]=ld(x)}),t}else return g}Zx(Jx(),1);var I4=Zx(Jx(),1);function lu(g,t){if(typeof g!="object")throw new Error(`Cannot merge into non-object objectToMergeWith. Received: ${JSON.stringify(g)}`);if(typeof t!="object")throw new Error(`Cannot merge using non-object objectToMergeWith. Received: ${JSON.stringify(t)}`);let i=(0,I4.cloneDeep)(g);for(let[x,T]of Object.entries(t))typeof T!="object"||T instanceof Set||i[x]===void 0?i[x]=T:i[x]=lu(i[x],T);return i}function NC(g,t){if(!(g===void 0||typeof g!="object"))for(let i of Object.keys(g)){if(i===t)return g[i];let x=g[i];if(typeof x=="object"){let T=NC(x,t);if(T!==void 0)return T}}}var v0="@composite:",N4="@inherit:",B4=class{constructor(g,t,i){this.tiledClassToMembersMap=g,this.enumNameToValuesMap=t,this.parserOptions=i,this.memoiser=new Map}flattenMembers(g,t){return this.memoiser.has(g)?{[g]:this.memoiser.get(g)}:(this.memoiser.set(g,t.reduce((i,x)=>An(An({},i),this.flattenMemberProperty(x)),{})),{[g]:this.memoiser.get(g)})}flattenMemberProperty(g){var t;let i=(t=g.propertyType)!=null?t:g.propertytype;if(g.type==="class"){if(!this.memoiser.has(i)){let E=this.tiledClassToMembersMap.get(i).reduce((s,y)=>lu(this.flattenMemberProperty(y),s),{});this.memoiser.set(i,E)}let x=this.memoiser.get(i),T=lu(x,this.flattenValue(g.value,x));return this.checkIfShouldFlatten(g.name)?T:{[g.name.replace(v0,"")]:T}}else return this.enumNameToValuesMap.has(i)?this.enumNameToValuesMap.get(i).valuesAsFlags?{[g.name]:new Set(g.value.split(",").filter(x=>x!==""))}:{[g.name]:g.value}:{[g.name]:g.value}}get memoisedFlattenedProperties(){return this.memoiser}flattenValue(g,t){return Object.entries(g).reduce((i,[x,T])=>{if(typeof T!="object")return NC(t,x)instanceof Set?lu({[x]:new Set(T.split(",").filter(E=>E!==""))},i):lu({[x]:T},i);if(this.checkIfShouldFlatten(x))return lu(this.flattenValue(T,t),i);{let E=x.replace(v0,"");return lu({[E]:this.flattenValue(T,t)},i)}},{})}checkIfShouldFlatten(g){var t;return((t=this.parserOptions)==null?void 0:t.defaultComposite)===!0?g.startsWith(N4):!g.startsWith(v0)}},uT=Zx(Jx(),1),U4=class{constructor(g){this.flattener=g}flattenPropertiesOnObject(g){var t,i,x,T;return dh(An(An({},this.flattener.memoisedFlattenedProperties.get((t=g.class)!=null?t:g.type)),(i=g.properties)==null?void 0:i.reduce((E,s)=>An(An({},E),this.flattener.flattenMemberProperty(s)),{})),{name:g.name,id:g.id,class:(T=(x=g.class)!=null?x:g.type)!=null?T:null,x:g.x,y:g.y})}flattenPropertiesOnTile(g){var t,i,x,T;return dh(An(An({},this.flattener.memoisedFlattenedProperties.get((t=g.class)!=null?t:g.type)),(i=g.properties)==null?void 0:i.reduce((E,s)=>An(An({},E),this.flattener.flattenMemberProperty(s)),{})),{id:g.id,class:(T=(x=g.class)!=null?x:g.type)!=null?T:null})}getCustomTypesMap(){return new Map([...this.flattener.memoisedFlattenedProperties.entries()].map(([g,t])=>[g,(0,uT.cloneDeep)(t)]))}getEnumsMap(){return new Map([...this.flattener.enumNameToValuesMap.entries()].map(([g,t])=>[g,(0,uT.cloneDeep)(t)]))}toJSON(){return JSON.stringify({customTypes:ld(this.getCustomTypesMap()),enums:ld(this.getEnumsMap())},null,4)}};function z4(g,t){let i=new Map(g.propertyTypes.filter(E=>E.type==="enum").map(E=>[E.name,new IC(E.values,E.valuesAsFlags)])),x=new Map(g.propertyTypes.filter(E=>E.type==="class").map(E=>[E.name,E.members])),T=new B4(x,i,t);return x.forEach((E,s)=>{T.flattenMembers(s,E)}),new U4(T)}var G4={parse:z4},BC=class{constructor(g,t){this.phaserTile=g,this.tiledProject=t}getProperty(g){var t,i;let x={};if(this.tiledProject){let T=G4.parse(this.tiledProject),E=this.getType();if(E){let s=(t=T.getCustomTypesMap())==null?void 0:t.get(E);if(s)for(let[y,e]of Object.entries(s))x[y]=e}}return(i=this.phaserTile.properties[g])!=null?i:x[g]}hasProperty(g){return this.getProperty(g)!=null}getType(){var g,t;return(t=(g=this.phaserTile.tileset)==null?void 0:g.tileData[this.phaserTile.index-1])==null?void 0:t.type}},V4=class{constructor(g,t){this.phaserTilemapLayer=g,this.tiledProject=t}getName(){return this.phaserTilemapLayer.layer.name}getProperty(g){let t=this.phaserTilemapLayer.layer.properties,i=t?.find(x=>x.name==g);return i?.value}hasProperty(g){return this.getProperty(g)!=null}isCharLayer(){return this.hasProperty(Qv)}getData(){return this.phaserTilemapLayer.layer.data.map(g=>g.map(t=>new BC(t,this.tiledProject)))}},H4=class{constructor(g,t){this.phaserTilemap=g,this.tiledProject=t;for(let i of this.phaserTilemap.layers)if(i.tilemapLayer==null)throw new Error(`Error initializing tilemap. Layer '${i.name}' has no 'tilemapLayer'. This can happen if you call 'createLayer' with the wrong layer ID.`)}getTileWidth(){return this.phaserTilemap.tileWidth}getTileHeight(){return this.phaserTilemap.tileHeight}getWidth(){return this.phaserTilemap.width}getHeight(){return this.phaserTilemap.height}getOrientation(){return this.phaserTilemap.orientation==Phaser.Tilemaps.Orientation.ISOMETRIC.toString()?"isometric":"orthogonal"}getLayers(){return this.phaserTilemap.layers.map(g=>new V4(g.tilemapLayer,this.tiledProject))}hasTileAt(g,t,i){return!!this.phaserTilemap.hasTileAt(g,t,i)}getTileAt(g,t,i){let x=this.phaserTilemap.getTileAt(g,t,!1,i);if(x)return new BC(x,this.tiledProject)}},UC=class Ry{constructor(t){this.scene=t,this.geHeadless=new M4(!1),this.isCreatedInternal=!1,Ry.welcomeMessagePrinted||(console.log(`Using GridEngine Phaser Plugin v${RC}`),Ry.welcomeMessagePrinted=!0),this.scene.sys.events.once("boot",this.boot,this)}boot(){this.scene.sys.events.on("update",this.update,this)}getCharLayer(t){return this.geHeadless.getCharLayer(t)}getTransition(t,i){return this.geHeadless.getTransition(t,i)}setTransition(t,i,x){this.geHeadless.setTransition(t,i,x)}create(t,i){this.geHeadless.create(new H4(t,i.tiledProject),i),this.isCreatedInternal=!0,this.gridCharacters=new Map;let x=this.setConfigDefaults(i);this.config=x,this.gridTilemap=new Py(t),this.addCharacters()}getPosition(t){return this.geHeadless.getPosition(t)}move(t,i){this.geHeadless.move(t,i)}moveRandomly(t,i=0,x=-1){this.geHeadless.moveRandomly(t,i,x)}getMovement(t){return this.geHeadless.getMovement(t)}moveTo(t,i,x){return this.geHeadless.moveTo(t,i,x)}stopMovement(t){this.geHeadless.stopMovement(t)}setSpeed(t,i){this.geHeadless.setSpeed(t,i)}getSpeed(t){return this.geHeadless.getSpeed(t)}setContainer(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.setContainer(i)}getContainer(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getContainer()}getOffsetX(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getOffsetX()}setOffsetX(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.setOffsetX(i)}getOffsetY(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getOffsetY()}setOffsetY(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.setOffsetY(i)}collidesWithTiles(t){return this.geHeadless.collidesWithTiles(t)}getWalkingAnimationMapping(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);let T=x.getAnimation();return T?.getWalkingAnimationMapping()}hasLayerOverlay(){var t;return this.initGuard(),!!((t=this.config)!=null&&t.layerOverlay)}setWalkingAnimationMapping(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);let E=T.getAnimation();E?.setWalkingAnimationMapping(i)}update(t,i){if(this.isCreatedInternal&&this.gridCharacters)for(let[x,T]of this.gridCharacters)T.update(i);this.geHeadless.update(t,i)}addCharacter(t){this.geHeadless.addCharacter(t),this.addCharacterInternal(t)}hasCharacter(t){return this.geHeadless.hasCharacter(t)}removeCharacter(t){var i,x;this.initGuard();let T=(i=this.gridCharacters)==null?void 0:i.get(t);if(!T)throw this.createCharUnknownErr(t);T.destroy(),(x=this.gridCharacters)==null||x.delete(t),this.geHeadless.removeCharacter(t)}removeAllCharacters(){if(this.initGuard(),!!this.gridCharacters){for(let t of this.gridCharacters.keys())this.removeCharacter(t);this.geHeadless.removeAllCharacters()}}getAllCharacters(t){return this.geHeadless.getAllCharacters(t)}getLabels(t){return this.geHeadless.getLabels(t)}addLabels(t,i){this.geHeadless.addLabels(t,i)}removeLabels(t,i){this.geHeadless.removeLabels(t,i)}clearLabels(t){this.geHeadless.clearLabels(t)}follow(t,i,x,T){let E;x===void 0?E={distance:0,closestPointIfBlocked:!1}:typeof x=="number"?(E={distance:x,closestPointIfBlocked:!1},T&&(E.closestPointIfBlocked=!0)):E=x,this.geHeadless.follow(t,i,E)}isMoving(t){return this.geHeadless.isMoving(t)}getFacingDirection(t){return this.geHeadless.getFacingDirection(t)}getFacingPosition(t){return this.geHeadless.getFacingPosition(t)}turnTowards(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);T.turnTowards(i),this.geHeadless.turnTowards(t,i)}getCharactersAt(t,i){return this.geHeadless.getCharactersAt(t,i)}setPosition(t,i,x){this.geHeadless.setPosition(t,i,x)}getSprite(t){var i;this.initGuard();let x=(i=this.gridCharacters)==null?void 0:i.get(t);if(!x)throw this.createCharUnknownErr(t);return x.getSprite()}setSprite(t,i){var x;this.initGuard();let T=(x=this.gridCharacters)==null?void 0:x.get(t);if(!T)throw this.createCharUnknownErr(t);i.setOrigin(0,0),T.setSprite(i)}isBlocked(t,i,x=["geDefault"]){return this.geHeadless.isBlocked(t,i,x)}isTileBlocked(t,i){return this.geHeadless.isTileBlocked(t,i)}getCollisionGroups(t){return this.geHeadless.getCollisionGroups(t)}setCollisionGroups(t,i){this.geHeadless.setCollisionGroups(t,i)}getIgnoreCollisionGroups(t){return this.geHeadless.getIgnoreCollisionGroups(t)}setIgnoreCollisionGroups(t,i){this.geHeadless.setIgnoreCollisionGroups(t,i)}getTilePosInDirection(t,i,x){return this.geHeadless.getTilePosInDirection(t,i,x)}findShortestPath(t,i,x={}){return this.geHeadless.findShortestPath(t,i,x)}steppedOn(t,i,x){return this.geHeadless.steppedOn(t,i,x)}characterShifted(){return this.geHeadless.characterShifted()}movementStarted(){return this.geHeadless.movementStarted()}movementStopped(){return this.geHeadless.movementStopped()}directionChanged(){return this.geHeadless.directionChanged()}positionChangeStarted(){return this.geHeadless.positionChangeStarted()}positionChangeFinished(){return this.geHeadless.positionChangeFinished()}getMovementProgress(t){return this.geHeadless.getMovementProgress(t)}rebuildTileCollisionCache(t,i,x,T){this.geHeadless.rebuildTileCollisionCache(t,i,x,T)}addQueueMovements(t,i,x){this.geHeadless.addQueueMovements(t,i,x)}getEnqueuedMovements(t){return this.geHeadless.getEnqueuedMovements(t)}queueMovementFinished(){return this.geHeadless.queueMovementFinished()}clearEnqueuedMovements(t){return this.geHeadless.clearEnqueuedMovements(t)}getState(){return{characters:this.geHeadless.getState().characters.map(t=>dh(An({},t),{offsetX:this.getOffsetX(t.id),offsetY:this.getOffsetY(t.id)}))}}setState(t){if(this.geHeadless.setState(t),this.gridCharacters)for(let i of t.characters){let x=this.gridCharacters.get(i.id);x&&(x.setOffsetX(i.offsetX),x.setOffsetY(i.offsetY))}}getTileCost(t,i,x){return this.initGuard(),this.geHeadless.getTileCost(t,i,x)}setConfigDefaults(t){return An({collisionTilePropertyName:"ge_collide",numberOfDirections:4,characterCollisionStrategy:"BLOCK_TWO_TILES",layerOverlay:!1,cacheTileCollisions:!1},t)}initGuard(){if(!this.isCreatedInternal)throw this.createUninitializedErr()}createUninitializedErr(){throw new Error("GridEngine not initialized. You need to call create() first.")}addCharacters(){var t;(t=this.config)==null||t.characters.forEach(i=>this.addCharacterInternal(i))}createCharUnknownErr(t){return new Error(`Character unknown: ${t}`)}addCharacterInternal(t){var i;if(this.initGuard(),!this.gridTilemap)throw this.createUninitializedErr();if(!this.config)throw this.createUninitializedErr();let x=new r4(t,this.scene,this.gridTilemap,this.config.layerOverlay,this.geHeadless);(i=this.gridCharacters)==null||i.set(t.id,x)}};UC.welcomeMessagePrinted=!1;var W4=UC,X4=W4;/*! Bundled license information: tiled-property-flattener/dist/tiled_property_flattener.min.js: (*! Bundled license information: @@ -6396,16 +6396,16 @@ tiled-property-flattener/dist/tiled_property_flattener.min.js: * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors *) *) -*/function fT(g){return g.type==="ROLL_DICE"}class du{constructor(t,i=4){this.bounds=t,this.capacity=i,this.points=[],this.divided=!1,this.cache=new Map}subdivide(){const{xMin:t,yMin:i,xMax:x,yMax:T}=this.bounds,E=(x-t)/2,s=(T-i)/2,y=t,e=i;this.northeast=new du({xMin:y+E,xMax:y+2*E,yMin:i,yMax:e+s},this.capacity),this.northwest=new du({xMin:t,xMax:y+E,yMin:i,yMax:e+s},this.capacity),this.southeast=new du({xMin:y+E,xMax:y+2*E,yMin:e+s,yMax:e+2*s},this.capacity),this.southwest=new du({xMin:t,xMax:y+E,yMin:e+s,yMax:e+2*s},this.capacity),this.divided=!0}insert(t){return this.contains(t.bounds)?this.points.length=i&&t.xMax<=T&&t.yMin>=x&&t.yMax<=E}generateCacheKey(t){const{xMin:i,xMax:x,yMin:T,yMax:E}=t;return`${i},${x},${T},${E}`}queryRange(t,i=[]){if(!this.intersects(t))return i;for(const x of this.points)this.isWithinBounds(x.bounds,t)&&i.push(x);return this.divided&&(this.northwest?.queryRange(t,i),this.northeast?.queryRange(t,i),this.southwest?.queryRange(t,i),this.southeast?.queryRange(t,i)),i}query(t,i=[]){const x=`${t.x},${t.y}`,T=this.cache.get(x);if(T)return T;if(!this.intersects({xMin:t.x,xMax:t.x,yMin:t.y,yMax:t.y}))return i;for(const E of this.points)this.isWithinRange(t,E.bounds)&&i.push(E);return this.divided&&(this.northwest?.query(t,i),this.northeast?.query(t,i),this.southwest?.query(t,i),this.southeast?.query(t,i)),this.cache.set(x,i),i}intersects(t){const{xMin:i,yMin:x,xMax:T,yMax:E}=this.bounds;return!(t.xMin>T||t.xMaxE||t.yMax=i.xMin&&t.xMin<=i.xMax&&t.yMax>=i.yMin&&t.yMin<=i.yMax}isWithinRange(t,i){return t.x>=i.xMin&&t.x<=i.xMax&&t.y>=i.yMin&&t.y<=i.yMax}}class Y4{constructor(){this.events={},this.lastEmitted=new Map}on(t,i){this.events[t]||(this.events[t]=[]),this.events[t]?.push(i)}off(t,i){this.events[t]&&(this.events[t]=this.events[t]?.filter(x=>x!==i))}emit(t,i,x=0){const T=Date.now(),E=this.lastEmitted.get(t)||0;if(T-E>=x){if(!this.events[t])return;this.events[t]?.forEach(s=>s(i)),this.lastEmitted.set(t,T)}}}const Pi=new Y4;function k4(g,t,i){let x=new Set([...t,void 0]);return g.listen((T,E)=>{x.has(E)&&i(T,E)})}function zC(g,t){return function(){return g.apply(t,arguments)}}const{toString:K4}=Object.prototype,{getPrototypeOf:$x}=Object,Qm=(g=>t=>{const i=K4.call(t);return g[i]||(g[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),Vo=g=>(g=g.toLowerCase(),t=>Qm(t)===g),_m=g=>t=>typeof t===g,{isArray:tc}=Array,yd=_m("undefined");function j4(g){return g!==null&&!yd(g)&&g.constructor!==null&&!yd(g.constructor)&&Ca(g.constructor.isBuffer)&&g.constructor.isBuffer(g)}const GC=Vo("ArrayBuffer");function Z4(g){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(g):t=g&&g.buffer&&GC(g.buffer),t}const J4=_m("string"),Ca=_m("function"),VC=_m("number"),qm=g=>g!==null&&typeof g=="object",$4=g=>g===!0||g===!1,_v=g=>{if(Qm(g)!=="object")return!1;const t=$x(g);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in g)&&!(Symbol.iterator in g)},Q4=Vo("Date"),_4=Vo("File"),q4=Vo("Blob"),tD=Vo("FileList"),eD=g=>qm(g)&&Ca(g.pipe),iD=g=>{let t;return g&&(typeof FormData=="function"&&g instanceof FormData||Ca(g.append)&&((t=Qm(g))==="formdata"||t==="object"&&Ca(g.toString)&&g.toString()==="[object FormData]"))},nD=Vo("URLSearchParams"),rD=g=>g.trim?g.trim():g.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function kd(g,t,{allOwnKeys:i=!1}={}){if(g===null||typeof g>"u")return;let x,T;if(typeof g!="object"&&(g=[g]),tc(g))for(x=0,T=g.length;x0;)if(T=i[x],t===T.toLowerCase())return T;return null}const WC=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,XC=g=>!yd(g)&&g!==WC;function Ry(){const{caseless:g}=XC(this)&&this||{},t={},i=(x,T)=>{const E=g&&HC(t,T)||T;_v(t[E])&&_v(x)?t[E]=Ry(t[E],x):_v(x)?t[E]=Ry({},x):tc(x)?t[E]=x.slice():t[E]=x};for(let x=0,T=arguments.length;x(kd(t,(T,E)=>{i&&Ca(T)?g[E]=zC(T,i):g[E]=T},{allOwnKeys:x}),g),aD=g=>(g.charCodeAt(0)===65279&&(g=g.slice(1)),g),oD=(g,t,i,x)=>{g.prototype=Object.create(t.prototype,x),g.prototype.constructor=g,Object.defineProperty(g,"super",{value:t.prototype}),i&&Object.assign(g.prototype,i)},lD=(g,t,i,x)=>{let T,E,s;const y={};if(t=t||{},g==null)return t;do{for(T=Object.getOwnPropertyNames(g),E=T.length;E-- >0;)s=T[E],(!x||x(s,g,t))&&!y[s]&&(t[s]=g[s],y[s]=!0);g=i!==!1&&$x(g)}while(g&&(!i||i(g,t))&&g!==Object.prototype);return t},hD=(g,t,i)=>{g=String(g),(i===void 0||i>g.length)&&(i=g.length),i-=t.length;const x=g.indexOf(t,i);return x!==-1&&x===i},uD=g=>{if(!g)return null;if(tc(g))return g;let t=g.length;if(!VC(t))return null;const i=new Array(t);for(;t-- >0;)i[t]=g[t];return i},fD=(g=>t=>g&&t instanceof g)(typeof Uint8Array<"u"&&$x(Uint8Array)),cD=(g,t)=>{const x=(g&&g[Symbol.iterator]).call(g);let T;for(;(T=x.next())&&!T.done;){const E=T.value;t.call(g,E[0],E[1])}},dD=(g,t)=>{let i;const x=[];for(;(i=g.exec(t))!==null;)x.push(i);return x},pD=Vo("HTMLFormElement"),vD=g=>g.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(i,x,T){return x.toUpperCase()+T}),cT=(({hasOwnProperty:g})=>(t,i)=>g.call(t,i))(Object.prototype),mD=Vo("RegExp"),YC=(g,t)=>{const i=Object.getOwnPropertyDescriptors(g),x={};kd(i,(T,E)=>{let s;(s=t(T,E,g))!==!1&&(x[E]=s||T)}),Object.defineProperties(g,x)},gD=g=>{YC(g,(t,i)=>{if(Ca(g)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;const x=g[i];if(Ca(x)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},yD=(g,t)=>{const i={},x=T=>{T.forEach(E=>{i[E]=!0})};return tc(g)?x(g):x(String(g).split(t)),i},xD=()=>{},SD=(g,t)=>(g=+g,Number.isFinite(g)?g:t),v0="abcdefghijklmnopqrstuvwxyz",dT="0123456789",kC={DIGIT:dT,ALPHA:v0,ALPHA_DIGIT:v0+v0.toUpperCase()+dT},TD=(g=16,t=kC.ALPHA_DIGIT)=>{let i="";const{length:x}=t;for(;g--;)i+=t[Math.random()*x|0];return i};function ED(g){return!!(g&&Ca(g.append)&&g[Symbol.toStringTag]==="FormData"&&g[Symbol.iterator])}const MD=g=>{const t=new Array(10),i=(x,T)=>{if(qm(x)){if(t.indexOf(x)>=0)return;if(!("toJSON"in x)){t[T]=x;const E=tc(x)?[]:{};return kd(x,(s,y)=>{const e=i(s,T+1);!yd(e)&&(E[y]=e)}),t[T]=void 0,E}}return x};return i(g,0)},CD=Vo("AsyncFunction"),wD=g=>g&&(qm(g)||Ca(g))&&Ca(g.then)&&Ca(g.catch),de={isArray:tc,isArrayBuffer:GC,isBuffer:j4,isFormData:iD,isArrayBufferView:Z4,isString:J4,isNumber:VC,isBoolean:$4,isObject:qm,isPlainObject:_v,isUndefined:yd,isDate:Q4,isFile:_4,isBlob:q4,isRegExp:mD,isFunction:Ca,isStream:eD,isURLSearchParams:nD,isTypedArray:fD,isFileList:tD,forEach:kd,merge:Ry,extend:sD,trim:rD,stripBOM:aD,inherits:oD,toFlatObject:lD,kindOf:Qm,kindOfTest:Vo,endsWith:hD,toArray:uD,forEachEntry:cD,matchAll:dD,isHTMLForm:pD,hasOwnProperty:cT,hasOwnProp:cT,reduceDescriptors:YC,freezeMethods:gD,toObjectSet:yD,toCamelCase:vD,noop:xD,toFiniteNumber:SD,findKey:HC,global:WC,isContextDefined:XC,ALPHABET:kC,generateString:TD,isSpecCompliantForm:ED,toJSONObject:MD,isAsyncFn:CD,isThenable:wD};function Hi(g,t,i,x,T){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=g,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),x&&(this.request=x),T&&(this.response=T)}de.inherits(Hi,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:de.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const KC=Hi.prototype,jC={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(g=>{jC[g]={value:g}});Object.defineProperties(Hi,jC);Object.defineProperty(KC,"isAxiosError",{value:!0});Hi.from=(g,t,i,x,T,E)=>{const s=Object.create(KC);return de.toFlatObject(g,s,function(e){return e!==Error.prototype},y=>y!=="isAxiosError"),Hi.call(s,g.message,t,i,x,T),s.cause=g,s.name=g.name,E&&Object.assign(s,E),s};const AD=null;function by(g){return de.isPlainObject(g)||de.isArray(g)}function ZC(g){return de.endsWith(g,"[]")?g.slice(0,-2):g}function pT(g,t,i){return g?g.concat(t).map(function(T,E){return T=ZC(T),!i&&E?"["+T+"]":T}).join(i?".":""):t}function PD(g){return de.isArray(g)&&!g.some(by)}const RD=de.toFlatObject(de,{},null,function(t){return/^is[A-Z]/.test(t)});function tg(g,t,i){if(!de.isObject(g))throw new TypeError("target must be an object");t=t||new FormData,i=de.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,f){return!de.isUndefined(f[u])});const x=i.metaTokens,T=i.visitor||p,E=i.dots,s=i.indexes,e=(i.Blob||typeof Blob<"u"&&Blob)&&de.isSpecCompliantForm(t);if(!de.isFunction(T))throw new TypeError("visitor must be a function");function r(n){if(n===null)return"";if(de.isDate(n))return n.toISOString();if(!e&&de.isBlob(n))throw new Hi("Blob is not supported. Use a Buffer instead.");return de.isArrayBuffer(n)||de.isTypedArray(n)?e&&typeof Blob=="function"?new Blob([n]):Buffer.from(n):n}function p(n,u,f){let o=n;if(n&&!f&&typeof n=="object"){if(de.endsWith(u,"{}"))u=x?u:u.slice(0,-2),n=JSON.stringify(n);else if(de.isArray(n)&&PD(n)||(de.isFileList(n)||de.endsWith(u,"[]"))&&(o=de.toArray(n)))return u=ZC(u),o.forEach(function(d,v){!(de.isUndefined(d)||d===null)&&t.append(s===!0?pT([u],v,E):s===null?u:u+"[]",r(d))}),!1}return by(n)?!0:(t.append(pT(f,u,E),r(n)),!1)}const h=[],a=Object.assign(RD,{defaultVisitor:p,convertValue:r,isVisitable:by});function l(n,u){if(!de.isUndefined(n)){if(h.indexOf(n)!==-1)throw Error("Circular reference detected in "+u.join("."));h.push(n),de.forEach(n,function(o,c){(!(de.isUndefined(o)||o===null)&&T.call(t,o,de.isString(c)?c.trim():c,u,a))===!0&&l(o,u?u.concat(c):[c])}),h.pop()}}if(!de.isObject(g))throw new TypeError("data must be an object");return l(g),t}function vT(g){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(g).replace(/[!'()~]|%20|%00/g,function(x){return t[x]})}function Qx(g,t){this._pairs=[],g&&tg(g,this,t)}const JC=Qx.prototype;JC.append=function(t,i){this._pairs.push([t,i])};JC.toString=function(t){const i=t?function(x){return t.call(this,x,vT)}:vT;return this._pairs.map(function(T){return i(T[0])+"="+i(T[1])},"").join("&")};function bD(g){return encodeURIComponent(g).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function $C(g,t,i){if(!t)return g;const x=i&&i.encode||bD,T=i&&i.serialize;let E;if(T?E=T(t,i):E=de.isURLSearchParams(t)?t.toString():new Qx(t,i).toString(x),E){const s=g.indexOf("#");s!==-1&&(g=g.slice(0,s)),g+=(g.indexOf("?")===-1?"?":"&")+E}return g}class mT{constructor(){this.handlers=[]}use(t,i,x){return this.handlers.push({fulfilled:t,rejected:i,synchronous:x?x.synchronous:!1,runWhen:x?x.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){de.forEach(this.handlers,function(x){x!==null&&t(x)})}}const QC={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},LD=typeof URLSearchParams<"u"?URLSearchParams:Qx,FD=typeof FormData<"u"?FormData:null,OD=typeof Blob<"u"?Blob:null,DD={isBrowser:!0,classes:{URLSearchParams:LD,FormData:FD,Blob:OD},protocols:["http","https","file","blob","url","data"]},_C=typeof window<"u"&&typeof document<"u",ID=(g=>_C&&["ReactNative","NativeScript","NS"].indexOf(g)<0)(typeof navigator<"u"&&navigator.product),ND=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",BD=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:_C,hasStandardBrowserEnv:ID,hasStandardBrowserWebWorkerEnv:ND},Symbol.toStringTag,{value:"Module"})),Do={...BD,...DD};function UD(g,t){return tg(g,new Do.classes.URLSearchParams,Object.assign({visitor:function(i,x,T,E){return Do.isNode&&de.isBuffer(i)?(this.append(x,i.toString("base64")),!1):E.defaultVisitor.apply(this,arguments)}},t))}function zD(g){return de.matchAll(/\w+|\[(\w*)]/g,g).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GD(g){const t={},i=Object.keys(g);let x;const T=i.length;let E;for(x=0;x=i.length;return s=!s&&de.isArray(T)?T.length:s,e?(de.hasOwnProp(T,s)?T[s]=[T[s],x]:T[s]=x,!y):((!T[s]||!de.isObject(T[s]))&&(T[s]=[]),t(i,x,T[s],E)&&de.isArray(T[s])&&(T[s]=GD(T[s])),!y)}if(de.isFormData(g)&&de.isFunction(g.entries)){const i={};return de.forEachEntry(g,(x,T)=>{t(zD(x),T,i,0)}),i}return null}function VD(g,t,i){if(de.isString(g))try{return(t||JSON.parse)(g),de.trim(g)}catch(x){if(x.name!=="SyntaxError")throw x}return(i||JSON.stringify)(g)}const _x={transitional:QC,adapter:["xhr","http"],transformRequest:[function(t,i){const x=i.getContentType()||"",T=x.indexOf("application/json")>-1,E=de.isObject(t);if(E&&de.isHTMLForm(t)&&(t=new FormData(t)),de.isFormData(t))return T?JSON.stringify(qC(t)):t;if(de.isArrayBuffer(t)||de.isBuffer(t)||de.isStream(t)||de.isFile(t)||de.isBlob(t))return t;if(de.isArrayBufferView(t))return t.buffer;if(de.isURLSearchParams(t))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let y;if(E){if(x.indexOf("application/x-www-form-urlencoded")>-1)return UD(t,this.formSerializer).toString();if((y=de.isFileList(t))||x.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return tg(y?{"files[]":t}:t,e&&new e,this.formSerializer)}}return E||T?(i.setContentType("application/json",!1),VD(t)):t}],transformResponse:[function(t){const i=this.transitional||_x.transitional,x=i&&i.forcedJSONParsing,T=this.responseType==="json";if(t&&de.isString(t)&&(x&&!this.responseType||T)){const s=!(i&&i.silentJSONParsing)&&T;try{return JSON.parse(t)}catch(y){if(s)throw y.name==="SyntaxError"?Hi.from(y,Hi.ERR_BAD_RESPONSE,this,null,this.response):y}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Do.classes.FormData,Blob:Do.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};de.forEach(["delete","get","head","post","put","patch"],g=>{_x.headers[g]={}});const qx=_x,HD=de.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),WD=g=>{const t={};let i,x,T;return g&&g.split(` -`).forEach(function(s){T=s.indexOf(":"),i=s.substring(0,T).trim().toLowerCase(),x=s.substring(T+1).trim(),!(!i||t[i]&&HD[i])&&(i==="set-cookie"?t[i]?t[i].push(x):t[i]=[x]:t[i]=t[i]?t[i]+", "+x:x)}),t},gT=Symbol("internals");function Hc(g){return g&&String(g).trim().toLowerCase()}function qv(g){return g===!1||g==null?g:de.isArray(g)?g.map(qv):String(g)}function XD(g){const t=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let x;for(;x=i.exec(g);)t[x[1]]=x[2];return t}const YD=g=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(g.trim());function m0(g,t,i,x,T){if(de.isFunction(x))return x.call(this,t,i);if(T&&(t=i),!!de.isString(t)){if(de.isString(x))return t.indexOf(x)!==-1;if(de.isRegExp(x))return x.test(t)}}function kD(g){return g.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,i,x)=>i.toUpperCase()+x)}function KD(g,t){const i=de.toCamelCase(" "+t);["get","set","has"].forEach(x=>{Object.defineProperty(g,x+i,{value:function(T,E,s){return this[x].call(this,t,T,E,s)},configurable:!0})})}class eg{constructor(t){t&&this.set(t)}set(t,i,x){const T=this;function E(y,e,r){const p=Hc(e);if(!p)throw new Error("header name must be a non-empty string");const h=de.findKey(T,p);(!h||T[h]===void 0||r===!0||r===void 0&&T[h]!==!1)&&(T[h||e]=qv(y))}const s=(y,e)=>de.forEach(y,(r,p)=>E(r,p,e));return de.isPlainObject(t)||t instanceof this.constructor?s(t,i):de.isString(t)&&(t=t.trim())&&!YD(t)?s(WD(t),i):t!=null&&E(i,t,x),this}get(t,i){if(t=Hc(t),t){const x=de.findKey(this,t);if(x){const T=this[x];if(!i)return T;if(i===!0)return XD(T);if(de.isFunction(i))return i.call(this,T,x);if(de.isRegExp(i))return i.exec(T);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,i){if(t=Hc(t),t){const x=de.findKey(this,t);return!!(x&&this[x]!==void 0&&(!i||m0(this,this[x],x,i)))}return!1}delete(t,i){const x=this;let T=!1;function E(s){if(s=Hc(s),s){const y=de.findKey(x,s);y&&(!i||m0(x,x[y],y,i))&&(delete x[y],T=!0)}}return de.isArray(t)?t.forEach(E):E(t),T}clear(t){const i=Object.keys(this);let x=i.length,T=!1;for(;x--;){const E=i[x];(!t||m0(this,this[E],E,t,!0))&&(delete this[E],T=!0)}return T}normalize(t){const i=this,x={};return de.forEach(this,(T,E)=>{const s=de.findKey(x,E);if(s){i[s]=qv(T),delete i[E];return}const y=t?kD(E):String(E).trim();y!==E&&delete i[E],i[y]=qv(T),x[y]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const i=Object.create(null);return de.forEach(this,(x,T)=>{x!=null&&x!==!1&&(i[T]=t&&de.isArray(x)?x.join(", "):x)}),i}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,i])=>t+": "+i).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...i){const x=new this(t);return i.forEach(T=>x.set(T)),x}static accessor(t){const x=(this[gT]=this[gT]={accessors:{}}).accessors,T=this.prototype;function E(s){const y=Hc(s);x[y]||(KD(T,s),x[y]=!0)}return de.isArray(t)?t.forEach(E):E(t),this}}eg.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);de.reduceDescriptors(eg.prototype,({value:g},t)=>{let i=t[0].toUpperCase()+t.slice(1);return{get:()=>g,set(x){this[i]=x}}});de.freezeMethods(eg);const El=eg;function g0(g,t){const i=this||qx,x=t||i,T=El.from(x.headers);let E=x.data;return de.forEach(g,function(y){E=y.call(i,E,T.normalize(),t?t.status:void 0)}),T.normalize(),E}function t2(g){return!!(g&&g.__CANCEL__)}function Kd(g,t,i){Hi.call(this,g??"canceled",Hi.ERR_CANCELED,t,i),this.name="CanceledError"}de.inherits(Kd,Hi,{__CANCEL__:!0});function jD(g,t,i){const x=i.config.validateStatus;!i.status||!x||x(i.status)?g(i):t(new Hi("Request failed with status code "+i.status,[Hi.ERR_BAD_REQUEST,Hi.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}const ZD=Do.hasStandardBrowserEnv?{write(g,t,i,x,T,E){const s=[g+"="+encodeURIComponent(t)];de.isNumber(i)&&s.push("expires="+new Date(i).toGMTString()),de.isString(x)&&s.push("path="+x),de.isString(T)&&s.push("domain="+T),E===!0&&s.push("secure"),document.cookie=s.join("; ")},read(g){const t=document.cookie.match(new RegExp("(^|;\\s*)("+g+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(g){this.write(g,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function JD(g){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(g)}function $D(g,t){return t?g.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):g}function e2(g,t){return g&&!JD(t)?$D(g,t):t}const QD=Do.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");let x;function T(E){let s=E;return t&&(i.setAttribute("href",s),s=i.href),i.setAttribute("href",s),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:i.pathname.charAt(0)==="/"?i.pathname:"/"+i.pathname}}return x=T(window.location.href),function(s){const y=de.isString(s)?T(s):s;return y.protocol===x.protocol&&y.host===x.host}}():function(){return function(){return!0}}();function _D(g){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(g);return t&&t[1]||""}function qD(g,t){g=g||10;const i=new Array(g),x=new Array(g);let T=0,E=0,s;return t=t!==void 0?t:1e3,function(e){const r=Date.now(),p=x[E];s||(s=r),i[T]=e,x[T]=r;let h=E,a=0;for(;h!==T;)a+=i[h++],h=h%g;if(T=(T+1)%g,T===E&&(E=(E+1)%g),r-s{const E=T.loaded,s=T.lengthComputable?T.total:void 0,y=E-i,e=x(y),r=E<=s;i=E;const p={loaded:E,total:s,progress:s?E/s:void 0,bytes:y,rate:e||void 0,estimated:e&&s&&r?(s-E)/e:void 0,event:T};p[t?"download":"upload"]=!0,g(p)}}const tI=typeof XMLHttpRequest<"u",eI=tI&&function(g){return new Promise(function(i,x){let T=g.data;const E=El.from(g.headers).normalize();let{responseType:s,withXSRFToken:y}=g,e;function r(){g.cancelToken&&g.cancelToken.unsubscribe(e),g.signal&&g.signal.removeEventListener("abort",e)}let p;if(de.isFormData(T)){if(Do.hasStandardBrowserEnv||Do.hasStandardBrowserWebWorkerEnv)E.setContentType(!1);else if((p=E.getContentType())!==!1){const[u,...f]=p?p.split(";").map(o=>o.trim()).filter(Boolean):[];E.setContentType([u||"multipart/form-data",...f].join("; "))}}let h=new XMLHttpRequest;if(g.auth){const u=g.auth.username||"",f=g.auth.password?unescape(encodeURIComponent(g.auth.password)):"";E.set("Authorization","Basic "+btoa(u+":"+f))}const a=e2(g.baseURL,g.url);h.open(g.method.toUpperCase(),$C(a,g.params,g.paramsSerializer),!0),h.timeout=g.timeout;function l(){if(!h)return;const u=El.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),o={data:!s||s==="text"||s==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:u,config:g,request:h};jD(function(d){i(d),r()},function(d){x(d),r()},o),h=null}if("onloadend"in h?h.onloadend=l:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(l)},h.onabort=function(){h&&(x(new Hi("Request aborted",Hi.ECONNABORTED,g,h)),h=null)},h.onerror=function(){x(new Hi("Network Error",Hi.ERR_NETWORK,g,h)),h=null},h.ontimeout=function(){let f=g.timeout?"timeout of "+g.timeout+"ms exceeded":"timeout exceeded";const o=g.transitional||QC;g.timeoutErrorMessage&&(f=g.timeoutErrorMessage),x(new Hi(f,o.clarifyTimeoutError?Hi.ETIMEDOUT:Hi.ECONNABORTED,g,h)),h=null},Do.hasStandardBrowserEnv&&(y&&de.isFunction(y)&&(y=y(g)),y||y!==!1&&QD(a))){const u=g.xsrfHeaderName&&g.xsrfCookieName&&ZD.read(g.xsrfCookieName);u&&E.set(g.xsrfHeaderName,u)}T===void 0&&E.setContentType(null),"setRequestHeader"in h&&de.forEach(E.toJSON(),function(f,o){h.setRequestHeader(o,f)}),de.isUndefined(g.withCredentials)||(h.withCredentials=!!g.withCredentials),s&&s!=="json"&&(h.responseType=g.responseType),typeof g.onDownloadProgress=="function"&&h.addEventListener("progress",yT(g.onDownloadProgress,!0)),typeof g.onUploadProgress=="function"&&h.upload&&h.upload.addEventListener("progress",yT(g.onUploadProgress)),(g.cancelToken||g.signal)&&(e=u=>{h&&(x(!u||u.type?new Kd(null,g,h):u),h.abort(),h=null)},g.cancelToken&&g.cancelToken.subscribe(e),g.signal&&(g.signal.aborted?e():g.signal.addEventListener("abort",e)));const n=_D(a);if(n&&Do.protocols.indexOf(n)===-1){x(new Hi("Unsupported protocol "+n+":",Hi.ERR_BAD_REQUEST,g));return}h.send(T||null)})},Ly={http:AD,xhr:eI};de.forEach(Ly,(g,t)=>{if(g){try{Object.defineProperty(g,"name",{value:t})}catch{}Object.defineProperty(g,"adapterName",{value:t})}});const xT=g=>`- ${g}`,iI=g=>de.isFunction(g)||g===null||g===!1,i2={getAdapter:g=>{g=de.isArray(g)?g:[g];const{length:t}=g;let i,x;const T={};for(let E=0;E`adapter ${y} `+(e===!1?"is not supported by the environment":"is not available in the build"));let s=t?E.length>1?`since : +*/function fT(g){return g.type==="ROLL_DICE"}class du{constructor(t,i=4){this.bounds=t,this.capacity=i,this.points=[],this.divided=!1,this.cache=new Map}subdivide(){const{xMin:t,yMin:i,xMax:x,yMax:T}=this.bounds,E=(x-t)/2,s=(T-i)/2,y=t,e=i;this.northeast=new du({xMin:y+E,xMax:y+2*E,yMin:i,yMax:e+s},this.capacity),this.northwest=new du({xMin:t,xMax:y+E,yMin:i,yMax:e+s},this.capacity),this.southeast=new du({xMin:y+E,xMax:y+2*E,yMin:e+s,yMax:e+2*s},this.capacity),this.southwest=new du({xMin:t,xMax:y+E,yMin:e+s,yMax:e+2*s},this.capacity),this.divided=!0}insert(t){return this.contains(t.bounds)?this.points.length=i&&t.xMax<=T&&t.yMin>=x&&t.yMax<=E}generateCacheKey(t){const{xMin:i,xMax:x,yMin:T,yMax:E}=t;return`${i},${x},${T},${E}`}queryRange(t,i=[]){if(!this.intersects(t))return i;for(const x of this.points)this.isWithinBounds(x.bounds,t)&&i.push(x);return this.divided&&(this.northwest?.queryRange(t,i),this.northeast?.queryRange(t,i),this.southwest?.queryRange(t,i),this.southeast?.queryRange(t,i)),i}query(t,i=[]){const x=`${t.x},${t.y}`,T=this.cache.get(x);if(T)return T;if(!this.intersects({xMin:t.x,xMax:t.x,yMin:t.y,yMax:t.y}))return i;for(const E of this.points)this.isWithinRange(t,E.bounds)&&i.push(E);return this.divided&&(this.northwest?.query(t,i),this.northeast?.query(t,i),this.southwest?.query(t,i),this.southeast?.query(t,i)),this.cache.set(x,i),i}intersects(t){const{xMin:i,yMin:x,xMax:T,yMax:E}=this.bounds;return!(t.xMin>T||t.xMaxE||t.yMax=i.xMin&&t.xMin<=i.xMax&&t.yMax>=i.yMin&&t.yMin<=i.yMax}isWithinRange(t,i){return t.x>=i.xMin&&t.x<=i.xMax&&t.y>=i.yMin&&t.y<=i.yMax}}class Y4{constructor(){this.events={},this.lastEmitted=new Map}on(t,i){this.events[t]||(this.events[t]=[]),this.events[t]?.push(i)}off(t,i){this.events[t]&&(this.events[t]=this.events[t]?.filter(x=>x!==i))}emit(t,i,x=0){const T=Date.now(),E=this.lastEmitted.get(t)||0;if(T-E>=x){if(!this.events[t])return;this.events[t]?.forEach(s=>s(i)),this.lastEmitted.set(t,T)}}}const Pi=new Y4;function k4(g,t,i){let x=new Set([...t,void 0]);return g.listen((T,E)=>{x.has(E)&&i(T,E)})}function zC(g,t){return function(){return g.apply(t,arguments)}}const{toString:K4}=Object.prototype,{getPrototypeOf:$x}=Object,_m=(g=>t=>{const i=K4.call(t);return g[i]||(g[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),Vo=g=>(g=g.toLowerCase(),t=>_m(t)===g),qm=g=>t=>typeof t===g,{isArray:tc}=Array,yd=qm("undefined");function j4(g){return g!==null&&!yd(g)&&g.constructor!==null&&!yd(g.constructor)&&Ca(g.constructor.isBuffer)&&g.constructor.isBuffer(g)}const GC=Vo("ArrayBuffer");function Z4(g){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(g):t=g&&g.buffer&&GC(g.buffer),t}const J4=qm("string"),Ca=qm("function"),VC=qm("number"),tg=g=>g!==null&&typeof g=="object",$4=g=>g===!0||g===!1,_v=g=>{if(_m(g)!=="object")return!1;const t=$x(g);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in g)&&!(Symbol.iterator in g)},Q4=Vo("Date"),_4=Vo("File"),q4=Vo("Blob"),tD=Vo("FileList"),eD=g=>tg(g)&&Ca(g.pipe),iD=g=>{let t;return g&&(typeof FormData=="function"&&g instanceof FormData||Ca(g.append)&&((t=_m(g))==="formdata"||t==="object"&&Ca(g.toString)&&g.toString()==="[object FormData]"))},nD=Vo("URLSearchParams"),rD=g=>g.trim?g.trim():g.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function kd(g,t,{allOwnKeys:i=!1}={}){if(g===null||typeof g>"u")return;let x,T;if(typeof g!="object"&&(g=[g]),tc(g))for(x=0,T=g.length;x0;)if(T=i[x],t===T.toLowerCase())return T;return null}const WC=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,XC=g=>!yd(g)&&g!==WC;function by(){const{caseless:g}=XC(this)&&this||{},t={},i=(x,T)=>{const E=g&&HC(t,T)||T;_v(t[E])&&_v(x)?t[E]=by(t[E],x):_v(x)?t[E]=by({},x):tc(x)?t[E]=x.slice():t[E]=x};for(let x=0,T=arguments.length;x(kd(t,(T,E)=>{i&&Ca(T)?g[E]=zC(T,i):g[E]=T},{allOwnKeys:x}),g),aD=g=>(g.charCodeAt(0)===65279&&(g=g.slice(1)),g),oD=(g,t,i,x)=>{g.prototype=Object.create(t.prototype,x),g.prototype.constructor=g,Object.defineProperty(g,"super",{value:t.prototype}),i&&Object.assign(g.prototype,i)},lD=(g,t,i,x)=>{let T,E,s;const y={};if(t=t||{},g==null)return t;do{for(T=Object.getOwnPropertyNames(g),E=T.length;E-- >0;)s=T[E],(!x||x(s,g,t))&&!y[s]&&(t[s]=g[s],y[s]=!0);g=i!==!1&&$x(g)}while(g&&(!i||i(g,t))&&g!==Object.prototype);return t},hD=(g,t,i)=>{g=String(g),(i===void 0||i>g.length)&&(i=g.length),i-=t.length;const x=g.indexOf(t,i);return x!==-1&&x===i},uD=g=>{if(!g)return null;if(tc(g))return g;let t=g.length;if(!VC(t))return null;const i=new Array(t);for(;t-- >0;)i[t]=g[t];return i},fD=(g=>t=>g&&t instanceof g)(typeof Uint8Array<"u"&&$x(Uint8Array)),cD=(g,t)=>{const x=(g&&g[Symbol.iterator]).call(g);let T;for(;(T=x.next())&&!T.done;){const E=T.value;t.call(g,E[0],E[1])}},dD=(g,t)=>{let i;const x=[];for(;(i=g.exec(t))!==null;)x.push(i);return x},pD=Vo("HTMLFormElement"),vD=g=>g.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(i,x,T){return x.toUpperCase()+T}),cT=(({hasOwnProperty:g})=>(t,i)=>g.call(t,i))(Object.prototype),mD=Vo("RegExp"),YC=(g,t)=>{const i=Object.getOwnPropertyDescriptors(g),x={};kd(i,(T,E)=>{let s;(s=t(T,E,g))!==!1&&(x[E]=s||T)}),Object.defineProperties(g,x)},gD=g=>{YC(g,(t,i)=>{if(Ca(g)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;const x=g[i];if(Ca(x)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},yD=(g,t)=>{const i={},x=T=>{T.forEach(E=>{i[E]=!0})};return tc(g)?x(g):x(String(g).split(t)),i},xD=()=>{},SD=(g,t)=>(g=+g,Number.isFinite(g)?g:t),m0="abcdefghijklmnopqrstuvwxyz",dT="0123456789",kC={DIGIT:dT,ALPHA:m0,ALPHA_DIGIT:m0+m0.toUpperCase()+dT},TD=(g=16,t=kC.ALPHA_DIGIT)=>{let i="";const{length:x}=t;for(;g--;)i+=t[Math.random()*x|0];return i};function ED(g){return!!(g&&Ca(g.append)&&g[Symbol.toStringTag]==="FormData"&&g[Symbol.iterator])}const MD=g=>{const t=new Array(10),i=(x,T)=>{if(tg(x)){if(t.indexOf(x)>=0)return;if(!("toJSON"in x)){t[T]=x;const E=tc(x)?[]:{};return kd(x,(s,y)=>{const e=i(s,T+1);!yd(e)&&(E[y]=e)}),t[T]=void 0,E}}return x};return i(g,0)},CD=Vo("AsyncFunction"),wD=g=>g&&(tg(g)||Ca(g))&&Ca(g.then)&&Ca(g.catch),de={isArray:tc,isArrayBuffer:GC,isBuffer:j4,isFormData:iD,isArrayBufferView:Z4,isString:J4,isNumber:VC,isBoolean:$4,isObject:tg,isPlainObject:_v,isUndefined:yd,isDate:Q4,isFile:_4,isBlob:q4,isRegExp:mD,isFunction:Ca,isStream:eD,isURLSearchParams:nD,isTypedArray:fD,isFileList:tD,forEach:kd,merge:by,extend:sD,trim:rD,stripBOM:aD,inherits:oD,toFlatObject:lD,kindOf:_m,kindOfTest:Vo,endsWith:hD,toArray:uD,forEachEntry:cD,matchAll:dD,isHTMLForm:pD,hasOwnProperty:cT,hasOwnProp:cT,reduceDescriptors:YC,freezeMethods:gD,toObjectSet:yD,toCamelCase:vD,noop:xD,toFiniteNumber:SD,findKey:HC,global:WC,isContextDefined:XC,ALPHABET:kC,generateString:TD,isSpecCompliantForm:ED,toJSONObject:MD,isAsyncFn:CD,isThenable:wD};function Hi(g,t,i,x,T){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=g,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),x&&(this.request=x),T&&(this.response=T)}de.inherits(Hi,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:de.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const KC=Hi.prototype,jC={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(g=>{jC[g]={value:g}});Object.defineProperties(Hi,jC);Object.defineProperty(KC,"isAxiosError",{value:!0});Hi.from=(g,t,i,x,T,E)=>{const s=Object.create(KC);return de.toFlatObject(g,s,function(e){return e!==Error.prototype},y=>y!=="isAxiosError"),Hi.call(s,g.message,t,i,x,T),s.cause=g,s.name=g.name,E&&Object.assign(s,E),s};const AD=null;function Ly(g){return de.isPlainObject(g)||de.isArray(g)}function ZC(g){return de.endsWith(g,"[]")?g.slice(0,-2):g}function pT(g,t,i){return g?g.concat(t).map(function(T,E){return T=ZC(T),!i&&E?"["+T+"]":T}).join(i?".":""):t}function PD(g){return de.isArray(g)&&!g.some(Ly)}const RD=de.toFlatObject(de,{},null,function(t){return/^is[A-Z]/.test(t)});function eg(g,t,i){if(!de.isObject(g))throw new TypeError("target must be an object");t=t||new FormData,i=de.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,f){return!de.isUndefined(f[u])});const x=i.metaTokens,T=i.visitor||p,E=i.dots,s=i.indexes,e=(i.Blob||typeof Blob<"u"&&Blob)&&de.isSpecCompliantForm(t);if(!de.isFunction(T))throw new TypeError("visitor must be a function");function r(n){if(n===null)return"";if(de.isDate(n))return n.toISOString();if(!e&&de.isBlob(n))throw new Hi("Blob is not supported. Use a Buffer instead.");return de.isArrayBuffer(n)||de.isTypedArray(n)?e&&typeof Blob=="function"?new Blob([n]):Buffer.from(n):n}function p(n,u,f){let o=n;if(n&&!f&&typeof n=="object"){if(de.endsWith(u,"{}"))u=x?u:u.slice(0,-2),n=JSON.stringify(n);else if(de.isArray(n)&&PD(n)||(de.isFileList(n)||de.endsWith(u,"[]"))&&(o=de.toArray(n)))return u=ZC(u),o.forEach(function(d,v){!(de.isUndefined(d)||d===null)&&t.append(s===!0?pT([u],v,E):s===null?u:u+"[]",r(d))}),!1}return Ly(n)?!0:(t.append(pT(f,u,E),r(n)),!1)}const h=[],a=Object.assign(RD,{defaultVisitor:p,convertValue:r,isVisitable:Ly});function l(n,u){if(!de.isUndefined(n)){if(h.indexOf(n)!==-1)throw Error("Circular reference detected in "+u.join("."));h.push(n),de.forEach(n,function(o,c){(!(de.isUndefined(o)||o===null)&&T.call(t,o,de.isString(c)?c.trim():c,u,a))===!0&&l(o,u?u.concat(c):[c])}),h.pop()}}if(!de.isObject(g))throw new TypeError("data must be an object");return l(g),t}function vT(g){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(g).replace(/[!'()~]|%20|%00/g,function(x){return t[x]})}function Qx(g,t){this._pairs=[],g&&eg(g,this,t)}const JC=Qx.prototype;JC.append=function(t,i){this._pairs.push([t,i])};JC.toString=function(t){const i=t?function(x){return t.call(this,x,vT)}:vT;return this._pairs.map(function(T){return i(T[0])+"="+i(T[1])},"").join("&")};function bD(g){return encodeURIComponent(g).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function $C(g,t,i){if(!t)return g;const x=i&&i.encode||bD,T=i&&i.serialize;let E;if(T?E=T(t,i):E=de.isURLSearchParams(t)?t.toString():new Qx(t,i).toString(x),E){const s=g.indexOf("#");s!==-1&&(g=g.slice(0,s)),g+=(g.indexOf("?")===-1?"?":"&")+E}return g}class mT{constructor(){this.handlers=[]}use(t,i,x){return this.handlers.push({fulfilled:t,rejected:i,synchronous:x?x.synchronous:!1,runWhen:x?x.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){de.forEach(this.handlers,function(x){x!==null&&t(x)})}}const QC={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},LD=typeof URLSearchParams<"u"?URLSearchParams:Qx,FD=typeof FormData<"u"?FormData:null,OD=typeof Blob<"u"?Blob:null,DD={isBrowser:!0,classes:{URLSearchParams:LD,FormData:FD,Blob:OD},protocols:["http","https","file","blob","url","data"]},_C=typeof window<"u"&&typeof document<"u",ID=(g=>_C&&["ReactNative","NativeScript","NS"].indexOf(g)<0)(typeof navigator<"u"&&navigator.product),ND=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",BD=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:_C,hasStandardBrowserEnv:ID,hasStandardBrowserWebWorkerEnv:ND},Symbol.toStringTag,{value:"Module"})),Do={...BD,...DD};function UD(g,t){return eg(g,new Do.classes.URLSearchParams,Object.assign({visitor:function(i,x,T,E){return Do.isNode&&de.isBuffer(i)?(this.append(x,i.toString("base64")),!1):E.defaultVisitor.apply(this,arguments)}},t))}function zD(g){return de.matchAll(/\w+|\[(\w*)]/g,g).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GD(g){const t={},i=Object.keys(g);let x;const T=i.length;let E;for(x=0;x=i.length;return s=!s&&de.isArray(T)?T.length:s,e?(de.hasOwnProp(T,s)?T[s]=[T[s],x]:T[s]=x,!y):((!T[s]||!de.isObject(T[s]))&&(T[s]=[]),t(i,x,T[s],E)&&de.isArray(T[s])&&(T[s]=GD(T[s])),!y)}if(de.isFormData(g)&&de.isFunction(g.entries)){const i={};return de.forEachEntry(g,(x,T)=>{t(zD(x),T,i,0)}),i}return null}function VD(g,t,i){if(de.isString(g))try{return(t||JSON.parse)(g),de.trim(g)}catch(x){if(x.name!=="SyntaxError")throw x}return(i||JSON.stringify)(g)}const _x={transitional:QC,adapter:["xhr","http"],transformRequest:[function(t,i){const x=i.getContentType()||"",T=x.indexOf("application/json")>-1,E=de.isObject(t);if(E&&de.isHTMLForm(t)&&(t=new FormData(t)),de.isFormData(t))return T?JSON.stringify(qC(t)):t;if(de.isArrayBuffer(t)||de.isBuffer(t)||de.isStream(t)||de.isFile(t)||de.isBlob(t))return t;if(de.isArrayBufferView(t))return t.buffer;if(de.isURLSearchParams(t))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let y;if(E){if(x.indexOf("application/x-www-form-urlencoded")>-1)return UD(t,this.formSerializer).toString();if((y=de.isFileList(t))||x.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return eg(y?{"files[]":t}:t,e&&new e,this.formSerializer)}}return E||T?(i.setContentType("application/json",!1),VD(t)):t}],transformResponse:[function(t){const i=this.transitional||_x.transitional,x=i&&i.forcedJSONParsing,T=this.responseType==="json";if(t&&de.isString(t)&&(x&&!this.responseType||T)){const s=!(i&&i.silentJSONParsing)&&T;try{return JSON.parse(t)}catch(y){if(s)throw y.name==="SyntaxError"?Hi.from(y,Hi.ERR_BAD_RESPONSE,this,null,this.response):y}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Do.classes.FormData,Blob:Do.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};de.forEach(["delete","get","head","post","put","patch"],g=>{_x.headers[g]={}});const qx=_x,HD=de.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),WD=g=>{const t={};let i,x,T;return g&&g.split(` +`).forEach(function(s){T=s.indexOf(":"),i=s.substring(0,T).trim().toLowerCase(),x=s.substring(T+1).trim(),!(!i||t[i]&&HD[i])&&(i==="set-cookie"?t[i]?t[i].push(x):t[i]=[x]:t[i]=t[i]?t[i]+", "+x:x)}),t},gT=Symbol("internals");function Hc(g){return g&&String(g).trim().toLowerCase()}function qv(g){return g===!1||g==null?g:de.isArray(g)?g.map(qv):String(g)}function XD(g){const t=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let x;for(;x=i.exec(g);)t[x[1]]=x[2];return t}const YD=g=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(g.trim());function g0(g,t,i,x,T){if(de.isFunction(x))return x.call(this,t,i);if(T&&(t=i),!!de.isString(t)){if(de.isString(x))return t.indexOf(x)!==-1;if(de.isRegExp(x))return x.test(t)}}function kD(g){return g.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,i,x)=>i.toUpperCase()+x)}function KD(g,t){const i=de.toCamelCase(" "+t);["get","set","has"].forEach(x=>{Object.defineProperty(g,x+i,{value:function(T,E,s){return this[x].call(this,t,T,E,s)},configurable:!0})})}class ig{constructor(t){t&&this.set(t)}set(t,i,x){const T=this;function E(y,e,r){const p=Hc(e);if(!p)throw new Error("header name must be a non-empty string");const h=de.findKey(T,p);(!h||T[h]===void 0||r===!0||r===void 0&&T[h]!==!1)&&(T[h||e]=qv(y))}const s=(y,e)=>de.forEach(y,(r,p)=>E(r,p,e));return de.isPlainObject(t)||t instanceof this.constructor?s(t,i):de.isString(t)&&(t=t.trim())&&!YD(t)?s(WD(t),i):t!=null&&E(i,t,x),this}get(t,i){if(t=Hc(t),t){const x=de.findKey(this,t);if(x){const T=this[x];if(!i)return T;if(i===!0)return XD(T);if(de.isFunction(i))return i.call(this,T,x);if(de.isRegExp(i))return i.exec(T);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,i){if(t=Hc(t),t){const x=de.findKey(this,t);return!!(x&&this[x]!==void 0&&(!i||g0(this,this[x],x,i)))}return!1}delete(t,i){const x=this;let T=!1;function E(s){if(s=Hc(s),s){const y=de.findKey(x,s);y&&(!i||g0(x,x[y],y,i))&&(delete x[y],T=!0)}}return de.isArray(t)?t.forEach(E):E(t),T}clear(t){const i=Object.keys(this);let x=i.length,T=!1;for(;x--;){const E=i[x];(!t||g0(this,this[E],E,t,!0))&&(delete this[E],T=!0)}return T}normalize(t){const i=this,x={};return de.forEach(this,(T,E)=>{const s=de.findKey(x,E);if(s){i[s]=qv(T),delete i[E];return}const y=t?kD(E):String(E).trim();y!==E&&delete i[E],i[y]=qv(T),x[y]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const i=Object.create(null);return de.forEach(this,(x,T)=>{x!=null&&x!==!1&&(i[T]=t&&de.isArray(x)?x.join(", "):x)}),i}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,i])=>t+": "+i).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...i){const x=new this(t);return i.forEach(T=>x.set(T)),x}static accessor(t){const x=(this[gT]=this[gT]={accessors:{}}).accessors,T=this.prototype;function E(s){const y=Hc(s);x[y]||(KD(T,s),x[y]=!0)}return de.isArray(t)?t.forEach(E):E(t),this}}ig.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);de.reduceDescriptors(ig.prototype,({value:g},t)=>{let i=t[0].toUpperCase()+t.slice(1);return{get:()=>g,set(x){this[i]=x}}});de.freezeMethods(ig);const El=ig;function y0(g,t){const i=this||qx,x=t||i,T=El.from(x.headers);let E=x.data;return de.forEach(g,function(y){E=y.call(i,E,T.normalize(),t?t.status:void 0)}),T.normalize(),E}function t2(g){return!!(g&&g.__CANCEL__)}function Kd(g,t,i){Hi.call(this,g??"canceled",Hi.ERR_CANCELED,t,i),this.name="CanceledError"}de.inherits(Kd,Hi,{__CANCEL__:!0});function jD(g,t,i){const x=i.config.validateStatus;!i.status||!x||x(i.status)?g(i):t(new Hi("Request failed with status code "+i.status,[Hi.ERR_BAD_REQUEST,Hi.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}const ZD=Do.hasStandardBrowserEnv?{write(g,t,i,x,T,E){const s=[g+"="+encodeURIComponent(t)];de.isNumber(i)&&s.push("expires="+new Date(i).toGMTString()),de.isString(x)&&s.push("path="+x),de.isString(T)&&s.push("domain="+T),E===!0&&s.push("secure"),document.cookie=s.join("; ")},read(g){const t=document.cookie.match(new RegExp("(^|;\\s*)("+g+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(g){this.write(g,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function JD(g){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(g)}function $D(g,t){return t?g.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):g}function e2(g,t){return g&&!JD(t)?$D(g,t):t}const QD=Do.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");let x;function T(E){let s=E;return t&&(i.setAttribute("href",s),s=i.href),i.setAttribute("href",s),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:i.pathname.charAt(0)==="/"?i.pathname:"/"+i.pathname}}return x=T(window.location.href),function(s){const y=de.isString(s)?T(s):s;return y.protocol===x.protocol&&y.host===x.host}}():function(){return function(){return!0}}();function _D(g){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(g);return t&&t[1]||""}function qD(g,t){g=g||10;const i=new Array(g),x=new Array(g);let T=0,E=0,s;return t=t!==void 0?t:1e3,function(e){const r=Date.now(),p=x[E];s||(s=r),i[T]=e,x[T]=r;let h=E,a=0;for(;h!==T;)a+=i[h++],h=h%g;if(T=(T+1)%g,T===E&&(E=(E+1)%g),r-s{const E=T.loaded,s=T.lengthComputable?T.total:void 0,y=E-i,e=x(y),r=E<=s;i=E;const p={loaded:E,total:s,progress:s?E/s:void 0,bytes:y,rate:e||void 0,estimated:e&&s&&r?(s-E)/e:void 0,event:T};p[t?"download":"upload"]=!0,g(p)}}const tI=typeof XMLHttpRequest<"u",eI=tI&&function(g){return new Promise(function(i,x){let T=g.data;const E=El.from(g.headers).normalize();let{responseType:s,withXSRFToken:y}=g,e;function r(){g.cancelToken&&g.cancelToken.unsubscribe(e),g.signal&&g.signal.removeEventListener("abort",e)}let p;if(de.isFormData(T)){if(Do.hasStandardBrowserEnv||Do.hasStandardBrowserWebWorkerEnv)E.setContentType(!1);else if((p=E.getContentType())!==!1){const[u,...f]=p?p.split(";").map(o=>o.trim()).filter(Boolean):[];E.setContentType([u||"multipart/form-data",...f].join("; "))}}let h=new XMLHttpRequest;if(g.auth){const u=g.auth.username||"",f=g.auth.password?unescape(encodeURIComponent(g.auth.password)):"";E.set("Authorization","Basic "+btoa(u+":"+f))}const a=e2(g.baseURL,g.url);h.open(g.method.toUpperCase(),$C(a,g.params,g.paramsSerializer),!0),h.timeout=g.timeout;function l(){if(!h)return;const u=El.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),o={data:!s||s==="text"||s==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:u,config:g,request:h};jD(function(d){i(d),r()},function(d){x(d),r()},o),h=null}if("onloadend"in h?h.onloadend=l:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(l)},h.onabort=function(){h&&(x(new Hi("Request aborted",Hi.ECONNABORTED,g,h)),h=null)},h.onerror=function(){x(new Hi("Network Error",Hi.ERR_NETWORK,g,h)),h=null},h.ontimeout=function(){let f=g.timeout?"timeout of "+g.timeout+"ms exceeded":"timeout exceeded";const o=g.transitional||QC;g.timeoutErrorMessage&&(f=g.timeoutErrorMessage),x(new Hi(f,o.clarifyTimeoutError?Hi.ETIMEDOUT:Hi.ECONNABORTED,g,h)),h=null},Do.hasStandardBrowserEnv&&(y&&de.isFunction(y)&&(y=y(g)),y||y!==!1&&QD(a))){const u=g.xsrfHeaderName&&g.xsrfCookieName&&ZD.read(g.xsrfCookieName);u&&E.set(g.xsrfHeaderName,u)}T===void 0&&E.setContentType(null),"setRequestHeader"in h&&de.forEach(E.toJSON(),function(f,o){h.setRequestHeader(o,f)}),de.isUndefined(g.withCredentials)||(h.withCredentials=!!g.withCredentials),s&&s!=="json"&&(h.responseType=g.responseType),typeof g.onDownloadProgress=="function"&&h.addEventListener("progress",yT(g.onDownloadProgress,!0)),typeof g.onUploadProgress=="function"&&h.upload&&h.upload.addEventListener("progress",yT(g.onUploadProgress)),(g.cancelToken||g.signal)&&(e=u=>{h&&(x(!u||u.type?new Kd(null,g,h):u),h.abort(),h=null)},g.cancelToken&&g.cancelToken.subscribe(e),g.signal&&(g.signal.aborted?e():g.signal.addEventListener("abort",e)));const n=_D(a);if(n&&Do.protocols.indexOf(n)===-1){x(new Hi("Unsupported protocol "+n+":",Hi.ERR_BAD_REQUEST,g));return}h.send(T||null)})},Fy={http:AD,xhr:eI};de.forEach(Fy,(g,t)=>{if(g){try{Object.defineProperty(g,"name",{value:t})}catch{}Object.defineProperty(g,"adapterName",{value:t})}});const xT=g=>`- ${g}`,iI=g=>de.isFunction(g)||g===null||g===!1,i2={getAdapter:g=>{g=de.isArray(g)?g:[g];const{length:t}=g;let i,x;const T={};for(let E=0;E`adapter ${y} `+(e===!1?"is not supported by the environment":"is not available in the build"));let s=t?E.length>1?`since : `+E.map(xT).join(` -`):" "+xT(E[0]):"as no adapter specified";throw new Hi("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return x},adapters:Ly};function y0(g){if(g.cancelToken&&g.cancelToken.throwIfRequested(),g.signal&&g.signal.aborted)throw new Kd(null,g)}function ST(g){return y0(g),g.headers=El.from(g.headers),g.data=g0.call(g,g.transformRequest),["post","put","patch"].indexOf(g.method)!==-1&&g.headers.setContentType("application/x-www-form-urlencoded",!1),i2.getAdapter(g.adapter||qx.adapter)(g).then(function(x){return y0(g),x.data=g0.call(g,g.transformResponse,x),x.headers=El.from(x.headers),x},function(x){return t2(x)||(y0(g),x&&x.response&&(x.response.data=g0.call(g,g.transformResponse,x.response),x.response.headers=El.from(x.response.headers))),Promise.reject(x)})}const TT=g=>g instanceof El?g.toJSON():g;function jf(g,t){t=t||{};const i={};function x(r,p,h){return de.isPlainObject(r)&&de.isPlainObject(p)?de.merge.call({caseless:h},r,p):de.isPlainObject(p)?de.merge({},p):de.isArray(p)?p.slice():p}function T(r,p,h){if(de.isUndefined(p)){if(!de.isUndefined(r))return x(void 0,r,h)}else return x(r,p,h)}function E(r,p){if(!de.isUndefined(p))return x(void 0,p)}function s(r,p){if(de.isUndefined(p)){if(!de.isUndefined(r))return x(void 0,r)}else return x(void 0,p)}function y(r,p,h){if(h in t)return x(r,p);if(h in g)return x(void 0,r)}const e={url:E,method:E,data:E,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:y,headers:(r,p)=>T(TT(r),TT(p),!0)};return de.forEach(Object.keys(Object.assign({},g,t)),function(p){const h=e[p]||T,a=h(g[p],t[p],p);de.isUndefined(a)&&h!==y||(i[p]=a)}),i}const n2="1.6.7",t1={};["object","boolean","number","function","string","symbol"].forEach((g,t)=>{t1[g]=function(x){return typeof x===g||"a"+(t<1?"n ":" ")+g}});const ET={};t1.transitional=function(t,i,x){function T(E,s){return"[Axios v"+n2+"] Transitional option '"+E+"'"+s+(x?". "+x:"")}return(E,s,y)=>{if(t===!1)throw new Hi(T(s," has been removed"+(i?" in "+i:"")),Hi.ERR_DEPRECATED);return i&&!ET[s]&&(ET[s]=!0,console.warn(T(s," has been deprecated since v"+i+" and will be removed in the near future"))),t?t(E,s,y):!0}};function nI(g,t,i){if(typeof g!="object")throw new Hi("options must be an object",Hi.ERR_BAD_OPTION_VALUE);const x=Object.keys(g);let T=x.length;for(;T-- >0;){const E=x[T],s=t[E];if(s){const y=g[E],e=y===void 0||s(y,E,g);if(e!==!0)throw new Hi("option "+E+" must be "+e,Hi.ERR_BAD_OPTION_VALUE);continue}if(i!==!0)throw new Hi("Unknown option "+E,Hi.ERR_BAD_OPTION)}}const Fy={assertOptions:nI,validators:t1},Ql=Fy.validators;class vm{constructor(t){this.defaults=t,this.interceptors={request:new mT,response:new mT}}async request(t,i){try{return await this._request(t,i)}catch(x){if(x instanceof Error){let T;Error.captureStackTrace?Error.captureStackTrace(T={}):T=new Error;const E=T.stack?T.stack.replace(/^.+\n/,""):"";x.stack?E&&!String(x.stack).endsWith(E.replace(/^.+\n.+\n/,""))&&(x.stack+=` -`+E):x.stack=E}throw x}}_request(t,i){typeof t=="string"?(i=i||{},i.url=t):i=t||{},i=jf(this.defaults,i);const{transitional:x,paramsSerializer:T,headers:E}=i;x!==void 0&&Fy.assertOptions(x,{silentJSONParsing:Ql.transitional(Ql.boolean),forcedJSONParsing:Ql.transitional(Ql.boolean),clarifyTimeoutError:Ql.transitional(Ql.boolean)},!1),T!=null&&(de.isFunction(T)?i.paramsSerializer={serialize:T}:Fy.assertOptions(T,{encode:Ql.function,serialize:Ql.function},!0)),i.method=(i.method||this.defaults.method||"get").toLowerCase();let s=E&&de.merge(E.common,E[i.method]);E&&de.forEach(["delete","get","head","post","put","patch","common"],n=>{delete E[n]}),i.headers=El.concat(s,E);const y=[];let e=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(i)===!1||(e=e&&u.synchronous,y.unshift(u.fulfilled,u.rejected))});const r=[];this.interceptors.response.forEach(function(u){r.push(u.fulfilled,u.rejected)});let p,h=0,a;if(!e){const n=[ST.bind(this),void 0];for(n.unshift.apply(n,y),n.push.apply(n,r),a=n.length,p=Promise.resolve(i);h{if(!x._listeners)return;let E=x._listeners.length;for(;E-- >0;)x._listeners[E](T);x._listeners=null}),this.promise.then=T=>{let E;const s=new Promise(y=>{x.subscribe(y),E=y}).then(T);return s.cancel=function(){x.unsubscribe(E)},s},t(function(E,s,y){x.reason||(x.reason=new Kd(E,s,y),i(x.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const i=this._listeners.indexOf(t);i!==-1&&this._listeners.splice(i,1)}static source(){let t;return{token:new e1(function(T){t=T}),cancel:t}}}const rI=e1;function sI(g){return function(i){return g.apply(null,i)}}function aI(g){return de.isObject(g)&&g.isAxiosError===!0}const Oy={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Oy).forEach(([g,t])=>{Oy[t]=g});const oI=Oy;function r2(g){const t=new tm(g),i=zC(tm.prototype.request,t);return de.extend(i,tm.prototype,t,{allOwnKeys:!0}),de.extend(i,t,null,{allOwnKeys:!0}),i.create=function(T){return r2(jf(g,T))},i}const xn=r2(qx);xn.Axios=tm;xn.CanceledError=Kd;xn.CancelToken=rI;xn.isCancel=t2;xn.VERSION=n2;xn.toFormData=tg;xn.AxiosError=Hi;xn.Cancel=xn.CanceledError;xn.all=function(t){return Promise.all(t)};xn.spread=sI;xn.isAxiosError=aI;xn.mergeConfig=jf;xn.AxiosHeaders=El;xn.formToJSON=g=>qC(de.isHTMLForm(g)?new FormData(g):g);xn.getAdapter=i2.getAdapter;xn.HttpStatusCode=oI;xn.default=xn;const Nf="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function lI(g,t,i){for(;g.length=0;x--){const T=g%Nf.length;i=Nf.charAt(T)+i,g=Math.floor(g/Nf.length)}return lI(i,t,Nf[0])}function i1(){const g=Date.now(),t=fI(g,10),i=uI(16);return t+i}const cI={id:"",title:"",description:"",journals:[],isComplete:!1,reward:""},dI={backpack:[],equipment:{head:null,body:null,legs:null,feet:null,hands:null,weapon:null,shield:null,accessory:null}},s2={},pI={inCombat:!1,isDead:!1,isResting:!1,activeBoosts:{}},vI={username:"Guest",health:"100",mana:"100",energy:"100",maxHealth:"100",maxMana:"100",maxEnergy:"100",armour:"0",agility:"0",strength:"0",intelligence:"0",experience:"0",reputation:"0",faith:"0"},mI={stats:vI,inventory:dI,state:pI},gI={tooltipItem:{id:null,position:{x:0,y:0}},submenuItem:{id:null,position:{x:0,y:0}},tooltipNPC:{id:null,position:{x:0,y:0}},isStatsMenuCollapsed:!1},yI={gamemode:"Idle",action:{type:"ROLL_DICE",diceValues:[],isRolling:!1},textures:{side1:"",side2:"",side3:"",side4:"",side5:"",side6:""}},xI=g=>{Dr(async()=>{Zr.set({...Zr.get(),[g.id]:g})})},SI=g=>{Dr(async()=>{const t=Zr.get(),{[g]:i,...x}=t;Zr.set(x)})};function Fu(g,t){return CL(g,t,{encode(i){return JSON.stringify(i)},decode(i){try{return JSON.parse(i)}catch{return t}}})}const Sn=Fu("playerData",mI),TI=Fu("quest",cI),Zr=Fu("items",s2),Zh=Fu("notifications",[]),a2=Fu("itemDB",s2),mm=Fu("settings",gI),xd=Fu("minigameState",yI),Jh=g=>mm.get()[g],Wc=(g,t)=>{Dr(async()=>{const i=mm.get();mm.set({...i,[g]:t})})},EI=()=>{Dr(async()=>{try{const t=(await xn.get("https://kbve.com/api/itemdb.json")).data,i={};Object.keys(t.key).forEach(x=>{const T=t.key[x];i[T.id]=T,i[T.name]=T}),a2.set(i)}catch(g){console.error("Failed to reload item database:",g)}})},MI=g=>a2.get()[g],CI=g=>{Dr(async()=>{const t=Sn.get();t.inventory.backpack.push(g),Sn.set({...t})})},yl=g=>{const i=Zr.get()[g];if(i)return i;console.warn(`Item with ID ${g} not found.`)},wI=g=>{Dr(async()=>{const t=i1(),i={...g,id:t};xI(i),CI(i.id),Pi.emit("notification",{title:"Success",message:`You got a ${i.name}, verified by E Corp ID ${i.id}`,notificationType:Au.success})})},AI=(g,t)=>{Dr(async()=>{const i=Sn.get(),x=Zr.get()[t];if(x){const T=i.inventory.equipment[g];if(T){const E=Zr.get()[T];E.equipped=!1,Zr.set({...Zr.get(),[E.id]:E})}x.equipped=!0,Zr.set({...Zr.get(),[x.id]:x}),i.inventory.equipment[g]=t,Sn.set({...i})}})},PI=g=>{Dr(async()=>{const t=Sn.get(),i=t.inventory.equipment[g];if(i){const x=Zr.get()[i];x&&(x.equipped=!1,Zr.set({...Zr.get(),[x.id]:x}),t.inventory.equipment[g]=null,Sn.set({...t}))}})},MT=g=>{Dr(async()=>{const t=Sn.get(),i=Zr.get()[g];i&&!i.equipped?(t.inventory.backpack=t.inventory.backpack.filter(x=>x!==g),Sn.set({...t}),SI(g)):Pi.emit("notification",{title:"Warning",message:"Cannot remove item that is currently equipped.",notificationType:Au.warning})})},o2=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.health,10),x=Math.max(i-g,0);t.stats={...t.stats,health:x.toString()},Sn.set({...t})})},RI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.health,10),x=parseInt(t.stats.maxHealth,10),T=Math.min(i+g,x);t.stats={...t.stats,health:T.toString()},Sn.set({...t})})},bI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.mana,10),x=Math.max(i-g,0);t.stats={...t.stats,mana:x.toString()},Sn.set({...t})})},LI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.mana,10),x=parseInt(t.stats.maxMana,10),T=Math.min(i+g,x);t.stats={...t.stats,mana:T.toString()},Sn.set({...t})})},FI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.energy,10),x=Math.max(i-g,0);t.stats={...t.stats,energy:x.toString()},Sn.set({...t})})},OI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.energy,10),x=parseInt(t.stats.maxEnergy,10),T=Math.min(i+g,x);t.stats={...t.stats,energy:T.toString()},Sn.set({...t})})},DI=g=>{if(g.health!==void 0){const t=parseInt(g.health,10);t>0?RI(t):o2(Math.abs(t))}if(g.mana!==void 0){const t=parseInt(g.mana,10);t>0?LI(t):bI(Math.abs(t))}if(g.energy!==void 0){const t=parseInt(g.energy,10);t>0?OI(t):FI(Math.abs(t))}},II=async g=>{const t=i1();Dr(async()=>{const i=Sn.get();i.state.activeBoosts[t]={...g,expiry:Date.now()+g.duration*1e3},Sn.set({...i})})},NI=g=>{Dr(async()=>{const t=Sn.get(),i=g.bonuses,x={health:i?.health!==void 0?i.health.toString():void 0,mana:i?.mana!==void 0?i.mana.toString():void 0,energy:i?.energy!==void 0?i.energy.toString():void 0};DI(x),g.boost&&II(g.boost),g.action&&console.log(`Action: ${g.action}`),Sn.set({...t})})},BI=g=>{const t=yl(g);if(!t)return[];const i=["view","discard"];return t.consumable&&i.push("consume"),t.equipped?i.push("unequip"):t.consumable||i.push("equip"),i},Au={caution:{type:"caution",color:"bg-yellow-200 border-yellow-300 text-yellow-700",imgUrl:"/assets/icons/notification.svg"},warning:{type:"warning",color:"bg-orange-200 border-orange-300 text-orange-700",imgUrl:"/assets/icons/notification.svg"},danger:{type:"danger",color:"bg-red-200 border-red-300 text-red-700",imgUrl:"/assets/icons/notification.svg"},success:{type:"success",color:"bg-green-200 border-green-300 text-green-700",imgUrl:"/assets/icons/notification.svg"},info:{type:"info",color:"bg-blue-200 border-blue-300 text-blue-700",imgUrl:"/assets/icons/notification.svg"}};function jd(g){try{Dr(async()=>{const t=xd.get();xd.set({...t,...g})})}catch(t){console.error("Error updating minigame state:",t)}}function UI(g){jd({gamemode:g})}function zI(g){jd({action:g})}function GI(g){jd({textures:g})}function l2(g){const t=xd.get();t.gamemode==="Dice"&&t.action.type==="ROLL_DICE"&&jd({action:{...t.action,diceValues:g}})}function CT(g){const t=xd.get();t.gamemode==="Dice"&&t.action.type==="ROLL_DICE"&&jd({action:{...t.action,isRolling:g}})}const VI=({styleClass:g,size:t=32,color:i="#000",onClick:x,...T})=>he.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",width:t,height:t,className:g,onClick:x,...T,children:he.jsx("path",{stroke:i,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11.493 8.757L8.039 5.304 5.374 7.969l3.454 3.453-2.59 2.59 7.797.004-.017-7.784-2.525 2.525zm11.679 2.665l3.454-3.453-2.665-2.665-3.454 3.453-2.525-2.525-.017 7.784 7.797-.004-2.59-2.59zM8.828 20.578l-3.454 3.453 2.665 2.665 3.454-3.453 2.526 2.525.017-7.784-7.797.004 2.589 2.59zm16.934-2.59l-7.797-.004.017 7.784 2.525-2.525 3.454 3.453 2.665-2.665-3.454-3.453 2.59-2.59z"})}),HI=({styleClass:g,size:t=24,color:i="#000",onClick:x,...T})=>he.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",width:t,height:t,className:g,onClick:x,...T,children:he.jsx("path",{stroke:i,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 8.5V4m0 0h4.5M4 4l5.5 5.5m10.5-1V4m0 0h-4.5M20 4l-5.5 5.5M4 15.5V20m0 0h4.5M4 20l5.5-5.5m10.5 1V20m0 0h-4.5m4.5 0l-5.5-5.5"})});/** +`):" "+xT(E[0]):"as no adapter specified";throw new Hi("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return x},adapters:Fy};function x0(g){if(g.cancelToken&&g.cancelToken.throwIfRequested(),g.signal&&g.signal.aborted)throw new Kd(null,g)}function ST(g){return x0(g),g.headers=El.from(g.headers),g.data=y0.call(g,g.transformRequest),["post","put","patch"].indexOf(g.method)!==-1&&g.headers.setContentType("application/x-www-form-urlencoded",!1),i2.getAdapter(g.adapter||qx.adapter)(g).then(function(x){return x0(g),x.data=y0.call(g,g.transformResponse,x),x.headers=El.from(x.headers),x},function(x){return t2(x)||(x0(g),x&&x.response&&(x.response.data=y0.call(g,g.transformResponse,x.response),x.response.headers=El.from(x.response.headers))),Promise.reject(x)})}const TT=g=>g instanceof El?g.toJSON():g;function jf(g,t){t=t||{};const i={};function x(r,p,h){return de.isPlainObject(r)&&de.isPlainObject(p)?de.merge.call({caseless:h},r,p):de.isPlainObject(p)?de.merge({},p):de.isArray(p)?p.slice():p}function T(r,p,h){if(de.isUndefined(p)){if(!de.isUndefined(r))return x(void 0,r,h)}else return x(r,p,h)}function E(r,p){if(!de.isUndefined(p))return x(void 0,p)}function s(r,p){if(de.isUndefined(p)){if(!de.isUndefined(r))return x(void 0,r)}else return x(void 0,p)}function y(r,p,h){if(h in t)return x(r,p);if(h in g)return x(void 0,r)}const e={url:E,method:E,data:E,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:y,headers:(r,p)=>T(TT(r),TT(p),!0)};return de.forEach(Object.keys(Object.assign({},g,t)),function(p){const h=e[p]||T,a=h(g[p],t[p],p);de.isUndefined(a)&&h!==y||(i[p]=a)}),i}const n2="1.6.7",t1={};["object","boolean","number","function","string","symbol"].forEach((g,t)=>{t1[g]=function(x){return typeof x===g||"a"+(t<1?"n ":" ")+g}});const ET={};t1.transitional=function(t,i,x){function T(E,s){return"[Axios v"+n2+"] Transitional option '"+E+"'"+s+(x?". "+x:"")}return(E,s,y)=>{if(t===!1)throw new Hi(T(s," has been removed"+(i?" in "+i:"")),Hi.ERR_DEPRECATED);return i&&!ET[s]&&(ET[s]=!0,console.warn(T(s," has been deprecated since v"+i+" and will be removed in the near future"))),t?t(E,s,y):!0}};function nI(g,t,i){if(typeof g!="object")throw new Hi("options must be an object",Hi.ERR_BAD_OPTION_VALUE);const x=Object.keys(g);let T=x.length;for(;T-- >0;){const E=x[T],s=t[E];if(s){const y=g[E],e=y===void 0||s(y,E,g);if(e!==!0)throw new Hi("option "+E+" must be "+e,Hi.ERR_BAD_OPTION_VALUE);continue}if(i!==!0)throw new Hi("Unknown option "+E,Hi.ERR_BAD_OPTION)}}const Oy={assertOptions:nI,validators:t1},Ql=Oy.validators;class mm{constructor(t){this.defaults=t,this.interceptors={request:new mT,response:new mT}}async request(t,i){try{return await this._request(t,i)}catch(x){if(x instanceof Error){let T;Error.captureStackTrace?Error.captureStackTrace(T={}):T=new Error;const E=T.stack?T.stack.replace(/^.+\n/,""):"";x.stack?E&&!String(x.stack).endsWith(E.replace(/^.+\n.+\n/,""))&&(x.stack+=` +`+E):x.stack=E}throw x}}_request(t,i){typeof t=="string"?(i=i||{},i.url=t):i=t||{},i=jf(this.defaults,i);const{transitional:x,paramsSerializer:T,headers:E}=i;x!==void 0&&Oy.assertOptions(x,{silentJSONParsing:Ql.transitional(Ql.boolean),forcedJSONParsing:Ql.transitional(Ql.boolean),clarifyTimeoutError:Ql.transitional(Ql.boolean)},!1),T!=null&&(de.isFunction(T)?i.paramsSerializer={serialize:T}:Oy.assertOptions(T,{encode:Ql.function,serialize:Ql.function},!0)),i.method=(i.method||this.defaults.method||"get").toLowerCase();let s=E&&de.merge(E.common,E[i.method]);E&&de.forEach(["delete","get","head","post","put","patch","common"],n=>{delete E[n]}),i.headers=El.concat(s,E);const y=[];let e=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(i)===!1||(e=e&&u.synchronous,y.unshift(u.fulfilled,u.rejected))});const r=[];this.interceptors.response.forEach(function(u){r.push(u.fulfilled,u.rejected)});let p,h=0,a;if(!e){const n=[ST.bind(this),void 0];for(n.unshift.apply(n,y),n.push.apply(n,r),a=n.length,p=Promise.resolve(i);h{if(!x._listeners)return;let E=x._listeners.length;for(;E-- >0;)x._listeners[E](T);x._listeners=null}),this.promise.then=T=>{let E;const s=new Promise(y=>{x.subscribe(y),E=y}).then(T);return s.cancel=function(){x.unsubscribe(E)},s},t(function(E,s,y){x.reason||(x.reason=new Kd(E,s,y),i(x.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const i=this._listeners.indexOf(t);i!==-1&&this._listeners.splice(i,1)}static source(){let t;return{token:new e1(function(T){t=T}),cancel:t}}}const rI=e1;function sI(g){return function(i){return g.apply(null,i)}}function aI(g){return de.isObject(g)&&g.isAxiosError===!0}const Dy={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Dy).forEach(([g,t])=>{Dy[t]=g});const oI=Dy;function r2(g){const t=new tm(g),i=zC(tm.prototype.request,t);return de.extend(i,tm.prototype,t,{allOwnKeys:!0}),de.extend(i,t,null,{allOwnKeys:!0}),i.create=function(T){return r2(jf(g,T))},i}const mn=r2(qx);mn.Axios=tm;mn.CanceledError=Kd;mn.CancelToken=rI;mn.isCancel=t2;mn.VERSION=n2;mn.toFormData=eg;mn.AxiosError=Hi;mn.Cancel=mn.CanceledError;mn.all=function(t){return Promise.all(t)};mn.spread=sI;mn.isAxiosError=aI;mn.mergeConfig=jf;mn.AxiosHeaders=El;mn.formToJSON=g=>qC(de.isHTMLForm(g)?new FormData(g):g);mn.getAdapter=i2.getAdapter;mn.HttpStatusCode=oI;mn.default=mn;const Nf="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function lI(g,t,i){for(;g.length=0;x--){const T=g%Nf.length;i=Nf.charAt(T)+i,g=Math.floor(g/Nf.length)}return lI(i,t,Nf[0])}function i1(){const g=Date.now(),t=fI(g,10),i=uI(16);return t+i}const cI={id:"",title:"",description:"",journals:[],isComplete:!1,reward:""},dI={backpack:[],equipment:{head:null,body:null,legs:null,feet:null,hands:null,weapon:null,shield:null,accessory:null}},s2={},pI={inCombat:!1,isDead:!1,isResting:!1,activeBoosts:{}},vI={username:"Guest",health:"100",mana:"100",energy:"100",maxHealth:"100",maxMana:"100",maxEnergy:"100",armour:"0",agility:"0",strength:"0",intelligence:"0",experience:"0",reputation:"0",faith:"0"},mI={stats:vI,inventory:dI,state:pI},gI={tooltipItem:{id:null,position:{x:0,y:0}},submenuItem:{id:null,position:{x:0,y:0}},tooltipNPC:{id:null,position:{x:0,y:0}},isStatsMenuCollapsed:!1},yI={gamemode:"Idle",action:{type:"ROLL_DICE",diceValues:[],isRolling:!1},textures:{side1:"",side2:"",side3:"",side4:"",side5:"",side6:""}},xI=g=>{Dr(async()=>{Zr.set({...Zr.get(),[g.id]:g})})},SI=g=>{Dr(async()=>{const t=Zr.get(),{[g]:i,...x}=t;Zr.set(x)})};function Fu(g,t){return CL(g,t,{encode(i){return JSON.stringify(i)},decode(i){try{return JSON.parse(i)}catch{return t}}})}const Sn=Fu("playerData",mI),TI=Fu("quest",cI),Zr=Fu("items",s2),Zh=Fu("notifications",[]),a2=Fu("itemDB",s2),gm=Fu("settings",gI),xd=Fu("minigameState",yI),Jh=g=>gm.get()[g],Wc=(g,t)=>{Dr(async()=>{const i=gm.get();gm.set({...i,[g]:t})})},EI=()=>{Dr(async()=>{try{const t=(await mn.get("https://kbve.com/api/itemdb.json")).data,i={};Object.keys(t.key).forEach(x=>{const T=t.key[x];i[T.id]=T,i[T.name]=T}),a2.set(i)}catch(g){console.error("Failed to reload item database:",g)}})},MI=g=>a2.get()[g],CI=g=>{Dr(async()=>{const t=Sn.get();t.inventory.backpack.push(g),Sn.set({...t})})},yl=g=>{const i=Zr.get()[g];if(i)return i;console.warn(`Item with ID ${g} not found.`)},wI=g=>{Dr(async()=>{const t=i1(),i={...g,id:t};xI(i),CI(i.id),Pi.emit("notification",{title:"Success",message:`You got a ${i.name}, verified by E Corp ID ${i.id}`,notificationType:Au.success})})},AI=(g,t)=>{Dr(async()=>{const i=Sn.get(),x=Zr.get()[t];if(x){const T=i.inventory.equipment[g];if(T){const E=Zr.get()[T];E.equipped=!1,Zr.set({...Zr.get(),[E.id]:E})}x.equipped=!0,Zr.set({...Zr.get(),[x.id]:x}),i.inventory.equipment[g]=t,Sn.set({...i})}})},PI=g=>{Dr(async()=>{const t=Sn.get(),i=t.inventory.equipment[g];if(i){const x=Zr.get()[i];x&&(x.equipped=!1,Zr.set({...Zr.get(),[x.id]:x}),t.inventory.equipment[g]=null,Sn.set({...t}))}})},MT=g=>{Dr(async()=>{const t=Sn.get(),i=Zr.get()[g];i&&!i.equipped?(t.inventory.backpack=t.inventory.backpack.filter(x=>x!==g),Sn.set({...t}),SI(g)):Pi.emit("notification",{title:"Warning",message:"Cannot remove item that is currently equipped.",notificationType:Au.warning})})},o2=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.health,10),x=Math.max(i-g,0);t.stats={...t.stats,health:x.toString()},Sn.set({...t})})},RI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.health,10),x=parseInt(t.stats.maxHealth,10),T=Math.min(i+g,x);t.stats={...t.stats,health:T.toString()},Sn.set({...t})})},bI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.mana,10),x=Math.max(i-g,0);t.stats={...t.stats,mana:x.toString()},Sn.set({...t})})},LI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.mana,10),x=parseInt(t.stats.maxMana,10),T=Math.min(i+g,x);t.stats={...t.stats,mana:T.toString()},Sn.set({...t})})},FI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.energy,10),x=Math.max(i-g,0);t.stats={...t.stats,energy:x.toString()},Sn.set({...t})})},OI=g=>{Dr(async()=>{const t=Sn.get(),i=parseInt(t.stats.energy,10),x=parseInt(t.stats.maxEnergy,10),T=Math.min(i+g,x);t.stats={...t.stats,energy:T.toString()},Sn.set({...t})})},DI=g=>{if(g.health!==void 0){const t=parseInt(g.health,10);t>0?RI(t):o2(Math.abs(t))}if(g.mana!==void 0){const t=parseInt(g.mana,10);t>0?LI(t):bI(Math.abs(t))}if(g.energy!==void 0){const t=parseInt(g.energy,10);t>0?OI(t):FI(Math.abs(t))}},II=async g=>{const t=i1();Dr(async()=>{const i=Sn.get();i.state.activeBoosts[t]={...g,expiry:Date.now()+g.duration*1e3},Sn.set({...i})})},NI=g=>{Dr(async()=>{const t=Sn.get(),i=g.bonuses,x={health:i?.health!==void 0?i.health.toString():void 0,mana:i?.mana!==void 0?i.mana.toString():void 0,energy:i?.energy!==void 0?i.energy.toString():void 0};DI(x),g.boost&&II(g.boost),g.action&&console.log(`Action: ${g.action}`),Sn.set({...t})})},BI=g=>{const t=yl(g);if(!t)return[];const i=["view","discard"];return t.consumable&&i.push("consume"),t.equipped?i.push("unequip"):t.consumable||i.push("equip"),i},Au={caution:{type:"caution",color:"bg-yellow-200 border-yellow-300 text-yellow-700",imgUrl:"/assets/icons/notification.svg"},warning:{type:"warning",color:"bg-orange-200 border-orange-300 text-orange-700",imgUrl:"/assets/icons/notification.svg"},danger:{type:"danger",color:"bg-red-200 border-red-300 text-red-700",imgUrl:"/assets/icons/notification.svg"},success:{type:"success",color:"bg-green-200 border-green-300 text-green-700",imgUrl:"/assets/icons/notification.svg"},info:{type:"info",color:"bg-blue-200 border-blue-300 text-blue-700",imgUrl:"/assets/icons/notification.svg"}};function jd(g){try{Dr(async()=>{const t=xd.get();xd.set({...t,...g})})}catch(t){console.error("Error updating minigame state:",t)}}function UI(g){jd({gamemode:g})}function zI(g){jd({action:g})}function GI(g){jd({textures:g})}function l2(g){const t=xd.get();t.gamemode==="Dice"&&t.action.type==="ROLL_DICE"&&jd({action:{...t.action,diceValues:g}})}function CT(g){const t=xd.get();t.gamemode==="Dice"&&t.action.type==="ROLL_DICE"&&jd({action:{...t.action,isRolling:g}})}const VI=({styleClass:g,size:t=32,color:i="#000",onClick:x,...T})=>he.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",width:t,height:t,className:g,onClick:x,...T,children:he.jsx("path",{stroke:i,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11.493 8.757L8.039 5.304 5.374 7.969l3.454 3.453-2.59 2.59 7.797.004-.017-7.784-2.525 2.525zm11.679 2.665l3.454-3.453-2.665-2.665-3.454 3.453-2.525-2.525-.017 7.784 7.797-.004-2.59-2.59zM8.828 20.578l-3.454 3.453 2.665 2.665 3.454-3.453 2.526 2.525.017-7.784-7.797.004 2.589 2.59zm16.934-2.59l-7.797-.004.017 7.784 2.525-2.525 3.454 3.453 2.665-2.665-3.454-3.453 2.59-2.59z"})}),HI=({styleClass:g,size:t=24,color:i="#000",onClick:x,...T})=>he.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",width:t,height:t,className:g,onClick:x,...T,children:he.jsx("path",{stroke:i,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 8.5V4m0 0h4.5M4 4l5.5 5.5m10.5-1V4m0 0h-4.5M20 4l-5.5 5.5M4 15.5V20m0 0h4.5M4 20l5.5-5.5m10.5 1V20m0 0h-4.5m4.5 0l-5.5-5.5"})});/** * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT - */const ig="161",WI={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},XI={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},h2=0,Dy=1,u2=2,YI=3,f2=0,ng=1,hd=2,_a=3,Cl=0,ms=1,Oo=2,Ml=0,yu=1,Iy=2,Ny=3,By=4,c2=5,oh=100,d2=101,p2=102,Uy=103,zy=104,v2=200,m2=201,g2=202,y2=203,gm=204,ym=205,x2=206,S2=207,T2=208,E2=209,M2=210,C2=211,w2=212,A2=213,P2=214,R2=0,b2=1,L2=2,Sd=3,F2=4,O2=5,D2=6,I2=7,Zd=0,N2=1,B2=2,Bo=0,U2=1,z2=2,G2=3,n1=4,V2=5,H2=6,Gy="attached",W2="detached",rg=300,wl=301,vh=302,Td=303,Ed=304,ec=306,Md=1e3,Jr=1001,Cd=1002,nr=1003,xm=1004,kI=1004,fu=1005,KI=1005,Nn=1006,ud=1007,jI=1007,Io=1008,ZI=1008,Uo=1009,X2=1010,Y2=1011,sg=1012,r1=1013,xl=1014,Ea=1015,Zf=1016,s1=1017,a1=1018,uh=1020,k2=1021,ps=1023,K2=1024,j2=1025,fh=1026,Pu=1027,Z2=1028,o1=1029,J2=1030,l1=1031,h1=1033,em=33776,im=33777,nm=33778,rm=33779,Vy=35840,Hy=35841,Wy=35842,Xy=35843,u1=36196,Yy=37492,ky=37496,Ky=37808,jy=37809,Zy=37810,Jy=37811,$y=37812,Qy=37813,_y=37814,qy=37815,tx=37816,ex=37817,ix=37818,nx=37819,rx=37820,sx=37821,sm=36492,ax=36494,ox=36495,$2=36283,lx=36284,hx=36285,ux=36286,Q2=2200,_2=2201,q2=2202,wd=2300,Ad=2301,am=2302,pu=2400,vu=2401,Pd=2402,ag=2500,f1=2501,JI=0,$I=1,QI=2,c1=3e3,ch=3001,tw=3200,ew=3201,yh=0,iw=1,ea="",vr="srgb",Go="srgb-linear",og="display-p3",Jd="display-p3-linear",Rd="linear",vn="srgb",bd="rec709",Ld="p3",_I=0,hu=7680,qI=7681,t5=7682,e5=7683,i5=34055,n5=34056,r5=5386,s5=512,a5=513,o5=514,l5=515,h5=516,u5=517,f5=518,fx=519,nw=512,rw=513,sw=514,d1=515,aw=516,ow=517,lw=518,hw=519,Fd=35044,c5=35048,d5=35040,p5=35045,v5=35049,m5=35041,g5=35046,y5=35050,x5=35042,S5="100",cx="300 es",Sm=1035,No=2e3,Od=2001;class Pl{addEventListener(t,i){this._listeners===void 0&&(this._listeners={});const x=this._listeners;x[t]===void 0&&(x[t]=[]),x[t].indexOf(i)===-1&&x[t].push(i)}hasEventListener(t,i){if(this._listeners===void 0)return!1;const x=this._listeners;return x[t]!==void 0&&x[t].indexOf(i)!==-1}removeEventListener(t,i){if(this._listeners===void 0)return;const T=this._listeners[t];if(T!==void 0){const E=T.indexOf(i);E!==-1&&T.splice(E,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const x=this._listeners[t.type];if(x!==void 0){t.target=this;const T=x.slice(0);for(let E=0,s=T.length;E>8&255]+kr[g>>16&255]+kr[g>>24&255]+"-"+kr[t&255]+kr[t>>8&255]+"-"+kr[t>>16&15|64]+kr[t>>24&255]+"-"+kr[i&63|128]+kr[i>>8&255]+"-"+kr[i>>16&255]+kr[i>>24&255]+kr[x&255]+kr[x>>8&255]+kr[x>>16&255]+kr[x>>24&255]).toLowerCase()}function jn(g,t,i){return Math.max(t,Math.min(i,g))}function p1(g,t){return(g%t+t)%t}function T5(g,t,i,x,T){return x+(g-t)*(T-x)/(i-t)}function E5(g,t,i){return g!==t?(i-g)/(t-g):0}function fd(g,t,i){return(1-i)*g+i*t}function M5(g,t,i,x){return fd(g,t,1-Math.exp(-i*x))}function C5(g,t=1){return t-Math.abs(p1(g,t*2)-t)}function w5(g,t,i){return g<=t?0:g>=i?1:(g=(g-t)/(i-t),g*g*(3-2*g))}function A5(g,t,i){return g<=t?0:g>=i?1:(g=(g-t)/(i-t),g*g*g*(g*(g*6-15)+10))}function P5(g,t){return g+Math.floor(Math.random()*(t-g+1))}function R5(g,t){return g+Math.random()*(t-g)}function b5(g){return g*(.5-Math.random())}function L5(g){g!==void 0&&(wT=g);let t=wT+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function F5(g){return g*xu}function O5(g){return g*Jf}function dx(g){return(g&g-1)===0&&g!==0}function D5(g){return Math.pow(2,Math.ceil(Math.log(g)/Math.LN2))}function Tm(g){return Math.pow(2,Math.floor(Math.log(g)/Math.LN2))}function I5(g,t,i,x,T){const E=Math.cos,s=Math.sin,y=E(i/2),e=s(i/2),r=E((t+x)/2),p=s((t+x)/2),h=E((t-x)/2),a=s((t-x)/2),l=E((x-t)/2),n=s((x-t)/2);switch(T){case"XYX":g.set(y*p,e*h,e*a,y*r);break;case"YZY":g.set(e*a,y*p,e*h,y*r);break;case"ZXZ":g.set(e*h,e*a,y*p,y*r);break;case"XZX":g.set(y*p,e*n,e*l,y*r);break;case"YXY":g.set(e*l,y*p,e*n,y*r);break;case"ZYZ":g.set(e*n,e*l,y*p,y*r);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+T)}}function vs(g,t){switch(t.constructor){case Float32Array:return g;case Uint32Array:return g/4294967295;case Uint16Array:return g/65535;case Uint8Array:return g/255;case Int32Array:return Math.max(g/2147483647,-1);case Int16Array:return Math.max(g/32767,-1);case Int8Array:return Math.max(g/127,-1);default:throw new Error("Invalid component type.")}}function wi(g,t){switch(t.constructor){case Float32Array:return g;case Uint32Array:return Math.round(g*4294967295);case Uint16Array:return Math.round(g*65535);case Uint8Array:return Math.round(g*255);case Int32Array:return Math.round(g*2147483647);case Int16Array:return Math.round(g*32767);case Int8Array:return Math.round(g*127);default:throw new Error("Invalid component type.")}}const om={DEG2RAD:xu,RAD2DEG:Jf,generateUUID:na,clamp:jn,euclideanModulo:p1,mapLinear:T5,inverseLerp:E5,lerp:fd,damp:M5,pingpong:C5,smoothstep:w5,smootherstep:A5,randInt:P5,randFloat:R5,randFloatSpread:b5,seededRandom:L5,degToRad:F5,radToDeg:O5,isPowerOfTwo:dx,ceilPowerOfTwo:D5,floorPowerOfTwo:Tm,setQuaternionFromProperEuler:I5,normalize:wi,denormalize:vs};class ve{constructor(t=0,i=0){ve.prototype.isVector2=!0,this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,i){return this.x=t,this.y=i,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const i=this.x,x=this.y,T=t.elements;return this.x=T[0]*i+T[3]*x+T[6],this.y=T[1]*i+T[4]*x+T[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this}clampLength(t,i){const x=this.length();return this.divideScalar(x||1).multiplyScalar(Math.max(t,Math.min(i,x)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const x=this.dot(t)/i;return Math.acos(jn(x,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,x=this.y-t.y;return i*i+x*x}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,x){return this.x=t.x+(i.x-t.x)*x,this.y=t.y+(i.y-t.y)*x,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){const x=Math.cos(i),T=Math.sin(i),E=this.x-t.x,s=this.y-t.y;return this.x=E*x-s*T+t.x,this.y=E*T+s*x+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Oi{constructor(t,i,x,T,E,s,y,e,r){Oi.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,i,x,T,E,s,y,e,r)}set(t,i,x,T,E,s,y,e,r){const p=this.elements;return p[0]=t,p[1]=T,p[2]=y,p[3]=i,p[4]=E,p[5]=e,p[6]=x,p[7]=s,p[8]=r,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const i=this.elements,x=t.elements;return i[0]=x[0],i[1]=x[1],i[2]=x[2],i[3]=x[3],i[4]=x[4],i[5]=x[5],i[6]=x[6],i[7]=x[7],i[8]=x[8],this}extractBasis(t,i,x){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),x.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const x=t.elements,T=i.elements,E=this.elements,s=x[0],y=x[3],e=x[6],r=x[1],p=x[4],h=x[7],a=x[2],l=x[5],n=x[8],u=T[0],f=T[3],o=T[6],c=T[1],d=T[4],v=T[7],m=T[2],S=T[5],M=T[8];return E[0]=s*u+y*c+e*m,E[3]=s*f+y*d+e*S,E[6]=s*o+y*v+e*M,E[1]=r*u+p*c+h*m,E[4]=r*f+p*d+h*S,E[7]=r*o+p*v+h*M,E[2]=a*u+l*c+n*m,E[5]=a*f+l*d+n*S,E[8]=a*o+l*v+n*M,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){const t=this.elements,i=t[0],x=t[1],T=t[2],E=t[3],s=t[4],y=t[5],e=t[6],r=t[7],p=t[8];return i*s*p-i*y*r-x*E*p+x*y*e+T*E*r-T*s*e}invert(){const t=this.elements,i=t[0],x=t[1],T=t[2],E=t[3],s=t[4],y=t[5],e=t[6],r=t[7],p=t[8],h=p*s-y*r,a=y*e-p*E,l=r*E-s*e,n=i*h+x*a+T*l;if(n===0)return this.set(0,0,0,0,0,0,0,0,0);const u=1/n;return t[0]=h*u,t[1]=(T*r-p*x)*u,t[2]=(y*x-T*s)*u,t[3]=a*u,t[4]=(p*i-T*e)*u,t[5]=(T*E-y*i)*u,t[6]=l*u,t[7]=(x*e-r*i)*u,t[8]=(s*i-x*E)*u,this}transpose(){let t;const i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,x,T,E,s,y){const e=Math.cos(E),r=Math.sin(E);return this.set(x*e,x*r,-x*(e*s+r*y)+s+t,-T*r,T*e,-T*(-r*s+e*y)+y+i,0,0,1),this}scale(t,i){return this.premultiply(x0.makeScale(t,i)),this}rotate(t){return this.premultiply(x0.makeRotation(-t)),this}translate(t,i){return this.premultiply(x0.makeTranslation(t,i)),this}makeTranslation(t,i){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,i,0,0,1),this}makeRotation(t){const i=Math.cos(t),x=Math.sin(t);return this.set(i,-x,0,x,i,0,0,0,1),this}makeScale(t,i){return this.set(t,0,0,0,i,0,0,0,1),this}equals(t){const i=this.elements,x=t.elements;for(let T=0;T<9;T++)if(i[T]!==x[T])return!1;return!0}fromArray(t,i=0){for(let x=0;x<9;x++)this.elements[x]=t[x+i];return this}toArray(t=[],i=0){const x=this.elements;return t[i]=x[0],t[i+1]=x[1],t[i+2]=x[2],t[i+3]=x[3],t[i+4]=x[4],t[i+5]=x[5],t[i+6]=x[6],t[i+7]=x[7],t[i+8]=x[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const x0=new Oi;function uw(g){for(let t=g.length-1;t>=0;--t)if(g[t]>=65535)return!0;return!1}const N5={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Bf(g,t){return new N5[g](t)}function Dd(g){return document.createElementNS("http://www.w3.org/1999/xhtml",g)}function fw(){const g=Dd("canvas");return g.style.display="block",g}const AT={};function Su(g){g in AT||(AT[g]=!0,console.warn(g))}const PT=new Oi().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),RT=new Oi().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ev={[Go]:{transfer:Rd,primaries:bd,toReference:g=>g,fromReference:g=>g},[vr]:{transfer:vn,primaries:bd,toReference:g=>g.convertSRGBToLinear(),fromReference:g=>g.convertLinearToSRGB()},[Jd]:{transfer:Rd,primaries:Ld,toReference:g=>g.applyMatrix3(RT),fromReference:g=>g.applyMatrix3(PT)},[og]:{transfer:vn,primaries:Ld,toReference:g=>g.convertSRGBToLinear().applyMatrix3(RT),fromReference:g=>g.applyMatrix3(PT).convertLinearToSRGB()}},B5=new Set([Go,Jd]),rn={enabled:!0,_workingColorSpace:Go,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(g){if(!B5.has(g))throw new Error(`Unsupported working color space, "${g}".`);this._workingColorSpace=g},convert:function(g,t,i){if(this.enabled===!1||t===i||!t||!i)return g;const x=ev[t].toReference,T=ev[i].fromReference;return T(x(g))},fromWorkingColorSpace:function(g,t){return this.convert(g,this._workingColorSpace,t)},toWorkingColorSpace:function(g,t){return this.convert(g,t,this._workingColorSpace)},getPrimaries:function(g){return ev[g].primaries},getTransfer:function(g){return g===ea?Rd:ev[g].transfer}};function Xf(g){return g<.04045?g*.0773993808:Math.pow(g*.9478672986+.0521327014,2.4)}function S0(g){return g<.0031308?g*12.92:1.055*Math.pow(g,.41666)-.055}let lf;class v1{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{lf===void 0&&(lf=Dd("canvas")),lf.width=t.width,lf.height=t.height;const x=lf.getContext("2d");t instanceof ImageData?x.putImageData(t,0,0):x.drawImage(t,0,0,t.width,t.height),i=lf}return i.width>2048||i.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),i.toDataURL("image/jpeg",.6)):i.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const i=Dd("canvas");i.width=t.width,i.height=t.height;const x=i.getContext("2d");x.drawImage(t,0,0,t.width,t.height);const T=x.getImageData(0,0,t.width,t.height),E=T.data;for(let s=0;s0&&(x.userData=this.userData),i||(t.textures[this.uuid]=x),x}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==rg)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Md:t.x=t.x-Math.floor(t.x);break;case Jr:t.x=t.x<0?0:1;break;case Cd:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Md:t.y=t.y-Math.floor(t.y);break;case Jr:t.y=t.y<0?0:1;break;case Cd:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Su("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===vr?ch:c1}set encoding(t){Su("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===ch?vr:ea}}Un.DEFAULT_IMAGE=null;Un.DEFAULT_MAPPING=rg;Un.DEFAULT_ANISOTROPY=1;class sn{constructor(t=0,i=0,x=0,T=1){sn.prototype.isVector4=!0,this.x=t,this.y=i,this.z=x,this.w=T}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,i,x,T){return this.x=t,this.y=i,this.z=x,this.w=T,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this.w=t.w+i.w,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this.w+=t.w*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this.w=t.w-i.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const i=this.x,x=this.y,T=this.z,E=this.w,s=t.elements;return this.x=s[0]*i+s[4]*x+s[8]*T+s[12]*E,this.y=s[1]*i+s[5]*x+s[9]*T+s[13]*E,this.z=s[2]*i+s[6]*x+s[10]*T+s[14]*E,this.w=s[3]*i+s[7]*x+s[11]*T+s[15]*E,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const i=Math.sqrt(1-t.w*t.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/i,this.y=t.y/i,this.z=t.z/i),this}setAxisAngleFromRotationMatrix(t){let i,x,T,E;const e=t.elements,r=e[0],p=e[4],h=e[8],a=e[1],l=e[5],n=e[9],u=e[2],f=e[6],o=e[10];if(Math.abs(p-a)<.01&&Math.abs(h-u)<.01&&Math.abs(n-f)<.01){if(Math.abs(p+a)<.1&&Math.abs(h+u)<.1&&Math.abs(n+f)<.1&&Math.abs(r+l+o-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;const d=(r+1)/2,v=(l+1)/2,m=(o+1)/2,S=(p+a)/4,M=(h+u)/4,w=(n+f)/4;return d>v&&d>m?d<.01?(x=0,T=.707106781,E=.707106781):(x=Math.sqrt(d),T=S/x,E=M/x):v>m?v<.01?(x=.707106781,T=0,E=.707106781):(T=Math.sqrt(v),x=S/T,E=w/T):m<.01?(x=.707106781,T=.707106781,E=0):(E=Math.sqrt(m),x=M/E,T=w/E),this.set(x,T,E,i),this}let c=Math.sqrt((f-n)*(f-n)+(h-u)*(h-u)+(a-p)*(a-p));return Math.abs(c)<.001&&(c=1),this.x=(f-n)/c,this.y=(h-u)/c,this.z=(a-p)/c,this.w=Math.acos((r+l+o-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this.w=Math.max(t.w,Math.min(i.w,this.w)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this.w=Math.max(t,Math.min(i,this.w)),this}clampLength(t,i){const x=this.length();return this.divideScalar(x||1).multiplyScalar(Math.max(t,Math.min(i,x)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this.w+=(t.w-this.w)*i,this}lerpVectors(t,i,x){return this.x=t.x+(i.x-t.x)*x,this.y=t.y+(i.y-t.y)*x,this.z=t.z+(i.z-t.z)*x,this.w=t.w+(i.w-t.w)*x,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this.w=t[i+3],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this.w=t.getW(i),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 cw extends Pl{constructor(t=1,i=1,x={}){super(),this.isRenderTarget=!0,this.width=t,this.height=i,this.depth=1,this.scissor=new sn(0,0,t,i),this.scissorTest=!1,this.viewport=new sn(0,0,t,i);const T={width:t,height:i,depth:1};x.encoding!==void 0&&(Su("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),x.colorSpace=x.encoding===ch?vr:ea),x=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Nn,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},x),this.texture=new Un(T,x.mapping,x.wrapS,x.wrapT,x.magFilter,x.minFilter,x.format,x.type,x.anisotropy,x.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=x.generateMipmaps,this.texture.internalFormat=x.internalFormat,this.depthBuffer=x.depthBuffer,this.stencilBuffer=x.stencilBuffer,this.depthTexture=x.depthTexture,this.samples=x.samples}setSize(t,i,x=1){(this.width!==t||this.height!==i||this.depth!==x)&&(this.width=t,this.height=i,this.depth=x,this.texture.image.width=t,this.texture.image.height=i,this.texture.image.depth=x,this.dispose()),this.viewport.set(0,0,t,i),this.scissor.set(0,0,t,i)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const i=Object.assign({},t.texture.image);return this.texture.source=new mu(i),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class io extends cw{constructor(t=1,i=1,x={}){super(t,i,x),this.isWebGLRenderTarget=!0}}class lg extends Un{constructor(t=null,i=1,x=1,T=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:i,height:x,depth:T},this.magFilter=nr,this.minFilter=nr,this.wrapR=Jr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class G5 extends io{constructor(t=1,i=1,x=1,T={}){super(t,i,T),this.isWebGLArrayRenderTarget=!0,this.depth=x,this.texture=new lg(null,t,i,x),this.texture.isRenderTargetTexture=!0}}class m1 extends Un{constructor(t=null,i=1,x=1,T=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:i,height:x,depth:T},this.magFilter=nr,this.minFilter=nr,this.wrapR=Jr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class V5 extends io{constructor(t=1,i=1,x=1,T={}){super(t,i,T),this.isWebGL3DRenderTarget=!0,this.depth=x,this.texture=new m1(null,t,i,x),this.texture.isRenderTargetTexture=!0}}class H5 extends io{constructor(t=1,i=1,x=1,T={}){super(t,i,T),this.isWebGLMultipleRenderTargets=!0;const E=this.texture;this.texture=[];for(let s=0;s=0?1:-1,d=1-o*o;if(d>Number.EPSILON){const m=Math.sqrt(d),S=Math.atan2(m,o*c);f=Math.sin(f*S)/m,y=Math.sin(y*S)/m}const v=y*c;if(e=e*f+a*v,r=r*f+l*v,p=p*f+n*v,h=h*f+u*v,f===1-y){const m=1/Math.sqrt(e*e+r*r+p*p+h*h);e*=m,r*=m,p*=m,h*=m}}t[i]=e,t[i+1]=r,t[i+2]=p,t[i+3]=h}static multiplyQuaternionsFlat(t,i,x,T,E,s){const y=x[T],e=x[T+1],r=x[T+2],p=x[T+3],h=E[s],a=E[s+1],l=E[s+2],n=E[s+3];return t[i]=y*n+p*h+e*l-r*a,t[i+1]=e*n+p*a+r*h-y*l,t[i+2]=r*n+p*l+y*a-e*h,t[i+3]=p*n-y*h-e*a-r*l,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,i,x,T){return this._x=t,this._y=i,this._z=x,this._w=T,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,i=!0){const x=t._x,T=t._y,E=t._z,s=t._order,y=Math.cos,e=Math.sin,r=y(x/2),p=y(T/2),h=y(E/2),a=e(x/2),l=e(T/2),n=e(E/2);switch(s){case"XYZ":this._x=a*p*h+r*l*n,this._y=r*l*h-a*p*n,this._z=r*p*n+a*l*h,this._w=r*p*h-a*l*n;break;case"YXZ":this._x=a*p*h+r*l*n,this._y=r*l*h-a*p*n,this._z=r*p*n-a*l*h,this._w=r*p*h+a*l*n;break;case"ZXY":this._x=a*p*h-r*l*n,this._y=r*l*h+a*p*n,this._z=r*p*n+a*l*h,this._w=r*p*h-a*l*n;break;case"ZYX":this._x=a*p*h-r*l*n,this._y=r*l*h+a*p*n,this._z=r*p*n-a*l*h,this._w=r*p*h+a*l*n;break;case"YZX":this._x=a*p*h+r*l*n,this._y=r*l*h+a*p*n,this._z=r*p*n-a*l*h,this._w=r*p*h-a*l*n;break;case"XZY":this._x=a*p*h-r*l*n,this._y=r*l*h-a*p*n,this._z=r*p*n+a*l*h,this._w=r*p*h+a*l*n;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return i===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,i){const x=i/2,T=Math.sin(x);return this._x=t.x*T,this._y=t.y*T,this._z=t.z*T,this._w=Math.cos(x),this._onChangeCallback(),this}setFromRotationMatrix(t){const i=t.elements,x=i[0],T=i[4],E=i[8],s=i[1],y=i[5],e=i[9],r=i[2],p=i[6],h=i[10],a=x+y+h;if(a>0){const l=.5/Math.sqrt(a+1);this._w=.25/l,this._x=(p-e)*l,this._y=(E-r)*l,this._z=(s-T)*l}else if(x>y&&x>h){const l=2*Math.sqrt(1+x-y-h);this._w=(p-e)/l,this._x=.25*l,this._y=(T+s)/l,this._z=(E+r)/l}else if(y>h){const l=2*Math.sqrt(1+y-x-h);this._w=(E-r)/l,this._x=(T+s)/l,this._y=.25*l,this._z=(e+p)/l}else{const l=2*Math.sqrt(1+h-x-y);this._w=(s-T)/l,this._x=(E+r)/l,this._y=(e+p)/l,this._z=.25*l}return this._onChangeCallback(),this}setFromUnitVectors(t,i){let x=t.dot(i)+1;return xMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=x):(this._x=0,this._y=-t.z,this._z=t.y,this._w=x)):(this._x=t.y*i.z-t.z*i.y,this._y=t.z*i.x-t.x*i.z,this._z=t.x*i.y-t.y*i.x,this._w=x),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(jn(this.dot(t),-1,1)))}rotateTowards(t,i){const x=this.angleTo(t);if(x===0)return this;const T=Math.min(1,i/x);return this.slerp(t,T),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,i){const x=t._x,T=t._y,E=t._z,s=t._w,y=i._x,e=i._y,r=i._z,p=i._w;return this._x=x*p+s*y+T*r-E*e,this._y=T*p+s*e+E*y-x*r,this._z=E*p+s*r+x*e-T*y,this._w=s*p-x*y-T*e-E*r,this._onChangeCallback(),this}slerp(t,i){if(i===0)return this;if(i===1)return this.copy(t);const x=this._x,T=this._y,E=this._z,s=this._w;let y=s*t._w+x*t._x+T*t._y+E*t._z;if(y<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,y=-y):this.copy(t),y>=1)return this._w=s,this._x=x,this._y=T,this._z=E,this;const e=1-y*y;if(e<=Number.EPSILON){const l=1-i;return this._w=l*s+i*this._w,this._x=l*x+i*this._x,this._y=l*T+i*this._y,this._z=l*E+i*this._z,this.normalize(),this}const r=Math.sqrt(e),p=Math.atan2(r,y),h=Math.sin((1-i)*p)/r,a=Math.sin(i*p)/r;return this._w=s*h+this._w*a,this._x=x*h+this._x*a,this._y=T*h+this._y*a,this._z=E*h+this._z*a,this._onChangeCallback(),this}slerpQuaternions(t,i,x){return this.copy(t).slerp(i,x)}random(){const t=Math.random(),i=Math.sqrt(1-t),x=Math.sqrt(t),T=2*Math.PI*Math.random(),E=2*Math.PI*Math.random();return this.set(i*Math.cos(T),x*Math.sin(E),x*Math.cos(E),i*Math.sin(T))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,i=0){return this._x=t[i],this._y=t[i+1],this._z=t[i+2],this._w=t[i+3],this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._w,t}fromBufferAttribute(t,i){return this._x=t.getX(i),this._y=t.getY(i),this._z=t.getZ(i),this._w=t.getW(i),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ct{constructor(t=0,i=0,x=0){Ct.prototype.isVector3=!0,this.x=t,this.y=i,this.z=x}set(t,i,x){return x===void 0&&(x=this.z),this.x=t,this.y=i,this.z=x,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return this.applyQuaternion(bT.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(bT.setFromAxisAngle(t,i))}applyMatrix3(t){const i=this.x,x=this.y,T=this.z,E=t.elements;return this.x=E[0]*i+E[3]*x+E[6]*T,this.y=E[1]*i+E[4]*x+E[7]*T,this.z=E[2]*i+E[5]*x+E[8]*T,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const i=this.x,x=this.y,T=this.z,E=t.elements,s=1/(E[3]*i+E[7]*x+E[11]*T+E[15]);return this.x=(E[0]*i+E[4]*x+E[8]*T+E[12])*s,this.y=(E[1]*i+E[5]*x+E[9]*T+E[13])*s,this.z=(E[2]*i+E[6]*x+E[10]*T+E[14])*s,this}applyQuaternion(t){const i=this.x,x=this.y,T=this.z,E=t.x,s=t.y,y=t.z,e=t.w,r=2*(s*T-y*x),p=2*(y*i-E*T),h=2*(E*x-s*i);return this.x=i+e*r+s*h-y*p,this.y=x+e*p+y*r-E*h,this.z=T+e*h+E*p-s*r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const i=this.x,x=this.y,T=this.z,E=t.elements;return this.x=E[0]*i+E[4]*x+E[8]*T,this.y=E[1]*i+E[5]*x+E[9]*T,this.z=E[2]*i+E[6]*x+E[10]*T,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this}clampLength(t,i){const x=this.length();return this.divideScalar(x||1).multiplyScalar(Math.max(t,Math.min(i,x)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,x){return this.x=t.x+(i.x-t.x)*x,this.y=t.y+(i.y-t.y)*x,this.z=t.z+(i.z-t.z)*x,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,i){const x=t.x,T=t.y,E=t.z,s=i.x,y=i.y,e=i.z;return this.x=T*e-E*y,this.y=E*s-x*e,this.z=x*y-T*s,this}projectOnVector(t){const i=t.lengthSq();if(i===0)return this.set(0,0,0);const x=t.dot(this)/i;return this.copy(t).multiplyScalar(x)}projectOnPlane(t){return E0.copy(this).projectOnVector(t),this.sub(E0)}reflect(t){return this.sub(E0.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const x=this.dot(t)/i;return Math.acos(jn(x,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,x=this.y-t.y,T=this.z-t.z;return i*i+x*x+T*T}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,i,x){const T=Math.sin(i)*t;return this.x=T*Math.sin(x),this.y=Math.cos(i)*t,this.z=T*Math.cos(x),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,x){return this.x=t*Math.sin(i),this.y=x,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){const i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){const i=this.setFromMatrixColumn(t,0).length(),x=this.setFromMatrixColumn(t,1).length(),T=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=x,this.z=T,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=(Math.random()-.5)*2,i=Math.random()*Math.PI*2,x=Math.sqrt(1-t**2);return this.x=x*Math.cos(i),this.y=x*Math.sin(i),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const E0=new Ct,bT=new Ds;class gs{constructor(t=new Ct(1/0,1/0,1/0),i=new Ct(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=i}set(t,i){return this.min.copy(t),this.max.copy(i),this}setFromArray(t){this.makeEmpty();for(let i=0,x=t.length;ithis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,i){return i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Ja),Ja.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let i,x;return t.normal.x>0?(i=t.normal.x*this.min.x,x=t.normal.x*this.max.x):(i=t.normal.x*this.max.x,x=t.normal.x*this.min.x),t.normal.y>0?(i+=t.normal.y*this.min.y,x+=t.normal.y*this.max.y):(i+=t.normal.y*this.max.y,x+=t.normal.y*this.min.y),t.normal.z>0?(i+=t.normal.z*this.min.z,x+=t.normal.z*this.max.z):(i+=t.normal.z*this.max.z,x+=t.normal.z*this.min.z),i<=-t.constant&&x>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Xc),nv.subVectors(this.max,Xc),hf.subVectors(t.a,Xc),uf.subVectors(t.b,Xc),ff.subVectors(t.c,Xc),_l.subVectors(uf,hf),ql.subVectors(ff,uf),$h.subVectors(hf,ff);let i=[0,-_l.z,_l.y,0,-ql.z,ql.y,0,-$h.z,$h.y,_l.z,0,-_l.x,ql.z,0,-ql.x,$h.z,0,-$h.x,-_l.y,_l.x,0,-ql.y,ql.x,0,-$h.y,$h.x,0];return!M0(i,hf,uf,ff,nv)||(i=[1,0,0,0,1,0,0,0,1],!M0(i,hf,uf,ff,nv))?!1:(rv.crossVectors(_l,ql),i=[rv.x,rv.y,rv.z],M0(i,hf,uf,ff,nv))}clampPoint(t,i){return i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ja).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ja).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(hl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),hl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),hl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),hl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),hl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),hl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),hl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),hl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(hl),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const hl=[new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct],Ja=new Ct,iv=new gs,hf=new Ct,uf=new Ct,ff=new Ct,_l=new Ct,ql=new Ct,$h=new Ct,Xc=new Ct,nv=new Ct,rv=new Ct,Qh=new Ct;function M0(g,t,i,x,T){for(let E=0,s=g.length-3;E<=s;E+=3){Qh.fromArray(g,E);const y=T.x*Math.abs(Qh.x)+T.y*Math.abs(Qh.y)+T.z*Math.abs(Qh.z),e=t.dot(Qh),r=i.dot(Qh),p=x.dot(Qh);if(Math.max(-Math.max(e,r,p),Math.min(e,r,p))>y)return!1}return!0}const W5=new gs,Yc=new Ct,C0=new Ct;class $r{constructor(t=new Ct,i=-1){this.isSphere=!0,this.center=t,this.radius=i}set(t,i){return this.center.copy(t),this.radius=i,this}setFromPoints(t,i){const x=this.center;i!==void 0?x.copy(i):W5.setFromPoints(t).getCenter(x);let T=0;for(let E=0,s=t.length;Ethis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Yc.subVectors(t,this.center);const i=Yc.lengthSq();if(i>this.radius*this.radius){const x=Math.sqrt(i),T=(x-this.radius)*.5;this.center.addScaledVector(Yc,T/x),this.radius+=T}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(C0.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Yc.copy(t.center).add(C0)),this.expandByPoint(Yc.copy(t.center).sub(C0))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const ul=new Ct,w0=new Ct,sv=new Ct,th=new Ct,A0=new Ct,av=new Ct,P0=new Ct;class ic{constructor(t=new Ct,i=new Ct(0,0,-1)){this.origin=t,this.direction=i}set(t,i){return this.origin.copy(t),this.direction.copy(i),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,i){return i.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ul)),this}closestPointToPoint(t,i){i.subVectors(t,this.origin);const x=i.dot(this.direction);return x<0?i.copy(this.origin):i.copy(this.origin).addScaledVector(this.direction,x)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const i=ul.subVectors(t,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(t):(ul.copy(this.origin).addScaledVector(this.direction,i),ul.distanceToSquared(t))}distanceSqToSegment(t,i,x,T){w0.copy(t).add(i).multiplyScalar(.5),sv.copy(i).sub(t).normalize(),th.copy(this.origin).sub(w0);const E=t.distanceTo(i)*.5,s=-this.direction.dot(sv),y=th.dot(this.direction),e=-th.dot(sv),r=th.lengthSq(),p=Math.abs(1-s*s);let h,a,l,n;if(p>0)if(h=s*e-y,a=s*y-e,n=E*p,h>=0)if(a>=-n)if(a<=n){const u=1/p;h*=u,a*=u,l=h*(h+s*a+2*y)+a*(s*h+a+2*e)+r}else a=E,h=Math.max(0,-(s*a+y)),l=-h*h+a*(a+2*e)+r;else a=-E,h=Math.max(0,-(s*a+y)),l=-h*h+a*(a+2*e)+r;else a<=-n?(h=Math.max(0,-(-s*E+y)),a=h>0?-E:Math.min(Math.max(-E,-e),E),l=-h*h+a*(a+2*e)+r):a<=n?(h=0,a=Math.min(Math.max(-E,-e),E),l=a*(a+2*e)+r):(h=Math.max(0,-(s*E+y)),a=h>0?E:Math.min(Math.max(-E,-e),E),l=-h*h+a*(a+2*e)+r);else a=s>0?-E:E,h=Math.max(0,-(s*a+y)),l=-h*h+a*(a+2*e)+r;return x&&x.copy(this.origin).addScaledVector(this.direction,h),T&&T.copy(w0).addScaledVector(sv,a),l}intersectSphere(t,i){ul.subVectors(t.center,this.origin);const x=ul.dot(this.direction),T=ul.dot(ul)-x*x,E=t.radius*t.radius;if(T>E)return null;const s=Math.sqrt(E-T),y=x-s,e=x+s;return e<0?null:y<0?this.at(e,i):this.at(y,i)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const i=t.normal.dot(this.direction);if(i===0)return t.distanceToPoint(this.origin)===0?0:null;const x=-(this.origin.dot(t.normal)+t.constant)/i;return x>=0?x:null}intersectPlane(t,i){const x=this.distanceToPlane(t);return x===null?null:this.at(x,i)}intersectsPlane(t){const i=t.distanceToPoint(this.origin);return i===0||t.normal.dot(this.direction)*i<0}intersectBox(t,i){let x,T,E,s,y,e;const r=1/this.direction.x,p=1/this.direction.y,h=1/this.direction.z,a=this.origin;return r>=0?(x=(t.min.x-a.x)*r,T=(t.max.x-a.x)*r):(x=(t.max.x-a.x)*r,T=(t.min.x-a.x)*r),p>=0?(E=(t.min.y-a.y)*p,s=(t.max.y-a.y)*p):(E=(t.max.y-a.y)*p,s=(t.min.y-a.y)*p),x>s||E>T||((E>x||isNaN(x))&&(x=E),(s=0?(y=(t.min.z-a.z)*h,e=(t.max.z-a.z)*h):(y=(t.max.z-a.z)*h,e=(t.min.z-a.z)*h),x>e||y>T)||((y>x||x!==x)&&(x=y),(e=0?x:T,i)}intersectsBox(t){return this.intersectBox(t,ul)!==null}intersectTriangle(t,i,x,T,E){A0.subVectors(i,t),av.subVectors(x,t),P0.crossVectors(A0,av);let s=this.direction.dot(P0),y;if(s>0){if(T)return null;y=1}else if(s<0)y=-1,s=-s;else return null;th.subVectors(this.origin,t);const e=y*this.direction.dot(av.crossVectors(th,av));if(e<0)return null;const r=y*this.direction.dot(A0.cross(th));if(r<0||e+r>s)return null;const p=-y*th.dot(P0);return p<0?null:this.at(p/s,E)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ci{constructor(t,i,x,T,E,s,y,e,r,p,h,a,l,n,u,f){ci.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,i,x,T,E,s,y,e,r,p,h,a,l,n,u,f)}set(t,i,x,T,E,s,y,e,r,p,h,a,l,n,u,f){const o=this.elements;return o[0]=t,o[4]=i,o[8]=x,o[12]=T,o[1]=E,o[5]=s,o[9]=y,o[13]=e,o[2]=r,o[6]=p,o[10]=h,o[14]=a,o[3]=l,o[7]=n,o[11]=u,o[15]=f,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 ci().fromArray(this.elements)}copy(t){const i=this.elements,x=t.elements;return i[0]=x[0],i[1]=x[1],i[2]=x[2],i[3]=x[3],i[4]=x[4],i[5]=x[5],i[6]=x[6],i[7]=x[7],i[8]=x[8],i[9]=x[9],i[10]=x[10],i[11]=x[11],i[12]=x[12],i[13]=x[13],i[14]=x[14],i[15]=x[15],this}copyPosition(t){const i=this.elements,x=t.elements;return i[12]=x[12],i[13]=x[13],i[14]=x[14],this}setFromMatrix3(t){const i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,x){return t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),x.setFromMatrixColumn(this,2),this}makeBasis(t,i,x){return this.set(t.x,i.x,x.x,0,t.y,i.y,x.y,0,t.z,i.z,x.z,0,0,0,0,1),this}extractRotation(t){const i=this.elements,x=t.elements,T=1/cf.setFromMatrixColumn(t,0).length(),E=1/cf.setFromMatrixColumn(t,1).length(),s=1/cf.setFromMatrixColumn(t,2).length();return i[0]=x[0]*T,i[1]=x[1]*T,i[2]=x[2]*T,i[3]=0,i[4]=x[4]*E,i[5]=x[5]*E,i[6]=x[6]*E,i[7]=0,i[8]=x[8]*s,i[9]=x[9]*s,i[10]=x[10]*s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){const i=this.elements,x=t.x,T=t.y,E=t.z,s=Math.cos(x),y=Math.sin(x),e=Math.cos(T),r=Math.sin(T),p=Math.cos(E),h=Math.sin(E);if(t.order==="XYZ"){const a=s*p,l=s*h,n=y*p,u=y*h;i[0]=e*p,i[4]=-e*h,i[8]=r,i[1]=l+n*r,i[5]=a-u*r,i[9]=-y*e,i[2]=u-a*r,i[6]=n+l*r,i[10]=s*e}else if(t.order==="YXZ"){const a=e*p,l=e*h,n=r*p,u=r*h;i[0]=a+u*y,i[4]=n*y-l,i[8]=s*r,i[1]=s*h,i[5]=s*p,i[9]=-y,i[2]=l*y-n,i[6]=u+a*y,i[10]=s*e}else if(t.order==="ZXY"){const a=e*p,l=e*h,n=r*p,u=r*h;i[0]=a-u*y,i[4]=-s*h,i[8]=n+l*y,i[1]=l+n*y,i[5]=s*p,i[9]=u-a*y,i[2]=-s*r,i[6]=y,i[10]=s*e}else if(t.order==="ZYX"){const a=s*p,l=s*h,n=y*p,u=y*h;i[0]=e*p,i[4]=n*r-l,i[8]=a*r+u,i[1]=e*h,i[5]=u*r+a,i[9]=l*r-n,i[2]=-r,i[6]=y*e,i[10]=s*e}else if(t.order==="YZX"){const a=s*e,l=s*r,n=y*e,u=y*r;i[0]=e*p,i[4]=u-a*h,i[8]=n*h+l,i[1]=h,i[5]=s*p,i[9]=-y*p,i[2]=-r*p,i[6]=l*h+n,i[10]=a-u*h}else if(t.order==="XZY"){const a=s*e,l=s*r,n=y*e,u=y*r;i[0]=e*p,i[4]=-h,i[8]=r*p,i[1]=a*h+u,i[5]=s*p,i[9]=l*h-n,i[2]=n*h-l,i[6]=y*p,i[10]=u*h+a}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(X5,t,Y5)}lookAt(t,i,x){const T=this.elements;return qs.subVectors(t,i),qs.lengthSq()===0&&(qs.z=1),qs.normalize(),eh.crossVectors(x,qs),eh.lengthSq()===0&&(Math.abs(x.z)===1?qs.x+=1e-4:qs.z+=1e-4,qs.normalize(),eh.crossVectors(x,qs)),eh.normalize(),ov.crossVectors(qs,eh),T[0]=eh.x,T[4]=ov.x,T[8]=qs.x,T[1]=eh.y,T[5]=ov.y,T[9]=qs.y,T[2]=eh.z,T[6]=ov.z,T[10]=qs.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const x=t.elements,T=i.elements,E=this.elements,s=x[0],y=x[4],e=x[8],r=x[12],p=x[1],h=x[5],a=x[9],l=x[13],n=x[2],u=x[6],f=x[10],o=x[14],c=x[3],d=x[7],v=x[11],m=x[15],S=T[0],M=T[4],w=T[8],C=T[12],A=T[1],P=T[5],b=T[9],O=T[13],I=T[2],D=T[6],B=T[10],G=T[14],z=T[3],X=T[7],K=T[11],Q=T[15];return E[0]=s*S+y*A+e*I+r*z,E[4]=s*M+y*P+e*D+r*X,E[8]=s*w+y*b+e*B+r*K,E[12]=s*C+y*O+e*G+r*Q,E[1]=p*S+h*A+a*I+l*z,E[5]=p*M+h*P+a*D+l*X,E[9]=p*w+h*b+a*B+l*K,E[13]=p*C+h*O+a*G+l*Q,E[2]=n*S+u*A+f*I+o*z,E[6]=n*M+u*P+f*D+o*X,E[10]=n*w+u*b+f*B+o*K,E[14]=n*C+u*O+f*G+o*Q,E[3]=c*S+d*A+v*I+m*z,E[7]=c*M+d*P+v*D+m*X,E[11]=c*w+d*b+v*B+m*K,E[15]=c*C+d*O+v*G+m*Q,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){const t=this.elements,i=t[0],x=t[4],T=t[8],E=t[12],s=t[1],y=t[5],e=t[9],r=t[13],p=t[2],h=t[6],a=t[10],l=t[14],n=t[3],u=t[7],f=t[11],o=t[15];return n*(+E*e*h-T*r*h-E*y*a+x*r*a+T*y*l-x*e*l)+u*(+i*e*l-i*r*a+E*s*a-T*s*l+T*r*p-E*e*p)+f*(+i*r*h-i*y*l-E*s*h+x*s*l+E*y*p-x*r*p)+o*(-T*y*p-i*e*h+i*y*a+T*s*h-x*s*a+x*e*p)}transpose(){const t=this.elements;let i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,x){const T=this.elements;return t.isVector3?(T[12]=t.x,T[13]=t.y,T[14]=t.z):(T[12]=t,T[13]=i,T[14]=x),this}invert(){const t=this.elements,i=t[0],x=t[1],T=t[2],E=t[3],s=t[4],y=t[5],e=t[6],r=t[7],p=t[8],h=t[9],a=t[10],l=t[11],n=t[12],u=t[13],f=t[14],o=t[15],c=h*f*r-u*a*r+u*e*l-y*f*l-h*e*o+y*a*o,d=n*a*r-p*f*r-n*e*l+s*f*l+p*e*o-s*a*o,v=p*u*r-n*h*r+n*y*l-s*u*l-p*y*o+s*h*o,m=n*h*e-p*u*e-n*y*a+s*u*a+p*y*f-s*h*f,S=i*c+x*d+T*v+E*m;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 t[0]=c*M,t[1]=(u*a*E-h*f*E-u*T*l+x*f*l+h*T*o-x*a*o)*M,t[2]=(y*f*E-u*e*E+u*T*r-x*f*r-y*T*o+x*e*o)*M,t[3]=(h*e*E-y*a*E-h*T*r+x*a*r+y*T*l-x*e*l)*M,t[4]=d*M,t[5]=(p*f*E-n*a*E+n*T*l-i*f*l-p*T*o+i*a*o)*M,t[6]=(n*e*E-s*f*E-n*T*r+i*f*r+s*T*o-i*e*o)*M,t[7]=(s*a*E-p*e*E+p*T*r-i*a*r-s*T*l+i*e*l)*M,t[8]=v*M,t[9]=(n*h*E-p*u*E-n*x*l+i*u*l+p*x*o-i*h*o)*M,t[10]=(s*u*E-n*y*E+n*x*r-i*u*r-s*x*o+i*y*o)*M,t[11]=(p*y*E-s*h*E-p*x*r+i*h*r+s*x*l-i*y*l)*M,t[12]=m*M,t[13]=(p*u*T-n*h*T+n*x*a-i*u*a-p*x*f+i*h*f)*M,t[14]=(n*y*T-s*u*T-n*x*e+i*u*e+s*x*f-i*y*f)*M,t[15]=(s*h*T-p*y*T+p*x*e-i*h*e-s*x*a+i*y*a)*M,this}scale(t){const i=this.elements,x=t.x,T=t.y,E=t.z;return i[0]*=x,i[4]*=T,i[8]*=E,i[1]*=x,i[5]*=T,i[9]*=E,i[2]*=x,i[6]*=T,i[10]*=E,i[3]*=x,i[7]*=T,i[11]*=E,this}getMaxScaleOnAxis(){const t=this.elements,i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],x=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],T=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,x,T))}makeTranslation(t,i,x){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,i,0,0,1,x,0,0,0,1),this}makeRotationX(t){const i=Math.cos(t),x=Math.sin(t);return this.set(1,0,0,0,0,i,-x,0,0,x,i,0,0,0,0,1),this}makeRotationY(t){const i=Math.cos(t),x=Math.sin(t);return this.set(i,0,x,0,0,1,0,0,-x,0,i,0,0,0,0,1),this}makeRotationZ(t){const i=Math.cos(t),x=Math.sin(t);return this.set(i,-x,0,0,x,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){const x=Math.cos(i),T=Math.sin(i),E=1-x,s=t.x,y=t.y,e=t.z,r=E*s,p=E*y;return this.set(r*s+x,r*y-T*e,r*e+T*y,0,r*y+T*e,p*y+x,p*e-T*s,0,r*e-T*y,p*e+T*s,E*e*e+x,0,0,0,0,1),this}makeScale(t,i,x){return this.set(t,0,0,0,0,i,0,0,0,0,x,0,0,0,0,1),this}makeShear(t,i,x,T,E,s){return this.set(1,x,E,0,t,1,s,0,i,T,1,0,0,0,0,1),this}compose(t,i,x){const T=this.elements,E=i._x,s=i._y,y=i._z,e=i._w,r=E+E,p=s+s,h=y+y,a=E*r,l=E*p,n=E*h,u=s*p,f=s*h,o=y*h,c=e*r,d=e*p,v=e*h,m=x.x,S=x.y,M=x.z;return T[0]=(1-(u+o))*m,T[1]=(l+v)*m,T[2]=(n-d)*m,T[3]=0,T[4]=(l-v)*S,T[5]=(1-(a+o))*S,T[6]=(f+c)*S,T[7]=0,T[8]=(n+d)*M,T[9]=(f-c)*M,T[10]=(1-(a+u))*M,T[11]=0,T[12]=t.x,T[13]=t.y,T[14]=t.z,T[15]=1,this}decompose(t,i,x){const T=this.elements;let E=cf.set(T[0],T[1],T[2]).length();const s=cf.set(T[4],T[5],T[6]).length(),y=cf.set(T[8],T[9],T[10]).length();this.determinant()<0&&(E=-E),t.x=T[12],t.y=T[13],t.z=T[14],$a.copy(this);const r=1/E,p=1/s,h=1/y;return $a.elements[0]*=r,$a.elements[1]*=r,$a.elements[2]*=r,$a.elements[4]*=p,$a.elements[5]*=p,$a.elements[6]*=p,$a.elements[8]*=h,$a.elements[9]*=h,$a.elements[10]*=h,i.setFromRotationMatrix($a),x.x=E,x.y=s,x.z=y,this}makePerspective(t,i,x,T,E,s,y=No){const e=this.elements,r=2*E/(i-t),p=2*E/(x-T),h=(i+t)/(i-t),a=(x+T)/(x-T);let l,n;if(y===No)l=-(s+E)/(s-E),n=-2*s*E/(s-E);else if(y===Od)l=-s/(s-E),n=-s*E/(s-E);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+y);return e[0]=r,e[4]=0,e[8]=h,e[12]=0,e[1]=0,e[5]=p,e[9]=a,e[13]=0,e[2]=0,e[6]=0,e[10]=l,e[14]=n,e[3]=0,e[7]=0,e[11]=-1,e[15]=0,this}makeOrthographic(t,i,x,T,E,s,y=No){const e=this.elements,r=1/(i-t),p=1/(x-T),h=1/(s-E),a=(i+t)*r,l=(x+T)*p;let n,u;if(y===No)n=(s+E)*h,u=-2*h;else if(y===Od)n=E*h,u=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+y);return e[0]=2*r,e[4]=0,e[8]=0,e[12]=-a,e[1]=0,e[5]=2*p,e[9]=0,e[13]=-l,e[2]=0,e[6]=0,e[10]=u,e[14]=-n,e[3]=0,e[7]=0,e[11]=0,e[15]=1,this}equals(t){const i=this.elements,x=t.elements;for(let T=0;T<16;T++)if(i[T]!==x[T])return!1;return!0}fromArray(t,i=0){for(let x=0;x<16;x++)this.elements[x]=t[x+i];return this}toArray(t=[],i=0){const x=this.elements;return t[i]=x[0],t[i+1]=x[1],t[i+2]=x[2],t[i+3]=x[3],t[i+4]=x[4],t[i+5]=x[5],t[i+6]=x[6],t[i+7]=x[7],t[i+8]=x[8],t[i+9]=x[9],t[i+10]=x[10],t[i+11]=x[11],t[i+12]=x[12],t[i+13]=x[13],t[i+14]=x[14],t[i+15]=x[15],t}}const cf=new Ct,$a=new ci,X5=new Ct(0,0,0),Y5=new Ct(1,1,1),eh=new Ct,ov=new Ct,qs=new Ct,LT=new ci,FT=new Ds;class qa{constructor(t=0,i=0,x=0,T=qa.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=i,this._z=x,this._order=T}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,i,x,T=this._order){return this._x=t,this._y=i,this._z=x,this._order=T,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,i=this._order,x=!0){const T=t.elements,E=T[0],s=T[4],y=T[8],e=T[1],r=T[5],p=T[9],h=T[2],a=T[6],l=T[10];switch(i){case"XYZ":this._y=Math.asin(jn(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(-p,l),this._z=Math.atan2(-s,E)):(this._x=Math.atan2(a,r),this._z=0);break;case"YXZ":this._x=Math.asin(-jn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(y,l),this._z=Math.atan2(e,r)):(this._y=Math.atan2(-h,E),this._z=0);break;case"ZXY":this._x=Math.asin(jn(a,-1,1)),Math.abs(a)<.9999999?(this._y=Math.atan2(-h,l),this._z=Math.atan2(-s,r)):(this._y=0,this._z=Math.atan2(e,E));break;case"ZYX":this._y=Math.asin(-jn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(a,l),this._z=Math.atan2(e,E)):(this._x=0,this._z=Math.atan2(-s,r));break;case"YZX":this._z=Math.asin(jn(e,-1,1)),Math.abs(e)<.9999999?(this._x=Math.atan2(-p,r),this._y=Math.atan2(-h,E)):(this._x=0,this._y=Math.atan2(y,l));break;case"XZY":this._z=Math.asin(-jn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(a,r),this._y=Math.atan2(y,E)):(this._x=Math.atan2(-p,l),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,x===!0&&this._onChangeCallback(),this}setFromQuaternion(t,i,x){return LT.makeRotationFromQuaternion(t),this.setFromRotationMatrix(LT,i,x)}setFromVector3(t,i=this._order){return this.set(t.x,t.y,t.z,i)}reorder(t){return FT.setFromEuler(this),this.setFromQuaternion(FT,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}qa.DEFAULT_ORDER="XYZ";class Tu{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let i=0;i1){for(let x=0;x0&&(T.userData=this.userData),T.layers=this.layers.mask,T.matrix=this.matrix.toArray(),T.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(T.matrixAutoUpdate=!1),this.isInstancedMesh&&(T.type="InstancedMesh",T.count=this.count,T.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(T.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(T.type="BatchedMesh",T.perObjectFrustumCulled=this.perObjectFrustumCulled,T.sortObjects=this.sortObjects,T.drawRanges=this._drawRanges,T.reservedRanges=this._reservedRanges,T.visibility=this._visibility,T.active=this._active,T.bounds=this._bounds.map(y=>({boxInitialized:y.boxInitialized,boxMin:y.box.min.toArray(),boxMax:y.box.max.toArray(),sphereInitialized:y.sphereInitialized,sphereRadius:y.sphere.radius,sphereCenter:y.sphere.center.toArray()})),T.maxGeometryCount=this._maxGeometryCount,T.maxVertexCount=this._maxVertexCount,T.maxIndexCount=this._maxIndexCount,T.geometryInitialized=this._geometryInitialized,T.geometryCount=this._geometryCount,T.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(T.boundingSphere={center:T.boundingSphere.center.toArray(),radius:T.boundingSphere.radius}),this.boundingBox!==null&&(T.boundingBox={min:T.boundingBox.min.toArray(),max:T.boundingBox.max.toArray()}));function E(y,e){return y[e.uuid]===void 0&&(y[e.uuid]=e.toJSON(t)),e.uuid}if(this.isScene)this.background&&(this.background.isColor?T.background=this.background.toJSON():this.background.isTexture&&(T.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(T.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){T.geometry=E(t.geometries,this.geometry);const y=this.geometry.parameters;if(y!==void 0&&y.shapes!==void 0){const e=y.shapes;if(Array.isArray(e))for(let r=0,p=e.length;r0){T.children=[];for(let y=0;y0){T.animations=[];for(let y=0;y0&&(x.geometries=y),e.length>0&&(x.materials=e),r.length>0&&(x.textures=r),p.length>0&&(x.images=p),h.length>0&&(x.shapes=h),a.length>0&&(x.skeletons=a),l.length>0&&(x.animations=l),n.length>0&&(x.nodes=n)}return x.object=T,x;function s(y){const e=[];for(const r in y){const p=y[r];delete p.metadata,e.push(p)}return e}}clone(t){return new this.constructor().copy(this,t)}copy(t,i=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),i===!0)for(let x=0;x0?T.multiplyScalar(1/Math.sqrt(E)):T.set(0,0,0)}static getBarycoord(t,i,x,T,E){Qa.subVectors(T,i),cl.subVectors(x,i),R0.subVectors(t,i);const s=Qa.dot(Qa),y=Qa.dot(cl),e=Qa.dot(R0),r=cl.dot(cl),p=cl.dot(R0),h=s*r-y*y;if(h===0)return E.set(0,0,0),null;const a=1/h,l=(r*e-y*p)*a,n=(s*p-y*e)*a;return E.set(1-l-n,n,l)}static containsPoint(t,i,x,T){return this.getBarycoord(t,i,x,T,dl)===null?!1:dl.x>=0&&dl.y>=0&&dl.x+dl.y<=1}static getInterpolation(t,i,x,T,E,s,y,e){return this.getBarycoord(t,i,x,T,dl)===null?(e.x=0,e.y=0,"z"in e&&(e.z=0),"w"in e&&(e.w=0),null):(e.setScalar(0),e.addScaledVector(E,dl.x),e.addScaledVector(s,dl.y),e.addScaledVector(y,dl.z),e)}static isFrontFacing(t,i,x,T){return Qa.subVectors(x,i),cl.subVectors(t,i),Qa.cross(cl).dot(T)<0}set(t,i,x){return this.a.copy(t),this.b.copy(i),this.c.copy(x),this}setFromPointsAndIndices(t,i,x,T){return this.a.copy(t[i]),this.b.copy(t[x]),this.c.copy(t[T]),this}setFromAttributeAndIndices(t,i,x,T){return this.a.fromBufferAttribute(t,i),this.b.fromBufferAttribute(t,x),this.c.fromBufferAttribute(t,T),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Qa.subVectors(this.c,this.b),cl.subVectors(this.a,this.b),Qa.cross(cl).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ia.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return ia.getBarycoord(t,this.a,this.b,this.c,i)}getInterpolation(t,i,x,T,E){return ia.getInterpolation(t,this.a,this.b,this.c,i,x,T,E)}containsPoint(t){return ia.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ia.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){const x=this.a,T=this.b,E=this.c;let s,y;pf.subVectors(T,x),vf.subVectors(E,x),b0.subVectors(t,x);const e=pf.dot(b0),r=vf.dot(b0);if(e<=0&&r<=0)return i.copy(x);L0.subVectors(t,T);const p=pf.dot(L0),h=vf.dot(L0);if(p>=0&&h<=p)return i.copy(T);const a=e*h-p*r;if(a<=0&&e>=0&&p<=0)return s=e/(e-p),i.copy(x).addScaledVector(pf,s);F0.subVectors(t,E);const l=pf.dot(F0),n=vf.dot(F0);if(n>=0&&l<=n)return i.copy(E);const u=l*r-e*n;if(u<=0&&r>=0&&n<=0)return y=r/(r-n),i.copy(x).addScaledVector(vf,y);const f=p*n-l*h;if(f<=0&&h-p>=0&&l-n>=0)return BT.subVectors(E,T),y=(h-p)/(h-p+(l-n)),i.copy(T).addScaledVector(BT,y);const o=1/(f+u+a);return s=u*o,y=a*o,i.copy(x).addScaledVector(pf,s).addScaledVector(vf,y)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const dw={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},ih={h:0,s:0,l:0},hv={h:0,s:0,l:0};function O0(g,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?g+(t-g)*6*i:i<1/2?t:i<2/3?g+(t-g)*6*(2/3-i):g}class ze{constructor(t,i,x){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,i,x)}set(t,i,x){if(i===void 0&&x===void 0){const T=t;T&&T.isColor?this.copy(T):typeof T=="number"?this.setHex(T):typeof T=="string"&&this.setStyle(T)}else this.setRGB(t,i,x);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,i=vr){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,rn.toWorkingColorSpace(this,i),this}setRGB(t,i,x,T=rn.workingColorSpace){return this.r=t,this.g=i,this.b=x,rn.toWorkingColorSpace(this,T),this}setHSL(t,i,x,T=rn.workingColorSpace){if(t=p1(t,1),i=jn(i,0,1),x=jn(x,0,1),i===0)this.r=this.g=this.b=x;else{const E=x<=.5?x*(1+i):x+i-x*i,s=2*x-E;this.r=O0(s,E,t+1/3),this.g=O0(s,E,t),this.b=O0(s,E,t-1/3)}return rn.toWorkingColorSpace(this,T),this}setStyle(t,i=vr){function x(E){E!==void 0&&parseFloat(E)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let T;if(T=/^(\w+)\(([^\)]*)\)/.exec(t)){let E;const s=T[1],y=T[2];switch(s){case"rgb":case"rgba":if(E=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return x(E[4]),this.setRGB(Math.min(255,parseInt(E[1],10))/255,Math.min(255,parseInt(E[2],10))/255,Math.min(255,parseInt(E[3],10))/255,i);if(E=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return x(E[4]),this.setRGB(Math.min(100,parseInt(E[1],10))/100,Math.min(100,parseInt(E[2],10))/100,Math.min(100,parseInt(E[3],10))/100,i);break;case"hsl":case"hsla":if(E=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return x(E[4]),this.setHSL(parseFloat(E[1])/360,parseFloat(E[2])/100,parseFloat(E[3])/100,i);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(T=/^\#([A-Fa-f\d]+)$/.exec(t)){const E=T[1],s=E.length;if(s===3)return this.setRGB(parseInt(E.charAt(0),16)/15,parseInt(E.charAt(1),16)/15,parseInt(E.charAt(2),16)/15,i);if(s===6)return this.setHex(parseInt(E,16),i);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,i);return this}setColorName(t,i=vr){const x=dw[t.toLowerCase()];return x!==void 0?this.setHex(x,i):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Xf(t.r),this.g=Xf(t.g),this.b=Xf(t.b),this}copyLinearToSRGB(t){return this.r=S0(t.r),this.g=S0(t.g),this.b=S0(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=vr){return rn.fromWorkingColorSpace(Kr.copy(this),t),Math.round(jn(Kr.r*255,0,255))*65536+Math.round(jn(Kr.g*255,0,255))*256+Math.round(jn(Kr.b*255,0,255))}getHexString(t=vr){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,i=rn.workingColorSpace){rn.fromWorkingColorSpace(Kr.copy(this),i);const x=Kr.r,T=Kr.g,E=Kr.b,s=Math.max(x,T,E),y=Math.min(x,T,E);let e,r;const p=(y+s)/2;if(y===s)e=0,r=0;else{const h=s-y;switch(r=p<=.5?h/(s+y):h/(2-s-y),s){case x:e=(T-E)/h+(T0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const i in t){const x=t[i];if(x===void 0){console.warn(`THREE.Material: parameter '${i}' has value of undefined.`);continue}const T=this[i];if(T===void 0){console.warn(`THREE.Material: '${i}' is not a property of THREE.${this.type}.`);continue}T&&T.isColor?T.set(x):T&&T.isVector3&&x&&x.isVector3?T.copy(x):this[i]=x}}toJSON(t){const i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{}});const x={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};x.uuid=this.uuid,x.type=this.type,this.name!==""&&(x.name=this.name),this.color&&this.color.isColor&&(x.color=this.color.getHex()),this.roughness!==void 0&&(x.roughness=this.roughness),this.metalness!==void 0&&(x.metalness=this.metalness),this.sheen!==void 0&&(x.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(x.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(x.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(x.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(x.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(x.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(x.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(x.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(x.shininess=this.shininess),this.clearcoat!==void 0&&(x.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(x.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(x.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(x.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(x.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,x.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(x.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(x.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(x.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(x.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(x.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(x.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(x.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(x.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(x.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(x.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(x.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(x.lightMap=this.lightMap.toJSON(t).uuid,x.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(x.aoMap=this.aoMap.toJSON(t).uuid,x.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(x.bumpMap=this.bumpMap.toJSON(t).uuid,x.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(x.normalMap=this.normalMap.toJSON(t).uuid,x.normalMapType=this.normalMapType,x.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(x.displacementMap=this.displacementMap.toJSON(t).uuid,x.displacementScale=this.displacementScale,x.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(x.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(x.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(x.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(x.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(x.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(x.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(x.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(x.combine=this.combine)),this.envMapIntensity!==void 0&&(x.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(x.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(x.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(x.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(x.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(x.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(x.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(x.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(x.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(x.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(x.size=this.size),this.shadowSide!==null&&(x.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(x.sizeAttenuation=this.sizeAttenuation),this.blending!==yu&&(x.blending=this.blending),this.side!==Cl&&(x.side=this.side),this.vertexColors===!0&&(x.vertexColors=!0),this.opacity<1&&(x.opacity=this.opacity),this.transparent===!0&&(x.transparent=!0),this.blendSrc!==gm&&(x.blendSrc=this.blendSrc),this.blendDst!==ym&&(x.blendDst=this.blendDst),this.blendEquation!==oh&&(x.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(x.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(x.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(x.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(x.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(x.blendAlpha=this.blendAlpha),this.depthFunc!==Sd&&(x.depthFunc=this.depthFunc),this.depthTest===!1&&(x.depthTest=this.depthTest),this.depthWrite===!1&&(x.depthWrite=this.depthWrite),this.colorWrite===!1&&(x.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(x.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==fx&&(x.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(x.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(x.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==hu&&(x.stencilFail=this.stencilFail),this.stencilZFail!==hu&&(x.stencilZFail=this.stencilZFail),this.stencilZPass!==hu&&(x.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(x.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(x.rotation=this.rotation),this.polygonOffset===!0&&(x.polygonOffset=!0),this.polygonOffsetFactor!==0&&(x.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(x.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(x.linewidth=this.linewidth),this.dashSize!==void 0&&(x.dashSize=this.dashSize),this.gapSize!==void 0&&(x.gapSize=this.gapSize),this.scale!==void 0&&(x.scale=this.scale),this.dithering===!0&&(x.dithering=!0),this.alphaTest>0&&(x.alphaTest=this.alphaTest),this.alphaHash===!0&&(x.alphaHash=!0),this.alphaToCoverage===!0&&(x.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(x.premultipliedAlpha=!0),this.forceSinglePass===!0&&(x.forceSinglePass=!0),this.wireframe===!0&&(x.wireframe=!0),this.wireframeLinewidth>1&&(x.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(x.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(x.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(x.flatShading=!0),this.visible===!1&&(x.visible=!1),this.toneMapped===!1&&(x.toneMapped=!1),this.fog===!1&&(x.fog=!1),Object.keys(this.userData).length>0&&(x.userData=this.userData);function T(E){const s=[];for(const y in E){const e=E[y];delete e.metadata,s.push(e)}return s}if(i){const E=T(t.textures),s=T(t.images);E.length>0&&(x.textures=E),s.length>0&&(x.images=s)}return x}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const i=t.clippingPlanes;let x=null;if(i!==null){const T=i.length;x=new Array(T);for(let E=0;E!==T;++E)x[E]=i[E].clone()}return this.clippingPlanes=x,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class xh extends Hr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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.combine=Zd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const ml=Q5();function Q5(){const g=new ArrayBuffer(4),t=new Float32Array(g),i=new Uint32Array(g),x=new Uint32Array(512),T=new Uint32Array(512);for(let e=0;e<256;++e){const r=e-127;r<-27?(x[e]=0,x[e|256]=32768,T[e]=24,T[e|256]=24):r<-14?(x[e]=1024>>-r-14,x[e|256]=1024>>-r-14|32768,T[e]=-r-1,T[e|256]=-r-1):r<=15?(x[e]=r+15<<10,x[e|256]=r+15<<10|32768,T[e]=13,T[e|256]=13):r<128?(x[e]=31744,x[e|256]=64512,T[e]=24,T[e|256]=24):(x[e]=31744,x[e|256]=64512,T[e]=13,T[e|256]=13)}const E=new Uint32Array(2048),s=new Uint32Array(64),y=new Uint32Array(64);for(let e=1;e<1024;++e){let r=e<<13,p=0;for(;!(r&8388608);)r<<=1,p-=8388608;r&=-8388609,p+=947912704,E[e]=r|p}for(let e=1024;e<2048;++e)E[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(y[e]=1024);return{floatView:t,uint32View:i,baseTable:x,shiftTable:T,mantissaTable:E,exponentTable:s,offsetTable:y}}function Os(g){Math.abs(g)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),g=jn(g,-65504,65504),ml.floatView[0]=g;const t=ml.uint32View[0],i=t>>23&511;return ml.baseTable[i]+((t&8388607)>>ml.shiftTable[i])}function nd(g){const t=g>>10;return ml.uint32View[0]=ml.mantissaTable[ml.offsetTable[t]+(g&1023)]+ml.exponentTable[t],ml.floatView[0]}const _5={toHalfFloat:Os,fromHalfFloat:nd},ur=new Ct,uv=new ve;class an{constructor(t,i,x=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=i,this.count=t!==void 0?t.length/i:0,this.normalized=x,this.usage=Fd,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ea,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Su("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,i,x){t*=this.itemSize,x*=i.itemSize;for(let T=0,E=this.itemSize;T0&&(t.userData=this.userData),this.parameters!==void 0){const e=this.parameters;for(const r in e)e[r]!==void 0&&(t[r]=e[r]);return t}t.data={attributes:{}};const i=this.index;i!==null&&(t.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});const x=this.attributes;for(const e in x){const r=x[e];t.data.attributes[e]=r.toJSON(t.data)}const T={};let E=!1;for(const e in this.morphAttributes){const r=this.morphAttributes[e],p=[];for(let h=0,a=r.length;h0&&(T[e]=p,E=!0)}E&&(t.data.morphAttributes=T,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const y=this.boundingSphere;return y!==null&&(t.data.boundingSphere={center:y.center.toArray(),radius:y.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const i={};this.name=t.name;const x=t.index;x!==null&&this.setIndex(x.clone(i));const T=t.attributes;for(const r in T){const p=T[r];this.setAttribute(r,p.clone(i))}const E=t.morphAttributes;for(const r in E){const p=[],h=E[r];for(let a=0,l=h.length;a0){const T=i[x[0]];if(T!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let E=0,s=T.length;E(t.far-t.near)**2))&&(UT.copy(E).invert(),_h.copy(t.ray).applyMatrix4(UT),!(x.boundingBox!==null&&_h.intersectsBox(x.boundingBox)===!1)&&this._computeIntersections(t,i,_h)))}_computeIntersections(t,i,x){let T;const E=this.geometry,s=this.material,y=E.index,e=E.attributes.position,r=E.attributes.uv,p=E.attributes.uv1,h=E.attributes.normal,a=E.groups,l=E.drawRange;if(y!==null)if(Array.isArray(s))for(let n=0,u=a.length;ni.far?null:{distance:r,point:gv.clone(),object:g}}function yv(g,t,i,x,T,E,s,y,e,r){g.getVertexPosition(y,gf),g.getVertexPosition(e,yf),g.getVertexPosition(r,xf);const p=oN(g,t,i,x,gf,yf,xf,mv);if(p){T&&(dv.fromBufferAttribute(T,y),pv.fromBufferAttribute(T,e),vv.fromBufferAttribute(T,r),p.uv=ia.getInterpolation(mv,gf,yf,xf,dv,pv,vv,new ve)),E&&(dv.fromBufferAttribute(E,y),pv.fromBufferAttribute(E,e),vv.fromBufferAttribute(E,r),p.uv1=ia.getInterpolation(mv,gf,yf,xf,dv,pv,vv,new ve),p.uv2=p.uv1),s&&(GT.fromBufferAttribute(s,y),VT.fromBufferAttribute(s,e),HT.fromBufferAttribute(s,r),p.normal=ia.getInterpolation(mv,gf,yf,xf,GT,VT,HT,new Ct),p.normal.dot(x.direction)>0&&p.normal.multiplyScalar(-1));const h={a:y,b:e,c:r,normal:new Ct,materialIndex:0};ia.getNormal(gf,yf,xf,h.normal),p.face=h}return p}class Ou extends Li{constructor(t=1,i=1,x=1,T=1,E=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:i,depth:x,widthSegments:T,heightSegments:E,depthSegments:s};const y=this;T=Math.floor(T),E=Math.floor(E),s=Math.floor(s);const e=[],r=[],p=[],h=[];let a=0,l=0;n("z","y","x",-1,-1,x,i,t,s,E,0),n("z","y","x",1,-1,x,i,-t,s,E,1),n("x","z","y",1,1,t,x,i,T,s,2),n("x","z","y",1,-1,t,x,-i,T,s,3),n("x","y","z",1,-1,t,i,x,T,E,4),n("x","y","z",-1,-1,t,i,-x,T,E,5),this.setIndex(e),this.setAttribute("position",new ke(r,3)),this.setAttribute("normal",new ke(p,3)),this.setAttribute("uv",new ke(h,2));function n(u,f,o,c,d,v,m,S,M,w,C){const A=v/M,P=m/w,b=v/2,O=m/2,I=S/2,D=M+1,B=w+1;let G=0,z=0;const X=new Ct;for(let K=0;K0?1:-1,p.push(X.x,X.y,X.z),h.push(tt/M),h.push(1-K/w),G+=1}}for(let K=0;K>8&255]+kr[g>>16&255]+kr[g>>24&255]+"-"+kr[t&255]+kr[t>>8&255]+"-"+kr[t>>16&15|64]+kr[t>>24&255]+"-"+kr[i&63|128]+kr[i>>8&255]+"-"+kr[i>>16&255]+kr[i>>24&255]+kr[x&255]+kr[x>>8&255]+kr[x>>16&255]+kr[x>>24&255]).toLowerCase()}function jn(g,t,i){return Math.max(t,Math.min(i,g))}function p1(g,t){return(g%t+t)%t}function T5(g,t,i,x,T){return x+(g-t)*(T-x)/(i-t)}function E5(g,t,i){return g!==t?(i-g)/(t-g):0}function fd(g,t,i){return(1-i)*g+i*t}function M5(g,t,i,x){return fd(g,t,1-Math.exp(-i*x))}function C5(g,t=1){return t-Math.abs(p1(g,t*2)-t)}function w5(g,t,i){return g<=t?0:g>=i?1:(g=(g-t)/(i-t),g*g*(3-2*g))}function A5(g,t,i){return g<=t?0:g>=i?1:(g=(g-t)/(i-t),g*g*g*(g*(g*6-15)+10))}function P5(g,t){return g+Math.floor(Math.random()*(t-g+1))}function R5(g,t){return g+Math.random()*(t-g)}function b5(g){return g*(.5-Math.random())}function L5(g){g!==void 0&&(wT=g);let t=wT+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function F5(g){return g*xu}function O5(g){return g*Jf}function px(g){return(g&g-1)===0&&g!==0}function D5(g){return Math.pow(2,Math.ceil(Math.log(g)/Math.LN2))}function Em(g){return Math.pow(2,Math.floor(Math.log(g)/Math.LN2))}function I5(g,t,i,x,T){const E=Math.cos,s=Math.sin,y=E(i/2),e=s(i/2),r=E((t+x)/2),p=s((t+x)/2),h=E((t-x)/2),a=s((t-x)/2),l=E((x-t)/2),n=s((x-t)/2);switch(T){case"XYX":g.set(y*p,e*h,e*a,y*r);break;case"YZY":g.set(e*a,y*p,e*h,y*r);break;case"ZXZ":g.set(e*h,e*a,y*p,y*r);break;case"XZX":g.set(y*p,e*n,e*l,y*r);break;case"YXY":g.set(e*l,y*p,e*n,y*r);break;case"ZYZ":g.set(e*n,e*l,y*p,y*r);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+T)}}function vs(g,t){switch(t.constructor){case Float32Array:return g;case Uint32Array:return g/4294967295;case Uint16Array:return g/65535;case Uint8Array:return g/255;case Int32Array:return Math.max(g/2147483647,-1);case Int16Array:return Math.max(g/32767,-1);case Int8Array:return Math.max(g/127,-1);default:throw new Error("Invalid component type.")}}function wi(g,t){switch(t.constructor){case Float32Array:return g;case Uint32Array:return Math.round(g*4294967295);case Uint16Array:return Math.round(g*65535);case Uint8Array:return Math.round(g*255);case Int32Array:return Math.round(g*2147483647);case Int16Array:return Math.round(g*32767);case Int8Array:return Math.round(g*127);default:throw new Error("Invalid component type.")}}const om={DEG2RAD:xu,RAD2DEG:Jf,generateUUID:na,clamp:jn,euclideanModulo:p1,mapLinear:T5,inverseLerp:E5,lerp:fd,damp:M5,pingpong:C5,smoothstep:w5,smootherstep:A5,randInt:P5,randFloat:R5,randFloatSpread:b5,seededRandom:L5,degToRad:F5,radToDeg:O5,isPowerOfTwo:px,ceilPowerOfTwo:D5,floorPowerOfTwo:Em,setQuaternionFromProperEuler:I5,normalize:wi,denormalize:vs};class ve{constructor(t=0,i=0){ve.prototype.isVector2=!0,this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,i){return this.x=t,this.y=i,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const i=this.x,x=this.y,T=t.elements;return this.x=T[0]*i+T[3]*x+T[6],this.y=T[1]*i+T[4]*x+T[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this}clampLength(t,i){const x=this.length();return this.divideScalar(x||1).multiplyScalar(Math.max(t,Math.min(i,x)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const x=this.dot(t)/i;return Math.acos(jn(x,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,x=this.y-t.y;return i*i+x*x}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,x){return this.x=t.x+(i.x-t.x)*x,this.y=t.y+(i.y-t.y)*x,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){const x=Math.cos(i),T=Math.sin(i),E=this.x-t.x,s=this.y-t.y;return this.x=E*x-s*T+t.x,this.y=E*T+s*x+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Oi{constructor(t,i,x,T,E,s,y,e,r){Oi.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,i,x,T,E,s,y,e,r)}set(t,i,x,T,E,s,y,e,r){const p=this.elements;return p[0]=t,p[1]=T,p[2]=y,p[3]=i,p[4]=E,p[5]=e,p[6]=x,p[7]=s,p[8]=r,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const i=this.elements,x=t.elements;return i[0]=x[0],i[1]=x[1],i[2]=x[2],i[3]=x[3],i[4]=x[4],i[5]=x[5],i[6]=x[6],i[7]=x[7],i[8]=x[8],this}extractBasis(t,i,x){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),x.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const x=t.elements,T=i.elements,E=this.elements,s=x[0],y=x[3],e=x[6],r=x[1],p=x[4],h=x[7],a=x[2],l=x[5],n=x[8],u=T[0],f=T[3],o=T[6],c=T[1],d=T[4],v=T[7],m=T[2],S=T[5],M=T[8];return E[0]=s*u+y*c+e*m,E[3]=s*f+y*d+e*S,E[6]=s*o+y*v+e*M,E[1]=r*u+p*c+h*m,E[4]=r*f+p*d+h*S,E[7]=r*o+p*v+h*M,E[2]=a*u+l*c+n*m,E[5]=a*f+l*d+n*S,E[8]=a*o+l*v+n*M,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){const t=this.elements,i=t[0],x=t[1],T=t[2],E=t[3],s=t[4],y=t[5],e=t[6],r=t[7],p=t[8];return i*s*p-i*y*r-x*E*p+x*y*e+T*E*r-T*s*e}invert(){const t=this.elements,i=t[0],x=t[1],T=t[2],E=t[3],s=t[4],y=t[5],e=t[6],r=t[7],p=t[8],h=p*s-y*r,a=y*e-p*E,l=r*E-s*e,n=i*h+x*a+T*l;if(n===0)return this.set(0,0,0,0,0,0,0,0,0);const u=1/n;return t[0]=h*u,t[1]=(T*r-p*x)*u,t[2]=(y*x-T*s)*u,t[3]=a*u,t[4]=(p*i-T*e)*u,t[5]=(T*E-y*i)*u,t[6]=l*u,t[7]=(x*e-r*i)*u,t[8]=(s*i-x*E)*u,this}transpose(){let t;const i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,x,T,E,s,y){const e=Math.cos(E),r=Math.sin(E);return this.set(x*e,x*r,-x*(e*s+r*y)+s+t,-T*r,T*e,-T*(-r*s+e*y)+y+i,0,0,1),this}scale(t,i){return this.premultiply(S0.makeScale(t,i)),this}rotate(t){return this.premultiply(S0.makeRotation(-t)),this}translate(t,i){return this.premultiply(S0.makeTranslation(t,i)),this}makeTranslation(t,i){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,i,0,0,1),this}makeRotation(t){const i=Math.cos(t),x=Math.sin(t);return this.set(i,-x,0,x,i,0,0,0,1),this}makeScale(t,i){return this.set(t,0,0,0,i,0,0,0,1),this}equals(t){const i=this.elements,x=t.elements;for(let T=0;T<9;T++)if(i[T]!==x[T])return!1;return!0}fromArray(t,i=0){for(let x=0;x<9;x++)this.elements[x]=t[x+i];return this}toArray(t=[],i=0){const x=this.elements;return t[i]=x[0],t[i+1]=x[1],t[i+2]=x[2],t[i+3]=x[3],t[i+4]=x[4],t[i+5]=x[5],t[i+6]=x[6],t[i+7]=x[7],t[i+8]=x[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const S0=new Oi;function uw(g){for(let t=g.length-1;t>=0;--t)if(g[t]>=65535)return!0;return!1}const N5={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Bf(g,t){return new N5[g](t)}function Dd(g){return document.createElementNS("http://www.w3.org/1999/xhtml",g)}function fw(){const g=Dd("canvas");return g.style.display="block",g}const AT={};function Su(g){g in AT||(AT[g]=!0,console.warn(g))}const PT=new Oi().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),RT=new Oi().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ev={[Go]:{transfer:Rd,primaries:bd,toReference:g=>g,fromReference:g=>g},[vr]:{transfer:vn,primaries:bd,toReference:g=>g.convertSRGBToLinear(),fromReference:g=>g.convertLinearToSRGB()},[Jd]:{transfer:Rd,primaries:Ld,toReference:g=>g.applyMatrix3(RT),fromReference:g=>g.applyMatrix3(PT)},[lg]:{transfer:vn,primaries:Ld,toReference:g=>g.convertSRGBToLinear().applyMatrix3(RT),fromReference:g=>g.applyMatrix3(PT).convertLinearToSRGB()}},B5=new Set([Go,Jd]),rn={enabled:!0,_workingColorSpace:Go,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(g){if(!B5.has(g))throw new Error(`Unsupported working color space, "${g}".`);this._workingColorSpace=g},convert:function(g,t,i){if(this.enabled===!1||t===i||!t||!i)return g;const x=ev[t].toReference,T=ev[i].fromReference;return T(x(g))},fromWorkingColorSpace:function(g,t){return this.convert(g,this._workingColorSpace,t)},toWorkingColorSpace:function(g,t){return this.convert(g,t,this._workingColorSpace)},getPrimaries:function(g){return ev[g].primaries},getTransfer:function(g){return g===ea?Rd:ev[g].transfer}};function Xf(g){return g<.04045?g*.0773993808:Math.pow(g*.9478672986+.0521327014,2.4)}function T0(g){return g<.0031308?g*12.92:1.055*Math.pow(g,.41666)-.055}let lf;class v1{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{lf===void 0&&(lf=Dd("canvas")),lf.width=t.width,lf.height=t.height;const x=lf.getContext("2d");t instanceof ImageData?x.putImageData(t,0,0):x.drawImage(t,0,0,t.width,t.height),i=lf}return i.width>2048||i.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),i.toDataURL("image/jpeg",.6)):i.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const i=Dd("canvas");i.width=t.width,i.height=t.height;const x=i.getContext("2d");x.drawImage(t,0,0,t.width,t.height);const T=x.getImageData(0,0,t.width,t.height),E=T.data;for(let s=0;s0&&(x.userData=this.userData),i||(t.textures[this.uuid]=x),x}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==sg)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Md:t.x=t.x-Math.floor(t.x);break;case Jr:t.x=t.x<0?0:1;break;case Cd:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Md:t.y=t.y-Math.floor(t.y);break;case Jr:t.y=t.y<0?0:1;break;case Cd:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Su("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===vr?ch:c1}set encoding(t){Su("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===ch?vr:ea}}Un.DEFAULT_IMAGE=null;Un.DEFAULT_MAPPING=sg;Un.DEFAULT_ANISOTROPY=1;class sn{constructor(t=0,i=0,x=0,T=1){sn.prototype.isVector4=!0,this.x=t,this.y=i,this.z=x,this.w=T}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,i,x,T){return this.x=t,this.y=i,this.z=x,this.w=T,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this.w=t.w+i.w,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this.w+=t.w*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this.w=t.w-i.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const i=this.x,x=this.y,T=this.z,E=this.w,s=t.elements;return this.x=s[0]*i+s[4]*x+s[8]*T+s[12]*E,this.y=s[1]*i+s[5]*x+s[9]*T+s[13]*E,this.z=s[2]*i+s[6]*x+s[10]*T+s[14]*E,this.w=s[3]*i+s[7]*x+s[11]*T+s[15]*E,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const i=Math.sqrt(1-t.w*t.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/i,this.y=t.y/i,this.z=t.z/i),this}setAxisAngleFromRotationMatrix(t){let i,x,T,E;const e=t.elements,r=e[0],p=e[4],h=e[8],a=e[1],l=e[5],n=e[9],u=e[2],f=e[6],o=e[10];if(Math.abs(p-a)<.01&&Math.abs(h-u)<.01&&Math.abs(n-f)<.01){if(Math.abs(p+a)<.1&&Math.abs(h+u)<.1&&Math.abs(n+f)<.1&&Math.abs(r+l+o-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;const d=(r+1)/2,v=(l+1)/2,m=(o+1)/2,S=(p+a)/4,M=(h+u)/4,w=(n+f)/4;return d>v&&d>m?d<.01?(x=0,T=.707106781,E=.707106781):(x=Math.sqrt(d),T=S/x,E=M/x):v>m?v<.01?(x=.707106781,T=0,E=.707106781):(T=Math.sqrt(v),x=S/T,E=w/T):m<.01?(x=.707106781,T=.707106781,E=0):(E=Math.sqrt(m),x=M/E,T=w/E),this.set(x,T,E,i),this}let c=Math.sqrt((f-n)*(f-n)+(h-u)*(h-u)+(a-p)*(a-p));return Math.abs(c)<.001&&(c=1),this.x=(f-n)/c,this.y=(h-u)/c,this.z=(a-p)/c,this.w=Math.acos((r+l+o-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this.w=Math.max(t.w,Math.min(i.w,this.w)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this.w=Math.max(t,Math.min(i,this.w)),this}clampLength(t,i){const x=this.length();return this.divideScalar(x||1).multiplyScalar(Math.max(t,Math.min(i,x)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this.w+=(t.w-this.w)*i,this}lerpVectors(t,i,x){return this.x=t.x+(i.x-t.x)*x,this.y=t.y+(i.y-t.y)*x,this.z=t.z+(i.z-t.z)*x,this.w=t.w+(i.w-t.w)*x,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this.w=t[i+3],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this.w=t.getW(i),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 cw extends Pl{constructor(t=1,i=1,x={}){super(),this.isRenderTarget=!0,this.width=t,this.height=i,this.depth=1,this.scissor=new sn(0,0,t,i),this.scissorTest=!1,this.viewport=new sn(0,0,t,i);const T={width:t,height:i,depth:1};x.encoding!==void 0&&(Su("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),x.colorSpace=x.encoding===ch?vr:ea),x=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Nn,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},x),this.texture=new Un(T,x.mapping,x.wrapS,x.wrapT,x.magFilter,x.minFilter,x.format,x.type,x.anisotropy,x.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=x.generateMipmaps,this.texture.internalFormat=x.internalFormat,this.depthBuffer=x.depthBuffer,this.stencilBuffer=x.stencilBuffer,this.depthTexture=x.depthTexture,this.samples=x.samples}setSize(t,i,x=1){(this.width!==t||this.height!==i||this.depth!==x)&&(this.width=t,this.height=i,this.depth=x,this.texture.image.width=t,this.texture.image.height=i,this.texture.image.depth=x,this.dispose()),this.viewport.set(0,0,t,i),this.scissor.set(0,0,t,i)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const i=Object.assign({},t.texture.image);return this.texture.source=new mu(i),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class io extends cw{constructor(t=1,i=1,x={}){super(t,i,x),this.isWebGLRenderTarget=!0}}class hg extends Un{constructor(t=null,i=1,x=1,T=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:i,height:x,depth:T},this.magFilter=nr,this.minFilter=nr,this.wrapR=Jr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class G5 extends io{constructor(t=1,i=1,x=1,T={}){super(t,i,T),this.isWebGLArrayRenderTarget=!0,this.depth=x,this.texture=new hg(null,t,i,x),this.texture.isRenderTargetTexture=!0}}class m1 extends Un{constructor(t=null,i=1,x=1,T=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:i,height:x,depth:T},this.magFilter=nr,this.minFilter=nr,this.wrapR=Jr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class V5 extends io{constructor(t=1,i=1,x=1,T={}){super(t,i,T),this.isWebGL3DRenderTarget=!0,this.depth=x,this.texture=new m1(null,t,i,x),this.texture.isRenderTargetTexture=!0}}class H5 extends io{constructor(t=1,i=1,x=1,T={}){super(t,i,T),this.isWebGLMultipleRenderTargets=!0;const E=this.texture;this.texture=[];for(let s=0;s=0?1:-1,d=1-o*o;if(d>Number.EPSILON){const m=Math.sqrt(d),S=Math.atan2(m,o*c);f=Math.sin(f*S)/m,y=Math.sin(y*S)/m}const v=y*c;if(e=e*f+a*v,r=r*f+l*v,p=p*f+n*v,h=h*f+u*v,f===1-y){const m=1/Math.sqrt(e*e+r*r+p*p+h*h);e*=m,r*=m,p*=m,h*=m}}t[i]=e,t[i+1]=r,t[i+2]=p,t[i+3]=h}static multiplyQuaternionsFlat(t,i,x,T,E,s){const y=x[T],e=x[T+1],r=x[T+2],p=x[T+3],h=E[s],a=E[s+1],l=E[s+2],n=E[s+3];return t[i]=y*n+p*h+e*l-r*a,t[i+1]=e*n+p*a+r*h-y*l,t[i+2]=r*n+p*l+y*a-e*h,t[i+3]=p*n-y*h-e*a-r*l,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,i,x,T){return this._x=t,this._y=i,this._z=x,this._w=T,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,i=!0){const x=t._x,T=t._y,E=t._z,s=t._order,y=Math.cos,e=Math.sin,r=y(x/2),p=y(T/2),h=y(E/2),a=e(x/2),l=e(T/2),n=e(E/2);switch(s){case"XYZ":this._x=a*p*h+r*l*n,this._y=r*l*h-a*p*n,this._z=r*p*n+a*l*h,this._w=r*p*h-a*l*n;break;case"YXZ":this._x=a*p*h+r*l*n,this._y=r*l*h-a*p*n,this._z=r*p*n-a*l*h,this._w=r*p*h+a*l*n;break;case"ZXY":this._x=a*p*h-r*l*n,this._y=r*l*h+a*p*n,this._z=r*p*n+a*l*h,this._w=r*p*h-a*l*n;break;case"ZYX":this._x=a*p*h-r*l*n,this._y=r*l*h+a*p*n,this._z=r*p*n-a*l*h,this._w=r*p*h+a*l*n;break;case"YZX":this._x=a*p*h+r*l*n,this._y=r*l*h+a*p*n,this._z=r*p*n-a*l*h,this._w=r*p*h-a*l*n;break;case"XZY":this._x=a*p*h-r*l*n,this._y=r*l*h-a*p*n,this._z=r*p*n+a*l*h,this._w=r*p*h+a*l*n;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return i===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,i){const x=i/2,T=Math.sin(x);return this._x=t.x*T,this._y=t.y*T,this._z=t.z*T,this._w=Math.cos(x),this._onChangeCallback(),this}setFromRotationMatrix(t){const i=t.elements,x=i[0],T=i[4],E=i[8],s=i[1],y=i[5],e=i[9],r=i[2],p=i[6],h=i[10],a=x+y+h;if(a>0){const l=.5/Math.sqrt(a+1);this._w=.25/l,this._x=(p-e)*l,this._y=(E-r)*l,this._z=(s-T)*l}else if(x>y&&x>h){const l=2*Math.sqrt(1+x-y-h);this._w=(p-e)/l,this._x=.25*l,this._y=(T+s)/l,this._z=(E+r)/l}else if(y>h){const l=2*Math.sqrt(1+y-x-h);this._w=(E-r)/l,this._x=(T+s)/l,this._y=.25*l,this._z=(e+p)/l}else{const l=2*Math.sqrt(1+h-x-y);this._w=(s-T)/l,this._x=(E+r)/l,this._y=(e+p)/l,this._z=.25*l}return this._onChangeCallback(),this}setFromUnitVectors(t,i){let x=t.dot(i)+1;return xMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=x):(this._x=0,this._y=-t.z,this._z=t.y,this._w=x)):(this._x=t.y*i.z-t.z*i.y,this._y=t.z*i.x-t.x*i.z,this._z=t.x*i.y-t.y*i.x,this._w=x),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(jn(this.dot(t),-1,1)))}rotateTowards(t,i){const x=this.angleTo(t);if(x===0)return this;const T=Math.min(1,i/x);return this.slerp(t,T),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,i){const x=t._x,T=t._y,E=t._z,s=t._w,y=i._x,e=i._y,r=i._z,p=i._w;return this._x=x*p+s*y+T*r-E*e,this._y=T*p+s*e+E*y-x*r,this._z=E*p+s*r+x*e-T*y,this._w=s*p-x*y-T*e-E*r,this._onChangeCallback(),this}slerp(t,i){if(i===0)return this;if(i===1)return this.copy(t);const x=this._x,T=this._y,E=this._z,s=this._w;let y=s*t._w+x*t._x+T*t._y+E*t._z;if(y<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,y=-y):this.copy(t),y>=1)return this._w=s,this._x=x,this._y=T,this._z=E,this;const e=1-y*y;if(e<=Number.EPSILON){const l=1-i;return this._w=l*s+i*this._w,this._x=l*x+i*this._x,this._y=l*T+i*this._y,this._z=l*E+i*this._z,this.normalize(),this}const r=Math.sqrt(e),p=Math.atan2(r,y),h=Math.sin((1-i)*p)/r,a=Math.sin(i*p)/r;return this._w=s*h+this._w*a,this._x=x*h+this._x*a,this._y=T*h+this._y*a,this._z=E*h+this._z*a,this._onChangeCallback(),this}slerpQuaternions(t,i,x){return this.copy(t).slerp(i,x)}random(){const t=Math.random(),i=Math.sqrt(1-t),x=Math.sqrt(t),T=2*Math.PI*Math.random(),E=2*Math.PI*Math.random();return this.set(i*Math.cos(T),x*Math.sin(E),x*Math.cos(E),i*Math.sin(T))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,i=0){return this._x=t[i],this._y=t[i+1],this._z=t[i+2],this._w=t[i+3],this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._w,t}fromBufferAttribute(t,i){return this._x=t.getX(i),this._y=t.getY(i),this._z=t.getZ(i),this._w=t.getW(i),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ct{constructor(t=0,i=0,x=0){Ct.prototype.isVector3=!0,this.x=t,this.y=i,this.z=x}set(t,i,x){return x===void 0&&(x=this.z),this.x=t,this.y=i,this.z=x,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return this.applyQuaternion(bT.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(bT.setFromAxisAngle(t,i))}applyMatrix3(t){const i=this.x,x=this.y,T=this.z,E=t.elements;return this.x=E[0]*i+E[3]*x+E[6]*T,this.y=E[1]*i+E[4]*x+E[7]*T,this.z=E[2]*i+E[5]*x+E[8]*T,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const i=this.x,x=this.y,T=this.z,E=t.elements,s=1/(E[3]*i+E[7]*x+E[11]*T+E[15]);return this.x=(E[0]*i+E[4]*x+E[8]*T+E[12])*s,this.y=(E[1]*i+E[5]*x+E[9]*T+E[13])*s,this.z=(E[2]*i+E[6]*x+E[10]*T+E[14])*s,this}applyQuaternion(t){const i=this.x,x=this.y,T=this.z,E=t.x,s=t.y,y=t.z,e=t.w,r=2*(s*T-y*x),p=2*(y*i-E*T),h=2*(E*x-s*i);return this.x=i+e*r+s*h-y*p,this.y=x+e*p+y*r-E*h,this.z=T+e*h+E*p-s*r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const i=this.x,x=this.y,T=this.z,E=t.elements;return this.x=E[0]*i+E[4]*x+E[8]*T,this.y=E[1]*i+E[5]*x+E[9]*T,this.z=E[2]*i+E[6]*x+E[10]*T,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this}clampLength(t,i){const x=this.length();return this.divideScalar(x||1).multiplyScalar(Math.max(t,Math.min(i,x)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,x){return this.x=t.x+(i.x-t.x)*x,this.y=t.y+(i.y-t.y)*x,this.z=t.z+(i.z-t.z)*x,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,i){const x=t.x,T=t.y,E=t.z,s=i.x,y=i.y,e=i.z;return this.x=T*e-E*y,this.y=E*s-x*e,this.z=x*y-T*s,this}projectOnVector(t){const i=t.lengthSq();if(i===0)return this.set(0,0,0);const x=t.dot(this)/i;return this.copy(t).multiplyScalar(x)}projectOnPlane(t){return M0.copy(this).projectOnVector(t),this.sub(M0)}reflect(t){return this.sub(M0.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const x=this.dot(t)/i;return Math.acos(jn(x,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,x=this.y-t.y,T=this.z-t.z;return i*i+x*x+T*T}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,i,x){const T=Math.sin(i)*t;return this.x=T*Math.sin(x),this.y=Math.cos(i)*t,this.z=T*Math.cos(x),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,x){return this.x=t*Math.sin(i),this.y=x,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){const i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){const i=this.setFromMatrixColumn(t,0).length(),x=this.setFromMatrixColumn(t,1).length(),T=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=x,this.z=T,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i){return this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=(Math.random()-.5)*2,i=Math.random()*Math.PI*2,x=Math.sqrt(1-t**2);return this.x=x*Math.cos(i),this.y=x*Math.sin(i),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const M0=new Ct,bT=new Ds;class gs{constructor(t=new Ct(1/0,1/0,1/0),i=new Ct(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=i}set(t,i){return this.min.copy(t),this.max.copy(i),this}setFromArray(t){this.makeEmpty();for(let i=0,x=t.length;ithis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,i){return i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Ja),Ja.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let i,x;return t.normal.x>0?(i=t.normal.x*this.min.x,x=t.normal.x*this.max.x):(i=t.normal.x*this.max.x,x=t.normal.x*this.min.x),t.normal.y>0?(i+=t.normal.y*this.min.y,x+=t.normal.y*this.max.y):(i+=t.normal.y*this.max.y,x+=t.normal.y*this.min.y),t.normal.z>0?(i+=t.normal.z*this.min.z,x+=t.normal.z*this.max.z):(i+=t.normal.z*this.max.z,x+=t.normal.z*this.min.z),i<=-t.constant&&x>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Xc),nv.subVectors(this.max,Xc),hf.subVectors(t.a,Xc),uf.subVectors(t.b,Xc),ff.subVectors(t.c,Xc),_l.subVectors(uf,hf),ql.subVectors(ff,uf),$h.subVectors(hf,ff);let i=[0,-_l.z,_l.y,0,-ql.z,ql.y,0,-$h.z,$h.y,_l.z,0,-_l.x,ql.z,0,-ql.x,$h.z,0,-$h.x,-_l.y,_l.x,0,-ql.y,ql.x,0,-$h.y,$h.x,0];return!C0(i,hf,uf,ff,nv)||(i=[1,0,0,0,1,0,0,0,1],!C0(i,hf,uf,ff,nv))?!1:(rv.crossVectors(_l,ql),i=[rv.x,rv.y,rv.z],C0(i,hf,uf,ff,nv))}clampPoint(t,i){return i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ja).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ja).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(hl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),hl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),hl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),hl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),hl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),hl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),hl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),hl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(hl),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const hl=[new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct],Ja=new Ct,iv=new gs,hf=new Ct,uf=new Ct,ff=new Ct,_l=new Ct,ql=new Ct,$h=new Ct,Xc=new Ct,nv=new Ct,rv=new Ct,Qh=new Ct;function C0(g,t,i,x,T){for(let E=0,s=g.length-3;E<=s;E+=3){Qh.fromArray(g,E);const y=T.x*Math.abs(Qh.x)+T.y*Math.abs(Qh.y)+T.z*Math.abs(Qh.z),e=t.dot(Qh),r=i.dot(Qh),p=x.dot(Qh);if(Math.max(-Math.max(e,r,p),Math.min(e,r,p))>y)return!1}return!0}const W5=new gs,Yc=new Ct,w0=new Ct;class $r{constructor(t=new Ct,i=-1){this.isSphere=!0,this.center=t,this.radius=i}set(t,i){return this.center.copy(t),this.radius=i,this}setFromPoints(t,i){const x=this.center;i!==void 0?x.copy(i):W5.setFromPoints(t).getCenter(x);let T=0;for(let E=0,s=t.length;Ethis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Yc.subVectors(t,this.center);const i=Yc.lengthSq();if(i>this.radius*this.radius){const x=Math.sqrt(i),T=(x-this.radius)*.5;this.center.addScaledVector(Yc,T/x),this.radius+=T}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(w0.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Yc.copy(t.center).add(w0)),this.expandByPoint(Yc.copy(t.center).sub(w0))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const ul=new Ct,A0=new Ct,sv=new Ct,th=new Ct,P0=new Ct,av=new Ct,R0=new Ct;class ic{constructor(t=new Ct,i=new Ct(0,0,-1)){this.origin=t,this.direction=i}set(t,i){return this.origin.copy(t),this.direction.copy(i),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,i){return i.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ul)),this}closestPointToPoint(t,i){i.subVectors(t,this.origin);const x=i.dot(this.direction);return x<0?i.copy(this.origin):i.copy(this.origin).addScaledVector(this.direction,x)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const i=ul.subVectors(t,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(t):(ul.copy(this.origin).addScaledVector(this.direction,i),ul.distanceToSquared(t))}distanceSqToSegment(t,i,x,T){A0.copy(t).add(i).multiplyScalar(.5),sv.copy(i).sub(t).normalize(),th.copy(this.origin).sub(A0);const E=t.distanceTo(i)*.5,s=-this.direction.dot(sv),y=th.dot(this.direction),e=-th.dot(sv),r=th.lengthSq(),p=Math.abs(1-s*s);let h,a,l,n;if(p>0)if(h=s*e-y,a=s*y-e,n=E*p,h>=0)if(a>=-n)if(a<=n){const u=1/p;h*=u,a*=u,l=h*(h+s*a+2*y)+a*(s*h+a+2*e)+r}else a=E,h=Math.max(0,-(s*a+y)),l=-h*h+a*(a+2*e)+r;else a=-E,h=Math.max(0,-(s*a+y)),l=-h*h+a*(a+2*e)+r;else a<=-n?(h=Math.max(0,-(-s*E+y)),a=h>0?-E:Math.min(Math.max(-E,-e),E),l=-h*h+a*(a+2*e)+r):a<=n?(h=0,a=Math.min(Math.max(-E,-e),E),l=a*(a+2*e)+r):(h=Math.max(0,-(s*E+y)),a=h>0?E:Math.min(Math.max(-E,-e),E),l=-h*h+a*(a+2*e)+r);else a=s>0?-E:E,h=Math.max(0,-(s*a+y)),l=-h*h+a*(a+2*e)+r;return x&&x.copy(this.origin).addScaledVector(this.direction,h),T&&T.copy(A0).addScaledVector(sv,a),l}intersectSphere(t,i){ul.subVectors(t.center,this.origin);const x=ul.dot(this.direction),T=ul.dot(ul)-x*x,E=t.radius*t.radius;if(T>E)return null;const s=Math.sqrt(E-T),y=x-s,e=x+s;return e<0?null:y<0?this.at(e,i):this.at(y,i)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const i=t.normal.dot(this.direction);if(i===0)return t.distanceToPoint(this.origin)===0?0:null;const x=-(this.origin.dot(t.normal)+t.constant)/i;return x>=0?x:null}intersectPlane(t,i){const x=this.distanceToPlane(t);return x===null?null:this.at(x,i)}intersectsPlane(t){const i=t.distanceToPoint(this.origin);return i===0||t.normal.dot(this.direction)*i<0}intersectBox(t,i){let x,T,E,s,y,e;const r=1/this.direction.x,p=1/this.direction.y,h=1/this.direction.z,a=this.origin;return r>=0?(x=(t.min.x-a.x)*r,T=(t.max.x-a.x)*r):(x=(t.max.x-a.x)*r,T=(t.min.x-a.x)*r),p>=0?(E=(t.min.y-a.y)*p,s=(t.max.y-a.y)*p):(E=(t.max.y-a.y)*p,s=(t.min.y-a.y)*p),x>s||E>T||((E>x||isNaN(x))&&(x=E),(s=0?(y=(t.min.z-a.z)*h,e=(t.max.z-a.z)*h):(y=(t.max.z-a.z)*h,e=(t.min.z-a.z)*h),x>e||y>T)||((y>x||x!==x)&&(x=y),(e=0?x:T,i)}intersectsBox(t){return this.intersectBox(t,ul)!==null}intersectTriangle(t,i,x,T,E){P0.subVectors(i,t),av.subVectors(x,t),R0.crossVectors(P0,av);let s=this.direction.dot(R0),y;if(s>0){if(T)return null;y=1}else if(s<0)y=-1,s=-s;else return null;th.subVectors(this.origin,t);const e=y*this.direction.dot(av.crossVectors(th,av));if(e<0)return null;const r=y*this.direction.dot(P0.cross(th));if(r<0||e+r>s)return null;const p=-y*th.dot(R0);return p<0?null:this.at(p/s,E)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ci{constructor(t,i,x,T,E,s,y,e,r,p,h,a,l,n,u,f){ci.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,i,x,T,E,s,y,e,r,p,h,a,l,n,u,f)}set(t,i,x,T,E,s,y,e,r,p,h,a,l,n,u,f){const o=this.elements;return o[0]=t,o[4]=i,o[8]=x,o[12]=T,o[1]=E,o[5]=s,o[9]=y,o[13]=e,o[2]=r,o[6]=p,o[10]=h,o[14]=a,o[3]=l,o[7]=n,o[11]=u,o[15]=f,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 ci().fromArray(this.elements)}copy(t){const i=this.elements,x=t.elements;return i[0]=x[0],i[1]=x[1],i[2]=x[2],i[3]=x[3],i[4]=x[4],i[5]=x[5],i[6]=x[6],i[7]=x[7],i[8]=x[8],i[9]=x[9],i[10]=x[10],i[11]=x[11],i[12]=x[12],i[13]=x[13],i[14]=x[14],i[15]=x[15],this}copyPosition(t){const i=this.elements,x=t.elements;return i[12]=x[12],i[13]=x[13],i[14]=x[14],this}setFromMatrix3(t){const i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,x){return t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),x.setFromMatrixColumn(this,2),this}makeBasis(t,i,x){return this.set(t.x,i.x,x.x,0,t.y,i.y,x.y,0,t.z,i.z,x.z,0,0,0,0,1),this}extractRotation(t){const i=this.elements,x=t.elements,T=1/cf.setFromMatrixColumn(t,0).length(),E=1/cf.setFromMatrixColumn(t,1).length(),s=1/cf.setFromMatrixColumn(t,2).length();return i[0]=x[0]*T,i[1]=x[1]*T,i[2]=x[2]*T,i[3]=0,i[4]=x[4]*E,i[5]=x[5]*E,i[6]=x[6]*E,i[7]=0,i[8]=x[8]*s,i[9]=x[9]*s,i[10]=x[10]*s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){const i=this.elements,x=t.x,T=t.y,E=t.z,s=Math.cos(x),y=Math.sin(x),e=Math.cos(T),r=Math.sin(T),p=Math.cos(E),h=Math.sin(E);if(t.order==="XYZ"){const a=s*p,l=s*h,n=y*p,u=y*h;i[0]=e*p,i[4]=-e*h,i[8]=r,i[1]=l+n*r,i[5]=a-u*r,i[9]=-y*e,i[2]=u-a*r,i[6]=n+l*r,i[10]=s*e}else if(t.order==="YXZ"){const a=e*p,l=e*h,n=r*p,u=r*h;i[0]=a+u*y,i[4]=n*y-l,i[8]=s*r,i[1]=s*h,i[5]=s*p,i[9]=-y,i[2]=l*y-n,i[6]=u+a*y,i[10]=s*e}else if(t.order==="ZXY"){const a=e*p,l=e*h,n=r*p,u=r*h;i[0]=a-u*y,i[4]=-s*h,i[8]=n+l*y,i[1]=l+n*y,i[5]=s*p,i[9]=u-a*y,i[2]=-s*r,i[6]=y,i[10]=s*e}else if(t.order==="ZYX"){const a=s*p,l=s*h,n=y*p,u=y*h;i[0]=e*p,i[4]=n*r-l,i[8]=a*r+u,i[1]=e*h,i[5]=u*r+a,i[9]=l*r-n,i[2]=-r,i[6]=y*e,i[10]=s*e}else if(t.order==="YZX"){const a=s*e,l=s*r,n=y*e,u=y*r;i[0]=e*p,i[4]=u-a*h,i[8]=n*h+l,i[1]=h,i[5]=s*p,i[9]=-y*p,i[2]=-r*p,i[6]=l*h+n,i[10]=a-u*h}else if(t.order==="XZY"){const a=s*e,l=s*r,n=y*e,u=y*r;i[0]=e*p,i[4]=-h,i[8]=r*p,i[1]=a*h+u,i[5]=s*p,i[9]=l*h-n,i[2]=n*h-l,i[6]=y*p,i[10]=u*h+a}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(X5,t,Y5)}lookAt(t,i,x){const T=this.elements;return qs.subVectors(t,i),qs.lengthSq()===0&&(qs.z=1),qs.normalize(),eh.crossVectors(x,qs),eh.lengthSq()===0&&(Math.abs(x.z)===1?qs.x+=1e-4:qs.z+=1e-4,qs.normalize(),eh.crossVectors(x,qs)),eh.normalize(),ov.crossVectors(qs,eh),T[0]=eh.x,T[4]=ov.x,T[8]=qs.x,T[1]=eh.y,T[5]=ov.y,T[9]=qs.y,T[2]=eh.z,T[6]=ov.z,T[10]=qs.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const x=t.elements,T=i.elements,E=this.elements,s=x[0],y=x[4],e=x[8],r=x[12],p=x[1],h=x[5],a=x[9],l=x[13],n=x[2],u=x[6],f=x[10],o=x[14],c=x[3],d=x[7],v=x[11],m=x[15],S=T[0],M=T[4],w=T[8],C=T[12],A=T[1],P=T[5],b=T[9],O=T[13],I=T[2],D=T[6],B=T[10],G=T[14],z=T[3],X=T[7],K=T[11],Q=T[15];return E[0]=s*S+y*A+e*I+r*z,E[4]=s*M+y*P+e*D+r*X,E[8]=s*w+y*b+e*B+r*K,E[12]=s*C+y*O+e*G+r*Q,E[1]=p*S+h*A+a*I+l*z,E[5]=p*M+h*P+a*D+l*X,E[9]=p*w+h*b+a*B+l*K,E[13]=p*C+h*O+a*G+l*Q,E[2]=n*S+u*A+f*I+o*z,E[6]=n*M+u*P+f*D+o*X,E[10]=n*w+u*b+f*B+o*K,E[14]=n*C+u*O+f*G+o*Q,E[3]=c*S+d*A+v*I+m*z,E[7]=c*M+d*P+v*D+m*X,E[11]=c*w+d*b+v*B+m*K,E[15]=c*C+d*O+v*G+m*Q,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){const t=this.elements,i=t[0],x=t[4],T=t[8],E=t[12],s=t[1],y=t[5],e=t[9],r=t[13],p=t[2],h=t[6],a=t[10],l=t[14],n=t[3],u=t[7],f=t[11],o=t[15];return n*(+E*e*h-T*r*h-E*y*a+x*r*a+T*y*l-x*e*l)+u*(+i*e*l-i*r*a+E*s*a-T*s*l+T*r*p-E*e*p)+f*(+i*r*h-i*y*l-E*s*h+x*s*l+E*y*p-x*r*p)+o*(-T*y*p-i*e*h+i*y*a+T*s*h-x*s*a+x*e*p)}transpose(){const t=this.elements;let i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,x){const T=this.elements;return t.isVector3?(T[12]=t.x,T[13]=t.y,T[14]=t.z):(T[12]=t,T[13]=i,T[14]=x),this}invert(){const t=this.elements,i=t[0],x=t[1],T=t[2],E=t[3],s=t[4],y=t[5],e=t[6],r=t[7],p=t[8],h=t[9],a=t[10],l=t[11],n=t[12],u=t[13],f=t[14],o=t[15],c=h*f*r-u*a*r+u*e*l-y*f*l-h*e*o+y*a*o,d=n*a*r-p*f*r-n*e*l+s*f*l+p*e*o-s*a*o,v=p*u*r-n*h*r+n*y*l-s*u*l-p*y*o+s*h*o,m=n*h*e-p*u*e-n*y*a+s*u*a+p*y*f-s*h*f,S=i*c+x*d+T*v+E*m;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 t[0]=c*M,t[1]=(u*a*E-h*f*E-u*T*l+x*f*l+h*T*o-x*a*o)*M,t[2]=(y*f*E-u*e*E+u*T*r-x*f*r-y*T*o+x*e*o)*M,t[3]=(h*e*E-y*a*E-h*T*r+x*a*r+y*T*l-x*e*l)*M,t[4]=d*M,t[5]=(p*f*E-n*a*E+n*T*l-i*f*l-p*T*o+i*a*o)*M,t[6]=(n*e*E-s*f*E-n*T*r+i*f*r+s*T*o-i*e*o)*M,t[7]=(s*a*E-p*e*E+p*T*r-i*a*r-s*T*l+i*e*l)*M,t[8]=v*M,t[9]=(n*h*E-p*u*E-n*x*l+i*u*l+p*x*o-i*h*o)*M,t[10]=(s*u*E-n*y*E+n*x*r-i*u*r-s*x*o+i*y*o)*M,t[11]=(p*y*E-s*h*E-p*x*r+i*h*r+s*x*l-i*y*l)*M,t[12]=m*M,t[13]=(p*u*T-n*h*T+n*x*a-i*u*a-p*x*f+i*h*f)*M,t[14]=(n*y*T-s*u*T-n*x*e+i*u*e+s*x*f-i*y*f)*M,t[15]=(s*h*T-p*y*T+p*x*e-i*h*e-s*x*a+i*y*a)*M,this}scale(t){const i=this.elements,x=t.x,T=t.y,E=t.z;return i[0]*=x,i[4]*=T,i[8]*=E,i[1]*=x,i[5]*=T,i[9]*=E,i[2]*=x,i[6]*=T,i[10]*=E,i[3]*=x,i[7]*=T,i[11]*=E,this}getMaxScaleOnAxis(){const t=this.elements,i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],x=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],T=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,x,T))}makeTranslation(t,i,x){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,i,0,0,1,x,0,0,0,1),this}makeRotationX(t){const i=Math.cos(t),x=Math.sin(t);return this.set(1,0,0,0,0,i,-x,0,0,x,i,0,0,0,0,1),this}makeRotationY(t){const i=Math.cos(t),x=Math.sin(t);return this.set(i,0,x,0,0,1,0,0,-x,0,i,0,0,0,0,1),this}makeRotationZ(t){const i=Math.cos(t),x=Math.sin(t);return this.set(i,-x,0,0,x,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){const x=Math.cos(i),T=Math.sin(i),E=1-x,s=t.x,y=t.y,e=t.z,r=E*s,p=E*y;return this.set(r*s+x,r*y-T*e,r*e+T*y,0,r*y+T*e,p*y+x,p*e-T*s,0,r*e-T*y,p*e+T*s,E*e*e+x,0,0,0,0,1),this}makeScale(t,i,x){return this.set(t,0,0,0,0,i,0,0,0,0,x,0,0,0,0,1),this}makeShear(t,i,x,T,E,s){return this.set(1,x,E,0,t,1,s,0,i,T,1,0,0,0,0,1),this}compose(t,i,x){const T=this.elements,E=i._x,s=i._y,y=i._z,e=i._w,r=E+E,p=s+s,h=y+y,a=E*r,l=E*p,n=E*h,u=s*p,f=s*h,o=y*h,c=e*r,d=e*p,v=e*h,m=x.x,S=x.y,M=x.z;return T[0]=(1-(u+o))*m,T[1]=(l+v)*m,T[2]=(n-d)*m,T[3]=0,T[4]=(l-v)*S,T[5]=(1-(a+o))*S,T[6]=(f+c)*S,T[7]=0,T[8]=(n+d)*M,T[9]=(f-c)*M,T[10]=(1-(a+u))*M,T[11]=0,T[12]=t.x,T[13]=t.y,T[14]=t.z,T[15]=1,this}decompose(t,i,x){const T=this.elements;let E=cf.set(T[0],T[1],T[2]).length();const s=cf.set(T[4],T[5],T[6]).length(),y=cf.set(T[8],T[9],T[10]).length();this.determinant()<0&&(E=-E),t.x=T[12],t.y=T[13],t.z=T[14],$a.copy(this);const r=1/E,p=1/s,h=1/y;return $a.elements[0]*=r,$a.elements[1]*=r,$a.elements[2]*=r,$a.elements[4]*=p,$a.elements[5]*=p,$a.elements[6]*=p,$a.elements[8]*=h,$a.elements[9]*=h,$a.elements[10]*=h,i.setFromRotationMatrix($a),x.x=E,x.y=s,x.z=y,this}makePerspective(t,i,x,T,E,s,y=No){const e=this.elements,r=2*E/(i-t),p=2*E/(x-T),h=(i+t)/(i-t),a=(x+T)/(x-T);let l,n;if(y===No)l=-(s+E)/(s-E),n=-2*s*E/(s-E);else if(y===Od)l=-s/(s-E),n=-s*E/(s-E);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+y);return e[0]=r,e[4]=0,e[8]=h,e[12]=0,e[1]=0,e[5]=p,e[9]=a,e[13]=0,e[2]=0,e[6]=0,e[10]=l,e[14]=n,e[3]=0,e[7]=0,e[11]=-1,e[15]=0,this}makeOrthographic(t,i,x,T,E,s,y=No){const e=this.elements,r=1/(i-t),p=1/(x-T),h=1/(s-E),a=(i+t)*r,l=(x+T)*p;let n,u;if(y===No)n=(s+E)*h,u=-2*h;else if(y===Od)n=E*h,u=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+y);return e[0]=2*r,e[4]=0,e[8]=0,e[12]=-a,e[1]=0,e[5]=2*p,e[9]=0,e[13]=-l,e[2]=0,e[6]=0,e[10]=u,e[14]=-n,e[3]=0,e[7]=0,e[11]=0,e[15]=1,this}equals(t){const i=this.elements,x=t.elements;for(let T=0;T<16;T++)if(i[T]!==x[T])return!1;return!0}fromArray(t,i=0){for(let x=0;x<16;x++)this.elements[x]=t[x+i];return this}toArray(t=[],i=0){const x=this.elements;return t[i]=x[0],t[i+1]=x[1],t[i+2]=x[2],t[i+3]=x[3],t[i+4]=x[4],t[i+5]=x[5],t[i+6]=x[6],t[i+7]=x[7],t[i+8]=x[8],t[i+9]=x[9],t[i+10]=x[10],t[i+11]=x[11],t[i+12]=x[12],t[i+13]=x[13],t[i+14]=x[14],t[i+15]=x[15],t}}const cf=new Ct,$a=new ci,X5=new Ct(0,0,0),Y5=new Ct(1,1,1),eh=new Ct,ov=new Ct,qs=new Ct,LT=new ci,FT=new Ds;class qa{constructor(t=0,i=0,x=0,T=qa.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=i,this._z=x,this._order=T}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,i,x,T=this._order){return this._x=t,this._y=i,this._z=x,this._order=T,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,i=this._order,x=!0){const T=t.elements,E=T[0],s=T[4],y=T[8],e=T[1],r=T[5],p=T[9],h=T[2],a=T[6],l=T[10];switch(i){case"XYZ":this._y=Math.asin(jn(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(-p,l),this._z=Math.atan2(-s,E)):(this._x=Math.atan2(a,r),this._z=0);break;case"YXZ":this._x=Math.asin(-jn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(y,l),this._z=Math.atan2(e,r)):(this._y=Math.atan2(-h,E),this._z=0);break;case"ZXY":this._x=Math.asin(jn(a,-1,1)),Math.abs(a)<.9999999?(this._y=Math.atan2(-h,l),this._z=Math.atan2(-s,r)):(this._y=0,this._z=Math.atan2(e,E));break;case"ZYX":this._y=Math.asin(-jn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(a,l),this._z=Math.atan2(e,E)):(this._x=0,this._z=Math.atan2(-s,r));break;case"YZX":this._z=Math.asin(jn(e,-1,1)),Math.abs(e)<.9999999?(this._x=Math.atan2(-p,r),this._y=Math.atan2(-h,E)):(this._x=0,this._y=Math.atan2(y,l));break;case"XZY":this._z=Math.asin(-jn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(a,r),this._y=Math.atan2(y,E)):(this._x=Math.atan2(-p,l),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,x===!0&&this._onChangeCallback(),this}setFromQuaternion(t,i,x){return LT.makeRotationFromQuaternion(t),this.setFromRotationMatrix(LT,i,x)}setFromVector3(t,i=this._order){return this.set(t.x,t.y,t.z,i)}reorder(t){return FT.setFromEuler(this),this.setFromQuaternion(FT,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}qa.DEFAULT_ORDER="XYZ";class Tu{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let i=0;i1){for(let x=0;x0&&(T.userData=this.userData),T.layers=this.layers.mask,T.matrix=this.matrix.toArray(),T.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(T.matrixAutoUpdate=!1),this.isInstancedMesh&&(T.type="InstancedMesh",T.count=this.count,T.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(T.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(T.type="BatchedMesh",T.perObjectFrustumCulled=this.perObjectFrustumCulled,T.sortObjects=this.sortObjects,T.drawRanges=this._drawRanges,T.reservedRanges=this._reservedRanges,T.visibility=this._visibility,T.active=this._active,T.bounds=this._bounds.map(y=>({boxInitialized:y.boxInitialized,boxMin:y.box.min.toArray(),boxMax:y.box.max.toArray(),sphereInitialized:y.sphereInitialized,sphereRadius:y.sphere.radius,sphereCenter:y.sphere.center.toArray()})),T.maxGeometryCount=this._maxGeometryCount,T.maxVertexCount=this._maxVertexCount,T.maxIndexCount=this._maxIndexCount,T.geometryInitialized=this._geometryInitialized,T.geometryCount=this._geometryCount,T.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(T.boundingSphere={center:T.boundingSphere.center.toArray(),radius:T.boundingSphere.radius}),this.boundingBox!==null&&(T.boundingBox={min:T.boundingBox.min.toArray(),max:T.boundingBox.max.toArray()}));function E(y,e){return y[e.uuid]===void 0&&(y[e.uuid]=e.toJSON(t)),e.uuid}if(this.isScene)this.background&&(this.background.isColor?T.background=this.background.toJSON():this.background.isTexture&&(T.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(T.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){T.geometry=E(t.geometries,this.geometry);const y=this.geometry.parameters;if(y!==void 0&&y.shapes!==void 0){const e=y.shapes;if(Array.isArray(e))for(let r=0,p=e.length;r0){T.children=[];for(let y=0;y0){T.animations=[];for(let y=0;y0&&(x.geometries=y),e.length>0&&(x.materials=e),r.length>0&&(x.textures=r),p.length>0&&(x.images=p),h.length>0&&(x.shapes=h),a.length>0&&(x.skeletons=a),l.length>0&&(x.animations=l),n.length>0&&(x.nodes=n)}return x.object=T,x;function s(y){const e=[];for(const r in y){const p=y[r];delete p.metadata,e.push(p)}return e}}clone(t){return new this.constructor().copy(this,t)}copy(t,i=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),i===!0)for(let x=0;x0?T.multiplyScalar(1/Math.sqrt(E)):T.set(0,0,0)}static getBarycoord(t,i,x,T,E){Qa.subVectors(T,i),cl.subVectors(x,i),b0.subVectors(t,i);const s=Qa.dot(Qa),y=Qa.dot(cl),e=Qa.dot(b0),r=cl.dot(cl),p=cl.dot(b0),h=s*r-y*y;if(h===0)return E.set(0,0,0),null;const a=1/h,l=(r*e-y*p)*a,n=(s*p-y*e)*a;return E.set(1-l-n,n,l)}static containsPoint(t,i,x,T){return this.getBarycoord(t,i,x,T,dl)===null?!1:dl.x>=0&&dl.y>=0&&dl.x+dl.y<=1}static getInterpolation(t,i,x,T,E,s,y,e){return this.getBarycoord(t,i,x,T,dl)===null?(e.x=0,e.y=0,"z"in e&&(e.z=0),"w"in e&&(e.w=0),null):(e.setScalar(0),e.addScaledVector(E,dl.x),e.addScaledVector(s,dl.y),e.addScaledVector(y,dl.z),e)}static isFrontFacing(t,i,x,T){return Qa.subVectors(x,i),cl.subVectors(t,i),Qa.cross(cl).dot(T)<0}set(t,i,x){return this.a.copy(t),this.b.copy(i),this.c.copy(x),this}setFromPointsAndIndices(t,i,x,T){return this.a.copy(t[i]),this.b.copy(t[x]),this.c.copy(t[T]),this}setFromAttributeAndIndices(t,i,x,T){return this.a.fromBufferAttribute(t,i),this.b.fromBufferAttribute(t,x),this.c.fromBufferAttribute(t,T),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Qa.subVectors(this.c,this.b),cl.subVectors(this.a,this.b),Qa.cross(cl).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ia.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return ia.getBarycoord(t,this.a,this.b,this.c,i)}getInterpolation(t,i,x,T,E){return ia.getInterpolation(t,this.a,this.b,this.c,i,x,T,E)}containsPoint(t){return ia.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ia.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){const x=this.a,T=this.b,E=this.c;let s,y;pf.subVectors(T,x),vf.subVectors(E,x),L0.subVectors(t,x);const e=pf.dot(L0),r=vf.dot(L0);if(e<=0&&r<=0)return i.copy(x);F0.subVectors(t,T);const p=pf.dot(F0),h=vf.dot(F0);if(p>=0&&h<=p)return i.copy(T);const a=e*h-p*r;if(a<=0&&e>=0&&p<=0)return s=e/(e-p),i.copy(x).addScaledVector(pf,s);O0.subVectors(t,E);const l=pf.dot(O0),n=vf.dot(O0);if(n>=0&&l<=n)return i.copy(E);const u=l*r-e*n;if(u<=0&&r>=0&&n<=0)return y=r/(r-n),i.copy(x).addScaledVector(vf,y);const f=p*n-l*h;if(f<=0&&h-p>=0&&l-n>=0)return BT.subVectors(E,T),y=(h-p)/(h-p+(l-n)),i.copy(T).addScaledVector(BT,y);const o=1/(f+u+a);return s=u*o,y=a*o,i.copy(x).addScaledVector(pf,s).addScaledVector(vf,y)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const dw={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},ih={h:0,s:0,l:0},hv={h:0,s:0,l:0};function D0(g,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?g+(t-g)*6*i:i<1/2?t:i<2/3?g+(t-g)*6*(2/3-i):g}class ze{constructor(t,i,x){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,i,x)}set(t,i,x){if(i===void 0&&x===void 0){const T=t;T&&T.isColor?this.copy(T):typeof T=="number"?this.setHex(T):typeof T=="string"&&this.setStyle(T)}else this.setRGB(t,i,x);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,i=vr){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,rn.toWorkingColorSpace(this,i),this}setRGB(t,i,x,T=rn.workingColorSpace){return this.r=t,this.g=i,this.b=x,rn.toWorkingColorSpace(this,T),this}setHSL(t,i,x,T=rn.workingColorSpace){if(t=p1(t,1),i=jn(i,0,1),x=jn(x,0,1),i===0)this.r=this.g=this.b=x;else{const E=x<=.5?x*(1+i):x+i-x*i,s=2*x-E;this.r=D0(s,E,t+1/3),this.g=D0(s,E,t),this.b=D0(s,E,t-1/3)}return rn.toWorkingColorSpace(this,T),this}setStyle(t,i=vr){function x(E){E!==void 0&&parseFloat(E)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let T;if(T=/^(\w+)\(([^\)]*)\)/.exec(t)){let E;const s=T[1],y=T[2];switch(s){case"rgb":case"rgba":if(E=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return x(E[4]),this.setRGB(Math.min(255,parseInt(E[1],10))/255,Math.min(255,parseInt(E[2],10))/255,Math.min(255,parseInt(E[3],10))/255,i);if(E=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return x(E[4]),this.setRGB(Math.min(100,parseInt(E[1],10))/100,Math.min(100,parseInt(E[2],10))/100,Math.min(100,parseInt(E[3],10))/100,i);break;case"hsl":case"hsla":if(E=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return x(E[4]),this.setHSL(parseFloat(E[1])/360,parseFloat(E[2])/100,parseFloat(E[3])/100,i);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(T=/^\#([A-Fa-f\d]+)$/.exec(t)){const E=T[1],s=E.length;if(s===3)return this.setRGB(parseInt(E.charAt(0),16)/15,parseInt(E.charAt(1),16)/15,parseInt(E.charAt(2),16)/15,i);if(s===6)return this.setHex(parseInt(E,16),i);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,i);return this}setColorName(t,i=vr){const x=dw[t.toLowerCase()];return x!==void 0?this.setHex(x,i):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Xf(t.r),this.g=Xf(t.g),this.b=Xf(t.b),this}copyLinearToSRGB(t){return this.r=T0(t.r),this.g=T0(t.g),this.b=T0(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=vr){return rn.fromWorkingColorSpace(Kr.copy(this),t),Math.round(jn(Kr.r*255,0,255))*65536+Math.round(jn(Kr.g*255,0,255))*256+Math.round(jn(Kr.b*255,0,255))}getHexString(t=vr){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,i=rn.workingColorSpace){rn.fromWorkingColorSpace(Kr.copy(this),i);const x=Kr.r,T=Kr.g,E=Kr.b,s=Math.max(x,T,E),y=Math.min(x,T,E);let e,r;const p=(y+s)/2;if(y===s)e=0,r=0;else{const h=s-y;switch(r=p<=.5?h/(s+y):h/(2-s-y),s){case x:e=(T-E)/h+(T0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const i in t){const x=t[i];if(x===void 0){console.warn(`THREE.Material: parameter '${i}' has value of undefined.`);continue}const T=this[i];if(T===void 0){console.warn(`THREE.Material: '${i}' is not a property of THREE.${this.type}.`);continue}T&&T.isColor?T.set(x):T&&T.isVector3&&x&&x.isVector3?T.copy(x):this[i]=x}}toJSON(t){const i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{}});const x={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};x.uuid=this.uuid,x.type=this.type,this.name!==""&&(x.name=this.name),this.color&&this.color.isColor&&(x.color=this.color.getHex()),this.roughness!==void 0&&(x.roughness=this.roughness),this.metalness!==void 0&&(x.metalness=this.metalness),this.sheen!==void 0&&(x.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(x.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(x.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(x.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(x.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(x.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(x.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(x.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(x.shininess=this.shininess),this.clearcoat!==void 0&&(x.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(x.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(x.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(x.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(x.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,x.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(x.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(x.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(x.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(x.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(x.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(x.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(x.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(x.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(x.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(x.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(x.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(x.lightMap=this.lightMap.toJSON(t).uuid,x.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(x.aoMap=this.aoMap.toJSON(t).uuid,x.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(x.bumpMap=this.bumpMap.toJSON(t).uuid,x.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(x.normalMap=this.normalMap.toJSON(t).uuid,x.normalMapType=this.normalMapType,x.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(x.displacementMap=this.displacementMap.toJSON(t).uuid,x.displacementScale=this.displacementScale,x.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(x.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(x.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(x.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(x.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(x.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(x.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(x.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(x.combine=this.combine)),this.envMapIntensity!==void 0&&(x.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(x.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(x.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(x.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(x.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(x.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(x.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(x.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(x.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(x.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(x.size=this.size),this.shadowSide!==null&&(x.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(x.sizeAttenuation=this.sizeAttenuation),this.blending!==yu&&(x.blending=this.blending),this.side!==Cl&&(x.side=this.side),this.vertexColors===!0&&(x.vertexColors=!0),this.opacity<1&&(x.opacity=this.opacity),this.transparent===!0&&(x.transparent=!0),this.blendSrc!==ym&&(x.blendSrc=this.blendSrc),this.blendDst!==xm&&(x.blendDst=this.blendDst),this.blendEquation!==oh&&(x.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(x.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(x.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(x.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(x.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(x.blendAlpha=this.blendAlpha),this.depthFunc!==Sd&&(x.depthFunc=this.depthFunc),this.depthTest===!1&&(x.depthTest=this.depthTest),this.depthWrite===!1&&(x.depthWrite=this.depthWrite),this.colorWrite===!1&&(x.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(x.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==cx&&(x.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(x.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(x.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==hu&&(x.stencilFail=this.stencilFail),this.stencilZFail!==hu&&(x.stencilZFail=this.stencilZFail),this.stencilZPass!==hu&&(x.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(x.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(x.rotation=this.rotation),this.polygonOffset===!0&&(x.polygonOffset=!0),this.polygonOffsetFactor!==0&&(x.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(x.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(x.linewidth=this.linewidth),this.dashSize!==void 0&&(x.dashSize=this.dashSize),this.gapSize!==void 0&&(x.gapSize=this.gapSize),this.scale!==void 0&&(x.scale=this.scale),this.dithering===!0&&(x.dithering=!0),this.alphaTest>0&&(x.alphaTest=this.alphaTest),this.alphaHash===!0&&(x.alphaHash=!0),this.alphaToCoverage===!0&&(x.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(x.premultipliedAlpha=!0),this.forceSinglePass===!0&&(x.forceSinglePass=!0),this.wireframe===!0&&(x.wireframe=!0),this.wireframeLinewidth>1&&(x.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(x.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(x.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(x.flatShading=!0),this.visible===!1&&(x.visible=!1),this.toneMapped===!1&&(x.toneMapped=!1),this.fog===!1&&(x.fog=!1),Object.keys(this.userData).length>0&&(x.userData=this.userData);function T(E){const s=[];for(const y in E){const e=E[y];delete e.metadata,s.push(e)}return s}if(i){const E=T(t.textures),s=T(t.images);E.length>0&&(x.textures=E),s.length>0&&(x.images=s)}return x}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const i=t.clippingPlanes;let x=null;if(i!==null){const T=i.length;x=new Array(T);for(let E=0;E!==T;++E)x[E]=i[E].clone()}return this.clippingPlanes=x,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class xh extends Hr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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.combine=Zd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const ml=Q5();function Q5(){const g=new ArrayBuffer(4),t=new Float32Array(g),i=new Uint32Array(g),x=new Uint32Array(512),T=new Uint32Array(512);for(let e=0;e<256;++e){const r=e-127;r<-27?(x[e]=0,x[e|256]=32768,T[e]=24,T[e|256]=24):r<-14?(x[e]=1024>>-r-14,x[e|256]=1024>>-r-14|32768,T[e]=-r-1,T[e|256]=-r-1):r<=15?(x[e]=r+15<<10,x[e|256]=r+15<<10|32768,T[e]=13,T[e|256]=13):r<128?(x[e]=31744,x[e|256]=64512,T[e]=24,T[e|256]=24):(x[e]=31744,x[e|256]=64512,T[e]=13,T[e|256]=13)}const E=new Uint32Array(2048),s=new Uint32Array(64),y=new Uint32Array(64);for(let e=1;e<1024;++e){let r=e<<13,p=0;for(;!(r&8388608);)r<<=1,p-=8388608;r&=-8388609,p+=947912704,E[e]=r|p}for(let e=1024;e<2048;++e)E[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(y[e]=1024);return{floatView:t,uint32View:i,baseTable:x,shiftTable:T,mantissaTable:E,exponentTable:s,offsetTable:y}}function Os(g){Math.abs(g)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),g=jn(g,-65504,65504),ml.floatView[0]=g;const t=ml.uint32View[0],i=t>>23&511;return ml.baseTable[i]+((t&8388607)>>ml.shiftTable[i])}function nd(g){const t=g>>10;return ml.uint32View[0]=ml.mantissaTable[ml.offsetTable[t]+(g&1023)]+ml.exponentTable[t],ml.floatView[0]}const _5={toHalfFloat:Os,fromHalfFloat:nd},ur=new Ct,uv=new ve;class an{constructor(t,i,x=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=i,this.count=t!==void 0?t.length/i:0,this.normalized=x,this.usage=Fd,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ea,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Su("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,i,x){t*=this.itemSize,x*=i.itemSize;for(let T=0,E=this.itemSize;T0&&(t.userData=this.userData),this.parameters!==void 0){const e=this.parameters;for(const r in e)e[r]!==void 0&&(t[r]=e[r]);return t}t.data={attributes:{}};const i=this.index;i!==null&&(t.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});const x=this.attributes;for(const e in x){const r=x[e];t.data.attributes[e]=r.toJSON(t.data)}const T={};let E=!1;for(const e in this.morphAttributes){const r=this.morphAttributes[e],p=[];for(let h=0,a=r.length;h0&&(T[e]=p,E=!0)}E&&(t.data.morphAttributes=T,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const y=this.boundingSphere;return y!==null&&(t.data.boundingSphere={center:y.center.toArray(),radius:y.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const i={};this.name=t.name;const x=t.index;x!==null&&this.setIndex(x.clone(i));const T=t.attributes;for(const r in T){const p=T[r];this.setAttribute(r,p.clone(i))}const E=t.morphAttributes;for(const r in E){const p=[],h=E[r];for(let a=0,l=h.length;a0){const T=i[x[0]];if(T!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let E=0,s=T.length;E(t.far-t.near)**2))&&(UT.copy(E).invert(),_h.copy(t.ray).applyMatrix4(UT),!(x.boundingBox!==null&&_h.intersectsBox(x.boundingBox)===!1)&&this._computeIntersections(t,i,_h)))}_computeIntersections(t,i,x){let T;const E=this.geometry,s=this.material,y=E.index,e=E.attributes.position,r=E.attributes.uv,p=E.attributes.uv1,h=E.attributes.normal,a=E.groups,l=E.drawRange;if(y!==null)if(Array.isArray(s))for(let n=0,u=a.length;ni.far?null:{distance:r,point:gv.clone(),object:g}}function yv(g,t,i,x,T,E,s,y,e,r){g.getVertexPosition(y,gf),g.getVertexPosition(e,yf),g.getVertexPosition(r,xf);const p=oN(g,t,i,x,gf,yf,xf,mv);if(p){T&&(dv.fromBufferAttribute(T,y),pv.fromBufferAttribute(T,e),vv.fromBufferAttribute(T,r),p.uv=ia.getInterpolation(mv,gf,yf,xf,dv,pv,vv,new ve)),E&&(dv.fromBufferAttribute(E,y),pv.fromBufferAttribute(E,e),vv.fromBufferAttribute(E,r),p.uv1=ia.getInterpolation(mv,gf,yf,xf,dv,pv,vv,new ve),p.uv2=p.uv1),s&&(GT.fromBufferAttribute(s,y),VT.fromBufferAttribute(s,e),HT.fromBufferAttribute(s,r),p.normal=ia.getInterpolation(mv,gf,yf,xf,GT,VT,HT,new Ct),p.normal.dot(x.direction)>0&&p.normal.multiplyScalar(-1));const h={a:y,b:e,c:r,normal:new Ct,materialIndex:0};ia.getNormal(gf,yf,xf,h.normal),p.face=h}return p}class Ou extends Li{constructor(t=1,i=1,x=1,T=1,E=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:i,depth:x,widthSegments:T,heightSegments:E,depthSegments:s};const y=this;T=Math.floor(T),E=Math.floor(E),s=Math.floor(s);const e=[],r=[],p=[],h=[];let a=0,l=0;n("z","y","x",-1,-1,x,i,t,s,E,0),n("z","y","x",1,-1,x,i,-t,s,E,1),n("x","z","y",1,1,t,x,i,T,s,2),n("x","z","y",1,-1,t,x,-i,T,s,3),n("x","y","z",1,-1,t,i,x,T,E,4),n("x","y","z",-1,-1,t,i,-x,T,E,5),this.setIndex(e),this.setAttribute("position",new ke(r,3)),this.setAttribute("normal",new ke(p,3)),this.setAttribute("uv",new ke(h,2));function n(u,f,o,c,d,v,m,S,M,w,C){const A=v/M,P=m/w,b=v/2,O=m/2,I=S/2,D=M+1,B=w+1;let G=0,z=0;const X=new Ct;for(let K=0;K0?1:-1,p.push(X.x,X.y,X.z),h.push(tt/M),h.push(1-K/w),G+=1}}for(let K=0;K1?null:i.copy(t.start).addScaledVector(x,E)}intersectsLine(t){const i=this.distanceToPoint(t.start),x=this.distanceToPoint(t.end);return i<0&&x>0||x<0&&i>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,i){const x=i||cN.getNormalMatrix(t),T=this.coplanarPoint(N0).applyMatrix4(t),E=this.normal.applyMatrix3(x).normalize();return this.constant=-T.dot(E),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qh=new $r,xv=new Ct;class _d{constructor(t=new ah,i=new ah,x=new ah,T=new ah,E=new ah,s=new ah){this.planes=[t,i,x,T,E,s]}set(t,i,x,T,E,s){const y=this.planes;return y[0].copy(t),y[1].copy(i),y[2].copy(x),y[3].copy(T),y[4].copy(E),y[5].copy(s),this}copy(t){const i=this.planes;for(let x=0;x<6;x++)i[x].copy(t.planes[x]);return this}setFromProjectionMatrix(t,i=No){const x=this.planes,T=t.elements,E=T[0],s=T[1],y=T[2],e=T[3],r=T[4],p=T[5],h=T[6],a=T[7],l=T[8],n=T[9],u=T[10],f=T[11],o=T[12],c=T[13],d=T[14],v=T[15];if(x[0].setComponents(e-E,a-r,f-l,v-o).normalize(),x[1].setComponents(e+E,a+r,f+l,v+o).normalize(),x[2].setComponents(e+s,a+p,f+n,v+c).normalize(),x[3].setComponents(e-s,a-p,f-n,v-c).normalize(),x[4].setComponents(e-y,a-h,f-u,v-d).normalize(),i===No)x[5].setComponents(e+y,a+h,f+u,v+d).normalize();else if(i===Od)x[5].setComponents(y,h,u,d).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+i);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),qh.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const i=t.geometry;i.boundingSphere===null&&i.computeBoundingSphere(),qh.copy(i.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(qh)}intersectsSprite(t){return qh.center.set(0,0,0),qh.radius=.7071067811865476,qh.applyMatrix4(t.matrixWorld),this.intersectsSphere(qh)}intersectsSphere(t){const i=this.planes,x=t.center,T=-t.radius;for(let E=0;E<6;E++)if(i[E].distanceToPoint(x)0?t.max.x:t.min.x,xv.y=T.normal.y>0?t.max.y:t.min.y,xv.z=T.normal.z>0?t.max.z:t.min.z,T.distanceToPoint(xv)<0)return!1}return!0}containsPoint(t){const i=this.planes;for(let x=0;x<6;x++)if(i[x].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function yw(){let g=null,t=!1,i=null,x=null;function T(E,s){i(E,s),x=g.requestAnimationFrame(T)}return{start:function(){t!==!0&&i!==null&&(x=g.requestAnimationFrame(T),t=!0)},stop:function(){g.cancelAnimationFrame(x),t=!1},setAnimationLoop:function(E){i=E},setContext:function(E){g=E}}}function dN(g,t){const i=t.isWebGL2,x=new WeakMap;function T(r,p){const h=r.array,a=r.usage,l=h.byteLength,n=g.createBuffer();g.bindBuffer(p,n),g.bufferData(p,h,a),r.onUploadCallback();let u;if(h instanceof Float32Array)u=g.FLOAT;else if(h instanceof Uint16Array)if(r.isFloat16BufferAttribute)if(i)u=g.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else u=g.UNSIGNED_SHORT;else if(h instanceof Int16Array)u=g.SHORT;else if(h instanceof Uint32Array)u=g.UNSIGNED_INT;else if(h instanceof Int32Array)u=g.INT;else if(h instanceof Int8Array)u=g.BYTE;else if(h instanceof Uint8Array)u=g.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)u=g.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:n,type:u,bytesPerElement:h.BYTES_PER_ELEMENT,version:r.version,size:l}}function E(r,p,h){const a=p.array,l=p._updateRange,n=p.updateRanges;if(g.bindBuffer(h,r),l.count===-1&&n.length===0&&g.bufferSubData(h,0,a),n.length!==0){for(let u=0,f=n.length;u1?null:i.copy(t.start).addScaledVector(x,E)}intersectsLine(t){const i=this.distanceToPoint(t.start),x=this.distanceToPoint(t.end);return i<0&&x>0||x<0&&i>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,i){const x=i||cN.getNormalMatrix(t),T=this.coplanarPoint(B0).applyMatrix4(t),E=this.normal.applyMatrix3(x).normalize();return this.constant=-T.dot(E),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qh=new $r,xv=new Ct;class _d{constructor(t=new ah,i=new ah,x=new ah,T=new ah,E=new ah,s=new ah){this.planes=[t,i,x,T,E,s]}set(t,i,x,T,E,s){const y=this.planes;return y[0].copy(t),y[1].copy(i),y[2].copy(x),y[3].copy(T),y[4].copy(E),y[5].copy(s),this}copy(t){const i=this.planes;for(let x=0;x<6;x++)i[x].copy(t.planes[x]);return this}setFromProjectionMatrix(t,i=No){const x=this.planes,T=t.elements,E=T[0],s=T[1],y=T[2],e=T[3],r=T[4],p=T[5],h=T[6],a=T[7],l=T[8],n=T[9],u=T[10],f=T[11],o=T[12],c=T[13],d=T[14],v=T[15];if(x[0].setComponents(e-E,a-r,f-l,v-o).normalize(),x[1].setComponents(e+E,a+r,f+l,v+o).normalize(),x[2].setComponents(e+s,a+p,f+n,v+c).normalize(),x[3].setComponents(e-s,a-p,f-n,v-c).normalize(),x[4].setComponents(e-y,a-h,f-u,v-d).normalize(),i===No)x[5].setComponents(e+y,a+h,f+u,v+d).normalize();else if(i===Od)x[5].setComponents(y,h,u,d).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+i);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),qh.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const i=t.geometry;i.boundingSphere===null&&i.computeBoundingSphere(),qh.copy(i.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(qh)}intersectsSprite(t){return qh.center.set(0,0,0),qh.radius=.7071067811865476,qh.applyMatrix4(t.matrixWorld),this.intersectsSphere(qh)}intersectsSphere(t){const i=this.planes,x=t.center,T=-t.radius;for(let E=0;E<6;E++)if(i[E].distanceToPoint(x)0?t.max.x:t.min.x,xv.y=T.normal.y>0?t.max.y:t.min.y,xv.z=T.normal.z>0?t.max.z:t.min.z,T.distanceToPoint(xv)<0)return!1}return!0}containsPoint(t){const i=this.planes;for(let x=0;x<6;x++)if(i[x].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function yw(){let g=null,t=!1,i=null,x=null;function T(E,s){i(E,s),x=g.requestAnimationFrame(T)}return{start:function(){t!==!0&&i!==null&&(x=g.requestAnimationFrame(T),t=!0)},stop:function(){g.cancelAnimationFrame(x),t=!1},setAnimationLoop:function(E){i=E},setContext:function(E){g=E}}}function dN(g,t){const i=t.isWebGL2,x=new WeakMap;function T(r,p){const h=r.array,a=r.usage,l=h.byteLength,n=g.createBuffer();g.bindBuffer(p,n),g.bufferData(p,h,a),r.onUploadCallback();let u;if(h instanceof Float32Array)u=g.FLOAT;else if(h instanceof Uint16Array)if(r.isFloat16BufferAttribute)if(i)u=g.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else u=g.UNSIGNED_SHORT;else if(h instanceof Int16Array)u=g.SHORT;else if(h instanceof Uint32Array)u=g.UNSIGNED_INT;else if(h instanceof Int32Array)u=g.INT;else if(h instanceof Int8Array)u=g.BYTE;else if(h instanceof Uint8Array)u=g.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)u=g.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:n,type:u,bytesPerElement:h.BYTES_PER_ELEMENT,version:r.version,size:l}}function E(r,p,h){const a=p.array,l=p._updateRange,n=p.updateRanges;if(g.bindBuffer(h,r),l.count===-1&&n.length===0&&g.bufferSubData(h,0,a),n.length!==0){for(let u=0,f=n.length;u #include #include -}`,bi={alphahash_fragment:pN,alphahash_pars_fragment:vN,alphamap_fragment:mN,alphamap_pars_fragment:gN,alphatest_fragment:yN,alphatest_pars_fragment:xN,aomap_fragment:SN,aomap_pars_fragment:TN,batching_pars_vertex:EN,batching_vertex:MN,begin_vertex:CN,beginnormal_vertex:wN,bsdfs:AN,iridescence_fragment:PN,bumpmap_pars_fragment:RN,clipping_planes_fragment:bN,clipping_planes_pars_fragment:LN,clipping_planes_pars_vertex:FN,clipping_planes_vertex:ON,color_fragment:DN,color_pars_fragment:IN,color_pars_vertex:NN,color_vertex:BN,common:UN,cube_uv_reflection_fragment:zN,defaultnormal_vertex:GN,displacementmap_pars_vertex:VN,displacementmap_vertex:HN,emissivemap_fragment:WN,emissivemap_pars_fragment:XN,colorspace_fragment:YN,colorspace_pars_fragment:kN,envmap_fragment:KN,envmap_common_pars_fragment:jN,envmap_pars_fragment:ZN,envmap_pars_vertex:JN,envmap_physical_pars_fragment:o9,envmap_vertex:$N,fog_vertex:QN,fog_pars_vertex:_N,fog_fragment:qN,fog_pars_fragment:t9,gradientmap_pars_fragment:e9,lightmap_fragment:i9,lightmap_pars_fragment:n9,lights_lambert_fragment:r9,lights_lambert_pars_fragment:s9,lights_pars_begin:a9,lights_toon_fragment:l9,lights_toon_pars_fragment:h9,lights_phong_fragment:u9,lights_phong_pars_fragment:f9,lights_physical_fragment:c9,lights_physical_pars_fragment:d9,lights_fragment_begin:p9,lights_fragment_maps:v9,lights_fragment_end:m9,logdepthbuf_fragment:g9,logdepthbuf_pars_fragment:y9,logdepthbuf_pars_vertex:x9,logdepthbuf_vertex:S9,map_fragment:T9,map_pars_fragment:E9,map_particle_fragment:M9,map_particle_pars_fragment:C9,metalnessmap_fragment:w9,metalnessmap_pars_fragment:A9,morphcolor_vertex:P9,morphnormal_vertex:R9,morphtarget_pars_vertex:b9,morphtarget_vertex:L9,normal_fragment_begin:F9,normal_fragment_maps:O9,normal_pars_fragment:D9,normal_pars_vertex:I9,normal_vertex:N9,normalmap_pars_fragment:B9,clearcoat_normal_fragment_begin:U9,clearcoat_normal_fragment_maps:z9,clearcoat_pars_fragment:G9,iridescence_pars_fragment:V9,opaque_fragment:H9,packing:W9,premultiplied_alpha_fragment:X9,project_vertex:Y9,dithering_fragment:k9,dithering_pars_fragment:K9,roughnessmap_fragment:j9,roughnessmap_pars_fragment:Z9,shadowmap_pars_fragment:J9,shadowmap_pars_vertex:$9,shadowmap_vertex:Q9,shadowmask_pars_fragment:_9,skinbase_vertex:q9,skinning_pars_vertex:tB,skinning_vertex:eB,skinnormal_vertex:iB,specularmap_fragment:nB,specularmap_pars_fragment:rB,tonemapping_fragment:sB,tonemapping_pars_fragment:aB,transmission_fragment:oB,transmission_pars_fragment:lB,uv_pars_fragment:hB,uv_pars_vertex:uB,uv_vertex:fB,worldpos_vertex:cB,background_vert:dB,background_frag:pB,backgroundCube_vert:vB,backgroundCube_frag:mB,cube_vert:gB,cube_frag:yB,depth_vert:xB,depth_frag:SB,distanceRGBA_vert:TB,distanceRGBA_frag:EB,equirect_vert:MB,equirect_frag:CB,linedashed_vert:wB,linedashed_frag:AB,meshbasic_vert:PB,meshbasic_frag:RB,meshlambert_vert:bB,meshlambert_frag:LB,meshmatcap_vert:FB,meshmatcap_frag:OB,meshnormal_vert:DB,meshnormal_frag:IB,meshphong_vert:NB,meshphong_frag:BB,meshphysical_vert:UB,meshphysical_frag:zB,meshtoon_vert:GB,meshtoon_frag:VB,points_vert:HB,points_frag:WB,shadow_vert:XB,shadow_frag:YB,sprite_vert:kB,sprite_frag:KB},Fe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oi},alphaMap:{value:null},alphaMapTransform:{value:new Oi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oi}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oi},normalScale:{value:new ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oi},alphaTest:{value:0},uvTransform:{value:new Oi}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oi},alphaMap:{value:null},alphaMapTransform:{value:new Oi},alphaTest:{value:0}}},to={basic:{uniforms:ds([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.fog]),vertexShader:bi.meshbasic_vert,fragmentShader:bi.meshbasic_frag},lambert:{uniforms:ds([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:bi.meshlambert_vert,fragmentShader:bi.meshlambert_frag},phong:{uniforms:ds([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30}}]),vertexShader:bi.meshphong_vert,fragmentShader:bi.meshphong_frag},standard:{uniforms:ds([Fe.common,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.roughnessmap,Fe.metalnessmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:bi.meshphysical_vert,fragmentShader:bi.meshphysical_frag},toon:{uniforms:ds([Fe.common,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.gradientmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:bi.meshtoon_vert,fragmentShader:bi.meshtoon_frag},matcap:{uniforms:ds([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,{matcap:{value:null}}]),vertexShader:bi.meshmatcap_vert,fragmentShader:bi.meshmatcap_frag},points:{uniforms:ds([Fe.points,Fe.fog]),vertexShader:bi.points_vert,fragmentShader:bi.points_frag},dashed:{uniforms:ds([Fe.common,Fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:bi.linedashed_vert,fragmentShader:bi.linedashed_frag},depth:{uniforms:ds([Fe.common,Fe.displacementmap]),vertexShader:bi.depth_vert,fragmentShader:bi.depth_frag},normal:{uniforms:ds([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,{opacity:{value:1}}]),vertexShader:bi.meshnormal_vert,fragmentShader:bi.meshnormal_frag},sprite:{uniforms:ds([Fe.sprite,Fe.fog]),vertexShader:bi.sprite_vert,fragmentShader:bi.sprite_frag},background:{uniforms:{uvTransform:{value:new Oi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:bi.background_vert,fragmentShader:bi.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:bi.backgroundCube_vert,fragmentShader:bi.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:bi.cube_vert,fragmentShader:bi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:bi.equirect_vert,fragmentShader:bi.equirect_frag},distanceRGBA:{uniforms:ds([Fe.common,Fe.displacementmap,{referencePosition:{value:new Ct},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:bi.distanceRGBA_vert,fragmentShader:bi.distanceRGBA_frag},shadow:{uniforms:ds([Fe.lights,Fe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:bi.shadow_vert,fragmentShader:bi.shadow_frag}};to.physical={uniforms:ds([to.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oi},clearcoatNormalScale:{value:new ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oi},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oi},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oi},transmissionSamplerSize:{value:new ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oi},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oi},anisotropyVector:{value:new ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oi}}]),vertexShader:bi.meshphysical_vert,fragmentShader:bi.meshphysical_frag};const Sv={r:0,b:0,g:0};function jB(g,t,i,x,T,E,s){const y=new ze(0);let e=E===!0?0:1,r,p,h=null,a=0,l=null;function n(f,o){let c=!1,d=o.isScene===!0?o.background:null;d&&d.isTexture&&(d=(o.backgroundBlurriness>0?i:t).get(d)),d===null?u(y,e):d&&d.isColor&&(u(d,1),c=!0);const v=g.xr.getEnvironmentBlendMode();v==="additive"?x.buffers.color.setClear(0,0,0,1,s):v==="alpha-blend"&&x.buffers.color.setClear(0,0,0,0,s),(g.autoClear||c)&&g.clear(g.autoClearColor,g.autoClearDepth,g.autoClearStencil),d&&(d.isCubeTexture||d.mapping===ec)?(p===void 0&&(p=new cr(new Ou(1,1,1),new no({name:"BackgroundCubeMaterial",uniforms:$f(to.backgroundCube.uniforms),vertexShader:to.backgroundCube.vertexShader,fragmentShader:to.backgroundCube.fragmentShader,side:ms,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(m,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),T.update(p)),p.material.uniforms.envMap.value=d,p.material.uniforms.flipEnvMap.value=d.isCubeTexture&&d.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=o.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=o.backgroundIntensity,p.material.toneMapped=rn.getTransfer(d.colorSpace)!==vn,(h!==d||a!==d.version||l!==g.toneMapping)&&(p.material.needsUpdate=!0,h=d,a=d.version,l=g.toneMapping),p.layers.enableAll(),f.unshift(p,p.geometry,p.material,0,0,null)):d&&d.isTexture&&(r===void 0&&(r=new cr(new nc(2,2),new no({name:"BackgroundMaterial",uniforms:$f(to.background.uniforms),vertexShader:to.background.vertexShader,fragmentShader:to.background.fragmentShader,side:Cl,depthTest:!1,depthWrite:!1,fog:!1})),r.geometry.deleteAttribute("normal"),Object.defineProperty(r.material,"map",{get:function(){return this.uniforms.t2D.value}}),T.update(r)),r.material.uniforms.t2D.value=d,r.material.uniforms.backgroundIntensity.value=o.backgroundIntensity,r.material.toneMapped=rn.getTransfer(d.colorSpace)!==vn,d.matrixAutoUpdate===!0&&d.updateMatrix(),r.material.uniforms.uvTransform.value.copy(d.matrix),(h!==d||a!==d.version||l!==g.toneMapping)&&(r.material.needsUpdate=!0,h=d,a=d.version,l=g.toneMapping),r.layers.enableAll(),f.unshift(r,r.geometry,r.material,0,0,null))}function u(f,o){f.getRGB(Sv,pw(g)),x.buffers.color.setClear(Sv.r,Sv.g,Sv.b,o,s)}return{getClearColor:function(){return y},setClearColor:function(f,o=1){y.set(f),e=o,u(y,e)},getClearAlpha:function(){return e},setClearAlpha:function(f){e=f,u(y,e)},render:n}}function ZB(g,t,i,x){const T=g.getParameter(g.MAX_VERTEX_ATTRIBS),E=x.isWebGL2?null:t.get("OES_vertex_array_object"),s=x.isWebGL2||E!==null,y={},e=f(null);let r=e,p=!1;function h(I,D,B,G,z){let X=!1;if(s){const K=u(G,B,D);r!==K&&(r=K,l(r.object)),X=o(I,G,B,z),X&&c(I,G,B,z)}else{const K=D.wireframe===!0;(r.geometry!==G.id||r.program!==B.id||r.wireframe!==K)&&(r.geometry=G.id,r.program=B.id,r.wireframe=K,X=!0)}z!==null&&i.update(z,g.ELEMENT_ARRAY_BUFFER),(X||p)&&(p=!1,w(I,D,B,G),z!==null&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,i.get(z).buffer))}function a(){return x.isWebGL2?g.createVertexArray():E.createVertexArrayOES()}function l(I){return x.isWebGL2?g.bindVertexArray(I):E.bindVertexArrayOES(I)}function n(I){return x.isWebGL2?g.deleteVertexArray(I):E.deleteVertexArrayOES(I)}function u(I,D,B){const G=B.wireframe===!0;let z=y[I.id];z===void 0&&(z={},y[I.id]=z);let X=z[D.id];X===void 0&&(X={},z[D.id]=X);let K=X[G];return K===void 0&&(K=f(a()),X[G]=K),K}function f(I){const D=[],B=[],G=[];for(let z=0;z=0){const Z=z[tt];let U=X[tt];if(U===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(U=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(U=I.instanceColor)),Z===void 0||Z.attribute!==U||U&&Z.data!==U.data)return!0;K++}return r.attributesNum!==K||r.index!==G}function c(I,D,B,G){const z={},X=D.attributes;let K=0;const Q=B.getAttributes();for(const tt in Q)if(Q[tt].location>=0){let Z=X[tt];Z===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(Z=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(Z=I.instanceColor));const U={};U.attribute=Z,Z&&Z.data&&(U.data=Z.data),z[tt]=U,K++}r.attributes=z,r.attributesNum=K,r.index=G}function d(){const I=r.newAttributes;for(let D=0,B=I.length;D=0){let Y=z[Q];if(Y===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(Y=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(Y=I.instanceColor)),Y!==void 0){const Z=Y.normalized,U=Y.itemSize,H=i.get(Y);if(H===void 0)continue;const J=H.buffer,_=H.type,q=H.bytesPerElement,at=x.isWebGL2===!0&&(_===g.INT||_===g.UNSIGNED_INT||Y.gpuType===r1);if(Y.isInterleavedBufferAttribute){const ot=Y.data,rt=ot.stride,gt=Y.offset;if(ot.isInstancedInterleavedBuffer){for(let yt=0;yt0&&g.getShaderPrecisionFormat(g.FRAGMENT_SHADER,g.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&g.getShaderPrecisionFormat(g.VERTEX_SHADER,g.MEDIUM_FLOAT).precision>0&&g.getShaderPrecisionFormat(g.FRAGMENT_SHADER,g.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&g.constructor.name==="WebGL2RenderingContext";let y=i.precision!==void 0?i.precision:"highp";const e=E(y);e!==y&&(console.warn("THREE.WebGLRenderer:",y,"not supported, using",e,"instead."),y=e);const r=s||t.has("WEBGL_draw_buffers"),p=i.logarithmicDepthBuffer===!0,h=g.getParameter(g.MAX_TEXTURE_IMAGE_UNITS),a=g.getParameter(g.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=g.getParameter(g.MAX_TEXTURE_SIZE),n=g.getParameter(g.MAX_CUBE_MAP_TEXTURE_SIZE),u=g.getParameter(g.MAX_VERTEX_ATTRIBS),f=g.getParameter(g.MAX_VERTEX_UNIFORM_VECTORS),o=g.getParameter(g.MAX_VARYING_VECTORS),c=g.getParameter(g.MAX_FRAGMENT_UNIFORM_VECTORS),d=a>0,v=s||t.has("OES_texture_float"),m=d&&v,S=s?g.getParameter(g.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:r,getMaxAnisotropy:T,getMaxPrecision:E,precision:y,logarithmicDepthBuffer:p,maxTextures:h,maxVertexTextures:a,maxTextureSize:l,maxCubemapSize:n,maxAttributes:u,maxVertexUniforms:f,maxVaryings:o,maxFragmentUniforms:c,vertexTextures:d,floatFragmentTextures:v,floatVertexTextures:m,maxSamples:S}}function QB(g){const t=this;let i=null,x=0,T=!1,E=!1;const s=new ah,y=new Oi,e={value:null,needsUpdate:!1};this.uniform=e,this.numPlanes=0,this.numIntersection=0,this.init=function(h,a){const l=h.length!==0||a||x!==0||T;return T=a,x=h.length,l},this.beginShadows=function(){E=!0,p(null)},this.endShadows=function(){E=!1},this.setGlobalState=function(h,a){i=p(h,a,0)},this.setState=function(h,a,l){const n=h.clippingPlanes,u=h.clipIntersection,f=h.clipShadows,o=g.get(h);if(!T||n===null||n.length===0||E&&!f)E?p(null):r();else{const c=E?0:x,d=c*4;let v=o.clippingState||null;e.value=v,v=p(n,a,d,l);for(let m=0;m!==d;++m)v[m]=i[m];o.clippingState=v,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=c}};function r(){e.value!==i&&(e.value=i,e.needsUpdate=x>0),t.numPlanes=x,t.numIntersection=0}function p(h,a,l,n){const u=h!==null?h.length:0;let f=null;if(u!==0){if(f=e.value,n!==!0||f===null){const o=l+u*4,c=a.matrixWorldInverse;y.getNormalMatrix(c),(f===null||f.length0){const r=new gw(e.height);return r.fromEquirectangularTexture(g,s),t.set(s,r),s.addEventListener("dispose",T),i(r.texture,s.mapping)}else return null}}return s}function T(s){const y=s.target;y.removeEventListener("dispose",T);const e=t.get(y);e!==void 0&&(t.delete(y),e.dispose())}function E(){t=new WeakMap}return{get:x,dispose:E}}class qd extends $d{constructor(t=-1,i=1,x=1,T=-1,E=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=i,this.top=x,this.bottom=T,this.near=E,this.far=s,this.updateProjectionMatrix()}copy(t,i){return super.copy(t,i),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,i,x,T,E,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=i,this.view.offsetX=x,this.view.offsetY=T,this.view.width=E,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),i=(this.top-this.bottom)/(2*this.zoom),x=(this.right+this.left)/2,T=(this.top+this.bottom)/2;let E=x-t,s=x+t,y=T+i,e=T-i;if(this.view!==null&&this.view.enabled){const r=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;E+=r*this.view.offsetX,s=E+r*this.view.width,y-=p*this.view.offsetY,e=y-p*this.view.height}this.projectionMatrix.makeOrthographic(E,s,y,e,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const i=super.toJSON(t);return i.object.zoom=this.zoom,i.object.left=this.left,i.object.right=this.right,i.object.top=this.top,i.object.bottom=this.bottom,i.object.near=this.near,i.object.far=this.far,this.view!==null&&(i.object.view=Object.assign({},this.view)),i}}const Uf=4,YT=[.125,.215,.35,.446,.526,.582],cu=20,B0=new qd,kT=new ze;let U0=null,z0=0,G0=0;const uu=(1+Math.sqrt(5))/2,Ef=1/uu,KT=[new Ct(1,1,1),new Ct(-1,1,1),new Ct(1,1,-1),new Ct(-1,1,-1),new Ct(0,uu,Ef),new Ct(0,uu,-Ef),new Ct(Ef,0,uu),new Ct(-Ef,0,uu),new Ct(uu,Ef,0),new Ct(-uu,Ef,0)];class px{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,i=0,x=.1,T=100){U0=this._renderer.getRenderTarget(),z0=this._renderer.getActiveCubeFace(),G0=this._renderer.getActiveMipmapLevel(),this._setSize(256);const E=this._allocateTargets();return E.depthBuffer=!0,this._sceneToCubeUV(t,x,T,E),i>0&&this._blur(E,0,0,i),this._applyPMREM(E),this._cleanup(E),E}fromEquirectangular(t,i=null){return this._fromTexture(t,i)}fromCubemap(t,i=null){return this._fromTexture(t,i)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=JT(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ZT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?d:0,d,d),p.setRenderTarget(T),u&&p.render(n,y),p.render(t,y)}n.geometry.dispose(),n.material.dispose(),p.toneMapping=a,p.autoClear=h,t.background=f}_textureToCubeUV(t,i){const x=this._renderer,T=t.mapping===wl||t.mapping===vh;T?(this._cubemapMaterial===null&&(this._cubemapMaterial=JT()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ZT());const E=T?this._cubemapMaterial:this._equirectMaterial,s=new cr(this._lodPlanes[0],E),y=E.uniforms;y.envMap.value=t;const e=this._cubeSize;Tv(i,0,0,3*e,2*e),x.setRenderTarget(i),x.render(s,B0)}_applyPMREM(t){const i=this._renderer,x=i.autoClear;i.autoClear=!1;for(let T=1;Tcu&&console.warn(`sigmaRadians, ${E}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${cu}`);const o=[];let c=0;for(let M=0;Md-Uf?T-d+Uf:0),S=4*(this._cubeSize-v);Tv(i,m,S,3*v,2*v),e.setRenderTarget(i),e.render(h,B0)}}function qB(g){const t=[],i=[],x=[];let T=g;const E=g-Uf+1+YT.length;for(let s=0;sg-Uf?e=YT[s-g+Uf-1]:s===0&&(e=0),x.push(e);const r=1/(y-2),p=-r,h=1+r,a=[p,p,h,p,h,h,p,p,h,h,p,h],l=6,n=6,u=3,f=2,o=1,c=new Float32Array(u*n*l),d=new Float32Array(f*n*l),v=new Float32Array(o*n*l);for(let S=0;S2?0:-1,C=[M,w,0,M+2/3,w,0,M+2/3,w+1,0,M,w,0,M+2/3,w+1,0,M,w+1,0];c.set(C,u*n*S),d.set(a,f*n*S);const A=[S,S,S,S,S,S];v.set(A,o*n*S)}const m=new Li;m.setAttribute("position",new an(c,u)),m.setAttribute("uv",new an(d,f)),m.setAttribute("faceIndex",new an(v,o)),t.push(m),T>Uf&&T--}return{lodPlanes:t,sizeLods:i,sigmas:x}}function jT(g,t,i){const x=new io(g,t,i);return x.texture.mapping=ec,x.texture.name="PMREM.cubeUv",x.scissorTest=!0,x}function Tv(g,t,i,x,T){g.viewport.set(t,i,x,T),g.scissor.set(t,i,x,T)}function t8(g,t,i){const x=new Float32Array(cu),T=new Ct(0,1,0);return new no({name:"SphericalGaussianBlur",defines:{n:cu,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${g}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:x},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:T}},vertexShader:x1(),fragmentShader:` +}`,bi={alphahash_fragment:pN,alphahash_pars_fragment:vN,alphamap_fragment:mN,alphamap_pars_fragment:gN,alphatest_fragment:yN,alphatest_pars_fragment:xN,aomap_fragment:SN,aomap_pars_fragment:TN,batching_pars_vertex:EN,batching_vertex:MN,begin_vertex:CN,beginnormal_vertex:wN,bsdfs:AN,iridescence_fragment:PN,bumpmap_pars_fragment:RN,clipping_planes_fragment:bN,clipping_planes_pars_fragment:LN,clipping_planes_pars_vertex:FN,clipping_planes_vertex:ON,color_fragment:DN,color_pars_fragment:IN,color_pars_vertex:NN,color_vertex:BN,common:UN,cube_uv_reflection_fragment:zN,defaultnormal_vertex:GN,displacementmap_pars_vertex:VN,displacementmap_vertex:HN,emissivemap_fragment:WN,emissivemap_pars_fragment:XN,colorspace_fragment:YN,colorspace_pars_fragment:kN,envmap_fragment:KN,envmap_common_pars_fragment:jN,envmap_pars_fragment:ZN,envmap_pars_vertex:JN,envmap_physical_pars_fragment:o9,envmap_vertex:$N,fog_vertex:QN,fog_pars_vertex:_N,fog_fragment:qN,fog_pars_fragment:t9,gradientmap_pars_fragment:e9,lightmap_fragment:i9,lightmap_pars_fragment:n9,lights_lambert_fragment:r9,lights_lambert_pars_fragment:s9,lights_pars_begin:a9,lights_toon_fragment:l9,lights_toon_pars_fragment:h9,lights_phong_fragment:u9,lights_phong_pars_fragment:f9,lights_physical_fragment:c9,lights_physical_pars_fragment:d9,lights_fragment_begin:p9,lights_fragment_maps:v9,lights_fragment_end:m9,logdepthbuf_fragment:g9,logdepthbuf_pars_fragment:y9,logdepthbuf_pars_vertex:x9,logdepthbuf_vertex:S9,map_fragment:T9,map_pars_fragment:E9,map_particle_fragment:M9,map_particle_pars_fragment:C9,metalnessmap_fragment:w9,metalnessmap_pars_fragment:A9,morphcolor_vertex:P9,morphnormal_vertex:R9,morphtarget_pars_vertex:b9,morphtarget_vertex:L9,normal_fragment_begin:F9,normal_fragment_maps:O9,normal_pars_fragment:D9,normal_pars_vertex:I9,normal_vertex:N9,normalmap_pars_fragment:B9,clearcoat_normal_fragment_begin:U9,clearcoat_normal_fragment_maps:z9,clearcoat_pars_fragment:G9,iridescence_pars_fragment:V9,opaque_fragment:H9,packing:W9,premultiplied_alpha_fragment:X9,project_vertex:Y9,dithering_fragment:k9,dithering_pars_fragment:K9,roughnessmap_fragment:j9,roughnessmap_pars_fragment:Z9,shadowmap_pars_fragment:J9,shadowmap_pars_vertex:$9,shadowmap_vertex:Q9,shadowmask_pars_fragment:_9,skinbase_vertex:q9,skinning_pars_vertex:tB,skinning_vertex:eB,skinnormal_vertex:iB,specularmap_fragment:nB,specularmap_pars_fragment:rB,tonemapping_fragment:sB,tonemapping_pars_fragment:aB,transmission_fragment:oB,transmission_pars_fragment:lB,uv_pars_fragment:hB,uv_pars_vertex:uB,uv_vertex:fB,worldpos_vertex:cB,background_vert:dB,background_frag:pB,backgroundCube_vert:vB,backgroundCube_frag:mB,cube_vert:gB,cube_frag:yB,depth_vert:xB,depth_frag:SB,distanceRGBA_vert:TB,distanceRGBA_frag:EB,equirect_vert:MB,equirect_frag:CB,linedashed_vert:wB,linedashed_frag:AB,meshbasic_vert:PB,meshbasic_frag:RB,meshlambert_vert:bB,meshlambert_frag:LB,meshmatcap_vert:FB,meshmatcap_frag:OB,meshnormal_vert:DB,meshnormal_frag:IB,meshphong_vert:NB,meshphong_frag:BB,meshphysical_vert:UB,meshphysical_frag:zB,meshtoon_vert:GB,meshtoon_frag:VB,points_vert:HB,points_frag:WB,shadow_vert:XB,shadow_frag:YB,sprite_vert:kB,sprite_frag:KB},Fe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oi},alphaMap:{value:null},alphaMapTransform:{value:new Oi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oi}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oi},normalScale:{value:new ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oi},alphaTest:{value:0},uvTransform:{value:new Oi}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oi},alphaMap:{value:null},alphaMapTransform:{value:new Oi},alphaTest:{value:0}}},to={basic:{uniforms:ds([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.fog]),vertexShader:bi.meshbasic_vert,fragmentShader:bi.meshbasic_frag},lambert:{uniforms:ds([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:bi.meshlambert_vert,fragmentShader:bi.meshlambert_frag},phong:{uniforms:ds([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30}}]),vertexShader:bi.meshphong_vert,fragmentShader:bi.meshphong_frag},standard:{uniforms:ds([Fe.common,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.roughnessmap,Fe.metalnessmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:bi.meshphysical_vert,fragmentShader:bi.meshphysical_frag},toon:{uniforms:ds([Fe.common,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.gradientmap,Fe.fog,Fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:bi.meshtoon_vert,fragmentShader:bi.meshtoon_frag},matcap:{uniforms:ds([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,{matcap:{value:null}}]),vertexShader:bi.meshmatcap_vert,fragmentShader:bi.meshmatcap_frag},points:{uniforms:ds([Fe.points,Fe.fog]),vertexShader:bi.points_vert,fragmentShader:bi.points_frag},dashed:{uniforms:ds([Fe.common,Fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:bi.linedashed_vert,fragmentShader:bi.linedashed_frag},depth:{uniforms:ds([Fe.common,Fe.displacementmap]),vertexShader:bi.depth_vert,fragmentShader:bi.depth_frag},normal:{uniforms:ds([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,{opacity:{value:1}}]),vertexShader:bi.meshnormal_vert,fragmentShader:bi.meshnormal_frag},sprite:{uniforms:ds([Fe.sprite,Fe.fog]),vertexShader:bi.sprite_vert,fragmentShader:bi.sprite_frag},background:{uniforms:{uvTransform:{value:new Oi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:bi.background_vert,fragmentShader:bi.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:bi.backgroundCube_vert,fragmentShader:bi.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:bi.cube_vert,fragmentShader:bi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:bi.equirect_vert,fragmentShader:bi.equirect_frag},distanceRGBA:{uniforms:ds([Fe.common,Fe.displacementmap,{referencePosition:{value:new Ct},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:bi.distanceRGBA_vert,fragmentShader:bi.distanceRGBA_frag},shadow:{uniforms:ds([Fe.lights,Fe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:bi.shadow_vert,fragmentShader:bi.shadow_frag}};to.physical={uniforms:ds([to.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oi},clearcoatNormalScale:{value:new ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oi},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oi},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oi},transmissionSamplerSize:{value:new ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oi},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oi},anisotropyVector:{value:new ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oi}}]),vertexShader:bi.meshphysical_vert,fragmentShader:bi.meshphysical_frag};const Sv={r:0,b:0,g:0};function jB(g,t,i,x,T,E,s){const y=new ze(0);let e=E===!0?0:1,r,p,h=null,a=0,l=null;function n(f,o){let c=!1,d=o.isScene===!0?o.background:null;d&&d.isTexture&&(d=(o.backgroundBlurriness>0?i:t).get(d)),d===null?u(y,e):d&&d.isColor&&(u(d,1),c=!0);const v=g.xr.getEnvironmentBlendMode();v==="additive"?x.buffers.color.setClear(0,0,0,1,s):v==="alpha-blend"&&x.buffers.color.setClear(0,0,0,0,s),(g.autoClear||c)&&g.clear(g.autoClearColor,g.autoClearDepth,g.autoClearStencil),d&&(d.isCubeTexture||d.mapping===ec)?(p===void 0&&(p=new cr(new Ou(1,1,1),new no({name:"BackgroundCubeMaterial",uniforms:$f(to.backgroundCube.uniforms),vertexShader:to.backgroundCube.vertexShader,fragmentShader:to.backgroundCube.fragmentShader,side:ms,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(m,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),T.update(p)),p.material.uniforms.envMap.value=d,p.material.uniforms.flipEnvMap.value=d.isCubeTexture&&d.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=o.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=o.backgroundIntensity,p.material.toneMapped=rn.getTransfer(d.colorSpace)!==vn,(h!==d||a!==d.version||l!==g.toneMapping)&&(p.material.needsUpdate=!0,h=d,a=d.version,l=g.toneMapping),p.layers.enableAll(),f.unshift(p,p.geometry,p.material,0,0,null)):d&&d.isTexture&&(r===void 0&&(r=new cr(new nc(2,2),new no({name:"BackgroundMaterial",uniforms:$f(to.background.uniforms),vertexShader:to.background.vertexShader,fragmentShader:to.background.fragmentShader,side:Cl,depthTest:!1,depthWrite:!1,fog:!1})),r.geometry.deleteAttribute("normal"),Object.defineProperty(r.material,"map",{get:function(){return this.uniforms.t2D.value}}),T.update(r)),r.material.uniforms.t2D.value=d,r.material.uniforms.backgroundIntensity.value=o.backgroundIntensity,r.material.toneMapped=rn.getTransfer(d.colorSpace)!==vn,d.matrixAutoUpdate===!0&&d.updateMatrix(),r.material.uniforms.uvTransform.value.copy(d.matrix),(h!==d||a!==d.version||l!==g.toneMapping)&&(r.material.needsUpdate=!0,h=d,a=d.version,l=g.toneMapping),r.layers.enableAll(),f.unshift(r,r.geometry,r.material,0,0,null))}function u(f,o){f.getRGB(Sv,pw(g)),x.buffers.color.setClear(Sv.r,Sv.g,Sv.b,o,s)}return{getClearColor:function(){return y},setClearColor:function(f,o=1){y.set(f),e=o,u(y,e)},getClearAlpha:function(){return e},setClearAlpha:function(f){e=f,u(y,e)},render:n}}function ZB(g,t,i,x){const T=g.getParameter(g.MAX_VERTEX_ATTRIBS),E=x.isWebGL2?null:t.get("OES_vertex_array_object"),s=x.isWebGL2||E!==null,y={},e=f(null);let r=e,p=!1;function h(I,D,B,G,z){let X=!1;if(s){const K=u(G,B,D);r!==K&&(r=K,l(r.object)),X=o(I,G,B,z),X&&c(I,G,B,z)}else{const K=D.wireframe===!0;(r.geometry!==G.id||r.program!==B.id||r.wireframe!==K)&&(r.geometry=G.id,r.program=B.id,r.wireframe=K,X=!0)}z!==null&&i.update(z,g.ELEMENT_ARRAY_BUFFER),(X||p)&&(p=!1,w(I,D,B,G),z!==null&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,i.get(z).buffer))}function a(){return x.isWebGL2?g.createVertexArray():E.createVertexArrayOES()}function l(I){return x.isWebGL2?g.bindVertexArray(I):E.bindVertexArrayOES(I)}function n(I){return x.isWebGL2?g.deleteVertexArray(I):E.deleteVertexArrayOES(I)}function u(I,D,B){const G=B.wireframe===!0;let z=y[I.id];z===void 0&&(z={},y[I.id]=z);let X=z[D.id];X===void 0&&(X={},z[D.id]=X);let K=X[G];return K===void 0&&(K=f(a()),X[G]=K),K}function f(I){const D=[],B=[],G=[];for(let z=0;z=0){const Z=z[tt];let U=X[tt];if(U===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(U=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(U=I.instanceColor)),Z===void 0||Z.attribute!==U||U&&Z.data!==U.data)return!0;K++}return r.attributesNum!==K||r.index!==G}function c(I,D,B,G){const z={},X=D.attributes;let K=0;const Q=B.getAttributes();for(const tt in Q)if(Q[tt].location>=0){let Z=X[tt];Z===void 0&&(tt==="instanceMatrix"&&I.instanceMatrix&&(Z=I.instanceMatrix),tt==="instanceColor"&&I.instanceColor&&(Z=I.instanceColor));const U={};U.attribute=Z,Z&&Z.data&&(U.data=Z.data),z[tt]=U,K++}r.attributes=z,r.attributesNum=K,r.index=G}function d(){const I=r.newAttributes;for(let D=0,B=I.length;D=0){let Y=z[Q];if(Y===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(Y=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(Y=I.instanceColor)),Y!==void 0){const Z=Y.normalized,U=Y.itemSize,H=i.get(Y);if(H===void 0)continue;const J=H.buffer,_=H.type,q=H.bytesPerElement,at=x.isWebGL2===!0&&(_===g.INT||_===g.UNSIGNED_INT||Y.gpuType===r1);if(Y.isInterleavedBufferAttribute){const ot=Y.data,rt=ot.stride,gt=Y.offset;if(ot.isInstancedInterleavedBuffer){for(let yt=0;yt0&&g.getShaderPrecisionFormat(g.FRAGMENT_SHADER,g.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&g.getShaderPrecisionFormat(g.VERTEX_SHADER,g.MEDIUM_FLOAT).precision>0&&g.getShaderPrecisionFormat(g.FRAGMENT_SHADER,g.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&g.constructor.name==="WebGL2RenderingContext";let y=i.precision!==void 0?i.precision:"highp";const e=E(y);e!==y&&(console.warn("THREE.WebGLRenderer:",y,"not supported, using",e,"instead."),y=e);const r=s||t.has("WEBGL_draw_buffers"),p=i.logarithmicDepthBuffer===!0,h=g.getParameter(g.MAX_TEXTURE_IMAGE_UNITS),a=g.getParameter(g.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=g.getParameter(g.MAX_TEXTURE_SIZE),n=g.getParameter(g.MAX_CUBE_MAP_TEXTURE_SIZE),u=g.getParameter(g.MAX_VERTEX_ATTRIBS),f=g.getParameter(g.MAX_VERTEX_UNIFORM_VECTORS),o=g.getParameter(g.MAX_VARYING_VECTORS),c=g.getParameter(g.MAX_FRAGMENT_UNIFORM_VECTORS),d=a>0,v=s||t.has("OES_texture_float"),m=d&&v,S=s?g.getParameter(g.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:r,getMaxAnisotropy:T,getMaxPrecision:E,precision:y,logarithmicDepthBuffer:p,maxTextures:h,maxVertexTextures:a,maxTextureSize:l,maxCubemapSize:n,maxAttributes:u,maxVertexUniforms:f,maxVaryings:o,maxFragmentUniforms:c,vertexTextures:d,floatFragmentTextures:v,floatVertexTextures:m,maxSamples:S}}function QB(g){const t=this;let i=null,x=0,T=!1,E=!1;const s=new ah,y=new Oi,e={value:null,needsUpdate:!1};this.uniform=e,this.numPlanes=0,this.numIntersection=0,this.init=function(h,a){const l=h.length!==0||a||x!==0||T;return T=a,x=h.length,l},this.beginShadows=function(){E=!0,p(null)},this.endShadows=function(){E=!1},this.setGlobalState=function(h,a){i=p(h,a,0)},this.setState=function(h,a,l){const n=h.clippingPlanes,u=h.clipIntersection,f=h.clipShadows,o=g.get(h);if(!T||n===null||n.length===0||E&&!f)E?p(null):r();else{const c=E?0:x,d=c*4;let v=o.clippingState||null;e.value=v,v=p(n,a,d,l);for(let m=0;m!==d;++m)v[m]=i[m];o.clippingState=v,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=c}};function r(){e.value!==i&&(e.value=i,e.needsUpdate=x>0),t.numPlanes=x,t.numIntersection=0}function p(h,a,l,n){const u=h!==null?h.length:0;let f=null;if(u!==0){if(f=e.value,n!==!0||f===null){const o=l+u*4,c=a.matrixWorldInverse;y.getNormalMatrix(c),(f===null||f.length0){const r=new gw(e.height);return r.fromEquirectangularTexture(g,s),t.set(s,r),s.addEventListener("dispose",T),i(r.texture,s.mapping)}else return null}}return s}function T(s){const y=s.target;y.removeEventListener("dispose",T);const e=t.get(y);e!==void 0&&(t.delete(y),e.dispose())}function E(){t=new WeakMap}return{get:x,dispose:E}}class qd extends $d{constructor(t=-1,i=1,x=1,T=-1,E=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=i,this.top=x,this.bottom=T,this.near=E,this.far=s,this.updateProjectionMatrix()}copy(t,i){return super.copy(t,i),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,i,x,T,E,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=i,this.view.offsetX=x,this.view.offsetY=T,this.view.width=E,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),i=(this.top-this.bottom)/(2*this.zoom),x=(this.right+this.left)/2,T=(this.top+this.bottom)/2;let E=x-t,s=x+t,y=T+i,e=T-i;if(this.view!==null&&this.view.enabled){const r=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;E+=r*this.view.offsetX,s=E+r*this.view.width,y-=p*this.view.offsetY,e=y-p*this.view.height}this.projectionMatrix.makeOrthographic(E,s,y,e,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const i=super.toJSON(t);return i.object.zoom=this.zoom,i.object.left=this.left,i.object.right=this.right,i.object.top=this.top,i.object.bottom=this.bottom,i.object.near=this.near,i.object.far=this.far,this.view!==null&&(i.object.view=Object.assign({},this.view)),i}}const Uf=4,YT=[.125,.215,.35,.446,.526,.582],cu=20,U0=new qd,kT=new ze;let z0=null,G0=0,V0=0;const uu=(1+Math.sqrt(5))/2,Ef=1/uu,KT=[new Ct(1,1,1),new Ct(-1,1,1),new Ct(1,1,-1),new Ct(-1,1,-1),new Ct(0,uu,Ef),new Ct(0,uu,-Ef),new Ct(Ef,0,uu),new Ct(-Ef,0,uu),new Ct(uu,Ef,0),new Ct(-uu,Ef,0)];class vx{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,i=0,x=.1,T=100){z0=this._renderer.getRenderTarget(),G0=this._renderer.getActiveCubeFace(),V0=this._renderer.getActiveMipmapLevel(),this._setSize(256);const E=this._allocateTargets();return E.depthBuffer=!0,this._sceneToCubeUV(t,x,T,E),i>0&&this._blur(E,0,0,i),this._applyPMREM(E),this._cleanup(E),E}fromEquirectangular(t,i=null){return this._fromTexture(t,i)}fromCubemap(t,i=null){return this._fromTexture(t,i)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=JT(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ZT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?d:0,d,d),p.setRenderTarget(T),u&&p.render(n,y),p.render(t,y)}n.geometry.dispose(),n.material.dispose(),p.toneMapping=a,p.autoClear=h,t.background=f}_textureToCubeUV(t,i){const x=this._renderer,T=t.mapping===wl||t.mapping===vh;T?(this._cubemapMaterial===null&&(this._cubemapMaterial=JT()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ZT());const E=T?this._cubemapMaterial:this._equirectMaterial,s=new cr(this._lodPlanes[0],E),y=E.uniforms;y.envMap.value=t;const e=this._cubeSize;Tv(i,0,0,3*e,2*e),x.setRenderTarget(i),x.render(s,U0)}_applyPMREM(t){const i=this._renderer,x=i.autoClear;i.autoClear=!1;for(let T=1;Tcu&&console.warn(`sigmaRadians, ${E}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${cu}`);const o=[];let c=0;for(let M=0;Md-Uf?T-d+Uf:0),S=4*(this._cubeSize-v);Tv(i,m,S,3*v,2*v),e.setRenderTarget(i),e.render(h,U0)}}function qB(g){const t=[],i=[],x=[];let T=g;const E=g-Uf+1+YT.length;for(let s=0;sg-Uf?e=YT[s-g+Uf-1]:s===0&&(e=0),x.push(e);const r=1/(y-2),p=-r,h=1+r,a=[p,p,h,p,h,h,p,p,h,h,p,h],l=6,n=6,u=3,f=2,o=1,c=new Float32Array(u*n*l),d=new Float32Array(f*n*l),v=new Float32Array(o*n*l);for(let S=0;S2?0:-1,C=[M,w,0,M+2/3,w,0,M+2/3,w+1,0,M,w,0,M+2/3,w+1,0,M,w+1,0];c.set(C,u*n*S),d.set(a,f*n*S);const A=[S,S,S,S,S,S];v.set(A,o*n*S)}const m=new Li;m.setAttribute("position",new an(c,u)),m.setAttribute("uv",new an(d,f)),m.setAttribute("faceIndex",new an(v,o)),t.push(m),T>Uf&&T--}return{lodPlanes:t,sizeLods:i,sigmas:x}}function jT(g,t,i){const x=new io(g,t,i);return x.texture.mapping=ec,x.texture.name="PMREM.cubeUv",x.scissorTest=!0,x}function Tv(g,t,i,x,T){g.viewport.set(t,i,x,T),g.scissor.set(t,i,x,T)}function t8(g,t,i){const x=new Float32Array(cu),T=new Ct(0,1,0);return new no({name:"SphericalGaussianBlur",defines:{n:cu,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${g}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:x},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:T}},vertexShader:x1(),fragmentShader:` precision mediump float; precision mediump int; @@ -10062,16 +10062,16 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function e8(g){let t=new WeakMap,i=null;function x(y){if(y&&y.isTexture){const e=y.mapping,r=e===Td||e===Ed,p=e===wl||e===vh;if(r||p)if(y.isRenderTargetTexture&&y.needsPMREMUpdate===!0){y.needsPMREMUpdate=!1;let h=t.get(y);return i===null&&(i=new px(g)),h=r?i.fromEquirectangular(y,h):i.fromCubemap(y,h),t.set(y,h),h.texture}else{if(t.has(y))return t.get(y).texture;{const h=y.image;if(r&&h&&h.height>0||p&&h&&T(h)){i===null&&(i=new px(g));const a=r?i.fromEquirectangular(y):i.fromCubemap(y);return t.set(y,a),y.addEventListener("dispose",E),a.texture}else return null}}}return y}function T(y){let e=0;const r=6;for(let p=0;pt.maxTextureSize&&(A=Math.ceil(C/t.maxTextureSize),C=t.maxTextureSize);const P=new Float32Array(C*A*4*n),b=new lg(P,C,A,n);b.type=Ea,b.needsUpdate=!0;const O=w*4;for(let D=0;D0)return g;const T=t*i;let E=$T[T];if(E===void 0&&(E=new Float32Array(T),$T[T]=E),t!==0){x.toArray(E,0);for(let s=1,y=0;s!==t;++s)y+=i,g[s].toArray(E,y)}return E}function gr(g,t){if(g.length!==t.length)return!1;for(let i=0,x=g.length;i0||p&&h&&T(h)){i===null&&(i=new vx(g));const a=r?i.fromEquirectangular(y):i.fromCubemap(y);return t.set(y,a),y.addEventListener("dispose",E),a.texture}else return null}}}return y}function T(y){let e=0;const r=6;for(let p=0;pt.maxTextureSize&&(A=Math.ceil(C/t.maxTextureSize),C=t.maxTextureSize);const P=new Float32Array(C*A*4*n),b=new hg(P,C,A,n);b.type=Ea,b.needsUpdate=!0;const O=w*4;for(let D=0;D0)return g;const T=t*i;let E=$T[T];if(E===void 0&&(E=new Float32Array(T),$T[T]=E),t!==0){x.toArray(E,0);for(let s=1,y=0;s!==t;++s)y+=i,g[s].toArray(E,y)}return E}function gr(g,t){if(g.length!==t.length)return!1;for(let i=0,x=g.length;i":" "} ${y}: ${i[s]}`)}return x.join(` -`)}function n6(g){const t=rn.getPrimaries(rn.workingColorSpace),i=rn.getPrimaries(g);let x;switch(t===i?x="":t===Ld&&i===bd?x="LinearDisplayP3ToLinearSRGB":t===bd&&i===Ld&&(x="LinearSRGBToLinearDisplayP3"),g){case Go:case Jd:return[x,"LinearTransferOETF"];case vr:case og:return[x,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",g),[x,"LinearTransferOETF"]}}function nE(g,t,i){const x=g.getShaderParameter(t,g.COMPILE_STATUS),T=g.getShaderInfoLog(t).trim();if(x&&T==="")return"";const E=/ERROR: 0:(\d+)/.exec(T);if(E){const s=parseInt(E[1]);return i.toUpperCase()+` +`)}function n6(g){const t=rn.getPrimaries(rn.workingColorSpace),i=rn.getPrimaries(g);let x;switch(t===i?x="":t===Ld&&i===bd?x="LinearDisplayP3ToLinearSRGB":t===bd&&i===Ld&&(x="LinearSRGBToLinearDisplayP3"),g){case Go:case Jd:return[x,"LinearTransferOETF"];case vr:case lg:return[x,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",g),[x,"LinearTransferOETF"]}}function nE(g,t,i){const x=g.getShaderParameter(t,g.COMPILE_STATUS),T=g.getShaderInfoLog(t).trim();if(x&&T==="")return"";const E=/ERROR: 0:(\d+)/.exec(T);if(E){const s=parseInt(E[1]);return i.toUpperCase()+` `+T+` `+i6(g.getShaderSource(t),s)}else return T}function r6(g,t){const i=n6(t);return`vec4 ${g}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}function s6(g,t){let i;switch(t){case U2:i="Linear";break;case z2:i="Reinhard";break;case G2:i="OptimizedCineon";break;case n1:i="ACESFilmic";break;case H2:i="AgX";break;case V2:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+g+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function a6(g){return[g.extensionDerivatives||g.envMapCubeUVHeight||g.bumpMap||g.normalMapTangentSpace||g.clearcoatNormalMap||g.flatShading||g.alphaToCoverage||g.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(g.extensionFragDepth||g.logarithmicDepthBuffer)&&g.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",g.extensionDrawBuffers&&g.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(g.extensionShaderTextureLOD||g.envMap||g.transmission)&&g.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(zf).join(` `)}function o6(g){return[g.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",g.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(zf).join(` `)}function l6(g){const t=[];for(const i in g){const x=g[i];x!==!1&&t.push("#define "+i+" "+x)}return t.join(` -`)}function h6(g,t){const i={},x=g.getProgramParameter(t,g.ACTIVE_ATTRIBUTES);for(let T=0;T/gm;function vx(g){return g.replace(u6,c6)}const f6=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function c6(g,t){let i=bi[t];if(i===void 0){const x=f6.get(t);if(x!==void 0)i=bi[x],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,x);else throw new Error("Can not resolve #include <"+t+">")}return vx(i)}const d6=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function aE(g){return g.replace(d6,p6)}function p6(g,t,i,x){let T="";for(let E=parseInt(t);E/gm;function mx(g){return g.replace(u6,c6)}const f6=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function c6(g,t){let i=bi[t];if(i===void 0){const x=f6.get(t);if(x!==void 0)i=bi[x],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,x);else throw new Error("Can not resolve #include <"+t+">")}return mx(i)}const d6=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function aE(g){return g.replace(d6,p6)}function p6(g,t,i,x){let T="";for(let E=parseInt(t);E0&&(o+=` `),c=[l,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,u].filter(zf).join(` @@ -10100,10 +10100,10 @@ void main() { `].filter(zf).join(` `),c=[l,oE(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,u,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+r:"",i.envMap?"#define "+p:"",i.envMap?"#define "+h:"",a?"#define CUBEUV_TEXEL_WIDTH "+a.texelWidth:"",a?"#define CUBEUV_TEXEL_HEIGHT "+a.texelHeight:"",a?"#define CUBEUV_MAX_MIP "+a.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&i.flatShading===!1?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+e:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==Bo?"#define TONE_MAPPING":"",i.toneMapping!==Bo?bi.tonemapping_pars_fragment:"",i.toneMapping!==Bo?s6("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",bi.colorspace_pars_fragment,r6("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",` `].filter(zf).join(` -`)),s=vx(s),s=rE(s,i),s=sE(s,i),y=vx(y),y=rE(y,i),y=sE(y,i),s=aE(s),y=aE(y),i.isWebGL2&&i.isRawShaderMaterial!==!0&&(d=`#version 300 es +`)),s=mx(s),s=rE(s,i),s=sE(s,i),y=mx(y),y=rE(y,i),y=sE(y,i),s=aE(s),y=aE(y),i.isWebGL2&&i.isRawShaderMaterial!==!0&&(d=`#version 300 es `,o=[n,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+o,c=["precision mediump sampler2DArray;","#define varying in",i.glslVersion===cx?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===cx?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`+o,c=["precision mediump sampler2DArray;","#define varying in",i.glslVersion===dx?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===dx?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` `+c);const v=d+o+s,m=d+c+y,S=iE(T,T.VERTEX_SHADER,v),M=iE(T,T.FRAGMENT_SHADER,m);T.attachShader(f,S),T.attachShader(f,M),i.index0AttributeName!==void 0?T.bindAttribLocation(f,0,i.index0AttributeName):i.morphTargets===!0&&T.bindAttribLocation(f,0,"position"),T.linkProgram(f);function w(b){if(g.debug.checkShaderErrors){const O=T.getProgramInfoLog(f).trim(),I=T.getShaderInfoLog(S).trim(),D=T.getShaderInfoLog(M).trim();let B=!0,G=!0;if(T.getProgramParameter(f,T.LINK_STATUS)===!1)if(B=!1,typeof g.debug.onShaderError=="function")g.debug.onShaderError(T,f,S,M);else{const z=nE(T,S,"vertex"),X=nE(T,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+T.getError()+" - VALIDATE_STATUS "+T.getProgramParameter(f,T.VALIDATE_STATUS)+` @@ -10140,7 +10140,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function B6(g,t,i){let x=new _d;const T=new ve,E=new ve,s=new sn,y=new T1({depthPacking:ew}),e=new E1,r={},p=i.maxTextureSize,h={[Cl]:ms,[ms]:Cl,[Oo]:Oo},a=new no({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ve},radius:{value:4}},vertexShader:I6,fragmentShader:N6}),l=a.clone();l.defines.HORIZONTAL_PASS=1;const n=new Li;n.setAttribute("position",new an(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const u=new cr(n,a),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ng;let o=this.type;this.render=function(S,M,w){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||S.length===0)return;const C=g.getRenderTarget(),A=g.getActiveCubeFace(),P=g.getActiveMipmapLevel(),b=g.state;b.setBlending(Ml),b.buffers.color.setClear(1,1,1,1),b.buffers.depth.setTest(!0),b.setScissorTest(!1);const O=o!==_a&&this.type===_a,I=o===_a&&this.type!==_a;for(let D=0,B=S.length;Dp||T.y>p)&&(T.x>p&&(E.x=Math.floor(p/X.x),T.x=E.x*X.x,z.mapSize.x=E.x),T.y>p&&(E.y=Math.floor(p/X.y),T.y=E.y*X.y,z.mapSize.y=E.y)),z.map===null||O===!0||I===!0){const Q=this.type!==_a?{minFilter:nr,magFilter:nr}:{};z.map!==null&&z.map.dispose(),z.map=new io(T.x,T.y,Q),z.map.texture.name=G.name+".shadowMap",z.camera.updateProjectionMatrix()}g.setRenderTarget(z.map),g.clear();const K=z.getViewportCount();for(let Q=0;Q0||M.map&&M.alphaTest>0){const b=A.uuid,O=M.uuid;let I=r[b];I===void 0&&(I={},r[b]=I);let D=I[O];D===void 0&&(D=A.clone(),I[O]=D,M.addEventListener("dispose",m)),A=D}if(A.visible=M.visible,A.wireframe=M.wireframe,C===_a?A.side=M.shadowSide!==null?M.shadowSide:M.side:A.side=M.shadowSide!==null?M.shadowSide:h[M.side],A.alphaMap=M.alphaMap,A.alphaTest=M.alphaTest,A.map=M.map,A.clipShadows=M.clipShadows,A.clippingPlanes=M.clippingPlanes,A.clipIntersection=M.clipIntersection,A.displacementMap=M.displacementMap,A.displacementScale=M.displacementScale,A.displacementBias=M.displacementBias,A.wireframeLinewidth=M.wireframeLinewidth,A.linewidth=M.linewidth,w.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const b=g.properties.get(A);b.light=w}return A}function v(S,M,w,C,A){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&A===_a)&&(!S.frustumCulled||x.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,S.matrixWorld);const O=t.update(S),I=S.material;if(Array.isArray(I)){const D=O.groups;for(let B=0,G=D.length;B=1):K.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),z=X>=2);let Q=null,tt={};const Y=g.getParameter(g.SCISSOR_BOX),Z=g.getParameter(g.VIEWPORT),U=new sn().fromArray(Y),H=new sn().fromArray(Z);function J(bt,Me,Ce,Ve){const Je=new Uint8Array(4),zi=g.createTexture();g.bindTexture(bt,zi),g.texParameteri(bt,g.TEXTURE_MIN_FILTER,g.NEAREST),g.texParameteri(bt,g.TEXTURE_MAG_FILTER,g.NEAREST);for(let Di=0;Di"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap;let h;const a=new WeakMap;let l=!1;try{l=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function n(dt,ut){return l?new OffscreenCanvas(dt,ut):Dd("canvas")}function u(dt,ut,Rt,Dt){let Ht=1;if((dt.width>Dt||dt.height>Dt)&&(Ht=Dt/Math.max(dt.width,dt.height)),Ht<1||ut===!0)if(typeof HTMLImageElement<"u"&&dt instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&dt instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&dt instanceof ImageBitmap){const Bt=ut?Tm:Math.floor,ne=Bt(Ht*dt.width),oe=Bt(Ht*dt.height);h===void 0&&(h=n(ne,oe));const ge=Rt?n(ne,oe):h;return ge.width=ne,ge.height=oe,ge.getContext("2d").drawImage(dt,0,0,ne,oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+dt.width+"x"+dt.height+") to ("+ne+"x"+oe+")."),ge}else return"data"in dt&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+dt.width+"x"+dt.height+")."),dt;return dt}function f(dt){return dx(dt.width)&&dx(dt.height)}function o(dt){return y?!1:dt.wrapS!==Jr||dt.wrapT!==Jr||dt.minFilter!==nr&&dt.minFilter!==Nn}function c(dt,ut){return dt.generateMipmaps&&ut&&dt.minFilter!==nr&&dt.minFilter!==Nn}function d(dt){g.generateMipmap(dt)}function v(dt,ut,Rt,Dt,Ht=!1){if(y===!1)return ut;if(dt!==null){if(g[dt]!==void 0)return g[dt];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+dt+"'")}let Bt=ut;if(ut===g.RED&&(Rt===g.FLOAT&&(Bt=g.R32F),Rt===g.HALF_FLOAT&&(Bt=g.R16F),Rt===g.UNSIGNED_BYTE&&(Bt=g.R8)),ut===g.RED_INTEGER&&(Rt===g.UNSIGNED_BYTE&&(Bt=g.R8UI),Rt===g.UNSIGNED_SHORT&&(Bt=g.R16UI),Rt===g.UNSIGNED_INT&&(Bt=g.R32UI),Rt===g.BYTE&&(Bt=g.R8I),Rt===g.SHORT&&(Bt=g.R16I),Rt===g.INT&&(Bt=g.R32I)),ut===g.RG&&(Rt===g.FLOAT&&(Bt=g.RG32F),Rt===g.HALF_FLOAT&&(Bt=g.RG16F),Rt===g.UNSIGNED_BYTE&&(Bt=g.RG8)),ut===g.RGBA){const ne=Ht?Rd:rn.getTransfer(Dt);Rt===g.FLOAT&&(Bt=g.RGBA32F),Rt===g.HALF_FLOAT&&(Bt=g.RGBA16F),Rt===g.UNSIGNED_BYTE&&(Bt=ne===vn?g.SRGB8_ALPHA8:g.RGBA8),Rt===g.UNSIGNED_SHORT_4_4_4_4&&(Bt=g.RGBA4),Rt===g.UNSIGNED_SHORT_5_5_5_1&&(Bt=g.RGB5_A1)}return(Bt===g.R16F||Bt===g.R32F||Bt===g.RG16F||Bt===g.RG32F||Bt===g.RGBA16F||Bt===g.RGBA32F)&&t.get("EXT_color_buffer_float"),Bt}function m(dt,ut,Rt){return c(dt,Rt)===!0||dt.isFramebufferTexture&&dt.minFilter!==nr&&dt.minFilter!==Nn?Math.log2(Math.max(ut.width,ut.height))+1:dt.mipmaps!==void 0&&dt.mipmaps.length>0?dt.mipmaps.length:dt.isCompressedTexture&&Array.isArray(dt.image)?ut.mipmaps.length:1}function S(dt){return dt===nr||dt===xm||dt===fu?g.NEAREST:g.LINEAR}function M(dt){const ut=dt.target;ut.removeEventListener("dispose",M),C(ut),ut.isVideoTexture&&p.delete(ut)}function w(dt){const ut=dt.target;ut.removeEventListener("dispose",w),P(ut)}function C(dt){const ut=x.get(dt);if(ut.__webglInit===void 0)return;const Rt=dt.source,Dt=a.get(Rt);if(Dt){const Ht=Dt[ut.__cacheKey];Ht.usedTimes--,Ht.usedTimes===0&&A(dt),Object.keys(Dt).length===0&&a.delete(Rt)}x.remove(dt)}function A(dt){const ut=x.get(dt);g.deleteTexture(ut.__webglTexture);const Rt=dt.source,Dt=a.get(Rt);delete Dt[ut.__cacheKey],s.memory.textures--}function P(dt){const ut=dt.texture,Rt=x.get(dt),Dt=x.get(ut);if(Dt.__webglTexture!==void 0&&(g.deleteTexture(Dt.__webglTexture),s.memory.textures--),dt.depthTexture&&dt.depthTexture.dispose(),dt.isWebGLCubeRenderTarget)for(let Ht=0;Ht<6;Ht++){if(Array.isArray(Rt.__webglFramebuffer[Ht]))for(let Bt=0;Bt=T.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+dt+" texture units while this GPU supports only "+T.maxTextures),b+=1,dt}function D(dt){const ut=[];return ut.push(dt.wrapS),ut.push(dt.wrapT),ut.push(dt.wrapR||0),ut.push(dt.magFilter),ut.push(dt.minFilter),ut.push(dt.anisotropy),ut.push(dt.internalFormat),ut.push(dt.format),ut.push(dt.type),ut.push(dt.generateMipmaps),ut.push(dt.premultiplyAlpha),ut.push(dt.flipY),ut.push(dt.unpackAlignment),ut.push(dt.colorSpace),ut.join()}function B(dt,ut){const Rt=x.get(dt);if(dt.isVideoTexture&&Pt(dt),dt.isRenderTargetTexture===!1&&dt.version>0&&Rt.__version!==dt.version){const Dt=dt.image;if(Dt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Dt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{U(Rt,dt,ut);return}}i.bindTexture(g.TEXTURE_2D,Rt.__webglTexture,g.TEXTURE0+ut)}function G(dt,ut){const Rt=x.get(dt);if(dt.version>0&&Rt.__version!==dt.version){U(Rt,dt,ut);return}i.bindTexture(g.TEXTURE_2D_ARRAY,Rt.__webglTexture,g.TEXTURE0+ut)}function z(dt,ut){const Rt=x.get(dt);if(dt.version>0&&Rt.__version!==dt.version){U(Rt,dt,ut);return}i.bindTexture(g.TEXTURE_3D,Rt.__webglTexture,g.TEXTURE0+ut)}function X(dt,ut){const Rt=x.get(dt);if(dt.version>0&&Rt.__version!==dt.version){H(Rt,dt,ut);return}i.bindTexture(g.TEXTURE_CUBE_MAP,Rt.__webglTexture,g.TEXTURE0+ut)}const K={[Md]:g.REPEAT,[Jr]:g.CLAMP_TO_EDGE,[Cd]:g.MIRRORED_REPEAT},Q={[nr]:g.NEAREST,[xm]:g.NEAREST_MIPMAP_NEAREST,[fu]:g.NEAREST_MIPMAP_LINEAR,[Nn]:g.LINEAR,[ud]:g.LINEAR_MIPMAP_NEAREST,[Io]:g.LINEAR_MIPMAP_LINEAR},tt={[nw]:g.NEVER,[hw]:g.ALWAYS,[rw]:g.LESS,[d1]:g.LEQUAL,[sw]:g.EQUAL,[lw]:g.GEQUAL,[aw]:g.GREATER,[ow]:g.NOTEQUAL};function Y(dt,ut,Rt){if(ut.type===Ea&&t.has("OES_texture_float_linear")===!1&&(ut.magFilter===Nn||ut.magFilter===ud||ut.magFilter===fu||ut.magFilter===Io||ut.minFilter===Nn||ut.minFilter===ud||ut.minFilter===fu||ut.minFilter===Io)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),Rt?(g.texParameteri(dt,g.TEXTURE_WRAP_S,K[ut.wrapS]),g.texParameteri(dt,g.TEXTURE_WRAP_T,K[ut.wrapT]),(dt===g.TEXTURE_3D||dt===g.TEXTURE_2D_ARRAY)&&g.texParameteri(dt,g.TEXTURE_WRAP_R,K[ut.wrapR]),g.texParameteri(dt,g.TEXTURE_MAG_FILTER,Q[ut.magFilter]),g.texParameteri(dt,g.TEXTURE_MIN_FILTER,Q[ut.minFilter])):(g.texParameteri(dt,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),g.texParameteri(dt,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE),(dt===g.TEXTURE_3D||dt===g.TEXTURE_2D_ARRAY)&&g.texParameteri(dt,g.TEXTURE_WRAP_R,g.CLAMP_TO_EDGE),(ut.wrapS!==Jr||ut.wrapT!==Jr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),g.texParameteri(dt,g.TEXTURE_MAG_FILTER,S(ut.magFilter)),g.texParameteri(dt,g.TEXTURE_MIN_FILTER,S(ut.minFilter)),ut.minFilter!==nr&&ut.minFilter!==Nn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),ut.compareFunction&&(g.texParameteri(dt,g.TEXTURE_COMPARE_MODE,g.COMPARE_REF_TO_TEXTURE),g.texParameteri(dt,g.TEXTURE_COMPARE_FUNC,tt[ut.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){const Dt=t.get("EXT_texture_filter_anisotropic");if(ut.magFilter===nr||ut.minFilter!==fu&&ut.minFilter!==Io||ut.type===Ea&&t.has("OES_texture_float_linear")===!1||y===!1&&ut.type===Zf&&t.has("OES_texture_half_float_linear")===!1)return;(ut.anisotropy>1||x.get(ut).__currentAnisotropy)&&(g.texParameterf(dt,Dt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ut.anisotropy,T.getMaxAnisotropy())),x.get(ut).__currentAnisotropy=ut.anisotropy)}}function Z(dt,ut){let Rt=!1;dt.__webglInit===void 0&&(dt.__webglInit=!0,ut.addEventListener("dispose",M));const Dt=ut.source;let Ht=a.get(Dt);Ht===void 0&&(Ht={},a.set(Dt,Ht));const Bt=D(ut);if(Bt!==dt.__cacheKey){Ht[Bt]===void 0&&(Ht[Bt]={texture:g.createTexture(),usedTimes:0},s.memory.textures++,Rt=!0),Ht[Bt].usedTimes++;const ne=Ht[dt.__cacheKey];ne!==void 0&&(Ht[dt.__cacheKey].usedTimes--,ne.usedTimes===0&&A(ut)),dt.__cacheKey=Bt,dt.__webglTexture=Ht[Bt].texture}return Rt}function U(dt,ut,Rt){let Dt=g.TEXTURE_2D;(ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(Dt=g.TEXTURE_2D_ARRAY),ut.isData3DTexture&&(Dt=g.TEXTURE_3D);const Ht=Z(dt,ut),Bt=ut.source;i.bindTexture(Dt,dt.__webglTexture,g.TEXTURE0+Rt);const ne=x.get(Bt);if(Bt.version!==ne.__version||Ht===!0){i.activeTexture(g.TEXTURE0+Rt);const oe=rn.getPrimaries(rn.workingColorSpace),ge=ut.colorSpace===ea?null:rn.getPrimaries(ut.colorSpace),xe=ut.colorSpace===ea||oe===ge?g.NONE:g.BROWSER_DEFAULT_WEBGL;g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,ut.flipY),g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ut.premultiplyAlpha),g.pixelStorei(g.UNPACK_ALIGNMENT,ut.unpackAlignment),g.pixelStorei(g.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);const Ae=o(ut)&&f(ut.image)===!1;let qt=u(ut.image,Ae,!1,T.maxTextureSize);qt=Vt(ut,qt);const Ge=f(qt)||y,Oe=E.convert(ut.format,ut.colorSpace);let Be=E.convert(ut.type),Le=v(ut.internalFormat,Oe,Be,ut.colorSpace,ut.isVideoTexture);Y(Dt,ut,Ge);let ie;const Ke=ut.mipmaps,ri=y&&ut.isVideoTexture!==!0&&Le!==u1,Ti=ne.__version===void 0||Ht===!0,le=Bt.dataReady,xi=m(ut,qt,Ge);if(ut.isDepthTexture)Le=g.DEPTH_COMPONENT,y?ut.type===Ea?Le=g.DEPTH_COMPONENT32F:ut.type===xl?Le=g.DEPTH_COMPONENT24:ut.type===uh?Le=g.DEPTH24_STENCIL8:Le=g.DEPTH_COMPONENT16:ut.type===Ea&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),ut.format===fh&&Le===g.DEPTH_COMPONENT&&ut.type!==sg&&ut.type!==xl&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),ut.type=xl,Be=E.convert(ut.type)),ut.format===Pu&&Le===g.DEPTH_COMPONENT&&(Le=g.DEPTH_STENCIL,ut.type!==uh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),ut.type=uh,Be=E.convert(ut.type))),Ti&&(ri?i.texStorage2D(g.TEXTURE_2D,1,Le,qt.width,qt.height):i.texImage2D(g.TEXTURE_2D,0,Le,qt.width,qt.height,0,Oe,Be,null));else if(ut.isDataTexture)if(Ke.length>0&&Ge){ri&&Ti&&i.texStorage2D(g.TEXTURE_2D,xi,Le,Ke[0].width,Ke[0].height);for(let bt=0,Me=Ke.length;bt>=1,Me>>=1}}else if(Ke.length>0&&Ge){ri&&Ti&&i.texStorage2D(g.TEXTURE_2D,xi,Le,Ke[0].width,Ke[0].height);for(let bt=0,Me=Ke.length;bt0&&le++,i.texStorage2D(g.TEXTURE_CUBE_MAP,le,ie,qt[0].width,qt[0].height));for(let bt=0;bt<6;bt++)if(Ae){Ke?Ti&&i.texSubImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+bt,0,0,0,qt[bt].width,qt[bt].height,Be,Le,qt[bt].data):i.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+bt,0,ie,qt[bt].width,qt[bt].height,0,Be,Le,qt[bt].data);for(let Me=0;Me>Bt),qt=Math.max(1,ut.height>>Bt);Ht===g.TEXTURE_3D||Ht===g.TEXTURE_2D_ARRAY?i.texImage3D(Ht,Bt,ge,Ae,qt,ut.depth,0,ne,oe,null):i.texImage2D(Ht,Bt,ge,Ae,qt,0,ne,oe,null)}i.bindFramebuffer(g.FRAMEBUFFER,dt),At(ut)?e.framebufferTexture2DMultisampleEXT(g.FRAMEBUFFER,Dt,Ht,x.get(Rt).__webglTexture,0,Et(ut)):(Ht===g.TEXTURE_2D||Ht>=g.TEXTURE_CUBE_MAP_POSITIVE_X&&Ht<=g.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&g.framebufferTexture2D(g.FRAMEBUFFER,Dt,Ht,x.get(Rt).__webglTexture,Bt),i.bindFramebuffer(g.FRAMEBUFFER,null)}function _(dt,ut,Rt){if(g.bindRenderbuffer(g.RENDERBUFFER,dt),ut.depthBuffer&&!ut.stencilBuffer){let Dt=y===!0?g.DEPTH_COMPONENT24:g.DEPTH_COMPONENT16;if(Rt||At(ut)){const Ht=ut.depthTexture;Ht&&Ht.isDepthTexture&&(Ht.type===Ea?Dt=g.DEPTH_COMPONENT32F:Ht.type===xl&&(Dt=g.DEPTH_COMPONENT24));const Bt=Et(ut);At(ut)?e.renderbufferStorageMultisampleEXT(g.RENDERBUFFER,Bt,Dt,ut.width,ut.height):g.renderbufferStorageMultisample(g.RENDERBUFFER,Bt,Dt,ut.width,ut.height)}else g.renderbufferStorage(g.RENDERBUFFER,Dt,ut.width,ut.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,dt)}else if(ut.depthBuffer&&ut.stencilBuffer){const Dt=Et(ut);Rt&&At(ut)===!1?g.renderbufferStorageMultisample(g.RENDERBUFFER,Dt,g.DEPTH24_STENCIL8,ut.width,ut.height):At(ut)?e.renderbufferStorageMultisampleEXT(g.RENDERBUFFER,Dt,g.DEPTH24_STENCIL8,ut.width,ut.height):g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_STENCIL,ut.width,ut.height),g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,dt)}else{const Dt=ut.isWebGLMultipleRenderTargets===!0?ut.texture:[ut.texture];for(let Ht=0;Ht0){Rt.__webglFramebuffer[oe]=[];for(let ge=0;ge0){Rt.__webglFramebuffer=[];for(let oe=0;oe0&&At(dt)===!1){const oe=Bt?ut:[ut];Rt.__webglMultisampledFramebuffer=g.createFramebuffer(),Rt.__webglColorRenderbuffer=[],i.bindFramebuffer(g.FRAMEBUFFER,Rt.__webglMultisampledFramebuffer);for(let ge=0;ge0)for(let ge=0;ge0)for(let ge=0;ge0&&At(dt)===!1){const ut=dt.isWebGLMultipleRenderTargets?dt.texture:[dt.texture],Rt=dt.width,Dt=dt.height;let Ht=g.COLOR_BUFFER_BIT;const Bt=[],ne=dt.stencilBuffer?g.DEPTH_STENCIL_ATTACHMENT:g.DEPTH_ATTACHMENT,oe=x.get(dt),ge=dt.isWebGLMultipleRenderTargets===!0;if(ge)for(let xe=0;xe0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&ut.__useRenderToTexture!==!1}function Pt(dt){const ut=s.render.frame;p.get(dt)!==ut&&(p.set(dt,ut),dt.update())}function Vt(dt,ut){const Rt=dt.colorSpace,Dt=dt.format,Ht=dt.type;return dt.isCompressedTexture===!0||dt.isVideoTexture===!0||dt.format===Sm||Rt!==Go&&Rt!==ea&&(rn.getTransfer(Rt)===vn?y===!1?t.has("EXT_sRGB")===!0&&Dt===ps?(dt.format=Sm,dt.minFilter=Nn,dt.generateMipmaps=!1):ut=v1.sRGBToLinear(ut):(Dt!==ps||Ht!==Uo)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Rt)),ut}this.allocateTextureUnit=I,this.resetTextureUnits=O,this.setTexture2D=B,this.setTexture2DArray=G,this.setTexture3D=z,this.setTextureCube=X,this.rebindTextures=ot,this.setupRenderTarget=rt,this.updateRenderTargetMipmap=gt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=at,this.setupFrameBufferTexture=J,this.useMultisampledRTT=At}function Cw(g,t,i){const x=i.isWebGL2;function T(E,s=ea){let y;const e=rn.getTransfer(s);if(E===Uo)return g.UNSIGNED_BYTE;if(E===s1)return g.UNSIGNED_SHORT_4_4_4_4;if(E===a1)return g.UNSIGNED_SHORT_5_5_5_1;if(E===X2)return g.BYTE;if(E===Y2)return g.SHORT;if(E===sg)return g.UNSIGNED_SHORT;if(E===r1)return g.INT;if(E===xl)return g.UNSIGNED_INT;if(E===Ea)return g.FLOAT;if(E===Zf)return x?g.HALF_FLOAT:(y=t.get("OES_texture_half_float"),y!==null?y.HALF_FLOAT_OES:null);if(E===k2)return g.ALPHA;if(E===ps)return g.RGBA;if(E===K2)return g.LUMINANCE;if(E===j2)return g.LUMINANCE_ALPHA;if(E===fh)return g.DEPTH_COMPONENT;if(E===Pu)return g.DEPTH_STENCIL;if(E===Sm)return y=t.get("EXT_sRGB"),y!==null?y.SRGB_ALPHA_EXT:null;if(E===Z2)return g.RED;if(E===o1)return g.RED_INTEGER;if(E===J2)return g.RG;if(E===l1)return g.RG_INTEGER;if(E===h1)return g.RGBA_INTEGER;if(E===em||E===im||E===nm||E===rm)if(e===vn)if(y=t.get("WEBGL_compressed_texture_s3tc_srgb"),y!==null){if(E===em)return y.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(E===im)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(E===nm)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(E===rm)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(y=t.get("WEBGL_compressed_texture_s3tc"),y!==null){if(E===em)return y.COMPRESSED_RGB_S3TC_DXT1_EXT;if(E===im)return y.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(E===nm)return y.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(E===rm)return y.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(E===Vy||E===Hy||E===Wy||E===Xy)if(y=t.get("WEBGL_compressed_texture_pvrtc"),y!==null){if(E===Vy)return y.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(E===Hy)return y.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(E===Wy)return y.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(E===Xy)return y.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(E===u1)return y=t.get("WEBGL_compressed_texture_etc1"),y!==null?y.COMPRESSED_RGB_ETC1_WEBGL:null;if(E===Yy||E===ky)if(y=t.get("WEBGL_compressed_texture_etc"),y!==null){if(E===Yy)return e===vn?y.COMPRESSED_SRGB8_ETC2:y.COMPRESSED_RGB8_ETC2;if(E===ky)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:y.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(E===Ky||E===jy||E===Zy||E===Jy||E===$y||E===Qy||E===_y||E===qy||E===tx||E===ex||E===ix||E===nx||E===rx||E===sx)if(y=t.get("WEBGL_compressed_texture_astc"),y!==null){if(E===Ky)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:y.COMPRESSED_RGBA_ASTC_4x4_KHR;if(E===jy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:y.COMPRESSED_RGBA_ASTC_5x4_KHR;if(E===Zy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:y.COMPRESSED_RGBA_ASTC_5x5_KHR;if(E===Jy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:y.COMPRESSED_RGBA_ASTC_6x5_KHR;if(E===$y)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:y.COMPRESSED_RGBA_ASTC_6x6_KHR;if(E===Qy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:y.COMPRESSED_RGBA_ASTC_8x5_KHR;if(E===_y)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:y.COMPRESSED_RGBA_ASTC_8x6_KHR;if(E===qy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:y.COMPRESSED_RGBA_ASTC_8x8_KHR;if(E===tx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:y.COMPRESSED_RGBA_ASTC_10x5_KHR;if(E===ex)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:y.COMPRESSED_RGBA_ASTC_10x6_KHR;if(E===ix)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:y.COMPRESSED_RGBA_ASTC_10x8_KHR;if(E===nx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:y.COMPRESSED_RGBA_ASTC_10x10_KHR;if(E===rx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:y.COMPRESSED_RGBA_ASTC_12x10_KHR;if(E===sx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:y.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(E===sm||E===ax||E===ox)if(y=t.get("EXT_texture_compression_bptc"),y!==null){if(E===sm)return e===vn?y.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:y.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(E===ax)return y.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(E===ox)return y.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(E===$2||E===lx||E===hx||E===ux)if(y=t.get("EXT_texture_compression_rgtc"),y!==null){if(E===sm)return y.COMPRESSED_RED_RGTC1_EXT;if(E===lx)return y.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(E===hx)return y.COMPRESSED_RED_GREEN_RGTC2_EXT;if(E===ux)return y.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return E===uh?x?g.UNSIGNED_INT_24_8:(y=t.get("WEBGL_depth_texture"),y!==null?y.UNSIGNED_INT_24_8_WEBGL:null):g[E]!==void 0?g[E]:null}return{convert:T}}class ww extends Or{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Gf extends Yi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const G6={type:"move"};class H0{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gf,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 Gf,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ct,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ct),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gf,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ct,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ct),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const i=this._hand;if(i)for(const x of t.hand.values())this._getHandJoint(i,x)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,i,x){let T=null,E=null,s=null;const y=this._targetRay,e=this._grip,r=this._hand;if(t&&i.session.visibilityState!=="visible-blurred"){if(r&&t.hand){s=!0;for(const u of t.hand.values()){const f=i.getJointPose(u,x),o=this._getHandJoint(r,u);f!==null&&(o.matrix.fromArray(f.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,o.jointRadius=f.radius),o.visible=f!==null}const p=r.joints["index-finger-tip"],h=r.joints["thumb-tip"],a=p.position.distanceTo(h.position),l=.02,n=.005;r.inputState.pinching&&a>l+n?(r.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!r.inputState.pinching&&a<=l-n&&(r.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else e!==null&&t.gripSpace&&(E=i.getPose(t.gripSpace,x),E!==null&&(e.matrix.fromArray(E.transform.matrix),e.matrix.decompose(e.position,e.rotation,e.scale),e.matrixWorldNeedsUpdate=!0,E.linearVelocity?(e.hasLinearVelocity=!0,e.linearVelocity.copy(E.linearVelocity)):e.hasLinearVelocity=!1,E.angularVelocity?(e.hasAngularVelocity=!0,e.angularVelocity.copy(E.angularVelocity)):e.hasAngularVelocity=!1));y!==null&&(T=i.getPose(t.targetRaySpace,x),T===null&&E!==null&&(T=E),T!==null&&(y.matrix.fromArray(T.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,T.linearVelocity?(y.hasLinearVelocity=!0,y.linearVelocity.copy(T.linearVelocity)):y.hasLinearVelocity=!1,T.angularVelocity?(y.hasAngularVelocity=!0,y.angularVelocity.copy(T.angularVelocity)):y.hasAngularVelocity=!1,this.dispatchEvent(G6)))}return y!==null&&(y.visible=T!==null),e!==null&&(e.visible=E!==null),r!==null&&(r.visible=s!==null),this}_getHandJoint(t,i){if(t.joints[i.jointName]===void 0){const x=new Gf;x.matrixAutoUpdate=!1,x.visible=!1,t.joints[i.jointName]=x,t.add(x)}return t.joints[i.jointName]}}const V6=` +}`;function B6(g,t,i){let x=new _d;const T=new ve,E=new ve,s=new sn,y=new T1({depthPacking:ew}),e=new E1,r={},p=i.maxTextureSize,h={[Cl]:ms,[ms]:Cl,[Oo]:Oo},a=new no({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ve},radius:{value:4}},vertexShader:I6,fragmentShader:N6}),l=a.clone();l.defines.HORIZONTAL_PASS=1;const n=new Li;n.setAttribute("position",new an(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const u=new cr(n,a),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=rg;let o=this.type;this.render=function(S,M,w){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||S.length===0)return;const C=g.getRenderTarget(),A=g.getActiveCubeFace(),P=g.getActiveMipmapLevel(),b=g.state;b.setBlending(Ml),b.buffers.color.setClear(1,1,1,1),b.buffers.depth.setTest(!0),b.setScissorTest(!1);const O=o!==_a&&this.type===_a,I=o===_a&&this.type!==_a;for(let D=0,B=S.length;Dp||T.y>p)&&(T.x>p&&(E.x=Math.floor(p/X.x),T.x=E.x*X.x,z.mapSize.x=E.x),T.y>p&&(E.y=Math.floor(p/X.y),T.y=E.y*X.y,z.mapSize.y=E.y)),z.map===null||O===!0||I===!0){const Q=this.type!==_a?{minFilter:nr,magFilter:nr}:{};z.map!==null&&z.map.dispose(),z.map=new io(T.x,T.y,Q),z.map.texture.name=G.name+".shadowMap",z.camera.updateProjectionMatrix()}g.setRenderTarget(z.map),g.clear();const K=z.getViewportCount();for(let Q=0;Q0||M.map&&M.alphaTest>0){const b=A.uuid,O=M.uuid;let I=r[b];I===void 0&&(I={},r[b]=I);let D=I[O];D===void 0&&(D=A.clone(),I[O]=D,M.addEventListener("dispose",m)),A=D}if(A.visible=M.visible,A.wireframe=M.wireframe,C===_a?A.side=M.shadowSide!==null?M.shadowSide:M.side:A.side=M.shadowSide!==null?M.shadowSide:h[M.side],A.alphaMap=M.alphaMap,A.alphaTest=M.alphaTest,A.map=M.map,A.clipShadows=M.clipShadows,A.clippingPlanes=M.clippingPlanes,A.clipIntersection=M.clipIntersection,A.displacementMap=M.displacementMap,A.displacementScale=M.displacementScale,A.displacementBias=M.displacementBias,A.wireframeLinewidth=M.wireframeLinewidth,A.linewidth=M.linewidth,w.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const b=g.properties.get(A);b.light=w}return A}function v(S,M,w,C,A){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&A===_a)&&(!S.frustumCulled||x.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,S.matrixWorld);const O=t.update(S),I=S.material;if(Array.isArray(I)){const D=O.groups;for(let B=0,G=D.length;B=1):K.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),z=X>=2);let Q=null,tt={};const Y=g.getParameter(g.SCISSOR_BOX),Z=g.getParameter(g.VIEWPORT),U=new sn().fromArray(Y),H=new sn().fromArray(Z);function J(bt,Me,Ce,Ve){const Je=new Uint8Array(4),zi=g.createTexture();g.bindTexture(bt,zi),g.texParameteri(bt,g.TEXTURE_MIN_FILTER,g.NEAREST),g.texParameteri(bt,g.TEXTURE_MAG_FILTER,g.NEAREST);for(let Di=0;Di"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap;let h;const a=new WeakMap;let l=!1;try{l=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function n(dt,ut){return l?new OffscreenCanvas(dt,ut):Dd("canvas")}function u(dt,ut,Rt,Dt){let Ht=1;if((dt.width>Dt||dt.height>Dt)&&(Ht=Dt/Math.max(dt.width,dt.height)),Ht<1||ut===!0)if(typeof HTMLImageElement<"u"&&dt instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&dt instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&dt instanceof ImageBitmap){const Bt=ut?Em:Math.floor,ne=Bt(Ht*dt.width),oe=Bt(Ht*dt.height);h===void 0&&(h=n(ne,oe));const ge=Rt?n(ne,oe):h;return ge.width=ne,ge.height=oe,ge.getContext("2d").drawImage(dt,0,0,ne,oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+dt.width+"x"+dt.height+") to ("+ne+"x"+oe+")."),ge}else return"data"in dt&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+dt.width+"x"+dt.height+")."),dt;return dt}function f(dt){return px(dt.width)&&px(dt.height)}function o(dt){return y?!1:dt.wrapS!==Jr||dt.wrapT!==Jr||dt.minFilter!==nr&&dt.minFilter!==Nn}function c(dt,ut){return dt.generateMipmaps&&ut&&dt.minFilter!==nr&&dt.minFilter!==Nn}function d(dt){g.generateMipmap(dt)}function v(dt,ut,Rt,Dt,Ht=!1){if(y===!1)return ut;if(dt!==null){if(g[dt]!==void 0)return g[dt];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+dt+"'")}let Bt=ut;if(ut===g.RED&&(Rt===g.FLOAT&&(Bt=g.R32F),Rt===g.HALF_FLOAT&&(Bt=g.R16F),Rt===g.UNSIGNED_BYTE&&(Bt=g.R8)),ut===g.RED_INTEGER&&(Rt===g.UNSIGNED_BYTE&&(Bt=g.R8UI),Rt===g.UNSIGNED_SHORT&&(Bt=g.R16UI),Rt===g.UNSIGNED_INT&&(Bt=g.R32UI),Rt===g.BYTE&&(Bt=g.R8I),Rt===g.SHORT&&(Bt=g.R16I),Rt===g.INT&&(Bt=g.R32I)),ut===g.RG&&(Rt===g.FLOAT&&(Bt=g.RG32F),Rt===g.HALF_FLOAT&&(Bt=g.RG16F),Rt===g.UNSIGNED_BYTE&&(Bt=g.RG8)),ut===g.RGBA){const ne=Ht?Rd:rn.getTransfer(Dt);Rt===g.FLOAT&&(Bt=g.RGBA32F),Rt===g.HALF_FLOAT&&(Bt=g.RGBA16F),Rt===g.UNSIGNED_BYTE&&(Bt=ne===vn?g.SRGB8_ALPHA8:g.RGBA8),Rt===g.UNSIGNED_SHORT_4_4_4_4&&(Bt=g.RGBA4),Rt===g.UNSIGNED_SHORT_5_5_5_1&&(Bt=g.RGB5_A1)}return(Bt===g.R16F||Bt===g.R32F||Bt===g.RG16F||Bt===g.RG32F||Bt===g.RGBA16F||Bt===g.RGBA32F)&&t.get("EXT_color_buffer_float"),Bt}function m(dt,ut,Rt){return c(dt,Rt)===!0||dt.isFramebufferTexture&&dt.minFilter!==nr&&dt.minFilter!==Nn?Math.log2(Math.max(ut.width,ut.height))+1:dt.mipmaps!==void 0&&dt.mipmaps.length>0?dt.mipmaps.length:dt.isCompressedTexture&&Array.isArray(dt.image)?ut.mipmaps.length:1}function S(dt){return dt===nr||dt===Sm||dt===fu?g.NEAREST:g.LINEAR}function M(dt){const ut=dt.target;ut.removeEventListener("dispose",M),C(ut),ut.isVideoTexture&&p.delete(ut)}function w(dt){const ut=dt.target;ut.removeEventListener("dispose",w),P(ut)}function C(dt){const ut=x.get(dt);if(ut.__webglInit===void 0)return;const Rt=dt.source,Dt=a.get(Rt);if(Dt){const Ht=Dt[ut.__cacheKey];Ht.usedTimes--,Ht.usedTimes===0&&A(dt),Object.keys(Dt).length===0&&a.delete(Rt)}x.remove(dt)}function A(dt){const ut=x.get(dt);g.deleteTexture(ut.__webglTexture);const Rt=dt.source,Dt=a.get(Rt);delete Dt[ut.__cacheKey],s.memory.textures--}function P(dt){const ut=dt.texture,Rt=x.get(dt),Dt=x.get(ut);if(Dt.__webglTexture!==void 0&&(g.deleteTexture(Dt.__webglTexture),s.memory.textures--),dt.depthTexture&&dt.depthTexture.dispose(),dt.isWebGLCubeRenderTarget)for(let Ht=0;Ht<6;Ht++){if(Array.isArray(Rt.__webglFramebuffer[Ht]))for(let Bt=0;Bt=T.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+dt+" texture units while this GPU supports only "+T.maxTextures),b+=1,dt}function D(dt){const ut=[];return ut.push(dt.wrapS),ut.push(dt.wrapT),ut.push(dt.wrapR||0),ut.push(dt.magFilter),ut.push(dt.minFilter),ut.push(dt.anisotropy),ut.push(dt.internalFormat),ut.push(dt.format),ut.push(dt.type),ut.push(dt.generateMipmaps),ut.push(dt.premultiplyAlpha),ut.push(dt.flipY),ut.push(dt.unpackAlignment),ut.push(dt.colorSpace),ut.join()}function B(dt,ut){const Rt=x.get(dt);if(dt.isVideoTexture&&Pt(dt),dt.isRenderTargetTexture===!1&&dt.version>0&&Rt.__version!==dt.version){const Dt=dt.image;if(Dt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Dt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{U(Rt,dt,ut);return}}i.bindTexture(g.TEXTURE_2D,Rt.__webglTexture,g.TEXTURE0+ut)}function G(dt,ut){const Rt=x.get(dt);if(dt.version>0&&Rt.__version!==dt.version){U(Rt,dt,ut);return}i.bindTexture(g.TEXTURE_2D_ARRAY,Rt.__webglTexture,g.TEXTURE0+ut)}function z(dt,ut){const Rt=x.get(dt);if(dt.version>0&&Rt.__version!==dt.version){U(Rt,dt,ut);return}i.bindTexture(g.TEXTURE_3D,Rt.__webglTexture,g.TEXTURE0+ut)}function X(dt,ut){const Rt=x.get(dt);if(dt.version>0&&Rt.__version!==dt.version){H(Rt,dt,ut);return}i.bindTexture(g.TEXTURE_CUBE_MAP,Rt.__webglTexture,g.TEXTURE0+ut)}const K={[Md]:g.REPEAT,[Jr]:g.CLAMP_TO_EDGE,[Cd]:g.MIRRORED_REPEAT},Q={[nr]:g.NEAREST,[Sm]:g.NEAREST_MIPMAP_NEAREST,[fu]:g.NEAREST_MIPMAP_LINEAR,[Nn]:g.LINEAR,[ud]:g.LINEAR_MIPMAP_NEAREST,[Io]:g.LINEAR_MIPMAP_LINEAR},tt={[nw]:g.NEVER,[hw]:g.ALWAYS,[rw]:g.LESS,[d1]:g.LEQUAL,[sw]:g.EQUAL,[lw]:g.GEQUAL,[aw]:g.GREATER,[ow]:g.NOTEQUAL};function Y(dt,ut,Rt){if(ut.type===Ea&&t.has("OES_texture_float_linear")===!1&&(ut.magFilter===Nn||ut.magFilter===ud||ut.magFilter===fu||ut.magFilter===Io||ut.minFilter===Nn||ut.minFilter===ud||ut.minFilter===fu||ut.minFilter===Io)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),Rt?(g.texParameteri(dt,g.TEXTURE_WRAP_S,K[ut.wrapS]),g.texParameteri(dt,g.TEXTURE_WRAP_T,K[ut.wrapT]),(dt===g.TEXTURE_3D||dt===g.TEXTURE_2D_ARRAY)&&g.texParameteri(dt,g.TEXTURE_WRAP_R,K[ut.wrapR]),g.texParameteri(dt,g.TEXTURE_MAG_FILTER,Q[ut.magFilter]),g.texParameteri(dt,g.TEXTURE_MIN_FILTER,Q[ut.minFilter])):(g.texParameteri(dt,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),g.texParameteri(dt,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE),(dt===g.TEXTURE_3D||dt===g.TEXTURE_2D_ARRAY)&&g.texParameteri(dt,g.TEXTURE_WRAP_R,g.CLAMP_TO_EDGE),(ut.wrapS!==Jr||ut.wrapT!==Jr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),g.texParameteri(dt,g.TEXTURE_MAG_FILTER,S(ut.magFilter)),g.texParameteri(dt,g.TEXTURE_MIN_FILTER,S(ut.minFilter)),ut.minFilter!==nr&&ut.minFilter!==Nn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),ut.compareFunction&&(g.texParameteri(dt,g.TEXTURE_COMPARE_MODE,g.COMPARE_REF_TO_TEXTURE),g.texParameteri(dt,g.TEXTURE_COMPARE_FUNC,tt[ut.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){const Dt=t.get("EXT_texture_filter_anisotropic");if(ut.magFilter===nr||ut.minFilter!==fu&&ut.minFilter!==Io||ut.type===Ea&&t.has("OES_texture_float_linear")===!1||y===!1&&ut.type===Zf&&t.has("OES_texture_half_float_linear")===!1)return;(ut.anisotropy>1||x.get(ut).__currentAnisotropy)&&(g.texParameterf(dt,Dt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ut.anisotropy,T.getMaxAnisotropy())),x.get(ut).__currentAnisotropy=ut.anisotropy)}}function Z(dt,ut){let Rt=!1;dt.__webglInit===void 0&&(dt.__webglInit=!0,ut.addEventListener("dispose",M));const Dt=ut.source;let Ht=a.get(Dt);Ht===void 0&&(Ht={},a.set(Dt,Ht));const Bt=D(ut);if(Bt!==dt.__cacheKey){Ht[Bt]===void 0&&(Ht[Bt]={texture:g.createTexture(),usedTimes:0},s.memory.textures++,Rt=!0),Ht[Bt].usedTimes++;const ne=Ht[dt.__cacheKey];ne!==void 0&&(Ht[dt.__cacheKey].usedTimes--,ne.usedTimes===0&&A(ut)),dt.__cacheKey=Bt,dt.__webglTexture=Ht[Bt].texture}return Rt}function U(dt,ut,Rt){let Dt=g.TEXTURE_2D;(ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(Dt=g.TEXTURE_2D_ARRAY),ut.isData3DTexture&&(Dt=g.TEXTURE_3D);const Ht=Z(dt,ut),Bt=ut.source;i.bindTexture(Dt,dt.__webglTexture,g.TEXTURE0+Rt);const ne=x.get(Bt);if(Bt.version!==ne.__version||Ht===!0){i.activeTexture(g.TEXTURE0+Rt);const oe=rn.getPrimaries(rn.workingColorSpace),ge=ut.colorSpace===ea?null:rn.getPrimaries(ut.colorSpace),xe=ut.colorSpace===ea||oe===ge?g.NONE:g.BROWSER_DEFAULT_WEBGL;g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,ut.flipY),g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ut.premultiplyAlpha),g.pixelStorei(g.UNPACK_ALIGNMENT,ut.unpackAlignment),g.pixelStorei(g.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);const Ae=o(ut)&&f(ut.image)===!1;let qt=u(ut.image,Ae,!1,T.maxTextureSize);qt=Vt(ut,qt);const Ge=f(qt)||y,Oe=E.convert(ut.format,ut.colorSpace);let Be=E.convert(ut.type),Le=v(ut.internalFormat,Oe,Be,ut.colorSpace,ut.isVideoTexture);Y(Dt,ut,Ge);let ie;const Ke=ut.mipmaps,ri=y&&ut.isVideoTexture!==!0&&Le!==u1,Ti=ne.__version===void 0||Ht===!0,le=Bt.dataReady,xi=m(ut,qt,Ge);if(ut.isDepthTexture)Le=g.DEPTH_COMPONENT,y?ut.type===Ea?Le=g.DEPTH_COMPONENT32F:ut.type===xl?Le=g.DEPTH_COMPONENT24:ut.type===uh?Le=g.DEPTH24_STENCIL8:Le=g.DEPTH_COMPONENT16:ut.type===Ea&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),ut.format===fh&&Le===g.DEPTH_COMPONENT&&ut.type!==ag&&ut.type!==xl&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),ut.type=xl,Be=E.convert(ut.type)),ut.format===Pu&&Le===g.DEPTH_COMPONENT&&(Le=g.DEPTH_STENCIL,ut.type!==uh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),ut.type=uh,Be=E.convert(ut.type))),Ti&&(ri?i.texStorage2D(g.TEXTURE_2D,1,Le,qt.width,qt.height):i.texImage2D(g.TEXTURE_2D,0,Le,qt.width,qt.height,0,Oe,Be,null));else if(ut.isDataTexture)if(Ke.length>0&&Ge){ri&&Ti&&i.texStorage2D(g.TEXTURE_2D,xi,Le,Ke[0].width,Ke[0].height);for(let bt=0,Me=Ke.length;bt>=1,Me>>=1}}else if(Ke.length>0&&Ge){ri&&Ti&&i.texStorage2D(g.TEXTURE_2D,xi,Le,Ke[0].width,Ke[0].height);for(let bt=0,Me=Ke.length;bt0&&le++,i.texStorage2D(g.TEXTURE_CUBE_MAP,le,ie,qt[0].width,qt[0].height));for(let bt=0;bt<6;bt++)if(Ae){Ke?Ti&&i.texSubImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+bt,0,0,0,qt[bt].width,qt[bt].height,Be,Le,qt[bt].data):i.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+bt,0,ie,qt[bt].width,qt[bt].height,0,Be,Le,qt[bt].data);for(let Me=0;Me>Bt),qt=Math.max(1,ut.height>>Bt);Ht===g.TEXTURE_3D||Ht===g.TEXTURE_2D_ARRAY?i.texImage3D(Ht,Bt,ge,Ae,qt,ut.depth,0,ne,oe,null):i.texImage2D(Ht,Bt,ge,Ae,qt,0,ne,oe,null)}i.bindFramebuffer(g.FRAMEBUFFER,dt),At(ut)?e.framebufferTexture2DMultisampleEXT(g.FRAMEBUFFER,Dt,Ht,x.get(Rt).__webglTexture,0,Et(ut)):(Ht===g.TEXTURE_2D||Ht>=g.TEXTURE_CUBE_MAP_POSITIVE_X&&Ht<=g.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&g.framebufferTexture2D(g.FRAMEBUFFER,Dt,Ht,x.get(Rt).__webglTexture,Bt),i.bindFramebuffer(g.FRAMEBUFFER,null)}function _(dt,ut,Rt){if(g.bindRenderbuffer(g.RENDERBUFFER,dt),ut.depthBuffer&&!ut.stencilBuffer){let Dt=y===!0?g.DEPTH_COMPONENT24:g.DEPTH_COMPONENT16;if(Rt||At(ut)){const Ht=ut.depthTexture;Ht&&Ht.isDepthTexture&&(Ht.type===Ea?Dt=g.DEPTH_COMPONENT32F:Ht.type===xl&&(Dt=g.DEPTH_COMPONENT24));const Bt=Et(ut);At(ut)?e.renderbufferStorageMultisampleEXT(g.RENDERBUFFER,Bt,Dt,ut.width,ut.height):g.renderbufferStorageMultisample(g.RENDERBUFFER,Bt,Dt,ut.width,ut.height)}else g.renderbufferStorage(g.RENDERBUFFER,Dt,ut.width,ut.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,dt)}else if(ut.depthBuffer&&ut.stencilBuffer){const Dt=Et(ut);Rt&&At(ut)===!1?g.renderbufferStorageMultisample(g.RENDERBUFFER,Dt,g.DEPTH24_STENCIL8,ut.width,ut.height):At(ut)?e.renderbufferStorageMultisampleEXT(g.RENDERBUFFER,Dt,g.DEPTH24_STENCIL8,ut.width,ut.height):g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_STENCIL,ut.width,ut.height),g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,dt)}else{const Dt=ut.isWebGLMultipleRenderTargets===!0?ut.texture:[ut.texture];for(let Ht=0;Ht0){Rt.__webglFramebuffer[oe]=[];for(let ge=0;ge0){Rt.__webglFramebuffer=[];for(let oe=0;oe0&&At(dt)===!1){const oe=Bt?ut:[ut];Rt.__webglMultisampledFramebuffer=g.createFramebuffer(),Rt.__webglColorRenderbuffer=[],i.bindFramebuffer(g.FRAMEBUFFER,Rt.__webglMultisampledFramebuffer);for(let ge=0;ge0)for(let ge=0;ge0)for(let ge=0;ge0&&At(dt)===!1){const ut=dt.isWebGLMultipleRenderTargets?dt.texture:[dt.texture],Rt=dt.width,Dt=dt.height;let Ht=g.COLOR_BUFFER_BIT;const Bt=[],ne=dt.stencilBuffer?g.DEPTH_STENCIL_ATTACHMENT:g.DEPTH_ATTACHMENT,oe=x.get(dt),ge=dt.isWebGLMultipleRenderTargets===!0;if(ge)for(let xe=0;xe0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&ut.__useRenderToTexture!==!1}function Pt(dt){const ut=s.render.frame;p.get(dt)!==ut&&(p.set(dt,ut),dt.update())}function Vt(dt,ut){const Rt=dt.colorSpace,Dt=dt.format,Ht=dt.type;return dt.isCompressedTexture===!0||dt.isVideoTexture===!0||dt.format===Tm||Rt!==Go&&Rt!==ea&&(rn.getTransfer(Rt)===vn?y===!1?t.has("EXT_sRGB")===!0&&Dt===ps?(dt.format=Tm,dt.minFilter=Nn,dt.generateMipmaps=!1):ut=v1.sRGBToLinear(ut):(Dt!==ps||Ht!==Uo)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Rt)),ut}this.allocateTextureUnit=I,this.resetTextureUnits=O,this.setTexture2D=B,this.setTexture2DArray=G,this.setTexture3D=z,this.setTextureCube=X,this.rebindTextures=ot,this.setupRenderTarget=rt,this.updateRenderTargetMipmap=gt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=at,this.setupFrameBufferTexture=J,this.useMultisampledRTT=At}function Cw(g,t,i){const x=i.isWebGL2;function T(E,s=ea){let y;const e=rn.getTransfer(s);if(E===Uo)return g.UNSIGNED_BYTE;if(E===s1)return g.UNSIGNED_SHORT_4_4_4_4;if(E===a1)return g.UNSIGNED_SHORT_5_5_5_1;if(E===X2)return g.BYTE;if(E===Y2)return g.SHORT;if(E===ag)return g.UNSIGNED_SHORT;if(E===r1)return g.INT;if(E===xl)return g.UNSIGNED_INT;if(E===Ea)return g.FLOAT;if(E===Zf)return x?g.HALF_FLOAT:(y=t.get("OES_texture_half_float"),y!==null?y.HALF_FLOAT_OES:null);if(E===k2)return g.ALPHA;if(E===ps)return g.RGBA;if(E===K2)return g.LUMINANCE;if(E===j2)return g.LUMINANCE_ALPHA;if(E===fh)return g.DEPTH_COMPONENT;if(E===Pu)return g.DEPTH_STENCIL;if(E===Tm)return y=t.get("EXT_sRGB"),y!==null?y.SRGB_ALPHA_EXT:null;if(E===Z2)return g.RED;if(E===o1)return g.RED_INTEGER;if(E===J2)return g.RG;if(E===l1)return g.RG_INTEGER;if(E===h1)return g.RGBA_INTEGER;if(E===em||E===im||E===nm||E===rm)if(e===vn)if(y=t.get("WEBGL_compressed_texture_s3tc_srgb"),y!==null){if(E===em)return y.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(E===im)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(E===nm)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(E===rm)return y.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(y=t.get("WEBGL_compressed_texture_s3tc"),y!==null){if(E===em)return y.COMPRESSED_RGB_S3TC_DXT1_EXT;if(E===im)return y.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(E===nm)return y.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(E===rm)return y.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(E===Hy||E===Wy||E===Xy||E===Yy)if(y=t.get("WEBGL_compressed_texture_pvrtc"),y!==null){if(E===Hy)return y.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(E===Wy)return y.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(E===Xy)return y.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(E===Yy)return y.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(E===u1)return y=t.get("WEBGL_compressed_texture_etc1"),y!==null?y.COMPRESSED_RGB_ETC1_WEBGL:null;if(E===ky||E===Ky)if(y=t.get("WEBGL_compressed_texture_etc"),y!==null){if(E===ky)return e===vn?y.COMPRESSED_SRGB8_ETC2:y.COMPRESSED_RGB8_ETC2;if(E===Ky)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:y.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(E===jy||E===Zy||E===Jy||E===$y||E===Qy||E===_y||E===qy||E===tx||E===ex||E===ix||E===nx||E===rx||E===sx||E===ax)if(y=t.get("WEBGL_compressed_texture_astc"),y!==null){if(E===jy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:y.COMPRESSED_RGBA_ASTC_4x4_KHR;if(E===Zy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:y.COMPRESSED_RGBA_ASTC_5x4_KHR;if(E===Jy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:y.COMPRESSED_RGBA_ASTC_5x5_KHR;if(E===$y)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:y.COMPRESSED_RGBA_ASTC_6x5_KHR;if(E===Qy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:y.COMPRESSED_RGBA_ASTC_6x6_KHR;if(E===_y)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:y.COMPRESSED_RGBA_ASTC_8x5_KHR;if(E===qy)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:y.COMPRESSED_RGBA_ASTC_8x6_KHR;if(E===tx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:y.COMPRESSED_RGBA_ASTC_8x8_KHR;if(E===ex)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:y.COMPRESSED_RGBA_ASTC_10x5_KHR;if(E===ix)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:y.COMPRESSED_RGBA_ASTC_10x6_KHR;if(E===nx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:y.COMPRESSED_RGBA_ASTC_10x8_KHR;if(E===rx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:y.COMPRESSED_RGBA_ASTC_10x10_KHR;if(E===sx)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:y.COMPRESSED_RGBA_ASTC_12x10_KHR;if(E===ax)return e===vn?y.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:y.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(E===sm||E===ox||E===lx)if(y=t.get("EXT_texture_compression_bptc"),y!==null){if(E===sm)return e===vn?y.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:y.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(E===ox)return y.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(E===lx)return y.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(E===$2||E===hx||E===ux||E===fx)if(y=t.get("EXT_texture_compression_rgtc"),y!==null){if(E===sm)return y.COMPRESSED_RED_RGTC1_EXT;if(E===hx)return y.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(E===ux)return y.COMPRESSED_RED_GREEN_RGTC2_EXT;if(E===fx)return y.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return E===uh?x?g.UNSIGNED_INT_24_8:(y=t.get("WEBGL_depth_texture"),y!==null?y.UNSIGNED_INT_24_8_WEBGL:null):g[E]!==void 0?g[E]:null}return{convert:T}}class ww extends Or{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Gf extends Yi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const G6={type:"move"};class W0{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gf,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 Gf,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ct,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ct),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gf,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ct,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ct),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const i=this._hand;if(i)for(const x of t.hand.values())this._getHandJoint(i,x)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,i,x){let T=null,E=null,s=null;const y=this._targetRay,e=this._grip,r=this._hand;if(t&&i.session.visibilityState!=="visible-blurred"){if(r&&t.hand){s=!0;for(const u of t.hand.values()){const f=i.getJointPose(u,x),o=this._getHandJoint(r,u);f!==null&&(o.matrix.fromArray(f.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,o.jointRadius=f.radius),o.visible=f!==null}const p=r.joints["index-finger-tip"],h=r.joints["thumb-tip"],a=p.position.distanceTo(h.position),l=.02,n=.005;r.inputState.pinching&&a>l+n?(r.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!r.inputState.pinching&&a<=l-n&&(r.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else e!==null&&t.gripSpace&&(E=i.getPose(t.gripSpace,x),E!==null&&(e.matrix.fromArray(E.transform.matrix),e.matrix.decompose(e.position,e.rotation,e.scale),e.matrixWorldNeedsUpdate=!0,E.linearVelocity?(e.hasLinearVelocity=!0,e.linearVelocity.copy(E.linearVelocity)):e.hasLinearVelocity=!1,E.angularVelocity?(e.hasAngularVelocity=!0,e.angularVelocity.copy(E.angularVelocity)):e.hasAngularVelocity=!1));y!==null&&(T=i.getPose(t.targetRaySpace,x),T===null&&E!==null&&(T=E),T!==null&&(y.matrix.fromArray(T.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,T.linearVelocity?(y.hasLinearVelocity=!0,y.linearVelocity.copy(T.linearVelocity)):y.hasLinearVelocity=!1,T.angularVelocity?(y.hasAngularVelocity=!0,y.angularVelocity.copy(T.angularVelocity)):y.hasAngularVelocity=!1,this.dispatchEvent(G6)))}return y!==null&&(y.visible=T!==null),e!==null&&(e.visible=E!==null),r!==null&&(r.visible=s!==null),this}_getHandJoint(t,i){if(t.joints[i.jointName]===void 0){const x=new Gf;x.matrixAutoUpdate=!1,x.visible=!1,t.joints[i.jointName]=x,t.add(x)}return t.joints[i.jointName]}}const V6=` void main() { gl_Position = vec4( position, 1.0 ); @@ -10164,7 +10164,7 @@ void main() { } -}`;class W6{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,i,x){if(this.texture===null){const T=new Un,E=t.properties.get(T);E.__webglTexture=i.texture,(i.depthNear!=x.depthNear||i.depthFar!=x.depthFar)&&(this.depthNear=i.depthNear,this.depthFar=i.depthFar),this.texture=T}}render(t,i){if(this.texture!==null){if(this.mesh===null){const x=i.cameras[0].viewport,T=new no({extensions:{fragDepth:!0},vertexShader:V6,fragmentShader:H6,uniforms:{depthColor:{value:this.texture},depthWidth:{value:x.z},depthHeight:{value:x.w}}});this.mesh=new cr(new nc(20,20),T)}t.render(this.mesh,i)}}reset(){this.texture=null,this.mesh=null}}class X6 extends Pl{constructor(t,i){super();const x=this;let T=null,E=1,s=null,y="local-floor",e=1,r=null,p=null,h=null,a=null,l=null,n=null;const u=new W6,f=i.getContextAttributes();let o=null,c=null;const d=[],v=[],m=new ve;let S=null;const M=new Or;M.layers.enable(1),M.viewport=new sn;const w=new Or;w.layers.enable(2),w.viewport=new sn;const C=[M,w],A=new ww;A.layers.enable(1),A.layers.enable(2);let P=null,b=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let U=d[Z];return U===void 0&&(U=new H0,d[Z]=U),U.getTargetRaySpace()},this.getControllerGrip=function(Z){let U=d[Z];return U===void 0&&(U=new H0,d[Z]=U),U.getGripSpace()},this.getHand=function(Z){let U=d[Z];return U===void 0&&(U=new H0,d[Z]=U),U.getHandSpace()};function O(Z){const U=v.indexOf(Z.inputSource);if(U===-1)return;const H=d[U];H!==void 0&&(H.update(Z.inputSource,Z.frame,r||s),H.dispatchEvent({type:Z.type,data:Z.inputSource}))}function I(){T.removeEventListener("select",O),T.removeEventListener("selectstart",O),T.removeEventListener("selectend",O),T.removeEventListener("squeeze",O),T.removeEventListener("squeezestart",O),T.removeEventListener("squeezeend",O),T.removeEventListener("end",I),T.removeEventListener("inputsourceschange",D);for(let Z=0;Z=0&&(v[J]=null,d[J].disconnect(H))}for(let U=0;U=v.length){v.push(H),J=q;break}else if(v[q]===null){v[q]=H,J=q;break}if(J===-1)break}const _=d[J];_&&_.connect(H)}}const B=new Ct,G=new Ct;function z(Z,U,H){B.setFromMatrixPosition(U.matrixWorld),G.setFromMatrixPosition(H.matrixWorld);const J=B.distanceTo(G),_=U.projectionMatrix.elements,q=H.projectionMatrix.elements,at=_[14]/(_[10]-1),ot=_[14]/(_[10]+1),rt=(_[9]+1)/_[5],gt=(_[9]-1)/_[5],yt=(_[8]-1)/_[0],Et=(q[8]+1)/q[0],At=at*yt,Pt=at*Et,Vt=J/(-yt+Et),dt=Vt*-yt;U.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(dt),Z.translateZ(Vt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const ut=at+Vt,Rt=ot+Vt,Dt=At-dt,Ht=Pt+(J-dt),Bt=rt*ot/Rt*ut,ne=gt*ot/Rt*ut;Z.projectionMatrix.makePerspective(Dt,Ht,Bt,ne,ut,Rt),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function X(Z,U){U===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(U.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(T===null)return;u.texture!==null&&(Z.near=u.depthNear,Z.far=u.depthFar),A.near=w.near=M.near=Z.near,A.far=w.far=M.far=Z.far,(P!==A.near||b!==A.far)&&(T.updateRenderState({depthNear:A.near,depthFar:A.far}),P=A.near,b=A.far,M.near=P,M.far=b,w.near=P,w.far=b,M.updateProjectionMatrix(),w.updateProjectionMatrix(),Z.updateProjectionMatrix());const U=Z.parent,H=A.cameras;X(A,U);for(let J=0;J0&&(f.alphaTest.value=o.alphaTest);const c=t.get(o).envMap;if(c&&(f.envMap.value=c,f.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=o.reflectivity,f.ior.value=o.ior,f.refractionRatio.value=o.refractionRatio),o.lightMap){f.lightMap.value=o.lightMap;const d=g._useLegacyLights===!0?Math.PI:1;f.lightMapIntensity.value=o.lightMapIntensity*d,i(o.lightMap,f.lightMapTransform)}o.aoMap&&(f.aoMap.value=o.aoMap,f.aoMapIntensity.value=o.aoMapIntensity,i(o.aoMap,f.aoMapTransform))}function s(f,o){f.diffuse.value.copy(o.color),f.opacity.value=o.opacity,o.map&&(f.map.value=o.map,i(o.map,f.mapTransform))}function y(f,o){f.dashSize.value=o.dashSize,f.totalSize.value=o.dashSize+o.gapSize,f.scale.value=o.scale}function e(f,o,c,d){f.diffuse.value.copy(o.color),f.opacity.value=o.opacity,f.size.value=o.size*c,f.scale.value=d*.5,o.map&&(f.map.value=o.map,i(o.map,f.uvTransform)),o.alphaMap&&(f.alphaMap.value=o.alphaMap,i(o.alphaMap,f.alphaMapTransform)),o.alphaTest>0&&(f.alphaTest.value=o.alphaTest)}function r(f,o){f.diffuse.value.copy(o.color),f.opacity.value=o.opacity,f.rotation.value=o.rotation,o.map&&(f.map.value=o.map,i(o.map,f.mapTransform)),o.alphaMap&&(f.alphaMap.value=o.alphaMap,i(o.alphaMap,f.alphaMapTransform)),o.alphaTest>0&&(f.alphaTest.value=o.alphaTest)}function p(f,o){f.specular.value.copy(o.specular),f.shininess.value=Math.max(o.shininess,1e-4)}function h(f,o){o.gradientMap&&(f.gradientMap.value=o.gradientMap)}function a(f,o){f.metalness.value=o.metalness,o.metalnessMap&&(f.metalnessMap.value=o.metalnessMap,i(o.metalnessMap,f.metalnessMapTransform)),f.roughness.value=o.roughness,o.roughnessMap&&(f.roughnessMap.value=o.roughnessMap,i(o.roughnessMap,f.roughnessMapTransform)),t.get(o).envMap&&(f.envMapIntensity.value=o.envMapIntensity)}function l(f,o,c){f.ior.value=o.ior,o.sheen>0&&(f.sheenColor.value.copy(o.sheenColor).multiplyScalar(o.sheen),f.sheenRoughness.value=o.sheenRoughness,o.sheenColorMap&&(f.sheenColorMap.value=o.sheenColorMap,i(o.sheenColorMap,f.sheenColorMapTransform)),o.sheenRoughnessMap&&(f.sheenRoughnessMap.value=o.sheenRoughnessMap,i(o.sheenRoughnessMap,f.sheenRoughnessMapTransform))),o.clearcoat>0&&(f.clearcoat.value=o.clearcoat,f.clearcoatRoughness.value=o.clearcoatRoughness,o.clearcoatMap&&(f.clearcoatMap.value=o.clearcoatMap,i(o.clearcoatMap,f.clearcoatMapTransform)),o.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=o.clearcoatRoughnessMap,i(o.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),o.clearcoatNormalMap&&(f.clearcoatNormalMap.value=o.clearcoatNormalMap,i(o.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(o.clearcoatNormalScale),o.side===ms&&f.clearcoatNormalScale.value.negate())),o.iridescence>0&&(f.iridescence.value=o.iridescence,f.iridescenceIOR.value=o.iridescenceIOR,f.iridescenceThicknessMinimum.value=o.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=o.iridescenceThicknessRange[1],o.iridescenceMap&&(f.iridescenceMap.value=o.iridescenceMap,i(o.iridescenceMap,f.iridescenceMapTransform)),o.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=o.iridescenceThicknessMap,i(o.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),o.transmission>0&&(f.transmission.value=o.transmission,f.transmissionSamplerMap.value=c.texture,f.transmissionSamplerSize.value.set(c.width,c.height),o.transmissionMap&&(f.transmissionMap.value=o.transmissionMap,i(o.transmissionMap,f.transmissionMapTransform)),f.thickness.value=o.thickness,o.thicknessMap&&(f.thicknessMap.value=o.thicknessMap,i(o.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=o.attenuationDistance,f.attenuationColor.value.copy(o.attenuationColor)),o.anisotropy>0&&(f.anisotropyVector.value.set(o.anisotropy*Math.cos(o.anisotropyRotation),o.anisotropy*Math.sin(o.anisotropyRotation)),o.anisotropyMap&&(f.anisotropyMap.value=o.anisotropyMap,i(o.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=o.specularIntensity,f.specularColor.value.copy(o.specularColor),o.specularColorMap&&(f.specularColorMap.value=o.specularColorMap,i(o.specularColorMap,f.specularColorMapTransform)),o.specularIntensityMap&&(f.specularIntensityMap.value=o.specularIntensityMap,i(o.specularIntensityMap,f.specularIntensityMapTransform))}function n(f,o){o.matcap&&(f.matcap.value=o.matcap)}function u(f,o){const c=t.get(o).light;f.referencePosition.value.setFromMatrixPosition(c.matrixWorld),f.nearDistance.value=c.shadow.camera.near,f.farDistance.value=c.shadow.camera.far}return{refreshFogUniforms:x,refreshMaterialUniforms:T}}function k6(g,t,i,x){let T={},E={},s=[];const y=i.isWebGL2?g.getParameter(g.MAX_UNIFORM_BUFFER_BINDINGS):0;function e(c,d){const v=d.program;x.uniformBlockBinding(c,v)}function r(c,d){let v=T[c.id];v===void 0&&(n(c),v=p(c),T[c.id]=v,c.addEventListener("dispose",f));const m=d.program;x.updateUBOMapping(c,m);const S=t.render.frame;E[c.id]!==S&&(a(c),E[c.id]=S)}function p(c){const d=h();c.__bindingPointIndex=d;const v=g.createBuffer(),m=c.__size,S=c.usage;return g.bindBuffer(g.UNIFORM_BUFFER,v),g.bufferData(g.UNIFORM_BUFFER,m,S),g.bindBuffer(g.UNIFORM_BUFFER,null),g.bindBufferBase(g.UNIFORM_BUFFER,d,v),v}function h(){for(let c=0;c0&&(v+=m-S),c.__size=v,c.__cache={},this}function u(c){const d={boundary:0,storage:0};return typeof c=="number"||typeof c=="boolean"?(d.boundary=4,d.storage=4):c.isVector2?(d.boundary=8,d.storage=8):c.isVector3||c.isColor?(d.boundary=16,d.storage=12):c.isVector4?(d.boundary=16,d.storage=16):c.isMatrix3?(d.boundary=48,d.storage=48):c.isMatrix4?(d.boundary=64,d.storage=64):c.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",c),d}function f(c){const d=c.target;d.removeEventListener("dispose",f);const v=s.indexOf(d.__bindingPointIndex);s.splice(v,1),g.deleteBuffer(T[d.id]),delete T[d.id],delete E[d.id]}function o(){for(const c in T)g.deleteBuffer(T[c]);s=[],T={},E={}}return{bind:e,update:r,dispose:o}}class M1{constructor(t={}){const{canvas:i=fw(),context:x=null,depth:T=!0,stencil:E=!0,alpha:s=!1,antialias:y=!1,premultipliedAlpha:e=!0,preserveDrawingBuffer:r=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:h=!1}=t;this.isWebGLRenderer=!0;let a;x!==null?a=x.getContextAttributes().alpha:a=s;const l=new Uint32Array(4),n=new Int32Array(4);let u=null,f=null;const o=[],c=[];this.domElement=i,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=vr,this._useLegacyLights=!1,this.toneMapping=Bo,this.toneMappingExposure=1;const d=this;let v=!1,m=0,S=0,M=null,w=-1,C=null;const A=new sn,P=new sn;let b=null;const O=new ze(0);let I=0,D=i.width,B=i.height,G=1,z=null,X=null;const K=new sn(0,0,D,B),Q=new sn(0,0,D,B);let tt=!1;const Y=new _d;let Z=!1,U=!1,H=null;const J=new ci,_=new ve,q=new Ct,at={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ot(){return M===null?G:1}let rt=x;function gt(Tt,jt){for(let _t=0;_t{function Te(){if(ee.forEach(function(Ue){Vt.get(Ue).currentProgram.isReady()&&ee.delete(Ue)}),ee.size===0){te(Tt);return}setTimeout(Te,10)}yt.get("KHR_parallel_shader_compile")!==null?Te():setTimeout(Te,10)})};let Di=null;function en(Tt){Di&&Di(Tt)}function Zn(){di.stop()}function Gi(){di.start()}const di=new yw;di.setAnimationLoop(en),typeof self<"u"&&di.setContext(self),this.setAnimationLoop=function(Tt){Di=Tt,le.setAnimationLoop(Tt),Tt===null?di.stop():di.start()},le.addEventListener("sessionstart",Zn),le.addEventListener("sessionend",Gi),this.render=function(Tt,jt){if(jt!==void 0&&jt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;Tt.matrixWorldAutoUpdate===!0&&Tt.updateMatrixWorld(),jt.parent===null&&jt.matrixWorldAutoUpdate===!0&&jt.updateMatrixWorld(),le.enabled===!0&&le.isPresenting===!0&&(le.cameraAutoUpdate===!0&&le.updateCamera(jt),jt=le.getCamera()),Tt.isScene===!0&&Tt.onBeforeRender(d,Tt,jt,M),f=xe.get(Tt,c.length),f.init(),c.push(f),J.multiplyMatrices(jt.projectionMatrix,jt.matrixWorldInverse),Y.setFromProjectionMatrix(J),U=this.localClippingEnabled,Z=Ae.init(this.clippingPlanes,U),u=ge.get(Tt,o.length),u.init(),o.push(u),Wi(Tt,jt,0,d.sortObjects),u.finish(),d.sortObjects===!0&&u.sort(z,X),this.info.render.frame++,Z===!0&&Ae.beginShadows();const _t=f.state.shadowsArray;if(qt.render(_t,Tt,jt),Z===!0&&Ae.endShadows(),this.info.autoReset===!0&&this.info.reset(),(le.enabled===!1||le.isPresenting===!1||le.hasDepthSensing()===!1)&&Ge.render(u,Tt),f.setupLights(d._useLegacyLights),jt.isArrayCamera){const ee=jt.cameras;for(let te=0,Te=ee.length;te0?f=c[c.length-1]:f=null,o.pop(),o.length>0?u=o[o.length-1]:u=null};function Wi(Tt,jt,_t,ee){if(Tt.visible===!1)return;if(Tt.layers.test(jt.layers)){if(Tt.isGroup)_t=Tt.renderOrder;else if(Tt.isLOD)Tt.autoUpdate===!0&&Tt.update(jt);else if(Tt.isLight)f.pushLight(Tt),Tt.castShadow&&f.pushShadow(Tt);else if(Tt.isSprite){if(!Tt.frustumCulled||Y.intersectsSprite(Tt)){ee&&q.setFromMatrixPosition(Tt.matrixWorld).applyMatrix4(J);const Ue=Bt.update(Tt),We=Tt.material;We.visible&&u.push(Tt,Ue,We,_t,q.z,null)}}else if((Tt.isMesh||Tt.isLine||Tt.isPoints)&&(!Tt.frustumCulled||Y.intersectsObject(Tt))){const Ue=Bt.update(Tt),We=Tt.material;if(ee&&(Tt.boundingSphere!==void 0?(Tt.boundingSphere===null&&Tt.computeBoundingSphere(),q.copy(Tt.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),q.copy(Ue.boundingSphere.center)),q.applyMatrix4(Tt.matrixWorld).applyMatrix4(J)),Array.isArray(We)){const $e=Ue.groups;for(let qe=0,ii=$e.length;qe0&&aa(te,Te,jt,_t),ee&&At.viewport(A.copy(ee)),te.length>0&&Bs(te,jt,_t),Te.length>0&&Bs(Te,jt,_t),Ue.length>0&&Bs(Ue,jt,_t),At.buffers.depth.setTest(!0),At.buffers.depth.setMask(!0),At.buffers.color.setMask(!0),At.setPolygonOffset(!1)}function aa(Tt,jt,_t,ee){if((_t.isScene===!0?_t.overrideMaterial:null)!==null)return;const Te=Et.isWebGL2;H===null&&(H=new io(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")?Zf:Uo,minFilter:Io,samples:Te?4:0})),d.getDrawingBufferSize(_),Te?H.setSize(_.x,_.y):H.setSize(Tm(_.x),Tm(_.y));const Ue=d.getRenderTarget();d.setRenderTarget(H),d.getClearColor(O),I=d.getClearAlpha(),I<1&&d.setClearColor(16777215,.5),d.clear();const We=d.toneMapping;d.toneMapping=Bo,Bs(Tt,_t,ee),dt.updateMultisampleRenderTarget(H),dt.updateRenderTargetMipmap(H);let $e=!1;for(let qe=0,ii=jt.length;qe0),ai=!!_t.morphAttributes.position,Ji=!!_t.morphAttributes.normal,hn=!!_t.morphAttributes.color;let ki=Bo;ee.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(ki=d.toneMapping);const mn=_t.morphAttributes.position||_t.morphAttributes.normal||_t.morphAttributes.color,ti=mn!==void 0?mn.length:0,Se=Vt.get(ee),Nr=f.state.lights;if(Z===!0&&(U===!0||Tt!==C)){const Tn=Tt===C&&ee.id===w;Ae.setState(ee,Tt,Tn)}let mi=!1;ee.version===Se.__version?(Se.needsLights&&Se.lightsStateVersion!==Nr.state.version||Se.outputColorSpace!==We||te.isBatchedMesh&&Se.batching===!1||!te.isBatchedMesh&&Se.batching===!0||te.isInstancedMesh&&Se.instancing===!1||!te.isInstancedMesh&&Se.instancing===!0||te.isSkinnedMesh&&Se.skinning===!1||!te.isSkinnedMesh&&Se.skinning===!0||te.isInstancedMesh&&Se.instancingColor===!0&&te.instanceColor===null||te.isInstancedMesh&&Se.instancingColor===!1&&te.instanceColor!==null||Se.envMap!==$e||ee.fog===!0&&Se.fog!==Te||Se.numClippingPlanes!==void 0&&(Se.numClippingPlanes!==Ae.numPlanes||Se.numIntersection!==Ae.numIntersection)||Se.vertexAlphas!==qe||Se.vertexTangents!==ii||Se.morphTargets!==ai||Se.morphNormals!==Ji||Se.morphColors!==hn||Se.toneMapping!==ki||Et.isWebGL2===!0&&Se.morphTargetsCount!==ti)&&(mi=!0):(mi=!0,Se.__version=ee.version);let un=Se.currentProgram;mi===!0&&(un=ao(ee,jt,te));let Ii=!1,Gn=!1,pn=!1;const Ki=un.getUniforms(),dr=Se.uniforms;if(At.useProgram(un.program)&&(Ii=!0,Gn=!0,pn=!0),ee.id!==w&&(w=ee.id,Gn=!0),Ii||C!==Tt){Ki.setValue(rt,"projectionMatrix",Tt.projectionMatrix),Ki.setValue(rt,"viewMatrix",Tt.matrixWorldInverse);const Tn=Ki.map.cameraPosition;Tn!==void 0&&Tn.setValue(rt,q.setFromMatrixPosition(Tt.matrixWorld)),Et.logarithmicDepthBuffer&&Ki.setValue(rt,"logDepthBufFC",2/(Math.log(Tt.far+1)/Math.LN2)),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&Ki.setValue(rt,"isOrthographic",Tt.isOrthographicCamera===!0),C!==Tt&&(C=Tt,Gn=!0,pn=!0)}if(te.isSkinnedMesh){Ki.setOptional(rt,te,"bindMatrix"),Ki.setOptional(rt,te,"bindMatrixInverse");const Tn=te.skeleton;Tn&&(Et.floatVertexTextures?(Tn.boneTexture===null&&Tn.computeBoneTexture(),Ki.setValue(rt,"boneTexture",Tn.boneTexture,dt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}te.isBatchedMesh&&(Ki.setOptional(rt,te,"batchingTexture"),Ki.setValue(rt,"batchingTexture",te._matricesTexture,dt));const zs=_t.morphAttributes;if((zs.position!==void 0||zs.normal!==void 0||zs.color!==void 0&&Et.isWebGL2===!0)&&Oe.update(te,_t,un),(Gn||Se.receiveShadow!==te.receiveShadow)&&(Se.receiveShadow=te.receiveShadow,Ki.setValue(rt,"receiveShadow",te.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(dr.envMap.value=$e,dr.flipEnvMap.value=$e.isCubeTexture&&$e.isRenderTargetTexture===!1?-1:1),Gn&&(Ki.setValue(rt,"toneMappingExposure",d.toneMappingExposure),Se.needsLights&&oo(dr,pn),Te&&ee.fog===!0&&oe.refreshFogUniforms(dr,Te),oe.refreshMaterialUniforms(dr,ee,G,B,H),lm.upload(rt,_r(Se),dr,dt)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(lm.upload(rt,_r(Se),dr,dt),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&Ki.setValue(rt,"center",te.center),Ki.setValue(rt,"modelViewMatrix",te.modelViewMatrix),Ki.setValue(rt,"normalMatrix",te.normalMatrix),Ki.setValue(rt,"modelMatrix",te.matrixWorld),ee.isShaderMaterial||ee.isRawShaderMaterial){const Tn=ee.uniformsGroups;for(let oa=0,Jn=Tn.length;oa0&&dt.useMultisampledRTT(Tt)===!1?te=Vt.get(Tt).__webglMultisampledFramebuffer:Array.isArray(ii)?te=ii[_t]:te=ii,A.copy(Tt.viewport),P.copy(Tt.scissor),b=Tt.scissorTest}else A.copy(K).multiplyScalar(G).floor(),P.copy(Q).multiplyScalar(G).floor(),b=tt;if(At.bindFramebuffer(rt.FRAMEBUFFER,te)&&Et.drawBuffers&&ee&&At.drawBuffers(Tt,te),At.viewport(A),At.scissor(P),At.setScissorTest(b),Te){const $e=Vt.get(Tt.texture);rt.framebufferTexture2D(rt.FRAMEBUFFER,rt.COLOR_ATTACHMENT0,rt.TEXTURE_CUBE_MAP_POSITIVE_X+jt,$e.__webglTexture,_t)}else if(Ue){const $e=Vt.get(Tt.texture),qe=jt||0;rt.framebufferTextureLayer(rt.FRAMEBUFFER,rt.COLOR_ATTACHMENT0,$e.__webglTexture,_t||0,qe)}w=-1},this.readRenderTargetPixels=function(Tt,jt,_t,ee,te,Te,Ue){if(!(Tt&&Tt.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let We=Vt.get(Tt).__webglFramebuffer;if(Tt.isWebGLCubeRenderTarget&&Ue!==void 0&&(We=We[Ue]),We){At.bindFramebuffer(rt.FRAMEBUFFER,We);try{const $e=Tt.texture,qe=$e.format,ii=$e.type;if(qe!==ps&&ie.convert(qe)!==rt.getParameter(rt.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ai=ii===Zf&&(yt.has("EXT_color_buffer_half_float")||Et.isWebGL2&&yt.has("EXT_color_buffer_float"));if(ii!==Uo&&ie.convert(ii)!==rt.getParameter(rt.IMPLEMENTATION_COLOR_READ_TYPE)&&!(ii===Ea&&(Et.isWebGL2||yt.has("OES_texture_float")||yt.has("WEBGL_color_buffer_float")))&&!ai){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}jt>=0&&jt<=Tt.width-ee&&_t>=0&&_t<=Tt.height-te&&rt.readPixels(jt,_t,ee,te,ie.convert(qe),ie.convert(ii),Te)}finally{const $e=M!==null?Vt.get(M).__webglFramebuffer:null;At.bindFramebuffer(rt.FRAMEBUFFER,$e)}}},this.copyFramebufferToTexture=function(Tt,jt,_t=0){const ee=Math.pow(2,-_t),te=Math.floor(jt.image.width*ee),Te=Math.floor(jt.image.height*ee);dt.setTexture2D(jt,0),rt.copyTexSubImage2D(rt.TEXTURE_2D,_t,0,0,Tt.x,Tt.y,te,Te),At.unbindTexture()},this.copyTextureToTexture=function(Tt,jt,_t,ee=0){const te=jt.image.width,Te=jt.image.height,Ue=ie.convert(_t.format),We=ie.convert(_t.type);dt.setTexture2D(_t,0),rt.pixelStorei(rt.UNPACK_FLIP_Y_WEBGL,_t.flipY),rt.pixelStorei(rt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_t.premultiplyAlpha),rt.pixelStorei(rt.UNPACK_ALIGNMENT,_t.unpackAlignment),jt.isDataTexture?rt.texSubImage2D(rt.TEXTURE_2D,ee,Tt.x,Tt.y,te,Te,Ue,We,jt.image.data):jt.isCompressedTexture?rt.compressedTexSubImage2D(rt.TEXTURE_2D,ee,Tt.x,Tt.y,jt.mipmaps[0].width,jt.mipmaps[0].height,Ue,jt.mipmaps[0].data):rt.texSubImage2D(rt.TEXTURE_2D,ee,Tt.x,Tt.y,Ue,We,jt.image),ee===0&&_t.generateMipmaps&&rt.generateMipmap(rt.TEXTURE_2D),At.unbindTexture()},this.copyTextureToTexture3D=function(Tt,jt,_t,ee,te=0){if(d.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Te=Tt.max.x-Tt.min.x+1,Ue=Tt.max.y-Tt.min.y+1,We=Tt.max.z-Tt.min.z+1,$e=ie.convert(ee.format),qe=ie.convert(ee.type);let ii;if(ee.isData3DTexture)dt.setTexture3D(ee,0),ii=rt.TEXTURE_3D;else if(ee.isDataArrayTexture||ee.isCompressedArrayTexture)dt.setTexture2DArray(ee,0),ii=rt.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}rt.pixelStorei(rt.UNPACK_FLIP_Y_WEBGL,ee.flipY),rt.pixelStorei(rt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),rt.pixelStorei(rt.UNPACK_ALIGNMENT,ee.unpackAlignment);const ai=rt.getParameter(rt.UNPACK_ROW_LENGTH),Ji=rt.getParameter(rt.UNPACK_IMAGE_HEIGHT),hn=rt.getParameter(rt.UNPACK_SKIP_PIXELS),ki=rt.getParameter(rt.UNPACK_SKIP_ROWS),mn=rt.getParameter(rt.UNPACK_SKIP_IMAGES),ti=_t.isCompressedTexture?_t.mipmaps[te]:_t.image;rt.pixelStorei(rt.UNPACK_ROW_LENGTH,ti.width),rt.pixelStorei(rt.UNPACK_IMAGE_HEIGHT,ti.height),rt.pixelStorei(rt.UNPACK_SKIP_PIXELS,Tt.min.x),rt.pixelStorei(rt.UNPACK_SKIP_ROWS,Tt.min.y),rt.pixelStorei(rt.UNPACK_SKIP_IMAGES,Tt.min.z),_t.isDataTexture||_t.isData3DTexture?rt.texSubImage3D(ii,te,jt.x,jt.y,jt.z,Te,Ue,We,$e,qe,ti.data):_t.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),rt.compressedTexSubImage3D(ii,te,jt.x,jt.y,jt.z,Te,Ue,We,$e,ti.data)):rt.texSubImage3D(ii,te,jt.x,jt.y,jt.z,Te,Ue,We,$e,qe,ti),rt.pixelStorei(rt.UNPACK_ROW_LENGTH,ai),rt.pixelStorei(rt.UNPACK_IMAGE_HEIGHT,Ji),rt.pixelStorei(rt.UNPACK_SKIP_PIXELS,hn),rt.pixelStorei(rt.UNPACK_SKIP_ROWS,ki),rt.pixelStorei(rt.UNPACK_SKIP_IMAGES,mn),te===0&&ee.generateMipmaps&&rt.generateMipmap(ii),At.unbindTexture()},this.initTexture=function(Tt){Tt.isCubeTexture?dt.setTextureCube(Tt,0):Tt.isData3DTexture?dt.setTexture3D(Tt,0):Tt.isDataArrayTexture||Tt.isCompressedArrayTexture?dt.setTexture2DArray(Tt,0):dt.setTexture2D(Tt,0),At.unbindTexture()},this.resetState=function(){m=0,S=0,M=null,At.reset(),Ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return No}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const i=this.getContext();i.drawingBufferColorSpace=t===og?"display-p3":"srgb",i.unpackColorSpace=rn.workingColorSpace===Jd?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===vr?ch:c1}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===ch?vr:Go}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}}class Aw extends M1{}Aw.prototype.isWebGL1Renderer=!0;class ug{constructor(t,i=25e-5){this.isFogExp2=!0,this.name="",this.color=new ze(t),this.density=i}clone(){return new ug(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class fg{constructor(t,i=1,x=1e3){this.isFog=!0,this.name="",this.color=new ze(t),this.near=i,this.far=x}clone(){return new fg(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Em extends Yi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,i){return super.copy(t,i),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const i=super.toJSON(t);return this.fog!==null&&(i.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(i.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(i.object.backgroundIntensity=this.backgroundIntensity),i}}class cg{constructor(t,i){this.isInterleavedBuffer=!0,this.array=t,this.stride=i,this.count=t!==void 0?t.length/i:0,this.usage=Fd,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=na()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Su("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,i,x){t*=this.stride,x*=i.stride;for(let T=0,E=this.stride;Tt.far||i.push({distance:e,point:jc.clone(),uv:ia.getInterpolation(jc,Ev,Jc,Mv,fE,W0,cE,new ve),face:null,object:this})}copy(t,i){return super.copy(t,i),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Cv(g,t,i,x,T,E){Af.subVectors(g,i).addScalar(.5).multiply(x),T!==void 0?(Zc.x=E*Af.x-T*Af.y,Zc.y=T*Af.x+E*Af.y):Zc.copy(Af),g.copy(t),g.x+=Zc.x,g.y+=Zc.y,g.applyMatrix4(Pw)}const wv=new Ct,dE=new Ct;class bw extends Yi{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const i=t.levels;for(let x=0,T=i.length;x0){let x,T;for(x=1,T=i.length;x0){wv.setFromMatrixPosition(this.matrixWorld);const T=t.ray.origin.distanceTo(wv);this.getObjectForDistance(T).raycast(t,i)}}update(t){const i=this.levels;if(i.length>1){wv.setFromMatrixPosition(t.matrixWorld),dE.setFromMatrixPosition(this.matrixWorld);const x=wv.distanceTo(dE)/t.zoom;i[0].object.visible=!0;let T,E;for(T=1,E=i.length;T=s)i[T-1].object.visible=!1,i[T].object.visible=!0;else break}for(this._currentLevel=T-1;T=x.length&&x.push({start:-1,count:-1,z:-1});const E=x[this.index];T.push(E),this.index++,E.start=t.start,E.count=t.count,E.z=i}reset(){this.list.length=0,this.index=0}}const Rf="batchId",rh=new ci,EE=new ci,_6=new ci,ME=new ci,k0=new _d,Rv=new gs,tu=new $r,_c=new Ct,K0=new Q6,jr=new cr,bv=[];function q6(g,t,i=0){const x=t.itemSize;if(g.isInterleavedBufferAttribute||g.array.constructor!==t.array.constructor){const T=g.count;for(let E=0;E65536?new Uint32Array(E):new Uint16Array(E);i.setIndex(new an(y,1))}const s=T>65536?new Uint32Array(x):new Uint16Array(x);i.setAttribute(Rf,new an(s,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(Rf))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Rf}"`);const i=this.geometry;if(!!t.getIndex()!=!!i.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const x in i.attributes){if(x===Rf)continue;if(!t.hasAttribute(x))throw new Error(`BatchedMesh: Added geometry missing "${x}". All geometries must have consistent attributes.`);const T=t.getAttribute(x),E=i.getAttribute(x);if(T.itemSize!==E.itemSize||T.normalized!==E.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gs);const t=this._geometryCount,i=this.boundingBox,x=this._active;i.makeEmpty();for(let T=0;T=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const T={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let E=null;const s=this._reservedRanges,y=this._drawRanges,e=this._bounds;this._geometryCount!==0&&(E=s[s.length-1]),i===-1?T.vertexCount=t.getAttribute("position").count:T.vertexCount=i,E===null?T.vertexStart=0:T.vertexStart=E.vertexStart+E.vertexCount;const r=t.getIndex(),p=r!==null;if(p&&(x===-1?T.indexCount=r.count:T.indexCount=x,E===null?T.indexStart=0:T.indexStart=E.indexStart+E.indexCount),T.indexStart!==-1&&T.indexStart+T.indexCount>this._maxIndexCount||T.vertexStart+T.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._visibility,a=this._active,l=this._matricesTexture,n=this._matricesTexture.image.data;h.push(!0),a.push(!0);const u=this._geometryCount;this._geometryCount++,_6.toArray(n,u*16),l.needsUpdate=!0,s.push(T),y.push({start:p?T.indexStart:T.vertexStart,count:-1}),e.push({boxInitialized:!1,box:new gs,sphereInitialized:!1,sphere:new $r});const f=this.geometry.getAttribute(Rf);for(let o=0;o=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(i);const x=this.geometry,T=x.getIndex()!==null,E=x.getIndex(),s=i.getIndex(),y=this._reservedRanges[t];if(T&&s.count>y.indexCount||i.attributes.position.count>y.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const e=y.vertexStart,r=y.vertexCount;for(const l in x.attributes){if(l===Rf)continue;const n=i.getAttribute(l),u=x.getAttribute(l);q6(n,u,e);const f=n.itemSize;for(let o=n.count,c=r;o=i.length||i[t]===!1?this:(i[t]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(t,i){if(this._active[t]===!1)return null;const T=this._bounds[t],E=T.box,s=this.geometry;if(T.boxInitialized===!1){E.makeEmpty();const y=s.index,e=s.attributes.position,r=this._drawRanges[t];for(let p=r.start,h=r.start+r.count;p=s||x[t]===!1?this:(i.toArray(E,t*16),T.needsUpdate=!0,this)}getMatrixAt(t,i){const x=this._active,T=this._matricesTexture.image.data,E=this._geometryCount;return t>=E||x[t]===!1?null:i.fromArray(T,t*16)}setVisibleAt(t,i){const x=this._visibility,T=this._active,E=this._geometryCount;return t>=E||T[t]===!1||x[t]===i?this:(x[t]=i,this._visibilityChanged=!0,this)}getVisibleAt(t){const i=this._visibility,x=this._active,T=this._geometryCount;return t>=T||x[t]===!1?!1:i[t]}raycast(t,i){const x=this._visibility,T=this._active,E=this._drawRanges,s=this._geometryCount,y=this.matrixWorld,e=this.geometry;jr.material=this.material,jr.geometry.index=e.index,jr.geometry.attributes=e.attributes,jr.geometry.boundingBox===null&&(jr.geometry.boundingBox=new gs),jr.geometry.boundingSphere===null&&(jr.geometry.boundingSphere=new $r);for(let r=0;r({...i})),this._reservedRanges=t._reservedRanges.map(i=>({...i})),this._visibility=t._visibility.slice(),this._active=t._active.slice(),this._bounds=t._bounds.map(i=>({boxInitialized:i.boxInitialized,box:i.box.clone(),sphereInitialized:i.sphereInitialized,sphere:i.sphere.clone()})),this._maxGeometryCount=t._maxGeometryCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(t,i,x,T,E){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=T.getIndex(),y=s===null?1:s.array.BYTES_PER_ELEMENT,e=this._active,r=this._visibility,p=this._multiDrawStarts,h=this._multiDrawCounts,a=this._drawRanges,l=this.perObjectFrustumCulled;l&&(ME.multiplyMatrices(x.projectionMatrix,x.matrixWorldInverse).multiply(this.matrixWorld),k0.setFromProjectionMatrix(ME,t.coordinateSystem));let n=0;if(this.sortObjects){EE.copy(this.matrixWorld).invert(),_c.setFromMatrixPosition(x.matrixWorld).applyMatrix4(EE);for(let o=0,c=r.length;oe)continue;a.applyMatrix4(this.matrixWorld);const w=t.ray.origin.distanceTo(a);wt.far||i.push({distance:w,point:h.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this})}}else{const o=Math.max(0,s.start),c=Math.min(f.count,s.start+s.count);for(let d=o,v=c-1;de)continue;a.applyMatrix4(this.matrixWorld);const S=t.ray.origin.distanceTo(a);St.far||i.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const i=this.geometry.morphAttributes,x=Object.keys(i);if(x.length>0){const T=i[x[0]];if(T!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let E=0,s=T.length;E0){const T=i[x[0]];if(T!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let E=0,s=T.length;ET.far)return;E.push({distance:r,distanceToRay:Math.sqrt(y),point:e,index:t,face:null,object:s})}}class tU extends Un{constructor(t,i,x,T,E,s,y,e,r){super(t,i,x,T,E,s,y,e,r),this.isVideoTexture=!0,this.minFilter=s!==void 0?s:Nn,this.magFilter=E!==void 0?E:Nn,this.generateMipmaps=!1;const p=this;function h(){p.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class eU extends Un{constructor(t,i){super({width:t,height:i}),this.isFramebufferTexture=!0,this.magFilter=nr,this.minFilter=nr,this.generateMipmaps=!1,this.needsUpdate=!0}}class pg extends Un{constructor(t,i,x,T,E,s,y,e,r,p,h,a){super(null,s,y,e,r,p,T,E,h,a),this.isCompressedTexture=!0,this.image={width:i,height:x},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class iU extends pg{constructor(t,i,x,T,E,s){super(t,i,x,E,s),this.isCompressedArrayTexture=!0,this.image.depth=T,this.wrapR=Jr}}class nU extends pg{constructor(t,i,x){super(void 0,t[0].width,t[0].height,i,x,wl),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class rU extends Un{constructor(t,i,x,T,E,s,y,e,r){super(t,i,x,T,E,s,y,e,r),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ro{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,i){const x=this.getUtoTmapping(t);return this.getPoint(x,i)}getPoints(t=5){const i=[];for(let x=0;x<=t;x++)i.push(this.getPoint(x/t));return i}getSpacedPoints(t=5){const i=[];for(let x=0;x<=t;x++)i.push(this.getPointAt(x/t));return i}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const i=[];let x,T=this.getPoint(0),E=0;i.push(0);for(let s=1;s<=t;s++)x=this.getPoint(s/t),E+=x.distanceTo(T),i.push(E),T=x;return this.cacheArcLengths=i,i}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,i){const x=this.getLengths();let T=0;const E=x.length;let s;i?s=i:s=t*x[E-1];let y=0,e=E-1,r;for(;y<=e;)if(T=Math.floor(y+(e-y)/2),r=x[T]-s,r<0)y=T+1;else if(r>0)e=T-1;else{e=T;break}if(T=e,x[T]===s)return T/(E-1);const p=x[T],a=x[T+1]-p,l=(s-p)/a;return(T+l)/(E-1)}getTangent(t,i){let T=t-1e-4,E=t+1e-4;T<0&&(T=0),E>1&&(E=1);const s=this.getPoint(T),y=this.getPoint(E),e=i||(s.isVector2?new ve:new Ct);return e.copy(y).sub(s).normalize(),e}getTangentAt(t,i){const x=this.getUtoTmapping(t);return this.getTangent(x,i)}computeFrenetFrames(t,i){const x=new Ct,T=[],E=[],s=[],y=new Ct,e=new ci;for(let l=0;l<=t;l++){const n=l/t;T[l]=this.getTangentAt(n,new Ct)}E[0]=new Ct,s[0]=new Ct;let r=Number.MAX_VALUE;const p=Math.abs(T[0].x),h=Math.abs(T[0].y),a=Math.abs(T[0].z);p<=r&&(r=p,x.set(1,0,0)),h<=r&&(r=h,x.set(0,1,0)),a<=r&&x.set(0,0,1),y.crossVectors(T[0],x).normalize(),E[0].crossVectors(T[0],y),s[0].crossVectors(T[0],E[0]);for(let l=1;l<=t;l++){if(E[l]=E[l-1].clone(),s[l]=s[l-1].clone(),y.crossVectors(T[l-1],T[l]),y.length()>Number.EPSILON){y.normalize();const n=Math.acos(jn(T[l-1].dot(T[l]),-1,1));E[l].applyMatrix4(e.makeRotationAxis(y,n))}s[l].crossVectors(T[l],E[l])}if(i===!0){let l=Math.acos(jn(E[0].dot(E[t]),-1,1));l/=t,T[0].dot(y.crossVectors(E[0],E[t]))>0&&(l=-l);for(let n=1;n<=t;n++)E[n].applyMatrix4(e.makeRotationAxis(T[n],l*n)),s[n].crossVectors(T[n],E[n])}return{tangents:T,normals:E,binormals:s}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class vg extends ro{constructor(t=0,i=0,x=1,T=1,E=0,s=Math.PI*2,y=!1,e=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=i,this.xRadius=x,this.yRadius=T,this.aStartAngle=E,this.aEndAngle=s,this.aClockwise=y,this.aRotation=e}getPoint(t,i){const x=i||new ve,T=Math.PI*2;let E=this.aEndAngle-this.aStartAngle;const s=Math.abs(E)T;)E-=T;E0?0:(Math.floor(Math.abs(y)/E)+1)*E:e===0&&y===E-1&&(y=E-2,e=1);let r,p;this.closed||y>0?r=T[(y-1)%E]:(Dv.subVectors(T[0],T[1]).add(T[0]),r=Dv);const h=T[y%E],a=T[(y+1)%E];if(this.closed||y+2T.length-2?T.length-1:s+1],h=T[s>T.length-3?T.length-1:s+2];return x.set(FE(y,e.x,r.x,p.x,h.x),FE(y,e.y,r.y,p.y,h.y)),x}copy(t){super.copy(t),this.points=[];for(let i=0,x=t.points.length;i=x){const s=T[E]-x,y=this.curves[E],e=y.getLength(),r=e===0?0:1-s/e;return y.getPointAt(r,i)}E++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let i=0;for(let x=0,T=this.curves.length;x1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(t){super.copy(t),this.curves=[];for(let i=0,x=t.curves.length;i0){const h=r.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(r);const p=r.getPoint(1);return this.currentPoint.copy(p),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class tp extends Li{constructor(t=[new ve(0,-.5),new ve(.5,0),new ve(0,.5)],i=12,x=0,T=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:i,phiStart:x,phiLength:T},i=Math.floor(i),T=jn(T,0,Math.PI*2);const E=[],s=[],y=[],e=[],r=[],p=1/i,h=new Ct,a=new ve,l=new Ct,n=new Ct,u=new Ct;let f=0,o=0;for(let c=0;c<=t.length-1;c++)switch(c){case 0:f=t[c+1].x-t[c].x,o=t[c+1].y-t[c].y,l.x=o*1,l.y=-f,l.z=o*0,u.copy(l),l.normalize(),e.push(l.x,l.y,l.z);break;case t.length-1:e.push(u.x,u.y,u.z);break;default:f=t[c+1].x-t[c].x,o=t[c+1].y-t[c].y,l.x=o*1,l.y=-f,l.z=o*0,n.copy(l),l.x+=u.x,l.y+=u.y,l.z+=u.z,l.normalize(),e.push(l.x,l.y,l.z),u.copy(n)}for(let c=0;c<=i;c++){const d=x+c*p*T,v=Math.sin(d),m=Math.cos(d);for(let S=0;S<=t.length-1;S++){h.x=t[S].x*v,h.y=t[S].y,h.z=t[S].x*m,s.push(h.x,h.y,h.z),a.x=c/i,a.y=S/(t.length-1),y.push(a.x,a.y);const M=e[3*S+0]*v,w=e[3*S+1],C=e[3*S+0]*m;r.push(M,w,C)}}for(let c=0;c0&&d(!0),i>0&&d(!1)),this.setIndex(p),this.setAttribute("position",new ke(h,3)),this.setAttribute("normal",new ke(a,3)),this.setAttribute("uv",new ke(l,2));function c(){const v=new Ct,m=new Ct;let S=0;const M=(i-t)/x;for(let w=0;w<=E;w++){const C=[],A=w/E,P=A*(i-t)+t;for(let b=0;b<=T;b++){const O=b/T,I=O*e+y,D=Math.sin(I),B=Math.cos(I);m.x=P*D,m.y=-A*x+f,m.z=P*B,h.push(m.x,m.y,m.z),v.set(D,M,B).normalize(),a.push(v.x,v.y,v.z),l.push(O,1-A),C.push(n++)}u.push(C)}for(let w=0;w.9&&M<.1&&(d<.2&&(s[c+0]+=1),v<.2&&(s[c+2]+=1),m<.2&&(s[c+4]+=1))}}function a(c){E.push(c.x,c.y,c.z)}function l(c,d){const v=c*3;d.x=t[v+0],d.y=t[v+1],d.z=t[v+2]}function n(){const c=new Ct,d=new Ct,v=new Ct,m=new Ct,S=new ve,M=new ve,w=new ve;for(let C=0,A=0;C80*i){y=r=g[0],e=p=g[1];for(let n=i;nr&&(r=h),a>p&&(p=a);l=Math.max(r-y,p-e),l=l!==0?32767/l:0}return Nd(E,s,i,y,e,l,0),s}};function Hw(g,t,i,x,T){let E,s;if(T===RU(g,t,i,x)>0)for(E=t;E=t;E-=x)s=OE(E,g[E],g[E+1],s);return s&&Sg(s,s.next)&&(Ud(s),s=s.next),s}function bu(g,t){if(!g)return g;t||(t=g);let i=g,x;do if(x=!1,!i.steiner&&(Sg(i,i.next)||Bn(i.prev,i,i.next)===0)){if(Ud(i),i=t=i.prev,i===i.next)break;x=!0}else i=i.next;while(x||i!==t);return t}function Nd(g,t,i,x,T,E,s){if(!g)return;!s&&E&&EU(g,x,T,E);let y=g,e,r;for(;g.prev!==g.next;){if(e=g.prev,r=g.next,E?pU(g,x,T,E):dU(g)){t.push(e.i/i|0),t.push(g.i/i|0),t.push(r.i/i|0),Ud(g),g=r.next,y=r.next;continue}if(g=r,g===y){s?s===1?(g=vU(bu(g),t,i),Nd(g,t,i,x,T,E,2)):s===2&&mU(g,t,i,x,T,E):Nd(bu(g),t,i,x,T,E,1);break}}}function dU(g){const t=g.prev,i=g,x=g.next;if(Bn(t,i,x)>=0)return!1;const T=t.x,E=i.x,s=x.x,y=t.y,e=i.y,r=x.y,p=TE?T>s?T:s:E>s?E:s,l=y>e?y>r?y:r:e>r?e:r;let n=x.next;for(;n!==t;){if(n.x>=p&&n.x<=a&&n.y>=h&&n.y<=l&&Vf(T,y,E,e,s,r,n.x,n.y)&&Bn(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function pU(g,t,i,x){const T=g.prev,E=g,s=g.next;if(Bn(T,E,s)>=0)return!1;const y=T.x,e=E.x,r=s.x,p=T.y,h=E.y,a=s.y,l=ye?y>r?y:r:e>r?e:r,f=p>h?p>a?p:a:h>a?h:a,o=gx(l,n,t,i,x),c=gx(u,f,t,i,x);let d=g.prevZ,v=g.nextZ;for(;d&&d.z>=o&&v&&v.z<=c;){if(d.x>=l&&d.x<=u&&d.y>=n&&d.y<=f&&d!==T&&d!==s&&Vf(y,p,e,h,r,a,d.x,d.y)&&Bn(d.prev,d,d.next)>=0||(d=d.prevZ,v.x>=l&&v.x<=u&&v.y>=n&&v.y<=f&&v!==T&&v!==s&&Vf(y,p,e,h,r,a,v.x,v.y)&&Bn(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;d&&d.z>=o;){if(d.x>=l&&d.x<=u&&d.y>=n&&d.y<=f&&d!==T&&d!==s&&Vf(y,p,e,h,r,a,d.x,d.y)&&Bn(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;v&&v.z<=c;){if(v.x>=l&&v.x<=u&&v.y>=n&&v.y<=f&&v!==T&&v!==s&&Vf(y,p,e,h,r,a,v.x,v.y)&&Bn(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function vU(g,t,i){let x=g;do{const T=x.prev,E=x.next.next;!Sg(T,E)&&Ww(T,x,x.next,E)&&Bd(T,E)&&Bd(E,T)&&(t.push(T.i/i|0),t.push(x.i/i|0),t.push(E.i/i|0),Ud(x),Ud(x.next),x=g=E),x=x.next}while(x!==g);return bu(x)}function mU(g,t,i,x,T,E){let s=g;do{let y=s.next.next;for(;y!==s.prev;){if(s.i!==y.i&&wU(s,y)){let e=Xw(s,y);s=bu(s,s.next),e=bu(e,e.next),Nd(s,t,i,x,T,E,0),Nd(e,t,i,x,T,E,0);return}y=y.next}s=s.next}while(s!==g)}function gU(g,t,i,x){const T=[];let E,s,y,e,r;for(E=0,s=t.length;E=i.next.y&&i.next.y!==i.y){const a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=E&&a>x&&(x=a,T=i.x=i.x&&i.x>=e&&E!==i.x&&Vf(sT.x||i.x===T.x&&TU(T,i)))&&(T=i,p=h)),i=i.next;while(i!==y);return T}function TU(g,t){return Bn(g.prev,g,t.prev)<0&&Bn(t.next,g,g.next)<0}function EU(g,t,i,x){let T=g;do T.z===0&&(T.z=gx(T.x,T.y,t,i,x)),T.prevZ=T.prev,T.nextZ=T.next,T=T.next;while(T!==g);T.prevZ.nextZ=null,T.prevZ=null,MU(T)}function MU(g){let t,i,x,T,E,s,y,e,r=1;do{for(i=g,g=null,E=null,s=0;i;){for(s++,x=i,y=0,t=0;t0||e>0&&x;)y!==0&&(e===0||!x||i.z<=x.z)?(T=i,i=i.nextZ,y--):(T=x,x=x.nextZ,e--),E?E.nextZ=T:g=T,T.prevZ=E,E=T;i=x}E.nextZ=null,r*=2}while(s>1);return g}function gx(g,t,i,x,T){return g=(g-i)*T|0,t=(t-x)*T|0,g=(g|g<<8)&16711935,g=(g|g<<4)&252645135,g=(g|g<<2)&858993459,g=(g|g<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,g|t<<1}function CU(g){let t=g,i=g;do(t.x=(g-s)*(E-y)&&(g-s)*(x-y)>=(i-s)*(t-y)&&(i-s)*(E-y)>=(T-s)*(x-y)}function wU(g,t){return g.next.i!==t.i&&g.prev.i!==t.i&&!AU(g,t)&&(Bd(g,t)&&Bd(t,g)&&PU(g,t)&&(Bn(g.prev,g,t.prev)||Bn(g,t.prev,t))||Sg(g,t)&&Bn(g.prev,g,g.next)>0&&Bn(t.prev,t,t.next)>0)}function Bn(g,t,i){return(t.y-g.y)*(i.x-t.x)-(t.x-g.x)*(i.y-t.y)}function Sg(g,t){return g.x===t.x&&g.y===t.y}function Ww(g,t,i,x){const T=zv(Bn(g,t,i)),E=zv(Bn(g,t,x)),s=zv(Bn(i,x,g)),y=zv(Bn(i,x,t));return!!(T!==E&&s!==y||T===0&&Uv(g,i,t)||E===0&&Uv(g,x,t)||s===0&&Uv(i,g,x)||y===0&&Uv(i,t,x))}function Uv(g,t,i){return t.x<=Math.max(g.x,i.x)&&t.x>=Math.min(g.x,i.x)&&t.y<=Math.max(g.y,i.y)&&t.y>=Math.min(g.y,i.y)}function zv(g){return g>0?1:g<0?-1:0}function AU(g,t){let i=g;do{if(i.i!==g.i&&i.next.i!==g.i&&i.i!==t.i&&i.next.i!==t.i&&Ww(i,i.next,g,t))return!0;i=i.next}while(i!==g);return!1}function Bd(g,t){return Bn(g.prev,g,g.next)<0?Bn(g,t,g.next)>=0&&Bn(g,g.prev,t)>=0:Bn(g,t,g.prev)<0||Bn(g,g.next,t)<0}function PU(g,t){let i=g,x=!1;const T=(g.x+t.x)/2,E=(g.y+t.y)/2;do i.y>E!=i.next.y>E&&i.next.y!==i.y&&T<(i.next.x-i.x)*(E-i.y)/(i.next.y-i.y)+i.x&&(x=!x),i=i.next;while(i!==g);return x}function Xw(g,t){const i=new yx(g.i,g.x,g.y),x=new yx(t.i,t.x,t.y),T=g.next,E=t.prev;return g.next=t,t.prev=g,i.next=T,T.prev=i,x.next=i,i.prev=x,E.next=x,x.prev=E,x}function OE(g,t,i,x){const T=new yx(g,t,i);return x?(T.next=x.next,T.prev=x,x.next.prev=T,x.next=T):(T.prev=T,T.next=T),T}function Ud(g){g.next.prev=g.prev,g.prev.next=g.next,g.prevZ&&(g.prevZ.nextZ=g.nextZ),g.nextZ&&(g.nextZ.prevZ=g.prevZ)}function yx(g,t,i){this.i=g,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function RU(g,t,i,x){let T=0;for(let E=t,s=i-x;E2&&g[t-1].equals(g[0])&&g.pop()}function IE(g,t){for(let i=0;iNumber.EPSILON){const Bt=Math.sqrt(Dt),ne=Math.sqrt(ut*ut+Rt*Rt),oe=gt.x-dt/Bt,ge=gt.y+Vt/Bt,xe=yt.x-Rt/ne,Ae=yt.y+ut/ne,qt=((xe-oe)*Rt-(Ae-ge)*ut)/(Vt*Rt-dt*ut);Et=oe+Vt*qt-rt.x,At=ge+dt*qt-rt.y;const Ge=Et*Et+At*At;if(Ge<=2)return new ve(Et,At);Pt=Math.sqrt(Ge/2)}else{let Bt=!1;Vt>Number.EPSILON?ut>Number.EPSILON&&(Bt=!0):Vt<-Number.EPSILON?ut<-Number.EPSILON&&(Bt=!0):Math.sign(dt)===Math.sign(Rt)&&(Bt=!0),Bt?(Et=-dt,At=Vt,Pt=Math.sqrt(Dt)):(Et=Vt,At=dt,Pt=Math.sqrt(Dt/2))}return new ve(Et/Pt,At/Pt)}const X=[];for(let rt=0,gt=I.length,yt=gt-1,Et=rt+1;rt=0;rt--){const gt=rt/f,yt=l*Math.cos(gt*Math.PI/2),Et=n*Math.sin(gt*Math.PI/2)+u;for(let At=0,Pt=I.length;At=0;){const Et=yt;let At=yt-1;At<0&&(At=rt.length-1);for(let Pt=0,Vt=p+f*2;Pt0)&&l.push(d,v,S),(o!==x-1||e0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Zw extends Hr{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ze(16777215),this.specular=new ze(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Zd,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Jw extends Hr{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ze(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class $w extends Hr{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Qw extends Hr{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Zd,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class _w extends Hr{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ze(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class qw extends ys{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function gu(g,t,i){return!g||!i&&g.constructor===t?g:typeof t.BYTES_PER_ELEMENT=="number"?new t(g):Array.prototype.slice.call(g)}function tA(g){return ArrayBuffer.isView(g)&&!(g instanceof DataView)}function eA(g){function t(T,E){return g[T]-g[E]}const i=g.length,x=new Array(i);for(let T=0;T!==i;++T)x[T]=T;return x.sort(t),x}function xx(g,t,i){const x=g.length,T=new g.constructor(x);for(let E=0,s=0;s!==x;++E){const y=i[E]*t;for(let e=0;e!==t;++e)T[s++]=g[y+e]}return T}function D1(g,t,i,x){let T=1,E=g[0];for(;E!==void 0&&E[x]===void 0;)E=g[T++];if(E===void 0)return;let s=E[x];if(s!==void 0)if(Array.isArray(s))do s=E[x],s!==void 0&&(t.push(E.time),i.push.apply(i,s)),E=g[T++];while(E!==void 0);else if(s.toArray!==void 0)do s=E[x],s!==void 0&&(t.push(E.time),s.toArray(i,i.length)),E=g[T++];while(E!==void 0);else do s=E[x],s!==void 0&&(t.push(E.time),i.push(s)),E=g[T++];while(E!==void 0)}function OU(g,t,i,x,T=30){const E=g.clone();E.name=t;const s=[];for(let e=0;e=x)){h.push(r.times[l]);for(let u=0;uE.tracks[e].times[0]&&(y=E.tracks[e].times[0]);for(let e=0;e=y.times[n]){const o=n*h+p,c=o+h-p;u=y.values.slice(o,c)}else{const o=y.createInterpolant(),c=p,d=h-p;o.evaluate(E),u=o.resultBuffer.slice(c,d)}e==="quaternion"&&new Ds().fromArray(u).normalize().conjugate().toArray(u);const f=r.times.length;for(let o=0;o=E)){const y=i[1];t=E)break e}s=x,x=0;break i}break t}for(;x>>1;ti;)--s;if(++s,E!==0||s!==T){E>=s&&(s=Math.max(s,1),E=s-1);const y=this.getValueSize();this.times=x.slice(E,s),this.values=this.values.slice(E*y,s*y)}return this}validate(){let t=!0;const i=this.getValueSize();i-Math.floor(i)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const x=this.times,T=this.values,E=x.length;E===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let y=0;y!==E;y++){const e=x[y];if(typeof e=="number"&&isNaN(e)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,y,e),t=!1;break}if(s!==null&&s>e){console.error("THREE.KeyframeTrack: Out of order keys.",this,y,e,s),t=!1;break}s=e}if(T!==void 0&&tA(T))for(let y=0,e=T.length;y!==e;++y){const r=T[y];if(isNaN(r)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,y,r),t=!1;break}}return t}optimize(){const t=this.times.slice(),i=this.values.slice(),x=this.getValueSize(),T=this.getInterpolation()===am,E=t.length-1;let s=1;for(let y=1;y0){t[s]=t[E];for(let y=E*x,e=s*x,r=0;r!==x;++r)i[e+r]=i[y+r];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=i.slice(0,s*x)):(this.times=t,this.values=i),this}clone(){const t=this.times.slice(),i=this.values.slice(),x=this.constructor,T=new x(this.name,t,i);return T.createInterpolant=this.createInterpolant,T}}so.prototype.TimeBufferType=Float32Array;so.prototype.ValueBufferType=Float32Array;so.prototype.DefaultInterpolation=Ad;class Du extends so{}Du.prototype.ValueTypeName="bool";Du.prototype.ValueBufferType=Array;Du.prototype.DefaultInterpolation=wd;Du.prototype.InterpolantFactoryMethodLinear=void 0;Du.prototype.InterpolantFactoryMethodSmooth=void 0;class N1 extends so{}N1.prototype.ValueTypeName="color";class zd extends so{}zd.prototype.ValueTypeName="number";class rA extends np{constructor(t,i,x,T){super(t,i,x,T)}interpolate_(t,i,x,T){const E=this.resultBuffer,s=this.sampleValues,y=this.valueSize,e=(x-i)/(T-i);let r=t*y;for(let p=r+y;r!==p;r+=4)Ds.slerpFlat(E,0,s,r-y,s,r,e);return E}}class ac extends so{InterpolantFactoryMethodLinear(t){return new rA(this.times,this.values,this.getValueSize(),t)}}ac.prototype.ValueTypeName="quaternion";ac.prototype.DefaultInterpolation=Ad;ac.prototype.InterpolantFactoryMethodSmooth=void 0;class Iu extends so{}Iu.prototype.ValueTypeName="string";Iu.prototype.ValueBufferType=Array;Iu.prototype.DefaultInterpolation=wd;Iu.prototype.InterpolantFactoryMethodLinear=void 0;Iu.prototype.InterpolantFactoryMethodSmooth=void 0;class Gd extends so{}Gd.prototype.ValueTypeName="vector";class Vd{constructor(t,i=-1,x,T=ag){this.name=t,this.tracks=x,this.duration=i,this.blendMode=T,this.uuid=na(),this.duration<0&&this.resetDuration()}static parse(t){const i=[],x=t.tracks,T=1/(t.fps||1);for(let s=0,y=x.length;s!==y;++s)i.push(BU(x[s]).scale(T));const E=new this(t.name,t.duration,i,t.blendMode);return E.uuid=t.uuid,E}static toJSON(t){const i=[],x=t.tracks,T={name:t.name,duration:t.duration,tracks:i,uuid:t.uuid,blendMode:t.blendMode};for(let E=0,s=x.length;E!==s;++E)i.push(so.toJSON(x[E]));return T}static CreateFromMorphTargetSequence(t,i,x,T){const E=i.length,s=[];for(let y=0;y1){const h=p[1];let a=T[h];a||(T[h]=a=[]),a.push(r)}}const s=[];for(const y in T)s.push(this.CreateFromMorphTargetSequence(y,T[y],i,x));return s}static parseAnimation(t,i){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const x=function(h,a,l,n,u){if(l.length!==0){const f=[],o=[];D1(l,f,o,n),f.length!==0&&u.push(new h(a,f,o))}},T=[],E=t.name||"default",s=t.fps||30,y=t.blendMode;let e=t.length||-1;const r=t.hierarchy||[];for(let h=0;h{i&&i(E),this.manager.itemEnd(t)},0),E;if(pl[t]!==void 0){pl[t].push({onLoad:i,onProgress:x,onError:T});return}pl[t]=[],pl[t].push({onLoad:i,onProgress:x,onError:T});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),y=this.mimeType,e=this.responseType;fetch(s).then(r=>{if(r.status===200||r.status===0){if(r.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||r.body===void 0||r.body.getReader===void 0)return r;const p=pl[t],h=r.body.getReader(),a=r.headers.get("Content-Length")||r.headers.get("X-File-Size"),l=a?parseInt(a):0,n=l!==0;let u=0;const f=new ReadableStream({start(o){c();function c(){h.read().then(({done:d,value:v})=>{if(d)o.close();else{u+=v.byteLength;const m=new ProgressEvent("progress",{lengthComputable:n,loaded:u,total:l});for(let S=0,M=p.length;S{switch(e){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"document":return r.text().then(p=>new DOMParser().parseFromString(p,y));case"json":return r.json();default:if(y===void 0)return r.text();{const h=/charset="?([^;"\s]*)"?/i.exec(y),a=h&&h[1]?h[1].toLowerCase():void 0,l=new TextDecoder(a);return r.arrayBuffer().then(n=>l.decode(n))}}}).then(r=>{Sl.add(t,r);const p=pl[t];delete pl[t];for(let h=0,a=p.length;h{const p=pl[t];if(p===void 0)throw this.manager.itemError(t),r;delete pl[t];for(let h=0,a=p.length;h{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class zU extends Ns{constructor(t){super(t)}load(t,i,x,T){const E=this,s=new Al(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(y){try{i(E.parse(JSON.parse(y)))}catch(e){T?T(e):console.error(e),E.manager.itemError(t)}},x,T)}parse(t){const i=[];for(let x=0;x0:T.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const E in t.uniforms){const s=t.uniforms[E];switch(T.uniforms[E]={},s.type){case"t":T.uniforms[E].value=x(s.value);break;case"c":T.uniforms[E].value=new ze().setHex(s.value);break;case"v2":T.uniforms[E].value=new ve().fromArray(s.value);break;case"v3":T.uniforms[E].value=new Ct().fromArray(s.value);break;case"v4":T.uniforms[E].value=new sn().fromArray(s.value);break;case"m3":T.uniforms[E].value=new Oi().fromArray(s.value);break;case"m4":T.uniforms[E].value=new ci().fromArray(s.value);break;default:T.uniforms[E].value=s.value}}if(t.defines!==void 0&&(T.defines=t.defines),t.vertexShader!==void 0&&(T.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(T.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(T.glslVersion=t.glslVersion),t.extensions!==void 0)for(const E in t.extensions)T.extensions[E]=t.extensions[E];if(t.lights!==void 0&&(T.lights=t.lights),t.clipping!==void 0&&(T.clipping=t.clipping),t.size!==void 0&&(T.size=t.size),t.sizeAttenuation!==void 0&&(T.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(T.map=x(t.map)),t.matcap!==void 0&&(T.matcap=x(t.matcap)),t.alphaMap!==void 0&&(T.alphaMap=x(t.alphaMap)),t.bumpMap!==void 0&&(T.bumpMap=x(t.bumpMap)),t.bumpScale!==void 0&&(T.bumpScale=t.bumpScale),t.normalMap!==void 0&&(T.normalMap=x(t.normalMap)),t.normalMapType!==void 0&&(T.normalMapType=t.normalMapType),t.normalScale!==void 0){let E=t.normalScale;Array.isArray(E)===!1&&(E=[E,E]),T.normalScale=new ve().fromArray(E)}return t.displacementMap!==void 0&&(T.displacementMap=x(t.displacementMap)),t.displacementScale!==void 0&&(T.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(T.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(T.roughnessMap=x(t.roughnessMap)),t.metalnessMap!==void 0&&(T.metalnessMap=x(t.metalnessMap)),t.emissiveMap!==void 0&&(T.emissiveMap=x(t.emissiveMap)),t.emissiveIntensity!==void 0&&(T.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(T.specularMap=x(t.specularMap)),t.specularIntensityMap!==void 0&&(T.specularIntensityMap=x(t.specularIntensityMap)),t.specularColorMap!==void 0&&(T.specularColorMap=x(t.specularColorMap)),t.envMap!==void 0&&(T.envMap=x(t.envMap)),t.envMapIntensity!==void 0&&(T.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(T.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(T.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(T.lightMap=x(t.lightMap)),t.lightMapIntensity!==void 0&&(T.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(T.aoMap=x(t.aoMap)),t.aoMapIntensity!==void 0&&(T.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(T.gradientMap=x(t.gradientMap)),t.clearcoatMap!==void 0&&(T.clearcoatMap=x(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(T.clearcoatRoughnessMap=x(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(T.clearcoatNormalMap=x(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(T.clearcoatNormalScale=new ve().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(T.iridescenceMap=x(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(T.iridescenceThicknessMap=x(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(T.transmissionMap=x(t.transmissionMap)),t.thicknessMap!==void 0&&(T.thicknessMap=x(t.thicknessMap)),t.anisotropyMap!==void 0&&(T.anisotropyMap=x(t.anisotropyMap)),t.sheenColorMap!==void 0&&(T.sheenColorMap=x(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(T.sheenRoughnessMap=x(t.sheenRoughnessMap)),T}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){const i={ShadowMaterial:kw,SpriteMaterial:C1,RawShaderMaterial:Kw,ShaderMaterial:no,PointsMaterial:A1,MeshPhysicalMaterial:jw,MeshStandardMaterial:vl,MeshPhongMaterial:Zw,MeshToonMaterial:Jw,MeshNormalMaterial:$w,MeshLambertMaterial:Qw,MeshDepthMaterial:T1,MeshDistanceMaterial:E1,MeshBasicMaterial:xh,MeshMatcapMaterial:_w,LineDashedMaterial:qw,LineBasicMaterial:ys,Material:Hr};return new i[t]}}class Sx{static decodeText(t){if(typeof TextDecoder<"u")return new TextDecoder().decode(t);let i="";for(let x=0,T=t.length;x0){const e=new B1(i);E=new Hd(e),E.setCrossOrigin(this.crossOrigin);for(let r=0,p=t.length;r0){T=new Hd(this.manager),T.setCrossOrigin(this.crossOrigin);for(let s=0,y=t.length;s{const f=new gs;f.min.fromArray(u.boxMin),f.max.fromArray(u.boxMax);const o=new $r;return o.radius=u.sphereRadius,o.center.fromArray(u.sphereCenter),{boxInitialized:u.boxInitialized,box:f,sphereInitialized:u.sphereInitialized,sphere:o}}),s._maxGeometryCount=t.maxGeometryCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=r(t.matricesTexture.uuid);break;case"LOD":s=new bw;break;case"Line":s=new mh(y(t.geometry),e(t.material));break;case"LineLoop":s=new Dw(y(t.geometry),e(t.material));break;case"LineSegments":s=new Ho(y(t.geometry),e(t.material));break;case"PointCloud":case"Points":s=new Iw(y(t.geometry),e(t.material));break;case"Sprite":s=new Rw(e(t.material));break;case"Group":s=new Gf;break;case"Bone":s=new w1;break;default:s=new Yi}if(s.uuid=t.uuid,t.name!==void 0&&(s.name=t.name),t.matrix!==void 0?(s.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(t.position!==void 0&&s.position.fromArray(t.position),t.rotation!==void 0&&s.rotation.fromArray(t.rotation),t.quaternion!==void 0&&s.quaternion.fromArray(t.quaternion),t.scale!==void 0&&s.scale.fromArray(t.scale)),t.up!==void 0&&s.up.fromArray(t.up),t.castShadow!==void 0&&(s.castShadow=t.castShadow),t.receiveShadow!==void 0&&(s.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.bias!==void 0&&(s.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(s.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(s.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&s.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(s.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(s.visible=t.visible),t.frustumCulled!==void 0&&(s.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(s.renderOrder=t.renderOrder),t.userData!==void 0&&(s.userData=t.userData),t.layers!==void 0&&(s.layers.mask=t.layers),t.children!==void 0){const a=t.children;for(let l=0;l"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,i,x,T){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const E=this,s=Sl.get(t);if(s!==void 0){if(E.manager.itemStart(t),s.then){s.then(r=>{i&&i(r),E.manager.itemEnd(t)}).catch(r=>{T&&T(r)});return}return setTimeout(function(){i&&i(s),E.manager.itemEnd(t)},0),s}const y={};y.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",y.headers=this.requestHeader;const e=fetch(t,y).then(function(r){return r.blob()}).then(function(r){return createImageBitmap(r,Object.assign(E.options,{colorSpaceConversion:"none"}))}).then(function(r){return Sl.add(t,r),i&&i(r),E.manager.itemEnd(t),r}).catch(function(r){T&&T(r),Sl.remove(t),E.manager.itemError(t),E.manager.itemEnd(t)});Sl.add(t,e),E.manager.itemStart(t)}}let Gv,z1=class{static getContext(){return Gv===void 0&&(Gv=new(window.AudioContext||window.webkitAudioContext)),Gv}static setContext(t){Gv=t}};class ZU extends Ns{constructor(t){super(t)}load(t,i,x,T){const E=this,s=new Al(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(e){try{const r=e.slice(0);z1.getContext().decodeAudioData(r,function(h){i(h)}).catch(y)}catch(r){y(r)}},x,T);function y(e){T?T(e):console.error(e),E.manager.itemError(t)}}}const WE=new ci,XE=new ci,eu=new ci;class JU{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Or,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Or,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const i=this._cache;if(i.focus!==t.focus||i.fov!==t.fov||i.aspect!==t.aspect*this.aspect||i.near!==t.near||i.far!==t.far||i.zoom!==t.zoom||i.eyeSep!==this.eyeSep){i.focus=t.focus,i.fov=t.fov,i.aspect=t.aspect*this.aspect,i.near=t.near,i.far=t.far,i.zoom=t.zoom,i.eyeSep=this.eyeSep,eu.copy(t.projectionMatrix);const T=i.eyeSep/2,E=T*i.near/i.focus,s=i.near*Math.tan(xu*i.fov*.5)/i.zoom;let y,e;XE.elements[12]=-T,WE.elements[12]=T,y=-s*i.aspect+E,e=s*i.aspect+E,eu.elements[0]=2*i.near/(e-y),eu.elements[8]=(e+y)/(e-y),this.cameraL.projectionMatrix.copy(eu),y=-s*i.aspect-E,e=s*i.aspect-E,eu.elements[0]=2*i.near/(e-y),eu.elements[8]=(e+y)/(e-y),this.cameraR.projectionMatrix.copy(eu)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(XE),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(WE)}}class G1{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=YE(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const i=YE();t=(i-this.oldTime)/1e3,this.oldTime=i,this.elapsedTime+=t}return t}}function YE(){return(typeof performance>"u"?Date:performance).now()}const iu=new Ct,kE=new Ds,$U=new Ct,nu=new Ct;class QU extends Yi{constructor(){super(),this.type="AudioListener",this.context=z1.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new G1}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const i=this.context.listener,x=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(iu,kE,$U),nu.set(0,0,-1).applyQuaternion(kE),i.positionX){const T=this.context.currentTime+this.timeDelta;i.positionX.linearRampToValueAtTime(iu.x,T),i.positionY.linearRampToValueAtTime(iu.y,T),i.positionZ.linearRampToValueAtTime(iu.z,T),i.forwardX.linearRampToValueAtTime(nu.x,T),i.forwardY.linearRampToValueAtTime(nu.y,T),i.forwardZ.linearRampToValueAtTime(nu.z,T),i.upX.linearRampToValueAtTime(x.x,T),i.upY.linearRampToValueAtTime(x.y,T),i.upZ.linearRampToValueAtTime(x.z,T)}else i.setPosition(iu.x,iu.y,iu.z),i.setOrientation(nu.x,nu.y,nu.z,x.x,x.y,x.z)}}let gA=class extends Yi{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const i=this.context.createBufferSource();return i.buffer=this.buffer,i.loop=this.loop,i.loopStart=this.loopStart,i.loopEnd=this.loopEnd,i.onended=this.onEnded.bind(this),i.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=i,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,i=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,i=this.filters.length;t0&&this._mixBufferRegionAdditive(x,T,this._addIndex*i,1,i);for(let e=i,r=i+i;e!==r;++e)if(x[e]!==x[e+i]){y.setValue(x,T);break}}saveOriginalState(){const t=this.binding,i=this.buffer,x=this.valueSize,T=x*this._origIndex;t.getValue(i,T);for(let E=x,s=T;E!==s;++E)i[E]=i[T+E%x];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,i=t+this.valueSize;for(let x=t;x=.5)for(let s=0;s!==E;++s)t[i+s]=t[x+s]}_slerp(t,i,x,T){Ds.slerpFlat(t,i,t,i,t,x,T)}_slerpAdditive(t,i,x,T,E){const s=this._workIndex*E;Ds.multiplyQuaternionsFlat(t,s,t,i,t,x),Ds.slerpFlat(t,i,t,i,t,s,T)}_lerp(t,i,x,T,E){const s=1-T;for(let y=0;y!==E;++y){const e=i+y;t[e]=t[e]*s+t[x+y]*T}}_lerpAdditive(t,i,x,T,E){for(let s=0;s!==E;++s){const y=i+s;t[y]=t[y]+t[x+s]*T}}}const V1="\\[\\]\\.:\\/",e7=new RegExp("["+V1+"]","g"),H1="[^"+V1+"]",i7="[^"+V1.replace("\\.","")+"]",n7=/((?:WC+[\/:])*)/.source.replace("WC",H1),r7=/(WCOD+)?/.source.replace("WCOD",i7),s7=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",H1),a7=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",H1),o7=new RegExp("^"+n7+r7+s7+a7+"$"),l7=["material","materials","bones","map"];class h7{constructor(t,i,x){const T=x||Xi.parseTrackName(i);this._targetGroup=t,this._bindings=t.subscribe_(i,T)}getValue(t,i){this.bind();const x=this._targetGroup.nCachedObjects_,T=this._bindings[x];T!==void 0&&T.getValue(t,i)}setValue(t,i){const x=this._bindings;for(let T=this._targetGroup.nCachedObjects_,E=x.length;T!==E;++T)x[T].setValue(t,i)}bind(){const t=this._bindings;for(let i=this._targetGroup.nCachedObjects_,x=t.length;i!==x;++i)t[i].bind()}unbind(){const t=this._bindings;for(let i=this._targetGroup.nCachedObjects_,x=t.length;i!==x;++i)t[i].unbind()}}class Xi{constructor(t,i,x){this.path=i,this.parsedPath=x||Xi.parseTrackName(i),this.node=Xi.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,i,x){return t&&t.isAnimationObjectGroup?new Xi.Composite(t,i,x):new Xi(t,i,x)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(e7,"")}static parseTrackName(t){const i=o7.exec(t);if(i===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const x={nodeName:i[2],objectName:i[3],objectIndex:i[4],propertyName:i[5],propertyIndex:i[6]},T=x.nodeName&&x.nodeName.lastIndexOf(".");if(T!==void 0&&T!==-1){const E=x.nodeName.substring(T+1);l7.indexOf(E)!==-1&&(x.nodeName=x.nodeName.substring(0,T),x.objectName=E)}if(x.propertyName===null||x.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return x}static findNode(t,i){if(i===void 0||i===""||i==="."||i===-1||i===t.name||i===t.uuid)return t;if(t.skeleton){const x=t.skeleton.getBoneByName(i);if(x!==void 0)return x}if(t.children){const x=function(E){for(let s=0;s=E){const h=E++,a=t[h];i[a.uuid]=p,t[p]=a,i[r]=h,t[h]=e;for(let l=0,n=T;l!==n;++l){const u=x[l],f=u[h],o=u[p];u[p]=f,u[h]=o}}}this.nCachedObjects_=E}uncache(){const t=this._objects,i=this._indicesByUUID,x=this._bindings,T=x.length;let E=this.nCachedObjects_,s=t.length;for(let y=0,e=arguments.length;y!==e;++y){const r=arguments[y],p=r.uuid,h=i[p];if(h!==void 0)if(delete i[p],h0&&(i[l.uuid]=h),t[h]=l,t.pop();for(let n=0,u=T;n!==u;++n){const f=x[n];f[h]=f[a],f.pop()}}}this.nCachedObjects_=E}subscribe_(t,i){const x=this._bindingsIndicesByPath;let T=x[t];const E=this._bindings;if(T!==void 0)return E[T];const s=this._paths,y=this._parsedPaths,e=this._objects,r=e.length,p=this.nCachedObjects_,h=new Array(r);T=E.length,x[t]=T,s.push(t),y.push(i),E.push(h);for(let a=p,l=e.length;a!==l;++a){const n=e[a];h[a]=new Xi(n,t,i)}return h}unsubscribe_(t){const i=this._bindingsIndicesByPath,x=i[t];if(x!==void 0){const T=this._paths,E=this._parsedPaths,s=this._bindings,y=s.length-1,e=s[y],r=t[y];i[r]=x,s[x]=e,s.pop(),E[x]=E[y],E.pop(),T[x]=T[y],T.pop()}}}class xA{constructor(t,i,x=null,T=i.blendMode){this._mixer=t,this._clip=i,this._localRoot=x,this.blendMode=T;const E=i.tracks,s=E.length,y=new Array(s),e={endingStart:pu,endingEnd:pu};for(let r=0;r!==s;++r){const p=E[r].createInterpolant(null);y[r]=p,p.settings=e}this._interpolantSettings=e,this._interpolants=y,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=_2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,i){return this.loop=t,this.repetitions=i,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,i,x){if(t.fadeOut(i),this.fadeIn(i),x){const T=this._clip.duration,E=t._clip.duration,s=E/T,y=T/E;t.warp(1,s,i),this.warp(y,1,i)}return this}crossFadeTo(t,i,x){return t.crossFadeFrom(this,i,x)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,i,x){const T=this._mixer,E=T.time,s=this.timeScale;let y=this._timeScaleInterpolant;y===null&&(y=T._lendControlInterpolant(),this._timeScaleInterpolant=y);const e=y.parameterPositions,r=y.sampleValues;return e[0]=E,e[1]=E+x,r[0]=t/s,r[1]=i/s,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,i,x,T){if(!this.enabled){this._updateWeight(t);return}const E=this._startTime;if(E!==null){const e=(t-E)*x;e<0||x===0?i=0:(this._startTime=null,i=x*e)}i*=this._updateTimeScale(t);const s=this._updateTime(i),y=this._updateWeight(t);if(y>0){const e=this._interpolants,r=this._propertyBindings;switch(this.blendMode){case f1:for(let p=0,h=e.length;p!==h;++p)e[p].evaluate(s),r[p].accumulateAdditive(y);break;case ag:default:for(let p=0,h=e.length;p!==h;++p)e[p].evaluate(s),r[p].accumulate(T,y)}}}_updateWeight(t){let i=0;if(this.enabled){i=this.weight;const x=this._weightInterpolant;if(x!==null){const T=x.evaluate(t)[0];i*=T,t>x.parameterPositions[1]&&(this.stopFading(),T===0&&(this.enabled=!1))}}return this._effectiveWeight=i,i}_updateTimeScale(t){let i=0;if(!this.paused){i=this.timeScale;const x=this._timeScaleInterpolant;if(x!==null){const T=x.evaluate(t)[0];i*=T,t>x.parameterPositions[1]&&(this.stopWarping(),i===0?this.paused=!0:this.timeScale=i)}}return this._effectiveTimeScale=i,i}_updateTime(t){const i=this._clip.duration,x=this.loop;let T=this.time+t,E=this._loopCount;const s=x===q2;if(t===0)return E===-1?T:s&&(E&1)===1?i-T:T;if(x===Q2){E===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(T>=i)T=i;else if(T<0)T=0;else{this.time=T;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=T,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(E===-1&&(t>=0?(E=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),T>=i||T<0){const y=Math.floor(T/i);T-=i*y,E+=Math.abs(y);const e=this.repetitions-E;if(e<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,T=t>0?i:0,this.time=T,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(e===1){const r=t<0;this._setEndings(r,!r,s)}else this._setEndings(!1,!1,s);this._loopCount=E,this.time=T,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:y})}}else this.time=T;if(s&&(E&1)===1)return i-T}return T}_setEndings(t,i,x){const T=this._interpolantSettings;x?(T.endingStart=vu,T.endingEnd=vu):(t?T.endingStart=this.zeroSlopeAtStart?vu:pu:T.endingStart=Pd,i?T.endingEnd=this.zeroSlopeAtEnd?vu:pu:T.endingEnd=Pd)}_scheduleFading(t,i,x){const T=this._mixer,E=T.time;let s=this._weightInterpolant;s===null&&(s=T._lendControlInterpolant(),this._weightInterpolant=s);const y=s.parameterPositions,e=s.sampleValues;return y[0]=E,e[0]=i,y[1]=E+t,e[1]=x,this}}const f7=new Float32Array(1);class c7 extends Pl{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,i){const x=t._localRoot||this._root,T=t._clip.tracks,E=T.length,s=t._propertyBindings,y=t._interpolants,e=x.uuid,r=this._bindingsByRootAndName;let p=r[e];p===void 0&&(p={},r[e]=p);for(let h=0;h!==E;++h){const a=T[h],l=a.name;let n=p[l];if(n!==void 0)++n.referenceCount,s[h]=n;else{if(n=s[h],n!==void 0){n._cacheIndex===null&&(++n.referenceCount,this._addInactiveBinding(n,e,l));continue}const u=i&&i._propertyBindings[h].binding.parsedPath;n=new yA(Xi.create(x,l,u),a.ValueTypeName,a.getValueSize()),++n.referenceCount,this._addInactiveBinding(n,e,l),s[h]=n}y[h].resultBuffer=n.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const x=(t._localRoot||this._root).uuid,T=t._clip.uuid,E=this._actionsByClip[T];this._bindAction(t,E&&E.knownActions[0]),this._addInactiveAction(t,T,x)}const i=t._propertyBindings;for(let x=0,T=i.length;x!==T;++x){const E=i[x];E.useCount++===0&&(this._lendBinding(E),E.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const i=t._propertyBindings;for(let x=0,T=i.length;x!==T;++x){const E=i[x];--E.useCount===0&&(E.restoreOriginalState(),this._takeBackBinding(E))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const i=t._cacheIndex;return i!==null&&i=0;--x)t[x].stop();return this}update(t){t*=this.timeScale;const i=this._actions,x=this._nActiveActions,T=this.time+=t,E=Math.sign(t),s=this._accuIndex^=1;for(let r=0;r!==x;++r)i[r]._update(T,t,E,s);const y=this._bindings,e=this._nActiveBindings;for(let r=0;r!==e;++r)y[r].apply(s);return this}setTime(t){this.time=0;for(let i=0;ithis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,i){return i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,i){return i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ZE).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const JE=new Ct,Vv=new Ct;class S7{constructor(t=new Ct,i=new Ct){this.start=t,this.end=i}set(t,i){return this.start.copy(t),this.end.copy(i),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,i){return this.delta(i).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,i){JE.subVectors(t,this.start),Vv.subVectors(this.end,this.start);const x=Vv.dot(Vv);let E=Vv.dot(JE)/x;return i&&(E=jn(E,0,1)),E}closestPointToPoint(t,i,x){const T=this.closestPointToPointParameter(t,i);return this.delta(x).multiplyScalar(T).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const $E=new Ct;class T7 extends Yi{constructor(t,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="SpotLightHelper";const x=new Li,T=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,y=1,e=32;s1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{eM.set(t.z,0,-t.x).normalize();const i=Math.acos(t.y);this.quaternion.setFromAxisAngle(eM,i)}}setLength(t,i=t*.2,x=i*.2){this.line.scale.set(1,Math.max(1e-4,t-i),1),this.line.updateMatrix(),this.cone.scale.set(x,i,x),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class I7 extends Ho{constructor(t=1){const i=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],x=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],T=new Li;T.setAttribute("position",new ke(i,3)),T.setAttribute("color",new ke(x,3));const E=new ys({vertexColors:!0,toneMapped:!1});super(T,E),this.type="AxesHelper"}setColors(t,i,x){const T=new ze,E=this.geometry.attributes.color.array;return T.set(t),T.toArray(E,0),T.toArray(E,3),T.set(i),T.toArray(E,6),T.toArray(E,9),T.set(x),T.toArray(E,12),T.toArray(E,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class N7{constructor(){this.type="ShapePath",this.color=new ze,this.subPaths=[],this.currentPath=null}moveTo(t,i){return this.currentPath=new Id,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,i),this}lineTo(t,i){return this.currentPath.lineTo(t,i),this}quadraticCurveTo(t,i,x,T){return this.currentPath.quadraticCurveTo(t,i,x,T),this}bezierCurveTo(t,i,x,T,E,s){return this.currentPath.bezierCurveTo(t,i,x,T,E,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function i(o){const c=[];for(let d=0,v=o.length;dNumber.EPSILON){if(A<0&&(M=c[S],C=-C,w=c[m],A=-A),o.yw.y)continue;if(o.y===M.y){if(o.x===M.x)return!0}else{const P=A*(o.x-M.x)-C*(o.y-M.y);if(P===0)return!0;if(P<0)continue;v=!v}}else{if(o.y!==M.y)continue;if(w.x<=o.x&&o.x<=M.x||M.x<=o.x&&o.x<=w.x)return!0}}return v}const T=zo.isClockWise,E=this.subPaths;if(E.length===0)return[];let s,y,e;const r=[];if(E.length===1)return y=E[0],e=new Mu,e.curves=y.curves,r.push(e),r;let p=!T(E[0].getPoints());p=t?!p:p;const h=[],a=[];let l=[],n=0,u;a[n]=void 0,l[n]=[];for(let o=0,c=E.length;o1){let o=!1,c=0;for(let d=0,v=a.length;d0&&o===!1&&(l=h)}let f;for(let o=0,c=a.length;o=0&&(v[J]=null,d[J].disconnect(H))}for(let U=0;U=v.length){v.push(H),J=q;break}else if(v[q]===null){v[q]=H,J=q;break}if(J===-1)break}const _=d[J];_&&_.connect(H)}}const B=new Ct,G=new Ct;function z(Z,U,H){B.setFromMatrixPosition(U.matrixWorld),G.setFromMatrixPosition(H.matrixWorld);const J=B.distanceTo(G),_=U.projectionMatrix.elements,q=H.projectionMatrix.elements,at=_[14]/(_[10]-1),ot=_[14]/(_[10]+1),rt=(_[9]+1)/_[5],gt=(_[9]-1)/_[5],yt=(_[8]-1)/_[0],Et=(q[8]+1)/q[0],At=at*yt,Pt=at*Et,Vt=J/(-yt+Et),dt=Vt*-yt;U.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(dt),Z.translateZ(Vt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const ut=at+Vt,Rt=ot+Vt,Dt=At-dt,Ht=Pt+(J-dt),Bt=rt*ot/Rt*ut,ne=gt*ot/Rt*ut;Z.projectionMatrix.makePerspective(Dt,Ht,Bt,ne,ut,Rt),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function X(Z,U){U===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(U.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(T===null)return;u.texture!==null&&(Z.near=u.depthNear,Z.far=u.depthFar),A.near=w.near=M.near=Z.near,A.far=w.far=M.far=Z.far,(P!==A.near||b!==A.far)&&(T.updateRenderState({depthNear:A.near,depthFar:A.far}),P=A.near,b=A.far,M.near=P,M.far=b,w.near=P,w.far=b,M.updateProjectionMatrix(),w.updateProjectionMatrix(),Z.updateProjectionMatrix());const U=Z.parent,H=A.cameras;X(A,U);for(let J=0;J0&&(f.alphaTest.value=o.alphaTest);const c=t.get(o).envMap;if(c&&(f.envMap.value=c,f.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=o.reflectivity,f.ior.value=o.ior,f.refractionRatio.value=o.refractionRatio),o.lightMap){f.lightMap.value=o.lightMap;const d=g._useLegacyLights===!0?Math.PI:1;f.lightMapIntensity.value=o.lightMapIntensity*d,i(o.lightMap,f.lightMapTransform)}o.aoMap&&(f.aoMap.value=o.aoMap,f.aoMapIntensity.value=o.aoMapIntensity,i(o.aoMap,f.aoMapTransform))}function s(f,o){f.diffuse.value.copy(o.color),f.opacity.value=o.opacity,o.map&&(f.map.value=o.map,i(o.map,f.mapTransform))}function y(f,o){f.dashSize.value=o.dashSize,f.totalSize.value=o.dashSize+o.gapSize,f.scale.value=o.scale}function e(f,o,c,d){f.diffuse.value.copy(o.color),f.opacity.value=o.opacity,f.size.value=o.size*c,f.scale.value=d*.5,o.map&&(f.map.value=o.map,i(o.map,f.uvTransform)),o.alphaMap&&(f.alphaMap.value=o.alphaMap,i(o.alphaMap,f.alphaMapTransform)),o.alphaTest>0&&(f.alphaTest.value=o.alphaTest)}function r(f,o){f.diffuse.value.copy(o.color),f.opacity.value=o.opacity,f.rotation.value=o.rotation,o.map&&(f.map.value=o.map,i(o.map,f.mapTransform)),o.alphaMap&&(f.alphaMap.value=o.alphaMap,i(o.alphaMap,f.alphaMapTransform)),o.alphaTest>0&&(f.alphaTest.value=o.alphaTest)}function p(f,o){f.specular.value.copy(o.specular),f.shininess.value=Math.max(o.shininess,1e-4)}function h(f,o){o.gradientMap&&(f.gradientMap.value=o.gradientMap)}function a(f,o){f.metalness.value=o.metalness,o.metalnessMap&&(f.metalnessMap.value=o.metalnessMap,i(o.metalnessMap,f.metalnessMapTransform)),f.roughness.value=o.roughness,o.roughnessMap&&(f.roughnessMap.value=o.roughnessMap,i(o.roughnessMap,f.roughnessMapTransform)),t.get(o).envMap&&(f.envMapIntensity.value=o.envMapIntensity)}function l(f,o,c){f.ior.value=o.ior,o.sheen>0&&(f.sheenColor.value.copy(o.sheenColor).multiplyScalar(o.sheen),f.sheenRoughness.value=o.sheenRoughness,o.sheenColorMap&&(f.sheenColorMap.value=o.sheenColorMap,i(o.sheenColorMap,f.sheenColorMapTransform)),o.sheenRoughnessMap&&(f.sheenRoughnessMap.value=o.sheenRoughnessMap,i(o.sheenRoughnessMap,f.sheenRoughnessMapTransform))),o.clearcoat>0&&(f.clearcoat.value=o.clearcoat,f.clearcoatRoughness.value=o.clearcoatRoughness,o.clearcoatMap&&(f.clearcoatMap.value=o.clearcoatMap,i(o.clearcoatMap,f.clearcoatMapTransform)),o.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=o.clearcoatRoughnessMap,i(o.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),o.clearcoatNormalMap&&(f.clearcoatNormalMap.value=o.clearcoatNormalMap,i(o.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(o.clearcoatNormalScale),o.side===ms&&f.clearcoatNormalScale.value.negate())),o.iridescence>0&&(f.iridescence.value=o.iridescence,f.iridescenceIOR.value=o.iridescenceIOR,f.iridescenceThicknessMinimum.value=o.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=o.iridescenceThicknessRange[1],o.iridescenceMap&&(f.iridescenceMap.value=o.iridescenceMap,i(o.iridescenceMap,f.iridescenceMapTransform)),o.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=o.iridescenceThicknessMap,i(o.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),o.transmission>0&&(f.transmission.value=o.transmission,f.transmissionSamplerMap.value=c.texture,f.transmissionSamplerSize.value.set(c.width,c.height),o.transmissionMap&&(f.transmissionMap.value=o.transmissionMap,i(o.transmissionMap,f.transmissionMapTransform)),f.thickness.value=o.thickness,o.thicknessMap&&(f.thicknessMap.value=o.thicknessMap,i(o.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=o.attenuationDistance,f.attenuationColor.value.copy(o.attenuationColor)),o.anisotropy>0&&(f.anisotropyVector.value.set(o.anisotropy*Math.cos(o.anisotropyRotation),o.anisotropy*Math.sin(o.anisotropyRotation)),o.anisotropyMap&&(f.anisotropyMap.value=o.anisotropyMap,i(o.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=o.specularIntensity,f.specularColor.value.copy(o.specularColor),o.specularColorMap&&(f.specularColorMap.value=o.specularColorMap,i(o.specularColorMap,f.specularColorMapTransform)),o.specularIntensityMap&&(f.specularIntensityMap.value=o.specularIntensityMap,i(o.specularIntensityMap,f.specularIntensityMapTransform))}function n(f,o){o.matcap&&(f.matcap.value=o.matcap)}function u(f,o){const c=t.get(o).light;f.referencePosition.value.setFromMatrixPosition(c.matrixWorld),f.nearDistance.value=c.shadow.camera.near,f.farDistance.value=c.shadow.camera.far}return{refreshFogUniforms:x,refreshMaterialUniforms:T}}function k6(g,t,i,x){let T={},E={},s=[];const y=i.isWebGL2?g.getParameter(g.MAX_UNIFORM_BUFFER_BINDINGS):0;function e(c,d){const v=d.program;x.uniformBlockBinding(c,v)}function r(c,d){let v=T[c.id];v===void 0&&(n(c),v=p(c),T[c.id]=v,c.addEventListener("dispose",f));const m=d.program;x.updateUBOMapping(c,m);const S=t.render.frame;E[c.id]!==S&&(a(c),E[c.id]=S)}function p(c){const d=h();c.__bindingPointIndex=d;const v=g.createBuffer(),m=c.__size,S=c.usage;return g.bindBuffer(g.UNIFORM_BUFFER,v),g.bufferData(g.UNIFORM_BUFFER,m,S),g.bindBuffer(g.UNIFORM_BUFFER,null),g.bindBufferBase(g.UNIFORM_BUFFER,d,v),v}function h(){for(let c=0;c0&&(v+=m-S),c.__size=v,c.__cache={},this}function u(c){const d={boundary:0,storage:0};return typeof c=="number"||typeof c=="boolean"?(d.boundary=4,d.storage=4):c.isVector2?(d.boundary=8,d.storage=8):c.isVector3||c.isColor?(d.boundary=16,d.storage=12):c.isVector4?(d.boundary=16,d.storage=16):c.isMatrix3?(d.boundary=48,d.storage=48):c.isMatrix4?(d.boundary=64,d.storage=64):c.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",c),d}function f(c){const d=c.target;d.removeEventListener("dispose",f);const v=s.indexOf(d.__bindingPointIndex);s.splice(v,1),g.deleteBuffer(T[d.id]),delete T[d.id],delete E[d.id]}function o(){for(const c in T)g.deleteBuffer(T[c]);s=[],T={},E={}}return{bind:e,update:r,dispose:o}}class M1{constructor(t={}){const{canvas:i=fw(),context:x=null,depth:T=!0,stencil:E=!0,alpha:s=!1,antialias:y=!1,premultipliedAlpha:e=!0,preserveDrawingBuffer:r=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:h=!1}=t;this.isWebGLRenderer=!0;let a;x!==null?a=x.getContextAttributes().alpha:a=s;const l=new Uint32Array(4),n=new Int32Array(4);let u=null,f=null;const o=[],c=[];this.domElement=i,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=vr,this._useLegacyLights=!1,this.toneMapping=Bo,this.toneMappingExposure=1;const d=this;let v=!1,m=0,S=0,M=null,w=-1,C=null;const A=new sn,P=new sn;let b=null;const O=new ze(0);let I=0,D=i.width,B=i.height,G=1,z=null,X=null;const K=new sn(0,0,D,B),Q=new sn(0,0,D,B);let tt=!1;const Y=new _d;let Z=!1,U=!1,H=null;const J=new ci,_=new ve,q=new Ct,at={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ot(){return M===null?G:1}let rt=x;function gt(Tt,jt){for(let _t=0;_t{function Te(){if(ee.forEach(function(Ue){Vt.get(Ue).currentProgram.isReady()&&ee.delete(Ue)}),ee.size===0){te(Tt);return}setTimeout(Te,10)}yt.get("KHR_parallel_shader_compile")!==null?Te():setTimeout(Te,10)})};let Di=null;function en(Tt){Di&&Di(Tt)}function Zn(){di.stop()}function Gi(){di.start()}const di=new yw;di.setAnimationLoop(en),typeof self<"u"&&di.setContext(self),this.setAnimationLoop=function(Tt){Di=Tt,le.setAnimationLoop(Tt),Tt===null?di.stop():di.start()},le.addEventListener("sessionstart",Zn),le.addEventListener("sessionend",Gi),this.render=function(Tt,jt){if(jt!==void 0&&jt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;Tt.matrixWorldAutoUpdate===!0&&Tt.updateMatrixWorld(),jt.parent===null&&jt.matrixWorldAutoUpdate===!0&&jt.updateMatrixWorld(),le.enabled===!0&&le.isPresenting===!0&&(le.cameraAutoUpdate===!0&&le.updateCamera(jt),jt=le.getCamera()),Tt.isScene===!0&&Tt.onBeforeRender(d,Tt,jt,M),f=xe.get(Tt,c.length),f.init(),c.push(f),J.multiplyMatrices(jt.projectionMatrix,jt.matrixWorldInverse),Y.setFromProjectionMatrix(J),U=this.localClippingEnabled,Z=Ae.init(this.clippingPlanes,U),u=ge.get(Tt,o.length),u.init(),o.push(u),Wi(Tt,jt,0,d.sortObjects),u.finish(),d.sortObjects===!0&&u.sort(z,X),this.info.render.frame++,Z===!0&&Ae.beginShadows();const _t=f.state.shadowsArray;if(qt.render(_t,Tt,jt),Z===!0&&Ae.endShadows(),this.info.autoReset===!0&&this.info.reset(),(le.enabled===!1||le.isPresenting===!1||le.hasDepthSensing()===!1)&&Ge.render(u,Tt),f.setupLights(d._useLegacyLights),jt.isArrayCamera){const ee=jt.cameras;for(let te=0,Te=ee.length;te0?f=c[c.length-1]:f=null,o.pop(),o.length>0?u=o[o.length-1]:u=null};function Wi(Tt,jt,_t,ee){if(Tt.visible===!1)return;if(Tt.layers.test(jt.layers)){if(Tt.isGroup)_t=Tt.renderOrder;else if(Tt.isLOD)Tt.autoUpdate===!0&&Tt.update(jt);else if(Tt.isLight)f.pushLight(Tt),Tt.castShadow&&f.pushShadow(Tt);else if(Tt.isSprite){if(!Tt.frustumCulled||Y.intersectsSprite(Tt)){ee&&q.setFromMatrixPosition(Tt.matrixWorld).applyMatrix4(J);const Ue=Bt.update(Tt),We=Tt.material;We.visible&&u.push(Tt,Ue,We,_t,q.z,null)}}else if((Tt.isMesh||Tt.isLine||Tt.isPoints)&&(!Tt.frustumCulled||Y.intersectsObject(Tt))){const Ue=Bt.update(Tt),We=Tt.material;if(ee&&(Tt.boundingSphere!==void 0?(Tt.boundingSphere===null&&Tt.computeBoundingSphere(),q.copy(Tt.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),q.copy(Ue.boundingSphere.center)),q.applyMatrix4(Tt.matrixWorld).applyMatrix4(J)),Array.isArray(We)){const $e=Ue.groups;for(let qe=0,ii=$e.length;qe0&&aa(te,Te,jt,_t),ee&&At.viewport(A.copy(ee)),te.length>0&&Bs(te,jt,_t),Te.length>0&&Bs(Te,jt,_t),Ue.length>0&&Bs(Ue,jt,_t),At.buffers.depth.setTest(!0),At.buffers.depth.setMask(!0),At.buffers.color.setMask(!0),At.setPolygonOffset(!1)}function aa(Tt,jt,_t,ee){if((_t.isScene===!0?_t.overrideMaterial:null)!==null)return;const Te=Et.isWebGL2;H===null&&(H=new io(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")?Zf:Uo,minFilter:Io,samples:Te?4:0})),d.getDrawingBufferSize(_),Te?H.setSize(_.x,_.y):H.setSize(Em(_.x),Em(_.y));const Ue=d.getRenderTarget();d.setRenderTarget(H),d.getClearColor(O),I=d.getClearAlpha(),I<1&&d.setClearColor(16777215,.5),d.clear();const We=d.toneMapping;d.toneMapping=Bo,Bs(Tt,_t,ee),dt.updateMultisampleRenderTarget(H),dt.updateRenderTargetMipmap(H);let $e=!1;for(let qe=0,ii=jt.length;qe0),ai=!!_t.morphAttributes.position,Ji=!!_t.morphAttributes.normal,hn=!!_t.morphAttributes.color;let ki=Bo;ee.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(ki=d.toneMapping);const gn=_t.morphAttributes.position||_t.morphAttributes.normal||_t.morphAttributes.color,ti=gn!==void 0?gn.length:0,Se=Vt.get(ee),Nr=f.state.lights;if(Z===!0&&(U===!0||Tt!==C)){const Tn=Tt===C&&ee.id===w;Ae.setState(ee,Tt,Tn)}let mi=!1;ee.version===Se.__version?(Se.needsLights&&Se.lightsStateVersion!==Nr.state.version||Se.outputColorSpace!==We||te.isBatchedMesh&&Se.batching===!1||!te.isBatchedMesh&&Se.batching===!0||te.isInstancedMesh&&Se.instancing===!1||!te.isInstancedMesh&&Se.instancing===!0||te.isSkinnedMesh&&Se.skinning===!1||!te.isSkinnedMesh&&Se.skinning===!0||te.isInstancedMesh&&Se.instancingColor===!0&&te.instanceColor===null||te.isInstancedMesh&&Se.instancingColor===!1&&te.instanceColor!==null||Se.envMap!==$e||ee.fog===!0&&Se.fog!==Te||Se.numClippingPlanes!==void 0&&(Se.numClippingPlanes!==Ae.numPlanes||Se.numIntersection!==Ae.numIntersection)||Se.vertexAlphas!==qe||Se.vertexTangents!==ii||Se.morphTargets!==ai||Se.morphNormals!==Ji||Se.morphColors!==hn||Se.toneMapping!==ki||Et.isWebGL2===!0&&Se.morphTargetsCount!==ti)&&(mi=!0):(mi=!0,Se.__version=ee.version);let un=Se.currentProgram;mi===!0&&(un=ao(ee,jt,te));let Ii=!1,Gn=!1,pn=!1;const Ki=un.getUniforms(),dr=Se.uniforms;if(At.useProgram(un.program)&&(Ii=!0,Gn=!0,pn=!0),ee.id!==w&&(w=ee.id,Gn=!0),Ii||C!==Tt){Ki.setValue(rt,"projectionMatrix",Tt.projectionMatrix),Ki.setValue(rt,"viewMatrix",Tt.matrixWorldInverse);const Tn=Ki.map.cameraPosition;Tn!==void 0&&Tn.setValue(rt,q.setFromMatrixPosition(Tt.matrixWorld)),Et.logarithmicDepthBuffer&&Ki.setValue(rt,"logDepthBufFC",2/(Math.log(Tt.far+1)/Math.LN2)),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&Ki.setValue(rt,"isOrthographic",Tt.isOrthographicCamera===!0),C!==Tt&&(C=Tt,Gn=!0,pn=!0)}if(te.isSkinnedMesh){Ki.setOptional(rt,te,"bindMatrix"),Ki.setOptional(rt,te,"bindMatrixInverse");const Tn=te.skeleton;Tn&&(Et.floatVertexTextures?(Tn.boneTexture===null&&Tn.computeBoneTexture(),Ki.setValue(rt,"boneTexture",Tn.boneTexture,dt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}te.isBatchedMesh&&(Ki.setOptional(rt,te,"batchingTexture"),Ki.setValue(rt,"batchingTexture",te._matricesTexture,dt));const zs=_t.morphAttributes;if((zs.position!==void 0||zs.normal!==void 0||zs.color!==void 0&&Et.isWebGL2===!0)&&Oe.update(te,_t,un),(Gn||Se.receiveShadow!==te.receiveShadow)&&(Se.receiveShadow=te.receiveShadow,Ki.setValue(rt,"receiveShadow",te.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(dr.envMap.value=$e,dr.flipEnvMap.value=$e.isCubeTexture&&$e.isRenderTargetTexture===!1?-1:1),Gn&&(Ki.setValue(rt,"toneMappingExposure",d.toneMappingExposure),Se.needsLights&&oo(dr,pn),Te&&ee.fog===!0&&oe.refreshFogUniforms(dr,Te),oe.refreshMaterialUniforms(dr,ee,G,B,H),lm.upload(rt,_r(Se),dr,dt)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(lm.upload(rt,_r(Se),dr,dt),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&Ki.setValue(rt,"center",te.center),Ki.setValue(rt,"modelViewMatrix",te.modelViewMatrix),Ki.setValue(rt,"normalMatrix",te.normalMatrix),Ki.setValue(rt,"modelMatrix",te.matrixWorld),ee.isShaderMaterial||ee.isRawShaderMaterial){const Tn=ee.uniformsGroups;for(let oa=0,Jn=Tn.length;oa0&&dt.useMultisampledRTT(Tt)===!1?te=Vt.get(Tt).__webglMultisampledFramebuffer:Array.isArray(ii)?te=ii[_t]:te=ii,A.copy(Tt.viewport),P.copy(Tt.scissor),b=Tt.scissorTest}else A.copy(K).multiplyScalar(G).floor(),P.copy(Q).multiplyScalar(G).floor(),b=tt;if(At.bindFramebuffer(rt.FRAMEBUFFER,te)&&Et.drawBuffers&&ee&&At.drawBuffers(Tt,te),At.viewport(A),At.scissor(P),At.setScissorTest(b),Te){const $e=Vt.get(Tt.texture);rt.framebufferTexture2D(rt.FRAMEBUFFER,rt.COLOR_ATTACHMENT0,rt.TEXTURE_CUBE_MAP_POSITIVE_X+jt,$e.__webglTexture,_t)}else if(Ue){const $e=Vt.get(Tt.texture),qe=jt||0;rt.framebufferTextureLayer(rt.FRAMEBUFFER,rt.COLOR_ATTACHMENT0,$e.__webglTexture,_t||0,qe)}w=-1},this.readRenderTargetPixels=function(Tt,jt,_t,ee,te,Te,Ue){if(!(Tt&&Tt.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let We=Vt.get(Tt).__webglFramebuffer;if(Tt.isWebGLCubeRenderTarget&&Ue!==void 0&&(We=We[Ue]),We){At.bindFramebuffer(rt.FRAMEBUFFER,We);try{const $e=Tt.texture,qe=$e.format,ii=$e.type;if(qe!==ps&&ie.convert(qe)!==rt.getParameter(rt.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ai=ii===Zf&&(yt.has("EXT_color_buffer_half_float")||Et.isWebGL2&&yt.has("EXT_color_buffer_float"));if(ii!==Uo&&ie.convert(ii)!==rt.getParameter(rt.IMPLEMENTATION_COLOR_READ_TYPE)&&!(ii===Ea&&(Et.isWebGL2||yt.has("OES_texture_float")||yt.has("WEBGL_color_buffer_float")))&&!ai){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}jt>=0&&jt<=Tt.width-ee&&_t>=0&&_t<=Tt.height-te&&rt.readPixels(jt,_t,ee,te,ie.convert(qe),ie.convert(ii),Te)}finally{const $e=M!==null?Vt.get(M).__webglFramebuffer:null;At.bindFramebuffer(rt.FRAMEBUFFER,$e)}}},this.copyFramebufferToTexture=function(Tt,jt,_t=0){const ee=Math.pow(2,-_t),te=Math.floor(jt.image.width*ee),Te=Math.floor(jt.image.height*ee);dt.setTexture2D(jt,0),rt.copyTexSubImage2D(rt.TEXTURE_2D,_t,0,0,Tt.x,Tt.y,te,Te),At.unbindTexture()},this.copyTextureToTexture=function(Tt,jt,_t,ee=0){const te=jt.image.width,Te=jt.image.height,Ue=ie.convert(_t.format),We=ie.convert(_t.type);dt.setTexture2D(_t,0),rt.pixelStorei(rt.UNPACK_FLIP_Y_WEBGL,_t.flipY),rt.pixelStorei(rt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_t.premultiplyAlpha),rt.pixelStorei(rt.UNPACK_ALIGNMENT,_t.unpackAlignment),jt.isDataTexture?rt.texSubImage2D(rt.TEXTURE_2D,ee,Tt.x,Tt.y,te,Te,Ue,We,jt.image.data):jt.isCompressedTexture?rt.compressedTexSubImage2D(rt.TEXTURE_2D,ee,Tt.x,Tt.y,jt.mipmaps[0].width,jt.mipmaps[0].height,Ue,jt.mipmaps[0].data):rt.texSubImage2D(rt.TEXTURE_2D,ee,Tt.x,Tt.y,Ue,We,jt.image),ee===0&&_t.generateMipmaps&&rt.generateMipmap(rt.TEXTURE_2D),At.unbindTexture()},this.copyTextureToTexture3D=function(Tt,jt,_t,ee,te=0){if(d.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Te=Tt.max.x-Tt.min.x+1,Ue=Tt.max.y-Tt.min.y+1,We=Tt.max.z-Tt.min.z+1,$e=ie.convert(ee.format),qe=ie.convert(ee.type);let ii;if(ee.isData3DTexture)dt.setTexture3D(ee,0),ii=rt.TEXTURE_3D;else if(ee.isDataArrayTexture||ee.isCompressedArrayTexture)dt.setTexture2DArray(ee,0),ii=rt.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}rt.pixelStorei(rt.UNPACK_FLIP_Y_WEBGL,ee.flipY),rt.pixelStorei(rt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),rt.pixelStorei(rt.UNPACK_ALIGNMENT,ee.unpackAlignment);const ai=rt.getParameter(rt.UNPACK_ROW_LENGTH),Ji=rt.getParameter(rt.UNPACK_IMAGE_HEIGHT),hn=rt.getParameter(rt.UNPACK_SKIP_PIXELS),ki=rt.getParameter(rt.UNPACK_SKIP_ROWS),gn=rt.getParameter(rt.UNPACK_SKIP_IMAGES),ti=_t.isCompressedTexture?_t.mipmaps[te]:_t.image;rt.pixelStorei(rt.UNPACK_ROW_LENGTH,ti.width),rt.pixelStorei(rt.UNPACK_IMAGE_HEIGHT,ti.height),rt.pixelStorei(rt.UNPACK_SKIP_PIXELS,Tt.min.x),rt.pixelStorei(rt.UNPACK_SKIP_ROWS,Tt.min.y),rt.pixelStorei(rt.UNPACK_SKIP_IMAGES,Tt.min.z),_t.isDataTexture||_t.isData3DTexture?rt.texSubImage3D(ii,te,jt.x,jt.y,jt.z,Te,Ue,We,$e,qe,ti.data):_t.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),rt.compressedTexSubImage3D(ii,te,jt.x,jt.y,jt.z,Te,Ue,We,$e,ti.data)):rt.texSubImage3D(ii,te,jt.x,jt.y,jt.z,Te,Ue,We,$e,qe,ti),rt.pixelStorei(rt.UNPACK_ROW_LENGTH,ai),rt.pixelStorei(rt.UNPACK_IMAGE_HEIGHT,Ji),rt.pixelStorei(rt.UNPACK_SKIP_PIXELS,hn),rt.pixelStorei(rt.UNPACK_SKIP_ROWS,ki),rt.pixelStorei(rt.UNPACK_SKIP_IMAGES,gn),te===0&&ee.generateMipmaps&&rt.generateMipmap(ii),At.unbindTexture()},this.initTexture=function(Tt){Tt.isCubeTexture?dt.setTextureCube(Tt,0):Tt.isData3DTexture?dt.setTexture3D(Tt,0):Tt.isDataArrayTexture||Tt.isCompressedArrayTexture?dt.setTexture2DArray(Tt,0):dt.setTexture2D(Tt,0),At.unbindTexture()},this.resetState=function(){m=0,S=0,M=null,At.reset(),Ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return No}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const i=this.getContext();i.drawingBufferColorSpace=t===lg?"display-p3":"srgb",i.unpackColorSpace=rn.workingColorSpace===Jd?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===vr?ch:c1}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===ch?vr:Go}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}}class Aw extends M1{}Aw.prototype.isWebGL1Renderer=!0;class fg{constructor(t,i=25e-5){this.isFogExp2=!0,this.name="",this.color=new ze(t),this.density=i}clone(){return new fg(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class cg{constructor(t,i=1,x=1e3){this.isFog=!0,this.name="",this.color=new ze(t),this.near=i,this.far=x}clone(){return new cg(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Mm extends Yi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,i){return super.copy(t,i),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const i=super.toJSON(t);return this.fog!==null&&(i.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(i.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(i.object.backgroundIntensity=this.backgroundIntensity),i}}class dg{constructor(t,i){this.isInterleavedBuffer=!0,this.array=t,this.stride=i,this.count=t!==void 0?t.length/i:0,this.usage=Fd,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=na()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Su("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,i){this.updateRanges.push({start:t,count:i})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,i,x){t*=this.stride,x*=i.stride;for(let T=0,E=this.stride;Tt.far||i.push({distance:e,point:jc.clone(),uv:ia.getInterpolation(jc,Ev,Jc,Mv,fE,X0,cE,new ve),face:null,object:this})}copy(t,i){return super.copy(t,i),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Cv(g,t,i,x,T,E){Af.subVectors(g,i).addScalar(.5).multiply(x),T!==void 0?(Zc.x=E*Af.x-T*Af.y,Zc.y=T*Af.x+E*Af.y):Zc.copy(Af),g.copy(t),g.x+=Zc.x,g.y+=Zc.y,g.applyMatrix4(Pw)}const wv=new Ct,dE=new Ct;class bw extends Yi{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const i=t.levels;for(let x=0,T=i.length;x0){let x,T;for(x=1,T=i.length;x0){wv.setFromMatrixPosition(this.matrixWorld);const T=t.ray.origin.distanceTo(wv);this.getObjectForDistance(T).raycast(t,i)}}update(t){const i=this.levels;if(i.length>1){wv.setFromMatrixPosition(t.matrixWorld),dE.setFromMatrixPosition(this.matrixWorld);const x=wv.distanceTo(dE)/t.zoom;i[0].object.visible=!0;let T,E;for(T=1,E=i.length;T=s)i[T-1].object.visible=!1,i[T].object.visible=!0;else break}for(this._currentLevel=T-1;T=x.length&&x.push({start:-1,count:-1,z:-1});const E=x[this.index];T.push(E),this.index++,E.start=t.start,E.count=t.count,E.z=i}reset(){this.list.length=0,this.index=0}}const Rf="batchId",rh=new ci,EE=new ci,_6=new ci,ME=new ci,K0=new _d,Rv=new gs,tu=new $r,_c=new Ct,j0=new Q6,jr=new cr,bv=[];function q6(g,t,i=0){const x=t.itemSize;if(g.isInterleavedBufferAttribute||g.array.constructor!==t.array.constructor){const T=g.count;for(let E=0;E65536?new Uint32Array(E):new Uint16Array(E);i.setIndex(new an(y,1))}const s=T>65536?new Uint32Array(x):new Uint16Array(x);i.setAttribute(Rf,new an(s,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(Rf))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Rf}"`);const i=this.geometry;if(!!t.getIndex()!=!!i.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const x in i.attributes){if(x===Rf)continue;if(!t.hasAttribute(x))throw new Error(`BatchedMesh: Added geometry missing "${x}". All geometries must have consistent attributes.`);const T=t.getAttribute(x),E=i.getAttribute(x);if(T.itemSize!==E.itemSize||T.normalized!==E.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gs);const t=this._geometryCount,i=this.boundingBox,x=this._active;i.makeEmpty();for(let T=0;T=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const T={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let E=null;const s=this._reservedRanges,y=this._drawRanges,e=this._bounds;this._geometryCount!==0&&(E=s[s.length-1]),i===-1?T.vertexCount=t.getAttribute("position").count:T.vertexCount=i,E===null?T.vertexStart=0:T.vertexStart=E.vertexStart+E.vertexCount;const r=t.getIndex(),p=r!==null;if(p&&(x===-1?T.indexCount=r.count:T.indexCount=x,E===null?T.indexStart=0:T.indexStart=E.indexStart+E.indexCount),T.indexStart!==-1&&T.indexStart+T.indexCount>this._maxIndexCount||T.vertexStart+T.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._visibility,a=this._active,l=this._matricesTexture,n=this._matricesTexture.image.data;h.push(!0),a.push(!0);const u=this._geometryCount;this._geometryCount++,_6.toArray(n,u*16),l.needsUpdate=!0,s.push(T),y.push({start:p?T.indexStart:T.vertexStart,count:-1}),e.push({boxInitialized:!1,box:new gs,sphereInitialized:!1,sphere:new $r});const f=this.geometry.getAttribute(Rf);for(let o=0;o=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(i);const x=this.geometry,T=x.getIndex()!==null,E=x.getIndex(),s=i.getIndex(),y=this._reservedRanges[t];if(T&&s.count>y.indexCount||i.attributes.position.count>y.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const e=y.vertexStart,r=y.vertexCount;for(const l in x.attributes){if(l===Rf)continue;const n=i.getAttribute(l),u=x.getAttribute(l);q6(n,u,e);const f=n.itemSize;for(let o=n.count,c=r;o=i.length||i[t]===!1?this:(i[t]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(t,i){if(this._active[t]===!1)return null;const T=this._bounds[t],E=T.box,s=this.geometry;if(T.boxInitialized===!1){E.makeEmpty();const y=s.index,e=s.attributes.position,r=this._drawRanges[t];for(let p=r.start,h=r.start+r.count;p=s||x[t]===!1?this:(i.toArray(E,t*16),T.needsUpdate=!0,this)}getMatrixAt(t,i){const x=this._active,T=this._matricesTexture.image.data,E=this._geometryCount;return t>=E||x[t]===!1?null:i.fromArray(T,t*16)}setVisibleAt(t,i){const x=this._visibility,T=this._active,E=this._geometryCount;return t>=E||T[t]===!1||x[t]===i?this:(x[t]=i,this._visibilityChanged=!0,this)}getVisibleAt(t){const i=this._visibility,x=this._active,T=this._geometryCount;return t>=T||x[t]===!1?!1:i[t]}raycast(t,i){const x=this._visibility,T=this._active,E=this._drawRanges,s=this._geometryCount,y=this.matrixWorld,e=this.geometry;jr.material=this.material,jr.geometry.index=e.index,jr.geometry.attributes=e.attributes,jr.geometry.boundingBox===null&&(jr.geometry.boundingBox=new gs),jr.geometry.boundingSphere===null&&(jr.geometry.boundingSphere=new $r);for(let r=0;r({...i})),this._reservedRanges=t._reservedRanges.map(i=>({...i})),this._visibility=t._visibility.slice(),this._active=t._active.slice(),this._bounds=t._bounds.map(i=>({boxInitialized:i.boxInitialized,box:i.box.clone(),sphereInitialized:i.sphereInitialized,sphere:i.sphere.clone()})),this._maxGeometryCount=t._maxGeometryCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(t,i,x,T,E){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=T.getIndex(),y=s===null?1:s.array.BYTES_PER_ELEMENT,e=this._active,r=this._visibility,p=this._multiDrawStarts,h=this._multiDrawCounts,a=this._drawRanges,l=this.perObjectFrustumCulled;l&&(ME.multiplyMatrices(x.projectionMatrix,x.matrixWorldInverse).multiply(this.matrixWorld),K0.setFromProjectionMatrix(ME,t.coordinateSystem));let n=0;if(this.sortObjects){EE.copy(this.matrixWorld).invert(),_c.setFromMatrixPosition(x.matrixWorld).applyMatrix4(EE);for(let o=0,c=r.length;oe)continue;a.applyMatrix4(this.matrixWorld);const w=t.ray.origin.distanceTo(a);wt.far||i.push({distance:w,point:h.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this})}}else{const o=Math.max(0,s.start),c=Math.min(f.count,s.start+s.count);for(let d=o,v=c-1;de)continue;a.applyMatrix4(this.matrixWorld);const S=t.ray.origin.distanceTo(a);St.far||i.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const i=this.geometry.morphAttributes,x=Object.keys(i);if(x.length>0){const T=i[x[0]];if(T!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let E=0,s=T.length;E0){const T=i[x[0]];if(T!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let E=0,s=T.length;ET.far)return;E.push({distance:r,distanceToRay:Math.sqrt(y),point:e,index:t,face:null,object:s})}}class tU extends Un{constructor(t,i,x,T,E,s,y,e,r){super(t,i,x,T,E,s,y,e,r),this.isVideoTexture=!0,this.minFilter=s!==void 0?s:Nn,this.magFilter=E!==void 0?E:Nn,this.generateMipmaps=!1;const p=this;function h(){p.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class eU extends Un{constructor(t,i){super({width:t,height:i}),this.isFramebufferTexture=!0,this.magFilter=nr,this.minFilter=nr,this.generateMipmaps=!1,this.needsUpdate=!0}}class vg extends Un{constructor(t,i,x,T,E,s,y,e,r,p,h,a){super(null,s,y,e,r,p,T,E,h,a),this.isCompressedTexture=!0,this.image={width:i,height:x},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class iU extends vg{constructor(t,i,x,T,E,s){super(t,i,x,E,s),this.isCompressedArrayTexture=!0,this.image.depth=T,this.wrapR=Jr}}class nU extends vg{constructor(t,i,x){super(void 0,t[0].width,t[0].height,i,x,wl),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class rU extends Un{constructor(t,i,x,T,E,s,y,e,r){super(t,i,x,T,E,s,y,e,r),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ro{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,i){const x=this.getUtoTmapping(t);return this.getPoint(x,i)}getPoints(t=5){const i=[];for(let x=0;x<=t;x++)i.push(this.getPoint(x/t));return i}getSpacedPoints(t=5){const i=[];for(let x=0;x<=t;x++)i.push(this.getPointAt(x/t));return i}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const i=[];let x,T=this.getPoint(0),E=0;i.push(0);for(let s=1;s<=t;s++)x=this.getPoint(s/t),E+=x.distanceTo(T),i.push(E),T=x;return this.cacheArcLengths=i,i}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,i){const x=this.getLengths();let T=0;const E=x.length;let s;i?s=i:s=t*x[E-1];let y=0,e=E-1,r;for(;y<=e;)if(T=Math.floor(y+(e-y)/2),r=x[T]-s,r<0)y=T+1;else if(r>0)e=T-1;else{e=T;break}if(T=e,x[T]===s)return T/(E-1);const p=x[T],a=x[T+1]-p,l=(s-p)/a;return(T+l)/(E-1)}getTangent(t,i){let T=t-1e-4,E=t+1e-4;T<0&&(T=0),E>1&&(E=1);const s=this.getPoint(T),y=this.getPoint(E),e=i||(s.isVector2?new ve:new Ct);return e.copy(y).sub(s).normalize(),e}getTangentAt(t,i){const x=this.getUtoTmapping(t);return this.getTangent(x,i)}computeFrenetFrames(t,i){const x=new Ct,T=[],E=[],s=[],y=new Ct,e=new ci;for(let l=0;l<=t;l++){const n=l/t;T[l]=this.getTangentAt(n,new Ct)}E[0]=new Ct,s[0]=new Ct;let r=Number.MAX_VALUE;const p=Math.abs(T[0].x),h=Math.abs(T[0].y),a=Math.abs(T[0].z);p<=r&&(r=p,x.set(1,0,0)),h<=r&&(r=h,x.set(0,1,0)),a<=r&&x.set(0,0,1),y.crossVectors(T[0],x).normalize(),E[0].crossVectors(T[0],y),s[0].crossVectors(T[0],E[0]);for(let l=1;l<=t;l++){if(E[l]=E[l-1].clone(),s[l]=s[l-1].clone(),y.crossVectors(T[l-1],T[l]),y.length()>Number.EPSILON){y.normalize();const n=Math.acos(jn(T[l-1].dot(T[l]),-1,1));E[l].applyMatrix4(e.makeRotationAxis(y,n))}s[l].crossVectors(T[l],E[l])}if(i===!0){let l=Math.acos(jn(E[0].dot(E[t]),-1,1));l/=t,T[0].dot(y.crossVectors(E[0],E[t]))>0&&(l=-l);for(let n=1;n<=t;n++)E[n].applyMatrix4(e.makeRotationAxis(T[n],l*n)),s[n].crossVectors(T[n],E[n])}return{tangents:T,normals:E,binormals:s}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class mg extends ro{constructor(t=0,i=0,x=1,T=1,E=0,s=Math.PI*2,y=!1,e=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=i,this.xRadius=x,this.yRadius=T,this.aStartAngle=E,this.aEndAngle=s,this.aClockwise=y,this.aRotation=e}getPoint(t,i){const x=i||new ve,T=Math.PI*2;let E=this.aEndAngle-this.aStartAngle;const s=Math.abs(E)T;)E-=T;E0?0:(Math.floor(Math.abs(y)/E)+1)*E:e===0&&y===E-1&&(y=E-2,e=1);let r,p;this.closed||y>0?r=T[(y-1)%E]:(Dv.subVectors(T[0],T[1]).add(T[0]),r=Dv);const h=T[y%E],a=T[(y+1)%E];if(this.closed||y+2T.length-2?T.length-1:s+1],h=T[s>T.length-3?T.length-1:s+2];return x.set(FE(y,e.x,r.x,p.x,h.x),FE(y,e.y,r.y,p.y,h.y)),x}copy(t){super.copy(t),this.points=[];for(let i=0,x=t.points.length;i=x){const s=T[E]-x,y=this.curves[E],e=y.getLength(),r=e===0?0:1-s/e;return y.getPointAt(r,i)}E++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let i=0;for(let x=0,T=this.curves.length;x1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(t){super.copy(t),this.curves=[];for(let i=0,x=t.curves.length;i0){const h=r.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(r);const p=r.getPoint(1);return this.currentPoint.copy(p),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class tp extends Li{constructor(t=[new ve(0,-.5),new ve(.5,0),new ve(0,.5)],i=12,x=0,T=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:i,phiStart:x,phiLength:T},i=Math.floor(i),T=jn(T,0,Math.PI*2);const E=[],s=[],y=[],e=[],r=[],p=1/i,h=new Ct,a=new ve,l=new Ct,n=new Ct,u=new Ct;let f=0,o=0;for(let c=0;c<=t.length-1;c++)switch(c){case 0:f=t[c+1].x-t[c].x,o=t[c+1].y-t[c].y,l.x=o*1,l.y=-f,l.z=o*0,u.copy(l),l.normalize(),e.push(l.x,l.y,l.z);break;case t.length-1:e.push(u.x,u.y,u.z);break;default:f=t[c+1].x-t[c].x,o=t[c+1].y-t[c].y,l.x=o*1,l.y=-f,l.z=o*0,n.copy(l),l.x+=u.x,l.y+=u.y,l.z+=u.z,l.normalize(),e.push(l.x,l.y,l.z),u.copy(n)}for(let c=0;c<=i;c++){const d=x+c*p*T,v=Math.sin(d),m=Math.cos(d);for(let S=0;S<=t.length-1;S++){h.x=t[S].x*v,h.y=t[S].y,h.z=t[S].x*m,s.push(h.x,h.y,h.z),a.x=c/i,a.y=S/(t.length-1),y.push(a.x,a.y);const M=e[3*S+0]*v,w=e[3*S+1],C=e[3*S+0]*m;r.push(M,w,C)}}for(let c=0;c0&&d(!0),i>0&&d(!1)),this.setIndex(p),this.setAttribute("position",new ke(h,3)),this.setAttribute("normal",new ke(a,3)),this.setAttribute("uv",new ke(l,2));function c(){const v=new Ct,m=new Ct;let S=0;const M=(i-t)/x;for(let w=0;w<=E;w++){const C=[],A=w/E,P=A*(i-t)+t;for(let b=0;b<=T;b++){const O=b/T,I=O*e+y,D=Math.sin(I),B=Math.cos(I);m.x=P*D,m.y=-A*x+f,m.z=P*B,h.push(m.x,m.y,m.z),v.set(D,M,B).normalize(),a.push(v.x,v.y,v.z),l.push(O,1-A),C.push(n++)}u.push(C)}for(let w=0;w.9&&M<.1&&(d<.2&&(s[c+0]+=1),v<.2&&(s[c+2]+=1),m<.2&&(s[c+4]+=1))}}function a(c){E.push(c.x,c.y,c.z)}function l(c,d){const v=c*3;d.x=t[v+0],d.y=t[v+1],d.z=t[v+2]}function n(){const c=new Ct,d=new Ct,v=new Ct,m=new Ct,S=new ve,M=new ve,w=new ve;for(let C=0,A=0;C80*i){y=r=g[0],e=p=g[1];for(let n=i;nr&&(r=h),a>p&&(p=a);l=Math.max(r-y,p-e),l=l!==0?32767/l:0}return Nd(E,s,i,y,e,l,0),s}};function Hw(g,t,i,x,T){let E,s;if(T===RU(g,t,i,x)>0)for(E=t;E=t;E-=x)s=OE(E,g[E],g[E+1],s);return s&&Tg(s,s.next)&&(Ud(s),s=s.next),s}function bu(g,t){if(!g)return g;t||(t=g);let i=g,x;do if(x=!1,!i.steiner&&(Tg(i,i.next)||Bn(i.prev,i,i.next)===0)){if(Ud(i),i=t=i.prev,i===i.next)break;x=!0}else i=i.next;while(x||i!==t);return t}function Nd(g,t,i,x,T,E,s){if(!g)return;!s&&E&&EU(g,x,T,E);let y=g,e,r;for(;g.prev!==g.next;){if(e=g.prev,r=g.next,E?pU(g,x,T,E):dU(g)){t.push(e.i/i|0),t.push(g.i/i|0),t.push(r.i/i|0),Ud(g),g=r.next,y=r.next;continue}if(g=r,g===y){s?s===1?(g=vU(bu(g),t,i),Nd(g,t,i,x,T,E,2)):s===2&&mU(g,t,i,x,T,E):Nd(bu(g),t,i,x,T,E,1);break}}}function dU(g){const t=g.prev,i=g,x=g.next;if(Bn(t,i,x)>=0)return!1;const T=t.x,E=i.x,s=x.x,y=t.y,e=i.y,r=x.y,p=TE?T>s?T:s:E>s?E:s,l=y>e?y>r?y:r:e>r?e:r;let n=x.next;for(;n!==t;){if(n.x>=p&&n.x<=a&&n.y>=h&&n.y<=l&&Vf(T,y,E,e,s,r,n.x,n.y)&&Bn(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function pU(g,t,i,x){const T=g.prev,E=g,s=g.next;if(Bn(T,E,s)>=0)return!1;const y=T.x,e=E.x,r=s.x,p=T.y,h=E.y,a=s.y,l=ye?y>r?y:r:e>r?e:r,f=p>h?p>a?p:a:h>a?h:a,o=yx(l,n,t,i,x),c=yx(u,f,t,i,x);let d=g.prevZ,v=g.nextZ;for(;d&&d.z>=o&&v&&v.z<=c;){if(d.x>=l&&d.x<=u&&d.y>=n&&d.y<=f&&d!==T&&d!==s&&Vf(y,p,e,h,r,a,d.x,d.y)&&Bn(d.prev,d,d.next)>=0||(d=d.prevZ,v.x>=l&&v.x<=u&&v.y>=n&&v.y<=f&&v!==T&&v!==s&&Vf(y,p,e,h,r,a,v.x,v.y)&&Bn(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;d&&d.z>=o;){if(d.x>=l&&d.x<=u&&d.y>=n&&d.y<=f&&d!==T&&d!==s&&Vf(y,p,e,h,r,a,d.x,d.y)&&Bn(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;v&&v.z<=c;){if(v.x>=l&&v.x<=u&&v.y>=n&&v.y<=f&&v!==T&&v!==s&&Vf(y,p,e,h,r,a,v.x,v.y)&&Bn(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function vU(g,t,i){let x=g;do{const T=x.prev,E=x.next.next;!Tg(T,E)&&Ww(T,x,x.next,E)&&Bd(T,E)&&Bd(E,T)&&(t.push(T.i/i|0),t.push(x.i/i|0),t.push(E.i/i|0),Ud(x),Ud(x.next),x=g=E),x=x.next}while(x!==g);return bu(x)}function mU(g,t,i,x,T,E){let s=g;do{let y=s.next.next;for(;y!==s.prev;){if(s.i!==y.i&&wU(s,y)){let e=Xw(s,y);s=bu(s,s.next),e=bu(e,e.next),Nd(s,t,i,x,T,E,0),Nd(e,t,i,x,T,E,0);return}y=y.next}s=s.next}while(s!==g)}function gU(g,t,i,x){const T=[];let E,s,y,e,r;for(E=0,s=t.length;E=i.next.y&&i.next.y!==i.y){const a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=E&&a>x&&(x=a,T=i.x=i.x&&i.x>=e&&E!==i.x&&Vf(sT.x||i.x===T.x&&TU(T,i)))&&(T=i,p=h)),i=i.next;while(i!==y);return T}function TU(g,t){return Bn(g.prev,g,t.prev)<0&&Bn(t.next,g,g.next)<0}function EU(g,t,i,x){let T=g;do T.z===0&&(T.z=yx(T.x,T.y,t,i,x)),T.prevZ=T.prev,T.nextZ=T.next,T=T.next;while(T!==g);T.prevZ.nextZ=null,T.prevZ=null,MU(T)}function MU(g){let t,i,x,T,E,s,y,e,r=1;do{for(i=g,g=null,E=null,s=0;i;){for(s++,x=i,y=0,t=0;t0||e>0&&x;)y!==0&&(e===0||!x||i.z<=x.z)?(T=i,i=i.nextZ,y--):(T=x,x=x.nextZ,e--),E?E.nextZ=T:g=T,T.prevZ=E,E=T;i=x}E.nextZ=null,r*=2}while(s>1);return g}function yx(g,t,i,x,T){return g=(g-i)*T|0,t=(t-x)*T|0,g=(g|g<<8)&16711935,g=(g|g<<4)&252645135,g=(g|g<<2)&858993459,g=(g|g<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,g|t<<1}function CU(g){let t=g,i=g;do(t.x=(g-s)*(E-y)&&(g-s)*(x-y)>=(i-s)*(t-y)&&(i-s)*(E-y)>=(T-s)*(x-y)}function wU(g,t){return g.next.i!==t.i&&g.prev.i!==t.i&&!AU(g,t)&&(Bd(g,t)&&Bd(t,g)&&PU(g,t)&&(Bn(g.prev,g,t.prev)||Bn(g,t.prev,t))||Tg(g,t)&&Bn(g.prev,g,g.next)>0&&Bn(t.prev,t,t.next)>0)}function Bn(g,t,i){return(t.y-g.y)*(i.x-t.x)-(t.x-g.x)*(i.y-t.y)}function Tg(g,t){return g.x===t.x&&g.y===t.y}function Ww(g,t,i,x){const T=zv(Bn(g,t,i)),E=zv(Bn(g,t,x)),s=zv(Bn(i,x,g)),y=zv(Bn(i,x,t));return!!(T!==E&&s!==y||T===0&&Uv(g,i,t)||E===0&&Uv(g,x,t)||s===0&&Uv(i,g,x)||y===0&&Uv(i,t,x))}function Uv(g,t,i){return t.x<=Math.max(g.x,i.x)&&t.x>=Math.min(g.x,i.x)&&t.y<=Math.max(g.y,i.y)&&t.y>=Math.min(g.y,i.y)}function zv(g){return g>0?1:g<0?-1:0}function AU(g,t){let i=g;do{if(i.i!==g.i&&i.next.i!==g.i&&i.i!==t.i&&i.next.i!==t.i&&Ww(i,i.next,g,t))return!0;i=i.next}while(i!==g);return!1}function Bd(g,t){return Bn(g.prev,g,g.next)<0?Bn(g,t,g.next)>=0&&Bn(g,g.prev,t)>=0:Bn(g,t,g.prev)<0||Bn(g,g.next,t)<0}function PU(g,t){let i=g,x=!1;const T=(g.x+t.x)/2,E=(g.y+t.y)/2;do i.y>E!=i.next.y>E&&i.next.y!==i.y&&T<(i.next.x-i.x)*(E-i.y)/(i.next.y-i.y)+i.x&&(x=!x),i=i.next;while(i!==g);return x}function Xw(g,t){const i=new xx(g.i,g.x,g.y),x=new xx(t.i,t.x,t.y),T=g.next,E=t.prev;return g.next=t,t.prev=g,i.next=T,T.prev=i,x.next=i,i.prev=x,E.next=x,x.prev=E,x}function OE(g,t,i,x){const T=new xx(g,t,i);return x?(T.next=x.next,T.prev=x,x.next.prev=T,x.next=T):(T.prev=T,T.next=T),T}function Ud(g){g.next.prev=g.prev,g.prev.next=g.next,g.prevZ&&(g.prevZ.nextZ=g.nextZ),g.nextZ&&(g.nextZ.prevZ=g.prevZ)}function xx(g,t,i){this.i=g,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function RU(g,t,i,x){let T=0;for(let E=t,s=i-x;E2&&g[t-1].equals(g[0])&&g.pop()}function IE(g,t){for(let i=0;iNumber.EPSILON){const Bt=Math.sqrt(Dt),ne=Math.sqrt(ut*ut+Rt*Rt),oe=gt.x-dt/Bt,ge=gt.y+Vt/Bt,xe=yt.x-Rt/ne,Ae=yt.y+ut/ne,qt=((xe-oe)*Rt-(Ae-ge)*ut)/(Vt*Rt-dt*ut);Et=oe+Vt*qt-rt.x,At=ge+dt*qt-rt.y;const Ge=Et*Et+At*At;if(Ge<=2)return new ve(Et,At);Pt=Math.sqrt(Ge/2)}else{let Bt=!1;Vt>Number.EPSILON?ut>Number.EPSILON&&(Bt=!0):Vt<-Number.EPSILON?ut<-Number.EPSILON&&(Bt=!0):Math.sign(dt)===Math.sign(Rt)&&(Bt=!0),Bt?(Et=-dt,At=Vt,Pt=Math.sqrt(Dt)):(Et=Vt,At=dt,Pt=Math.sqrt(Dt/2))}return new ve(Et/Pt,At/Pt)}const X=[];for(let rt=0,gt=I.length,yt=gt-1,Et=rt+1;rt=0;rt--){const gt=rt/f,yt=l*Math.cos(gt*Math.PI/2),Et=n*Math.sin(gt*Math.PI/2)+u;for(let At=0,Pt=I.length;At=0;){const Et=yt;let At=yt-1;At<0&&(At=rt.length-1);for(let Pt=0,Vt=p+f*2;Pt0)&&l.push(d,v,S),(o!==x-1||e0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Zw extends Hr{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ze(16777215),this.specular=new ze(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Zd,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Jw extends Hr{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ze(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class $w extends Hr{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Qw extends Hr{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Zd,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class _w extends Hr{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ze(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yh,this.normalScale=new ve(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class qw extends ys{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function gu(g,t,i){return!g||!i&&g.constructor===t?g:typeof t.BYTES_PER_ELEMENT=="number"?new t(g):Array.prototype.slice.call(g)}function tA(g){return ArrayBuffer.isView(g)&&!(g instanceof DataView)}function eA(g){function t(T,E){return g[T]-g[E]}const i=g.length,x=new Array(i);for(let T=0;T!==i;++T)x[T]=T;return x.sort(t),x}function Sx(g,t,i){const x=g.length,T=new g.constructor(x);for(let E=0,s=0;s!==x;++E){const y=i[E]*t;for(let e=0;e!==t;++e)T[s++]=g[y+e]}return T}function D1(g,t,i,x){let T=1,E=g[0];for(;E!==void 0&&E[x]===void 0;)E=g[T++];if(E===void 0)return;let s=E[x];if(s!==void 0)if(Array.isArray(s))do s=E[x],s!==void 0&&(t.push(E.time),i.push.apply(i,s)),E=g[T++];while(E!==void 0);else if(s.toArray!==void 0)do s=E[x],s!==void 0&&(t.push(E.time),s.toArray(i,i.length)),E=g[T++];while(E!==void 0);else do s=E[x],s!==void 0&&(t.push(E.time),i.push(s)),E=g[T++];while(E!==void 0)}function OU(g,t,i,x,T=30){const E=g.clone();E.name=t;const s=[];for(let e=0;e=x)){h.push(r.times[l]);for(let u=0;uE.tracks[e].times[0]&&(y=E.tracks[e].times[0]);for(let e=0;e=y.times[n]){const o=n*h+p,c=o+h-p;u=y.values.slice(o,c)}else{const o=y.createInterpolant(),c=p,d=h-p;o.evaluate(E),u=o.resultBuffer.slice(c,d)}e==="quaternion"&&new Ds().fromArray(u).normalize().conjugate().toArray(u);const f=r.times.length;for(let o=0;o=E)){const y=i[1];t=E)break e}s=x,x=0;break i}break t}for(;x>>1;ti;)--s;if(++s,E!==0||s!==T){E>=s&&(s=Math.max(s,1),E=s-1);const y=this.getValueSize();this.times=x.slice(E,s),this.values=this.values.slice(E*y,s*y)}return this}validate(){let t=!0;const i=this.getValueSize();i-Math.floor(i)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const x=this.times,T=this.values,E=x.length;E===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let y=0;y!==E;y++){const e=x[y];if(typeof e=="number"&&isNaN(e)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,y,e),t=!1;break}if(s!==null&&s>e){console.error("THREE.KeyframeTrack: Out of order keys.",this,y,e,s),t=!1;break}s=e}if(T!==void 0&&tA(T))for(let y=0,e=T.length;y!==e;++y){const r=T[y];if(isNaN(r)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,y,r),t=!1;break}}return t}optimize(){const t=this.times.slice(),i=this.values.slice(),x=this.getValueSize(),T=this.getInterpolation()===am,E=t.length-1;let s=1;for(let y=1;y0){t[s]=t[E];for(let y=E*x,e=s*x,r=0;r!==x;++r)i[e+r]=i[y+r];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=i.slice(0,s*x)):(this.times=t,this.values=i),this}clone(){const t=this.times.slice(),i=this.values.slice(),x=this.constructor,T=new x(this.name,t,i);return T.createInterpolant=this.createInterpolant,T}}so.prototype.TimeBufferType=Float32Array;so.prototype.ValueBufferType=Float32Array;so.prototype.DefaultInterpolation=Ad;class Du extends so{}Du.prototype.ValueTypeName="bool";Du.prototype.ValueBufferType=Array;Du.prototype.DefaultInterpolation=wd;Du.prototype.InterpolantFactoryMethodLinear=void 0;Du.prototype.InterpolantFactoryMethodSmooth=void 0;class N1 extends so{}N1.prototype.ValueTypeName="color";class zd extends so{}zd.prototype.ValueTypeName="number";class rA extends np{constructor(t,i,x,T){super(t,i,x,T)}interpolate_(t,i,x,T){const E=this.resultBuffer,s=this.sampleValues,y=this.valueSize,e=(x-i)/(T-i);let r=t*y;for(let p=r+y;r!==p;r+=4)Ds.slerpFlat(E,0,s,r-y,s,r,e);return E}}class ac extends so{InterpolantFactoryMethodLinear(t){return new rA(this.times,this.values,this.getValueSize(),t)}}ac.prototype.ValueTypeName="quaternion";ac.prototype.DefaultInterpolation=Ad;ac.prototype.InterpolantFactoryMethodSmooth=void 0;class Iu extends so{}Iu.prototype.ValueTypeName="string";Iu.prototype.ValueBufferType=Array;Iu.prototype.DefaultInterpolation=wd;Iu.prototype.InterpolantFactoryMethodLinear=void 0;Iu.prototype.InterpolantFactoryMethodSmooth=void 0;class Gd extends so{}Gd.prototype.ValueTypeName="vector";class Vd{constructor(t,i=-1,x,T=og){this.name=t,this.tracks=x,this.duration=i,this.blendMode=T,this.uuid=na(),this.duration<0&&this.resetDuration()}static parse(t){const i=[],x=t.tracks,T=1/(t.fps||1);for(let s=0,y=x.length;s!==y;++s)i.push(BU(x[s]).scale(T));const E=new this(t.name,t.duration,i,t.blendMode);return E.uuid=t.uuid,E}static toJSON(t){const i=[],x=t.tracks,T={name:t.name,duration:t.duration,tracks:i,uuid:t.uuid,blendMode:t.blendMode};for(let E=0,s=x.length;E!==s;++E)i.push(so.toJSON(x[E]));return T}static CreateFromMorphTargetSequence(t,i,x,T){const E=i.length,s=[];for(let y=0;y1){const h=p[1];let a=T[h];a||(T[h]=a=[]),a.push(r)}}const s=[];for(const y in T)s.push(this.CreateFromMorphTargetSequence(y,T[y],i,x));return s}static parseAnimation(t,i){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const x=function(h,a,l,n,u){if(l.length!==0){const f=[],o=[];D1(l,f,o,n),f.length!==0&&u.push(new h(a,f,o))}},T=[],E=t.name||"default",s=t.fps||30,y=t.blendMode;let e=t.length||-1;const r=t.hierarchy||[];for(let h=0;h{i&&i(E),this.manager.itemEnd(t)},0),E;if(pl[t]!==void 0){pl[t].push({onLoad:i,onProgress:x,onError:T});return}pl[t]=[],pl[t].push({onLoad:i,onProgress:x,onError:T});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),y=this.mimeType,e=this.responseType;fetch(s).then(r=>{if(r.status===200||r.status===0){if(r.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||r.body===void 0||r.body.getReader===void 0)return r;const p=pl[t],h=r.body.getReader(),a=r.headers.get("Content-Length")||r.headers.get("X-File-Size"),l=a?parseInt(a):0,n=l!==0;let u=0;const f=new ReadableStream({start(o){c();function c(){h.read().then(({done:d,value:v})=>{if(d)o.close();else{u+=v.byteLength;const m=new ProgressEvent("progress",{lengthComputable:n,loaded:u,total:l});for(let S=0,M=p.length;S{switch(e){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"document":return r.text().then(p=>new DOMParser().parseFromString(p,y));case"json":return r.json();default:if(y===void 0)return r.text();{const h=/charset="?([^;"\s]*)"?/i.exec(y),a=h&&h[1]?h[1].toLowerCase():void 0,l=new TextDecoder(a);return r.arrayBuffer().then(n=>l.decode(n))}}}).then(r=>{Sl.add(t,r);const p=pl[t];delete pl[t];for(let h=0,a=p.length;h{const p=pl[t];if(p===void 0)throw this.manager.itemError(t),r;delete pl[t];for(let h=0,a=p.length;h{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class zU extends Ns{constructor(t){super(t)}load(t,i,x,T){const E=this,s=new Al(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(y){try{i(E.parse(JSON.parse(y)))}catch(e){T?T(e):console.error(e),E.manager.itemError(t)}},x,T)}parse(t){const i=[];for(let x=0;x0:T.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const E in t.uniforms){const s=t.uniforms[E];switch(T.uniforms[E]={},s.type){case"t":T.uniforms[E].value=x(s.value);break;case"c":T.uniforms[E].value=new ze().setHex(s.value);break;case"v2":T.uniforms[E].value=new ve().fromArray(s.value);break;case"v3":T.uniforms[E].value=new Ct().fromArray(s.value);break;case"v4":T.uniforms[E].value=new sn().fromArray(s.value);break;case"m3":T.uniforms[E].value=new Oi().fromArray(s.value);break;case"m4":T.uniforms[E].value=new ci().fromArray(s.value);break;default:T.uniforms[E].value=s.value}}if(t.defines!==void 0&&(T.defines=t.defines),t.vertexShader!==void 0&&(T.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(T.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(T.glslVersion=t.glslVersion),t.extensions!==void 0)for(const E in t.extensions)T.extensions[E]=t.extensions[E];if(t.lights!==void 0&&(T.lights=t.lights),t.clipping!==void 0&&(T.clipping=t.clipping),t.size!==void 0&&(T.size=t.size),t.sizeAttenuation!==void 0&&(T.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(T.map=x(t.map)),t.matcap!==void 0&&(T.matcap=x(t.matcap)),t.alphaMap!==void 0&&(T.alphaMap=x(t.alphaMap)),t.bumpMap!==void 0&&(T.bumpMap=x(t.bumpMap)),t.bumpScale!==void 0&&(T.bumpScale=t.bumpScale),t.normalMap!==void 0&&(T.normalMap=x(t.normalMap)),t.normalMapType!==void 0&&(T.normalMapType=t.normalMapType),t.normalScale!==void 0){let E=t.normalScale;Array.isArray(E)===!1&&(E=[E,E]),T.normalScale=new ve().fromArray(E)}return t.displacementMap!==void 0&&(T.displacementMap=x(t.displacementMap)),t.displacementScale!==void 0&&(T.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(T.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(T.roughnessMap=x(t.roughnessMap)),t.metalnessMap!==void 0&&(T.metalnessMap=x(t.metalnessMap)),t.emissiveMap!==void 0&&(T.emissiveMap=x(t.emissiveMap)),t.emissiveIntensity!==void 0&&(T.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(T.specularMap=x(t.specularMap)),t.specularIntensityMap!==void 0&&(T.specularIntensityMap=x(t.specularIntensityMap)),t.specularColorMap!==void 0&&(T.specularColorMap=x(t.specularColorMap)),t.envMap!==void 0&&(T.envMap=x(t.envMap)),t.envMapIntensity!==void 0&&(T.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(T.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(T.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(T.lightMap=x(t.lightMap)),t.lightMapIntensity!==void 0&&(T.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(T.aoMap=x(t.aoMap)),t.aoMapIntensity!==void 0&&(T.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(T.gradientMap=x(t.gradientMap)),t.clearcoatMap!==void 0&&(T.clearcoatMap=x(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(T.clearcoatRoughnessMap=x(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(T.clearcoatNormalMap=x(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(T.clearcoatNormalScale=new ve().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(T.iridescenceMap=x(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(T.iridescenceThicknessMap=x(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(T.transmissionMap=x(t.transmissionMap)),t.thicknessMap!==void 0&&(T.thicknessMap=x(t.thicknessMap)),t.anisotropyMap!==void 0&&(T.anisotropyMap=x(t.anisotropyMap)),t.sheenColorMap!==void 0&&(T.sheenColorMap=x(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(T.sheenRoughnessMap=x(t.sheenRoughnessMap)),T}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){const i={ShadowMaterial:kw,SpriteMaterial:C1,RawShaderMaterial:Kw,ShaderMaterial:no,PointsMaterial:A1,MeshPhysicalMaterial:jw,MeshStandardMaterial:vl,MeshPhongMaterial:Zw,MeshToonMaterial:Jw,MeshNormalMaterial:$w,MeshLambertMaterial:Qw,MeshDepthMaterial:T1,MeshDistanceMaterial:E1,MeshBasicMaterial:xh,MeshMatcapMaterial:_w,LineDashedMaterial:qw,LineBasicMaterial:ys,Material:Hr};return new i[t]}}class Tx{static decodeText(t){if(typeof TextDecoder<"u")return new TextDecoder().decode(t);let i="";for(let x=0,T=t.length;x0){const e=new B1(i);E=new Hd(e),E.setCrossOrigin(this.crossOrigin);for(let r=0,p=t.length;r0){T=new Hd(this.manager),T.setCrossOrigin(this.crossOrigin);for(let s=0,y=t.length;s{const f=new gs;f.min.fromArray(u.boxMin),f.max.fromArray(u.boxMax);const o=new $r;return o.radius=u.sphereRadius,o.center.fromArray(u.sphereCenter),{boxInitialized:u.boxInitialized,box:f,sphereInitialized:u.sphereInitialized,sphere:o}}),s._maxGeometryCount=t.maxGeometryCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=r(t.matricesTexture.uuid);break;case"LOD":s=new bw;break;case"Line":s=new mh(y(t.geometry),e(t.material));break;case"LineLoop":s=new Dw(y(t.geometry),e(t.material));break;case"LineSegments":s=new Ho(y(t.geometry),e(t.material));break;case"PointCloud":case"Points":s=new Iw(y(t.geometry),e(t.material));break;case"Sprite":s=new Rw(e(t.material));break;case"Group":s=new Gf;break;case"Bone":s=new w1;break;default:s=new Yi}if(s.uuid=t.uuid,t.name!==void 0&&(s.name=t.name),t.matrix!==void 0?(s.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(t.position!==void 0&&s.position.fromArray(t.position),t.rotation!==void 0&&s.rotation.fromArray(t.rotation),t.quaternion!==void 0&&s.quaternion.fromArray(t.quaternion),t.scale!==void 0&&s.scale.fromArray(t.scale)),t.up!==void 0&&s.up.fromArray(t.up),t.castShadow!==void 0&&(s.castShadow=t.castShadow),t.receiveShadow!==void 0&&(s.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.bias!==void 0&&(s.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(s.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(s.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&s.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(s.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(s.visible=t.visible),t.frustumCulled!==void 0&&(s.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(s.renderOrder=t.renderOrder),t.userData!==void 0&&(s.userData=t.userData),t.layers!==void 0&&(s.layers.mask=t.layers),t.children!==void 0){const a=t.children;for(let l=0;l"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,i,x,T){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const E=this,s=Sl.get(t);if(s!==void 0){if(E.manager.itemStart(t),s.then){s.then(r=>{i&&i(r),E.manager.itemEnd(t)}).catch(r=>{T&&T(r)});return}return setTimeout(function(){i&&i(s),E.manager.itemEnd(t)},0),s}const y={};y.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",y.headers=this.requestHeader;const e=fetch(t,y).then(function(r){return r.blob()}).then(function(r){return createImageBitmap(r,Object.assign(E.options,{colorSpaceConversion:"none"}))}).then(function(r){return Sl.add(t,r),i&&i(r),E.manager.itemEnd(t),r}).catch(function(r){T&&T(r),Sl.remove(t),E.manager.itemError(t),E.manager.itemEnd(t)});Sl.add(t,e),E.manager.itemStart(t)}}let Gv,z1=class{static getContext(){return Gv===void 0&&(Gv=new(window.AudioContext||window.webkitAudioContext)),Gv}static setContext(t){Gv=t}};class ZU extends Ns{constructor(t){super(t)}load(t,i,x,T){const E=this,s=new Al(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(e){try{const r=e.slice(0);z1.getContext().decodeAudioData(r,function(h){i(h)}).catch(y)}catch(r){y(r)}},x,T);function y(e){T?T(e):console.error(e),E.manager.itemError(t)}}}const WE=new ci,XE=new ci,eu=new ci;class JU{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Or,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Or,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const i=this._cache;if(i.focus!==t.focus||i.fov!==t.fov||i.aspect!==t.aspect*this.aspect||i.near!==t.near||i.far!==t.far||i.zoom!==t.zoom||i.eyeSep!==this.eyeSep){i.focus=t.focus,i.fov=t.fov,i.aspect=t.aspect*this.aspect,i.near=t.near,i.far=t.far,i.zoom=t.zoom,i.eyeSep=this.eyeSep,eu.copy(t.projectionMatrix);const T=i.eyeSep/2,E=T*i.near/i.focus,s=i.near*Math.tan(xu*i.fov*.5)/i.zoom;let y,e;XE.elements[12]=-T,WE.elements[12]=T,y=-s*i.aspect+E,e=s*i.aspect+E,eu.elements[0]=2*i.near/(e-y),eu.elements[8]=(e+y)/(e-y),this.cameraL.projectionMatrix.copy(eu),y=-s*i.aspect-E,e=s*i.aspect-E,eu.elements[0]=2*i.near/(e-y),eu.elements[8]=(e+y)/(e-y),this.cameraR.projectionMatrix.copy(eu)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(XE),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(WE)}}class G1{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=YE(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const i=YE();t=(i-this.oldTime)/1e3,this.oldTime=i,this.elapsedTime+=t}return t}}function YE(){return(typeof performance>"u"?Date:performance).now()}const iu=new Ct,kE=new Ds,$U=new Ct,nu=new Ct;class QU extends Yi{constructor(){super(),this.type="AudioListener",this.context=z1.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new G1}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const i=this.context.listener,x=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(iu,kE,$U),nu.set(0,0,-1).applyQuaternion(kE),i.positionX){const T=this.context.currentTime+this.timeDelta;i.positionX.linearRampToValueAtTime(iu.x,T),i.positionY.linearRampToValueAtTime(iu.y,T),i.positionZ.linearRampToValueAtTime(iu.z,T),i.forwardX.linearRampToValueAtTime(nu.x,T),i.forwardY.linearRampToValueAtTime(nu.y,T),i.forwardZ.linearRampToValueAtTime(nu.z,T),i.upX.linearRampToValueAtTime(x.x,T),i.upY.linearRampToValueAtTime(x.y,T),i.upZ.linearRampToValueAtTime(x.z,T)}else i.setPosition(iu.x,iu.y,iu.z),i.setOrientation(nu.x,nu.y,nu.z,x.x,x.y,x.z)}}let gA=class extends Yi{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const i=this.context.createBufferSource();return i.buffer=this.buffer,i.loop=this.loop,i.loopStart=this.loopStart,i.loopEnd=this.loopEnd,i.onended=this.onEnded.bind(this),i.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=i,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,i=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,i=this.filters.length;t0&&this._mixBufferRegionAdditive(x,T,this._addIndex*i,1,i);for(let e=i,r=i+i;e!==r;++e)if(x[e]!==x[e+i]){y.setValue(x,T);break}}saveOriginalState(){const t=this.binding,i=this.buffer,x=this.valueSize,T=x*this._origIndex;t.getValue(i,T);for(let E=x,s=T;E!==s;++E)i[E]=i[T+E%x];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,i=t+this.valueSize;for(let x=t;x=.5)for(let s=0;s!==E;++s)t[i+s]=t[x+s]}_slerp(t,i,x,T){Ds.slerpFlat(t,i,t,i,t,x,T)}_slerpAdditive(t,i,x,T,E){const s=this._workIndex*E;Ds.multiplyQuaternionsFlat(t,s,t,i,t,x),Ds.slerpFlat(t,i,t,i,t,s,T)}_lerp(t,i,x,T,E){const s=1-T;for(let y=0;y!==E;++y){const e=i+y;t[e]=t[e]*s+t[x+y]*T}}_lerpAdditive(t,i,x,T,E){for(let s=0;s!==E;++s){const y=i+s;t[y]=t[y]+t[x+s]*T}}}const V1="\\[\\]\\.:\\/",e7=new RegExp("["+V1+"]","g"),H1="[^"+V1+"]",i7="[^"+V1.replace("\\.","")+"]",n7=/((?:WC+[\/:])*)/.source.replace("WC",H1),r7=/(WCOD+)?/.source.replace("WCOD",i7),s7=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",H1),a7=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",H1),o7=new RegExp("^"+n7+r7+s7+a7+"$"),l7=["material","materials","bones","map"];class h7{constructor(t,i,x){const T=x||Xi.parseTrackName(i);this._targetGroup=t,this._bindings=t.subscribe_(i,T)}getValue(t,i){this.bind();const x=this._targetGroup.nCachedObjects_,T=this._bindings[x];T!==void 0&&T.getValue(t,i)}setValue(t,i){const x=this._bindings;for(let T=this._targetGroup.nCachedObjects_,E=x.length;T!==E;++T)x[T].setValue(t,i)}bind(){const t=this._bindings;for(let i=this._targetGroup.nCachedObjects_,x=t.length;i!==x;++i)t[i].bind()}unbind(){const t=this._bindings;for(let i=this._targetGroup.nCachedObjects_,x=t.length;i!==x;++i)t[i].unbind()}}class Xi{constructor(t,i,x){this.path=i,this.parsedPath=x||Xi.parseTrackName(i),this.node=Xi.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,i,x){return t&&t.isAnimationObjectGroup?new Xi.Composite(t,i,x):new Xi(t,i,x)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(e7,"")}static parseTrackName(t){const i=o7.exec(t);if(i===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const x={nodeName:i[2],objectName:i[3],objectIndex:i[4],propertyName:i[5],propertyIndex:i[6]},T=x.nodeName&&x.nodeName.lastIndexOf(".");if(T!==void 0&&T!==-1){const E=x.nodeName.substring(T+1);l7.indexOf(E)!==-1&&(x.nodeName=x.nodeName.substring(0,T),x.objectName=E)}if(x.propertyName===null||x.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return x}static findNode(t,i){if(i===void 0||i===""||i==="."||i===-1||i===t.name||i===t.uuid)return t;if(t.skeleton){const x=t.skeleton.getBoneByName(i);if(x!==void 0)return x}if(t.children){const x=function(E){for(let s=0;s=E){const h=E++,a=t[h];i[a.uuid]=p,t[p]=a,i[r]=h,t[h]=e;for(let l=0,n=T;l!==n;++l){const u=x[l],f=u[h],o=u[p];u[p]=f,u[h]=o}}}this.nCachedObjects_=E}uncache(){const t=this._objects,i=this._indicesByUUID,x=this._bindings,T=x.length;let E=this.nCachedObjects_,s=t.length;for(let y=0,e=arguments.length;y!==e;++y){const r=arguments[y],p=r.uuid,h=i[p];if(h!==void 0)if(delete i[p],h0&&(i[l.uuid]=h),t[h]=l,t.pop();for(let n=0,u=T;n!==u;++n){const f=x[n];f[h]=f[a],f.pop()}}}this.nCachedObjects_=E}subscribe_(t,i){const x=this._bindingsIndicesByPath;let T=x[t];const E=this._bindings;if(T!==void 0)return E[T];const s=this._paths,y=this._parsedPaths,e=this._objects,r=e.length,p=this.nCachedObjects_,h=new Array(r);T=E.length,x[t]=T,s.push(t),y.push(i),E.push(h);for(let a=p,l=e.length;a!==l;++a){const n=e[a];h[a]=new Xi(n,t,i)}return h}unsubscribe_(t){const i=this._bindingsIndicesByPath,x=i[t];if(x!==void 0){const T=this._paths,E=this._parsedPaths,s=this._bindings,y=s.length-1,e=s[y],r=t[y];i[r]=x,s[x]=e,s.pop(),E[x]=E[y],E.pop(),T[x]=T[y],T.pop()}}}class xA{constructor(t,i,x=null,T=i.blendMode){this._mixer=t,this._clip=i,this._localRoot=x,this.blendMode=T;const E=i.tracks,s=E.length,y=new Array(s),e={endingStart:pu,endingEnd:pu};for(let r=0;r!==s;++r){const p=E[r].createInterpolant(null);y[r]=p,p.settings=e}this._interpolantSettings=e,this._interpolants=y,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=_2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,i){return this.loop=t,this.repetitions=i,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,i,x){if(t.fadeOut(i),this.fadeIn(i),x){const T=this._clip.duration,E=t._clip.duration,s=E/T,y=T/E;t.warp(1,s,i),this.warp(y,1,i)}return this}crossFadeTo(t,i,x){return t.crossFadeFrom(this,i,x)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,i,x){const T=this._mixer,E=T.time,s=this.timeScale;let y=this._timeScaleInterpolant;y===null&&(y=T._lendControlInterpolant(),this._timeScaleInterpolant=y);const e=y.parameterPositions,r=y.sampleValues;return e[0]=E,e[1]=E+x,r[0]=t/s,r[1]=i/s,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,i,x,T){if(!this.enabled){this._updateWeight(t);return}const E=this._startTime;if(E!==null){const e=(t-E)*x;e<0||x===0?i=0:(this._startTime=null,i=x*e)}i*=this._updateTimeScale(t);const s=this._updateTime(i),y=this._updateWeight(t);if(y>0){const e=this._interpolants,r=this._propertyBindings;switch(this.blendMode){case f1:for(let p=0,h=e.length;p!==h;++p)e[p].evaluate(s),r[p].accumulateAdditive(y);break;case og:default:for(let p=0,h=e.length;p!==h;++p)e[p].evaluate(s),r[p].accumulate(T,y)}}}_updateWeight(t){let i=0;if(this.enabled){i=this.weight;const x=this._weightInterpolant;if(x!==null){const T=x.evaluate(t)[0];i*=T,t>x.parameterPositions[1]&&(this.stopFading(),T===0&&(this.enabled=!1))}}return this._effectiveWeight=i,i}_updateTimeScale(t){let i=0;if(!this.paused){i=this.timeScale;const x=this._timeScaleInterpolant;if(x!==null){const T=x.evaluate(t)[0];i*=T,t>x.parameterPositions[1]&&(this.stopWarping(),i===0?this.paused=!0:this.timeScale=i)}}return this._effectiveTimeScale=i,i}_updateTime(t){const i=this._clip.duration,x=this.loop;let T=this.time+t,E=this._loopCount;const s=x===q2;if(t===0)return E===-1?T:s&&(E&1)===1?i-T:T;if(x===Q2){E===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(T>=i)T=i;else if(T<0)T=0;else{this.time=T;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=T,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(E===-1&&(t>=0?(E=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),T>=i||T<0){const y=Math.floor(T/i);T-=i*y,E+=Math.abs(y);const e=this.repetitions-E;if(e<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,T=t>0?i:0,this.time=T,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(e===1){const r=t<0;this._setEndings(r,!r,s)}else this._setEndings(!1,!1,s);this._loopCount=E,this.time=T,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:y})}}else this.time=T;if(s&&(E&1)===1)return i-T}return T}_setEndings(t,i,x){const T=this._interpolantSettings;x?(T.endingStart=vu,T.endingEnd=vu):(t?T.endingStart=this.zeroSlopeAtStart?vu:pu:T.endingStart=Pd,i?T.endingEnd=this.zeroSlopeAtEnd?vu:pu:T.endingEnd=Pd)}_scheduleFading(t,i,x){const T=this._mixer,E=T.time;let s=this._weightInterpolant;s===null&&(s=T._lendControlInterpolant(),this._weightInterpolant=s);const y=s.parameterPositions,e=s.sampleValues;return y[0]=E,e[0]=i,y[1]=E+t,e[1]=x,this}}const f7=new Float32Array(1);class c7 extends Pl{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,i){const x=t._localRoot||this._root,T=t._clip.tracks,E=T.length,s=t._propertyBindings,y=t._interpolants,e=x.uuid,r=this._bindingsByRootAndName;let p=r[e];p===void 0&&(p={},r[e]=p);for(let h=0;h!==E;++h){const a=T[h],l=a.name;let n=p[l];if(n!==void 0)++n.referenceCount,s[h]=n;else{if(n=s[h],n!==void 0){n._cacheIndex===null&&(++n.referenceCount,this._addInactiveBinding(n,e,l));continue}const u=i&&i._propertyBindings[h].binding.parsedPath;n=new yA(Xi.create(x,l,u),a.ValueTypeName,a.getValueSize()),++n.referenceCount,this._addInactiveBinding(n,e,l),s[h]=n}y[h].resultBuffer=n.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const x=(t._localRoot||this._root).uuid,T=t._clip.uuid,E=this._actionsByClip[T];this._bindAction(t,E&&E.knownActions[0]),this._addInactiveAction(t,T,x)}const i=t._propertyBindings;for(let x=0,T=i.length;x!==T;++x){const E=i[x];E.useCount++===0&&(this._lendBinding(E),E.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const i=t._propertyBindings;for(let x=0,T=i.length;x!==T;++x){const E=i[x];--E.useCount===0&&(E.restoreOriginalState(),this._takeBackBinding(E))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const i=t._cacheIndex;return i!==null&&i=0;--x)t[x].stop();return this}update(t){t*=this.timeScale;const i=this._actions,x=this._nActiveActions,T=this.time+=t,E=Math.sign(t),s=this._accuIndex^=1;for(let r=0;r!==x;++r)i[r]._update(T,t,E,s);const y=this._bindings,e=this._nActiveBindings;for(let r=0;r!==e;++r)y[r].apply(s);return this}setTime(t){this.time=0;for(let i=0;ithis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,i){return i.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,i){return i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ZE).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const JE=new Ct,Vv=new Ct;class S7{constructor(t=new Ct,i=new Ct){this.start=t,this.end=i}set(t,i){return this.start.copy(t),this.end.copy(i),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,i){return this.delta(i).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,i){JE.subVectors(t,this.start),Vv.subVectors(this.end,this.start);const x=Vv.dot(Vv);let E=Vv.dot(JE)/x;return i&&(E=jn(E,0,1)),E}closestPointToPoint(t,i,x){const T=this.closestPointToPointParameter(t,i);return this.delta(x).multiplyScalar(T).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const $E=new Ct;class T7 extends Yi{constructor(t,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="SpotLightHelper";const x=new Li,T=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,y=1,e=32;s1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{eM.set(t.z,0,-t.x).normalize();const i=Math.acos(t.y);this.quaternion.setFromAxisAngle(eM,i)}}setLength(t,i=t*.2,x=i*.2){this.line.scale.set(1,Math.max(1e-4,t-i),1),this.line.updateMatrix(),this.cone.scale.set(x,i,x),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class I7 extends Ho{constructor(t=1){const i=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],x=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],T=new Li;T.setAttribute("position",new ke(i,3)),T.setAttribute("color",new ke(x,3));const E=new ys({vertexColors:!0,toneMapped:!1});super(T,E),this.type="AxesHelper"}setColors(t,i,x){const T=new ze,E=this.geometry.attributes.color.array;return T.set(t),T.toArray(E,0),T.toArray(E,3),T.set(i),T.toArray(E,6),T.toArray(E,9),T.set(x),T.toArray(E,12),T.toArray(E,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class N7{constructor(){this.type="ShapePath",this.color=new ze,this.subPaths=[],this.currentPath=null}moveTo(t,i){return this.currentPath=new Id,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,i),this}lineTo(t,i){return this.currentPath.lineTo(t,i),this}quadraticCurveTo(t,i,x,T){return this.currentPath.quadraticCurveTo(t,i,x,T),this}bezierCurveTo(t,i,x,T,E,s){return this.currentPath.bezierCurveTo(t,i,x,T,E,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function i(o){const c=[];for(let d=0,v=o.length;dNumber.EPSILON){if(A<0&&(M=c[S],C=-C,w=c[m],A=-A),o.yw.y)continue;if(o.y===M.y){if(o.x===M.x)return!0}else{const P=A*(o.x-M.x)-C*(o.y-M.y);if(P===0)return!0;if(P<0)continue;v=!v}}else{if(o.y!==M.y)continue;if(w.x<=o.x&&o.x<=M.x||M.x<=o.x&&o.x<=w.x)return!0}}return v}const T=zo.isClockWise,E=this.subPaths;if(E.length===0)return[];let s,y,e;const r=[];if(E.length===1)return y=E[0],e=new Mu,e.curves=y.curves,r.push(e),r;let p=!T(E[0].getPoints());p=t?!p:p;const h=[],a=[];let l=[],n=0,u;a[n]=void 0,l[n]=[];for(let o=0,c=E.length;o1){let o=!1,c=0;for(let d=0,v=a.length;d0&&o===!1&&(l=h)}let f;for(let o=0,c=a.length;o{const h=typeof r=="function"?r(t):r;if(h!==t){const a=t;t=p?h:Object.assign({},t,h),i.forEach(l=>l(t,a))}},T=()=>t,E=(r,p=T,h=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let a=p(t);function l(){const n=p(t);if(!h(a,n)){const u=a;r(a=n,u)}}return i.add(l),()=>i.delete(l)},e={setState:x,getState:T,subscribe:(r,p,h)=>p||h?E(r,p,h):(i.add(r),()=>i.delete(r)),destroy:()=>i.clear()};return t=g(x,T,e),e}const z7=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),iM=z7?Pe.useEffect:Pe.useLayoutEffect;function G7(g){const t=typeof g=="function"?U7(g):g,i=(x=t.getState,T=Object.is)=>{const[,E]=Pe.useReducer(f=>f+1,0),s=t.getState(),y=Pe.useRef(s),e=Pe.useRef(x),r=Pe.useRef(T),p=Pe.useRef(!1),h=Pe.useRef();h.current===void 0&&(h.current=x(s));let a,l=!1;(y.current!==s||e.current!==x||r.current!==T||p.current)&&(a=x(s),l=!T(h.current,a)),iM(()=>{l&&(h.current=a),y.current=s,e.current=x,r.current=T,p.current=!1});const n=Pe.useRef(s);iM(()=>{const f=()=>{try{const c=t.getState(),d=e.current(c);r.current(h.current,d)||(y.current=c,h.current=d,E())}catch{p.current=!0,E()}},o=t.subscribe(f);return t.getState()!==n.current&&f(),o},[]);const u=l?a:h.current;return Pe.useDebugValue(u),u};return Object.assign(i,t),i[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const x=[i,t];return{next(){const T=x.length<=0;return{value:x.shift(),done:T}}}},i}var MA={exports:{}},iy={exports:{}},ny={};/** + */Nu.ConcurrentRoot=1;Nu.ContinuousEventPriority=4;Nu.DefaultEventPriority=16;Nu.DiscreteEventPriority=1;Nu.IdleEventPriority=536870912;Nu.LegacyRoot=0;EA.exports=Nu;var Hf=EA.exports;function U7(g){let t;const i=new Set,x=(r,p)=>{const h=typeof r=="function"?r(t):r;if(h!==t){const a=t;t=p?h:Object.assign({},t,h),i.forEach(l=>l(t,a))}},T=()=>t,E=(r,p=T,h=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let a=p(t);function l(){const n=p(t);if(!h(a,n)){const u=a;r(a=n,u)}}return i.add(l),()=>i.delete(l)},e={setState:x,getState:T,subscribe:(r,p,h)=>p||h?E(r,p,h):(i.add(r),()=>i.delete(r)),destroy:()=>i.clear()};return t=g(x,T,e),e}const z7=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),iM=z7?Pe.useEffect:Pe.useLayoutEffect;function G7(g){const t=typeof g=="function"?U7(g):g,i=(x=t.getState,T=Object.is)=>{const[,E]=Pe.useReducer(f=>f+1,0),s=t.getState(),y=Pe.useRef(s),e=Pe.useRef(x),r=Pe.useRef(T),p=Pe.useRef(!1),h=Pe.useRef();h.current===void 0&&(h.current=x(s));let a,l=!1;(y.current!==s||e.current!==x||r.current!==T||p.current)&&(a=x(s),l=!T(h.current,a)),iM(()=>{l&&(h.current=a),y.current=s,e.current=x,r.current=T,p.current=!1});const n=Pe.useRef(s);iM(()=>{const f=()=>{try{const c=t.getState(),d=e.current(c);r.current(h.current,d)||(y.current=c,h.current=d,E())}catch{p.current=!0,E()}},o=t.subscribe(f);return t.getState()!==n.current&&f(),o},[]);const u=l?a:h.current;return Pe.useDebugValue(u),u};return Object.assign(i,t),i[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const x=[i,t];return{next(){const T=x.length<=0;return{value:x.shift(),done:T}}}},i}var MA={exports:{}},ny={exports:{}},ry={};/** * @license React * scheduler.production.min.js * @@ -10180,7 +10180,7 @@ void main() { * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var nM;function V7(){return nM||(nM=1,function(g){function t(z,X){var K=z.length;z.push(X);t:for(;0>>1,tt=z[Q];if(0>>1;QT(U,K))HT(J,U)?(z[Q]=J,z[H]=K,Q=H):(z[Q]=U,z[Z]=K,Q=Z);else if(HT(J,K))z[Q]=J,z[H]=K,Q=H;else break t}}return X}function T(z,X){var K=z.sortIndex-X.sortIndex;return K!==0?K:z.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var E=performance;g.unstable_now=function(){return E.now()}}else{var s=Date,y=s.now();g.unstable_now=function(){return s.now()-y}}var e=[],r=[],p=1,h=null,a=3,l=!1,n=!1,u=!1,f=typeof setTimeout=="function"?setTimeout:null,o=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(z){for(var X=i(r);X!==null;){if(X.callback===null)x(r);else if(X.startTime<=z)x(r),X.sortIndex=X.expirationTime,t(e,X);else break;X=i(r)}}function v(z){if(u=!1,d(z),!n)if(i(e)!==null)n=!0,B(m);else{var X=i(r);X!==null&&G(v,X.startTime-z)}}function m(z,X){n=!1,u&&(u=!1,o(w),w=-1),l=!0;var K=a;try{for(d(X),h=i(e);h!==null&&(!(h.expirationTime>X)||z&&!P());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,a=h.priorityLevel;var tt=Q(h.expirationTime<=X);X=g.unstable_now(),typeof tt=="function"?h.callback=tt:h===i(e)&&x(e),d(X)}else x(e);h=i(e)}if(h!==null)var Y=!0;else{var Z=i(r);Z!==null&&G(v,Z.startTime-X),Y=!1}return Y}finally{h=null,a=K,l=!1}}var S=!1,M=null,w=-1,C=5,A=-1;function P(){return!(g.unstable_now()-Az||125Q?(z.sortIndex=K,t(r,z),i(e)===null&&z===i(r)&&(u?(o(w),w=-1):u=!0,G(v,K-Q))):(z.sortIndex=tt,t(e,z),n||l||(n=!0,B(m))),z},g.unstable_shouldYield=P,g.unstable_wrapCallback=function(z){var X=a;return function(){var K=a;a=X;try{return z.apply(this,arguments)}finally{a=K}}}}(ny)),ny}var rM;function H7(){return rM||(rM=1,iy.exports=V7()),iy.exports}/** + */var nM;function V7(){return nM||(nM=1,function(g){function t(z,X){var K=z.length;z.push(X);t:for(;0>>1,tt=z[Q];if(0>>1;QT(U,K))HT(J,U)?(z[Q]=J,z[H]=K,Q=H):(z[Q]=U,z[Z]=K,Q=Z);else if(HT(J,K))z[Q]=J,z[H]=K,Q=H;else break t}}return X}function T(z,X){var K=z.sortIndex-X.sortIndex;return K!==0?K:z.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var E=performance;g.unstable_now=function(){return E.now()}}else{var s=Date,y=s.now();g.unstable_now=function(){return s.now()-y}}var e=[],r=[],p=1,h=null,a=3,l=!1,n=!1,u=!1,f=typeof setTimeout=="function"?setTimeout:null,o=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(z){for(var X=i(r);X!==null;){if(X.callback===null)x(r);else if(X.startTime<=z)x(r),X.sortIndex=X.expirationTime,t(e,X);else break;X=i(r)}}function v(z){if(u=!1,d(z),!n)if(i(e)!==null)n=!0,B(m);else{var X=i(r);X!==null&&G(v,X.startTime-z)}}function m(z,X){n=!1,u&&(u=!1,o(w),w=-1),l=!0;var K=a;try{for(d(X),h=i(e);h!==null&&(!(h.expirationTime>X)||z&&!P());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,a=h.priorityLevel;var tt=Q(h.expirationTime<=X);X=g.unstable_now(),typeof tt=="function"?h.callback=tt:h===i(e)&&x(e),d(X)}else x(e);h=i(e)}if(h!==null)var Y=!0;else{var Z=i(r);Z!==null&&G(v,Z.startTime-X),Y=!1}return Y}finally{h=null,a=K,l=!1}}var S=!1,M=null,w=-1,C=5,A=-1;function P(){return!(g.unstable_now()-Az||125Q?(z.sortIndex=K,t(r,z),i(e)===null&&z===i(r)&&(u?(o(w),w=-1):u=!0,G(v,K-Q))):(z.sortIndex=tt,t(e,z),n||l||(n=!0,B(m))),z},g.unstable_shouldYield=P,g.unstable_wrapCallback=function(z){var X=a;return function(){var K=a;a=X;try{return z.apply(this,arguments)}finally{a=K}}}}(ry)),ry}var rM;function H7(){return rM||(rM=1,ny.exports=V7()),ny.exports}/** * @license React * react-reconciler.production.min.js * @@ -10192,13 +10192,13 @@ void main() { `+$e+L}var ii=!1;function ai(L,F){if(!L||ii)return"";ii=!0;var W=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(Ee){var $=Ee}Reflect.construct(L,[],F)}else{try{F.call()}catch(Ee){$=Ee}L.call(F.prototype)}else{try{throw Error()}catch(Ee){$=Ee}L()}}catch(Ee){if(Ee&&$&&typeof Ee.stack=="string"){for(var it=Ee.stack.split(` `),lt=$.stack.split(` `),wt=it.length-1,Xt=lt.length-1;1<=wt&&0<=Xt&&it[wt]!==lt[Xt];)Xt--;for(;1<=wt&&0<=Xt;wt--,Xt--)if(it[wt]!==lt[Xt]){if(wt!==1||Xt!==1)do if(wt--,Xt--,0>Xt||it[wt]!==lt[Xt]){var ae=` -`+it[wt].replace(" at new "," at ");return L.displayName&&ae.includes("")&&(ae=ae.replace("",L.displayName)),ae}while(1<=wt&&0<=Xt);break}}}finally{ii=!1,Error.prepareStackTrace=W}return(L=L?L.displayName||L.name:"")?qe(L):""}var Ji=Object.prototype.hasOwnProperty,hn=[],ki=-1;function mn(L){return{current:L}}function ti(L){0>ki||(L.current=hn[ki],hn[ki]=null,ki--)}function Se(L,F){ki++,hn[ki]=L.current,L.current=F}var Nr={},mi=mn(Nr),un=mn(!1),Ii=Nr;function Gn(L,F){var W=L.type.contextTypes;if(!W)return Nr;var $=L.stateNode;if($&&$.__reactInternalMemoizedUnmaskedChildContext===F)return $.__reactInternalMemoizedMaskedChildContext;var it={},lt;for(lt in W)it[lt]=F[lt];return $&&(L=L.stateNode,L.__reactInternalMemoizedUnmaskedChildContext=F,L.__reactInternalMemoizedMaskedChildContext=it),it}function pn(L){return L=L.childContextTypes,L!=null}function Ki(){ti(un),ti(mi)}function dr(L,F,W){if(mi.current!==Nr)throw Error(s(168));Se(mi,F),Se(un,W)}function zs(L,F,W){var $=L.stateNode;if(F=F.childContextTypes,typeof $.getChildContext!="function")return W;$=$.getChildContext();for(var it in $)if(!(it in F))throw Error(s(108,w(L)||"Unknown",it));return E({},W,$)}function Tn(L){return L=(L=L.stateNode)&&L.__reactInternalMemoizedMergedChildContext||Nr,Ii=mi.current,Se(mi,L),Se(un,un.current),!0}function oa(L,F,W){var $=L.stateNode;if(!$)throw Error(s(169));W?(L=zs(L,F,Ii),$.__reactInternalMemoizedMergedChildContext=L,ti(un),ti(mi),Se(mi,L)):ti(un),Se(un,W)}var Jn=Math.clz32?Math.clz32:lo,Ra=Math.log,Gs=Math.LN2;function lo(L){return L>>>=0,L===0?32:31-(Ra(L)/Gs|0)|0}var ba=64,ho=4194304;function gi(L){switch(L&-L){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 L&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return L&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return L}}function La(L,F){var W=L.pendingLanes;if(W===0)return 0;var $=0,it=L.suspendedLanes,lt=L.pingedLanes,wt=W&268435455;if(wt!==0){var Xt=wt&~it;Xt!==0?$=gi(Xt):(lt&=wt,lt!==0&&($=gi(lt)))}else wt=W&~it,wt!==0?$=gi(wt):lt!==0&&($=gi(lt));if($===0)return 0;if(F!==0&&F!==$&&!(F&it)&&(it=$&-$,lt=F&-F,it>=lt||it===16&&(lt&4194240)!==0))return F;if($&4&&($|=W&16),F=L.entangledLanes,F!==0)for(L=L.entanglements,F&=$;0W;W++)F.push(L);return F}function Hs(L,F,W){L.pendingLanes|=F,F!==536870912&&(L.suspendedLanes=0,L.pingedLanes=0),L=L.eventTimes,F=31-Jn(F),L[F]=W}function Ws(L,F){var W=L.pendingLanes&~F;L.pendingLanes=F,L.suspendedLanes=0,L.pingedLanes=0,L.expiredLanes&=F,L.mutableReadLanes&=F,L.entangledLanes&=F,F=L.entanglements;var $=L.eventTimes;for(L=L.expirationTimes;0>=wt,it-=wt,Es=1<<32-Jn(F)+it|W<Ci?(Yn=yi,yi=null):Yn=yi.sibling;var Ui=Qe(Jt,yi,re[Ci],Ne);if(Ui===null){yi===null&&(yi=Yn);break}L&&yi&&Ui.alternate===null&&F(Jt,yi),Yt=lt(Ui,Yt,Ci),Mi===null?Ye=Ui:Mi.sibling=Ui,Mi=Ui,yi=Yn}if(Ci===re.length)return W(Jt,yi),_i&&Ms(Jt,Ci),Ye;if(yi===null){for(;CiCi?(Yn=yi,yi=null):Yn=yi.sibling;var ga=Qe(Jt,yi,Ui.value,Ne);if(ga===null){yi===null&&(yi=Yn);break}L&&yi&&ga.alternate===null&&F(Jt,yi),Yt=lt(ga,Yt,Ci),Mi===null?Ye=ga:Mi.sibling=ga,Mi=ga,yi=Yn}if(Ui.done)return W(Jt,yi),_i&&Ms(Jt,Ci),Ye;if(yi===null){for(;!Ui.done;Ci++,Ui=re.next())Ui=vi(Jt,Ui.value,Ne),Ui!==null&&(Yt=lt(Ui,Yt,Ci),Mi===null?Ye=Ui:Mi.sibling=Ui,Mi=Ui);return _i&&Ms(Jt,Ci),Ye}for(yi=$(Jt,yi);!Ui.done;Ci++,Ui=re.next())Ui=qi(yi,Jt,Ci,Ui.value,Ne),Ui!==null&&(L&&Ui.alternate!==null&&yi.delete(Ui.key===null?Ci:Ui.key),Yt=lt(Ui,Yt,Ci),Mi===null?Ye=Ui:Mi.sibling=Ui,Mi=Ui);return L&&yi.forEach(function(rf){return F(Jt,rf)}),_i&&Ms(Jt,Ci),Ye}function hs(Jt,Yt,re,Ne){if(typeof re=="object"&&re!==null&&re.type===p&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case e:t:{for(var Ye=re.key,Mi=Yt;Mi!==null;){if(Mi.key===Ye){if(Ye=re.type,Ye===p){if(Mi.tag===7){W(Jt,Mi.sibling),Yt=it(Mi,re.props.children),Yt.return=Jt,Jt=Yt;break t}}else if(Mi.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===d&&Ha(Ye)===Mi.type){W(Jt,Mi.sibling),Yt=it(Mi,re.props),Yt.ref=Va(Jt,Mi,re),Yt.return=Jt,Jt=Yt;break t}W(Jt,Mi);break}else F(Jt,Mi);Mi=Mi.sibling}re.type===p?(Yt=bo(re.props.children,Jt.mode,Ne,re.key),Yt.return=Jt,Jt=Yt):(Ne=ef(re.type,re.key,re.props,null,Jt.mode,Ne),Ne.ref=Va(Jt,Yt,re),Ne.return=Jt,Jt=Ne)}return wt(Jt);case r:t:{for(Mi=re.key;Yt!==null;){if(Yt.key===Mi)if(Yt.tag===4&&Yt.stateNode.containerInfo===re.containerInfo&&Yt.stateNode.implementation===re.implementation){W(Jt,Yt.sibling),Yt=it(Yt,re.children||[]),Yt.return=Jt,Jt=Yt;break t}else{W(Jt,Yt);break}else F(Jt,Yt);Yt=Yt.sibling}Yt=Rs(re,Jt.mode,Ne),Yt.return=Jt,Jt=Yt}return wt(Jt);case d:return Mi=re._init,hs(Jt,Yt,Mi(re._payload),Ne)}if(D(re))return Xe(Jt,Yt,re,Ne);if(S(re))return br(Jt,Yt,re,Ne);Qn(Jt,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,Yt!==null&&Yt.tag===6?(W(Jt,Yt.sibling),Yt=it(Yt,re),Yt.return=Jt,Jt=Yt):(W(Jt,Yt),Yt=Rr(re,Jt.mode,Ne),Yt.return=Jt,Jt=Yt),wt(Jt)):W(Jt,Yt)}return hs}var Gr=Wa(!0),Ah=Wa(!1),V={},j=mn(V),et=mn(V),st=mn(V);function ht(L){if(L===V)throw Error(s(174));return L}function pt(L,F){Se(st,F),Se(et,L),Se(j,V),L=G(F),ti(j),Se(j,L)}function Mt(){ti(j),ti(et),ti(st)}function Nt(L){var F=ht(st.current),W=ht(j.current);F=z(W,L.type,F),W!==F&&(Se(et,L),Se(j,F))}function zt(L){et.current===L&&(ti(j),ti(et))}var ct=mn(0);function St(L){for(var F=L;F!==null;){if(F.tag===13){var W=F.memoizedState;if(W!==null&&(W=W.dehydrated,W===null||Pa(W)||aa(W)))return F}else if(F.tag===19&&F.memoizedProps.revealOrder!==void 0){if(F.flags&128)return F}else if(F.child!==null){F.child.return=F,F=F.child;continue}if(F===L)break;for(;F.sibling===null;){if(F.return===null||F.return===L)return null;F=F.return}F.sibling.return=F.return,F=F.sibling}return null}var vt=[];function Ft(){for(var L=0;LW?W:4,L(!0);var $=Ut.transition;Ut.transition={};try{L(!1),F()}finally{Ni=W,Ut.transition=$}}function lp(){return Ze().memoizedState}function _n(L,F,W){var $=va(L);W={lane:$,action:W,hasEagerState:!1,eagerState:null,next:null},hp(L)?up(F,W):(fc(L,F,W),W=wr(),L=As(L,$,W),L!==null&&fp(L,F,$))}function Er(L,F,W){var $=va(L),it={lane:$,action:W,hasEagerState:!1,eagerState:null,next:null};if(hp(L))up(F,it);else{fc(L,F,it);var lt=L.alternate;if(L.lanes===0&&(lt===null||lt.lanes===0)&&(lt=F.lastRenderedReducer,lt!==null))try{var wt=F.lastRenderedState,Xt=lt(wt,W);if(it.hasEagerState=!0,it.eagerState=Xt,Ts(Xt,wt))return}catch{}finally{}W=wr(),L=As(L,$,W),L!==null&&fp(L,F,$)}}function hp(L){var F=L.alternate;return L===It||F!==null&&F===It}function up(L,F){se=$t=!0;var W=L.pending;W===null?F.next=F:(F.next=W.next,W.next=F),L.pending=F}function fc(L,F,W){Wn!==null&&L.mode&1&&!(Ei&2)?(L=F.interleaved,L===null?(W.next=W,Wr===null?Wr=[F]:Wr.push(F)):(W.next=L.next,L.next=W),F.interleaved=W):(L=F.pending,L===null?W.next=W:(W.next=L.next,L.next=W),F.pending=W)}function fp(L,F,W){if(W&4194240){var $=F.lanes;$&=L.pendingLanes,W|=$,F.lanes=W,bl(L,W)}}var zl={readContext:$i,useCallback:pe,useContext:pe,useEffect:pe,useImperativeHandle:pe,useInsertionEffect:pe,useLayoutEffect:pe,useMemo:pe,useReducer:pe,useRef:pe,useState:pe,useDebugValue:pe,useDeferredValue:pe,useTransition:pe,useMutableSource:pe,useSyncExternalStore:pe,useId:pe,unstable_isNewReconciler:!1},Fh={readContext:$i,useCallback:function(L,F){return _e().memoizedState=[L,F===void 0?null:F],L},useContext:$i,useEffect:Ul,useImperativeHandle:function(L,F,W){return W=W!=null?W.concat([L]):null,xo(4194308,4,Rh.bind(null,F,L),W)},useLayoutEffect:function(L,F){return xo(4194308,4,L,F)},useInsertionEffect:function(L,F){return xo(4,2,L,F)},useMemo:function(L,F){var W=_e();return F=F===void 0?null:F,L=L(),W.memoizedState=[L,F],L},useReducer:function(L,F,W){var $=_e();return F=W!==void 0?W(F):F,$.memoizedState=$.baseState=F,L={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:L,lastRenderedState:F},$.queue=L,L=L.dispatch=_n.bind(null,It,L),[$.memoizedState,L]},useRef:function(L){var F=_e();return L={current:L},F.memoizedState=L},useState:go,useDebugValue:Lh,useDeferredValue:function(L){var F=go(L),W=F[0],$=F[1];return Ul(function(){var it=Ut.transition;Ut.transition={};try{$(L)}finally{Ut.transition=it}},[L]),W},useTransition:function(){var L=go(!1),F=L[0];return L=Lg.bind(null,L[1]),_e().memoizedState=L,[F,L]},useMutableSource:function(){},useSyncExternalStore:function(L,F,W){var $=It,it=_e();if(_i){if(W===void 0)throw Error(s(407));W=W()}else{if(W=F(),Wn===null)throw Error(s(349));Wt&30||Cn($,F,W)}it.memoizedState=W;var lt={value:W,getSnapshot:F};return it.queue=lt,Ul(bn.bind(null,$,lt,L),[L]),$.flags|=2048,yo(9,mo.bind(null,$,lt,W,F),void 0,null),W},useId:function(){var L=_e(),F=Wn.identifierPrefix;if(_i){var W=es,$=Es;W=($&~(1<<32-Jn($)-1)).toString(32)+W,F=":"+F+"R"+W,W=ue++,0")&&(ae=ae.replace("",L.displayName)),ae}while(1<=wt&&0<=Xt);break}}}finally{ii=!1,Error.prepareStackTrace=W}return(L=L?L.displayName||L.name:"")?qe(L):""}var Ji=Object.prototype.hasOwnProperty,hn=[],ki=-1;function gn(L){return{current:L}}function ti(L){0>ki||(L.current=hn[ki],hn[ki]=null,ki--)}function Se(L,F){ki++,hn[ki]=L.current,L.current=F}var Nr={},mi=gn(Nr),un=gn(!1),Ii=Nr;function Gn(L,F){var W=L.type.contextTypes;if(!W)return Nr;var $=L.stateNode;if($&&$.__reactInternalMemoizedUnmaskedChildContext===F)return $.__reactInternalMemoizedMaskedChildContext;var it={},lt;for(lt in W)it[lt]=F[lt];return $&&(L=L.stateNode,L.__reactInternalMemoizedUnmaskedChildContext=F,L.__reactInternalMemoizedMaskedChildContext=it),it}function pn(L){return L=L.childContextTypes,L!=null}function Ki(){ti(un),ti(mi)}function dr(L,F,W){if(mi.current!==Nr)throw Error(s(168));Se(mi,F),Se(un,W)}function zs(L,F,W){var $=L.stateNode;if(F=F.childContextTypes,typeof $.getChildContext!="function")return W;$=$.getChildContext();for(var it in $)if(!(it in F))throw Error(s(108,w(L)||"Unknown",it));return E({},W,$)}function Tn(L){return L=(L=L.stateNode)&&L.__reactInternalMemoizedMergedChildContext||Nr,Ii=mi.current,Se(mi,L),Se(un,un.current),!0}function oa(L,F,W){var $=L.stateNode;if(!$)throw Error(s(169));W?(L=zs(L,F,Ii),$.__reactInternalMemoizedMergedChildContext=L,ti(un),ti(mi),Se(mi,L)):ti(un),Se(un,W)}var Jn=Math.clz32?Math.clz32:lo,Ra=Math.log,Gs=Math.LN2;function lo(L){return L>>>=0,L===0?32:31-(Ra(L)/Gs|0)|0}var ba=64,ho=4194304;function gi(L){switch(L&-L){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 L&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return L&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return L}}function La(L,F){var W=L.pendingLanes;if(W===0)return 0;var $=0,it=L.suspendedLanes,lt=L.pingedLanes,wt=W&268435455;if(wt!==0){var Xt=wt&~it;Xt!==0?$=gi(Xt):(lt&=wt,lt!==0&&($=gi(lt)))}else wt=W&~it,wt!==0?$=gi(wt):lt!==0&&($=gi(lt));if($===0)return 0;if(F!==0&&F!==$&&!(F&it)&&(it=$&-$,lt=F&-F,it>=lt||it===16&&(lt&4194240)!==0))return F;if($&4&&($|=W&16),F=L.entangledLanes,F!==0)for(L=L.entanglements,F&=$;0W;W++)F.push(L);return F}function Hs(L,F,W){L.pendingLanes|=F,F!==536870912&&(L.suspendedLanes=0,L.pingedLanes=0),L=L.eventTimes,F=31-Jn(F),L[F]=W}function Ws(L,F){var W=L.pendingLanes&~F;L.pendingLanes=F,L.suspendedLanes=0,L.pingedLanes=0,L.expiredLanes&=F,L.mutableReadLanes&=F,L.entangledLanes&=F,F=L.entanglements;var $=L.eventTimes;for(L=L.expirationTimes;0>=wt,it-=wt,Es=1<<32-Jn(F)+it|W<Ci?(Yn=yi,yi=null):Yn=yi.sibling;var Ui=Qe(Jt,yi,re[Ci],Ne);if(Ui===null){yi===null&&(yi=Yn);break}L&&yi&&Ui.alternate===null&&F(Jt,yi),Yt=lt(Ui,Yt,Ci),Mi===null?Ye=Ui:Mi.sibling=Ui,Mi=Ui,yi=Yn}if(Ci===re.length)return W(Jt,yi),_i&&Ms(Jt,Ci),Ye;if(yi===null){for(;CiCi?(Yn=yi,yi=null):Yn=yi.sibling;var ga=Qe(Jt,yi,Ui.value,Ne);if(ga===null){yi===null&&(yi=Yn);break}L&&yi&&ga.alternate===null&&F(Jt,yi),Yt=lt(ga,Yt,Ci),Mi===null?Ye=ga:Mi.sibling=ga,Mi=ga,yi=Yn}if(Ui.done)return W(Jt,yi),_i&&Ms(Jt,Ci),Ye;if(yi===null){for(;!Ui.done;Ci++,Ui=re.next())Ui=vi(Jt,Ui.value,Ne),Ui!==null&&(Yt=lt(Ui,Yt,Ci),Mi===null?Ye=Ui:Mi.sibling=Ui,Mi=Ui);return _i&&Ms(Jt,Ci),Ye}for(yi=$(Jt,yi);!Ui.done;Ci++,Ui=re.next())Ui=qi(yi,Jt,Ci,Ui.value,Ne),Ui!==null&&(L&&Ui.alternate!==null&&yi.delete(Ui.key===null?Ci:Ui.key),Yt=lt(Ui,Yt,Ci),Mi===null?Ye=Ui:Mi.sibling=Ui,Mi=Ui);return L&&yi.forEach(function(rf){return F(Jt,rf)}),_i&&Ms(Jt,Ci),Ye}function hs(Jt,Yt,re,Ne){if(typeof re=="object"&&re!==null&&re.type===p&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case e:t:{for(var Ye=re.key,Mi=Yt;Mi!==null;){if(Mi.key===Ye){if(Ye=re.type,Ye===p){if(Mi.tag===7){W(Jt,Mi.sibling),Yt=it(Mi,re.props.children),Yt.return=Jt,Jt=Yt;break t}}else if(Mi.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===d&&Ha(Ye)===Mi.type){W(Jt,Mi.sibling),Yt=it(Mi,re.props),Yt.ref=Va(Jt,Mi,re),Yt.return=Jt,Jt=Yt;break t}W(Jt,Mi);break}else F(Jt,Mi);Mi=Mi.sibling}re.type===p?(Yt=bo(re.props.children,Jt.mode,Ne,re.key),Yt.return=Jt,Jt=Yt):(Ne=ef(re.type,re.key,re.props,null,Jt.mode,Ne),Ne.ref=Va(Jt,Yt,re),Ne.return=Jt,Jt=Ne)}return wt(Jt);case r:t:{for(Mi=re.key;Yt!==null;){if(Yt.key===Mi)if(Yt.tag===4&&Yt.stateNode.containerInfo===re.containerInfo&&Yt.stateNode.implementation===re.implementation){W(Jt,Yt.sibling),Yt=it(Yt,re.children||[]),Yt.return=Jt,Jt=Yt;break t}else{W(Jt,Yt);break}else F(Jt,Yt);Yt=Yt.sibling}Yt=Rs(re,Jt.mode,Ne),Yt.return=Jt,Jt=Yt}return wt(Jt);case d:return Mi=re._init,hs(Jt,Yt,Mi(re._payload),Ne)}if(D(re))return Xe(Jt,Yt,re,Ne);if(S(re))return br(Jt,Yt,re,Ne);Qn(Jt,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,Yt!==null&&Yt.tag===6?(W(Jt,Yt.sibling),Yt=it(Yt,re),Yt.return=Jt,Jt=Yt):(W(Jt,Yt),Yt=Rr(re,Jt.mode,Ne),Yt.return=Jt,Jt=Yt),wt(Jt)):W(Jt,Yt)}return hs}var Gr=Wa(!0),Ah=Wa(!1),V={},j=gn(V),et=gn(V),st=gn(V);function ht(L){if(L===V)throw Error(s(174));return L}function pt(L,F){Se(st,F),Se(et,L),Se(j,V),L=G(F),ti(j),Se(j,L)}function Mt(){ti(j),ti(et),ti(st)}function Nt(L){var F=ht(st.current),W=ht(j.current);F=z(W,L.type,F),W!==F&&(Se(et,L),Se(j,F))}function zt(L){et.current===L&&(ti(j),ti(et))}var ct=gn(0);function St(L){for(var F=L;F!==null;){if(F.tag===13){var W=F.memoizedState;if(W!==null&&(W=W.dehydrated,W===null||Pa(W)||aa(W)))return F}else if(F.tag===19&&F.memoizedProps.revealOrder!==void 0){if(F.flags&128)return F}else if(F.child!==null){F.child.return=F,F=F.child;continue}if(F===L)break;for(;F.sibling===null;){if(F.return===null||F.return===L)return null;F=F.return}F.sibling.return=F.return,F=F.sibling}return null}var vt=[];function Ft(){for(var L=0;LW?W:4,L(!0);var $=Ut.transition;Ut.transition={};try{L(!1),F()}finally{Ni=W,Ut.transition=$}}function lp(){return Ze().memoizedState}function _n(L,F,W){var $=va(L);W={lane:$,action:W,hasEagerState:!1,eagerState:null,next:null},hp(L)?up(F,W):(fc(L,F,W),W=wr(),L=As(L,$,W),L!==null&&fp(L,F,$))}function Er(L,F,W){var $=va(L),it={lane:$,action:W,hasEagerState:!1,eagerState:null,next:null};if(hp(L))up(F,it);else{fc(L,F,it);var lt=L.alternate;if(L.lanes===0&&(lt===null||lt.lanes===0)&&(lt=F.lastRenderedReducer,lt!==null))try{var wt=F.lastRenderedState,Xt=lt(wt,W);if(it.hasEagerState=!0,it.eagerState=Xt,Ts(Xt,wt))return}catch{}finally{}W=wr(),L=As(L,$,W),L!==null&&fp(L,F,$)}}function hp(L){var F=L.alternate;return L===It||F!==null&&F===It}function up(L,F){se=$t=!0;var W=L.pending;W===null?F.next=F:(F.next=W.next,W.next=F),L.pending=F}function fc(L,F,W){Wn!==null&&L.mode&1&&!(Ei&2)?(L=F.interleaved,L===null?(W.next=W,Wr===null?Wr=[F]:Wr.push(F)):(W.next=L.next,L.next=W),F.interleaved=W):(L=F.pending,L===null?W.next=W:(W.next=L.next,L.next=W),F.pending=W)}function fp(L,F,W){if(W&4194240){var $=F.lanes;$&=L.pendingLanes,W|=$,F.lanes=W,bl(L,W)}}var zl={readContext:$i,useCallback:pe,useContext:pe,useEffect:pe,useImperativeHandle:pe,useInsertionEffect:pe,useLayoutEffect:pe,useMemo:pe,useReducer:pe,useRef:pe,useState:pe,useDebugValue:pe,useDeferredValue:pe,useTransition:pe,useMutableSource:pe,useSyncExternalStore:pe,useId:pe,unstable_isNewReconciler:!1},Fh={readContext:$i,useCallback:function(L,F){return _e().memoizedState=[L,F===void 0?null:F],L},useContext:$i,useEffect:Ul,useImperativeHandle:function(L,F,W){return W=W!=null?W.concat([L]):null,xo(4194308,4,Rh.bind(null,F,L),W)},useLayoutEffect:function(L,F){return xo(4194308,4,L,F)},useInsertionEffect:function(L,F){return xo(4,2,L,F)},useMemo:function(L,F){var W=_e();return F=F===void 0?null:F,L=L(),W.memoizedState=[L,F],L},useReducer:function(L,F,W){var $=_e();return F=W!==void 0?W(F):F,$.memoizedState=$.baseState=F,L={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:L,lastRenderedState:F},$.queue=L,L=L.dispatch=_n.bind(null,It,L),[$.memoizedState,L]},useRef:function(L){var F=_e();return L={current:L},F.memoizedState=L},useState:go,useDebugValue:Lh,useDeferredValue:function(L){var F=go(L),W=F[0],$=F[1];return Ul(function(){var it=Ut.transition;Ut.transition={};try{$(L)}finally{Ut.transition=it}},[L]),W},useTransition:function(){var L=go(!1),F=L[0];return L=Fg.bind(null,L[1]),_e().memoizedState=L,[F,L]},useMutableSource:function(){},useSyncExternalStore:function(L,F,W){var $=It,it=_e();if(_i){if(W===void 0)throw Error(s(407));W=W()}else{if(W=F(),Wn===null)throw Error(s(349));Wt&30||Cn($,F,W)}it.memoizedState=W;var lt={value:W,getSnapshot:F};return it.queue=lt,Ul(bn.bind(null,$,lt,L),[L]),$.flags|=2048,yo(9,mo.bind(null,$,lt,W,F),void 0,null),W},useId:function(){var L=_e(),F=Wn.identifierPrefix;if(_i){var W=es,$=Es;W=($&~(1<<32-Jn($)-1)).toString(32)+W,F=":"+F+"R"+W,W=ue++,0zh&&(F.flags|=128,$=!0,Mr(it,!1),F.lanes=4194304)}else{if(!$)if(L=St(lt),L!==null){if(F.flags|=128,$=!0,L=L.updateQueue,L!==null&&(F.updateQueue=L,F.flags|=4),Mr(it,!0),it.tail===null&&it.tailMode==="hidden"&&!lt.alternate&&!_i)return ni(F),null}else 2*nn()-it.renderingStartTime>zh&&W!==1073741824&&(F.flags|=128,$=!0,Mr(it,!1),F.lanes=4194304);it.isBackwards?(lt.sibling=F.child,F.child=lt):(L=it.last,L!==null?L.sibling=lt:F.child=lt,it.last=lt)}return it.tail!==null?(F=it.tail,it.rendering=F,it.tail=F.sibling,it.renderingStartTime=nn(),F.sibling=null,L=ct.current,Se(ct,$?L&1|2:L&1),F):(ni(F),null);case 22:case 23:return Rc(),$=F.memoizedState!==null,L!==null&&L.memoizedState!==null!==$&&(F.flags|=8192),$&&F.mode&1?os&1073741824&&(ni(F),ot&&F.subtreeFlags&6&&(F.flags|=8192)):ni(F),null;case 24:return null;case 25:return null}throw Error(s(156,F.tag))}var Og=y.ReactCurrentOwner,rs=!1;function Ln(L,F,W,$){F.child=L===null?Ah(F,null,W,$):Gr(F,L.child,W,$)}function mp(L,F,W,$,it){W=W.render;var lt=F.ref;return Xs(F,it),$=me(L,F,W,$,lt,it),W=be(),L!==null&&!rs?(F.updateQueue=L.updateQueue,F.flags&=-2053,L.lanes&=~it,qn(L,F,it)):(_i&&W&&Bl(F),F.flags|=1,Ln(L,F,$,it),F.child)}function gp(L,F,W,$,it){if(L===null){var lt=W.type;return typeof lt=="function"&&!Ic(lt)&<.defaultProps===void 0&&W.compare===null&&W.defaultProps===void 0?(F.tag=15,F.type=lt,yp(L,F,lt,$,it)):(L=ef(W.type,null,$,F,F.mode,it),L.ref=F.ref,L.return=F,F.child=L)}if(lt=L.child,!(L.lanes&it)){var wt=lt.memoizedProps;if(W=W.compare,W=W!==null?W:gn,W(wt,$)&&L.ref===F.ref)return qn(L,F,it)}return F.flags|=1,L=Ka(lt,$),L.ref=F.ref,L.return=F,F.child=L}function yp(L,F,W,$,it){if(L!==null&&gn(L.memoizedProps,$)&&L.ref===F.ref)if(rs=!1,(L.lanes&it)!==0)L.flags&131072&&(rs=!0);else return F.lanes=L.lanes,qn(L,F,it);return ks(L,F,W,$,it)}function xp(L,F,W){var $=F.pendingProps,it=$.children,lt=L!==null?L.memoizedState:null;if($.mode==="hidden")if(!(F.mode&1))F.memoizedState={baseLanes:0,cachePool:null},Se(Yl,os),os|=W;else if(W&1073741824)F.memoizedState={baseLanes:0,cachePool:null},$=lt!==null?lt.baseLanes:W,Se(Yl,os),os|=$;else return L=lt!==null?lt.baseLanes|W:W,F.lanes=F.childLanes=1073741824,F.memoizedState={baseLanes:L,cachePool:null},F.updateQueue=null,Se(Yl,os),os|=L,null;else lt!==null?($=lt.baseLanes|W,F.memoizedState=null):$=W,Se(Yl,os),os|=$;return Ln(L,F,it,W),F.child}function Sp(L,F){var W=F.ref;(L===null&&W!==null||L!==null&&L.ref!==W)&&(F.flags|=512,F.flags|=2097152)}function ks(L,F,W,$,it){var lt=pn(W)?Ii:mi.current;return lt=Gn(F,lt),Xs(F,it),W=me(L,F,W,$,lt,it),$=be(),L!==null&&!rs?(F.updateQueue=L.updateQueue,F.flags&=-2053,L.lanes&=~it,qn(L,F,it)):(_i&&$&&Bl(F),F.flags|=1,Ln(L,F,W,it),F.child)}function Tp(L,F,W,$,it){if(pn(W)){var lt=!0;Tn(F)}else lt=!1;if(Xs(F,it),F.stateNode===null)L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),Ko(F,W,$),za(F,W,$,it),$=!0;else if(L===null){var wt=F.stateNode,Xt=F.memoizedProps;wt.props=Xt;var ae=wt.context,Ee=W.contextType;typeof Ee=="object"&&Ee!==null?Ee=$i(Ee):(Ee=pn(W)?Ii:mi.current,Ee=Gn(F,Ee));var He=W.getDerivedStateFromProps,vi=typeof He=="function"||typeof wt.getSnapshotBeforeUpdate=="function";vi||typeof wt.UNSAFE_componentWillReceiveProps!="function"&&typeof wt.componentWillReceiveProps!="function"||(Xt!==$||ae!==Ee)&&jo(F,wt,$,Ee),yn=!1;var Qe=F.memoizedState;wt.state=Qe,Xr(F,$,wt,it),ae=F.memoizedState,Xt!==$||Qe!==ae||un.current||yn?(typeof He=="function"&&(qr(F,W,He,$),ae=F.memoizedState),(Xt=yn||Nl(F,W,Xt,$,Qe,ae,Ee))?(vi||typeof wt.UNSAFE_componentWillMount!="function"&&typeof wt.componentWillMount!="function"||(typeof wt.componentWillMount=="function"&&wt.componentWillMount(),typeof wt.UNSAFE_componentWillMount=="function"&&wt.UNSAFE_componentWillMount()),typeof wt.componentDidMount=="function"&&(F.flags|=4194308)):(typeof wt.componentDidMount=="function"&&(F.flags|=4194308),F.memoizedProps=$,F.memoizedState=ae),wt.props=$,wt.state=ae,wt.context=Ee,$=Xt):(typeof wt.componentDidMount=="function"&&(F.flags|=4194308),$=!1)}else{wt=F.stateNode,Ba(L,F),Xt=F.memoizedProps,Ee=F.type===F.elementType?Xt:Rn(F.type,Xt),wt.props=Ee,vi=F.pendingProps,Qe=wt.context,ae=W.contextType,typeof ae=="object"&&ae!==null?ae=$i(ae):(ae=pn(W)?Ii:mi.current,ae=Gn(F,ae));var qi=W.getDerivedStateFromProps;(He=typeof qi=="function"||typeof wt.getSnapshotBeforeUpdate=="function")||typeof wt.UNSAFE_componentWillReceiveProps!="function"&&typeof wt.componentWillReceiveProps!="function"||(Xt!==vi||Qe!==ae)&&jo(F,wt,$,ae),yn=!1,Qe=F.memoizedState,wt.state=Qe,Xr(F,$,wt,it);var Xe=F.memoizedState;Xt!==vi||Qe!==Xe||un.current||yn?(typeof qi=="function"&&(qr(F,W,qi,$),Xe=F.memoizedState),(Ee=yn||Nl(F,W,Ee,$,Qe,Xe,ae)||!1)?(He||typeof wt.UNSAFE_componentWillUpdate!="function"&&typeof wt.componentWillUpdate!="function"||(typeof wt.componentWillUpdate=="function"&&wt.componentWillUpdate($,Xe,ae),typeof wt.UNSAFE_componentWillUpdate=="function"&&wt.UNSAFE_componentWillUpdate($,Xe,ae)),typeof wt.componentDidUpdate=="function"&&(F.flags|=4),typeof wt.getSnapshotBeforeUpdate=="function"&&(F.flags|=1024)):(typeof wt.componentDidUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=4),typeof wt.getSnapshotBeforeUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=1024),F.memoizedProps=$,F.memoizedState=Xe),wt.props=$,wt.state=Xe,wt.context=ae,$=Ee):(typeof wt.componentDidUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=4),typeof wt.getSnapshotBeforeUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=1024),$=!1)}return dc(L,F,W,$,lt,it)}function dc(L,F,W,$,it,lt){Sp(L,F);var wt=(F.flags&128)!==0;if(!$&&!wt)return it&&oa(F,W,!1),qn(L,F,lt);$=F.stateNode,Og.current=F;var Xt=wt&&typeof W.getDerivedStateFromError!="function"?null:$.render();return F.flags|=1,L!==null&&wt?(F.child=Gr(F,L.child,null,lt),F.child=Gr(F,null,Xt,lt)):Ln(L,F,Xt,lt),F.memoizedState=$.state,it&&oa(F,W,!0),F.child}function Ep(L){var F=L.stateNode;F.pendingContext?dr(L,F.pendingContext,F.pendingContext!==F.context):F.context&&dr(L,F.context,!1),pt(L,F.containerInfo)}function Mp(L,F,W,$,it){return vo(),Ga(it),F.flags|=256,Ln(L,F,W,$),F.child}var Vu={dehydrated:null,treeContext:null,retryLane:0};function ws(L){return{baseLanes:L,cachePool:null}}function Cp(L,F,W){var $=F.pendingProps,it=ct.current,lt=!1,wt=(F.flags&128)!==0,Xt;if((Xt=wt)||(Xt=L!==null&&L.memoizedState===null?!1:(it&2)!==0),Xt?(lt=!0,F.flags&=-129):(L===null||L.memoizedState!==null)&&(it|=1),Se(ct,it&1),L===null)return cn(F),L=F.memoizedState,L!==null&&(L=L.dehydrated,L!==null)?(F.mode&1?aa(L)?F.lanes=8:F.lanes=1073741824:F.lanes=1,null):(it=$.children,L=$.fallback,lt?($=F.mode,lt=F.child,it={mode:"hidden",children:it},!($&1)&<!==null?(lt.childLanes=0,lt.pendingProps=it):lt=Xh(it,$,0,null),L=bo(L,$,W,null),lt.return=F,L.return=F,lt.sibling=L,F.child=lt,F.child.memoizedState=ws(W),F.memoizedState=Vu,L):pc(F,it));if(it=L.memoizedState,it!==null){if(Xt=it.dehydrated,Xt!==null){if(wt)return F.flags&256?(F.flags&=-257,Hu(L,F,W,Error(s(422)))):F.memoizedState!==null?(F.child=L.child,F.flags|=128,null):(lt=$.fallback,it=F.mode,$=Xh({mode:"visible",children:$.children},it,0,null),lt=bo(lt,it,W,null),lt.flags|=2,$.return=F,lt.return=F,$.sibling=lt,F.child=$,F.mode&1&&Gr(F,L.child,null,W),F.child.memoizedState=ws(W),F.memoizedState=Vu,lt);if(!(F.mode&1))F=Hu(L,F,W,null);else if(aa(Xt))F=Hu(L,F,W,Error(s(419)));else if($=(W&L.childLanes)!==0,rs||$){if($=Wn,$!==null){switch(W&-W){case 4:lt=2;break;case 16:lt=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:lt=32;break;case 536870912:lt=268435456;break;default:lt=0}$=lt&($.suspendedLanes|W)?0:lt,$!==0&&$!==it.retryLane&&(it.retryLane=$,As(L,$,-1))}_u(),F=Hu(L,F,W,Error(s(421)))}else Pa(Xt)?(F.flags|=128,F.child=L.child,F=Ro.bind(null,L),Bs(Xt,F),F=null):(W=it.treeContext,gt&&(Hn=Us(Xt),$n=F,_i=!0,is=null,po=!1,W!==null&&(sr[ar++]=Es,sr[ar++]=es,sr[ar++]=fa,Es=W.id,es=W.overflow,fa=F)),F=pc(F,F.pendingProps.children),F.flags|=4096);return F}return lt?($=Ap(L,F,$.children,$.fallback,W),lt=F.child,it=L.child.memoizedState,lt.memoizedState=it===null?ws(W):{baseLanes:it.baseLanes|W,cachePool:null},lt.childLanes=L.childLanes&~W,F.memoizedState=Vu,$):(W=wp(L,F,$.children,W),F.memoizedState=null,W)}return lt?($=Ap(L,F,$.children,$.fallback,W),lt=F.child,it=L.child.memoizedState,lt.memoizedState=it===null?ws(W):{baseLanes:it.baseLanes|W,cachePool:null},lt.childLanes=L.childLanes&~W,F.memoizedState=Vu,$):(W=wp(L,F,$.children,W),F.memoizedState=null,W)}function pc(L,F){return F=Xh({mode:"visible",children:F},L.mode,0,null),F.return=L,L.child=F}function wp(L,F,W,$){var it=L.child;return L=it.sibling,W=Ka(it,{mode:"visible",children:W}),!(F.mode&1)&&(W.lanes=$),W.return=F,W.sibling=null,L!==null&&($=F.deletions,$===null?(F.deletions=[L],F.flags|=16):$.push(L)),F.child=W}function Ap(L,F,W,$,it){var lt=F.mode;L=L.child;var wt=L.sibling,Xt={mode:"hidden",children:W};return!(lt&1)&&F.child!==L?(W=F.child,W.childLanes=0,W.pendingProps=Xt,F.deletions=null):(W=Ka(L,Xt),W.subtreeFlags=L.subtreeFlags&14680064),wt!==null?$=Ka(wt,$):($=bo($,lt,it,null),$.flags|=2),$.return=F,W.return=F,W.sibling=$,F.child=W,$}function Hu(L,F,W,$){return $!==null&&Ga($),Gr(F,L.child,null,W),L=pc(F,F.pendingProps.children),L.flags|=2,F.memoizedState=null,L}function So(L,F,W){L.lanes|=F;var $=L.alternate;$!==null&&($.lanes|=F),Na(L.return,F,W)}function vc(L,F,W,$,it){var lt=L.memoizedState;lt===null?L.memoizedState={isBackwards:F,rendering:null,renderingStartTime:0,last:$,tail:W,tailMode:it}:(lt.isBackwards=F,lt.rendering=null,lt.renderingStartTime=0,lt.last=$,lt.tail=W,lt.tailMode=it)}function Pp(L,F,W){var $=F.pendingProps,it=$.revealOrder,lt=$.tail;if(Ln(L,F,$.children,W),$=ct.current,$&2)$=$&1|2,F.flags|=128;else{if(L!==null&&L.flags&128)t:for(L=F.child;L!==null;){if(L.tag===13)L.memoizedState!==null&&So(L,W,F);else if(L.tag===19)So(L,W,F);else if(L.child!==null){L.child.return=L,L=L.child;continue}if(L===F)break t;for(;L.sibling===null;){if(L.return===null||L.return===F)break t;L=L.return}L.sibling.return=L.return,L=L.sibling}$&=1}if(Se(ct,$),!(F.mode&1))F.memoizedState=null;else switch(it){case"forwards":for(W=F.child,it=null;W!==null;)L=W.alternate,L!==null&&St(L)===null&&(it=W),W=W.sibling;W=it,W===null?(it=F.child,F.child=null):(it=W.sibling,W.sibling=null),vc(F,!1,it,W,lt);break;case"backwards":for(W=null,it=F.child,F.child=null;it!==null;){if(L=it.alternate,L!==null&&St(L)===null){F.child=it;break}L=it.sibling,it.sibling=W,W=it,it=L}vc(F,!0,W,null,lt);break;case"together":vc(F,!1,null,null,void 0);break;default:F.memoizedState=null}return F.child}function qn(L,F,W){if(L!==null&&(F.dependencies=L.dependencies),Kl|=F.lanes,!(W&F.childLanes))return null;if(L!==null&&F.child!==L.child)throw Error(s(153));if(F.child!==null){for(L=F.child,W=Ka(L,L.pendingProps),F.child=W,W.return=F;L.sibling!==null;)L=L.sibling,W=W.sibling=Ka(L,L.pendingProps),W.return=F;W.sibling=null}return F.child}function Dg(L,F,W){switch(F.tag){case 3:Ep(F),vo();break;case 5:Nt(F);break;case 1:pn(F.type)&&Tn(F);break;case 4:pt(F,F.stateNode.containerInfo);break;case 10:Ol(F,F.type._context,F.memoizedProps.value);break;case 13:var $=F.memoizedState;if($!==null)return $.dehydrated!==null?(Se(ct,ct.current&1),F.flags|=128,null):W&F.child.childLanes?Cp(L,F,W):(Se(ct,ct.current&1),L=qn(L,F,W),L!==null?L.sibling:null);Se(ct,ct.current&1);break;case 19:if($=(W&F.childLanes)!==0,L.flags&128){if($)return Pp(L,F,W);F.flags|=128}var it=F.memoizedState;if(it!==null&&(it.rendering=null,it.tail=null,it.lastEffect=null),Se(ct,ct.current),$)break;return null;case 22:case 23:return F.lanes=0,xp(L,F,W)}return qn(L,F,W)}function Ig(L,F){switch(or(F),F.tag){case 1:return pn(F.type)&&Ki(),L=F.flags,L&65536?(F.flags=L&-65537|128,F):null;case 3:return Mt(),ti(un),ti(mi),Ft(),L=F.flags,L&65536&&!(L&128)?(F.flags=L&-65537|128,F):null;case 5:return zt(F),null;case 13:if(ti(ct),L=F.memoizedState,L!==null&&L.dehydrated!==null){if(F.alternate===null)throw Error(s(340));vo()}return L=F.flags,L&65536?(F.flags=L&-65537|128,F):null;case 19:return ti(ct),null;case 4:return Mt(),null;case 10:return Dl(F.type._context),null;case 22:case 23:return Rc(),null;case 24:return null;default:return null}}var Wu=!1,qo=!1,Ng=typeof WeakSet=="function"?WeakSet:Set,De=null;function Ih(L,F){var W=L.ref;if(W!==null)if(typeof W=="function")try{W(null)}catch($){Pr(L,F,$)}else W.current=null}function mc(L,F,W){try{W()}catch($){Pr(L,F,$)}}var Rp=!1;function gc(L,F){for(X(L.containerInfo),De=F;De!==null;)if(L=De,F=L.child,(L.subtreeFlags&1028)!==0&&F!==null)F.return=L,De=F;else for(;De!==null;){L=De;try{var W=L.alternate;if(L.flags&1024)switch(L.tag){case 0:case 11:case 15:break;case 1:if(W!==null){var $=W.memoizedProps,it=W.memoizedState,lt=L.stateNode,wt=lt.getSnapshotBeforeUpdate(L.elementType===L.type?$:Rn(L.type,$),it);lt.__reactInternalSnapshotBeforeUpdate=wt}break;case 3:ot&&Me(L.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Xt){Pr(L,L.return,Xt)}if(F=L.sibling,F!==null){F.return=L.return,De=F;break}De=L.return}return W=Rp,Rp=!1,W}function Ks(L,F,W){var $=F.updateQueue;if($=$!==null?$.lastEffect:null,$!==null){var it=$=$.next;do{if((it.tag&L)===L){var lt=it.destroy;it.destroy=void 0,lt!==void 0&&mc(F,W,lt)}it=it.next}while(it!==$)}}function To(L,F){if(F=F.updateQueue,F=F!==null?F.lastEffect:null,F!==null){var W=F=F.next;do{if((W.tag&L)===L){var $=W.create;W.destroy=$()}W=W.next}while(W!==F)}}function yc(L){var F=L.ref;if(F!==null){var W=L.stateNode;switch(L.tag){case 5:L=B(W);break;default:L=W}typeof F=="function"?F(L):F.current=L}}function xc(L,F,W){if(xr&&typeof xr.onCommitFiberUnmount=="function")try{xr.onCommitFiberUnmount(fo,F)}catch{}switch(F.tag){case 0:case 11:case 14:case 15:if(L=F.updateQueue,L!==null&&(L=L.lastEffect,L!==null)){var $=L=L.next;do{var it=$,lt=it.destroy;it=it.tag,lt!==void 0&&(it&2||it&4)&&mc(F,W,lt),$=$.next}while($!==L)}break;case 1:if(Ih(F,W),L=F.stateNode,typeof L.componentWillUnmount=="function")try{L.props=F.memoizedProps,L.state=F.memoizedState,L.componentWillUnmount()}catch(wt){Pr(F,W,wt)}break;case 5:Ih(F,W);break;case 4:ot?Tc(L,F,W):rt&&rt&&(F=F.stateNode.containerInfo,W=Ve(F),Di(F,W))}}function bp(L,F,W){for(var $=F;;)if(xc(L,$,W),$.child===null||ot&&$.tag===4){if($===F)break;for(;$.sibling===null;){if($.return===null||$.return===F)return;$=$.return}$.sibling.return=$.return,$=$.sibling}else $.child.return=$,$=$.child}function pa(L){var F=L.alternate;F!==null&&(L.alternate=null,pa(F)),L.child=null,L.deletions=null,L.sibling=null,L.tag===5&&(F=L.stateNode,F!==null&&Pt(F)),L.stateNode=null,L.return=null,L.dependencies=null,L.memoizedProps=null,L.memoizedState=null,L.pendingProps=null,L.stateNode=null,L.updateQueue=null}function Xu(L){return L.tag===5||L.tag===3||L.tag===4}function Eo(L){t:for(;;){for(;L.sibling===null;){if(L.return===null||Xu(L.return))return null;L=L.return}for(L.sibling.return=L.return,L=L.sibling;L.tag!==5&&L.tag!==6&&L.tag!==18;){if(L.flags&2||L.child===null||L.tag===4)continue t;L.child.return=L,L=L.child}if(!(L.flags&2))return L.stateNode}}function ss(L){if(ot){t:{for(var F=L.return;F!==null;){if(Xu(F))break t;F=F.return}throw Error(s(160))}var W=F;switch(W.tag){case 5:F=W.stateNode,W.flags&32&&(ri(F),W.flags&=-33),W=Eo(L),Yu(L,W,F);break;case 3:case 4:F=W.stateNode.containerInfo,W=Eo(L),Sc(L,W,F);break;default:throw Error(s(161))}}}function Sc(L,F,W){var $=L.tag;if($===5||$===6)L=L.stateNode,F?Le(W,L,F):Ae(W,L);else if($!==4&&(L=L.child,L!==null))for(Sc(L,F,W),L=L.sibling;L!==null;)Sc(L,F,W),L=L.sibling}function Yu(L,F,W){var $=L.tag;if($===5||$===6)L=L.stateNode,F?Be(W,L,F):xe(W,L);else if($!==4&&(L=L.child,L!==null))for(Yu(L,F,W),L=L.sibling;L!==null;)Yu(L,F,W),L=L.sibling}function Tc(L,F,W){for(var $=F,it=!1,lt,wt;;){if(!it){it=$.return;t:for(;;){if(it===null)throw Error(s(160));switch(lt=it.stateNode,it.tag){case 5:wt=!1;break t;case 3:lt=lt.containerInfo,wt=!0;break t;case 4:lt=lt.containerInfo,wt=!0;break t}it=it.return}it=!0}if($.tag===5||$.tag===6)bp(L,$,W),wt?Ke(lt,$.stateNode):ie(lt,$.stateNode);else if($.tag===18)wt?te(lt,$.stateNode):ee(lt,$.stateNode);else if($.tag===4){if($.child!==null){lt=$.stateNode.containerInfo,wt=!0,$.child.return=$,$=$.child;continue}}else if(xc(L,$,W),$.child!==null){$.child.return=$,$=$.child;continue}if($===F)break;for(;$.sibling===null;){if($.return===null||$.return===F)return;$=$.return,$.tag===4&&(it=!1)}$.sibling.return=$.return,$=$.sibling}}function tl(L,F){if(ot){switch(F.tag){case 0:case 11:case 14:case 15:Ks(3,F,F.return),To(3,F),Ks(5,F,F.return);return;case 1:return;case 5:var W=F.stateNode;if(W!=null){var $=F.memoizedProps;L=L!==null?L.memoizedProps:$;var it=F.type,lt=F.updateQueue;F.updateQueue=null,lt!==null&&Oe(W,lt,it,L,$,F)}return;case 6:if(F.stateNode===null)throw Error(s(162));W=F.memoizedProps,qt(F.stateNode,L!==null?L.memoizedProps:W,W);return;case 3:gt&&L!==null&&L.memoizedState.isDehydrated&&jt(F.stateNode.containerInfo);return;case 12:return;case 13:js(F);return;case 19:js(F);return;case 17:return}throw Error(s(163))}switch(F.tag){case 0:case 11:case 14:case 15:Ks(3,F,F.return),To(3,F),Ks(5,F,F.return);return;case 12:return;case 13:js(F);return;case 19:js(F);return;case 3:gt&&L!==null&&L.memoizedState.isDehydrated&&jt(F.stateNode.containerInfo);break;case 22:case 23:return}t:if(rt){switch(F.tag){case 1:case 5:case 6:break t;case 3:case 4:F=F.stateNode,Di(F.containerInfo,F.pendingChildren);break t}throw Error(s(163))}}function js(L){var F=L.updateQueue;if(F!==null){L.updateQueue=null;var W=L.stateNode;W===null&&(W=L.stateNode=new Ng),F.forEach(function($){var it=Up.bind(null,L,$);W.has($)||(W.add($),$.then(it,it))})}}function Lp(L,F){for(De=F;De!==null;){F=De;var W=F.deletions;if(W!==null)for(var $=0;$";case Bh:return":has("+(Uh(L)||"")+")";case as:return'[role="'+L.value+'"]';case el:return'"'+L.value+'"';case Wl:return'[data-testname="'+L.value+'"]';default:throw Error(s(365))}}function Op(L,F){var W=[];L=[L,0];for(var $=0;$it&&(it=wt),$&=~lt}if($=it,$=nn()-$,$=(120>$?120:480>$?480:1080>$?1080:1920>$?1920:3e3>$?3e3:4320>$?4320:1960*Ug($/1960))-$,10<$){L.timeoutHandle=J(wo.bind(null,L,Cr),$);break}wo(L,Cr);break;case 5:wo(L,Cr);break;default:throw Error(s(329))}}}return ei(L,nn()),L.callbackNode===W?Dp.bind(null,L):null}function Pc(L,F){var W=jl;return L.current.memoizedState.isDehydrated&&(ma(L,F).flags|=256),L=Ar(L,F),L!==2&&(F=Cr,Cr=W,F!==null&&nl(F)),L}function nl(L){Cr===null?Cr=L:Cr.push.apply(Cr,L)}function Ip(L){for(var F=L;;){if(F.flags&16384){var W=F.updateQueue;if(W!==null&&(W=W.stores,W!==null))for(var $=0;$L?16:L,ka===null)var $=!1;else{if(L=ka,ka=null,Vh=0,Ei&6)throw Error(s(331));var it=Ei;for(Ei|=4,De=L.current;De!==null;){var lt=De,wt=lt.child;if(De.flags&16){var Xt=lt.deletions;if(Xt!==null){for(var ae=0;aenn()-Ac?ma(L,0):wc|=W),ei(L,F)}function Bp(L,F){F===0&&(L.mode&1?(F=ho,ho<<=1,!(ho&130023424)&&(ho=4194304)):F=1);var W=wr();L=Jl(L,F),L!==null&&(Hs(L,F,W),ei(L,W))}function Ro(L){var F=L.memoizedState,W=0;F!==null&&(W=F.retryLane),Bp(L,W)}function Up(L,F){var W=0;switch(L.tag){case 13:var $=L.stateNode,it=L.memoizedState;it!==null&&(W=it.retryLane);break;case 19:$=L.stateNode;break;default:throw Error(s(314))}$!==null&&$.delete(F),Bp(L,W)}var Dc;Dc=function(L,F,W){if(L!==null)if(L.memoizedProps!==F.pendingProps||un.current)rs=!0;else{if(!(L.lanes&W)&&!(F.flags&128))return rs=!1,Dg(L,F,W);rs=!!(L.flags&131072)}else rs=!1,_i&&F.flags&1048576&&wh(F,Zo,F.index);switch(F.lanes=0,F.tag){case 2:var $=F.type;L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),L=F.pendingProps;var it=Gn(F,mi.current);Xs(F,W),it=me(null,F,$,L,it,W);var lt=be();return F.flags|=1,typeof it=="object"&&it!==null&&typeof it.render=="function"&&it.$$typeof===void 0?(F.tag=1,F.memoizedState=null,F.updateQueue=null,pn($)?(lt=!0,Tn(F)):lt=!1,F.memoizedState=it.state!==null&&it.state!==void 0?it.state:null,Vn(F),it.updater=co,F.stateNode=it,it._reactInternals=F,za(F,$,L,W),F=dc(null,F,$,!0,lt,W)):(F.tag=0,_i&<&&Bl(F),Ln(null,F,it,W),F=F.child),F;case 16:$=F.elementType;t:{switch(L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),L=F.pendingProps,it=$._init,$=it($._payload),F.type=$,it=F.tag=zp($),L=Rn($,L),it){case 0:F=ks(null,F,$,L,W);break t;case 1:F=Tp(null,F,$,L,W);break t;case 11:F=mp(null,F,$,L,W);break t;case 14:F=gp(null,F,$,Rn($.type,L),W);break t}throw Error(s(306,$,""))}return F;case 0:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),ks(L,F,$,it,W);case 1:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),Tp(L,F,$,it,W);case 3:t:{if(Ep(F),L===null)throw Error(s(387));$=F.pendingProps,lt=F.memoizedState,it=lt.element,Ba(L,F),Xr(F,$,null,W);var wt=F.memoizedState;if($=wt.element,gt&<.isDehydrated)if(lt={element:$,isDehydrated:!1,cache:wt.cache,transitions:wt.transitions},F.updateQueue.baseState=lt,F.memoizedState=lt,F.flags&256){it=Error(s(423)),F=Mp(L,F,$,W,it);break t}else if($!==it){it=Error(s(424)),F=Mp(L,F,$,W,it);break t}else for(gt&&(Hn=_r(F.stateNode.containerInfo),$n=F,_i=!0,is=null,po=!1),W=Ah(F,null,$,W),F.child=W;W;)W.flags=W.flags&-3|4096,W=W.sibling;else{if(vo(),$===it){F=qn(L,F,W);break t}Ln(L,F,$,W)}F=F.child}return F;case 5:return Nt(F),L===null&&cn(F),$=F.type,it=F.pendingProps,lt=L!==null?L.memoizedProps:null,wt=it.children,U($,it)?wt=null:lt!==null&&U($,lt)&&(F.flags|=32),Sp(L,F),Ln(L,F,wt,W),F.child;case 6:return L===null&&cn(F),null;case 13:return Cp(L,F,W);case 4:return pt(F,F.stateNode.containerInfo),$=F.pendingProps,L===null?F.child=Gr(F,null,$,W):Ln(L,F,$,W),F.child;case 11:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),mp(L,F,$,it,W);case 7:return Ln(L,F,F.pendingProps,W),F.child;case 8:return Ln(L,F,F.pendingProps.children,W),F.child;case 12:return Ln(L,F,F.pendingProps.children,W),F.child;case 10:t:{if($=F.type._context,it=F.pendingProps,lt=F.memoizedProps,wt=it.value,Ol(F,$,wt),lt!==null)if(Ts(lt.value,wt)){if(lt.children===it.children&&!un.current){F=qn(L,F,W);break t}}else for(lt=F.child,lt!==null&&(lt.return=F);lt!==null;){var Xt=lt.dependencies;if(Xt!==null){wt=lt.child;for(var ae=Xt.firstContext;ae!==null;){if(ae.context===$){if(lt.tag===1){ae=Mn(-1,W&-W),ae.tag=2;var Ee=lt.updateQueue;if(Ee!==null){Ee=Ee.shared;var He=Ee.pending;He===null?ae.next=ae:(ae.next=He.next,He.next=ae),Ee.pending=ae}}lt.lanes|=W,ae=lt.alternate,ae!==null&&(ae.lanes|=W),Na(lt.return,W,F),Xt.lanes|=W;break}ae=ae.next}}else if(lt.tag===10)wt=lt.type===F.type?null:lt.child;else if(lt.tag===18){if(wt=lt.return,wt===null)throw Error(s(341));wt.lanes|=W,Xt=wt.alternate,Xt!==null&&(Xt.lanes|=W),Na(wt,W,F),wt=lt.sibling}else wt=lt.child;if(wt!==null)wt.return=lt;else for(wt=lt;wt!==null;){if(wt===F){wt=null;break}if(lt=wt.sibling,lt!==null){lt.return=wt.return,wt=lt;break}wt=wt.return}lt=wt}Ln(L,F,it.children,W),F=F.child}return F;case 9:return it=F.type,$=F.pendingProps.children,Xs(F,W),it=$i(it),$=$(it),F.flags|=1,Ln(L,F,$,W),F.child;case 14:return $=F.type,it=Rn($,F.pendingProps),it=Rn($.type,it),gp(L,F,$,it,W);case 15:return yp(L,F,F.type,F.pendingProps,W);case 17:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),F.tag=1,pn($)?(L=!0,Tn(F)):L=!1,Xs(F,W),Ko(F,$,it),za(F,$,it,W),dc(null,F,$,!0,L,W);case 19:return Pp(L,F,W);case 22:return xp(L,F,W)}throw Error(s(156,F.tag))};function tf(L,F){return Br(L,F)}function zg(L,F,W,$){this.tag=L,this.key=W,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=$,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ps(L,F,W,$){return new zg(L,F,W,$)}function Ic(L){return L=L.prototype,!(!L||!L.isReactComponent)}function zp(L){if(typeof L=="function")return Ic(L)?1:0;if(L!=null){if(L=L.$$typeof,L===u)return 11;if(L===c)return 14}return 2}function Ka(L,F){var W=L.alternate;return W===null?(W=Ps(L.tag,F,L.key,L.mode),W.elementType=L.elementType,W.type=L.type,W.stateNode=L.stateNode,W.alternate=L,L.alternate=W):(W.pendingProps=F,W.type=L.type,W.flags=0,W.subtreeFlags=0,W.deletions=null),W.flags=L.flags&14680064,W.childLanes=L.childLanes,W.lanes=L.lanes,W.child=L.child,W.memoizedProps=L.memoizedProps,W.memoizedState=L.memoizedState,W.updateQueue=L.updateQueue,F=L.dependencies,W.dependencies=F===null?null:{lanes:F.lanes,firstContext:F.firstContext},W.sibling=L.sibling,W.index=L.index,W.ref=L.ref,W}function ef(L,F,W,$,it,lt){var wt=2;if($=L,typeof L=="function")Ic(L)&&(wt=1);else if(typeof L=="string")wt=5;else t:switch(L){case p:return bo(W.children,it,lt,F);case h:wt=8,it|=8;break;case a:return L=Ps(12,W,F,it|2),L.elementType=a,L.lanes=lt,L;case f:return L=Ps(13,W,F,it),L.elementType=f,L.lanes=lt,L;case o:return L=Ps(19,W,F,it),L.elementType=o,L.lanes=lt,L;case v:return Xh(W,it,lt,F);default:if(typeof L=="object"&&L!==null)switch(L.$$typeof){case l:wt=10;break t;case n:wt=9;break t;case u:wt=11;break t;case c:wt=14;break t;case d:wt=16,$=null;break t}throw Error(s(130,L==null?L:typeof L,""))}return F=Ps(wt,W,F,it),F.elementType=L,F.type=$,F.lanes=lt,F}function bo(L,F,W,$){return L=Ps(7,L,$,F),L.lanes=W,L}function Xh(L,F,W,$){return L=Ps(22,L,$,F),L.elementType=v,L.lanes=W,L.stateNode={},L}function Rr(L,F,W){return L=Ps(6,L,null,F),L.lanes=W,L}function Rs(L,F,W){return F=Ps(4,L.children!==null?L.children:[],L.key,F),F.lanes=W,F.stateNode={containerInfo:L.containerInfo,pendingChildren:null,implementation:L.implementation},F}function Gg(L,F,W,$,it){this.tag=F,this.containerInfo=L,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=q,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vs(0),this.expirationTimes=Vs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vs(0),this.identifierPrefix=$,this.onRecoverableError=it,gt&&(this.mutableSourceEagerHydrationData=null)}function Gp(L,F,W,$,it,lt,wt,Xt,ae){return L=new Gg(L,F,W,Xt,ae),F===1?(F=1,lt===!0&&(F|=8)):F=0,lt=Ps(3,null,null,F),L.current=lt,lt.stateNode=L,lt.memoizedState={element:$,isDehydrated:W,cache:null,transitions:null},Vn(lt),L}function Yh(L){if(!L)return Nr;L=L._reactInternals;t:{if(C(L)!==L||L.tag!==1)throw Error(s(170));var F=L;do{switch(F.tag){case 3:F=F.stateNode.context;break t;case 1:if(pn(F.type)){F=F.stateNode.__reactInternalMemoizedMergedChildContext;break t}}F=F.return}while(F!==null);throw Error(s(171))}if(L.tag===1){var W=L.type;if(pn(W))return zs(L,W,F)}return F}function rl(L){var F=L._reactInternals;if(F===void 0)throw typeof L.render=="function"?Error(s(188)):(L=Object.keys(L).join(","),Error(s(268,L)));return L=b(F),L===null?null:L.stateNode}function Nc(L,F){if(L=L.memoizedState,L!==null&&L.dehydrated!==null){var W=L.retryLane;L.retryLane=W!==0&&W=Ee&<>=vi&&it<=He&&wt<=Qe){L.splice(F,1);break}else if($!==Ee||W.width!==ae.width||Qewt){if(!(lt!==vi||W.height!==ae.height||He<$||Ee>it)){Ee>$&&(ae.width+=Ee-$,ae.x=$),Helt&&(ae.height+=vi-lt,ae.y=lt),QeW&&(W=wt)),wtzh&&(F.flags|=128,$=!0,Mr(it,!1),F.lanes=4194304)}else{if(!$)if(L=St(lt),L!==null){if(F.flags|=128,$=!0,L=L.updateQueue,L!==null&&(F.updateQueue=L,F.flags|=4),Mr(it,!0),it.tail===null&&it.tailMode==="hidden"&&!lt.alternate&&!_i)return ni(F),null}else 2*nn()-it.renderingStartTime>zh&&W!==1073741824&&(F.flags|=128,$=!0,Mr(it,!1),F.lanes=4194304);it.isBackwards?(lt.sibling=F.child,F.child=lt):(L=it.last,L!==null?L.sibling=lt:F.child=lt,it.last=lt)}return it.tail!==null?(F=it.tail,it.rendering=F,it.tail=F.sibling,it.renderingStartTime=nn(),F.sibling=null,L=ct.current,Se(ct,$?L&1|2:L&1),F):(ni(F),null);case 22:case 23:return Rc(),$=F.memoizedState!==null,L!==null&&L.memoizedState!==null!==$&&(F.flags|=8192),$&&F.mode&1?os&1073741824&&(ni(F),ot&&F.subtreeFlags&6&&(F.flags|=8192)):ni(F),null;case 24:return null;case 25:return null}throw Error(s(156,F.tag))}var Dg=y.ReactCurrentOwner,rs=!1;function Ln(L,F,W,$){F.child=L===null?Ah(F,null,W,$):Gr(F,L.child,W,$)}function mp(L,F,W,$,it){W=W.render;var lt=F.ref;return Xs(F,it),$=me(L,F,W,$,lt,it),W=be(),L!==null&&!rs?(F.updateQueue=L.updateQueue,F.flags&=-2053,L.lanes&=~it,qn(L,F,it)):(_i&&W&&Bl(F),F.flags|=1,Ln(L,F,$,it),F.child)}function gp(L,F,W,$,it){if(L===null){var lt=W.type;return typeof lt=="function"&&!Ic(lt)&<.defaultProps===void 0&&W.compare===null&&W.defaultProps===void 0?(F.tag=15,F.type=lt,yp(L,F,lt,$,it)):(L=ef(W.type,null,$,F,F.mode,it),L.ref=F.ref,L.return=F,F.child=L)}if(lt=L.child,!(L.lanes&it)){var wt=lt.memoizedProps;if(W=W.compare,W=W!==null?W:yn,W(wt,$)&&L.ref===F.ref)return qn(L,F,it)}return F.flags|=1,L=Ka(lt,$),L.ref=F.ref,L.return=F,F.child=L}function yp(L,F,W,$,it){if(L!==null&&yn(L.memoizedProps,$)&&L.ref===F.ref)if(rs=!1,(L.lanes&it)!==0)L.flags&131072&&(rs=!0);else return F.lanes=L.lanes,qn(L,F,it);return ks(L,F,W,$,it)}function xp(L,F,W){var $=F.pendingProps,it=$.children,lt=L!==null?L.memoizedState:null;if($.mode==="hidden")if(!(F.mode&1))F.memoizedState={baseLanes:0,cachePool:null},Se(Yl,os),os|=W;else if(W&1073741824)F.memoizedState={baseLanes:0,cachePool:null},$=lt!==null?lt.baseLanes:W,Se(Yl,os),os|=$;else return L=lt!==null?lt.baseLanes|W:W,F.lanes=F.childLanes=1073741824,F.memoizedState={baseLanes:L,cachePool:null},F.updateQueue=null,Se(Yl,os),os|=L,null;else lt!==null?($=lt.baseLanes|W,F.memoizedState=null):$=W,Se(Yl,os),os|=$;return Ln(L,F,it,W),F.child}function Sp(L,F){var W=F.ref;(L===null&&W!==null||L!==null&&L.ref!==W)&&(F.flags|=512,F.flags|=2097152)}function ks(L,F,W,$,it){var lt=pn(W)?Ii:mi.current;return lt=Gn(F,lt),Xs(F,it),W=me(L,F,W,$,lt,it),$=be(),L!==null&&!rs?(F.updateQueue=L.updateQueue,F.flags&=-2053,L.lanes&=~it,qn(L,F,it)):(_i&&$&&Bl(F),F.flags|=1,Ln(L,F,W,it),F.child)}function Tp(L,F,W,$,it){if(pn(W)){var lt=!0;Tn(F)}else lt=!1;if(Xs(F,it),F.stateNode===null)L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),Ko(F,W,$),za(F,W,$,it),$=!0;else if(L===null){var wt=F.stateNode,Xt=F.memoizedProps;wt.props=Xt;var ae=wt.context,Ee=W.contextType;typeof Ee=="object"&&Ee!==null?Ee=$i(Ee):(Ee=pn(W)?Ii:mi.current,Ee=Gn(F,Ee));var He=W.getDerivedStateFromProps,vi=typeof He=="function"||typeof wt.getSnapshotBeforeUpdate=="function";vi||typeof wt.UNSAFE_componentWillReceiveProps!="function"&&typeof wt.componentWillReceiveProps!="function"||(Xt!==$||ae!==Ee)&&jo(F,wt,$,Ee),xn=!1;var Qe=F.memoizedState;wt.state=Qe,Xr(F,$,wt,it),ae=F.memoizedState,Xt!==$||Qe!==ae||un.current||xn?(typeof He=="function"&&(qr(F,W,He,$),ae=F.memoizedState),(Xt=xn||Nl(F,W,Xt,$,Qe,ae,Ee))?(vi||typeof wt.UNSAFE_componentWillMount!="function"&&typeof wt.componentWillMount!="function"||(typeof wt.componentWillMount=="function"&&wt.componentWillMount(),typeof wt.UNSAFE_componentWillMount=="function"&&wt.UNSAFE_componentWillMount()),typeof wt.componentDidMount=="function"&&(F.flags|=4194308)):(typeof wt.componentDidMount=="function"&&(F.flags|=4194308),F.memoizedProps=$,F.memoizedState=ae),wt.props=$,wt.state=ae,wt.context=Ee,$=Xt):(typeof wt.componentDidMount=="function"&&(F.flags|=4194308),$=!1)}else{wt=F.stateNode,Ba(L,F),Xt=F.memoizedProps,Ee=F.type===F.elementType?Xt:Rn(F.type,Xt),wt.props=Ee,vi=F.pendingProps,Qe=wt.context,ae=W.contextType,typeof ae=="object"&&ae!==null?ae=$i(ae):(ae=pn(W)?Ii:mi.current,ae=Gn(F,ae));var qi=W.getDerivedStateFromProps;(He=typeof qi=="function"||typeof wt.getSnapshotBeforeUpdate=="function")||typeof wt.UNSAFE_componentWillReceiveProps!="function"&&typeof wt.componentWillReceiveProps!="function"||(Xt!==vi||Qe!==ae)&&jo(F,wt,$,ae),xn=!1,Qe=F.memoizedState,wt.state=Qe,Xr(F,$,wt,it);var Xe=F.memoizedState;Xt!==vi||Qe!==Xe||un.current||xn?(typeof qi=="function"&&(qr(F,W,qi,$),Xe=F.memoizedState),(Ee=xn||Nl(F,W,Ee,$,Qe,Xe,ae)||!1)?(He||typeof wt.UNSAFE_componentWillUpdate!="function"&&typeof wt.componentWillUpdate!="function"||(typeof wt.componentWillUpdate=="function"&&wt.componentWillUpdate($,Xe,ae),typeof wt.UNSAFE_componentWillUpdate=="function"&&wt.UNSAFE_componentWillUpdate($,Xe,ae)),typeof wt.componentDidUpdate=="function"&&(F.flags|=4),typeof wt.getSnapshotBeforeUpdate=="function"&&(F.flags|=1024)):(typeof wt.componentDidUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=4),typeof wt.getSnapshotBeforeUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=1024),F.memoizedProps=$,F.memoizedState=Xe),wt.props=$,wt.state=Xe,wt.context=ae,$=Ee):(typeof wt.componentDidUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=4),typeof wt.getSnapshotBeforeUpdate!="function"||Xt===L.memoizedProps&&Qe===L.memoizedState||(F.flags|=1024),$=!1)}return dc(L,F,W,$,lt,it)}function dc(L,F,W,$,it,lt){Sp(L,F);var wt=(F.flags&128)!==0;if(!$&&!wt)return it&&oa(F,W,!1),qn(L,F,lt);$=F.stateNode,Dg.current=F;var Xt=wt&&typeof W.getDerivedStateFromError!="function"?null:$.render();return F.flags|=1,L!==null&&wt?(F.child=Gr(F,L.child,null,lt),F.child=Gr(F,null,Xt,lt)):Ln(L,F,Xt,lt),F.memoizedState=$.state,it&&oa(F,W,!0),F.child}function Ep(L){var F=L.stateNode;F.pendingContext?dr(L,F.pendingContext,F.pendingContext!==F.context):F.context&&dr(L,F.context,!1),pt(L,F.containerInfo)}function Mp(L,F,W,$,it){return vo(),Ga(it),F.flags|=256,Ln(L,F,W,$),F.child}var Vu={dehydrated:null,treeContext:null,retryLane:0};function ws(L){return{baseLanes:L,cachePool:null}}function Cp(L,F,W){var $=F.pendingProps,it=ct.current,lt=!1,wt=(F.flags&128)!==0,Xt;if((Xt=wt)||(Xt=L!==null&&L.memoizedState===null?!1:(it&2)!==0),Xt?(lt=!0,F.flags&=-129):(L===null||L.memoizedState!==null)&&(it|=1),Se(ct,it&1),L===null)return cn(F),L=F.memoizedState,L!==null&&(L=L.dehydrated,L!==null)?(F.mode&1?aa(L)?F.lanes=8:F.lanes=1073741824:F.lanes=1,null):(it=$.children,L=$.fallback,lt?($=F.mode,lt=F.child,it={mode:"hidden",children:it},!($&1)&<!==null?(lt.childLanes=0,lt.pendingProps=it):lt=Xh(it,$,0,null),L=bo(L,$,W,null),lt.return=F,L.return=F,lt.sibling=L,F.child=lt,F.child.memoizedState=ws(W),F.memoizedState=Vu,L):pc(F,it));if(it=L.memoizedState,it!==null){if(Xt=it.dehydrated,Xt!==null){if(wt)return F.flags&256?(F.flags&=-257,Hu(L,F,W,Error(s(422)))):F.memoizedState!==null?(F.child=L.child,F.flags|=128,null):(lt=$.fallback,it=F.mode,$=Xh({mode:"visible",children:$.children},it,0,null),lt=bo(lt,it,W,null),lt.flags|=2,$.return=F,lt.return=F,$.sibling=lt,F.child=$,F.mode&1&&Gr(F,L.child,null,W),F.child.memoizedState=ws(W),F.memoizedState=Vu,lt);if(!(F.mode&1))F=Hu(L,F,W,null);else if(aa(Xt))F=Hu(L,F,W,Error(s(419)));else if($=(W&L.childLanes)!==0,rs||$){if($=Wn,$!==null){switch(W&-W){case 4:lt=2;break;case 16:lt=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:lt=32;break;case 536870912:lt=268435456;break;default:lt=0}$=lt&($.suspendedLanes|W)?0:lt,$!==0&&$!==it.retryLane&&(it.retryLane=$,As(L,$,-1))}_u(),F=Hu(L,F,W,Error(s(421)))}else Pa(Xt)?(F.flags|=128,F.child=L.child,F=Ro.bind(null,L),Bs(Xt,F),F=null):(W=it.treeContext,gt&&(Hn=Us(Xt),$n=F,_i=!0,is=null,po=!1,W!==null&&(sr[ar++]=Es,sr[ar++]=es,sr[ar++]=fa,Es=W.id,es=W.overflow,fa=F)),F=pc(F,F.pendingProps.children),F.flags|=4096);return F}return lt?($=Ap(L,F,$.children,$.fallback,W),lt=F.child,it=L.child.memoizedState,lt.memoizedState=it===null?ws(W):{baseLanes:it.baseLanes|W,cachePool:null},lt.childLanes=L.childLanes&~W,F.memoizedState=Vu,$):(W=wp(L,F,$.children,W),F.memoizedState=null,W)}return lt?($=Ap(L,F,$.children,$.fallback,W),lt=F.child,it=L.child.memoizedState,lt.memoizedState=it===null?ws(W):{baseLanes:it.baseLanes|W,cachePool:null},lt.childLanes=L.childLanes&~W,F.memoizedState=Vu,$):(W=wp(L,F,$.children,W),F.memoizedState=null,W)}function pc(L,F){return F=Xh({mode:"visible",children:F},L.mode,0,null),F.return=L,L.child=F}function wp(L,F,W,$){var it=L.child;return L=it.sibling,W=Ka(it,{mode:"visible",children:W}),!(F.mode&1)&&(W.lanes=$),W.return=F,W.sibling=null,L!==null&&($=F.deletions,$===null?(F.deletions=[L],F.flags|=16):$.push(L)),F.child=W}function Ap(L,F,W,$,it){var lt=F.mode;L=L.child;var wt=L.sibling,Xt={mode:"hidden",children:W};return!(lt&1)&&F.child!==L?(W=F.child,W.childLanes=0,W.pendingProps=Xt,F.deletions=null):(W=Ka(L,Xt),W.subtreeFlags=L.subtreeFlags&14680064),wt!==null?$=Ka(wt,$):($=bo($,lt,it,null),$.flags|=2),$.return=F,W.return=F,W.sibling=$,F.child=W,$}function Hu(L,F,W,$){return $!==null&&Ga($),Gr(F,L.child,null,W),L=pc(F,F.pendingProps.children),L.flags|=2,F.memoizedState=null,L}function So(L,F,W){L.lanes|=F;var $=L.alternate;$!==null&&($.lanes|=F),Na(L.return,F,W)}function vc(L,F,W,$,it){var lt=L.memoizedState;lt===null?L.memoizedState={isBackwards:F,rendering:null,renderingStartTime:0,last:$,tail:W,tailMode:it}:(lt.isBackwards=F,lt.rendering=null,lt.renderingStartTime=0,lt.last=$,lt.tail=W,lt.tailMode=it)}function Pp(L,F,W){var $=F.pendingProps,it=$.revealOrder,lt=$.tail;if(Ln(L,F,$.children,W),$=ct.current,$&2)$=$&1|2,F.flags|=128;else{if(L!==null&&L.flags&128)t:for(L=F.child;L!==null;){if(L.tag===13)L.memoizedState!==null&&So(L,W,F);else if(L.tag===19)So(L,W,F);else if(L.child!==null){L.child.return=L,L=L.child;continue}if(L===F)break t;for(;L.sibling===null;){if(L.return===null||L.return===F)break t;L=L.return}L.sibling.return=L.return,L=L.sibling}$&=1}if(Se(ct,$),!(F.mode&1))F.memoizedState=null;else switch(it){case"forwards":for(W=F.child,it=null;W!==null;)L=W.alternate,L!==null&&St(L)===null&&(it=W),W=W.sibling;W=it,W===null?(it=F.child,F.child=null):(it=W.sibling,W.sibling=null),vc(F,!1,it,W,lt);break;case"backwards":for(W=null,it=F.child,F.child=null;it!==null;){if(L=it.alternate,L!==null&&St(L)===null){F.child=it;break}L=it.sibling,it.sibling=W,W=it,it=L}vc(F,!0,W,null,lt);break;case"together":vc(F,!1,null,null,void 0);break;default:F.memoizedState=null}return F.child}function qn(L,F,W){if(L!==null&&(F.dependencies=L.dependencies),Kl|=F.lanes,!(W&F.childLanes))return null;if(L!==null&&F.child!==L.child)throw Error(s(153));if(F.child!==null){for(L=F.child,W=Ka(L,L.pendingProps),F.child=W,W.return=F;L.sibling!==null;)L=L.sibling,W=W.sibling=Ka(L,L.pendingProps),W.return=F;W.sibling=null}return F.child}function Ig(L,F,W){switch(F.tag){case 3:Ep(F),vo();break;case 5:Nt(F);break;case 1:pn(F.type)&&Tn(F);break;case 4:pt(F,F.stateNode.containerInfo);break;case 10:Ol(F,F.type._context,F.memoizedProps.value);break;case 13:var $=F.memoizedState;if($!==null)return $.dehydrated!==null?(Se(ct,ct.current&1),F.flags|=128,null):W&F.child.childLanes?Cp(L,F,W):(Se(ct,ct.current&1),L=qn(L,F,W),L!==null?L.sibling:null);Se(ct,ct.current&1);break;case 19:if($=(W&F.childLanes)!==0,L.flags&128){if($)return Pp(L,F,W);F.flags|=128}var it=F.memoizedState;if(it!==null&&(it.rendering=null,it.tail=null,it.lastEffect=null),Se(ct,ct.current),$)break;return null;case 22:case 23:return F.lanes=0,xp(L,F,W)}return qn(L,F,W)}function Ng(L,F){switch(or(F),F.tag){case 1:return pn(F.type)&&Ki(),L=F.flags,L&65536?(F.flags=L&-65537|128,F):null;case 3:return Mt(),ti(un),ti(mi),Ft(),L=F.flags,L&65536&&!(L&128)?(F.flags=L&-65537|128,F):null;case 5:return zt(F),null;case 13:if(ti(ct),L=F.memoizedState,L!==null&&L.dehydrated!==null){if(F.alternate===null)throw Error(s(340));vo()}return L=F.flags,L&65536?(F.flags=L&-65537|128,F):null;case 19:return ti(ct),null;case 4:return Mt(),null;case 10:return Dl(F.type._context),null;case 22:case 23:return Rc(),null;case 24:return null;default:return null}}var Wu=!1,qo=!1,Bg=typeof WeakSet=="function"?WeakSet:Set,De=null;function Ih(L,F){var W=L.ref;if(W!==null)if(typeof W=="function")try{W(null)}catch($){Pr(L,F,$)}else W.current=null}function mc(L,F,W){try{W()}catch($){Pr(L,F,$)}}var Rp=!1;function gc(L,F){for(X(L.containerInfo),De=F;De!==null;)if(L=De,F=L.child,(L.subtreeFlags&1028)!==0&&F!==null)F.return=L,De=F;else for(;De!==null;){L=De;try{var W=L.alternate;if(L.flags&1024)switch(L.tag){case 0:case 11:case 15:break;case 1:if(W!==null){var $=W.memoizedProps,it=W.memoizedState,lt=L.stateNode,wt=lt.getSnapshotBeforeUpdate(L.elementType===L.type?$:Rn(L.type,$),it);lt.__reactInternalSnapshotBeforeUpdate=wt}break;case 3:ot&&Me(L.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Xt){Pr(L,L.return,Xt)}if(F=L.sibling,F!==null){F.return=L.return,De=F;break}De=L.return}return W=Rp,Rp=!1,W}function Ks(L,F,W){var $=F.updateQueue;if($=$!==null?$.lastEffect:null,$!==null){var it=$=$.next;do{if((it.tag&L)===L){var lt=it.destroy;it.destroy=void 0,lt!==void 0&&mc(F,W,lt)}it=it.next}while(it!==$)}}function To(L,F){if(F=F.updateQueue,F=F!==null?F.lastEffect:null,F!==null){var W=F=F.next;do{if((W.tag&L)===L){var $=W.create;W.destroy=$()}W=W.next}while(W!==F)}}function yc(L){var F=L.ref;if(F!==null){var W=L.stateNode;switch(L.tag){case 5:L=B(W);break;default:L=W}typeof F=="function"?F(L):F.current=L}}function xc(L,F,W){if(xr&&typeof xr.onCommitFiberUnmount=="function")try{xr.onCommitFiberUnmount(fo,F)}catch{}switch(F.tag){case 0:case 11:case 14:case 15:if(L=F.updateQueue,L!==null&&(L=L.lastEffect,L!==null)){var $=L=L.next;do{var it=$,lt=it.destroy;it=it.tag,lt!==void 0&&(it&2||it&4)&&mc(F,W,lt),$=$.next}while($!==L)}break;case 1:if(Ih(F,W),L=F.stateNode,typeof L.componentWillUnmount=="function")try{L.props=F.memoizedProps,L.state=F.memoizedState,L.componentWillUnmount()}catch(wt){Pr(F,W,wt)}break;case 5:Ih(F,W);break;case 4:ot?Tc(L,F,W):rt&&rt&&(F=F.stateNode.containerInfo,W=Ve(F),Di(F,W))}}function bp(L,F,W){for(var $=F;;)if(xc(L,$,W),$.child===null||ot&&$.tag===4){if($===F)break;for(;$.sibling===null;){if($.return===null||$.return===F)return;$=$.return}$.sibling.return=$.return,$=$.sibling}else $.child.return=$,$=$.child}function pa(L){var F=L.alternate;F!==null&&(L.alternate=null,pa(F)),L.child=null,L.deletions=null,L.sibling=null,L.tag===5&&(F=L.stateNode,F!==null&&Pt(F)),L.stateNode=null,L.return=null,L.dependencies=null,L.memoizedProps=null,L.memoizedState=null,L.pendingProps=null,L.stateNode=null,L.updateQueue=null}function Xu(L){return L.tag===5||L.tag===3||L.tag===4}function Eo(L){t:for(;;){for(;L.sibling===null;){if(L.return===null||Xu(L.return))return null;L=L.return}for(L.sibling.return=L.return,L=L.sibling;L.tag!==5&&L.tag!==6&&L.tag!==18;){if(L.flags&2||L.child===null||L.tag===4)continue t;L.child.return=L,L=L.child}if(!(L.flags&2))return L.stateNode}}function ss(L){if(ot){t:{for(var F=L.return;F!==null;){if(Xu(F))break t;F=F.return}throw Error(s(160))}var W=F;switch(W.tag){case 5:F=W.stateNode,W.flags&32&&(ri(F),W.flags&=-33),W=Eo(L),Yu(L,W,F);break;case 3:case 4:F=W.stateNode.containerInfo,W=Eo(L),Sc(L,W,F);break;default:throw Error(s(161))}}}function Sc(L,F,W){var $=L.tag;if($===5||$===6)L=L.stateNode,F?Le(W,L,F):Ae(W,L);else if($!==4&&(L=L.child,L!==null))for(Sc(L,F,W),L=L.sibling;L!==null;)Sc(L,F,W),L=L.sibling}function Yu(L,F,W){var $=L.tag;if($===5||$===6)L=L.stateNode,F?Be(W,L,F):xe(W,L);else if($!==4&&(L=L.child,L!==null))for(Yu(L,F,W),L=L.sibling;L!==null;)Yu(L,F,W),L=L.sibling}function Tc(L,F,W){for(var $=F,it=!1,lt,wt;;){if(!it){it=$.return;t:for(;;){if(it===null)throw Error(s(160));switch(lt=it.stateNode,it.tag){case 5:wt=!1;break t;case 3:lt=lt.containerInfo,wt=!0;break t;case 4:lt=lt.containerInfo,wt=!0;break t}it=it.return}it=!0}if($.tag===5||$.tag===6)bp(L,$,W),wt?Ke(lt,$.stateNode):ie(lt,$.stateNode);else if($.tag===18)wt?te(lt,$.stateNode):ee(lt,$.stateNode);else if($.tag===4){if($.child!==null){lt=$.stateNode.containerInfo,wt=!0,$.child.return=$,$=$.child;continue}}else if(xc(L,$,W),$.child!==null){$.child.return=$,$=$.child;continue}if($===F)break;for(;$.sibling===null;){if($.return===null||$.return===F)return;$=$.return,$.tag===4&&(it=!1)}$.sibling.return=$.return,$=$.sibling}}function tl(L,F){if(ot){switch(F.tag){case 0:case 11:case 14:case 15:Ks(3,F,F.return),To(3,F),Ks(5,F,F.return);return;case 1:return;case 5:var W=F.stateNode;if(W!=null){var $=F.memoizedProps;L=L!==null?L.memoizedProps:$;var it=F.type,lt=F.updateQueue;F.updateQueue=null,lt!==null&&Oe(W,lt,it,L,$,F)}return;case 6:if(F.stateNode===null)throw Error(s(162));W=F.memoizedProps,qt(F.stateNode,L!==null?L.memoizedProps:W,W);return;case 3:gt&&L!==null&&L.memoizedState.isDehydrated&&jt(F.stateNode.containerInfo);return;case 12:return;case 13:js(F);return;case 19:js(F);return;case 17:return}throw Error(s(163))}switch(F.tag){case 0:case 11:case 14:case 15:Ks(3,F,F.return),To(3,F),Ks(5,F,F.return);return;case 12:return;case 13:js(F);return;case 19:js(F);return;case 3:gt&&L!==null&&L.memoizedState.isDehydrated&&jt(F.stateNode.containerInfo);break;case 22:case 23:return}t:if(rt){switch(F.tag){case 1:case 5:case 6:break t;case 3:case 4:F=F.stateNode,Di(F.containerInfo,F.pendingChildren);break t}throw Error(s(163))}}function js(L){var F=L.updateQueue;if(F!==null){L.updateQueue=null;var W=L.stateNode;W===null&&(W=L.stateNode=new Bg),F.forEach(function($){var it=Up.bind(null,L,$);W.has($)||(W.add($),$.then(it,it))})}}function Lp(L,F){for(De=F;De!==null;){F=De;var W=F.deletions;if(W!==null)for(var $=0;$";case Bh:return":has("+(Uh(L)||"")+")";case as:return'[role="'+L.value+'"]';case el:return'"'+L.value+'"';case Wl:return'[data-testname="'+L.value+'"]';default:throw Error(s(365))}}function Op(L,F){var W=[];L=[L,0];for(var $=0;$it&&(it=wt),$&=~lt}if($=it,$=nn()-$,$=(120>$?120:480>$?480:1080>$?1080:1920>$?1920:3e3>$?3e3:4320>$?4320:1960*zg($/1960))-$,10<$){L.timeoutHandle=J(wo.bind(null,L,Cr),$);break}wo(L,Cr);break;case 5:wo(L,Cr);break;default:throw Error(s(329))}}}return ei(L,nn()),L.callbackNode===W?Dp.bind(null,L):null}function Pc(L,F){var W=jl;return L.current.memoizedState.isDehydrated&&(ma(L,F).flags|=256),L=Ar(L,F),L!==2&&(F=Cr,Cr=W,F!==null&&nl(F)),L}function nl(L){Cr===null?Cr=L:Cr.push.apply(Cr,L)}function Ip(L){for(var F=L;;){if(F.flags&16384){var W=F.updateQueue;if(W!==null&&(W=W.stores,W!==null))for(var $=0;$L?16:L,ka===null)var $=!1;else{if(L=ka,ka=null,Vh=0,Ei&6)throw Error(s(331));var it=Ei;for(Ei|=4,De=L.current;De!==null;){var lt=De,wt=lt.child;if(De.flags&16){var Xt=lt.deletions;if(Xt!==null){for(var ae=0;aenn()-Ac?ma(L,0):wc|=W),ei(L,F)}function Bp(L,F){F===0&&(L.mode&1?(F=ho,ho<<=1,!(ho&130023424)&&(ho=4194304)):F=1);var W=wr();L=Jl(L,F),L!==null&&(Hs(L,F,W),ei(L,W))}function Ro(L){var F=L.memoizedState,W=0;F!==null&&(W=F.retryLane),Bp(L,W)}function Up(L,F){var W=0;switch(L.tag){case 13:var $=L.stateNode,it=L.memoizedState;it!==null&&(W=it.retryLane);break;case 19:$=L.stateNode;break;default:throw Error(s(314))}$!==null&&$.delete(F),Bp(L,W)}var Dc;Dc=function(L,F,W){if(L!==null)if(L.memoizedProps!==F.pendingProps||un.current)rs=!0;else{if(!(L.lanes&W)&&!(F.flags&128))return rs=!1,Ig(L,F,W);rs=!!(L.flags&131072)}else rs=!1,_i&&F.flags&1048576&&wh(F,Zo,F.index);switch(F.lanes=0,F.tag){case 2:var $=F.type;L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),L=F.pendingProps;var it=Gn(F,mi.current);Xs(F,W),it=me(null,F,$,L,it,W);var lt=be();return F.flags|=1,typeof it=="object"&&it!==null&&typeof it.render=="function"&&it.$$typeof===void 0?(F.tag=1,F.memoizedState=null,F.updateQueue=null,pn($)?(lt=!0,Tn(F)):lt=!1,F.memoizedState=it.state!==null&&it.state!==void 0?it.state:null,Vn(F),it.updater=co,F.stateNode=it,it._reactInternals=F,za(F,$,L,W),F=dc(null,F,$,!0,lt,W)):(F.tag=0,_i&<&&Bl(F),Ln(null,F,it,W),F=F.child),F;case 16:$=F.elementType;t:{switch(L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),L=F.pendingProps,it=$._init,$=it($._payload),F.type=$,it=F.tag=zp($),L=Rn($,L),it){case 0:F=ks(null,F,$,L,W);break t;case 1:F=Tp(null,F,$,L,W);break t;case 11:F=mp(null,F,$,L,W);break t;case 14:F=gp(null,F,$,Rn($.type,L),W);break t}throw Error(s(306,$,""))}return F;case 0:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),ks(L,F,$,it,W);case 1:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),Tp(L,F,$,it,W);case 3:t:{if(Ep(F),L===null)throw Error(s(387));$=F.pendingProps,lt=F.memoizedState,it=lt.element,Ba(L,F),Xr(F,$,null,W);var wt=F.memoizedState;if($=wt.element,gt&<.isDehydrated)if(lt={element:$,isDehydrated:!1,cache:wt.cache,transitions:wt.transitions},F.updateQueue.baseState=lt,F.memoizedState=lt,F.flags&256){it=Error(s(423)),F=Mp(L,F,$,W,it);break t}else if($!==it){it=Error(s(424)),F=Mp(L,F,$,W,it);break t}else for(gt&&(Hn=_r(F.stateNode.containerInfo),$n=F,_i=!0,is=null,po=!1),W=Ah(F,null,$,W),F.child=W;W;)W.flags=W.flags&-3|4096,W=W.sibling;else{if(vo(),$===it){F=qn(L,F,W);break t}Ln(L,F,$,W)}F=F.child}return F;case 5:return Nt(F),L===null&&cn(F),$=F.type,it=F.pendingProps,lt=L!==null?L.memoizedProps:null,wt=it.children,U($,it)?wt=null:lt!==null&&U($,lt)&&(F.flags|=32),Sp(L,F),Ln(L,F,wt,W),F.child;case 6:return L===null&&cn(F),null;case 13:return Cp(L,F,W);case 4:return pt(F,F.stateNode.containerInfo),$=F.pendingProps,L===null?F.child=Gr(F,null,$,W):Ln(L,F,$,W),F.child;case 11:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),mp(L,F,$,it,W);case 7:return Ln(L,F,F.pendingProps,W),F.child;case 8:return Ln(L,F,F.pendingProps.children,W),F.child;case 12:return Ln(L,F,F.pendingProps.children,W),F.child;case 10:t:{if($=F.type._context,it=F.pendingProps,lt=F.memoizedProps,wt=it.value,Ol(F,$,wt),lt!==null)if(Ts(lt.value,wt)){if(lt.children===it.children&&!un.current){F=qn(L,F,W);break t}}else for(lt=F.child,lt!==null&&(lt.return=F);lt!==null;){var Xt=lt.dependencies;if(Xt!==null){wt=lt.child;for(var ae=Xt.firstContext;ae!==null;){if(ae.context===$){if(lt.tag===1){ae=Mn(-1,W&-W),ae.tag=2;var Ee=lt.updateQueue;if(Ee!==null){Ee=Ee.shared;var He=Ee.pending;He===null?ae.next=ae:(ae.next=He.next,He.next=ae),Ee.pending=ae}}lt.lanes|=W,ae=lt.alternate,ae!==null&&(ae.lanes|=W),Na(lt.return,W,F),Xt.lanes|=W;break}ae=ae.next}}else if(lt.tag===10)wt=lt.type===F.type?null:lt.child;else if(lt.tag===18){if(wt=lt.return,wt===null)throw Error(s(341));wt.lanes|=W,Xt=wt.alternate,Xt!==null&&(Xt.lanes|=W),Na(wt,W,F),wt=lt.sibling}else wt=lt.child;if(wt!==null)wt.return=lt;else for(wt=lt;wt!==null;){if(wt===F){wt=null;break}if(lt=wt.sibling,lt!==null){lt.return=wt.return,wt=lt;break}wt=wt.return}lt=wt}Ln(L,F,it.children,W),F=F.child}return F;case 9:return it=F.type,$=F.pendingProps.children,Xs(F,W),it=$i(it),$=$(it),F.flags|=1,Ln(L,F,$,W),F.child;case 14:return $=F.type,it=Rn($,F.pendingProps),it=Rn($.type,it),gp(L,F,$,it,W);case 15:return yp(L,F,F.type,F.pendingProps,W);case 17:return $=F.type,it=F.pendingProps,it=F.elementType===$?it:Rn($,it),L!==null&&(L.alternate=null,F.alternate=null,F.flags|=2),F.tag=1,pn($)?(L=!0,Tn(F)):L=!1,Xs(F,W),Ko(F,$,it),za(F,$,it,W),dc(null,F,$,!0,L,W);case 19:return Pp(L,F,W);case 22:return xp(L,F,W)}throw Error(s(156,F.tag))};function tf(L,F){return Br(L,F)}function Gg(L,F,W,$){this.tag=L,this.key=W,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=$,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ps(L,F,W,$){return new Gg(L,F,W,$)}function Ic(L){return L=L.prototype,!(!L||!L.isReactComponent)}function zp(L){if(typeof L=="function")return Ic(L)?1:0;if(L!=null){if(L=L.$$typeof,L===u)return 11;if(L===c)return 14}return 2}function Ka(L,F){var W=L.alternate;return W===null?(W=Ps(L.tag,F,L.key,L.mode),W.elementType=L.elementType,W.type=L.type,W.stateNode=L.stateNode,W.alternate=L,L.alternate=W):(W.pendingProps=F,W.type=L.type,W.flags=0,W.subtreeFlags=0,W.deletions=null),W.flags=L.flags&14680064,W.childLanes=L.childLanes,W.lanes=L.lanes,W.child=L.child,W.memoizedProps=L.memoizedProps,W.memoizedState=L.memoizedState,W.updateQueue=L.updateQueue,F=L.dependencies,W.dependencies=F===null?null:{lanes:F.lanes,firstContext:F.firstContext},W.sibling=L.sibling,W.index=L.index,W.ref=L.ref,W}function ef(L,F,W,$,it,lt){var wt=2;if($=L,typeof L=="function")Ic(L)&&(wt=1);else if(typeof L=="string")wt=5;else t:switch(L){case p:return bo(W.children,it,lt,F);case h:wt=8,it|=8;break;case a:return L=Ps(12,W,F,it|2),L.elementType=a,L.lanes=lt,L;case f:return L=Ps(13,W,F,it),L.elementType=f,L.lanes=lt,L;case o:return L=Ps(19,W,F,it),L.elementType=o,L.lanes=lt,L;case v:return Xh(W,it,lt,F);default:if(typeof L=="object"&&L!==null)switch(L.$$typeof){case l:wt=10;break t;case n:wt=9;break t;case u:wt=11;break t;case c:wt=14;break t;case d:wt=16,$=null;break t}throw Error(s(130,L==null?L:typeof L,""))}return F=Ps(wt,W,F,it),F.elementType=L,F.type=$,F.lanes=lt,F}function bo(L,F,W,$){return L=Ps(7,L,$,F),L.lanes=W,L}function Xh(L,F,W,$){return L=Ps(22,L,$,F),L.elementType=v,L.lanes=W,L.stateNode={},L}function Rr(L,F,W){return L=Ps(6,L,null,F),L.lanes=W,L}function Rs(L,F,W){return F=Ps(4,L.children!==null?L.children:[],L.key,F),F.lanes=W,F.stateNode={containerInfo:L.containerInfo,pendingChildren:null,implementation:L.implementation},F}function Vg(L,F,W,$,it){this.tag=F,this.containerInfo=L,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=q,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vs(0),this.expirationTimes=Vs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vs(0),this.identifierPrefix=$,this.onRecoverableError=it,gt&&(this.mutableSourceEagerHydrationData=null)}function Gp(L,F,W,$,it,lt,wt,Xt,ae){return L=new Vg(L,F,W,Xt,ae),F===1?(F=1,lt===!0&&(F|=8)):F=0,lt=Ps(3,null,null,F),L.current=lt,lt.stateNode=L,lt.memoizedState={element:$,isDehydrated:W,cache:null,transitions:null},Vn(lt),L}function Yh(L){if(!L)return Nr;L=L._reactInternals;t:{if(C(L)!==L||L.tag!==1)throw Error(s(170));var F=L;do{switch(F.tag){case 3:F=F.stateNode.context;break t;case 1:if(pn(F.type)){F=F.stateNode.__reactInternalMemoizedMergedChildContext;break t}}F=F.return}while(F!==null);throw Error(s(171))}if(L.tag===1){var W=L.type;if(pn(W))return zs(L,W,F)}return F}function rl(L){var F=L._reactInternals;if(F===void 0)throw typeof L.render=="function"?Error(s(188)):(L=Object.keys(L).join(","),Error(s(268,L)));return L=b(F),L===null?null:L.stateNode}function Nc(L,F){if(L=L.memoizedState,L!==null&&L.dehydrated!==null){var W=L.retryLane;L.retryLane=W!==0&&W=Ee&<>=vi&&it<=He&&wt<=Qe){L.splice(F,1);break}else if($!==Ee||W.width!==ae.width||Qewt){if(!(lt!==vi||W.height!==ae.height||He<$||Ee>it)){Ee>$&&(ae.width+=Ee-$,ae.x=$),Helt&&(ae.height+=vi-lt,ae.y=lt),QeW&&(W=wt)),wt ")+` No matching component was found for: - `)+L.join(" > ")}return null},i.getPublicRootInstance=function(L){if(L=L.current,!L.child)return null;switch(L.child.tag){case 5:return B(L.child.stateNode);default:return L.child.stateNode}},i.injectIntoDevTools=function(L){if(L={bundleType:L.bundleType,version:L.version,rendererPackageName:L.rendererPackageName,rendererConfig:L.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:y.ReactCurrentDispatcher,findHostInstanceByFiber:Vg,findFiberByHostInstance:L.findFiberByHostInstance||Vp,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")L=!1;else{var F=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(F.isDisabled||!F.supportsFiber)L=!0;else{try{fo=F.inject(L),xr=F}catch{}L=!!F.checkDCE}}return L},i.isAlreadyRendering=function(){return!1},i.observeVisibleRects=function(L,F,W,$){if(!ut)throw Error(s(363));L=Mc(L,F);var it=ge(L,W,$).disconnect;return{disconnect:function(){it()}}},i.registerMutableSourceForHydration=function(L,F){var W=F._getVersion;W=W(F._source),L.mutableSourceEagerHydrationData==null?L.mutableSourceEagerHydrationData=[F,W]:L.mutableSourceEagerHydrationData.push(F,W)},i.runWithPriority=function(L,F){var W=Ni;try{return Ni=L,F()}finally{Ni=W}},i.shouldError=function(){return null},i.shouldSuspend=function(){return!1},i.updateContainer=function(L,F,W,$){var it=F.current,lt=wr(),wt=va(it);return W=Yh(W),F.context===null?F.context=W:F.pendingContext=W,F=Mn(lt,wt),F.payload={element:L},$=$===void 0?null:$,$!==null&&(F.callback=$),Sr(it,F),L=As(it,wt,lt),L!==null&&la(L,it,wt),wt},i};MA.exports=W7;var X7=MA.exports;const Y7=Wd(X7);var CA={exports:{}},wA={};/** + `)+L.join(" > ")}return null},i.getPublicRootInstance=function(L){if(L=L.current,!L.child)return null;switch(L.child.tag){case 5:return B(L.child.stateNode);default:return L.child.stateNode}},i.injectIntoDevTools=function(L){if(L={bundleType:L.bundleType,version:L.version,rendererPackageName:L.rendererPackageName,rendererConfig:L.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:y.ReactCurrentDispatcher,findHostInstanceByFiber:Hg,findFiberByHostInstance:L.findFiberByHostInstance||Vp,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")L=!1;else{var F=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(F.isDisabled||!F.supportsFiber)L=!0;else{try{fo=F.inject(L),xr=F}catch{}L=!!F.checkDCE}}return L},i.isAlreadyRendering=function(){return!1},i.observeVisibleRects=function(L,F,W,$){if(!ut)throw Error(s(363));L=Mc(L,F);var it=ge(L,W,$).disconnect;return{disconnect:function(){it()}}},i.registerMutableSourceForHydration=function(L,F){var W=F._getVersion;W=W(F._source),L.mutableSourceEagerHydrationData==null?L.mutableSourceEagerHydrationData=[F,W]:L.mutableSourceEagerHydrationData.push(F,W)},i.runWithPriority=function(L,F){var W=Ni;try{return Ni=L,F()}finally{Ni=W}},i.shouldError=function(){return null},i.shouldSuspend=function(){return!1},i.updateContainer=function(L,F,W,$){var it=F.current,lt=wr(),wt=va(it);return W=Yh(W),F.context===null?F.context=W:F.pendingContext=W,F=Mn(lt,wt),F.payload={element:L},$=$===void 0?null:$,$!==null&&(F.callback=$),Sr(it,F),L=As(it,wt,lt),L!==null&&la(L,it,wt),wt},i};MA.exports=W7;var X7=MA.exports;const Y7=Wd(X7);var CA={exports:{}},wA={};/** * @license React * scheduler.production.min.js * @@ -10206,11 +10206,11 @@ No matching component was found for: * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(g){function t(z,X){var K=z.length;z.push(X);t:for(;0>>1,tt=z[Q];if(0>>1;QT(U,K))HT(J,U)?(z[Q]=J,z[H]=K,Q=H):(z[Q]=U,z[Z]=K,Q=Z);else if(HT(J,K))z[Q]=J,z[H]=K,Q=H;else break t}}return X}function T(z,X){var K=z.sortIndex-X.sortIndex;return K!==0?K:z.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var E=performance;g.unstable_now=function(){return E.now()}}else{var s=Date,y=s.now();g.unstable_now=function(){return s.now()-y}}var e=[],r=[],p=1,h=null,a=3,l=!1,n=!1,u=!1,f=typeof setTimeout=="function"?setTimeout:null,o=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(z){for(var X=i(r);X!==null;){if(X.callback===null)x(r);else if(X.startTime<=z)x(r),X.sortIndex=X.expirationTime,t(e,X);else break;X=i(r)}}function v(z){if(u=!1,d(z),!n)if(i(e)!==null)n=!0,B(m);else{var X=i(r);X!==null&&G(v,X.startTime-z)}}function m(z,X){n=!1,u&&(u=!1,o(w),w=-1),l=!0;var K=a;try{for(d(X),h=i(e);h!==null&&(!(h.expirationTime>X)||z&&!P());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,a=h.priorityLevel;var tt=Q(h.expirationTime<=X);X=g.unstable_now(),typeof tt=="function"?h.callback=tt:h===i(e)&&x(e),d(X)}else x(e);h=i(e)}if(h!==null)var Y=!0;else{var Z=i(r);Z!==null&&G(v,Z.startTime-X),Y=!1}return Y}finally{h=null,a=K,l=!1}}var S=!1,M=null,w=-1,C=5,A=-1;function P(){return!(g.unstable_now()-Az||125Q?(z.sortIndex=K,t(r,z),i(e)===null&&z===i(r)&&(u?(o(w),w=-1):u=!0,G(v,K-Q))):(z.sortIndex=tt,t(e,z),n||l||(n=!0,B(m))),z},g.unstable_shouldYield=P,g.unstable_wrapCallback=function(z){var X=a;return function(){var K=a;a=X;try{return z.apply(this,arguments)}finally{a=K}}}})(wA);CA.exports=wA;var sM=CA.exports;const X1={},k7=g=>void Object.assign(X1,g);function K7(g,t){function i(p,{args:h=[],attach:a,...l},n){let u=`${p[0].toUpperCase()}${p.slice(1)}`,f;if(p==="primitive"){if(l.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const o=l.object;f=Ff(o,{type:p,root:n,attach:a,primitive:!0})}else{const o=X1[u];if(!o)throw new Error(`R3F: ${u} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(h))throw new Error("R3F: The args prop must be an array!");f=Ff(new o(...h),{type:p,root:n,attach:a,memoizedProps:{args:h}})}return f.__r3f.attach===void 0&&(f instanceof Li?f.__r3f.attach="geometry":f instanceof Hr&&(f.__r3f.attach="material")),u!=="inject"&&ay(f,l),f}function x(p,h){let a=!1;if(h){var l,n;(l=h.__r3f)!=null&&l.attach?sy(p,h,h.__r3f.attach):h.isObject3D&&p.isObject3D&&(p.add(h),a=!0),a||(n=p.__r3f)==null||n.objects.push(h),h.__r3f||Ff(h,{}),h.__r3f.parent=p,Mx(h),Of(h)}}function T(p,h,a){let l=!1;if(h){var n,u;if((n=h.__r3f)!=null&&n.attach)sy(p,h,h.__r3f.attach);else if(h.isObject3D&&p.isObject3D){h.parent=p,h.dispatchEvent({type:"added"}),p.dispatchEvent({type:"childadded",child:h});const f=p.children.filter(c=>c!==h),o=f.indexOf(a);p.children=[...f.slice(0,o),h,...f.slice(o)],l=!0}l||(u=p.__r3f)==null||u.objects.push(h),h.__r3f||Ff(h,{}),h.__r3f.parent=p,Mx(h),Of(h)}}function E(p,h,a=!1){p&&[...p].forEach(l=>s(h,l,a))}function s(p,h,a){if(h){var l,n,u;if(h.__r3f&&(h.__r3f.parent=null),(l=p.__r3f)!=null&&l.objects&&(p.__r3f.objects=p.__r3f.objects.filter(v=>v!==h)),(n=h.__r3f)!=null&&n.attach)uM(p,h,h.__r3f.attach);else if(h.isObject3D&&p.isObject3D){var f;p.remove(h),(f=h.__r3f)!=null&&f.root&&tz(hm(h),h)}const c=(u=h.__r3f)==null?void 0:u.primitive,d=!c&&(a===void 0?h.dispose!==null:a);if(!c){var o;E((o=h.__r3f)==null?void 0:o.objects,h,d),E(h.children,h,d)}if(delete h.__r3f,d&&h.dispose&&h.type!=="Scene"){const v=()=>{try{h.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?sM.unstable_scheduleCallback(sM.unstable_IdlePriority,v):v()}Of(p)}}function y(p,h,a,l){var n;const u=(n=p.__r3f)==null?void 0:n.parent;if(!u)return;const f=i(h,a,p.__r3f.root);if(p.children){for(const o of p.children)o.__r3f&&x(f,o);p.children=p.children.filter(o=>!o.__r3f)}p.__r3f.objects.forEach(o=>x(f,o)),p.__r3f.objects=[],p.__r3f.autoRemovedBeforeAppend||s(u,p),f.parent&&(f.__r3f.autoRemovedBeforeAppend=!0),x(u,f),f.raycast&&f.__r3f.eventCount&&hm(f).getState().internal.interaction.push(f),[l,l.alternate].forEach(o=>{o!==null&&(o.stateNode=f,o.ref&&(typeof o.ref=="function"?o.ref(f):o.ref.current=f))})}const e=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:Y7({createInstance:i,removeChild:s,appendChild:x,appendInitialChild:x,insertBefore:T,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(p,h)=>{if(!h)return;const a=p.getState().scene;a.__r3f&&(a.__r3f.root=p,x(a,h))},removeChildFromContainer:(p,h)=>{h&&s(p.getState().scene,h)},insertInContainerBefore:(p,h,a)=>{if(!h||!a)return;const l=p.getState().scene;l.__r3f&&T(l,h,a)},getRootHostContext:()=>null,getChildHostContext:p=>p,finalizeInitialChildren(p){var h;return!!((h=p?.__r3f)!=null?h:{}).handlers},prepareUpdate(p,h,a,l){var n;if(((n=p?.__r3f)!=null?n:{}).primitive&&l.object&&l.object!==p)return[!0];{const{args:f=[],children:o,...c}=l,{args:d=[],children:v,...m}=a;if(!Array.isArray(f))throw new Error("R3F: the args prop must be an array!");if(f.some((M,w)=>M!==d[w]))return[!0];const S=OA(p,c,m,!0);return S.changes.length?[!1,S]:null}},commitUpdate(p,[h,a],l,n,u,f){h?y(p,l,u,f):ay(p,a)},commitMount(p,h,a,l){var n;const u=(n=p.__r3f)!=null?n:{};p.raycast&&u.handlers&&u.eventCount&&hm(p).getState().internal.interaction.push(p)},getPublicInstance:p=>p,prepareForCommit:()=>null,preparePortalMount:p=>Ff(p.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(p){var h;const{attach:a,parent:l}=(h=p.__r3f)!=null?h:{};a&&l&&uM(l,p,a),p.isObject3D&&(p.visible=!1),Of(p)},unhideInstance(p,h){var a;const{attach:l,parent:n}=(a=p.__r3f)!=null?a:{};l&&n&&sy(n,p,l),(p.isObject3D&&h.visible==null||h.visible)&&(p.visible=!0),Of(p)},createTextInstance:e,hideTextInstance:e,unhideTextInstance:e,getCurrentEventPriority:()=>t?t():Hf.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&wn.fun(performance.now)?performance.now:wn.fun(Date.now)?Date.now:()=>0,scheduleTimeout:wn.fun(setTimeout)?setTimeout:void 0,cancelTimeout:wn.fun(clearTimeout)?clearTimeout:void 0}),applyProps:ay}}var aM,oM;const ry=g=>"colorSpace"in g||"outputColorSpace"in g,AA=()=>{var g;return(g=X1.ColorManagement)!=null?g:null},PA=g=>g&&g.isOrthographicCamera,j7=g=>g&&g.hasOwnProperty("current"),rp=typeof window<"u"&&((aM=window.document)!=null&&aM.createElement||((oM=window.navigator)==null?void 0:oM.product)==="ReactNative")?Pe.useLayoutEffect:Pe.useEffect;function RA(g){const t=Pe.useRef(g);return rp(()=>void(t.current=g),[g]),t}function Z7({set:g}){return rp(()=>(g(new Promise(()=>null)),()=>g(!1)),[g]),null}class bA extends Pe.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}}bA.getDerivedStateFromError=()=>({error:!0});const LA="__default",lM=new Map,J7=g=>g&&!!g.memoized&&!!g.changes;function FA(g){var t;const i=typeof window<"u"?(t=window.devicePixelRatio)!=null?t:2:1;return Array.isArray(g)?Math.min(Math.max(g[0],i),g[1]):g}const td=g=>{var t;return(t=g.__r3f)==null?void 0:t.root.getState()};function hm(g){let t=g.__r3f.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}const wn={obj:g=>g===Object(g)&&!wn.arr(g)&&typeof g!="function",fun:g=>typeof g=="function",str:g=>typeof g=="string",num:g=>typeof g=="number",boo:g=>typeof g=="boolean",und:g=>g===void 0,arr:g=>Array.isArray(g),equ(g,t,{arrays:i="shallow",objects:x="reference",strict:T=!0}={}){if(typeof g!=typeof t||!!g!=!!t)return!1;if(wn.str(g)||wn.num(g))return g===t;const E=wn.obj(g);if(E&&x==="reference")return g===t;const s=wn.arr(g);if(s&&i==="reference")return g===t;if((s||E)&&g===t)return!0;let y;for(y in g)if(!(y in t))return!1;if(E&&i==="shallow"&&x==="shallow"){for(y in T?t:g)if(!wn.equ(g[y],t[y],{strict:T,objects:"reference"}))return!1}else for(y in T?t:g)if(g[y]!==t[y])return!1;if(wn.und(y)){if(s&&g.length===0&&t.length===0||E&&Object.keys(g).length===0&&Object.keys(t).length===0)return!0;if(g!==t)return!1}return!0}};function $7(g){g.dispose&&g.type!=="Scene"&&g.dispose();for(const t in g)t.dispose==null||t.dispose(),delete g[t]}function Ff(g,t){const i=g;return i.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...t},g}function Ex(g,t){let i=g;if(t.includes("-")){const x=t.split("-"),T=x.pop();return i=x.reduce((E,s)=>E[s],g),{target:i,key:T}}else return{target:i,key:t}}const hM=/-\d+$/;function sy(g,t,i){if(wn.str(i)){if(hM.test(i)){const E=i.replace(hM,""),{target:s,key:y}=Ex(g,E);Array.isArray(s[y])||(s[y]=[])}const{target:x,key:T}=Ex(g,i);t.__r3f.previousAttach=x[T],x[T]=t}else t.__r3f.previousAttach=i(g,t)}function uM(g,t,i){var x,T;if(wn.str(i)){const{target:E,key:s}=Ex(g,i),y=t.__r3f.previousAttach;y===void 0?delete E[s]:E[s]=y}else(x=t.__r3f)==null||x.previousAttach==null||x.previousAttach(g,t);(T=t.__r3f)==null||delete T.previousAttach}function OA(g,{children:t,key:i,ref:x,...T},{children:E,key:s,ref:y,...e}={},r=!1){var p;const h=(p=g?.__r3f)!=null?p:{},a=Object.entries(T),l=[];if(r){const u=Object.keys(e);for(let f=0;f{var o;if((o=g.__r3f)!=null&&o.primitive&&u==="object"||wn.equ(f,e[u]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(u))return l.push([u,f,!0,[]]);let c=[];u.includes("-")&&(c=u.split("-")),l.push([u,f,!1,c]);for(const d in T){const v=T[d];d.startsWith(`${u}-`)&&l.push([d,v,!1,d.split("-")])}});const n={...T};return h.memoizedProps&&h.memoizedProps.args&&(n.args=h.memoizedProps.args),h.memoizedProps&&h.memoizedProps.attach&&(n.attach=h.memoizedProps.attach),{memoized:n,changes:l}}const Q7=typeof process<"u"&&!1;function ay(g,t){var i,x,T;const E=(i=g.__r3f)!=null?i:{},s=E.root,y=(x=s==null||s.getState==null?void 0:s.getState())!=null?x:{},{memoized:e,changes:r}=J7(t)?t:OA(g,t),p=E.eventCount;g.__r3f&&(g.__r3f.memoizedProps=e);for(let a=0;ad[v],g),!(c&&c.set))){const[d,...v]=f.reverse();o=v.reverse().reduce((m,S)=>m[S],g),l=d}if(n===LA+"remove")if(o.constructor){let d=lM.get(o.constructor);d||(d=new o.constructor,lM.set(o.constructor,d)),n=d[l]}else n=0;if(u)n?E.handlers[l]=n:delete E.handlers[l],E.eventCount=Object.keys(E.handlers).length;else if(c&&c.set&&(c.copy||c instanceof Tu)){if(Array.isArray(n))c.fromArray?c.fromArray(n):c.set(...n);else if(c.copy&&n&&n.constructor&&(Q7?c.constructor.name===n.constructor.name:c.constructor===n.constructor))c.copy(n);else if(n!==void 0){const d=c instanceof ze;!d&&c.setScalar?c.setScalar(n):c instanceof Tu&&n instanceof Tu?c.mask=n.mask:c.set(n),!AA()&&!y.linear&&d&&c.convertSRGBToLinear()}}else if(o[l]=n,o[l]instanceof Un&&o[l].format===ps&&o[l].type===Uo){const d=o[l];ry(d)&&ry(y.gl)?d.colorSpace=y.gl.outputColorSpace:d.encoding=y.gl.outputEncoding}Of(g)}if(E.parent&&g.raycast&&p!==E.eventCount){const a=hm(g).getState().internal,l=a.interaction.indexOf(g);l>-1&&a.interaction.splice(l,1),E.eventCount&&a.interaction.push(g)}return!(r.length===1&&r[0][0]==="onUpdate")&&r.length&&(T=g.__r3f)!=null&&T.parent&&Mx(g),g}function Of(g){var t,i;const x=(t=g.__r3f)==null||(i=t.root)==null||i.getState==null?void 0:i.getState();x&&x.internal.frames===0&&x.invalidate()}function Mx(g){g.onUpdate==null||g.onUpdate(g)}function _7(g,t){g.manual||(PA(g)?(g.left=t.width/-2,g.right=t.width/2,g.top=t.height/2,g.bottom=t.height/-2):g.aspect=t.width/t.height,g.updateProjectionMatrix(),g.updateMatrixWorld())}function Kv(g){return(g.eventObject||g.object).uuid+"/"+g.index+g.instanceId}function q7(){var g;const t=typeof self<"u"&&self||typeof window<"u"&&window;if(!t)return Hf.DefaultEventPriority;switch((g=t.event)==null?void 0:g.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Hf.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Hf.ContinuousEventPriority;default:return Hf.DefaultEventPriority}}function DA(g,t,i,x){const T=i.get(t);T&&(i.delete(t),i.size===0&&(g.delete(x),T.target.releasePointerCapture(x)))}function tz(g,t){const{internal:i}=g.getState();i.interaction=i.interaction.filter(x=>x!==t),i.initialHits=i.initialHits.filter(x=>x!==t),i.hovered.forEach((x,T)=>{(x.eventObject===t||x.object===t)&&i.hovered.delete(T)}),i.capturedMap.forEach((x,T)=>{DA(i.capturedMap,t,x,T)})}function ez(g){function t(e){const{internal:r}=g.getState(),p=e.offsetX-r.initialClick[0],h=e.offsetY-r.initialClick[1];return Math.round(Math.sqrt(p*p+h*h))}function i(e){return e.filter(r=>["Move","Over","Enter","Out","Leave"].some(p=>{var h;return(h=r.__r3f)==null?void 0:h.handlers["onPointer"+p]}))}function x(e,r){const p=g.getState(),h=new Set,a=[],l=r?r(p.internal.interaction):p.internal.interaction;for(let o=0;o{const d=td(o.object),v=td(c.object);return!d||!v?o.distance-c.distance:v.events.priority-d.events.priority||o.distance-c.distance}).filter(o=>{const c=Kv(o);return h.has(c)?!1:(h.add(c),!0)});p.events.filter&&(u=p.events.filter(u,p));for(const o of u){let c=o.object;for(;c;){var f;(f=c.__r3f)!=null&&f.eventCount&&a.push({...o,eventObject:c}),c=c.parent}}if("pointerId"in e&&p.internal.capturedMap.has(e.pointerId))for(let o of p.internal.capturedMap.get(e.pointerId).values())h.has(Kv(o.intersection))||a.push(o.intersection);return a}function T(e,r,p,h){const a=g.getState();if(e.length){const l={stopped:!1};for(const n of e){const u=td(n.object)||a,{raycaster:f,pointer:o,camera:c,internal:d}=u,v=new Ct(o.x,o.y,0).unproject(c),m=A=>{var P,b;return(P=(b=d.capturedMap.get(A))==null?void 0:b.has(n.eventObject))!=null?P:!1},S=A=>{const P={intersection:n,target:r.target};d.capturedMap.has(A)?d.capturedMap.get(A).set(n.eventObject,P):d.capturedMap.set(A,new Map([[n.eventObject,P]])),r.target.setPointerCapture(A)},M=A=>{const P=d.capturedMap.get(A);P&&DA(d.capturedMap,n.eventObject,P,A)};let w={};for(let A in r){let P=r[A];typeof P!="function"&&(w[A]=P)}let C={...n,...w,pointer:o,intersections:e,stopped:l.stopped,delta:p,unprojectedPoint:v,ray:f.ray,camera:c,stopPropagation(){const A="pointerId"in r&&d.capturedMap.get(r.pointerId);if((!A||A.has(n.eventObject))&&(C.stopped=l.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(P=>P.eventObject===n.eventObject))){const P=e.slice(0,e.indexOf(n));E([...P,n])}},target:{hasPointerCapture:m,setPointerCapture:S,releasePointerCapture:M},currentTarget:{hasPointerCapture:m,setPointerCapture:S,releasePointerCapture:M},nativeEvent:r};if(h(C),l.stopped===!0)break}}return e}function E(e){const{internal:r}=g.getState();for(const p of r.hovered.values())if(!e.length||!e.find(h=>h.object===p.object&&h.index===p.index&&h.instanceId===p.instanceId)){const a=p.eventObject.__r3f,l=a?.handlers;if(r.hovered.delete(Kv(p)),a!=null&&a.eventCount){const n={...p,intersections:e};l.onPointerOut==null||l.onPointerOut(n),l.onPointerLeave==null||l.onPointerLeave(n)}}}function s(e,r){for(let p=0;pE([]);case"onLostPointerCapture":return r=>{const{internal:p}=g.getState();"pointerId"in r&&p.capturedMap.has(r.pointerId)&&requestAnimationFrame(()=>{p.capturedMap.has(r.pointerId)&&(p.capturedMap.delete(r.pointerId),E([]))})}}return function(p){const{onPointerMissed:h,internal:a}=g.getState();a.lastEvent.current=p;const l=e==="onPointerMove",n=e==="onClick"||e==="onContextMenu"||e==="onDoubleClick",f=x(p,l?i:void 0),o=n?t(p):0;e==="onPointerDown"&&(a.initialClick=[p.offsetX,p.offsetY],a.initialHits=f.map(d=>d.eventObject)),n&&!f.length&&o<=2&&(s(p,a.interaction),h&&h(p)),l&&E(f);function c(d){const v=d.eventObject,m=v.__r3f,S=m?.handlers;if(m!=null&&m.eventCount)if(l){if(S.onPointerOver||S.onPointerEnter||S.onPointerOut||S.onPointerLeave){const M=Kv(d),w=a.hovered.get(M);w?w.stopped&&d.stopPropagation():(a.hovered.set(M,d),S.onPointerOver==null||S.onPointerOver(d),S.onPointerEnter==null||S.onPointerEnter(d))}S.onPointerMove==null||S.onPointerMove(d)}else{const M=S[e];M?(!n||a.initialHits.includes(v))&&(s(p,a.interaction.filter(w=>!a.initialHits.includes(w))),M(d)):n&&a.initialHits.includes(v)&&s(p,a.interaction.filter(w=>!a.initialHits.includes(w)))}}T(f,p,o,c)}}return{handlePointer:y}}const IA=g=>!!(g!=null&&g.render),NA=Pe.createContext(null),iz=(g,t)=>{const i=G7((y,e)=>{const r=new Ct,p=new Ct,h=new Ct;function a(o=e().camera,c=p,d=e().size){const{width:v,height:m,top:S,left:M}=d,w=v/m;c instanceof Ct?h.copy(c):h.set(...c);const C=o.getWorldPosition(r).distanceTo(h);if(PA(o))return{width:v/o.zoom,height:m/o.zoom,top:S,left:M,factor:1,distance:C,aspect:w};{const A=o.fov*Math.PI/180,P=2*Math.tan(A/2)*C,b=P*(v/m);return{width:b,height:P,top:S,left:M,factor:v/b,distance:C,aspect:w}}}let l;const n=o=>y(c=>({performance:{...c.performance,current:o}})),u=new ve;return{set:y,get:e,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(o=1)=>g(e(),o),advance:(o,c)=>t(o,c,e()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new G1,pointer:u,mouse:u,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const o=e();l&&clearTimeout(l),o.performance.current!==o.performance.min&&n(o.performance.min),l=setTimeout(()=>n(e().performance.max),o.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:a},setEvents:o=>y(c=>({...c,events:{...c.events,...o}})),setSize:(o,c,d,v,m)=>{const S=e().camera,M={width:o,height:c,top:v||0,left:m||0,updateStyle:d};y(w=>({size:M,viewport:{...w.viewport,...a(S,p,M)}}))},setDpr:o=>y(c=>{const d=FA(o);return{viewport:{...c.viewport,dpr:d,initialDpr:c.viewport.initialDpr||d}}}),setFrameloop:(o="always")=>{const c=e().clock;c.stop(),c.elapsedTime=0,o!=="never"&&(c.start(),c.elapsedTime=0),y(()=>({frameloop:o}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:Pe.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(o,c,d)=>{const v=e().internal;return v.priority=v.priority+(c>0?1:0),v.subscribers.push({ref:o,priority:c,store:d}),v.subscribers=v.subscribers.sort((m,S)=>m.priority-S.priority),()=>{const m=e().internal;m!=null&&m.subscribers&&(m.priority=m.priority-(c>0?1:0),m.subscribers=m.subscribers.filter(S=>S.ref!==o))}}}}}),x=i.getState();let T=x.size,E=x.viewport.dpr,s=x.camera;return i.subscribe(()=>{const{camera:y,size:e,viewport:r,gl:p,set:h}=i.getState();if(e.width!==T.width||e.height!==T.height||r.dpr!==E){var a;T=e,E=r.dpr,_7(y,e),p.setPixelRatio(r.dpr);const l=(a=e.updateStyle)!=null?a:typeof HTMLCanvasElement<"u"&&p.domElement instanceof HTMLCanvasElement;p.setSize(e.width,e.height,l)}y!==s&&(s=y,h(l=>({viewport:{...l.viewport,...l.viewport.getCurrentViewport(y)}})))}),i.subscribe(y=>g(y)),i};let jv,nz=new Set,rz=new Set,sz=new Set;function oy(g,t){if(g.size)for(const{callback:i}of g.values())i(t)}function ed(g,t){switch(g){case"before":return oy(nz,t);case"after":return oy(rz,t);case"tail":return oy(sz,t)}}let ly,hy;function uy(g,t,i){let x=t.clock.getDelta();for(t.frameloop==="never"&&typeof g=="number"&&(x=g-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=g),ly=t.internal.subscribers,jv=0;jv0)&&!((p=E.gl.xr)!=null&&p.isPresenting)&&(x+=uy(r,E))}if(i=!1,ed("after",r),x===0)return ed("tail",r),t=!1,cancelAnimationFrame(T)}function y(r,p=1){var h;if(!r)return g.forEach(a=>y(a.store.getState(),p));(h=r.gl.xr)!=null&&h.isPresenting||!r.internal.active||r.frameloop==="never"||(p>1?r.internal.frames=Math.min(60,r.internal.frames+p):i?r.internal.frames=2:r.internal.frames=1,t||(t=!0,requestAnimationFrame(s)))}function e(r,p=!0,h,a){if(p&&ed("before",r),h)uy(r,h,a);else for(const l of g.values())uy(r,l.store.getState());p&&ed("after",r)}return{loop:s,invalidate:y,advance:e}}function oz(){const g=Pe.useContext(NA);if(!g)throw new Error("R3F: Hooks can only be used within the Canvas component!");return g}function lz(g,t=0){const i=oz(),x=i.getState().internal.subscribe,T=RA(g);return rp(()=>x(T,t,i),[t,x,i]),null}const _f=new Map,{invalidate:fM,advance:cM}=az(_f),{reconciler:Cm,applyProps:bf}=K7(_f,q7),Lf={objects:"shallow",strict:!1},hz=(g,t)=>{const i=typeof g=="function"?g(t):g;return IA(i)?i:new M1({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...g})};function uz(g,t){const i=typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement;if(t){const{width:x,height:T,top:E,left:s,updateStyle:y=i}=t;return{width:x,height:T,top:E,left:s,updateStyle:y}}else if(typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement&&g.parentElement){const{width:x,height:T,top:E,left:s}=g.parentElement.getBoundingClientRect();return{width:x,height:T,top:E,left:s,updateStyle:i}}else if(typeof OffscreenCanvas<"u"&&g instanceof OffscreenCanvas)return{width:g.width,height:g.height,top:0,left:0,updateStyle:i};return{width:0,height:0,top:0,left:0}}function fz(g){const t=_f.get(g),i=t?.fiber,x=t?.store;t&&console.warn("R3F.createRoot should only be called once!");const T=typeof reportError=="function"?reportError:console.error,E=x||iz(fM,cM),s=i||Cm.createContainer(E,Hf.ConcurrentRoot,null,!1,null,"",T,null);t||_f.set(g,{fiber:s,store:E});let y,e=!1,r;return{configure(p={}){let{gl:h,size:a,scene:l,events:n,onCreated:u,shadows:f=!1,linear:o=!1,flat:c=!1,legacy:d=!1,orthographic:v=!1,frameloop:m="always",dpr:S=[1,2],performance:M,raycaster:w,camera:C,onPointerMissed:A}=p,P=E.getState(),b=P.gl;P.gl||P.set({gl:b=hz(h,g)});let O=P.raycaster;O||P.set({raycaster:O=new SA});const{params:I,...D}=w||{};if(wn.equ(D,O,Lf)||bf(O,{...D}),wn.equ(I,O.params,Lf)||bf(O,{params:{...O.params,...I}}),!P.camera||P.camera===r&&!wn.equ(r,C,Lf)){r=C;const K=C instanceof $d,Q=K?C:v?new qd(0,0,0,0,.1,1e3):new Or(75,0,.1,1e3);K||(Q.position.z=5,C&&bf(Q,C),!P.camera&&!(C!=null&&C.rotation)&&Q.lookAt(0,0,0)),P.set({camera:Q}),O.camera=Q}if(!P.scene){let K;l instanceof Em?K=l:(K=new Em,l&&bf(K,l)),P.set({scene:Ff(K)})}if(!P.xr){var B;const K=(Y,Z)=>{const U=E.getState();U.frameloop!=="never"&&cM(Y,!0,U,Z)},Q=()=>{const Y=E.getState();Y.gl.xr.enabled=Y.gl.xr.isPresenting,Y.gl.xr.setAnimationLoop(Y.gl.xr.isPresenting?K:null),Y.gl.xr.isPresenting||fM(Y)},tt={connect(){const Y=E.getState().gl;Y.xr.addEventListener("sessionstart",Q),Y.xr.addEventListener("sessionend",Q)},disconnect(){const Y=E.getState().gl;Y.xr.removeEventListener("sessionstart",Q),Y.xr.removeEventListener("sessionend",Q)}};typeof((B=b.xr)==null?void 0:B.addEventListener)=="function"&&tt.connect(),P.set({xr:tt})}if(b.shadowMap){const K=b.shadowMap.enabled,Q=b.shadowMap.type;if(b.shadowMap.enabled=!!f,wn.boo(f))b.shadowMap.type=hd;else if(wn.str(f)){var G;const tt={basic:f2,percentage:ng,soft:hd,variance:_a};b.shadowMap.type=(G=tt[f])!=null?G:hd}else wn.obj(f)&&Object.assign(b.shadowMap,f);(K!==b.shadowMap.enabled||Q!==b.shadowMap.type)&&(b.shadowMap.needsUpdate=!0)}const z=AA();z&&("enabled"in z?z.enabled=!d:"legacyMode"in z&&(z.legacyMode=d)),e||bf(b,{outputEncoding:o?3e3:3001,toneMapping:c?Bo:n1}),P.legacy!==d&&P.set(()=>({legacy:d})),P.linear!==o&&P.set(()=>({linear:o})),P.flat!==c&&P.set(()=>({flat:c})),h&&!wn.fun(h)&&!IA(h)&&!wn.equ(h,b,Lf)&&bf(b,h),n&&!P.events.handlers&&P.set({events:n(E)});const X=uz(g,a);return wn.equ(X,P.size,Lf)||P.setSize(X.width,X.height,X.updateStyle,X.top,X.left),S&&P.viewport.dpr!==FA(S)&&P.setDpr(S),P.frameloop!==m&&P.setFrameloop(m),P.onPointerMissed||P.set({onPointerMissed:A}),M&&!wn.equ(M,P.performance,Lf)&&P.set(K=>({performance:{...K.performance,...M}})),y=u,e=!0,this},render(p){return e||this.configure(),Cm.updateContainer(Pe.createElement(cz,{store:E,children:p,onCreated:y,rootElement:g}),s,null,()=>{}),E},unmount(){BA(g)}}}function cz({store:g,children:t,onCreated:i,rootElement:x}){return rp(()=>{const T=g.getState();T.set(E=>({internal:{...E.internal,active:!0}})),i&&i(T),g.getState().events.connected||T.events.connect==null||T.events.connect(x)},[]),Pe.createElement(NA.Provider,{value:g},t)}function BA(g,t){const i=_f.get(g),x=i?.fiber;if(x){const T=i?.store.getState();T&&(T.internal.active=!1),Cm.updateContainer(null,x,null,()=>{T&&setTimeout(()=>{try{var E,s,y,e;T.events.disconnect==null||T.events.disconnect(),(E=T.gl)==null||(s=E.renderLists)==null||s.dispose==null||s.dispose(),(y=T.gl)==null||y.forceContextLoss==null||y.forceContextLoss(),(e=T.gl)!=null&&e.xr&&T.xr.disconnect(),$7(T),_f.delete(g),t&&t(g)}catch{}},500)})}}Cm.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:Pe.version});function wm(){return wm=Object.assign?Object.assign.bind():function(g){for(var t=1;t=0?x=setTimeout(e,t-p):(x=null,i||(y=g.apply(E,T),E=T=null))}var r=function(){E=this,T=arguments,s=Date.now();var p=i&&!x;return x||(x=setTimeout(e,t)),p&&(y=g.apply(E,T),E=T=null),y};return r.clear=function(){x&&(clearTimeout(x),x=null)},r.flush=function(){x&&(y=g.apply(E,T),E=T=null,clearTimeout(x),x=null)},r}Cx.debounce=Cx;var dz=Cx;const dM=Wd(dz);function pz(g){let{debounce:t,scroll:i,polyfill:x,offsetSize:T}=g===void 0?{debounce:0,scroll:!1,offsetSize:!1}:g;const E=x||(typeof window>"u"?class{}:window.ResizeObserver);if(!E)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,y]=Pe.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),e=Pe.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s}),r=t?typeof t=="number"?t:t.scroll:null,p=t?typeof t=="number"?t:t.resize:null,h=Pe.useRef(!1);Pe.useEffect(()=>(h.current=!0,()=>void(h.current=!1)));const[a,l,n]=Pe.useMemo(()=>{const c=()=>{if(!e.current.element)return;const{left:d,top:v,width:m,height:S,bottom:M,right:w,x:C,y:A}=e.current.element.getBoundingClientRect(),P={left:d,top:v,width:m,height:S,bottom:M,right:w,x:C,y:A};e.current.element instanceof HTMLElement&&T&&(P.height=e.current.element.offsetHeight,P.width=e.current.element.offsetWidth),Object.freeze(P),h.current&&!yz(e.current.lastBounds,P)&&y(e.current.lastBounds=P)};return[c,p?dM(c,p):c,r?dM(c,r):c]},[y,T,r,p]);function u(){e.current.scrollContainers&&(e.current.scrollContainers.forEach(c=>c.removeEventListener("scroll",n,!0)),e.current.scrollContainers=null),e.current.resizeObserver&&(e.current.resizeObserver.disconnect(),e.current.resizeObserver=null)}function f(){e.current.element&&(e.current.resizeObserver=new E(n),e.current.resizeObserver.observe(e.current.element),i&&e.current.scrollContainers&&e.current.scrollContainers.forEach(c=>c.addEventListener("scroll",n,{capture:!0,passive:!0})))}const o=c=>{!c||c===e.current.element||(u(),e.current.element=c,e.current.scrollContainers=UA(c),f())};return mz(n,!!i),vz(l),Pe.useEffect(()=>{u(),f()},[i,n,l]),Pe.useEffect(()=>u,[]),[o,s,a]}function vz(g){Pe.useEffect(()=>{const t=g;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[g])}function mz(g,t){Pe.useEffect(()=>{if(t){const i=g;return window.addEventListener("scroll",i,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",i,!0)}},[g,t])}function UA(g){const t=[];if(!g||g===document.body)return t;const{overflow:i,overflowX:x,overflowY:T}=window.getComputedStyle(g);return[i,x,T].some(E=>E==="auto"||E==="scroll")&&t.push(g),[...t,...UA(g.parentElement)]}const gz=["x","y","top","bottom","left","right","width","height"],yz=(g,t)=>gz.every(i=>g[i]===t[i]);var xz=Object.defineProperty,Sz=Object.defineProperties,Tz=Object.getOwnPropertyDescriptors,pM=Object.getOwnPropertySymbols,Ez=Object.prototype.hasOwnProperty,Mz=Object.prototype.propertyIsEnumerable,vM=(g,t,i)=>t in g?xz(g,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):g[t]=i,mM=(g,t)=>{for(var i in t||(t={}))Ez.call(t,i)&&vM(g,i,t[i]);if(pM)for(var i of pM(t))Mz.call(t,i)&&vM(g,i,t[i]);return g},Cz=(g,t)=>Sz(g,Tz(t)),gM,yM;typeof window<"u"&&((gM=window.document)!=null&&gM.createElement||((yM=window.navigator)==null?void 0:yM.product)==="ReactNative")?Pe.useLayoutEffect:Pe.useEffect;function zA(g,t,i){if(!g)return;if(i(g)===!0)return g;let x=t?g.return:g.child;for(;x;){const T=zA(x,t,i);if(T)return T;x=t?null:x.sibling}}function GA(g){try{return Object.defineProperties(g,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return g}}const xM=console.error;console.error=function(){const g=[...arguments].join("");if(g?.startsWith("Warning:")&&g.includes("useContext")){console.error=xM;return}return xM.apply(this,arguments)};const Y1=GA(Pe.createContext(null));class VA extends Pe.Component{render(){return Pe.createElement(Y1.Provider,{value:this._reactInternals},this.props.children)}}function wz(){const g=Pe.useContext(Y1);if(g===null)throw new Error("its-fine: useFiber must be called within a !");const t=Pe.useId();return Pe.useMemo(()=>{for(const x of[g,g?.alternate]){if(!x)continue;const T=zA(x,!1,E=>{let s=E.memoizedState;for(;s;){if(s.memoizedState===t)return!0;s=s.next}});if(T)return T}},[g,t])}function Az(){const g=wz(),[t]=Pe.useState(()=>new Map);t.clear();let i=g;for(;i;){if(i.type&&typeof i.type=="object"){const T=i.type._context===void 0&&i.type.Provider===i.type?i.type:i.type._context;T&&T!==Y1&&!t.has(T)&&t.set(T,Pe.useContext(GA(T)))}i=i.return}return t}function Pz(){const g=Az();return Pe.useMemo(()=>Array.from(g.keys()).reduce((t,i)=>x=>Pe.createElement(t,null,Pe.createElement(i.Provider,Cz(mM({},x),{value:g.get(i)}))),t=>Pe.createElement(VA,mM({},t))),[g])}const fy={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function Rz(g){const{handlePointer:t}=ez(g);return{priority:1,enabled:!0,compute(i,x,T){x.pointer.set(i.offsetX/x.size.width*2-1,-(i.offsetY/x.size.height)*2+1),x.raycaster.setFromCamera(x.pointer,x.camera)},connected:void 0,handlers:Object.keys(fy).reduce((i,x)=>({...i,[x]:t(x)}),{}),update:()=>{var i;const{events:x,internal:T}=g.getState();(i=T.lastEvent)!=null&&i.current&&x.handlers&&x.handlers.onPointerMove(T.lastEvent.current)},connect:i=>{var x;const{set:T,events:E}=g.getState();E.disconnect==null||E.disconnect(),T(s=>({events:{...s.events,connected:i}})),Object.entries((x=E.handlers)!=null?x:[]).forEach(([s,y])=>{const[e,r]=fy[s];i.addEventListener(e,y,{passive:r})})},disconnect:()=>{const{set:i,events:x}=g.getState();if(x.connected){var T;Object.entries((T=x.handlers)!=null?T:[]).forEach(([E,s])=>{if(x&&x.connected instanceof HTMLElement){const[y]=fy[E];x.connected.removeEventListener(y,s)}}),i(E=>({events:{...E.events,connected:void 0}}))}}}}const bz=Pe.forwardRef(function({children:t,fallback:i,resize:x,style:T,gl:E,events:s=Rz,eventSource:y,eventPrefix:e,shadows:r,linear:p,flat:h,legacy:a,orthographic:l,frameloop:n,dpr:u,performance:f,raycaster:o,camera:c,scene:d,onPointerMissed:v,onCreated:m,...S},M){Pe.useMemo(()=>k7(B7),[]);const w=Pz(),[C,A]=pz({scroll:!0,debounce:{scroll:50,resize:0},...x}),P=Pe.useRef(null),b=Pe.useRef(null);Pe.useImperativeHandle(M,()=>P.current);const O=RA(v),[I,D]=Pe.useState(!1),[B,G]=Pe.useState(!1);if(I)throw I;if(B)throw B;const z=Pe.useRef(null);rp(()=>{const K=P.current;A.width>0&&A.height>0&&K&&(z.current||(z.current=fz(K)),z.current.configure({gl:E,events:s,shadows:r,linear:p,flat:h,legacy:a,orthographic:l,frameloop:n,dpr:u,performance:f,raycaster:o,camera:c,scene:d,size:A,onPointerMissed:(...Q)=>O.current==null?void 0:O.current(...Q),onCreated:Q=>{Q.events.connect==null||Q.events.connect(y?j7(y)?y.current:y:b.current),e&&Q.setEvents({compute:(tt,Y)=>{const Z=tt[e+"X"],U=tt[e+"Y"];Y.pointer.set(Z/Y.size.width*2-1,-(U/Y.size.height)*2+1),Y.raycaster.setFromCamera(Y.pointer,Y.camera)}}),m?.(Q)}}),z.current.render(Pe.createElement(w,null,Pe.createElement(bA,{set:G},Pe.createElement(Pe.Suspense,{fallback:Pe.createElement(Z7,{set:D})},t)))))}),Pe.useEffect(()=>{const K=P.current;if(K)return()=>BA(K)},[]);const X=y?"none":"auto";return Pe.createElement("div",wm({ref:b,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:X,...T}},S),Pe.createElement("div",{ref:C,style:{width:"100%",height:"100%"}},Pe.createElement("canvas",{ref:P,style:{display:"block"}},i)))}),Lz=Pe.forwardRef(function(t,i){return Pe.createElement(VA,null,Pe.createElement(bz,wm({},t,{ref:i})))});function Tl(g,t={}){let i=Pe.useCallback(T=>t.keys?k4(g,t.keys,T):g.listen(T),[t.keys,g]),x=g.get.bind(g);return Pe.useSyncExternalStore(i,x,x)}const Fz=[new qa(-Math.PI/2,-Math.PI/2,-Math.PI/2),new qa(0,Math.PI/2,0),new qa(0,-Math.PI/2,-Math.PI/2),new qa(Math.PI/2,Math.PI,Math.PI),new qa(0,0,-Math.PI/2),new qa(Math.PI,0,0)],Oz=({diceValues:g,isRolling:t,textures:i})=>{const x=Pe.useRef([]),T=Pe.useRef([]);return Pe.useEffect(()=>{const E=new aA,s=new ze(16776960);T.current=[new vl({map:E.load(i.side1),color:s}),new vl({map:E.load(i.side2),color:s}),new vl({map:E.load(i.side3),color:s}),new vl({map:E.load(i.side4),color:s}),new vl({map:E.load(i.side5),color:s}),new vl({map:E.load(i.side6),color:s})],x.current.forEach(y=>{y&&(y.material=T.current)})},[i]),lz(()=>{x.current.forEach((E,s)=>{if(E)if(t)E.rotation.x+=.2,E.rotation.y+=.2;else{const y=Fz[g[s]-1];E.rotation.x=om.lerp(E.rotation.x,y.x,.1),E.rotation.y=om.lerp(E.rotation.y,y.y,.1),E.rotation.z=om.lerp(E.rotation.z,y.z,.1)}})}),he.jsx(he.Fragment,{children:g.map((E,s)=>he.jsxs("mesh",{ref:y=>x.current[s]=y,position:[s*2-(g.length-1),0,0],children:[he.jsx("boxGeometry",{args:[1,1,1]}),T.current.length===6&&T.current.map((y,e)=>he.jsx("meshStandardMaterial",{attach:`material-${e}`,map:y.map},e))]},s))})},Dz=({styleClass:g,textures:t,diceCount:i})=>{const x=Tl(xd);Pe.useEffect(()=>{UI("Dice"),GI(t),zI({type:"ROLL_DICE",diceValues:Array(i).fill(1),isRolling:!1})},[t,i]);const T=()=>{CT(!0),setTimeout(()=>{const E=Array.from({length:i},()=>Math.floor(Math.random()*6)+1);console.log("New dice values:",E),l2(E),CT(!1);const s={diceValues:E};Pi.emit("diceRollResult",s)},2e3)};return he.jsxs("div",{className:`flex flex-col items-center justify-center p-4 ${g}`,children:[he.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Dice Roller"}),he.jsxs(Lz,{className:"w-full h-full",camera:{position:[0,0,5]},children:[he.jsx("ambientLight",{intensity:2.5}),he.jsx("pointLight",{position:[10,10,10]}),fT(x.action)&&he.jsx(Oz,{diceValues:x.action.diceValues,isRolling:x.action.isRolling,textures:x.textures})]}),fT(x.action)&&he.jsx("button",{onClick:T,className:`mt-4 p-2 border border-yellow-300 rounded text-yellow-400 ${x.action.isRolling?"opacity-50":""}`,disabled:x.action.isRolling,children:"Roll Dice"})]})};class HA{constructor(t,i,x){this.scene=t,this.gridEngine=i,this.quadtree=x,this.cursor=this.scene.input.keyboard?.createCursorKeys(),this.initializeWASDKeys(),this.registerEventHandlers(),this.tooltip=this.scene.add.text(0,0,"Press [F]",{font:"16px Arial",backgroundColor:"#000000"}).setDepth(4).setPadding(3,2,2,3).setVisible(!1)}initializeWASDKeys(){const t=this.scene.input.keyboard;t&&(this.wasdKeys={W:t.addKey(Phaser.Input.Keyboard.KeyCodes.W),A:t.addKey(Phaser.Input.Keyboard.KeyCodes.A),S:t.addKey(Phaser.Input.Keyboard.KeyCodes.S),D:t.addKey(Phaser.Input.Keyboard.KeyCodes.D)})}handleConsume(t){const i=yl(t);i&&i.consumable?(console.log(`Consuming item: ${i.name}`),NI(i),MT(i.id)):console.log(`Item ${t} is not consumable`)}handleEquip(t){const i=yl(t);i&&(console.log(`Equipping item: ${i.name}`),AI("weapon",i.id))}handleUnequip(t){const i=yl(t);i&&(console.log(`Unequipping item: ${i.name}`),PI("weapon"))}handleDiscard(t){console.log(`Discarding item: ${t}`),MT(t)}handleView(t){const i=yl(t);if(i&&(console.log(`Viewing item: ${i.name} with ${i.slug}`),i.slug)){const x=`https://kbve.com/${i.slug}#${i.name.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]+/g,"")}`;window.open(x,"_blank")}}registerEventHandlers(){Pi.on("itemAction",this.handleItemAction.bind(this));//! Broken -Pi.on("playerMove",this.handlePlayerMove.bind(this)),Pi.on("playerReward",this.handlePlayerReward.bind(this)),Pi.on("playerDamage",this.handlePlayerCombatDamage.bind(this))}handleItemAction(t){if(t)switch(console.log(`Preparing Action: ${t.itemId} with ${t.action}`),t.action){case"consume":this.handleConsume(t.itemId);break;case"equip":this.handleEquip(t.itemId);break;case"unequip":this.handleUnequip(t.itemId);break;case"discard":this.handleDiscard(t.itemId);break;case"view":this.handleView(t.itemId);break;default:console.log(`Unknown action: ${t.action}`)}}handlePlayerReward(t){console.log("Rewarding the player"),t&&(Pi.emit("notification",{title:"Success",message:t.message,notificationType:Au.success}),wI(t.item))}handlePlayerCombatDamage(t){t&&(o2(parseInt(t.damage)),Pi.emit("notification",{title:"Danger",message:`You taken ${t.damage} points of damage!`,notificationType:Au.danger}))}handlePlayerMove(t){t&&this.gridEngine.moveTo("player",{x:t.x,y:t.y})}checkForNearbyObjects(){const i=this.gridEngine.getPosition("player"),x=i.x*48,T=i.y*48;this.quadtree.query(i).length>0?this.tooltip.setPosition(x,T-60).setVisible(!0):this.tooltip.setVisible(!1)}handleMovement(){if(!this.cursor)return;const t=this.cursor,i=this.wasdKeys;if(this.scene.input.keyboard?.addKey("F").isDown){const x=this.gridEngine.getPosition("player"),T=this.quadtree.query(x);for(const E of T)E.action()}(t.left.isDown||i.A.isDown)&&(t.up.isDown||i.W.isDown)?this.gridEngine.move("player","up-left"):(t.left.isDown||i.A.isDown)&&(t.down.isDown||i.S.isDown)?this.gridEngine.move("player","down-left"):(t.right.isDown||i.D.isDown)&&(t.up.isDown||i.W.isDown)?this.gridEngine.move("player","up-right"):(t.right.isDown||i.D.isDown)&&(t.down.isDown||i.S.isDown)?this.gridEngine.move("player","down-right"):t.left.isDown||i.A.isDown?this.gridEngine.move("player","left"):t.right.isDown||i.D.isDown?this.gridEngine.move("player","right"):t.up.isDown||i.W.isDown?this.gridEngine.move("player","up"):(t.down.isDown||i.S.isDown)&&this.gridEngine.move("player","down"),this.checkForNearbyObjects()}}class WA extends Phaser.GameObjects.Container{constructor(t,i,x,T){const E=i.x,s=i.y-i.height+10;super(t,E,s),this.sprite=i;const y=150,e=40+T.length*20;this.background=t.add.rectangle(0,0,y,e,0,.7),this.text=t.add.text(0,-e/2+10,x,{fontSize:"12px",color:"#ffffff"}).setOrigin(.5),this.buttons=T.map((r,p)=>{const h=t.add.text(0,-e/2+30+p*20,r.label,{fontSize:"12px",color:"#00ff00"}).setOrigin(.5);return h.setInteractive({useHandCursor:!0}),h.on("pointerdown",r.callback),h}),this.add(this.background),this.add(this.text),this.buttons.forEach(r=>this.add(r)),this.scene.add.existing(this)}updatePosition(){this.setPosition(this.sprite.x-30,this.sprite.y-this.sprite.height-this.background.height/2+100)}static attachToSprite(t,i,x,T){i.setInteractive(),i.on("pointerover",E=>{const s={npcId:i.name,npcName:x,actions:T.map(e=>e.label),coords:{x:E.x,y:E.y}};if(Pi.emit("npcInteraction",s),!i.getData("tooltipMenu")){const e=new WA(t,i,x,T);i.setData("tooltipMenu",e)}const y=i.getData("tooltipMenu");y.setVisible(!0),y.updatePosition()}),i.on("pointerout",()=>{const E=i.getData("tooltipMenu");E&&E.setVisible(!1)})}static updateAllTooltipPositions(t){t.children.list.forEach(i=>{if(i instanceof Phaser.GameObjects.Sprite){const x=i.getData("tooltipMenu");x&&x.updatePosition()}})}}let cG=class extends Phaser.GameObjects.Sprite{};function Iz(g,t,i,x){const y=g.add.graphics();y.fillStyle(16777215,1),y.fillRoundedRect(0,0,200,60,16),y.setDepth(99);const e=g.add.text(100,30,i,{fontFamily:"Arial",fontSize:16,color:"#000000"});e.setOrigin(.5),e.setWordWrapWidth(200-10*2),e.setDepth(100);const r=g.add.container(0,0,[y,e]);return r.setDepth(100),t.messageBubble=r,Bz(t),g.time.addEvent({delay:x,callback:()=>{r.destroy(),t.messageBubble===r&&(t.messageBubble=void 0)},callbackScope:g}),r}function Nz(g,t,i){const s=g.add.graphics();s.fillStyle(16777215,1),s.fillRoundedRect(0,0,200,60,16),s.setDepth(99);const y=g.add.text(100,30,i,{fontFamily:"Arial",fontSize:16,color:"#000000"});y.setOrigin(.5),y.setWordWrapWidth(200-10*2),y.setDepth(100);const e=g.add.container(0,0,[s,y]);return e.setDepth(100),t.textBubble=e,wx(t),e}function wx(g){const t=g.textBubble;t&&(t.x=g.x,t.y=g.y-g.height-t.height/2)}function Bz(g){const t=g.messageBubble;t&&(t.x=g.x,t.y=g.y-g.height-t.height/2)}class Uz{constructor(){this.actionHandlers={talk:this.talkToNPC.bind(this),quest:this.questWithNPC.bind(this),trade:this.tradeWithNPC.bind(this),combat:this.startCombat.bind(this),heal:this.healNPC.bind(this),steal:this.stealFromNPC.bind(this)}}getActionHandler(t){return this.actionHandlers[t]}questWithNPC(t){console.log(`Starting quest with NPC with ID: ${t.npcId}`)}healNPC(t){console.log(`Healing NPC with ID: ${t.npcId}`)}talkToNPC(t){console.log(`Talking to NPC with ID: ${t.npcId}`)}tradeWithNPC(t){console.log(`Trading with NPC with ID: ${t.npcId}`)}moveToNPC(t){const x=t.data?.coords||{x:10,y:15};Pi.emit("playerMove",x)}stealFromNPC(t){console.log(`Attempting to steal from NPC with ID: ${t.npcId}`);const i={npcId:t.npcId,npcName:t.npcName,data:t.data};Pi.emit("playerSteal",i)}startCombat(t){console.log(`Starting combat with NPC with ID: ${t.npcId}`)}checkFish(t){console.log(`Checking fish for NPC with ID: ${t.npcId}`)}attachNPCEvent(t,i,x,T){t.setInteractive(),t.on("pointerover",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};Pi.emit("npcInteraction",s)}),t.on("pointerout",()=>{}),t.on("pointerdown",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};console.log(`Click Registered at X: ${s.coords.x} Y: ${s.coords.y}`),Pi.emit("npcInteractionClick",s,1e3)})}}const k1=new Uz;var XA={exports:{}};(function(g,t){(function(i,x){g.exports=x()})(py,function(){var i=function(V,j){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(et,st){et.__proto__=st}||function(et,st){for(var ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(et[ht]=st[ht])})(V,j)},x=function(){return(x=Object.assign||function(V){for(var j,et=1,st=arguments.length;et"u"||E.Promise||(E.Promise=Promise);var r=Object.getPrototypeOf,p={}.hasOwnProperty;function h(V,j){return p.call(V,j)}function a(V,j){typeof j=="function"&&(j=j(r(V))),(typeof Reflect>"u"?s:Reflect.ownKeys)(j).forEach(function(et){n(V,et,j[et])})}var l=Object.defineProperty;function n(V,j,et,st){l(V,j,e(et&&h(et,"get")&&typeof et.get=="function"?{get:et.get,set:et.set,configurable:!0}:{value:et,configurable:!0,writable:!0},st))}function u(V){return{from:function(j){return V.prototype=Object.create(j.prototype),n(V.prototype,"constructor",V),{extend:a.bind(null,V.prototype)}}}}var f=Object.getOwnPropertyDescriptor,o=[].slice;function c(V,j,et){return o.call(V,j,et)}function d(V,j){return j(V)}function v(V){if(!V)throw new Error("Assertion Failed")}function m(V){E.setImmediate?setImmediate(V):setTimeout(V,0)}function S(V,j){if(typeof j=="string"&&h(V,j))return V[j];if(!j)return V;if(typeof j!="string"){for(var et=[],st=0,ht=j.length;st>>1,tt=z[Q];if(0>>1;QT(U,K))HT(J,U)?(z[Q]=J,z[H]=K,Q=H):(z[Q]=U,z[Z]=K,Q=Z);else if(HT(J,K))z[Q]=J,z[H]=K,Q=H;else break t}}return X}function T(z,X){var K=z.sortIndex-X.sortIndex;return K!==0?K:z.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var E=performance;g.unstable_now=function(){return E.now()}}else{var s=Date,y=s.now();g.unstable_now=function(){return s.now()-y}}var e=[],r=[],p=1,h=null,a=3,l=!1,n=!1,u=!1,f=typeof setTimeout=="function"?setTimeout:null,o=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(z){for(var X=i(r);X!==null;){if(X.callback===null)x(r);else if(X.startTime<=z)x(r),X.sortIndex=X.expirationTime,t(e,X);else break;X=i(r)}}function v(z){if(u=!1,d(z),!n)if(i(e)!==null)n=!0,B(m);else{var X=i(r);X!==null&&G(v,X.startTime-z)}}function m(z,X){n=!1,u&&(u=!1,o(w),w=-1),l=!0;var K=a;try{for(d(X),h=i(e);h!==null&&(!(h.expirationTime>X)||z&&!P());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,a=h.priorityLevel;var tt=Q(h.expirationTime<=X);X=g.unstable_now(),typeof tt=="function"?h.callback=tt:h===i(e)&&x(e),d(X)}else x(e);h=i(e)}if(h!==null)var Y=!0;else{var Z=i(r);Z!==null&&G(v,Z.startTime-X),Y=!1}return Y}finally{h=null,a=K,l=!1}}var S=!1,M=null,w=-1,C=5,A=-1;function P(){return!(g.unstable_now()-Az||125Q?(z.sortIndex=K,t(r,z),i(e)===null&&z===i(r)&&(u?(o(w),w=-1):u=!0,G(v,K-Q))):(z.sortIndex=tt,t(e,z),n||l||(n=!0,B(m))),z},g.unstable_shouldYield=P,g.unstable_wrapCallback=function(z){var X=a;return function(){var K=a;a=X;try{return z.apply(this,arguments)}finally{a=K}}}})(wA);CA.exports=wA;var sM=CA.exports;const X1={},k7=g=>void Object.assign(X1,g);function K7(g,t){function i(p,{args:h=[],attach:a,...l},n){let u=`${p[0].toUpperCase()}${p.slice(1)}`,f;if(p==="primitive"){if(l.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const o=l.object;f=Ff(o,{type:p,root:n,attach:a,primitive:!0})}else{const o=X1[u];if(!o)throw new Error(`R3F: ${u} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(h))throw new Error("R3F: The args prop must be an array!");f=Ff(new o(...h),{type:p,root:n,attach:a,memoizedProps:{args:h}})}return f.__r3f.attach===void 0&&(f instanceof Li?f.__r3f.attach="geometry":f instanceof Hr&&(f.__r3f.attach="material")),u!=="inject"&&oy(f,l),f}function x(p,h){let a=!1;if(h){var l,n;(l=h.__r3f)!=null&&l.attach?ay(p,h,h.__r3f.attach):h.isObject3D&&p.isObject3D&&(p.add(h),a=!0),a||(n=p.__r3f)==null||n.objects.push(h),h.__r3f||Ff(h,{}),h.__r3f.parent=p,Cx(h),Of(h)}}function T(p,h,a){let l=!1;if(h){var n,u;if((n=h.__r3f)!=null&&n.attach)ay(p,h,h.__r3f.attach);else if(h.isObject3D&&p.isObject3D){h.parent=p,h.dispatchEvent({type:"added"}),p.dispatchEvent({type:"childadded",child:h});const f=p.children.filter(c=>c!==h),o=f.indexOf(a);p.children=[...f.slice(0,o),h,...f.slice(o)],l=!0}l||(u=p.__r3f)==null||u.objects.push(h),h.__r3f||Ff(h,{}),h.__r3f.parent=p,Cx(h),Of(h)}}function E(p,h,a=!1){p&&[...p].forEach(l=>s(h,l,a))}function s(p,h,a){if(h){var l,n,u;if(h.__r3f&&(h.__r3f.parent=null),(l=p.__r3f)!=null&&l.objects&&(p.__r3f.objects=p.__r3f.objects.filter(v=>v!==h)),(n=h.__r3f)!=null&&n.attach)uM(p,h,h.__r3f.attach);else if(h.isObject3D&&p.isObject3D){var f;p.remove(h),(f=h.__r3f)!=null&&f.root&&tz(hm(h),h)}const c=(u=h.__r3f)==null?void 0:u.primitive,d=!c&&(a===void 0?h.dispose!==null:a);if(!c){var o;E((o=h.__r3f)==null?void 0:o.objects,h,d),E(h.children,h,d)}if(delete h.__r3f,d&&h.dispose&&h.type!=="Scene"){const v=()=>{try{h.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?sM.unstable_scheduleCallback(sM.unstable_IdlePriority,v):v()}Of(p)}}function y(p,h,a,l){var n;const u=(n=p.__r3f)==null?void 0:n.parent;if(!u)return;const f=i(h,a,p.__r3f.root);if(p.children){for(const o of p.children)o.__r3f&&x(f,o);p.children=p.children.filter(o=>!o.__r3f)}p.__r3f.objects.forEach(o=>x(f,o)),p.__r3f.objects=[],p.__r3f.autoRemovedBeforeAppend||s(u,p),f.parent&&(f.__r3f.autoRemovedBeforeAppend=!0),x(u,f),f.raycast&&f.__r3f.eventCount&&hm(f).getState().internal.interaction.push(f),[l,l.alternate].forEach(o=>{o!==null&&(o.stateNode=f,o.ref&&(typeof o.ref=="function"?o.ref(f):o.ref.current=f))})}const e=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:Y7({createInstance:i,removeChild:s,appendChild:x,appendInitialChild:x,insertBefore:T,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(p,h)=>{if(!h)return;const a=p.getState().scene;a.__r3f&&(a.__r3f.root=p,x(a,h))},removeChildFromContainer:(p,h)=>{h&&s(p.getState().scene,h)},insertInContainerBefore:(p,h,a)=>{if(!h||!a)return;const l=p.getState().scene;l.__r3f&&T(l,h,a)},getRootHostContext:()=>null,getChildHostContext:p=>p,finalizeInitialChildren(p){var h;return!!((h=p?.__r3f)!=null?h:{}).handlers},prepareUpdate(p,h,a,l){var n;if(((n=p?.__r3f)!=null?n:{}).primitive&&l.object&&l.object!==p)return[!0];{const{args:f=[],children:o,...c}=l,{args:d=[],children:v,...m}=a;if(!Array.isArray(f))throw new Error("R3F: the args prop must be an array!");if(f.some((M,w)=>M!==d[w]))return[!0];const S=OA(p,c,m,!0);return S.changes.length?[!1,S]:null}},commitUpdate(p,[h,a],l,n,u,f){h?y(p,l,u,f):oy(p,a)},commitMount(p,h,a,l){var n;const u=(n=p.__r3f)!=null?n:{};p.raycast&&u.handlers&&u.eventCount&&hm(p).getState().internal.interaction.push(p)},getPublicInstance:p=>p,prepareForCommit:()=>null,preparePortalMount:p=>Ff(p.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(p){var h;const{attach:a,parent:l}=(h=p.__r3f)!=null?h:{};a&&l&&uM(l,p,a),p.isObject3D&&(p.visible=!1),Of(p)},unhideInstance(p,h){var a;const{attach:l,parent:n}=(a=p.__r3f)!=null?a:{};l&&n&&ay(n,p,l),(p.isObject3D&&h.visible==null||h.visible)&&(p.visible=!0),Of(p)},createTextInstance:e,hideTextInstance:e,unhideTextInstance:e,getCurrentEventPriority:()=>t?t():Hf.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&wn.fun(performance.now)?performance.now:wn.fun(Date.now)?Date.now:()=>0,scheduleTimeout:wn.fun(setTimeout)?setTimeout:void 0,cancelTimeout:wn.fun(clearTimeout)?clearTimeout:void 0}),applyProps:oy}}var aM,oM;const sy=g=>"colorSpace"in g||"outputColorSpace"in g,AA=()=>{var g;return(g=X1.ColorManagement)!=null?g:null},PA=g=>g&&g.isOrthographicCamera,j7=g=>g&&g.hasOwnProperty("current"),rp=typeof window<"u"&&((aM=window.document)!=null&&aM.createElement||((oM=window.navigator)==null?void 0:oM.product)==="ReactNative")?Pe.useLayoutEffect:Pe.useEffect;function RA(g){const t=Pe.useRef(g);return rp(()=>void(t.current=g),[g]),t}function Z7({set:g}){return rp(()=>(g(new Promise(()=>null)),()=>g(!1)),[g]),null}class bA extends Pe.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}}bA.getDerivedStateFromError=()=>({error:!0});const LA="__default",lM=new Map,J7=g=>g&&!!g.memoized&&!!g.changes;function FA(g){var t;const i=typeof window<"u"?(t=window.devicePixelRatio)!=null?t:2:1;return Array.isArray(g)?Math.min(Math.max(g[0],i),g[1]):g}const td=g=>{var t;return(t=g.__r3f)==null?void 0:t.root.getState()};function hm(g){let t=g.__r3f.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}const wn={obj:g=>g===Object(g)&&!wn.arr(g)&&typeof g!="function",fun:g=>typeof g=="function",str:g=>typeof g=="string",num:g=>typeof g=="number",boo:g=>typeof g=="boolean",und:g=>g===void 0,arr:g=>Array.isArray(g),equ(g,t,{arrays:i="shallow",objects:x="reference",strict:T=!0}={}){if(typeof g!=typeof t||!!g!=!!t)return!1;if(wn.str(g)||wn.num(g))return g===t;const E=wn.obj(g);if(E&&x==="reference")return g===t;const s=wn.arr(g);if(s&&i==="reference")return g===t;if((s||E)&&g===t)return!0;let y;for(y in g)if(!(y in t))return!1;if(E&&i==="shallow"&&x==="shallow"){for(y in T?t:g)if(!wn.equ(g[y],t[y],{strict:T,objects:"reference"}))return!1}else for(y in T?t:g)if(g[y]!==t[y])return!1;if(wn.und(y)){if(s&&g.length===0&&t.length===0||E&&Object.keys(g).length===0&&Object.keys(t).length===0)return!0;if(g!==t)return!1}return!0}};function $7(g){g.dispose&&g.type!=="Scene"&&g.dispose();for(const t in g)t.dispose==null||t.dispose(),delete g[t]}function Ff(g,t){const i=g;return i.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...t},g}function Mx(g,t){let i=g;if(t.includes("-")){const x=t.split("-"),T=x.pop();return i=x.reduce((E,s)=>E[s],g),{target:i,key:T}}else return{target:i,key:t}}const hM=/-\d+$/;function ay(g,t,i){if(wn.str(i)){if(hM.test(i)){const E=i.replace(hM,""),{target:s,key:y}=Mx(g,E);Array.isArray(s[y])||(s[y]=[])}const{target:x,key:T}=Mx(g,i);t.__r3f.previousAttach=x[T],x[T]=t}else t.__r3f.previousAttach=i(g,t)}function uM(g,t,i){var x,T;if(wn.str(i)){const{target:E,key:s}=Mx(g,i),y=t.__r3f.previousAttach;y===void 0?delete E[s]:E[s]=y}else(x=t.__r3f)==null||x.previousAttach==null||x.previousAttach(g,t);(T=t.__r3f)==null||delete T.previousAttach}function OA(g,{children:t,key:i,ref:x,...T},{children:E,key:s,ref:y,...e}={},r=!1){var p;const h=(p=g?.__r3f)!=null?p:{},a=Object.entries(T),l=[];if(r){const u=Object.keys(e);for(let f=0;f{var o;if((o=g.__r3f)!=null&&o.primitive&&u==="object"||wn.equ(f,e[u]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(u))return l.push([u,f,!0,[]]);let c=[];u.includes("-")&&(c=u.split("-")),l.push([u,f,!1,c]);for(const d in T){const v=T[d];d.startsWith(`${u}-`)&&l.push([d,v,!1,d.split("-")])}});const n={...T};return h.memoizedProps&&h.memoizedProps.args&&(n.args=h.memoizedProps.args),h.memoizedProps&&h.memoizedProps.attach&&(n.attach=h.memoizedProps.attach),{memoized:n,changes:l}}const Q7=typeof process<"u"&&!1;function oy(g,t){var i,x,T;const E=(i=g.__r3f)!=null?i:{},s=E.root,y=(x=s==null||s.getState==null?void 0:s.getState())!=null?x:{},{memoized:e,changes:r}=J7(t)?t:OA(g,t),p=E.eventCount;g.__r3f&&(g.__r3f.memoizedProps=e);for(let a=0;ad[v],g),!(c&&c.set))){const[d,...v]=f.reverse();o=v.reverse().reduce((m,S)=>m[S],g),l=d}if(n===LA+"remove")if(o.constructor){let d=lM.get(o.constructor);d||(d=new o.constructor,lM.set(o.constructor,d)),n=d[l]}else n=0;if(u)n?E.handlers[l]=n:delete E.handlers[l],E.eventCount=Object.keys(E.handlers).length;else if(c&&c.set&&(c.copy||c instanceof Tu)){if(Array.isArray(n))c.fromArray?c.fromArray(n):c.set(...n);else if(c.copy&&n&&n.constructor&&(Q7?c.constructor.name===n.constructor.name:c.constructor===n.constructor))c.copy(n);else if(n!==void 0){const d=c instanceof ze;!d&&c.setScalar?c.setScalar(n):c instanceof Tu&&n instanceof Tu?c.mask=n.mask:c.set(n),!AA()&&!y.linear&&d&&c.convertSRGBToLinear()}}else if(o[l]=n,o[l]instanceof Un&&o[l].format===ps&&o[l].type===Uo){const d=o[l];sy(d)&&sy(y.gl)?d.colorSpace=y.gl.outputColorSpace:d.encoding=y.gl.outputEncoding}Of(g)}if(E.parent&&g.raycast&&p!==E.eventCount){const a=hm(g).getState().internal,l=a.interaction.indexOf(g);l>-1&&a.interaction.splice(l,1),E.eventCount&&a.interaction.push(g)}return!(r.length===1&&r[0][0]==="onUpdate")&&r.length&&(T=g.__r3f)!=null&&T.parent&&Cx(g),g}function Of(g){var t,i;const x=(t=g.__r3f)==null||(i=t.root)==null||i.getState==null?void 0:i.getState();x&&x.internal.frames===0&&x.invalidate()}function Cx(g){g.onUpdate==null||g.onUpdate(g)}function _7(g,t){g.manual||(PA(g)?(g.left=t.width/-2,g.right=t.width/2,g.top=t.height/2,g.bottom=t.height/-2):g.aspect=t.width/t.height,g.updateProjectionMatrix(),g.updateMatrixWorld())}function Kv(g){return(g.eventObject||g.object).uuid+"/"+g.index+g.instanceId}function q7(){var g;const t=typeof self<"u"&&self||typeof window<"u"&&window;if(!t)return Hf.DefaultEventPriority;switch((g=t.event)==null?void 0:g.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Hf.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Hf.ContinuousEventPriority;default:return Hf.DefaultEventPriority}}function DA(g,t,i,x){const T=i.get(t);T&&(i.delete(t),i.size===0&&(g.delete(x),T.target.releasePointerCapture(x)))}function tz(g,t){const{internal:i}=g.getState();i.interaction=i.interaction.filter(x=>x!==t),i.initialHits=i.initialHits.filter(x=>x!==t),i.hovered.forEach((x,T)=>{(x.eventObject===t||x.object===t)&&i.hovered.delete(T)}),i.capturedMap.forEach((x,T)=>{DA(i.capturedMap,t,x,T)})}function ez(g){function t(e){const{internal:r}=g.getState(),p=e.offsetX-r.initialClick[0],h=e.offsetY-r.initialClick[1];return Math.round(Math.sqrt(p*p+h*h))}function i(e){return e.filter(r=>["Move","Over","Enter","Out","Leave"].some(p=>{var h;return(h=r.__r3f)==null?void 0:h.handlers["onPointer"+p]}))}function x(e,r){const p=g.getState(),h=new Set,a=[],l=r?r(p.internal.interaction):p.internal.interaction;for(let o=0;o{const d=td(o.object),v=td(c.object);return!d||!v?o.distance-c.distance:v.events.priority-d.events.priority||o.distance-c.distance}).filter(o=>{const c=Kv(o);return h.has(c)?!1:(h.add(c),!0)});p.events.filter&&(u=p.events.filter(u,p));for(const o of u){let c=o.object;for(;c;){var f;(f=c.__r3f)!=null&&f.eventCount&&a.push({...o,eventObject:c}),c=c.parent}}if("pointerId"in e&&p.internal.capturedMap.has(e.pointerId))for(let o of p.internal.capturedMap.get(e.pointerId).values())h.has(Kv(o.intersection))||a.push(o.intersection);return a}function T(e,r,p,h){const a=g.getState();if(e.length){const l={stopped:!1};for(const n of e){const u=td(n.object)||a,{raycaster:f,pointer:o,camera:c,internal:d}=u,v=new Ct(o.x,o.y,0).unproject(c),m=A=>{var P,b;return(P=(b=d.capturedMap.get(A))==null?void 0:b.has(n.eventObject))!=null?P:!1},S=A=>{const P={intersection:n,target:r.target};d.capturedMap.has(A)?d.capturedMap.get(A).set(n.eventObject,P):d.capturedMap.set(A,new Map([[n.eventObject,P]])),r.target.setPointerCapture(A)},M=A=>{const P=d.capturedMap.get(A);P&&DA(d.capturedMap,n.eventObject,P,A)};let w={};for(let A in r){let P=r[A];typeof P!="function"&&(w[A]=P)}let C={...n,...w,pointer:o,intersections:e,stopped:l.stopped,delta:p,unprojectedPoint:v,ray:f.ray,camera:c,stopPropagation(){const A="pointerId"in r&&d.capturedMap.get(r.pointerId);if((!A||A.has(n.eventObject))&&(C.stopped=l.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(P=>P.eventObject===n.eventObject))){const P=e.slice(0,e.indexOf(n));E([...P,n])}},target:{hasPointerCapture:m,setPointerCapture:S,releasePointerCapture:M},currentTarget:{hasPointerCapture:m,setPointerCapture:S,releasePointerCapture:M},nativeEvent:r};if(h(C),l.stopped===!0)break}}return e}function E(e){const{internal:r}=g.getState();for(const p of r.hovered.values())if(!e.length||!e.find(h=>h.object===p.object&&h.index===p.index&&h.instanceId===p.instanceId)){const a=p.eventObject.__r3f,l=a?.handlers;if(r.hovered.delete(Kv(p)),a!=null&&a.eventCount){const n={...p,intersections:e};l.onPointerOut==null||l.onPointerOut(n),l.onPointerLeave==null||l.onPointerLeave(n)}}}function s(e,r){for(let p=0;pE([]);case"onLostPointerCapture":return r=>{const{internal:p}=g.getState();"pointerId"in r&&p.capturedMap.has(r.pointerId)&&requestAnimationFrame(()=>{p.capturedMap.has(r.pointerId)&&(p.capturedMap.delete(r.pointerId),E([]))})}}return function(p){const{onPointerMissed:h,internal:a}=g.getState();a.lastEvent.current=p;const l=e==="onPointerMove",n=e==="onClick"||e==="onContextMenu"||e==="onDoubleClick",f=x(p,l?i:void 0),o=n?t(p):0;e==="onPointerDown"&&(a.initialClick=[p.offsetX,p.offsetY],a.initialHits=f.map(d=>d.eventObject)),n&&!f.length&&o<=2&&(s(p,a.interaction),h&&h(p)),l&&E(f);function c(d){const v=d.eventObject,m=v.__r3f,S=m?.handlers;if(m!=null&&m.eventCount)if(l){if(S.onPointerOver||S.onPointerEnter||S.onPointerOut||S.onPointerLeave){const M=Kv(d),w=a.hovered.get(M);w?w.stopped&&d.stopPropagation():(a.hovered.set(M,d),S.onPointerOver==null||S.onPointerOver(d),S.onPointerEnter==null||S.onPointerEnter(d))}S.onPointerMove==null||S.onPointerMove(d)}else{const M=S[e];M?(!n||a.initialHits.includes(v))&&(s(p,a.interaction.filter(w=>!a.initialHits.includes(w))),M(d)):n&&a.initialHits.includes(v)&&s(p,a.interaction.filter(w=>!a.initialHits.includes(w)))}}T(f,p,o,c)}}return{handlePointer:y}}const IA=g=>!!(g!=null&&g.render),NA=Pe.createContext(null),iz=(g,t)=>{const i=G7((y,e)=>{const r=new Ct,p=new Ct,h=new Ct;function a(o=e().camera,c=p,d=e().size){const{width:v,height:m,top:S,left:M}=d,w=v/m;c instanceof Ct?h.copy(c):h.set(...c);const C=o.getWorldPosition(r).distanceTo(h);if(PA(o))return{width:v/o.zoom,height:m/o.zoom,top:S,left:M,factor:1,distance:C,aspect:w};{const A=o.fov*Math.PI/180,P=2*Math.tan(A/2)*C,b=P*(v/m);return{width:b,height:P,top:S,left:M,factor:v/b,distance:C,aspect:w}}}let l;const n=o=>y(c=>({performance:{...c.performance,current:o}})),u=new ve;return{set:y,get:e,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(o=1)=>g(e(),o),advance:(o,c)=>t(o,c,e()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new G1,pointer:u,mouse:u,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const o=e();l&&clearTimeout(l),o.performance.current!==o.performance.min&&n(o.performance.min),l=setTimeout(()=>n(e().performance.max),o.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:a},setEvents:o=>y(c=>({...c,events:{...c.events,...o}})),setSize:(o,c,d,v,m)=>{const S=e().camera,M={width:o,height:c,top:v||0,left:m||0,updateStyle:d};y(w=>({size:M,viewport:{...w.viewport,...a(S,p,M)}}))},setDpr:o=>y(c=>{const d=FA(o);return{viewport:{...c.viewport,dpr:d,initialDpr:c.viewport.initialDpr||d}}}),setFrameloop:(o="always")=>{const c=e().clock;c.stop(),c.elapsedTime=0,o!=="never"&&(c.start(),c.elapsedTime=0),y(()=>({frameloop:o}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:Pe.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(o,c,d)=>{const v=e().internal;return v.priority=v.priority+(c>0?1:0),v.subscribers.push({ref:o,priority:c,store:d}),v.subscribers=v.subscribers.sort((m,S)=>m.priority-S.priority),()=>{const m=e().internal;m!=null&&m.subscribers&&(m.priority=m.priority-(c>0?1:0),m.subscribers=m.subscribers.filter(S=>S.ref!==o))}}}}}),x=i.getState();let T=x.size,E=x.viewport.dpr,s=x.camera;return i.subscribe(()=>{const{camera:y,size:e,viewport:r,gl:p,set:h}=i.getState();if(e.width!==T.width||e.height!==T.height||r.dpr!==E){var a;T=e,E=r.dpr,_7(y,e),p.setPixelRatio(r.dpr);const l=(a=e.updateStyle)!=null?a:typeof HTMLCanvasElement<"u"&&p.domElement instanceof HTMLCanvasElement;p.setSize(e.width,e.height,l)}y!==s&&(s=y,h(l=>({viewport:{...l.viewport,...l.viewport.getCurrentViewport(y)}})))}),i.subscribe(y=>g(y)),i};let jv,nz=new Set,rz=new Set,sz=new Set;function ly(g,t){if(g.size)for(const{callback:i}of g.values())i(t)}function ed(g,t){switch(g){case"before":return ly(nz,t);case"after":return ly(rz,t);case"tail":return ly(sz,t)}}let hy,uy;function fy(g,t,i){let x=t.clock.getDelta();for(t.frameloop==="never"&&typeof g=="number"&&(x=g-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=g),hy=t.internal.subscribers,jv=0;jv0)&&!((p=E.gl.xr)!=null&&p.isPresenting)&&(x+=fy(r,E))}if(i=!1,ed("after",r),x===0)return ed("tail",r),t=!1,cancelAnimationFrame(T)}function y(r,p=1){var h;if(!r)return g.forEach(a=>y(a.store.getState(),p));(h=r.gl.xr)!=null&&h.isPresenting||!r.internal.active||r.frameloop==="never"||(p>1?r.internal.frames=Math.min(60,r.internal.frames+p):i?r.internal.frames=2:r.internal.frames=1,t||(t=!0,requestAnimationFrame(s)))}function e(r,p=!0,h,a){if(p&&ed("before",r),h)fy(r,h,a);else for(const l of g.values())fy(r,l.store.getState());p&&ed("after",r)}return{loop:s,invalidate:y,advance:e}}function oz(){const g=Pe.useContext(NA);if(!g)throw new Error("R3F: Hooks can only be used within the Canvas component!");return g}function lz(g,t=0){const i=oz(),x=i.getState().internal.subscribe,T=RA(g);return rp(()=>x(T,t,i),[t,x,i]),null}const _f=new Map,{invalidate:fM,advance:cM}=az(_f),{reconciler:wm,applyProps:bf}=K7(_f,q7),Lf={objects:"shallow",strict:!1},hz=(g,t)=>{const i=typeof g=="function"?g(t):g;return IA(i)?i:new M1({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...g})};function uz(g,t){const i=typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement;if(t){const{width:x,height:T,top:E,left:s,updateStyle:y=i}=t;return{width:x,height:T,top:E,left:s,updateStyle:y}}else if(typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement&&g.parentElement){const{width:x,height:T,top:E,left:s}=g.parentElement.getBoundingClientRect();return{width:x,height:T,top:E,left:s,updateStyle:i}}else if(typeof OffscreenCanvas<"u"&&g instanceof OffscreenCanvas)return{width:g.width,height:g.height,top:0,left:0,updateStyle:i};return{width:0,height:0,top:0,left:0}}function fz(g){const t=_f.get(g),i=t?.fiber,x=t?.store;t&&console.warn("R3F.createRoot should only be called once!");const T=typeof reportError=="function"?reportError:console.error,E=x||iz(fM,cM),s=i||wm.createContainer(E,Hf.ConcurrentRoot,null,!1,null,"",T,null);t||_f.set(g,{fiber:s,store:E});let y,e=!1,r;return{configure(p={}){let{gl:h,size:a,scene:l,events:n,onCreated:u,shadows:f=!1,linear:o=!1,flat:c=!1,legacy:d=!1,orthographic:v=!1,frameloop:m="always",dpr:S=[1,2],performance:M,raycaster:w,camera:C,onPointerMissed:A}=p,P=E.getState(),b=P.gl;P.gl||P.set({gl:b=hz(h,g)});let O=P.raycaster;O||P.set({raycaster:O=new SA});const{params:I,...D}=w||{};if(wn.equ(D,O,Lf)||bf(O,{...D}),wn.equ(I,O.params,Lf)||bf(O,{params:{...O.params,...I}}),!P.camera||P.camera===r&&!wn.equ(r,C,Lf)){r=C;const K=C instanceof $d,Q=K?C:v?new qd(0,0,0,0,.1,1e3):new Or(75,0,.1,1e3);K||(Q.position.z=5,C&&bf(Q,C),!P.camera&&!(C!=null&&C.rotation)&&Q.lookAt(0,0,0)),P.set({camera:Q}),O.camera=Q}if(!P.scene){let K;l instanceof Mm?K=l:(K=new Mm,l&&bf(K,l)),P.set({scene:Ff(K)})}if(!P.xr){var B;const K=(Y,Z)=>{const U=E.getState();U.frameloop!=="never"&&cM(Y,!0,U,Z)},Q=()=>{const Y=E.getState();Y.gl.xr.enabled=Y.gl.xr.isPresenting,Y.gl.xr.setAnimationLoop(Y.gl.xr.isPresenting?K:null),Y.gl.xr.isPresenting||fM(Y)},tt={connect(){const Y=E.getState().gl;Y.xr.addEventListener("sessionstart",Q),Y.xr.addEventListener("sessionend",Q)},disconnect(){const Y=E.getState().gl;Y.xr.removeEventListener("sessionstart",Q),Y.xr.removeEventListener("sessionend",Q)}};typeof((B=b.xr)==null?void 0:B.addEventListener)=="function"&&tt.connect(),P.set({xr:tt})}if(b.shadowMap){const K=b.shadowMap.enabled,Q=b.shadowMap.type;if(b.shadowMap.enabled=!!f,wn.boo(f))b.shadowMap.type=hd;else if(wn.str(f)){var G;const tt={basic:f2,percentage:rg,soft:hd,variance:_a};b.shadowMap.type=(G=tt[f])!=null?G:hd}else wn.obj(f)&&Object.assign(b.shadowMap,f);(K!==b.shadowMap.enabled||Q!==b.shadowMap.type)&&(b.shadowMap.needsUpdate=!0)}const z=AA();z&&("enabled"in z?z.enabled=!d:"legacyMode"in z&&(z.legacyMode=d)),e||bf(b,{outputEncoding:o?3e3:3001,toneMapping:c?Bo:n1}),P.legacy!==d&&P.set(()=>({legacy:d})),P.linear!==o&&P.set(()=>({linear:o})),P.flat!==c&&P.set(()=>({flat:c})),h&&!wn.fun(h)&&!IA(h)&&!wn.equ(h,b,Lf)&&bf(b,h),n&&!P.events.handlers&&P.set({events:n(E)});const X=uz(g,a);return wn.equ(X,P.size,Lf)||P.setSize(X.width,X.height,X.updateStyle,X.top,X.left),S&&P.viewport.dpr!==FA(S)&&P.setDpr(S),P.frameloop!==m&&P.setFrameloop(m),P.onPointerMissed||P.set({onPointerMissed:A}),M&&!wn.equ(M,P.performance,Lf)&&P.set(K=>({performance:{...K.performance,...M}})),y=u,e=!0,this},render(p){return e||this.configure(),wm.updateContainer(Pe.createElement(cz,{store:E,children:p,onCreated:y,rootElement:g}),s,null,()=>{}),E},unmount(){BA(g)}}}function cz({store:g,children:t,onCreated:i,rootElement:x}){return rp(()=>{const T=g.getState();T.set(E=>({internal:{...E.internal,active:!0}})),i&&i(T),g.getState().events.connected||T.events.connect==null||T.events.connect(x)},[]),Pe.createElement(NA.Provider,{value:g},t)}function BA(g,t){const i=_f.get(g),x=i?.fiber;if(x){const T=i?.store.getState();T&&(T.internal.active=!1),wm.updateContainer(null,x,null,()=>{T&&setTimeout(()=>{try{var E,s,y,e;T.events.disconnect==null||T.events.disconnect(),(E=T.gl)==null||(s=E.renderLists)==null||s.dispose==null||s.dispose(),(y=T.gl)==null||y.forceContextLoss==null||y.forceContextLoss(),(e=T.gl)!=null&&e.xr&&T.xr.disconnect(),$7(T),_f.delete(g),t&&t(g)}catch{}},500)})}}wm.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:Pe.version});function Am(){return Am=Object.assign?Object.assign.bind():function(g){for(var t=1;t=0?x=setTimeout(e,t-p):(x=null,i||(y=g.apply(E,T),E=T=null))}var r=function(){E=this,T=arguments,s=Date.now();var p=i&&!x;return x||(x=setTimeout(e,t)),p&&(y=g.apply(E,T),E=T=null),y};return r.clear=function(){x&&(clearTimeout(x),x=null)},r.flush=function(){x&&(y=g.apply(E,T),E=T=null,clearTimeout(x),x=null)},r}wx.debounce=wx;var dz=wx;const dM=Wd(dz);function pz(g){let{debounce:t,scroll:i,polyfill:x,offsetSize:T}=g===void 0?{debounce:0,scroll:!1,offsetSize:!1}:g;const E=x||(typeof window>"u"?class{}:window.ResizeObserver);if(!E)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,y]=Pe.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),e=Pe.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s}),r=t?typeof t=="number"?t:t.scroll:null,p=t?typeof t=="number"?t:t.resize:null,h=Pe.useRef(!1);Pe.useEffect(()=>(h.current=!0,()=>void(h.current=!1)));const[a,l,n]=Pe.useMemo(()=>{const c=()=>{if(!e.current.element)return;const{left:d,top:v,width:m,height:S,bottom:M,right:w,x:C,y:A}=e.current.element.getBoundingClientRect(),P={left:d,top:v,width:m,height:S,bottom:M,right:w,x:C,y:A};e.current.element instanceof HTMLElement&&T&&(P.height=e.current.element.offsetHeight,P.width=e.current.element.offsetWidth),Object.freeze(P),h.current&&!yz(e.current.lastBounds,P)&&y(e.current.lastBounds=P)};return[c,p?dM(c,p):c,r?dM(c,r):c]},[y,T,r,p]);function u(){e.current.scrollContainers&&(e.current.scrollContainers.forEach(c=>c.removeEventListener("scroll",n,!0)),e.current.scrollContainers=null),e.current.resizeObserver&&(e.current.resizeObserver.disconnect(),e.current.resizeObserver=null)}function f(){e.current.element&&(e.current.resizeObserver=new E(n),e.current.resizeObserver.observe(e.current.element),i&&e.current.scrollContainers&&e.current.scrollContainers.forEach(c=>c.addEventListener("scroll",n,{capture:!0,passive:!0})))}const o=c=>{!c||c===e.current.element||(u(),e.current.element=c,e.current.scrollContainers=UA(c),f())};return mz(n,!!i),vz(l),Pe.useEffect(()=>{u(),f()},[i,n,l]),Pe.useEffect(()=>u,[]),[o,s,a]}function vz(g){Pe.useEffect(()=>{const t=g;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[g])}function mz(g,t){Pe.useEffect(()=>{if(t){const i=g;return window.addEventListener("scroll",i,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",i,!0)}},[g,t])}function UA(g){const t=[];if(!g||g===document.body)return t;const{overflow:i,overflowX:x,overflowY:T}=window.getComputedStyle(g);return[i,x,T].some(E=>E==="auto"||E==="scroll")&&t.push(g),[...t,...UA(g.parentElement)]}const gz=["x","y","top","bottom","left","right","width","height"],yz=(g,t)=>gz.every(i=>g[i]===t[i]);var xz=Object.defineProperty,Sz=Object.defineProperties,Tz=Object.getOwnPropertyDescriptors,pM=Object.getOwnPropertySymbols,Ez=Object.prototype.hasOwnProperty,Mz=Object.prototype.propertyIsEnumerable,vM=(g,t,i)=>t in g?xz(g,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):g[t]=i,mM=(g,t)=>{for(var i in t||(t={}))Ez.call(t,i)&&vM(g,i,t[i]);if(pM)for(var i of pM(t))Mz.call(t,i)&&vM(g,i,t[i]);return g},Cz=(g,t)=>Sz(g,Tz(t)),gM,yM;typeof window<"u"&&((gM=window.document)!=null&&gM.createElement||((yM=window.navigator)==null?void 0:yM.product)==="ReactNative")?Pe.useLayoutEffect:Pe.useEffect;function zA(g,t,i){if(!g)return;if(i(g)===!0)return g;let x=t?g.return:g.child;for(;x;){const T=zA(x,t,i);if(T)return T;x=t?null:x.sibling}}function GA(g){try{return Object.defineProperties(g,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return g}}const xM=console.error;console.error=function(){const g=[...arguments].join("");if(g?.startsWith("Warning:")&&g.includes("useContext")){console.error=xM;return}return xM.apply(this,arguments)};const Y1=GA(Pe.createContext(null));class VA extends Pe.Component{render(){return Pe.createElement(Y1.Provider,{value:this._reactInternals},this.props.children)}}function wz(){const g=Pe.useContext(Y1);if(g===null)throw new Error("its-fine: useFiber must be called within a !");const t=Pe.useId();return Pe.useMemo(()=>{for(const x of[g,g?.alternate]){if(!x)continue;const T=zA(x,!1,E=>{let s=E.memoizedState;for(;s;){if(s.memoizedState===t)return!0;s=s.next}});if(T)return T}},[g,t])}function Az(){const g=wz(),[t]=Pe.useState(()=>new Map);t.clear();let i=g;for(;i;){if(i.type&&typeof i.type=="object"){const T=i.type._context===void 0&&i.type.Provider===i.type?i.type:i.type._context;T&&T!==Y1&&!t.has(T)&&t.set(T,Pe.useContext(GA(T)))}i=i.return}return t}function Pz(){const g=Az();return Pe.useMemo(()=>Array.from(g.keys()).reduce((t,i)=>x=>Pe.createElement(t,null,Pe.createElement(i.Provider,Cz(mM({},x),{value:g.get(i)}))),t=>Pe.createElement(VA,mM({},t))),[g])}const cy={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function Rz(g){const{handlePointer:t}=ez(g);return{priority:1,enabled:!0,compute(i,x,T){x.pointer.set(i.offsetX/x.size.width*2-1,-(i.offsetY/x.size.height)*2+1),x.raycaster.setFromCamera(x.pointer,x.camera)},connected:void 0,handlers:Object.keys(cy).reduce((i,x)=>({...i,[x]:t(x)}),{}),update:()=>{var i;const{events:x,internal:T}=g.getState();(i=T.lastEvent)!=null&&i.current&&x.handlers&&x.handlers.onPointerMove(T.lastEvent.current)},connect:i=>{var x;const{set:T,events:E}=g.getState();E.disconnect==null||E.disconnect(),T(s=>({events:{...s.events,connected:i}})),Object.entries((x=E.handlers)!=null?x:[]).forEach(([s,y])=>{const[e,r]=cy[s];i.addEventListener(e,y,{passive:r})})},disconnect:()=>{const{set:i,events:x}=g.getState();if(x.connected){var T;Object.entries((T=x.handlers)!=null?T:[]).forEach(([E,s])=>{if(x&&x.connected instanceof HTMLElement){const[y]=cy[E];x.connected.removeEventListener(y,s)}}),i(E=>({events:{...E.events,connected:void 0}}))}}}}const bz=Pe.forwardRef(function({children:t,fallback:i,resize:x,style:T,gl:E,events:s=Rz,eventSource:y,eventPrefix:e,shadows:r,linear:p,flat:h,legacy:a,orthographic:l,frameloop:n,dpr:u,performance:f,raycaster:o,camera:c,scene:d,onPointerMissed:v,onCreated:m,...S},M){Pe.useMemo(()=>k7(B7),[]);const w=Pz(),[C,A]=pz({scroll:!0,debounce:{scroll:50,resize:0},...x}),P=Pe.useRef(null),b=Pe.useRef(null);Pe.useImperativeHandle(M,()=>P.current);const O=RA(v),[I,D]=Pe.useState(!1),[B,G]=Pe.useState(!1);if(I)throw I;if(B)throw B;const z=Pe.useRef(null);rp(()=>{const K=P.current;A.width>0&&A.height>0&&K&&(z.current||(z.current=fz(K)),z.current.configure({gl:E,events:s,shadows:r,linear:p,flat:h,legacy:a,orthographic:l,frameloop:n,dpr:u,performance:f,raycaster:o,camera:c,scene:d,size:A,onPointerMissed:(...Q)=>O.current==null?void 0:O.current(...Q),onCreated:Q=>{Q.events.connect==null||Q.events.connect(y?j7(y)?y.current:y:b.current),e&&Q.setEvents({compute:(tt,Y)=>{const Z=tt[e+"X"],U=tt[e+"Y"];Y.pointer.set(Z/Y.size.width*2-1,-(U/Y.size.height)*2+1),Y.raycaster.setFromCamera(Y.pointer,Y.camera)}}),m?.(Q)}}),z.current.render(Pe.createElement(w,null,Pe.createElement(bA,{set:G},Pe.createElement(Pe.Suspense,{fallback:Pe.createElement(Z7,{set:D})},t)))))}),Pe.useEffect(()=>{const K=P.current;if(K)return()=>BA(K)},[]);const X=y?"none":"auto";return Pe.createElement("div",Am({ref:b,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:X,...T}},S),Pe.createElement("div",{ref:C,style:{width:"100%",height:"100%"}},Pe.createElement("canvas",{ref:P,style:{display:"block"}},i)))}),Lz=Pe.forwardRef(function(t,i){return Pe.createElement(VA,null,Pe.createElement(bz,Am({},t,{ref:i})))});function Tl(g,t={}){let i=Pe.useCallback(T=>t.keys?k4(g,t.keys,T):g.listen(T),[t.keys,g]),x=g.get.bind(g);return Pe.useSyncExternalStore(i,x,x)}const Fz=[new qa(-Math.PI/2,-Math.PI/2,-Math.PI/2),new qa(0,Math.PI/2,0),new qa(0,-Math.PI/2,-Math.PI/2),new qa(Math.PI/2,Math.PI,Math.PI),new qa(0,0,-Math.PI/2),new qa(Math.PI,0,0)],Oz=({diceValues:g,isRolling:t,textures:i})=>{const x=Pe.useRef([]),T=Pe.useRef([]);return Pe.useEffect(()=>{const E=new aA,s=new ze(16766720);T.current=[new vl({map:E.load(i.side1),color:s}),new vl({map:E.load(i.side2),color:s}),new vl({map:E.load(i.side3),color:s}),new vl({map:E.load(i.side4),color:s}),new vl({map:E.load(i.side5),color:s}),new vl({map:E.load(i.side6),color:s})],x.current.forEach(y=>{y&&(y.material=T.current)})},[i]),lz(()=>{x.current.forEach((E,s)=>{if(E)if(t)E.rotation.x+=.2,E.rotation.y+=.2;else{const y=Fz[g[s]-1];E.rotation.x=om.lerp(E.rotation.x,y.x,.1),E.rotation.y=om.lerp(E.rotation.y,y.y,.1),E.rotation.z=om.lerp(E.rotation.z,y.z,.1)}})}),he.jsx(he.Fragment,{children:g.map((E,s)=>he.jsxs("mesh",{ref:y=>x.current[s]=y,position:[s*2-(g.length-1),0,0],children:[he.jsx("boxGeometry",{args:[1,1,1]}),T.current.length===6&&T.current.map((y,e)=>he.jsx("meshStandardMaterial",{attach:`material-${e}`,...y},e))]},s))})},Dz=({styleClass:g,textures:t,diceCount:i})=>{const x=Tl(xd);Pe.useEffect(()=>{UI("Dice"),GI(t),zI({type:"ROLL_DICE",diceValues:Array(i).fill(1),isRolling:!1})},[t,i]);const T=()=>{CT(!0),setTimeout(()=>{const E=Array.from({length:i},()=>Math.floor(Math.random()*6)+1);console.log("New dice values:",E),l2(E),CT(!1);const s={diceValues:E};Pi.emit("diceRollResult",s)},2e3)};return he.jsxs("div",{className:`flex flex-col items-center justify-center p-4 ${g}`,children:[he.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Dice Roller"}),he.jsxs(Lz,{className:"w-full h-full",camera:{position:[0,0,5]},children:[he.jsx("ambientLight",{intensity:2.5}),he.jsx("pointLight",{position:[10,10,10]}),fT(x.action)&&he.jsx(Oz,{diceValues:x.action.diceValues,isRolling:x.action.isRolling,textures:x.textures})]}),fT(x.action)&&he.jsx("button",{onClick:T,className:`mt-4 p-2 border border-yellow-300 rounded text-yellow-400 ${x.action.isRolling?"opacity-50":""}`,disabled:x.action.isRolling,children:"Roll Dice"})]})};class HA{constructor(t,i,x){this.scene=t,this.gridEngine=i,this.quadtree=x,this.cursor=this.scene.input.keyboard?.createCursorKeys(),this.initializeWASDKeys(),this.registerEventHandlers(),this.tooltip=this.scene.add.text(0,0,"Press [F]",{font:"16px Arial",backgroundColor:"#000000"}).setDepth(4).setPadding(3,2,2,3).setVisible(!1)}initializeWASDKeys(){const t=this.scene.input.keyboard;t&&(this.wasdKeys={W:t.addKey(Phaser.Input.Keyboard.KeyCodes.W),A:t.addKey(Phaser.Input.Keyboard.KeyCodes.A),S:t.addKey(Phaser.Input.Keyboard.KeyCodes.S),D:t.addKey(Phaser.Input.Keyboard.KeyCodes.D)})}handleConsume(t){const i=yl(t);i&&i.consumable?(console.log(`Consuming item: ${i.name}`),NI(i),MT(i.id)):console.log(`Item ${t} is not consumable`)}handleEquip(t){const i=yl(t);i&&(console.log(`Equipping item: ${i.name}`),AI("weapon",i.id))}handleUnequip(t){const i=yl(t);i&&(console.log(`Unequipping item: ${i.name}`),PI("weapon"))}handleDiscard(t){console.log(`Discarding item: ${t}`),MT(t)}handleView(t){const i=yl(t);if(i&&(console.log(`Viewing item: ${i.name} with ${i.slug}`),i.slug)){const x=`https://kbve.com/${i.slug}#${i.name.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]+/g,"")}`;window.open(x,"_blank")}}registerEventHandlers(){Pi.on("itemAction",this.handleItemAction.bind(this));//! Broken +Pi.on("playerMove",this.handlePlayerMove.bind(this)),Pi.on("playerReward",this.handlePlayerReward.bind(this)),Pi.on("playerDamage",this.handlePlayerCombatDamage.bind(this))}handleItemAction(t){if(t)switch(console.log(`Preparing Action: ${t.itemId} with ${t.action}`),t.action){case"consume":this.handleConsume(t.itemId);break;case"equip":this.handleEquip(t.itemId);break;case"unequip":this.handleUnequip(t.itemId);break;case"discard":this.handleDiscard(t.itemId);break;case"view":this.handleView(t.itemId);break;default:console.log(`Unknown action: ${t.action}`)}}handlePlayerReward(t){console.log("Rewarding the player"),t&&(Pi.emit("notification",{title:"Success",message:t.message,notificationType:Au.success}),wI(t.item))}handlePlayerCombatDamage(t){t&&(o2(parseInt(t.damage)),Pi.emit("notification",{title:"Danger",message:`You taken ${t.damage} points of damage!`,notificationType:Au.danger}))}handlePlayerMove(t){t&&this.gridEngine.moveTo("player",{x:t.x,y:t.y})}checkForNearbyObjects(){const i=this.gridEngine.getPosition("player"),x=i.x*48,T=i.y*48;this.quadtree.query(i).length>0?this.tooltip.setPosition(x,T-60).setVisible(!0):this.tooltip.setVisible(!1)}handleMovement(){if(!this.cursor)return;const t=this.cursor,i=this.wasdKeys;if(this.scene.input.keyboard?.addKey("F").isDown){const x=this.gridEngine.getPosition("player"),T=this.quadtree.query(x);for(const E of T)E.action()}(t.left.isDown||i.A.isDown)&&(t.up.isDown||i.W.isDown)?this.gridEngine.move("player","up-left"):(t.left.isDown||i.A.isDown)&&(t.down.isDown||i.S.isDown)?this.gridEngine.move("player","down-left"):(t.right.isDown||i.D.isDown)&&(t.up.isDown||i.W.isDown)?this.gridEngine.move("player","up-right"):(t.right.isDown||i.D.isDown)&&(t.down.isDown||i.S.isDown)?this.gridEngine.move("player","down-right"):t.left.isDown||i.A.isDown?this.gridEngine.move("player","left"):t.right.isDown||i.D.isDown?this.gridEngine.move("player","right"):t.up.isDown||i.W.isDown?this.gridEngine.move("player","up"):(t.down.isDown||i.S.isDown)&&this.gridEngine.move("player","down"),this.checkForNearbyObjects()}}class WA extends Phaser.GameObjects.Container{constructor(t,i,x,T){const E=i.x,s=i.y-i.height+10;super(t,E,s),this.sprite=i;const y=150,e=40+T.length*20;this.background=t.add.rectangle(0,0,y,e,0,.7),this.text=t.add.text(0,-e/2+10,x,{fontSize:"12px",color:"#ffffff"}).setOrigin(.5),this.buttons=T.map((r,p)=>{const h=t.add.text(0,-e/2+30+p*20,r.label,{fontSize:"12px",color:"#00ff00"}).setOrigin(.5);return h.setInteractive({useHandCursor:!0}),h.on("pointerdown",r.callback),h}),this.add(this.background),this.add(this.text),this.buttons.forEach(r=>this.add(r)),this.scene.add.existing(this)}updatePosition(){this.setPosition(this.sprite.x-30,this.sprite.y-this.sprite.height-this.background.height/2+100)}static attachToSprite(t,i,x,T){i.setInteractive(),i.on("pointerover",E=>{const s={npcId:i.name,npcName:x,actions:T.map(e=>e.label),coords:{x:E.x,y:E.y}};if(Pi.emit("npcInteraction",s),!i.getData("tooltipMenu")){const e=new WA(t,i,x,T);i.setData("tooltipMenu",e)}const y=i.getData("tooltipMenu");y.setVisible(!0),y.updatePosition()}),i.on("pointerout",()=>{const E=i.getData("tooltipMenu");E&&E.setVisible(!1)})}static updateAllTooltipPositions(t){t.children.list.forEach(i=>{if(i instanceof Phaser.GameObjects.Sprite){const x=i.getData("tooltipMenu");x&&x.updatePosition()}})}}let cG=class extends Phaser.GameObjects.Sprite{};function Iz(g,t,i,x){const y=g.add.graphics();y.fillStyle(16777215,1),y.fillRoundedRect(0,0,200,60,16),y.setDepth(99);const e=g.add.text(100,30,i,{fontFamily:"Arial",fontSize:16,color:"#000000"});e.setOrigin(.5),e.setWordWrapWidth(200-10*2),e.setDepth(100);const r=g.add.container(0,0,[y,e]);return r.setDepth(100),t.messageBubble=r,Bz(t),g.time.addEvent({delay:x,callback:()=>{r.destroy(),t.messageBubble===r&&(t.messageBubble=void 0)},callbackScope:g}),r}function Nz(g,t,i){const s=g.add.graphics();s.fillStyle(16777215,1),s.fillRoundedRect(0,0,200,60,16),s.setDepth(99);const y=g.add.text(100,30,i,{fontFamily:"Arial",fontSize:16,color:"#000000"});y.setOrigin(.5),y.setWordWrapWidth(200-10*2),y.setDepth(100);const e=g.add.container(0,0,[s,y]);return e.setDepth(100),t.textBubble=e,Ax(t),e}function Ax(g){const t=g.textBubble;t&&(t.x=g.x,t.y=g.y-g.height-t.height/2)}function Bz(g){const t=g.messageBubble;t&&(t.x=g.x,t.y=g.y-g.height-t.height/2)}class Uz{constructor(){this.actionHandlers={talk:this.talkToNPC.bind(this),quest:this.questWithNPC.bind(this),trade:this.tradeWithNPC.bind(this),combat:this.startCombat.bind(this),heal:this.healNPC.bind(this),steal:this.stealFromNPC.bind(this),lore:this.loreFromNPC.bind(this)}}getActionHandler(t){return this.actionHandlers[t]}loreFromNPC(t){console.log(`Pulling up the lore of the NPC with ID: ${t.npcId}`)}questWithNPC(t){console.log(`Starting quest with NPC with ID: ${t.npcId}`)}healNPC(t){console.log(`Healing NPC with ID: ${t.npcId}`)}talkToNPC(t){console.log(`Talking to NPC with ID: ${t.npcId}`)}tradeWithNPC(t){console.log(`Trading with NPC with ID: ${t.npcId}`)}moveToNPC(t){const x=t.data?.coords||{x:10,y:15};Pi.emit("playerMove",x)}stealFromNPC(t){console.log(`Attempting to steal from NPC with ID: ${t.npcId}`);const i={npcId:t.npcId,npcName:t.npcName,data:t.data};Pi.emit("playerSteal",i)}startCombat(t){console.log(`Starting combat with NPC with ID: ${t.npcId}`)}checkFish(t){console.log(`Checking fish for NPC with ID: ${t.npcId}`)}attachNPCEvent(t,i,x,T){t.setInteractive(),t.on("pointerover",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};Pi.emit("npcInteraction",s)}),t.on("pointerout",()=>{}),t.on("pointerdown",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};console.log(`Click Registered at X: ${s.coords.x} Y: ${s.coords.y}`),Pi.emit("npcInteractionClick",s,1e3)})}}const k1=new Uz;var XA={exports:{}};(function(g,t){(function(i,x){g.exports=x()})(vy,function(){var i=function(V,j){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(et,st){et.__proto__=st}||function(et,st){for(var ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(et[ht]=st[ht])})(V,j)},x=function(){return(x=Object.assign||function(V){for(var j,et=1,st=arguments.length;et"u"||E.Promise||(E.Promise=Promise);var r=Object.getPrototypeOf,p={}.hasOwnProperty;function h(V,j){return p.call(V,j)}function a(V,j){typeof j=="function"&&(j=j(r(V))),(typeof Reflect>"u"?s:Reflect.ownKeys)(j).forEach(function(et){n(V,et,j[et])})}var l=Object.defineProperty;function n(V,j,et,st){l(V,j,e(et&&h(et,"get")&&typeof et.get=="function"?{get:et.get,set:et.set,configurable:!0}:{value:et,configurable:!0,writable:!0},st))}function u(V){return{from:function(j){return V.prototype=Object.create(j.prototype),n(V.prototype,"constructor",V),{extend:a.bind(null,V.prototype)}}}}var f=Object.getOwnPropertyDescriptor,o=[].slice;function c(V,j,et){return o.call(V,j,et)}function d(V,j){return j(V)}function v(V){if(!V)throw new Error("Assertion Failed")}function m(V){E.setImmediate?setImmediate(V):setTimeout(V,0)}function S(V,j){if(typeof j=="string"&&h(V,j))return V[j];if(!j)return V;if(typeof j!="string"){for(var et=[],st=0,ht=j.length;st"u"?[]:function(){var V=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[V,r(V),V];var j=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[j,r(j),V]}(),ne=Gs[0],lr=Gs[1],Gs=Gs[2],lr=lr&&lr.then,oe=ne&&ne.constructor,ge=!!Gs,xe=function(V,j){Ke.push([V,j]),qt&&(queueMicrotask(zi),qt=!1)},Ae=!0,qt=!0,Ge=[],Oe=[],Be=gt,Le={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:rt,pgp:!1,env:{},finalize:rt},ie=Le,Ke=[],ri=0,Ti=[];function le(V){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var j=this._PSD=ie;if(typeof V!="function"){if(V!==Ht)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Me(this,this._value))}this._state=null,this._value=null,++j.ref,function et(st,ht){try{ht(function(pt){if(st._state===null){if(pt===st)throw new TypeError("A promise cannot be resolved with itself.");var Mt=st._lib&&Di();pt&&typeof pt.then=="function"?et(st,function(Nt,zt){pt instanceof le?pt._then(Nt,zt):pt.then(Nt,zt)}):(st._state=!0,st._value=pt,Ce(st)),Mt&&en()}},Me.bind(null,st))}catch(pt){Me(st,pt)}}(this,V)}var xi={get:function(){var V=ie,j=Qr;function et(st,ht){var pt=this,Mt=!V.global&&(V!==ie||j!==Qr),Nt=Mt&&!xs(),zt=new le(function(ct,St){Ve(pt,new bt(ee(st,V,Mt,Nt),ee(ht,V,Mt,Nt),ct,St,V))});return this._consoleTask&&(zt._consoleTask=this._consoleTask),zt}return et.prototype=Ht,et},set:function(V){n(this,"then",V&&V.prototype===Ht?xi:{get:function(){return V},set:xi.set})}};function bt(V,j,et,st,ht){this.onFulfilled=typeof V=="function"?V:null,this.onRejected=typeof j=="function"?j:null,this.resolve=et,this.reject=st,this.psd=ht}function Me(V,j){var et,st;Oe.push(j),V._state===null&&(et=V._lib&&Di(),j=Be(j),V._state=!1,V._value=j,st=V,Ge.some(function(ht){return ht._value===st._value})||Ge.push(st),Ce(V),et&&en())}function Ce(V){var j=V._listeners;V._listeners=[];for(var et=0,st=j.length;et.",$e="String expected.",qe=[],ii="__dbnames",ai="readonly",Ji="readwrite";function hn(V,j){return V?j?function(){return V.apply(this,arguments)&&j.apply(this,arguments)}:V:j}var ki={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function mn(V){return typeof V!="string"||/\./.test(V)?function(j){return j}:function(j){return j[V]===void 0&&V in j&&delete(j=O(j))[V],j}}function ti(){throw q.Type()}function Se(V,j){try{var et=Nr(V),st=Nr(j);if(et!==st)return et==="Array"?1:st==="Array"?-1:et==="binary"?1:st==="binary"?-1:et==="string"?1:st==="string"?-1:et==="Date"?1:st!=="Date"?NaN:-1;switch(et){case"number":case"Date":case"string":return j$t+se&&Kt($t+Ft)})})}var Zt=Ki(et)&&et.limit===1/0&&(typeof V!="function"||V===La)&&{index:et.index,range:et.range};return Kt(0).then(function(){if(0=Ft})).length!==0?(St.forEach(function(Kt){Wt.push(function(){var Zt=It,$t=Kt._cfg.dbschema;Ia(vt,Zt,Ut),Ia(vt,$t,Ut),It=vt._dbSchema=$t;var se=Rn(Zt,$t);se.add.forEach(function(me){Fa(Ut,me[0],me[1].primKey,me[1].indexes)}),se.change.forEach(function(me){if(me.recreate)throw new q.Upgrade("Not yet support for changing primary key");var be=Ut.objectStore(me.name);me.add.forEach(function(_e){return En(be,_e)}),me.change.forEach(function(_e){be.deleteIndex(_e.name),En(be,_e)}),me.del.forEach(function(_e){return be.deleteIndex(_e)})});var ue=Kt._cfg.contentUpgrade;if(ue&&Kt._cfg.version>Ft){ko(vt,Ut),Lt._memoizedTables={};var Re=w($t);se.del.forEach(function(me){Re[me]=Zt[me]}),zr(vt,[vt.Transaction.prototype]),Fl(vt,[vt.Transaction.prototype],s(Re),Re),Lt.schema=Re;var pe,we=Q(ue);return we&&Us(),se=le.follow(function(){var me;(pe=ue(Lt))&&we&&(me=xs.bind(null,null),pe.then(me,me))}),pe&&typeof pe.then=="function"?le.resolve(pe):se.then(function(){return pe})}}),Wt.push(function(Zt){var $t,se,ue=Kt._cfg.dbschema;$t=ue,se=Zt,[].slice.call(se.db.objectStoreNames).forEach(function(Re){return $t[Re]==null&&se.db.deleteObjectStore(Re)}),zr(vt,[vt.Transaction.prototype]),Fl(vt,[vt.Transaction.prototype],vt._storeNames,vt._dbSchema),Lt.schema=vt._dbSchema}),Wt.push(function(Zt){vt.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(vt.idbdb.version/10)===Kt._cfg.version?(vt.idbdb.deleteObjectStore("$meta"),delete vt._dbSchema.$meta,vt._storeNames=vt._storeNames.filter(function($t){return $t!=="$meta"})):Zt.objectStore("$meta").put(Kt._cfg.version,"version"))})}),function Kt(){return Wt.length?le.resolve(Wt.shift()(Lt.idbtrans)).then(Kt):le.resolve()}().then(function(){Oa(It,Ut)})):le.resolve();var vt,Ft,Lt,Ut,Wt,It}).catch(Mt)):(s(ht).forEach(function(St){Fa(et,St,ht[St].primKey,ht[St].indexes)}),ko(V,et),void le.follow(function(){return V.on.populate.fire(pt)}).catch(Mt));var zt,ct})}function Ch(V,j){Oa(V._dbSchema,j),j.db.version%10!=0||j.objectStoreNames.contains("$meta")||j.db.createObjectStore("$meta").add(Math.ceil(j.db.version/10-1),"version");var et=Da(0,V.idbdb,j);Ia(V,V._dbSchema,j);for(var st=0,ht=Rn(et,V._dbSchema).change;stMath.pow(2,62)?0:It.oldVersion,vt=It<1,V.idbdb=Wt.result,pt&&Ch(V,St),gn(V,It/10,St,Lt))},Lt),Wt.onsuccess=di(function(){St=null;var It,Kt,Zt,$t,se,ue=V.idbdb=Wt.result,Re=c(ue.objectStoreNames);if(0"u"?le.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(Ft){function Lt(){return indexedDB.databases().finally(Ft)}zt=setInterval(Lt,100),Lt()}).finally(function(){return clearInterval(zt)}):Promise.resolve()).then(Nt)]).then(function(){return Mt(),j.onReadyBeingFired=[],le.resolve(Wr(function(){return V.on.ready.fire(V.vip)})).then(function Ft(){if(0j.limit?Ft.length=j.limit:V.length===j.limit&&Ft.length=Kt.limit&&(!Kt.values||ue.req.values)&&po(ue.req.query.range,Kt.query.range)}),!1,Zt,$t];case"count":return se=$t.find(function(ue){return _i(ue.req.query.range,Kt.query.range)}),[se,!!se,Zt,$t]}}(j,et,"query",pt),St=ct[0],vt=ct[1],Ft=ct[2],Lt=ct[3];return St&&vt?St.obsSet=pt.obsSet:(vt=st.query(pt).then(function(Ut){var Wt=Ut.result;if(St&&(St.res=Wt),Mt){for(var It=0,Kt=Wt.length;It{console.log(`Texture ${s} loaded successfully.`),this.addNPCToScene(t,E,x,T)}),t.load.start()}else throw new Error(`Sprite with ID ${E.spriteImageId} not found`)}}catch(E){E instanceof Error?console.error(`Failed to load NPC: ${E.message}`):console.error("Failed to load NPC:",E)}}addNPCToScene(t,i,x,T){try{console.log(`Adding NPC to scene: ${JSON.stringify(i)}`),console.log(`Using sprite key: ${i.spriteKey}`);const E=t.add.sprite(0,0,i.spriteKey);E.scale=i.scale||1.5,E.name=i.id||"Error Missing Name",console.log(`NPC Sprite created with texture key ${i.spriteKey} at position (${i.startPosition.x}, ${i.startPosition.y})`);const s={id:i.id,sprite:E,walkingAnimationMapping:i.walkingAnimationMapping,startPosition:{x:x??i.startPosition.x,y:T??i.startPosition.y},speed:i.speed};if(console.log(`Grid engine config: ${JSON.stringify(s)}`),!t.textures.exists(i.spriteKey))throw new Error(`Texture with key ${i.spriteKey} does not exist in the scene`);t.gridEngine.addCharacter(s),console.log(`NPC added to grid engine with ID ${i.id}`),((e,r,p)=>{const h=t.gridEngine.getPosition(e.name);console.log(`Attaching NPC events to ${r} at position: ${JSON.stringify(h)}`),k1.attachNPCEvent(e,r,p,{coords:h})})(E,i.name,i.actions.map(e=>({label:e}))),console.log(`NPC ${i.name} added to scene successfully`)}catch(E){E instanceof Error?console.error(`Error adding NPC to scene from addNPCToScene: ${E.message}`):console.error("Error adding NPC to scene:",E)}}}const Rx=new Gz;function YA(g){return+g[g.length-1]}function kA(g){return g.startsWith("monster_bird_")&&!g.startsWith("monster_bird_shadow")}function KA(g,t,i,x,T){const E=[];for(let s=0;s<10;s++){const y=g.add.sprite(0,0,"monster_bird");y.setCrop(t,i,x,T),y.scale=3,E.push(y)}return E}function jA(g){return KA(g,0,0,61,47)}function ZA(g){return KA(g,22,47,16,10)}function JA(g){g.anims.create({key:"bird",frames:g.anims.generateFrameNumbers("monster_bird",{start:0,end:2}),frameRate:10,repeat:-1,yoyo:!0})}class Vz extends jm.Scene{mainMenuButtonImage;mainMenuButtonText;constructor(){super("Preloader")}preload(){this.load.image("mainBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.image("scroll","https://kbve.com/assets/img/fishchip/scroll.webp"),this.load.audio("music","https://kbve.com/assets/img/fishchip/bg.ogg"),this.load.image("creditsBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.audio("type","https://kbve.com/assets/img/fishchip/type.mp3"),this.load.spritesheet("fishing","https://kbve.com/assets/img/fishchip/animate.png",{frameWidth:800,frameHeight:600}),this.load.image("fish","https://kbve.com/assets/img/letter_logo.png"),this.load.image("background","https://kbve.com/assets/img/fishchip/scaled_fish_menu_minigame.webp"),this.load.image("tiles","https://kbve.com/assets/img/fishchip/desert_tileset_1.png"),this.load.image("cloud-city-tiles","/assets/map/cloud_tileset.png"),this.load.tilemapTiledJSON("cloud-city-map-large","/assets/map/cloud_city_large.json"),this.load.tilemapTiledJSON("cloud-city-map","https://kbve.com/assets/img/fishchip/cloud_city.json"),this.load.spritesheet("player","https://kbve.com/assets/img/fishchip/chip_charactersheet_warmer.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("knights","/assets/entity/knights.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("jacko","/assets/entity/jacko.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("monks","/assets/entity/monks.png",{frameWidth:52,frameHeight:72}),EI()}async create(){await Rx.initializeDatabase(),this.sound.get("music")?.isPlaying||this.sound.add("music",{loop:!0,volume:.1}).play(),this.add.image(480,480,"mainBg").setScale(.1),this.mainMenuButtonImage=this.add.image(480,480,"scroll").setAlpha(.9).setScale(.7,.2).setInteractive({useHandCursor:!0}),this.mainMenuButtonText=this.add.text(480,480,"Start Game",{fontFamily:"Arial Black",fontSize:50,color:"#ffffff",stroke:"#000000",strokeThickness:6}).setOrigin(.5).setInteractive({useHandCursor:!0}),this.mainMenuButtonText.on("pointerdown",()=>{this.scene.start("SandCity")},this)}}let pG=class extends sd.GameObjects.Sprite{textBubble;tooltip};class Hz extends jm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"SandCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new du(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57}),Pi.emit("notification",{title:"Success",message:`You arrived safely to SandCity Passport: ${i1()}`,notificationType:Au.success})}async create(){const t=this.make.tilemap({key:"cloud-city-map"});t.addTilesetImage("Cloud City","tiles");for(let E=0;E({id:"monster_bird_"+s,sprite:E,startPosition:{x:7,y:7+s},speed:5,collides:!1})),...this.monsterBirdShadows.map((E,s)=>({id:"monster_bird_shadow_"+s,sprite:E,startPosition:{x:7,y:7+s},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new HA(this,this.gridEngine,this.quadtree),Iz(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!",3e3),await Rx.loadCharacter(this,"01J2DT4G871KJ0VNSHCNC5REDM"),await Rx.loadCharacter(this,"01J2HCTMQ58JBMJGW9YA3FBQCG",8,8),this.gridEngine.moveRandomly("npc",1500,3),this.gridEngine.moveRandomly("fishNpc",1500,3);for(let E=0;E<10;E++)this.gridEngine.moveRandomly("monster_bird_"+E,1e3,10);this.gridEngine.positionChangeStarted().subscribe(({charId:E,exitTile:s,enterTile:y})=>{kA(E)&&this.gridEngine.moveTo("monster_bird_shadow_"+YA(E),{x:y.x,y:y.y})});const T=(E,s,y)=>{const e=this.gridEngine.getPosition(E.name);k1.attachNPCEvent(E,s,y,{coords:e})};T(this.npcSprite,"FisherMan",[{label:"Talk"},{label:"Trade"},{label:"Move to"},{label:"Steal"},{label:"Combat"}]),T(this.fishNpcSprite,"Fish NPC Actions",[{label:"Check Fish"},{label:"Move to"}]),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Pi.emit("charEvent",i)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:()=>{const i={message:"Sign does not have much to say.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Pi.emit("charEvent",i)}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Pi.emit("charEvent",i)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Pi.emit("charEvent",i)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement()}}class mG extends sd.GameObjects.Sprite{textBubble}class Wz extends jm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"CloudCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new du(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57})}create(){const t=this.make.tilemap({key:"cloud-city-map-large"});t.addTilesetImage("cloud_tileset","cloud-city-tiles");for(let T=0;T({id:"monster_bird_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1})),...this.monsterBirdShadows.map((T,E)=>({id:"monster_bird_shadow_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new HA(this,this.gridEngine,this.quadtree),Nz(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!"),this.gridEngine.moveRandomly("npc",1500,3);for(let T=0;T<10;T++)this.gridEngine.moveRandomly("monster_bird_"+T,1e3,20);this.gridEngine.positionChangeStarted().subscribe(({charId:T,exitTile:E,enterTile:s})=>{kA(T)&&this.gridEngine.moveTo("monster_bird_shadow_"+YA(T),{x:s.x,y:s.y})}),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Pi.emit("charEvent",i)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:async()=>{try{const T={message:`The Database Response time: ${(await(await fetch("https://api.cryptothrone.com/api/v1/speed")).json()).message.time_ms} ms`,character_name:"Planets Be Scalin",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Pi.emit("charEvent",T)}catch(i){console.error("Error fetching data:",i);const x={message:"Sign does not have much to say. Failed to fetch response time.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Pi.emit("charEvent",x)}}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Pi.emit("charEvent",i)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Pi.emit("charEvent",i)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement(),this.npcSprite&&this.npcSprite.textBubble&&wx(this.npcSprite),this.fishNpcSprite&&this.fishNpcSprite.textBubble&&wx(this.fishNpcSprite)}}const Xz=cm.div` + `+pt:""),this.inner=pt||null):typeof ht=="object"&&(this.message="".concat(ht.name," ").concat(ht.message),this.inner=ht):(this.message=tt[j]||et,this.inner=null)}return u(st).from(_),V[j]=st,V},{});q.Syntax=SyntaxError,q.Type=TypeError,q.Range=RangeError;var at=ne.reduce(function(V,j){return V[j+"Error"]=q[j],V},{}),ot=lr.reduce(function(V,j){return["Syntax","Type","Range"].indexOf(j)===-1&&(V[j+"Error"]=q[j]),V},{});function rt(){}function gt(V){return V}function yt(V,j){return V==null||V===gt?j:function(et){return j(V(et))}}function Et(V,j){return function(){V.apply(this,arguments),j.apply(this,arguments)}}function At(V,j){return V===rt?j:function(){var et=V.apply(this,arguments);et!==void 0&&(arguments[0]=et);var st=this.onsuccess,ht=this.onerror;this.onsuccess=null,this.onerror=null;var pt=j.apply(this,arguments);return st&&(this.onsuccess=this.onsuccess?Et(st,this.onsuccess):st),ht&&(this.onerror=this.onerror?Et(ht,this.onerror):ht),pt!==void 0?pt:et}}function Pt(V,j){return V===rt?j:function(){V.apply(this,arguments);var et=this.onsuccess,st=this.onerror;this.onsuccess=this.onerror=null,j.apply(this,arguments),et&&(this.onsuccess=this.onsuccess?Et(et,this.onsuccess):et),st&&(this.onerror=this.onerror?Et(st,this.onerror):st)}}function Vt(V,j){return V===rt?j:function(et){var st=V.apply(this,arguments);e(et,st);var ht=this.onsuccess,pt=this.onerror;return this.onsuccess=null,this.onerror=null,et=j.apply(this,arguments),ht&&(this.onsuccess=this.onsuccess?Et(ht,this.onsuccess):ht),pt&&(this.onerror=this.onerror?Et(pt,this.onerror):pt),st===void 0?et===void 0?void 0:et:e(st,et)}}function dt(V,j){return V===rt?j:function(){return j.apply(this,arguments)!==!1&&V.apply(this,arguments)}}function ut(V,j){return V===rt?j:function(){var et=V.apply(this,arguments);if(et&&typeof et.then=="function"){for(var st=this,ht=arguments.length,pt=new Array(ht);ht--;)pt[ht]=arguments[ht];return et.then(function(){return j.apply(st,pt)})}return j.apply(this,arguments)}}ot.ModifyError=U,ot.DexieError=Y,ot.BulkError=H;var Rt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Dt(V){Rt=V}var Ht={},Bt=100,Gs=typeof Promise>"u"?[]:function(){var V=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[V,r(V),V];var j=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[j,r(j),V]}(),ne=Gs[0],lr=Gs[1],Gs=Gs[2],lr=lr&&lr.then,oe=ne&&ne.constructor,ge=!!Gs,xe=function(V,j){Ke.push([V,j]),qt&&(queueMicrotask(zi),qt=!1)},Ae=!0,qt=!0,Ge=[],Oe=[],Be=gt,Le={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:rt,pgp:!1,env:{},finalize:rt},ie=Le,Ke=[],ri=0,Ti=[];function le(V){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var j=this._PSD=ie;if(typeof V!="function"){if(V!==Ht)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Me(this,this._value))}this._state=null,this._value=null,++j.ref,function et(st,ht){try{ht(function(pt){if(st._state===null){if(pt===st)throw new TypeError("A promise cannot be resolved with itself.");var Mt=st._lib&&Di();pt&&typeof pt.then=="function"?et(st,function(Nt,zt){pt instanceof le?pt._then(Nt,zt):pt.then(Nt,zt)}):(st._state=!0,st._value=pt,Ce(st)),Mt&&en()}},Me.bind(null,st))}catch(pt){Me(st,pt)}}(this,V)}var xi={get:function(){var V=ie,j=Qr;function et(st,ht){var pt=this,Mt=!V.global&&(V!==ie||j!==Qr),Nt=Mt&&!xs(),zt=new le(function(ct,St){Ve(pt,new bt(ee(st,V,Mt,Nt),ee(ht,V,Mt,Nt),ct,St,V))});return this._consoleTask&&(zt._consoleTask=this._consoleTask),zt}return et.prototype=Ht,et},set:function(V){n(this,"then",V&&V.prototype===Ht?xi:{get:function(){return V},set:xi.set})}};function bt(V,j,et,st,ht){this.onFulfilled=typeof V=="function"?V:null,this.onRejected=typeof j=="function"?j:null,this.resolve=et,this.reject=st,this.psd=ht}function Me(V,j){var et,st;Oe.push(j),V._state===null&&(et=V._lib&&Di(),j=Be(j),V._state=!1,V._value=j,st=V,Ge.some(function(ht){return ht._value===st._value})||Ge.push(st),Ce(V),et&&en())}function Ce(V){var j=V._listeners;V._listeners=[];for(var et=0,st=j.length;et.",$e="String expected.",qe=[],ii="__dbnames",ai="readonly",Ji="readwrite";function hn(V,j){return V?j?function(){return V.apply(this,arguments)&&j.apply(this,arguments)}:V:j}var ki={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function gn(V){return typeof V!="string"||/\./.test(V)?function(j){return j}:function(j){return j[V]===void 0&&V in j&&delete(j=O(j))[V],j}}function ti(){throw q.Type()}function Se(V,j){try{var et=Nr(V),st=Nr(j);if(et!==st)return et==="Array"?1:st==="Array"?-1:et==="binary"?1:st==="binary"?-1:et==="string"?1:st==="string"?-1:et==="Date"?1:st!=="Date"?NaN:-1;switch(et){case"number":case"Date":case"string":return j$t+se&&Kt($t+Ft)})})}var Zt=Ki(et)&&et.limit===1/0&&(typeof V!="function"||V===La)&&{index:et.index,range:et.range};return Kt(0).then(function(){if(0=Ft})).length!==0?(St.forEach(function(Kt){Wt.push(function(){var Zt=It,$t=Kt._cfg.dbschema;Ia(vt,Zt,Ut),Ia(vt,$t,Ut),It=vt._dbSchema=$t;var se=Rn(Zt,$t);se.add.forEach(function(me){Fa(Ut,me[0],me[1].primKey,me[1].indexes)}),se.change.forEach(function(me){if(me.recreate)throw new q.Upgrade("Not yet support for changing primary key");var be=Ut.objectStore(me.name);me.add.forEach(function(_e){return En(be,_e)}),me.change.forEach(function(_e){be.deleteIndex(_e.name),En(be,_e)}),me.del.forEach(function(_e){return be.deleteIndex(_e)})});var ue=Kt._cfg.contentUpgrade;if(ue&&Kt._cfg.version>Ft){ko(vt,Ut),Lt._memoizedTables={};var Re=w($t);se.del.forEach(function(me){Re[me]=Zt[me]}),zr(vt,[vt.Transaction.prototype]),Fl(vt,[vt.Transaction.prototype],s(Re),Re),Lt.schema=Re;var pe,we=Q(ue);return we&&Us(),se=le.follow(function(){var me;(pe=ue(Lt))&&we&&(me=xs.bind(null,null),pe.then(me,me))}),pe&&typeof pe.then=="function"?le.resolve(pe):se.then(function(){return pe})}}),Wt.push(function(Zt){var $t,se,ue=Kt._cfg.dbschema;$t=ue,se=Zt,[].slice.call(se.db.objectStoreNames).forEach(function(Re){return $t[Re]==null&&se.db.deleteObjectStore(Re)}),zr(vt,[vt.Transaction.prototype]),Fl(vt,[vt.Transaction.prototype],vt._storeNames,vt._dbSchema),Lt.schema=vt._dbSchema}),Wt.push(function(Zt){vt.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(vt.idbdb.version/10)===Kt._cfg.version?(vt.idbdb.deleteObjectStore("$meta"),delete vt._dbSchema.$meta,vt._storeNames=vt._storeNames.filter(function($t){return $t!=="$meta"})):Zt.objectStore("$meta").put(Kt._cfg.version,"version"))})}),function Kt(){return Wt.length?le.resolve(Wt.shift()(Lt.idbtrans)).then(Kt):le.resolve()}().then(function(){Oa(It,Ut)})):le.resolve();var vt,Ft,Lt,Ut,Wt,It}).catch(Mt)):(s(ht).forEach(function(St){Fa(et,St,ht[St].primKey,ht[St].indexes)}),ko(V,et),void le.follow(function(){return V.on.populate.fire(pt)}).catch(Mt));var zt,ct})}function Ch(V,j){Oa(V._dbSchema,j),j.db.version%10!=0||j.objectStoreNames.contains("$meta")||j.db.createObjectStore("$meta").add(Math.ceil(j.db.version/10-1),"version");var et=Da(0,V.idbdb,j);Ia(V,V._dbSchema,j);for(var st=0,ht=Rn(et,V._dbSchema).change;stMath.pow(2,62)?0:It.oldVersion,vt=It<1,V.idbdb=Wt.result,pt&&Ch(V,St),yn(V,It/10,St,Lt))},Lt),Wt.onsuccess=di(function(){St=null;var It,Kt,Zt,$t,se,ue=V.idbdb=Wt.result,Re=c(ue.objectStoreNames);if(0"u"?le.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(Ft){function Lt(){return indexedDB.databases().finally(Ft)}zt=setInterval(Lt,100),Lt()}).finally(function(){return clearInterval(zt)}):Promise.resolve()).then(Nt)]).then(function(){return Mt(),j.onReadyBeingFired=[],le.resolve(Wr(function(){return V.on.ready.fire(V.vip)})).then(function Ft(){if(0j.limit?Ft.length=j.limit:V.length===j.limit&&Ft.length=Kt.limit&&(!Kt.values||ue.req.values)&&po(ue.req.query.range,Kt.query.range)}),!1,Zt,$t];case"count":return se=$t.find(function(ue){return _i(ue.req.query.range,Kt.query.range)}),[se,!!se,Zt,$t]}}(j,et,"query",pt),St=ct[0],vt=ct[1],Ft=ct[2],Lt=ct[3];return St&&vt?St.obsSet=pt.obsSet:(vt=st.query(pt).then(function(Ut){var Wt=Ut.result;if(St&&(St.res=Wt),Mt){for(var It=0,Kt=Wt.length;It{console.log(`Texture ${s} loaded successfully.`),this.addNPCToScene(t,E,x,T)}),t.load.start()}else throw new Error(`Sprite with ID ${E.spriteImageId} not found`)}}catch(E){E instanceof Error?console.error(`Failed to load NPC: ${E.message}`):console.error("Failed to load NPC:",E)}}addNPCToScene(t,i,x,T){try{console.log(`Adding NPC to scene: ${JSON.stringify(i)}`),console.log(`Using sprite key: ${i.spriteKey}`);const E=t.add.sprite(0,0,i.spriteKey);E.scale=i.scale||1.5,E.name=i.id||"Error Missing Name",console.log(`NPC Sprite created with texture key ${i.spriteKey} at position (${i.startPosition.x}, ${i.startPosition.y})`);const s={id:i.id,sprite:E,walkingAnimationMapping:i.walkingAnimationMapping,startPosition:{x:x??i.startPosition.x,y:T??i.startPosition.y},speed:i.speed};if(console.log(`Grid engine config: ${JSON.stringify(s)}`),!t.textures.exists(i.spriteKey))throw new Error(`Texture with key ${i.spriteKey} does not exist in the scene`);t.gridEngine.addCharacter(s),console.log(`NPC added to grid engine with ID ${i.id}`),((e,r,p)=>{const h=t.gridEngine.getPosition(e.name);console.log(`Attaching NPC events to ${r} at position: ${JSON.stringify(h)}`),k1.attachNPCEvent(e,r,p,{coords:h})})(E,i.name,i.actions.map(e=>({label:e}))),console.log(`NPC ${i.name} added to scene successfully`)}catch(E){E instanceof Error?console.error(`Error adding NPC to scene from addNPCToScene: ${E.message}`):console.error("Error adding NPC to scene:",E)}}async addDialogue(t){await this.dialogues.put(t)}async getDialogue(t){return await this.dialogues.get(t)}async getAllDialogues(){return await this.dialogues.toArray()}async getDialoguesForNPC(t){const i=await this.getNPC(t);if(!i)throw new Error;return(await Promise.all((i.dialogues||[]).map(T=>this.getDialogue(T.dialogueId)))).filter(T=>T!==void 0)}async markDialogueAsRead(t,i){const x=await this.getNPC(t);if(!x)throw new Error(`NPC with ID ${t} not found`);const T=x.dialogues?.find(E=>E.dialogueId===i);T&&(T.read=!0,await this.addNPC(x))}async fetchDialogues(t){try{const x=(await mn.get(t)).data.key,T=Object.values(x).map(E=>({...E}));await this.dialogues.bulkPut(T)}catch(i){console.error(`Failed to fetch dialogues from ${t}:`,i)}}}const um=new Gz;function YA(g){return+g[g.length-1]}function kA(g){return g.startsWith("monster_bird_")&&!g.startsWith("monster_bird_shadow")}function KA(g,t,i,x,T){const E=[];for(let s=0;s<10;s++){const y=g.add.sprite(0,0,"monster_bird");y.setCrop(t,i,x,T),y.scale=3,E.push(y)}return E}function jA(g){return KA(g,0,0,61,47)}function ZA(g){return KA(g,22,47,16,10)}function JA(g){g.anims.create({key:"bird",frames:g.anims.generateFrameNumbers("monster_bird",{start:0,end:2}),frameRate:10,repeat:-1,yoyo:!0})}class Vz extends Zm.Scene{mainMenuButtonImage;mainMenuButtonText;constructor(){super("Preloader")}preload(){this.load.image("mainBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.image("scroll","https://kbve.com/assets/img/fishchip/scroll.webp"),this.load.audio("music","https://kbve.com/assets/img/fishchip/bg.ogg"),this.load.image("creditsBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.audio("type","https://kbve.com/assets/img/fishchip/type.mp3"),this.load.spritesheet("fishing","https://kbve.com/assets/img/fishchip/animate.png",{frameWidth:800,frameHeight:600}),this.load.image("fish","https://kbve.com/assets/img/letter_logo.png"),this.load.image("background","https://kbve.com/assets/img/fishchip/scaled_fish_menu_minigame.webp"),this.load.image("tiles","https://kbve.com/assets/img/fishchip/desert_tileset_1.png"),this.load.image("cloud-city-tiles","/assets/map/cloud_tileset.png"),this.load.tilemapTiledJSON("cloud-city-map-large","/assets/map/cloud_city_large.json"),this.load.tilemapTiledJSON("cloud-city-map","https://kbve.com/assets/img/fishchip/cloud_city.json"),this.load.spritesheet("player","https://kbve.com/assets/img/fishchip/chip_charactersheet_warmer.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("knights","/assets/entity/knights.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("jacko","/assets/entity/jacko.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("monks","/assets/entity/monks.png",{frameWidth:52,frameHeight:72}),EI()}async create(){await um.initializeDatabase(),this.sound.get("music")?.isPlaying||this.sound.add("music",{loop:!0,volume:.1}).play(),this.add.image(480,480,"mainBg").setScale(.1),this.mainMenuButtonImage=this.add.image(480,480,"scroll").setAlpha(.9).setScale(.7,.2).setInteractive({useHandCursor:!0}),this.mainMenuButtonText=this.add.text(480,480,"Start Game",{fontFamily:"Arial Black",fontSize:50,color:"#ffffff",stroke:"#000000",strokeThickness:6}).setOrigin(.5).setInteractive({useHandCursor:!0}),this.mainMenuButtonText.on("pointerdown",()=>{this.scene.start("SandCity")},this)}}let pG=class extends sd.GameObjects.Sprite{textBubble;tooltip};class Hz extends Zm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"SandCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new du(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57}),Pi.emit("notification",{title:"Success",message:`You arrived safely to SandCity Passport: ${i1()}`,notificationType:Au.success})}async create(){const t=this.make.tilemap({key:"cloud-city-map"});t.addTilesetImage("Cloud City","tiles");for(let E=0;E({id:"monster_bird_"+s,sprite:E,startPosition:{x:7,y:7+s},speed:5,collides:!1})),...this.monsterBirdShadows.map((E,s)=>({id:"monster_bird_shadow_"+s,sprite:E,startPosition:{x:7,y:7+s},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new HA(this,this.gridEngine,this.quadtree),Iz(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!",3e3),await um.loadCharacter(this,"01J2DT4G871KJ0VNSHCNC5REDM"),await um.loadCharacter(this,"01J2HCTMQ58JBMJGW9YA3FBQCG",8,8),await um.loadCharacter(this,"01J2HQJBMBGEEMWDBDWATRCY3T",8,15),this.gridEngine.moveRandomly("npc",1500,3),this.gridEngine.moveRandomly("fishNpc",1500,3);for(let E=0;E<10;E++)this.gridEngine.moveRandomly("monster_bird_"+E,1e3,10);this.gridEngine.positionChangeStarted().subscribe(({charId:E,exitTile:s,enterTile:y})=>{kA(E)&&this.gridEngine.moveTo("monster_bird_shadow_"+YA(E),{x:y.x,y:y.y})});const T=(E,s,y)=>{const e=this.gridEngine.getPosition(E.name);k1.attachNPCEvent(E,s,y,{coords:e})};T(this.npcSprite,"FisherMan",[{label:"Talk"},{label:"Trade"},{label:"Move to"},{label:"Steal"},{label:"Combat"}]),T(this.fishNpcSprite,"Fish NPC Actions",[{label:"Check Fish"},{label:"Move to"}]),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Pi.emit("charEvent",i)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:()=>{const i={message:"Sign does not have much to say.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Pi.emit("charEvent",i)}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Pi.emit("charEvent",i)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Pi.emit("charEvent",i)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement()}}class mG extends sd.GameObjects.Sprite{textBubble}class Wz extends Zm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"CloudCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new du(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57})}create(){const t=this.make.tilemap({key:"cloud-city-map-large"});t.addTilesetImage("cloud_tileset","cloud-city-tiles");for(let T=0;T({id:"monster_bird_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1})),...this.monsterBirdShadows.map((T,E)=>({id:"monster_bird_shadow_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new HA(this,this.gridEngine,this.quadtree),Nz(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!"),this.gridEngine.moveRandomly("npc",1500,3);for(let T=0;T<10;T++)this.gridEngine.moveRandomly("monster_bird_"+T,1e3,20);this.gridEngine.positionChangeStarted().subscribe(({charId:T,exitTile:E,enterTile:s})=>{kA(T)&&this.gridEngine.moveTo("monster_bird_shadow_"+YA(T),{x:s.x,y:s.y})}),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Pi.emit("charEvent",i)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:async()=>{try{const T={message:`The Database Response time: ${(await(await fetch("https://api.cryptothrone.com/api/v1/speed")).json()).message.time_ms} ms`,character_name:"Planets Be Scalin",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Pi.emit("charEvent",T)}catch(i){console.error("Error fetching data:",i);const x={message:"Sign does not have much to say. Failed to fetch response time.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Pi.emit("charEvent",x)}}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Pi.emit("charEvent",i)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Pi.emit("charEvent",i)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement(),this.npcSprite&&this.npcSprite.textBubble&&Ax(this.npcSprite),this.fishNpcSprite&&this.fishNpcSprite.textBubble&&Ax(this.fishNpcSprite)}}const Xz=dm.div` // Your style here -`;function Yz(){const g=Pe.useRef(null);return Pe.useEffect(()=>{if(g.current){const t=g.current,x={...{title:"CryptoThrone",render:{antialias:!1},scale:{mode:sd.Scale.RESIZE,min:{width:1024,height:768},max:{width:1600,height:1200},zoom:1},type:sd.AUTO,transparent:!0,width:800,height:600,physics:{default:"arcade",arcade:{gravity:{x:0,y:0},debug:!1}},plugins:{scene:[{key:"gridEngine",plugin:X4,mapping:"gridEngine"}]},scene:[Vz,Hz,Wz],input:{mouse:{preventDefaultWheel:!1},touch:{capture:!1}}},parent:t},T=new sd.Game(x);return()=>{T.destroy(!0)}}},[]),he.jsx(Xz,{children:he.jsx("div",{ref:g})})}const TM=bx({message:""}),kz=()=>{const g=Tl(TM);Pe.useEffect(()=>{const i=x=>{if(x){TM.set(x);const T=document.querySelector("#hs-stacked-overlays");T&&(T.classList.remove("hidden"),T.classList.add("open"))}};return Pi.on("charEvent",i),()=>{Pi.off("charEvent",i)}},[]);const t=()=>{const i=document.querySelector("#hs-stacked-overlays");i&&(i.classList.add("hidden"),i.classList.remove("open"))};return he.jsx(he.Fragment,{children:he.jsx("div",{id:"hs-stacked-overlays",className:"hs-overlay hs-overlay-backdrop-open:bg-gray-900/50 hidden size-full fixed top-0 start-0 z-[60] overflow-x-hidden overflow-y-auto pointer-events-none [--overlay-backdrop:static]","data-hs-overlay-keyboard":"false",children:he.jsx("div",{className:"hs-overlay-open:mt-7 hs-overlay-open:opacity-100 hs-overlay-open:duration-500 mt-0 opacity-0 ease-out transition-all sm:max-w-lg sm:w-full m-3 sm:mx-auto",children:he.jsxs("div",{className:"flex flex-col lg:flex-row bg-zinc-950 border border-yellow-500 shadow-sm rounded-xl pointer-events-auto bg-cover",style:{backgroundImage:`url(${g.background_image||"https://kbve.com/assets/img/curved-images/wave.jpg"})`},children:[he.jsxs("div",{className:"w-full lg:w-1/3 p-4 rounded-l-xl flex flex-col items-center justify-center",children:[he.jsx("h3",{className:"font-bold text-yellow-400 bg-zinc-950/80 rounded-2xl text-center mb-4",children:`${g.character_name||"NPC"}`}),he.jsx("img",{src:g.character_image||"/assets/npc/barkeep.webp",alt:"Character",className:"w-full h-auto rounded-md"})]}),he.jsxs("div",{className:"w-full lg:w-2/3 p-4 bg-cover bg-center rounded-r-xl",children:[he.jsxs("div",{className:"flex justify-between items-center pb-3 border-b",children:[he.jsx("h3",{className:"font-bold text-yellow-400",children:""}),he.jsxs("button",{type:"button",className:"flex justify-center items-center size-7 text-sm font-semibold rounded-full border border-transparent text-yellow-400 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays",onClick:t,children:[he.jsx("span",{className:"sr-only",children:"Close"}),he.jsxs("svg",{className:"flex-shrink-0 size-4",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",children:[he.jsx("path",{d:"M18 6 6 18"}),he.jsx("path",{d:"m6 6 12 12"})]})]})]}),he.jsx("div",{className:"p-4 overflow-y-auto",children:he.jsx("p",{className:"mt-1 mb-2 text-yellow-400 bg-zinc-950/80 rounded-xl p-4",children:g.message||"No Message"})}),he.jsx("div",{className:"flex justify-end items-center gap-x-2 py-3 px-4 border-t",children:he.jsxs("button",{className:"relative rounded px-5 py-2.5 overflow-hidden group bg-yellow-500 relative hover:bg-gradient-to-r hover:from-yellow-500 hover:to-yellow-400 text-white hover:ring-2 hover:ring-offset-2 hover:ring-yellow-400 transition-all ease-out duration-300 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays",onClick:t,children:[he.jsx("span",{className:"absolute right-0 w-8 h-32 -mt-12 transition-all duration-1000 transform translate-x-12 bg-white opacity-10 rotate-12 group-hover:-translate-x-40 ease"}),he.jsx("span",{className:"relative",children:"Okay."})]})})]})]})})})})},Kz=(g,t)=>{const i=yl(g);return i?he.jsxs("div",{style:{top:t.y,left:t.x},className:"absolute bg-gray-700 text-white p-2 rounded shadow-lg z-50",children:[he.jsx("p",{className:"text-sm font-semibold",children:i.name}),he.jsxs("p",{className:"text-xs",children:["Type: ",i.type]}),he.jsxs("p",{className:"text-xs",children:["Bonuses: ",JSON.stringify(i.bonuses)]}),he.jsxs("p",{className:"text-xs",children:["Durability: ",i.durability]}),he.jsxs("p",{className:"text-xs",children:["Weight: ",i.weight]})]}):null},jz=(g,t,i,x)=>he.jsx("ul",{className:"grid grid-cols-8 gap-2",children:Object.keys(g).map(T=>{const E=g[T];return Zz(E,t,i,x)})}),Zz=(g,t,i,x)=>{if(!g)return he.jsx("li",{className:"text-sm relative flex items-center justify-center border border-gray-500 bg-gray-200",style:{width:"32px",height:"32px"}},`empty-${Math.random()}`);const T=yl(g);return T?he.jsxs("li",{className:"text-sm relative",onMouseEnter:E=>t(T.id,E),onMouseLeave:i,onClick:E=>x(T.id,E),children:[T.name," (",T.type,") - Bonuses: ",JSON.stringify(T.bonuses)," - Durability: ",T.durability," - Weight: ",T.weight]},T.id):null},Jz=(g,t,i,x)=>he.jsx("ul",{className:"grid grid-cols-8 gap-1",children:g.map((T,E)=>{const s=yl(T);return s?he.jsx("li",{className:"text-sm relative hover:scale-[1.3] transition ease-in-out duration-100",onMouseEnter:y=>t(s.id,y),onMouseLeave:i,onClick:y=>x(s.id,y),children:he.jsx("img",{src:s.img,alt:s.name,style:{width:"32px",height:"32px"},className:"inline-block border border-yellow-400/50"})},E):null})}),$z=()=>{const g=Tl(Sn);Tl(mm),Tl(TI),Tl(Zr),Pe.useEffect(()=>{const r=p=>{};return Pi.on("playerEvent",r),()=>{Pi.off("playerEvent",r)}},[]);const t=(r,p)=>{Wc("tooltipItem",{id:r,position:{x:p.clientX+10,y:p.clientY-150}})},i=()=>{Wc("tooltipItem",{...Jh("tooltipItem"),id:null})},x=(r,p)=>{Wc("submenuItem",{id:r,position:{x:p.clientX,y:p.clientY-150}})},T=()=>{Wc("submenuItem",{...Jh("submenuItem"),id:null})},E=(r,p)=>{const h=yl(r);if(h){const a={itemId:h.id,action:p};Pi.emit("itemAction",a),T()}};if(!g||!g.stats)return null;const s=Jh("submenuItem"),y=s.id?BI(s.id):[],e=Jh("tooltipItem");return he.jsxs("div",{className:"fixed top-24 left-3 w-[350px] p-4 bg-zinc-800 text-yellow-400 border border-yellow-300 rounded-lg z-20 transition transform ease-in-out duration-500 opacity-50 hover:opacity-100",children:[he.jsx("button",{onClick:()=>Wc("isStatsMenuCollapsed",!Jh("isStatsMenuCollapsed")),className:"bg-yellow-500 text-white p-2 rounded",children:Jh("isStatsMenuCollapsed")?he.jsx(HI,{styleClass:"w-8"}):he.jsx(VI,{styleClass:"w-8"})}),he.jsxs("div",{className:`transition transform duration-1000 ease-in-out ${Jh("isStatsMenuCollapsed")?"max-h-0 overflow-hidden":"max-h-screen"}`,children:[he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Stats"}),he.jsx("p",{className:"text-sm text-green-400",children:`HP: ${g.stats.health||"0"} / ${g.stats.maxHealth}`}),he.jsx("p",{className:"text-sm text-blue-400",children:`MP: ${g.stats.mana||"0"} / ${g.stats.maxMana}`}),he.jsx("p",{className:"text-sm text-yellow-400",children:`EP: ${g.stats.energy||"0"} / ${g.stats.maxEnergy}`})]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"User Information"}),he.jsx("p",{className:"text-sm",children:g.stats.username||"Guest"})]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"General Information"}),he.jsx("p",{className:"text-sm",children:""})]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Inventory"}),Jz(g.inventory.backpack,t,i,x)]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Equipment"}),jz(g.inventory.equipment,t,i,x)]}),e.id&&Kz(e.id,e.position),s.id&&he.jsxs("div",{style:{top:s.position.y,left:s.position.x},className:"absolute bg-gray-700 text-white p-2 rounded shadow-lg z-50",children:[he.jsx("button",{onClick:T,className:"absolute top-1 right-1 translate-x-6 bg-yellow-400 p-1 text-white hover:text-gray-400",children:"X"}),he.jsx("p",{className:"text-sm strong",children:"Actions:"}),he.jsxs("ul",{className:"text-xs",children:[y.map(r=>he.jsx("li",{onClick:()=>s.id&&E(s.id,r),className:"cursor-pointer hover:bg-gray-600",children:r.charAt(0).toUpperCase()+r.slice(1)},r)),he.jsx("li",{onClick:T,className:"cursor-pointer hover:bg-gray-600",children:"Close"})]})]})]})]})},cy=bx(null),dy=bx(null),Qz=()=>{const g=Tl(cy),[t,i]=Pe.useState({x:0,y:0});Pe.useEffect(()=>{const y=e=>{e&&(cy.set(e),i(x(e.coords.x,e.coords.y)))};return Pi.on("npcInteractionClick",y),()=>{Pi.off("npcInteractionClick",y)}},[]);const x=(y,e)=>{let n=y+250,u=e+250;return n+200>window.innerWidth-10&&(n=window.innerWidth-200-10),u+200>window.innerHeight-10&&(u=window.innerHeight-200-10),n<10&&(n=10),u<10&&(u=10),{x:n,y:u}},T=y=>{if(g){const e=k1.getActionHandler(y);e&&(e(g),E())}},E=()=>{cy.set(null)},s=()=>{if(!g)return null;const{npcName:y,actions:e,npcId:r}=g,{x:p,y:h}=t;return he.jsxs("div",{className:"absolute bg-zinc-900 border border-yellow-300 rounded-md p-2 z-50 transition transform ease-in-out duration-500 opacity-50 hover:opacity-100",style:{left:`${p}px`,top:`${h}px`,transform:"translate(-50%, -100%)"},children:[he.jsxs("div",{className:"flex justify-between items-center mb-2",children:[he.jsx("h3",{className:"font-bold text-sm",children:y}),he.jsx("button",{onClick:E,className:"text-xs font-bold m-1 text-yellow-300 hover:text-yellow-500",children:"X"})]}),e.map((a,l)=>he.jsx("button",{onClick:()=>T(a),className:"block w-full text-xs py-1 px-2 mb-1 bg-yellow-500 hover:bg-yellow-400 rounded",children:a},l)),he.jsx("button",{onClick:E,className:"block w-full text-xs py-1 px-2 mt-2 bg-red-500 hover:bg-red-600 rounded text-white",children:"Close"})]},r)};return he.jsx("div",{children:s()})},_z=()=>{const g=Tl(Zh);Pe.useEffect(()=>{const i=x=>{if(x){const T=Date.now()+Math.random();Zh.set([...Zh.get(),{id:T,...x}]),setTimeout(()=>{Zh.set(Zh.get().filter(E=>E.id!==T))},5e3)}};return Pi.on("notification",i),()=>{Pi.off("notification",i)}},[]);const t=i=>{Zh.set(Zh.get().filter(x=>x.id!==i))};return he.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 m-4 space-y-2",children:Array.isArray(g)&&g.map(i=>he.jsx("div",{className:`hs-removing:translate-x-5 hs-removing:opacity-0 transition duration-300 max-w-xs border rounded-xl shadow-lg ${i.notificationType.color}`,role:"alert",children:he.jsxs("div",{className:"flex p-4",children:[he.jsx("img",{src:i.notificationType.imgUrl,alt:i.notificationType.type,className:"flex-shrink-0 size-4"}),he.jsxs("div",{className:"ms-2",children:[he.jsx("h3",{className:"text-sm font-bold",children:i.title}),he.jsx("p",{className:"text-sm",children:i.message})]}),he.jsx("div",{className:"ms-auto",children:he.jsxs("button",{type:"button",className:"inline-flex flex-shrink-0 justify-center items-center size-5 rounded-lg text-gray-800 opacity-50 hover:opacity-100 focus:outline-none focus:opacity-100 dark:text-white",onClick:()=>t(i.id),children:[he.jsx("span",{className:"sr-only",children:"Close"}),he.jsxs("svg",{className:"flex-shrink-0 size-4 bg-zinc-900",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",children:[he.jsx("path",{d:"M18 6 6 18"}),he.jsx("path",{d:"m6 6 12 12"})]})]})})]})},i.id))})},qz=()=>{const g=Tl(dy),[t,i]=Pe.useState([]),[x,T]=Pe.useState(null);Pe.useEffect(()=>{const y=r=>{r&&dy.set(r)},e=r=>{r&&i(r.diceValues)};return Pi.on("playerSteal",y),Pi.on("diceRollResult",e),()=>{Pi.off("playerSteal",y),Pi.off("diceRollResult",e)}},[]),Pe.useEffect(()=>{t.length>0&&E(t)},[t]);const E=y=>{const e=y.reduce((a,l)=>a+l,0);if(T(e),!g)return;let r="",p="";switch(!0){case e===12:r="01J27QABD2GPFNRVK69S51HSGB",p=`You successfully stole a ${r}!`;break;case e===11:r="01J27QN2KZG1RDZW4CE9Q9Z3YQ",p=`You successfully stole a ${r}!`;break;case e===10:r="01J269PK47V1DWX2S1251DEASD",p=`You successfully stole a ${r}!`;break;case e===9:r="Blue Shark",p=`You successfully stole a ${r}!`;break;case e>=7:r="Salmon",p=`You successfully stole a ${r}!`;break;case e===2:Pi.emit("notification",{title:"Danger",message:`You crit failed to steal from ${g.npcName}!`,notificationType:Au.danger}),Pi.emit("playerDamage",{damage:"5"});break;default:Pi.emit("notification",{title:"Danger",message:`You failed to steal from ${g.npcName}!`,notificationType:Au.danger}),Pi.emit("playerDamage",{damage:"1"});return}const h=MI(r);h?Pi.emit("playerReward",{message:p,item:h}):console.warn("Item not found in ItemDB")},s=()=>{l2([]),i([]),T(null),dy.set(null)};return g?he.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50 bg-zinc-800 bg-opacity-50",children:he.jsxs("div",{className:"bg-zinc-800 p-4 rounded-lg shadow-lg max-w-xs w-full",children:[he.jsx(tG,{npcName:g.npcName,roll:x}),he.jsx(iG,{}),he.jsx(nG,{handleClose:s})]})}):null},tG=({npcName:g,roll:t})=>he.jsxs("div",{children:[he.jsx("h2",{className:"text-lg text-yellow-400 font-bold mb-4",children:"Steal Attempt"}),he.jsxs("p",{className:"mb-4",children:["Roll the dice to steal from ",g,". You need a total of 7 or higher to succeed."]}),t!==null&&he.jsxs("p",{className:"mb-4",children:["Your roll: ",t]})]}),eG=()=>he.jsx(Dz,{textures:{side1:"/assets/items/set/dice/dice1.png",side2:"/assets/items/set/dice/dice2.png",side3:"/assets/items/set/dice/dice3.png",side4:"/assets/items/set/dice/dice4.png",side5:"/assets/items/set/dice/dice5.png",side6:"/assets/items/set/dice/dice6.png"},styleClass:"h-96",diceCount:2}),iG=Pe.memo(eG),nG=({handleClose:g})=>he.jsx("button",{onClick:g,className:"block w-full py-2 bg-red-500 text-white rounded hover:bg-red-700 mt-2",children:"Close"}),rG=cm.div` +`;function Yz(){const g=Pe.useRef(null);return Pe.useEffect(()=>{if(g.current){const t=g.current,x={...{title:"CryptoThrone",render:{antialias:!1},scale:{mode:sd.Scale.RESIZE,min:{width:1024,height:768},max:{width:1600,height:1200},zoom:1},type:sd.AUTO,transparent:!0,width:800,height:600,physics:{default:"arcade",arcade:{gravity:{x:0,y:0},debug:!1}},plugins:{scene:[{key:"gridEngine",plugin:X4,mapping:"gridEngine"}]},scene:[Vz,Hz,Wz],input:{mouse:{preventDefaultWheel:!1},touch:{capture:!1}}},parent:t},T=new sd.Game(x);return()=>{T.destroy(!0)}}},[]),he.jsx(Xz,{children:he.jsx("div",{ref:g})})}const TM=bx({message:""}),kz=()=>{const g=Tl(TM);Pe.useEffect(()=>{const i=x=>{if(x){TM.set(x);const T=document.querySelector("#hs-stacked-overlays");T&&(T.classList.remove("hidden"),T.classList.add("open"))}};return Pi.on("charEvent",i),()=>{Pi.off("charEvent",i)}},[]);const t=()=>{const i=document.querySelector("#hs-stacked-overlays");i&&(i.classList.add("hidden"),i.classList.remove("open"))};return he.jsx(he.Fragment,{children:he.jsx("div",{id:"hs-stacked-overlays",className:"hs-overlay hs-overlay-backdrop-open:bg-gray-900/50 hidden size-full fixed top-0 start-0 z-[60] overflow-x-hidden overflow-y-auto pointer-events-none [--overlay-backdrop:static]","data-hs-overlay-keyboard":"false",children:he.jsx("div",{className:"hs-overlay-open:mt-7 hs-overlay-open:opacity-100 hs-overlay-open:duration-500 mt-0 opacity-0 ease-out transition-all sm:max-w-lg sm:w-full m-3 sm:mx-auto",children:he.jsxs("div",{className:"flex flex-col lg:flex-row bg-zinc-950 border border-yellow-500 shadow-sm rounded-xl pointer-events-auto bg-cover",style:{backgroundImage:`url(${g.background_image||"https://kbve.com/assets/img/curved-images/wave.jpg"})`},children:[he.jsxs("div",{className:"w-full lg:w-1/3 p-4 rounded-l-xl flex flex-col items-center justify-center",children:[he.jsx("h3",{className:"font-bold text-yellow-400 bg-zinc-950/80 rounded-2xl text-center mb-4",children:`${g.character_name||"NPC"}`}),he.jsx("img",{src:g.character_image||"/assets/npc/barkeep.webp",alt:"Character",className:"w-full h-auto rounded-md"})]}),he.jsxs("div",{className:"w-full lg:w-2/3 p-4 bg-cover bg-center rounded-r-xl",children:[he.jsxs("div",{className:"flex justify-between items-center pb-3 border-b",children:[he.jsx("h3",{className:"font-bold text-yellow-400",children:""}),he.jsxs("button",{type:"button",className:"flex justify-center items-center size-7 text-sm font-semibold rounded-full border border-transparent text-yellow-400 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays",onClick:t,children:[he.jsx("span",{className:"sr-only",children:"Close"}),he.jsxs("svg",{className:"flex-shrink-0 size-4",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",children:[he.jsx("path",{d:"M18 6 6 18"}),he.jsx("path",{d:"m6 6 12 12"})]})]})]}),he.jsx("div",{className:"p-4 overflow-y-auto",children:he.jsx("p",{className:"mt-1 mb-2 text-yellow-400 bg-zinc-950/80 rounded-xl p-4",children:g.message||"No Message"})}),he.jsx("div",{className:"flex justify-end items-center gap-x-2 py-3 px-4 border-t",children:he.jsxs("button",{className:"relative rounded px-5 py-2.5 overflow-hidden group bg-yellow-500 relative hover:bg-gradient-to-r hover:from-yellow-500 hover:to-yellow-400 text-white hover:ring-2 hover:ring-offset-2 hover:ring-yellow-400 transition-all ease-out duration-300 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays",onClick:t,children:[he.jsx("span",{className:"absolute right-0 w-8 h-32 -mt-12 transition-all duration-1000 transform translate-x-12 bg-white opacity-10 rotate-12 group-hover:-translate-x-40 ease"}),he.jsx("span",{className:"relative",children:"Okay."})]})})]})]})})})})},Kz=(g,t)=>{const i=yl(g);return i?he.jsxs("div",{style:{top:t.y,left:t.x},className:"absolute bg-gray-700 text-white p-2 rounded shadow-lg z-50",children:[he.jsx("p",{className:"text-sm font-semibold",children:i.name}),he.jsxs("p",{className:"text-xs",children:["Type: ",i.type]}),he.jsxs("p",{className:"text-xs",children:["Bonuses: ",JSON.stringify(i.bonuses)]}),he.jsxs("p",{className:"text-xs",children:["Durability: ",i.durability]}),he.jsxs("p",{className:"text-xs",children:["Weight: ",i.weight]})]}):null},jz=(g,t,i,x)=>he.jsx("ul",{className:"grid grid-cols-8 gap-2",children:Object.keys(g).map(T=>{const E=g[T];return Zz(E,t,i,x)})}),Zz=(g,t,i,x)=>{if(!g)return he.jsx("li",{className:"text-sm relative flex items-center justify-center border border-gray-500 bg-gray-200",style:{width:"32px",height:"32px"}},`empty-${Math.random()}`);const T=yl(g);return T?he.jsxs("li",{className:"text-sm relative",onMouseEnter:E=>t(T.id,E),onMouseLeave:i,onClick:E=>x(T.id,E),children:[T.name," (",T.type,") - Bonuses: ",JSON.stringify(T.bonuses)," - Durability: ",T.durability," - Weight: ",T.weight]},T.id):null},Jz=(g,t,i,x)=>he.jsx("ul",{className:"grid grid-cols-8 gap-1",children:g.map((T,E)=>{const s=yl(T);return s?he.jsx("li",{className:"text-sm relative hover:scale-[1.3] transition ease-in-out duration-100",onMouseEnter:y=>t(s.id,y),onMouseLeave:i,onClick:y=>x(s.id,y),children:he.jsx("img",{src:s.img,alt:s.name,style:{width:"32px",height:"32px"},className:"inline-block border border-yellow-400/50"})},E):null})}),$z=()=>{const g=Tl(Sn);Tl(gm),Tl(TI),Tl(Zr),Pe.useEffect(()=>{const r=p=>{};return Pi.on("playerEvent",r),()=>{Pi.off("playerEvent",r)}},[]);const t=(r,p)=>{Wc("tooltipItem",{id:r,position:{x:p.clientX+10,y:p.clientY-150}})},i=()=>{Wc("tooltipItem",{...Jh("tooltipItem"),id:null})},x=(r,p)=>{Wc("submenuItem",{id:r,position:{x:p.clientX,y:p.clientY-150}})},T=()=>{Wc("submenuItem",{...Jh("submenuItem"),id:null})},E=(r,p)=>{const h=yl(r);if(h){const a={itemId:h.id,action:p};Pi.emit("itemAction",a),T()}};if(!g||!g.stats)return null;const s=Jh("submenuItem"),y=s.id?BI(s.id):[],e=Jh("tooltipItem");return he.jsxs("div",{className:"fixed top-24 left-3 w-[350px] p-4 bg-zinc-800 text-yellow-400 border border-yellow-300 rounded-lg z-20 transition transform ease-in-out duration-500 opacity-50 hover:opacity-100",children:[he.jsx("button",{onClick:()=>Wc("isStatsMenuCollapsed",!Jh("isStatsMenuCollapsed")),className:"bg-yellow-500 text-white p-2 rounded",children:Jh("isStatsMenuCollapsed")?he.jsx(HI,{styleClass:"w-8"}):he.jsx(VI,{styleClass:"w-8"})}),he.jsxs("div",{className:`transition transform duration-1000 ease-in-out ${Jh("isStatsMenuCollapsed")?"max-h-0 overflow-hidden":"max-h-screen"}`,children:[he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Stats"}),he.jsx("p",{className:"text-sm text-green-400",children:`HP: ${g.stats.health||"0"} / ${g.stats.maxHealth}`}),he.jsx("p",{className:"text-sm text-blue-400",children:`MP: ${g.stats.mana||"0"} / ${g.stats.maxMana}`}),he.jsx("p",{className:"text-sm text-yellow-400",children:`EP: ${g.stats.energy||"0"} / ${g.stats.maxEnergy}`})]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"User Information"}),he.jsx("p",{className:"text-sm",children:g.stats.username||"Guest"})]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"General Information"}),he.jsx("p",{className:"text-sm",children:""})]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Inventory"}),Jz(g.inventory.backpack,t,i,x)]}),he.jsxs("div",{className:"mb-4",children:[he.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Equipment"}),jz(g.inventory.equipment,t,i,x)]}),e.id&&Kz(e.id,e.position),s.id&&he.jsxs("div",{style:{top:s.position.y,left:s.position.x},className:"absolute bg-gray-700 text-white p-2 rounded shadow-lg z-50",children:[he.jsx("button",{onClick:T,className:"absolute top-1 right-1 translate-x-6 bg-yellow-400 p-1 text-white hover:text-gray-400",children:"X"}),he.jsx("p",{className:"text-sm strong",children:"Actions:"}),he.jsxs("ul",{className:"text-xs",children:[y.map(r=>he.jsx("li",{onClick:()=>s.id&&E(s.id,r),className:"cursor-pointer hover:bg-gray-600",children:r.charAt(0).toUpperCase()+r.slice(1)},r)),he.jsx("li",{onClick:T,className:"cursor-pointer hover:bg-gray-600",children:"Close"})]})]})]})]})},dy=bx(null),py=bx(null),Qz=()=>{const g=Tl(dy),[t,i]=Pe.useState({x:0,y:0});Pe.useEffect(()=>{const y=e=>{e&&(dy.set(e),i(x(e.coords.x,e.coords.y)))};return Pi.on("npcInteractionClick",y),()=>{Pi.off("npcInteractionClick",y)}},[]);const x=(y,e)=>{let n=y+250,u=e+250;return n+200>window.innerWidth-10&&(n=window.innerWidth-200-10),u+200>window.innerHeight-10&&(u=window.innerHeight-200-10),n<10&&(n=10),u<10&&(u=10),{x:n,y:u}},T=y=>{if(g){const e=k1.getActionHandler(y);e&&(e(g),E())}},E=()=>{dy.set(null)},s=()=>{if(!g)return null;const{npcName:y,actions:e,npcId:r}=g,{x:p,y:h}=t;return he.jsxs("div",{className:"absolute bg-zinc-900 border border-yellow-300 rounded-md p-2 z-50 transition transform ease-in-out duration-500 opacity-50 hover:opacity-100",style:{left:`${p}px`,top:`${h}px`,transform:"translate(-50%, -100%)"},children:[he.jsxs("div",{className:"flex justify-between items-center mb-2",children:[he.jsx("h3",{className:"font-bold text-sm",children:y}),he.jsx("button",{onClick:E,className:"text-xs font-bold m-1 text-yellow-300 hover:text-yellow-500",children:"X"})]}),e.map((a,l)=>he.jsx("button",{onClick:()=>T(a),className:"block w-full text-xs py-1 px-2 mb-1 bg-yellow-500 hover:bg-yellow-400 rounded",children:a},l)),he.jsx("button",{onClick:E,className:"block w-full text-xs py-1 px-2 mt-2 bg-red-500 hover:bg-red-600 rounded text-white",children:"Close"})]},r)};return he.jsx("div",{children:s()})},_z=()=>{const g=Tl(Zh);Pe.useEffect(()=>{const i=x=>{if(x){const T=Date.now()+Math.random();Zh.set([...Zh.get(),{id:T,...x}]),setTimeout(()=>{Zh.set(Zh.get().filter(E=>E.id!==T))},5e3)}};return Pi.on("notification",i),()=>{Pi.off("notification",i)}},[]);const t=i=>{Zh.set(Zh.get().filter(x=>x.id!==i))};return he.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 m-4 space-y-2",children:Array.isArray(g)&&g.map(i=>he.jsx("div",{className:`hs-removing:translate-x-5 hs-removing:opacity-0 transition duration-300 max-w-xs border rounded-xl shadow-lg ${i.notificationType.color}`,role:"alert",children:he.jsxs("div",{className:"flex p-4",children:[he.jsx("img",{src:i.notificationType.imgUrl,alt:i.notificationType.type,className:"flex-shrink-0 size-4"}),he.jsxs("div",{className:"ms-2",children:[he.jsx("h3",{className:"text-sm font-bold",children:i.title}),he.jsx("p",{className:"text-sm",children:i.message})]}),he.jsx("div",{className:"ms-auto",children:he.jsxs("button",{type:"button",className:"inline-flex flex-shrink-0 justify-center items-center size-5 rounded-lg text-gray-800 opacity-50 hover:opacity-100 focus:outline-none focus:opacity-100 dark:text-white",onClick:()=>t(i.id),children:[he.jsx("span",{className:"sr-only",children:"Close"}),he.jsxs("svg",{className:"flex-shrink-0 size-4 bg-zinc-900",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",children:[he.jsx("path",{d:"M18 6 6 18"}),he.jsx("path",{d:"m6 6 12 12"})]})]})})]})},i.id))})},qz=()=>{const g=Tl(py),[t,i]=Pe.useState([]),[x,T]=Pe.useState(null);Pe.useEffect(()=>{const y=r=>{r&&py.set(r)},e=r=>{r&&i(r.diceValues)};return Pi.on("playerSteal",y),Pi.on("diceRollResult",e),()=>{Pi.off("playerSteal",y),Pi.off("diceRollResult",e)}},[]),Pe.useEffect(()=>{t.length>0&&E(t)},[t]);const E=y=>{const e=y.reduce((a,l)=>a+l,0);if(T(e),!g)return;let r="",p="";switch(!0){case e===12:r="01J27QABD2GPFNRVK69S51HSGB",p=`You successfully stole a ${r}!`;break;case e===11:r="01J27QN2KZG1RDZW4CE9Q9Z3YQ",p=`You successfully stole a ${r}!`;break;case e===10:r="01J269PK47V1DWX2S1251DEASD",p=`You successfully stole a ${r}!`;break;case e===9:r="Blue Shark",p=`You successfully stole a ${r}!`;break;case e>=7:r="Salmon",p=`You successfully stole a ${r}!`;break;case e===2:Pi.emit("notification",{title:"Danger",message:`You crit failed to steal from ${g.npcName}!`,notificationType:Au.danger}),Pi.emit("playerDamage",{damage:"5"});break;default:Pi.emit("notification",{title:"Danger",message:`You failed to steal from ${g.npcName}!`,notificationType:Au.danger}),Pi.emit("playerDamage",{damage:"1"});return}const h=MI(r);h?Pi.emit("playerReward",{message:p,item:h}):console.warn("Item not found in ItemDB")},s=()=>{l2([]),i([]),T(null),py.set(null)};return g?he.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50 bg-zinc-800 bg-opacity-50",children:he.jsxs("div",{className:"bg-zinc-800 p-4 rounded-lg shadow-lg max-w-xs w-full",children:[he.jsx(tG,{npcName:g.npcName,roll:x}),he.jsx(iG,{}),he.jsx(nG,{handleClose:s})]})}):null},tG=({npcName:g,roll:t})=>he.jsxs("div",{children:[he.jsx("h2",{className:"text-lg text-yellow-400 font-bold mb-4",children:"Steal Attempt"}),he.jsxs("p",{className:"mb-4",children:["Roll the dice to steal from ",g,". You need a total of 7 or higher to succeed."]}),t!==null&&he.jsxs("p",{className:"mb-4",children:["Your roll: ",t]})]}),eG=()=>he.jsx(Dz,{textures:{side1:"/assets/items/set/dice/dice1.png",side2:"/assets/items/set/dice/dice2.png",side3:"/assets/items/set/dice/dice3.png",side4:"/assets/items/set/dice/dice4.png",side5:"/assets/items/set/dice/dice5.png",side6:"/assets/items/set/dice/dice6.png"},styleClass:"h-96",diceCount:4}),iG=Pe.memo(eG),nG=({handleClose:g})=>he.jsx("button",{onClick:g,className:"block w-full py-2 bg-red-500 text-white rounded hover:bg-red-700 mt-2",children:"Close"}),rG=dm.div` // Your style here `;function gG(){return he.jsxs(rG,{children:[he.jsx($z,{}),he.jsx("div",{className:"flex justify-center items-center h-screen",children:he.jsxs("div",{className:"border-4 border-yellow-500 rounded-xl",children:[he.jsx(qz,{}),he.jsx(Yz,{}),he.jsx(_z,{})]})}),he.jsx(Qz,{}),he.jsx(kz,{})]})}export{gG as default}; diff --git a/docs/assets/items/npc/sprites/jesus.png b/docs/assets/items/npc/sprites/jesus.png new file mode 100644 index 0000000000000000000000000000000000000000..5fa18c38bbb58e06dde44447ea33606de4702820 GIT binary patch literal 6801 zcmbVRX&{u{+oyV>Ja#INZ5nIIz77r94G$t3)!1jqG6rL7m{C%eLPU~f%94GAWT(hp zmXI}?P}ayc%vj!gRL}GO@PFSA?|iw>eV=okbDirt*YEnBYoaci8L}S#>o@}g11ro( z&k}g1F)%QKn2!Q2?Y6%tz=O|E-^T9}#>Fqt(HF&_jl?*iKrpnUE6Nh(h`iy`fjZB? za5%ut%Er&e^lx=%3|hvKK1L=8?F~pXFr3#4@^*CgK>2~3P_AxXQ1EhXBN*g{go5G9 zrgEmqf&^=6g3br20~4T8evY6Zw5JzVJqQXum{%QW(?83C zK?g(pJfPs8O4*oR1nFXYQ6Oa*6=`RAMKzErL`Gg2qNbp94x}I_uOcf4k(F1HmXlYP zgQ&~NgMR(Mz-qoo7j;WLgI{X_Z&2`cKR<7ES=qqAK$$>A8H}&1tULq)k(E=BRZx%y zMo43Cc=Me$SwX!aDo9dHcCxyg>9B9i1@#eo!!=>CY{oy-iL3nb-^a%TR#H zWP=>NW#wh$WYK8)z79rX{VY-cs_|b(W36s@qhu{nSd71~GvE&wk>A3A?f&nD=mP<5 z)Xja}0H-*5>S3Jy(I_uJm>v`i^vEFHkm^n<3Qmg75IJdQ6bd5ktgNIW4M91|Nh>P5 z$SJC*DIpcqlz-3j-{jR4v~_jmAO`vnh_bxAzA8jcRmnhCM@?H^K}jB>qVro8=7sfh z^m0c1UfT^=`x**q!}wZZFrL3p!NuzsKMeLd#v7!oOZU1eND}Vmg~SA6 z&(PiUbJuz(U$+1h(!dvk1|8U0-R-~V;H2c@0&!G=NTXcTCJya0eJZ*m{49o1o;A?aya@_3pYl#aF+Ff%tznn24@nPnnSk_c|Cn1#!%kqI-;a&O@mQa+Z390Y{w%4Y7VUI9 z3ur{M#{Or6-oYB1Is7><$hrm0{82Yf)9YN8+m=`rW)r^qDG0xq#s2)ox{+EZr|Fp? zT-8es#sH=6n)$|tl2@Za`}J>%h?*A3@+6{~#+O{C2vXoEscIo2JS#!}U?`HLk*eBg zsS;csTH@a+1D~gNX;;1Eblm;I+W;M`+~s*}?gk&GiG1@~=}*Tmw>iZXZs;~y@LG3F zc}MydU{aGRbHh2wu_^O3#qO4|P0sX+$PklVRFLE{-ocg9n`5)&Q$a9NJIfbt!q4g1 zz`7cj!Di1)e7GEk-^X#KhG%h^&{gSk>k3P~pZ7OaZgx&MG+@L$`CMMNN%W&_zNtMQ z{X)_p`!U06Q$RDuhHfq&+t_PwVkMR>rXJDm*uH>2ibzXMTYM`{maIIMtO7Q&X9@uA z_qIx}y&Ez;yENk4c`o9Q6dU}dp@Xe+=7^^=KlXSVc|PRCy61GLb(<U=UtfZBU^;{pAJhZY%ZVhD0T=pVn~j zmyP$W{^O0>B|<3&I;hfh0FAoySO|oq?|o#;$_*^}BoIWbU!w34+tk(OXnKNpi5$Qv z1(|1qT1wF9I)R>)v25ICY6+3Ku4m1Im$Q4l;79tdy?Ni1mg-+ng#uT>=}tRHpc)t_ zqZtum^2Th8;z^OE{B3MWciA`?F&YV4db2BQMw3|yobgZ5s>}GXmUcm7dLwViryf|U z^SvamPTX$Si|^Z&Dbj*a255`%5m_zH^UJwLS(nUdAXch+hH*`Et$PT`BRHAZ@WZmu zM|e6ghS2EWFJ&-rk4D~GxltFHWqn{oV8!aFn?edFlv5hs+W7hDicY~J3pfVrcl!AE zHX3gAuv*5fq4y}wuNSs5B#b@|R=+VnIixk4%dYiN05%Y_`lf2wrdp;Vu@Ls!m>W0+ zAA(>ZeX336vK|lJGTZ4MHAoX@hA^5Xg;McM0rb5i3hf*fcHwLS` zxHX5K(quXf3G9vV?+~YPrat#)Ggr@*#_uPY%UU7_k4&oxB*jYdV*U52mAZtQ`4XI1 zp4WDNoRDlJv%cX&)QQF6;XH%S_Px*zWz$z8_UUXp`1O#wP;&8Y0(GE+g-|m`P%g92 znlyxb-a}I$ z3pQ73d`wDw1Q#kY?f6)Pb8{yYjgV`Q(;VnIPr;n`D)84C?+KXkl3e_qs;Nz*#rTHJ ziOq@EtB)*hoGJ~xUiPfPVt>~NE-z`z(ETarfeuDJ1C-+0mh^$Z*u?`@^PED_8R za@#5D=Bz5I9?v3HA-x|-1-(nTJgUlCUb5B|f5E=^!%tWk=^4FhkH@a?kBYrUh_r^* zePVKwW`LY@E6@7M?*8d*XYlg+B}i77Pw`A)vXnwyv5TFi+PZ{J?PL)YPw|+>@WN7Wo|l;y0KsJx>0CYUGc3$eg=Bb6IP5>f_|8AvCrb z|HxY51$X#86G`*LWnO%}3f98`@9^BwWbc%B4A0<+Q46WZ7}lXxQR+7ZR2F} z{S0uHFd}XtQQM6@W8r*g?bR`Ak=;J;b0`k~c@aa~RjLH5xCA4&N9UjQ;?nY<2RP95 z_3Mfsdw6cRc#WCVS%qOE5WY|M(l=heM%0kmAJi8~;L2jcaqIkzcHTxS^(?D1+t~q# z;EhKG2ttcl{B3LE$@Sg26O)o|n}+osyvGd1q>N*Xef0fbN?Z*F)I>Mw4`zMQf& zY8B#&H9kR>j1K=_Qv;AJ{>>3b@}u=1*!xB>=2vCpijgG?7?SW%#MMX!4TYif4SOw% zK=yB=+3pYIit-?#m83s4xV-NWJ(h z0Vzot*>uYn=87%I>r`QLT|3qkE~Gk@#*Y^68wxNo%rMBHBi5ML3C}4-%=T$$8=1-e*o9YAvi8@=_tG&gZw0Z`n=Z9><9ouDb?d zo$?)qey2$;@^%GVbn$!WP7n4tSSNT*kua+Iv|9}QY2CO; z??J$`2wD63adY-XO$R-X)WBtx)zIm}{?>1Z(yRe$_0y;rpXw-jCQTqWKfCkItdReN zUJ$8IG;Ggq&By2&Q)(BH`*NY5J&#YXixn_13Pb!gDa1Xz` zxt34zPkMM*NnLV%)o5k$VP@03A7AP`GAF9LW?OK6L%=<> zkUF`Fp=z1r7y&1yBhpg)mErgLe)Gw}Au-MiWjRkgd!N$^Z$~{328BZ!^IU~Q-;9;b zQ`D~o@^6REo~S6aOc!4jO1B%U=r<2upTGagUO2EI6IFfpShhGhuS2`ar_XHjCTGiM zvjpZ0&=`5mJ-p!=RsA-?758J{V#$vhX^r_L5%sgy3GV{HC3%wZ_jp58isHs-h1;Dc zhcxpBo>p}W%H``7EC%lg(a4scX`r!&T8}>u4Yx*hekzZy5TVdUg{FlYBtq(|P5E*o z5qY*PKv;{z6aNy2DVa0nDC5{lObjc1wA_Th7LrODM%qK+-_*5Q3Qm+vrRrH%p+me; z6!j_PR-0a#oB|odw|V=_EYUyKHX8fX`9>Mw%FwdeyvuhWj+cK=wa~6Sfp$kt(=4 zjf9)s44|{DvwRi>qG8{74Z_E-tWtN(;G0{5V%ovFasQM zcvT9oocg($&NQQT4rpf5pG`S2%qm2K%@Bm)9(nD&MXp))_Eve9sLCcko%`mS`YktZN)oA^Wt+`i%1E^FlNGx~sh81^PsC_S|9DBnj} zJMw;M`7&POa!eIHX&f-&BR9g>!hc8_Q7@QJD84s${ir%8>6Q8e=Tc9d*t5q-l)}`` z${#TPZT7WWb?$>x5lpyU9x1n408}+6?fvokOGb1{B#v3QUyZ!UxqiPYwqnQTjK-@P zossf=kC`T`xHP#=XOA(?BB$;63g@b0ib zAv%&L+k@9OxWnWs=mu*kPB7=zi%a>T7}JA*lfHkZ-DY zf~ShYI%|l~>_Yo&N5!YRp2)oZpH*XQqwi2UB5X`{dv*TgQLNqwd^` zBgtoCVPSboj3WU%JthV>!27*VyFX*MisheS>tq3oUlG3@$9s=0| zrUtt!=cpX^4UH|hfE$Hx&FvQlPnc8o+#6tjE^=(&9>q?1FL=#xe=51`xY+)8KJy%h zZJ4KIk5GNh;UPF{kij01zkMetWK=g!zZTD{#4fW4mM(=`?N-K?9M5pMFN>y$RW{K z42Bw;3e1EK^2TsF8-wIW%d!j-nRL$kb(xlqq6(Q{IuE{|S*jgjW(}@tlWmdQAX3+x zZEtCg*GiXs-AF<38hwrOcd)s`Si3nh5k=WKHn!Y3C=#hcnM+}s*18`gDxh4=9FcKJ z;;UKPd;NeC7V)%50^(BgDRTkUhpT=3cR!KF4wub*t<&E_1NY3l4!)dDZnN%5l0i`h z9%msp_p&!@vu-Vl=(M3f?&{qk+4E|3Nc`Q)KaUH4g^%7=o(edeQ^PBGntMCwE@O7N+epPFgZf8>^c$RM z)13{0>T;)Hq0%kFa1g=@$t;rkz5$?~e-H@03K0U8P+zgK;<{^JQx(NP{E^pbLPO0K zW`)x}Rfu~-`(x~EwrA(NNj*xSP*$gJ?Wl^}LomArNb2=P=Kd|kikCgDw(s&`d^rZv z@Jy@GOLqT|QG|v_#-^S#osHe|<^irFp58nyM-5Bg{M+E+7x?+*X9MW43bO(V7LS(B zCn9mS)5$2v+~jROj>BxI+%|9{T<{;p$nnM{V%*|$y>`XWGPnQNk**+1=$U{P zYdTN8FIjOB{4}?H0Wyb$Ole|0JZ0k@G%m;uM-6SI?d;sg{@6sp4=(rg;ss;hm3uk4 zUHFynEZd06agRH6j~(HZLF+xxX~_A!HjLc3bAWmr0Ae0VD;f_<9W6gK<+*}J?lqI9 zXffq3e3Z!%3ZZDq=YU>XTj}>GJ#BMZz6P)kT||c&fY-hc zz1>6(WmX&bd{P0+qWDY7fT_?9aiJ6Rx9` z?!Gx~8!Nd?E*ImZJ_iKR!X1E{wJPv08)4R|!JVr<+b{An3G_}t6F62TDt?eZP z{f=wQE8PG+U`B@7GWV1YALA z`CT1-T`?~0;|&G_g;Kp!!Sm4DdX^@xQe5W*xBJZ50q`4^==$cl89YURE=j!=%sQ<~ z5T0=rNf*W2>=scMP8#6HMh_n|gyd%uP4p8hM4XRGps)B7owXiATMWV_mid%%-6<1A zH;9p!so?!rlGTkB&FxH)tRJo{2j9bycxOKJ4hk84w-%hVdaF6D`)GNuWN;%L$TL@a z#J&;_&}k87*~0Zkg~U^FT#RuYD23cuqF?Karp$_{bFGHO!03UVyy`CpZQCXLndr+fdf1J$7WUrmRYb-;DCC+JI+bw5 z(xL})H=YXc-#k@_pjVgV6bKb&- l$Z8&ZmX5d9R{IKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000A)Nkl|8U@a<<;>AA!$Te&N;P%V{Bbhe- z@(nA=FmPY8)tfANa-9!9P=A!e)LQCFYIC5ij#Oog&@h0SmghW`mRS{>k`rLU=IP{EK zn8(oUex+qUk5@cKMV`Lw)qStqPoMaV_ul`2Q0NZb-QA3ic$E#?&|yYe8<4KU>iyzb zm&mM3E}nHs|F2hl({mA@+>M%DPC0Y#!sTJV-)Aiw-raAv+DrO)dB3~j-Ix* zHa~!6i!rNo`vXRE-nP_2;Q8R}P^Ffpj!WxPpNw(Ml`Yi_}|qB>F$ngQJM{RlvC8twFJ1>l)PdHKa} z Blog Account GitHub Discord Log in -