/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@superviz/matterport-plugin@1.3.0/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{a as Qu,b as ed,c as td,d as nd,e as id,f as sd,g as rd,h as od,i as ad,j as el,k as ld,l as cd,m as Yt,n as hd}from"./chunks/chunk-RULG7SIV.js";import{a as tl,b as ud}from"./chunks/chunk-BBO4UPBN.js";import{a as dd}from"./chunks/chunk-I65RM6UE.js";import{a as Li,b as pd,c as Q,d as fd,e as md,f as gd,g as nl,h as vd,i as Pt}from"./chunks/chunk-ZK5IMVXR.js";import{a as Qa,b as z}from"./chunks/chunk-SURW4GBG.js";import{a as Ke,b as Ka,d as B,e as ge,f as ja,h as Ge,i as Zt,k as ce}from"./chunks/chunk-UMKU6IU4.js";var Xp=Ke(((t,e)=>{(function(){var n,i="Expected a function",r="__lodash_hash_undefined__",s="__lodash_placeholder__",a=16,o=32,l=64,c=128,u=256,h=1/0,d=9007199254740991,p=NaN,f=4294967295,m=f-1,g=f>>>1,v=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",a],["flip",512],["partial",o],["partialRight",l],["rearg",u]],_="[object Arguments]",y="[object Array]",b="[object Boolean]",w="[object Date]",x="[object Error]",S="[object Function]",E="[object GeneratorFunction]",C="[object Map]",M="[object Number]",P="[object Object]",A="[object Promise]",T="[object RegExp]",I="[object Set]",O="[object String]",L="[object Symbol]",N="[object WeakMap]",R="[object ArrayBuffer]",k="[object DataView]",D="[object Float32Array]",U="[object Float64Array]",F="[object Int8Array]",z="[object Int16Array]",B="[object Int32Array]",V="[object Uint8Array]",H="[object Uint8ClampedArray]",j="[object Uint16Array]",G="[object Uint32Array]",W=/\b__p \+= '';/g,$=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Z=/&(?:amp|lt|gt|quot|#39);/g,K=/[&<>"']/g,X=RegExp(Z.source),J=RegExp(K.source),Y=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nt=/^\w*$/,it=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rt=/[\\^$.*+?()[\]{}|]/g,st=RegExp(rt.source),at=/^\s+/,ot=/\s/,lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ct=/\{\n\/\* \[wrapped with (.+)\] \*/,ut=/,? & /,ht=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,dt=/[()=,{}\[\]\/\s]/,pt=/\\(\\)?/g,ft=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,mt=/\w*$/,gt=/^[-+]0x[0-9a-f]+$/i,vt=/^0b[01]+$/i,_t=/^\[object .+?Constructor\]$/,yt=/^0o[0-7]+$/i,bt=/^(?:0|[1-9]\d*)$/,wt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,xt=/($^)/,St=/['\n\r\u2028\u2029\\]/g,Et="\\ud800-\\udfff",Ct="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Mt="\\u2700-\\u27bf",Pt="a-z\\xdf-\\xf6\\xf8-\\xff",At="A-Z\\xc0-\\xd6\\xd8-\\xde",Tt="\\ufe0e\\ufe0f",It="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\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",Ot="['’]",Lt="["+Et+"]",Nt="["+It+"]",Rt="["+Ct+"]",kt="\\d+",Dt="["+Mt+"]",Ut="["+Pt+"]",Ft="[^"+Et+It+kt+Mt+Pt+At+"]",zt="\\ud83c[\\udffb-\\udfff]",Bt="[^"+Et+"]",Vt="(?:\\ud83c[\\udde6-\\uddff]){2}",Ht="[\\ud800-\\udbff][\\udc00-\\udfff]",jt="["+At+"]",Gt="\\u200d",Wt="(?:"+Ut+"|"+Ft+")",$t="(?:"+jt+"|"+Ft+")",qt="(?:['’](?:d|ll|m|re|s|t|ve))?",Zt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Kt="(?:"+Rt+"|"+zt+")"+"?",Xt="["+Tt+"]?",Jt=Xt+Kt+("(?:"+Gt+"(?:"+[Bt,Vt,Ht].join("|")+")"+Xt+Kt+")*"),Yt="(?:"+[Dt,Vt,Ht].join("|")+")"+Jt,Qt="(?:"+[Bt+Rt+"?",Rt,Vt,Ht,Lt].join("|")+")",te=RegExp(Ot,"g"),ee=RegExp(Rt,"g"),ne=RegExp(zt+"(?="+zt+")|"+Qt+Jt,"g"),ie=RegExp([jt+"?"+Ut+"+"+qt+"(?="+[Nt,jt,"$"].join("|")+")",$t+"+"+Zt+"(?="+[Nt,jt+Wt,"$"].join("|")+")",jt+"?"+Wt+"+"+qt,jt+"+"+Zt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",kt,Yt].join("|"),"g"),re=RegExp("["+Gt+Et+Ct+Tt+"]"),se=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ae=["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"],oe=-1,le={};le[D]=le[U]=le[F]=le[z]=le[B]=le[V]=le[H]=le[j]=le[G]=!0,le[_]=le[y]=le[R]=le[b]=le[k]=le[w]=le[x]=le[S]=le[C]=le[M]=le[P]=le[T]=le[I]=le[O]=le[N]=!1;var ce={};ce[_]=ce[y]=ce[R]=ce[k]=ce[b]=ce[w]=ce[D]=ce[U]=ce[F]=ce[z]=ce[B]=ce[C]=ce[M]=ce[P]=ce[T]=ce[I]=ce[O]=ce[L]=ce[V]=ce[H]=ce[j]=ce[G]=!0,ce[x]=ce[S]=ce[N]=!1;var ue={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},he=parseFloat,de=parseInt,pe="object"==typeof window&&window&&window.Object===Object&&window,fe="object"==typeof self&&self&&self.Object===Object&&self,me=pe||fe||Function("return this")(),ge="object"==typeof t&&t&&!t.nodeType&&t,ve=ge&&"object"==typeof e&&e&&!e.nodeType&&e,_e=ve&&ve.exports===ge,ye=_e&&pe.process,be=function(){try{return ve&&ve.require&&ve.require("util").types||ye&&ye.binding&&ye.binding("util")}catch{}}(),we=be&&be.isArrayBuffer,xe=be&&be.isDate,Se=be&&be.isMap,Ee=be&&be.isRegExp,Ce=be&&be.isSet,Me=be&&be.isTypedArray;function Pe(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Ae(t,e,n,i){for(var r=-1,s=null==t?0:t.length;++r<s;){var a=t[r];e(i,a,n(a),t)}return i}function Te(t,e){for(var n=-1,i=null==t?0:t.length;++n<i&&!1!==e(t[n],n,t););return t}function Ie(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Oe(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(!e(t[n],n,t))return!1;return!0}function Le(t,e){for(var n=-1,i=null==t?0:t.length,r=0,s=[];++n<i;){var a=t[n];e(a,n,t)&&(s[r++]=a)}return s}function Ne(t,e){return!!(null==t?0:t.length)&&je(t,e,0)>-1}function Re(t,e,n){for(var i=-1,r=null==t?0:t.length;++i<r;)if(n(e,t[i]))return!0;return!1}function ke(t,e){for(var n=-1,i=null==t?0:t.length,r=Array(i);++n<i;)r[n]=e(t[n],n,t);return r}function De(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}function Ue(t,e,n,i){var r=-1,s=null==t?0:t.length;for(i&&s&&(n=t[++r]);++r<s;)n=e(n,t[r],r,t);return n}function Fe(t,e,n,i){var r=null==t?0:t.length;for(i&&r&&(n=t[--r]);r--;)n=e(n,t[r],r,t);return n}function ze(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}var Be=qe("length");function Ve(t,e,n){var i;return n(t,(function(t,n,r){if(e(t,n,r))return i=n,!1})),i}function He(t,e,n,i){for(var r=t.length,s=n+(i?1:-1);i?s--:++s<r;)if(e(t[s],s,t))return s;return-1}function je(t,e,n){return e==e?function(t,e,n){for(var i=n-1,r=t.length;++i<r;)if(t[i]===e)return i;return-1}(t,e,n):He(t,We,n)}function Ge(t,e,n,i){for(var r=n-1,s=t.length;++r<s;)if(i(t[r],e))return r;return-1}function We(t){return t!=t}function $e(t,e){var n=null==t?0:t.length;return n?Xe(t,e)/n:p}function qe(t){return function(e){return null==e?n:e[t]}}function Ze(t){return function(e){return null==t?n:t[e]}}function Ke(t,e,n,i,r){return r(t,(function(t,r,s){n=i?(i=!1,t):e(n,t,r,s)})),n}function Xe(t,e){for(var i,r=-1,s=t.length;++r<s;){var a=e(t[r]);a!==n&&(i=i===n?a:i+a)}return i}function Je(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}function Ye(t){return t&&t.slice(0,mn(t)+1).replace(at,"")}function Qe(t){return function(e){return t(e)}}function tn(t,e){return ke(e,(function(e){return t[e]}))}function en(t,e){return t.has(e)}function nn(t,e){for(var n=-1,i=t.length;++n<i&&je(e,t[n],0)>-1;);return n}function rn(t,e){for(var n=t.length;n--&&je(e,t[n],0)>-1;);return n}var sn=Ze({"À":"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","Œ":"Oe","œ":"oe","ŉ":"'n","ſ":"s"}),an=Ze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function on(t){return"\\"+ue[t]}function ln(t){return re.test(t)}function cn(t){var e=-1,n=Array(t.size);return t.forEach((function(t,i){n[++e]=[i,t]})),n}function un(t,e){return function(n){return t(e(n))}}function hn(t,e){for(var n=-1,i=t.length,r=0,a=[];++n<i;){var o=t[n];(o===e||o===s)&&(t[n]=s,a[r++]=n)}return a}function dn(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}function pn(t){return ln(t)?function(t){for(var e=ne.lastIndex=0;ne.test(t);)++e;return e}(t):Be(t)}function fn(t){return ln(t)?function(t){return t.match(ne)||[]}(t):function(t){return t.split("")}(t)}function mn(t){for(var e=t.length;e--&&ot.test(t.charAt(e)););return e}var gn=Ze({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var vn=function t(e){var ot,Et=(e=null==e?me:vn.defaults(me.Object(),e,vn.pick(me,ae))).Array,Ct=e.Date,Mt=e.Error,Pt=e.Function,At=e.Math,Tt=e.Object,It=e.RegExp,Ot=e.String,Lt=e.TypeError,Nt=Et.prototype,Rt=Pt.prototype,kt=Tt.prototype,Dt=e["__core-js_shared__"],Ut=Rt.toString,Ft=kt.hasOwnProperty,zt=0,Bt=(ot=/[^.]+$/.exec(Dt&&Dt.keys&&Dt.keys.IE_PROTO||""))?"Symbol(src)_1."+ot:"",Vt=kt.toString,Ht=Ut.call(Tt),jt=me._,Gt=It("^"+Ut.call(Ft).replace(rt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Wt=_e?e.Buffer:n,$t=e.Symbol,qt=e.Uint8Array,Zt=Wt?Wt.allocUnsafe:n,Kt=un(Tt.getPrototypeOf,Tt),Xt=Tt.create,Jt=kt.propertyIsEnumerable,Yt=Nt.splice,Qt=$t?$t.isConcatSpreadable:n,ne=$t?$t.iterator:n,re=$t?$t.toStringTag:n,ue=function(){try{var t=ps(Tt,"defineProperty");return t({},"",{}),t}catch{}}(),pe=e.clearTimeout!==me.clearTimeout&&e.clearTimeout,fe=Ct&&Ct.now!==me.Date.now&&Ct.now,ge=e.setTimeout!==me.setTimeout&&e.setTimeout,ve=At.ceil,ye=At.floor,be=Tt.getOwnPropertySymbols,Be=Wt?Wt.isBuffer:n,Ze=e.isFinite,_n=Nt.join,yn=un(Tt.keys,Tt),bn=At.max,wn=At.min,xn=Ct.now,Sn=e.parseInt,En=At.random,Cn=Nt.reverse,Mn=ps(e,"DataView"),Pn=ps(e,"Map"),An=ps(e,"Promise"),Tn=ps(e,"Set"),In=ps(e,"WeakMap"),On=ps(Tt,"create"),Ln=In&&new In,Nn={},Rn=zs(Mn),kn=zs(Pn),Dn=zs(An),Un=zs(Tn),Fn=zs(In),zn=$t?$t.prototype:n,Bn=zn?zn.valueOf:n,Vn=zn?zn.toString:n;function Hn(t){if(no(t)&&!Wa(t)&&!(t instanceof $n)){if(t instanceof Wn)return t;if(Ft.call(t,"__wrapped__"))return Bs(t)}return new Wn(t)}var jn=function(){function t(){}return function(e){if(!eo(e))return{};if(Xt)return Xt(e);t.prototype=e;var i=new t;return t.prototype=n,i}}();function Gn(){}function Wn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function $n(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}function qn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Zn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Kn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Xn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Kn;++e<n;)this.add(t[e])}function Jn(t){var e=this.__data__=new Zn(t);this.size=e.size}function Yn(t,e){var n=Wa(t),i=!n&&Ga(t),r=!n&&!i&&Ka(t),s=!n&&!i&&!r&&uo(t),a=n||i||r||s,o=a?Je(t.length,Ot):[],l=o.length;for(var c in t)(e||Ft.call(t,c))&&(!a||!("length"==c||r&&("offset"==c||"parent"==c)||s&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||bs(c,l)))&&o.push(c);return o}function Qn(t){var e=t.length;return e?t[Xi(0,e-1)]:n}function ti(t,e){return Ds(Or(t),ci(e,0,t.length))}function ei(t){return Ds(Or(t))}function ni(t,e,i){(i!==n&&!Va(t[e],i)||i===n&&!(e in t))&&oi(t,e,i)}function ii(t,e,i){var r=t[e];(!Ft.call(t,e)||!Va(r,i)||i===n&&!(e in t))&&oi(t,e,i)}function ri(t,e){for(var n=t.length;n--;)if(Va(t[n][0],e))return n;return-1}function si(t,e,n,i){return fi(t,(function(t,r,s){e(i,t,n(t),s)})),i}function ai(t,e){return t&&Lr(e,No(e),t)}function oi(t,e,n){"__proto__"==e&&ue?ue(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function li(t,e){for(var i=-1,r=e.length,s=Et(r),a=null==t;++i<r;)s[i]=a?n:Ao(t,e[i]);return s}function ci(t,e,i){return t==t&&(i!==n&&(t=t<=i?t:i),e!==n&&(t=t>=e?t:e)),t}function ui(t,e,i,r,s,a){var o,l=1&e,c=2&e,u=4&e;if(i&&(o=s?i(t,r,s,a):i(t)),o!==n)return o;if(!eo(t))return t;var h=Wa(t);if(h){if(o=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Ft.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!l)return Or(t,o)}else{var d=gs(t),p=d==S||d==E;if(Ka(t))return Cr(t,l);if(d==P||d==_||p&&!s){if(o=c||p?{}:_s(t),!l)return c?function(t,e){return Lr(t,ms(t),e)}(t,function(t,e){return t&&Lr(e,Ro(e),t)}(o,t)):function(t,e){return Lr(t,fs(t),e)}(t,ai(o,t))}else{if(!ce[d])return s?t:{};o=function(t,e,n){var i=t.constructor;switch(e){case R:return Mr(t);case b:case w:return new i(+t);case k:return function(t,e){var n=e?Mr(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case D:case U:case F:case z:case B:case V:case H:case j:case G:return Pr(t,n);case C:return new i;case M:case O:return new i(t);case T:return function(t){var e=new t.constructor(t.source,mt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case I:return new i;case L:return function(t){return Bn?Tt(Bn.call(t)):{}}(t)}}(t,d,l)}}a||(a=new Jn);var f=a.get(t);if(f)return f;a.set(t,o),oo(t)?t.forEach((function(n){o.add(ui(n,e,i,n,t,a))})):io(t)&&t.forEach((function(n,r){o.set(r,ui(n,e,i,r,t,a))}));var m=h?n:(u?c?as:ss:c?Ro:No)(t);return Te(m||t,(function(n,r){m&&(n=t[r=n]),ii(o,r,ui(n,e,i,r,t,a))})),o}function hi(t,e,i){var r=i.length;if(null==t)return!r;for(t=Tt(t);r--;){var s=i[r],a=e[s],o=t[s];if(o===n&&!(s in t)||!a(o))return!1}return!0}function di(t,e,r){if("function"!=typeof t)throw new Lt(i);return Ls((function(){t.apply(n,r)}),e)}function pi(t,e,n,i){var r=-1,s=Ne,a=!0,o=t.length,l=[],c=e.length;if(!o)return l;n&&(e=ke(e,Qe(n))),i?(s=Re,a=!1):e.length>=200&&(s=en,a=!1,e=new Xn(e));t:for(;++r<o;){var u=t[r],h=null==n?u:n(u);if(u=i||0!==u?u:0,a&&h==h){for(var d=c;d--;)if(e[d]===h)continue t;l.push(u)}else s(e,h,i)||l.push(u)}return l}Hn.templateSettings={escape:Y,evaluate:Q,interpolate:tt,variable:"",imports:{_:Hn}},Hn.prototype=Gn.prototype,Hn.prototype.constructor=Hn,Wn.prototype=jn(Gn.prototype),Wn.prototype.constructor=Wn,$n.prototype=jn(Gn.prototype),$n.prototype.constructor=$n,qn.prototype.clear=function(){this.__data__=On?On(null):{},this.size=0},qn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},qn.prototype.get=function(t){var e=this.__data__;if(On){var i=e[t];return i===r?n:i}return Ft.call(e,t)?e[t]:n},qn.prototype.has=function(t){var e=this.__data__;return On?e[t]!==n:Ft.call(e,t)},qn.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=On&&e===n?r:e,this},Zn.prototype.clear=function(){this.__data__=[],this.size=0},Zn.prototype.delete=function(t){var e=this.__data__,n=ri(e,t);return!(n<0)&&(n==e.length-1?e.pop():Yt.call(e,n,1),--this.size,!0)},Zn.prototype.get=function(t){var e=this.__data__,i=ri(e,t);return i<0?n:e[i][1]},Zn.prototype.has=function(t){return ri(this.__data__,t)>-1},Zn.prototype.set=function(t,e){var n=this.__data__,i=ri(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this},Kn.prototype.clear=function(){this.size=0,this.__data__={hash:new qn,map:new(Pn||Zn),string:new qn}},Kn.prototype.delete=function(t){var e=hs(this,t).delete(t);return this.size-=e?1:0,e},Kn.prototype.get=function(t){return hs(this,t).get(t)},Kn.prototype.has=function(t){return hs(this,t).has(t)},Kn.prototype.set=function(t,e){var n=hs(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this},Xn.prototype.add=Xn.prototype.push=function(t){return this.__data__.set(t,r),this},Xn.prototype.has=function(t){return this.__data__.has(t)},Jn.prototype.clear=function(){this.__data__=new Zn,this.size=0},Jn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Jn.prototype.get=function(t){return this.__data__.get(t)},Jn.prototype.has=function(t){return this.__data__.has(t)},Jn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Zn){var i=n.__data__;if(!Pn||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Kn(i)}return n.set(t,e),this.size=n.size,this};var fi=kr(xi),mi=kr(Si,!0);function gi(t,e){var n=!0;return fi(t,(function(t,i,r){return n=!!e(t,i,r)})),n}function vi(t,e,i){for(var r=-1,s=t.length;++r<s;){var a=t[r],o=e(a);if(null!=o&&(l===n?o==o&&!co(o):i(o,l)))var l=o,c=a}return c}function _i(t,e){var n=[];return fi(t,(function(t,i,r){e(t,i,r)&&n.push(t)})),n}function yi(t,e,n,i,r){var s=-1,a=t.length;for(n||(n=ys),r||(r=[]);++s<a;){var o=t[s];e>0&&n(o)?e>1?yi(o,e-1,n,i,r):De(r,o):i||(r[r.length]=o)}return r}var bi=Dr(),wi=Dr(!0);function xi(t,e){return t&&bi(t,e,No)}function Si(t,e){return t&&wi(t,e,No)}function Ei(t,e){return Le(e,(function(e){return Ya(t[e])}))}function Ci(t,e){for(var i=0,r=(e=wr(e,t)).length;null!=t&&i<r;)t=t[Fs(e[i++])];return i&&i==r?t:n}function Mi(t,e,n){var i=e(t);return Wa(t)?i:De(i,n(t))}function Pi(t){return null==t?t===n?"[object Undefined]":"[object Null]":re&&re in Tt(t)?function(t){var e=Ft.call(t,re),i=t[re];try{t[re]=n;var r=!0}catch{}var s=Vt.call(t);return r&&(e?t[re]=i:delete t[re]),s}(t):function(t){return Vt.call(t)}(t)}function Ai(t,e){return t>e}function Ti(t,e){return null!=t&&Ft.call(t,e)}function Ii(t,e){return null!=t&&e in Tt(t)}function Oi(t,e,i){for(var r=i?Re:Ne,s=t[0].length,a=t.length,o=a,l=Et(a),c=1/0,u=[];o--;){var h=t[o];o&&e&&(h=ke(h,Qe(e))),c=wn(h.length,c),l[o]=!i&&(e||s>=120&&h.length>=120)?new Xn(o&&h):n}h=t[0];var d=-1,p=l[0];t:for(;++d<s&&u.length<c;){var f=h[d],m=e?e(f):f;if(f=i||0!==f?f:0,!(p?en(p,m):r(u,m,i))){for(o=a;--o;){var g=l[o];if(!(g?en(g,m):r(t[o],m,i)))continue t}p&&p.push(m),u.push(f)}}return u}function Li(t,e,i){var r=null==(t=Ts(t,e=wr(e,t)))?t:t[Fs(Js(e))];return null==r?n:Pe(r,t,i)}function Ni(t){return no(t)&&Pi(t)==_}function Ri(t,e,i,r,s){return t===e||(null==t||null==e||!no(t)&&!no(e)?t!=t&&e!=e:function(t,e,i,r,s,a){var o=Wa(t),l=Wa(e),c=o?y:gs(t),u=l?y:gs(e),h=(c=c==_?P:c)==P,d=(u=u==_?P:u)==P,p=c==u;if(p&&Ka(t)){if(!Ka(e))return!1;o=!0,h=!1}if(p&&!h)return a||(a=new Jn),o||uo(t)?is(t,e,i,r,s,a):function(t,e,n,i,r,s,a){switch(n){case k:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case R:return!(t.byteLength!=e.byteLength||!s(new qt(t),new qt(e)));case b:case w:case M:return Va(+t,+e);case x:return t.name==e.name&&t.message==e.message;case T:case O:return t==e+"";case C:var o=cn;case I:var l=1&i;if(o||(o=dn),t.size!=e.size&&!l)return!1;var c=a.get(t);if(c)return c==e;i|=2,a.set(t,e);var u=is(o(t),o(e),i,r,s,a);return a.delete(t),u;case L:if(Bn)return Bn.call(t)==Bn.call(e)}return!1}(t,e,c,i,r,s,a);if(!(1&i)){var f=h&&Ft.call(t,"__wrapped__"),m=d&&Ft.call(e,"__wrapped__");if(f||m){var g=f?t.value():t,v=m?e.value():e;return a||(a=new Jn),s(g,v,i,r,a)}}return!!p&&(a||(a=new Jn),function(t,e,i,r,s,a){var o=1&i,l=ss(t),c=l.length,u=ss(e),h=u.length;if(c!=h&&!o)return!1;for(var d=c;d--;){var p=l[d];if(!(o?p in e:Ft.call(e,p)))return!1}var f=a.get(t),m=a.get(e);if(f&&m)return f==e&&m==t;var g=!0;a.set(t,e),a.set(e,t);for(var v=o;++d<c;){var _=t[p=l[d]],y=e[p];if(r)var b=o?r(y,_,p,e,t,a):r(_,y,p,t,e,a);if(!(b===n?_===y||s(_,y,i,r,a):b)){g=!1;break}v||(v="constructor"==p)}if(g&&!v){var w=t.constructor,x=e.constructor;w!=x&&"constructor"in t&&"constructor"in e&&!("function"==typeof w&&w instanceof w&&"function"==typeof x&&x instanceof x)&&(g=!1)}return a.delete(t),a.delete(e),g}(t,e,i,r,s,a))}(t,e,i,r,Ri,s))}function ki(t,e,i,r){var s=i.length,a=s,o=!r;if(null==t)return!a;for(t=Tt(t);s--;){var l=i[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<a;){var c=(l=i[s])[0],u=t[c],h=l[1];if(o&&l[2]){if(u===n&&!(c in t))return!1}else{var d=new Jn;if(r)var p=r(u,h,c,t,e,d);if(!(p===n?Ri(h,u,3,r,d):p))return!1}}return!0}function Di(t){return!(!eo(t)||function(t){return!!Bt&&Bt in t}(t))&&(Ya(t)?Gt:_t).test(zs(t))}function Ui(t){return"function"==typeof t?t:null==t?sl:"object"==typeof t?Wa(t)?ji(t[0],t[1]):Hi(t):fl(t)}function Fi(t){if(!Cs(t))return yn(t);var e=[];for(var n in Tt(t))Ft.call(t,n)&&"constructor"!=n&&e.push(n);return e}function zi(t){if(!eo(t))return function(t){var e=[];if(null!=t)for(var n in Tt(t))e.push(n);return e}(t);var e=Cs(t),n=[];for(var i in t)"constructor"==i&&(e||!Ft.call(t,i))||n.push(i);return n}function Bi(t,e){return t<e}function Vi(t,e){var n=-1,i=qa(t)?Et(t.length):[];return fi(t,(function(t,r,s){i[++n]=e(t,r,s)})),i}function Hi(t){var e=ds(t);return 1==e.length&&e[0][2]?Ps(e[0][0],e[0][1]):function(n){return n===t||ki(n,t,e)}}function ji(t,e){return xs(t)&&Ms(e)?Ps(Fs(t),e):function(i){var r=Ao(i,t);return r===n&&r===e?To(i,t):Ri(e,r,3)}}function Gi(t,e,i,r,s){t!==e&&bi(e,(function(a,o){if(s||(s=new Jn),eo(a))!function(t,e,i,r,s,a,o){var l=Is(t,i),c=Is(e,i),u=o.get(c);if(u)return void ni(t,i,u);var h=a?a(l,c,i+"",t,e,o):n,d=h===n;if(d){var p=Wa(c),f=!p&&Ka(c),m=!p&&!f&&uo(c);h=c,p||f||m?Wa(l)?h=l:Za(l)?h=Or(l):f?(d=!1,h=Cr(c,!0)):m?(d=!1,h=Pr(c,!0)):h=[]:so(c)||Ga(c)?(h=l,Ga(l)?h=yo(l):(!eo(l)||Ya(l))&&(h=_s(c))):d=!1}d&&(o.set(c,h),s(h,c,r,a,o),o.delete(c)),ni(t,i,h)}(t,e,o,i,Gi,r,s);else{var l=r?r(Is(t,o),a,o+"",t,e,s):n;l===n&&(l=a),ni(t,o,l)}}),Ro)}function Wi(t,e){var i=t.length;if(i)return bs(e+=e<0?i:0,i)?t[e]:n}function $i(t,e,n){e=e.length?ke(e,(function(t){return Wa(t)?function(e){return Ci(e,1===t.length?t[0]:t)}:t})):[sl];var i=-1;return e=ke(e,Qe(us())),function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}(Vi(t,(function(t,n,r){return{criteria:ke(e,(function(e){return e(t)})),index:++i,value:t}})),(function(t,e){return function(t,e,n){for(var i=-1,r=t.criteria,s=e.criteria,a=r.length,o=n.length;++i<a;){var l=Ar(r[i],s[i]);if(l)return i>=o?l:l*("desc"==n[i]?-1:1)}return t.index-e.index}(t,e,n)}))}function qi(t,e,n){for(var i=-1,r=e.length,s={};++i<r;){var a=e[i],o=Ci(t,a);n(o,a)&&er(s,wr(a,t),o)}return s}function Zi(t,e,n,i){var r=i?Ge:je,s=-1,a=e.length,o=t;for(t===e&&(e=Or(e)),n&&(o=ke(t,Qe(n)));++s<a;)for(var l=0,c=e[s],u=n?n(c):c;(l=r(o,u,l,i))>-1;)o!==t&&Yt.call(o,l,1),Yt.call(t,l,1);return t}function Ki(t,e){for(var n=t?e.length:0,i=n-1;n--;){var r=e[n];if(n==i||r!==s){var s=r;bs(r)?Yt.call(t,r,1):pr(t,r)}}return t}function Xi(t,e){return t+ye(En()*(e-t+1))}function Ji(t,e){var n="";if(!t||e<1||e>d)return n;do{e%2&&(n+=t),(e=ye(e/2))&&(t+=t)}while(e);return n}function Yi(t,e){return Ns(As(t,e,sl),t+"")}function Qi(t){return Qn(Ho(t))}function tr(t,e){var n=Ho(t);return Ds(n,ci(e,0,n.length))}function er(t,e,i,r){if(!eo(t))return t;for(var s=-1,a=(e=wr(e,t)).length,o=a-1,l=t;null!=l&&++s<a;){var c=Fs(e[s]),u=i;if("__proto__"===c||"constructor"===c||"prototype"===c)return t;if(s!=o){var h=l[c];(u=r?r(h,c,l):n)===n&&(u=eo(h)?h:bs(e[s+1])?[]:{})}ii(l,c,u),l=l[c]}return t}var nr=Ln?function(t,e){return Ln.set(t,e),t}:sl,ir=ue?function(t,e){return ue(t,"toString",{configurable:!0,enumerable:!1,value:nl(e),writable:!0})}:sl;function rr(t){return Ds(Ho(t))}function sr(t,e,n){var i=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(n=n>r?r:n)<0&&(n+=r),r=e>n?0:n-e>>>0,e>>>=0;for(var s=Et(r);++i<r;)s[i]=t[i+e];return s}function ar(t,e){var n;return fi(t,(function(t,i,r){return!(n=e(t,i,r))})),!!n}function or(t,e,n){var i=0,r=null==t?i:t.length;if("number"==typeof e&&e==e&&r<=g){for(;i<r;){var s=i+r>>>1,a=t[s];null!==a&&!co(a)&&(n?a<=e:a<e)?i=s+1:r=s}return r}return lr(t,e,sl,n)}function lr(t,e,i,r){var s=0,a=null==t?0:t.length;if(0===a)return 0;for(var o=(e=i(e))!=e,l=null===e,c=co(e),u=e===n;s<a;){var h=ye((s+a)/2),d=i(t[h]),p=d!==n,f=null===d,g=d==d,v=co(d);if(o)var _=r||g;else _=u?g&&(r||p):l?g&&p&&(r||!f):c?g&&p&&!f&&(r||!v):!f&&!v&&(r?d<=e:d<e);_?s=h+1:a=h}return wn(a,m)}function cr(t,e){for(var n=-1,i=t.length,r=0,s=[];++n<i;){var a=t[n],o=e?e(a):a;if(!n||!Va(o,l)){var l=o;s[r++]=0===a?0:a}}return s}function ur(t){return"number"==typeof t?t:co(t)?p:+t}function hr(t){if("string"==typeof t)return t;if(Wa(t))return ke(t,hr)+"";if(co(t))return Vn?Vn.call(t):"";var e=t+"";return"0"==e&&1/t==-h?"-0":e}function dr(t,e,n){var i=-1,r=Ne,s=t.length,a=!0,o=[],l=o;if(n)a=!1,r=Re;else if(s>=200){var c=e?null:Jr(t);if(c)return dn(c);a=!1,r=en,l=new Xn}else l=e?[]:o;t:for(;++i<s;){var u=t[i],h=e?e(u):u;if(u=n||0!==u?u:0,a&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue t;e&&l.push(h),o.push(u)}else r(l,h,n)||(l!==o&&l.push(h),o.push(u))}return o}function pr(t,e){return null==(t=Ts(t,e=wr(e,t)))||delete t[Fs(Js(e))]}function fr(t,e,n,i){return er(t,e,n(Ci(t,e)),i)}function mr(t,e,n,i){for(var r=t.length,s=i?r:-1;(i?s--:++s<r)&&e(t[s],s,t););return n?sr(t,i?0:s,i?s+1:r):sr(t,i?s+1:0,i?r:s)}function gr(t,e){var n=t;return n instanceof $n&&(n=n.value()),Ue(e,(function(t,e){return e.func.apply(e.thisArg,De([t],e.args))}),n)}function vr(t,e,n){var i=t.length;if(i<2)return i?dr(t[0]):[];for(var r=-1,s=Et(i);++r<i;)for(var a=t[r],o=-1;++o<i;)o!=r&&(s[r]=pi(s[r]||a,t[o],e,n));return dr(yi(s,1),e,n)}function _r(t,e,i){for(var r=-1,s=t.length,a=e.length,o={};++r<s;){var l=r<a?e[r]:n;i(o,t[r],l)}return o}function yr(t){return Za(t)?t:[]}function br(t){return"function"==typeof t?t:sl}function wr(t,e){return Wa(t)?t:xs(t,e)?[t]:Us(bo(t))}var xr=Yi;function Sr(t,e,i){var r=t.length;return i=i===n?r:i,!e&&i>=r?t:sr(t,e,i)}var Er=pe||function(t){return me.clearTimeout(t)};function Cr(t,e){if(e)return t.slice();var n=t.length,i=Zt?Zt(n):new t.constructor(n);return t.copy(i),i}function Mr(t){var e=new t.constructor(t.byteLength);return new qt(e).set(new qt(t)),e}function Pr(t,e){var n=e?Mr(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Ar(t,e){if(t!==e){var i=t!==n,r=null===t,s=t==t,a=co(t),o=e!==n,l=null===e,c=e==e,u=co(e);if(!l&&!u&&!a&&t>e||a&&o&&c&&!l&&!u||r&&o&&c||!i&&c||!s)return 1;if(!r&&!a&&!u&&t<e||u&&i&&s&&!r&&!a||l&&i&&s||!o&&s||!c)return-1}return 0}function Tr(t,e,n,i){for(var r=-1,s=t.length,a=n.length,o=-1,l=e.length,c=bn(s-a,0),u=Et(l+c),h=!i;++o<l;)u[o]=e[o];for(;++r<a;)(h||r<s)&&(u[n[r]]=t[r]);for(;c--;)u[o++]=t[r++];return u}function Ir(t,e,n,i){for(var r=-1,s=t.length,a=-1,o=n.length,l=-1,c=e.length,u=bn(s-o,0),h=Et(u+c),d=!i;++r<u;)h[r]=t[r];for(var p=r;++l<c;)h[p+l]=e[l];for(;++a<o;)(d||r<s)&&(h[p+n[a]]=t[r++]);return h}function Or(t,e){var n=-1,i=t.length;for(e||(e=Et(i));++n<i;)e[n]=t[n];return e}function Lr(t,e,i,r){var s=!i;i||(i={});for(var a=-1,o=e.length;++a<o;){var l=e[a],c=r?r(i[l],t[l],l,i,t):n;c===n&&(c=t[l]),s?oi(i,l,c):ii(i,l,c)}return i}function Nr(t,e){return function(n,i){var r=Wa(n)?Ae:si,s=e?e():{};return r(n,t,us(i,2),s)}}function Rr(t){return Yi((function(e,i){var r=-1,s=i.length,a=s>1?i[s-1]:n,o=s>2?i[2]:n;for(a=t.length>3&&"function"==typeof a?(s--,a):n,o&&ws(i[0],i[1],o)&&(a=s<3?n:a,s=1),e=Tt(e);++r<s;){var l=i[r];l&&t(e,l,r,a)}return e}))}function kr(t,e){return function(n,i){if(null==n)return n;if(!qa(n))return t(n,i);for(var r=n.length,s=e?r:-1,a=Tt(n);(e?s--:++s<r)&&!1!==i(a[s],s,a););return n}}function Dr(t){return function(e,n,i){for(var r=-1,s=Tt(e),a=i(e),o=a.length;o--;){var l=a[t?o:++r];if(!1===n(s[l],l,s))break}return e}}function Ur(t){return function(e){var i=ln(e=bo(e))?fn(e):n,r=i?i[0]:e.charAt(0),s=i?Sr(i,1).join(""):e.slice(1);return r[t]()+s}}function Fr(t){return function(e){return Ue(Qo(Wo(e).replace(te,"")),t,"")}}function zr(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=jn(t.prototype),i=t.apply(n,e);return eo(i)?i:n}}function Br(t){return function(e,i,r){var s=Tt(e);if(!qa(e)){var a=us(i,3);e=No(e),i=function(t){return a(s[t],t,s)}}var o=t(e,i,r);return o>-1?s[a?e[o]:o]:n}}function Vr(t){return rs((function(e){var r=e.length,s=r,a=Wn.prototype.thru;for(t&&e.reverse();s--;){var o=e[s];if("function"!=typeof o)throw new Lt(i);if(a&&!l&&"wrapper"==ls(o))var l=new Wn([],!0)}for(s=l?s:r;++s<r;){var c=ls(o=e[s]),u="wrapper"==c?os(o):n;l=u&&Ss(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[ls(u[0])].apply(l,u[3]):1==o.length&&Ss(o)?l[c]():l.thru(o)}return function(){var t=arguments,n=t[0];if(l&&1==t.length&&Wa(n))return l.plant(n).value();for(var i=0,s=r?e[i].apply(this,t):n;++i<r;)s=e[i].call(this,s);return s}}))}function Hr(t,e,i,r,s,a,o,l,u,h){var d=e&c,p=1&e,f=2&e,m=24&e,g=512&e,v=f?n:zr(t);return function c(){for(var _=arguments.length,y=Et(_),b=_;b--;)y[b]=arguments[b];if(m)var w=cs(c),x=function(t,e){for(var n=t.length,i=0;n--;)t[n]===e&&++i;return i}(y,w);if(r&&(y=Tr(y,r,s,m)),a&&(y=Ir(y,a,o,m)),_-=x,m&&_<h){var S=hn(y,w);return Kr(t,e,Hr,c.placeholder,i,y,S,l,u,h-_)}var E=p?i:this,C=f?E[t]:t;return _=y.length,l?y=function(t,e){for(var i=t.length,r=wn(e.length,i),s=Or(t);r--;){var a=e[r];t[r]=bs(a,i)?s[a]:n}return t}(y,l):g&&_>1&&y.reverse(),d&&u<_&&(y.length=u),this&&this!==me&&this instanceof c&&(C=v||zr(C)),C.apply(E,y)}}function jr(t,e){return function(n,i){return function(t,e,n,i){return xi(t,(function(t,r,s){e(i,n(t),r,s)})),i}(n,t,e(i),{})}}function Gr(t,e){return function(i,r){var s;if(i===n&&r===n)return e;if(i!==n&&(s=i),r!==n){if(s===n)return r;"string"==typeof i||"string"==typeof r?(i=hr(i),r=hr(r)):(i=ur(i),r=ur(r)),s=t(i,r)}return s}}function Wr(t){return rs((function(e){return e=ke(e,Qe(us())),Yi((function(n){var i=this;return t(e,(function(t){return Pe(t,i,n)}))}))}))}function $r(t,e){var i=(e=e===n?" ":hr(e)).length;if(i<2)return i?Ji(e,t):e;var r=Ji(e,ve(t/pn(e)));return ln(e)?Sr(fn(r),0,t).join(""):r.slice(0,t)}function qr(t){return function(e,i,r){return r&&"number"!=typeof r&&ws(e,i,r)&&(i=r=n),e=mo(e),i===n?(i=e,e=0):i=mo(i),function(t,e,n,i){for(var r=-1,s=bn(ve((e-t)/(n||1)),0),a=Et(s);s--;)a[i?s:++r]=t,t+=n;return a}(e,i,r=r===n?e<i?1:-1:mo(r),t)}}function Zr(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=_o(e),n=_o(n)),t(e,n)}}function Kr(t,e,i,r,s,a,c,u,h,d){var p=8&e;e|=p?o:l,4&(e&=~(p?l:o))||(e&=-4);var f=[t,e,s,p?a:n,p?c:n,p?n:a,p?n:c,u,h,d],m=i.apply(n,f);return Ss(t)&&Os(m,f),m.placeholder=r,Rs(m,t,e)}function Xr(t){var e=At[t];return function(t,n){if(t=_o(t),(n=null==n?0:wn(go(n),292))&&Ze(t)){var i=(bo(t)+"e").split("e");return+((i=(bo(e(i[0]+"e"+(+i[1]+n)))+"e").split("e"))[0]+"e"+(+i[1]-n))}return e(t)}}var Jr=Tn&&1/dn(new Tn([,-0]))[1]==h?function(t){return new Tn(t)}:ul;function Yr(t){return function(e){var n=gs(e);return n==C?cn(e):n==I?function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}(e):function(t,e){return ke(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Qr(t,e,r,h,d,p,f,m){var g=2&e;if(!g&&"function"!=typeof t)throw new Lt(i);var v=h?h.length:0;if(v||(e&=-97,h=d=n),f=f===n?f:bn(go(f),0),m=m===n?m:go(m),v-=d?d.length:0,e&l){var _=h,y=d;h=d=n}var b=g?n:os(t),w=[t,e,r,h,d,_,y,p,f,m];if(b&&function(t,e){var n=t[1],i=e[1],r=n|i,a=r<131,o=i==c&&8==n||i==c&&n==u&&t[7].length<=e[8]||384==i&&e[7].length<=e[8]&&8==n;if(!a&&!o)return t;1&i&&(t[2]=e[2],r|=1&n?0:4);var l=e[3];if(l){var h=t[3];t[3]=h?Tr(h,l,e[4]):l,t[4]=h?hn(t[3],s):e[4]}l=e[5],l&&(h=t[5],t[5]=h?Ir(h,l,e[6]):l,t[6]=h?hn(t[5],s):e[6]),l=e[7],l&&(t[7]=l),i&c&&(t[8]=null==t[8]?e[8]:wn(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=r}(w,b),t=w[0],e=w[1],r=w[2],h=w[3],d=w[4],!(m=w[9]=w[9]===n?g?0:t.length:bn(w[9]-v,0))&&24&e&&(e&=-25),e&&1!=e)x=8==e||e==a?function(t,e,i){var r=zr(t);return function s(){for(var a=arguments.length,o=Et(a),l=a,c=cs(s);l--;)o[l]=arguments[l];var u=a<3&&o[0]!==c&&o[a-1]!==c?[]:hn(o,c);return(a-=u.length)<i?Kr(t,e,Hr,s.placeholder,n,o,u,n,n,i-a):Pe(this&&this!==me&&this instanceof s?r:t,this,o)}}(t,e,m):e!=o&&33!=e||d.length?Hr.apply(n,w):function(t,e,n,i){var r=1&e,s=zr(t);return function e(){for(var a=-1,o=arguments.length,l=-1,c=i.length,u=Et(c+o),h=this&&this!==me&&this instanceof e?s:t;++l<c;)u[l]=i[l];for(;o--;)u[l++]=arguments[++a];return Pe(h,r?n:this,u)}}(t,e,r,h);else var x=function(t,e,n){var i=1&e,r=zr(t);return function e(){return(this&&this!==me&&this instanceof e?r:t).apply(i?n:this,arguments)}}(t,e,r);return Rs((b?nr:Os)(x,w),t,e)}function ts(t,e,i,r){return t===n||Va(t,kt[i])&&!Ft.call(r,i)?e:t}function es(t,e,i,r,s,a){return eo(t)&&eo(e)&&(a.set(e,t),Gi(t,e,n,es,a),a.delete(e)),t}function ns(t){return so(t)?n:t}function is(t,e,i,r,s,a){var o=1&i,l=t.length,c=e.length;if(l!=c&&!(o&&c>l))return!1;var u=a.get(t),h=a.get(e);if(u&&h)return u==e&&h==t;var d=-1,p=!0,f=2&i?new Xn:n;for(a.set(t,e),a.set(e,t);++d<l;){var m=t[d],g=e[d];if(r)var v=o?r(g,m,d,e,t,a):r(m,g,d,t,e,a);if(v!==n){if(v)continue;p=!1;break}if(f){if(!ze(e,(function(t,e){if(!en(f,e)&&(m===t||s(m,t,i,r,a)))return f.push(e)}))){p=!1;break}}else if(m!==g&&!s(m,g,i,r,a)){p=!1;break}}return a.delete(t),a.delete(e),p}function rs(t){return Ns(As(t,n,$s),t+"")}function ss(t){return Mi(t,No,fs)}function as(t){return Mi(t,Ro,ms)}var os=Ln?function(t){return Ln.get(t)}:ul;function ls(t){for(var e=t.name+"",n=Nn[e],i=Ft.call(Nn,e)?n.length:0;i--;){var r=n[i],s=r.func;if(null==s||s==t)return r.name}return e}function cs(t){return(Ft.call(Hn,"placeholder")?Hn:t).placeholder}function us(){var t=Hn.iteratee||al;return t=t===al?Ui:t,arguments.length?t(arguments[0],arguments[1]):t}function hs(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function ds(t){for(var e=No(t),n=e.length;n--;){var i=e[n],r=t[i];e[n]=[i,r,Ms(r)]}return e}function ps(t,e){var i=function(t,e){return null==t?n:t[e]}(t,e);return Di(i)?i:n}var fs=be?function(t){return null==t?[]:(t=Tt(t),Le(be(t),(function(e){return Jt.call(t,e)})))}:vl,ms=be?function(t){for(var e=[];t;)De(e,fs(t)),t=Kt(t);return e}:vl,gs=Pi;function vs(t,e,n){for(var i=-1,r=(e=wr(e,t)).length,s=!1;++i<r;){var a=Fs(e[i]);if(!(s=null!=t&&n(t,a)))break;t=t[a]}return s||++i!=r?s:!!(r=null==t?0:t.length)&&to(r)&&bs(a,r)&&(Wa(t)||Ga(t))}function _s(t){return"function"!=typeof t.constructor||Cs(t)?{}:jn(Kt(t))}function ys(t){return Wa(t)||Ga(t)||!!(Qt&&t&&t[Qt])}function bs(t,e){var n=typeof t;return!!(e=e??d)&&("number"==n||"symbol"!=n&&bt.test(t))&&t>-1&&t%1==0&&t<e}function ws(t,e,n){if(!eo(n))return!1;var i=typeof e;return!!("number"==i?qa(n)&&bs(e,n.length):"string"==i&&e in n)&&Va(n[e],t)}function xs(t,e){if(Wa(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!co(t))||(nt.test(t)||!et.test(t)||null!=e&&t in Tt(e))}function Ss(t){var e=ls(t),n=Hn[e];if("function"!=typeof n||!(e in $n.prototype))return!1;if(t===n)return!0;var i=os(n);return!!i&&t===i[0]}(Mn&&gs(new Mn(new ArrayBuffer(1)))!=k||Pn&&gs(new Pn)!=C||An&&gs(An.resolve())!=A||Tn&&gs(new Tn)!=I||In&&gs(new In)!=N)&&(gs=function(t){var e=Pi(t),i=e==P?t.constructor:n,r=i?zs(i):"";if(r)switch(r){case Rn:return k;case kn:return C;case Dn:return A;case Un:return I;case Fn:return N}return e});var Es=Dt?Ya:_l;function Cs(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||kt)}function Ms(t){return t==t&&!eo(t)}function Ps(t,e){return function(i){return null!=i&&(i[t]===e&&(e!==n||t in Tt(i)))}}function As(t,e,i){return e=bn(e===n?t.length-1:e,0),function(){for(var n=arguments,r=-1,s=bn(n.length-e,0),a=Et(s);++r<s;)a[r]=n[e+r];r=-1;for(var o=Et(e+1);++r<e;)o[r]=n[r];return o[e]=i(a),Pe(t,this,o)}}function Ts(t,e){return e.length<2?t:Ci(t,sr(e,0,-1))}function Is(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Os=ks(nr),Ls=ge||function(t,e){return me.setTimeout(t,e)},Ns=ks(ir);function Rs(t,e,n){var i=e+"";return Ns(t,function(t,e){var n=e.length;if(!n)return t;var i=n-1;return e[i]=(n>1?"& ":"")+e[i],e=e.join(n>2?", ":" "),t.replace(lt,"{\n/* [wrapped with "+e+"] */\n")}(i,function(t,e){return Te(v,(function(n){var i="_."+n[0];e&n[1]&&!Ne(t,i)&&t.push(i)})),t.sort()}(function(t){var e=t.match(ct);return e?e[1].split(ut):[]}(i),n)))}function ks(t){var e=0,i=0;return function(){var r=xn(),s=16-(r-i);if(i=r,s>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(n,arguments)}}function Ds(t,e){var i=-1,r=t.length,s=r-1;for(e=e===n?r:e;++i<e;){var a=Xi(i,s),o=t[a];t[a]=t[i],t[i]=o}return t.length=e,t}var Us=function(t){var e=ka(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(it,(function(t,n,i,r){e.push(i?r.replace(pt,"$1"):n||t)})),e}));function Fs(t){if("string"==typeof t||co(t))return t;var e=t+"";return"0"==e&&1/t==-h?"-0":e}function zs(t){if(null!=t){try{return Ut.call(t)}catch{}try{return t+""}catch{}}return""}function Bs(t){if(t instanceof $n)return t.clone();var e=new Wn(t.__wrapped__,t.__chain__);return e.__actions__=Or(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var Vs=Yi((function(t,e){return Za(t)?pi(t,yi(e,1,Za,!0)):[]})),Hs=Yi((function(t,e){var i=Js(e);return Za(i)&&(i=n),Za(t)?pi(t,yi(e,1,Za,!0),us(i,2)):[]})),js=Yi((function(t,e){var i=Js(e);return Za(i)&&(i=n),Za(t)?pi(t,yi(e,1,Za,!0),n,i):[]}));function Gs(t,e,n){var i=null==t?0:t.length;if(!i)return-1;var r=null==n?0:go(n);return r<0&&(r=bn(i+r,0)),He(t,us(e,3),r)}function Ws(t,e,i){var r=null==t?0:t.length;if(!r)return-1;var s=r-1;return i!==n&&(s=go(i),s=i<0?bn(r+s,0):wn(s,r-1)),He(t,us(e,3),s,!0)}function $s(t){return(null==t?0:t.length)?yi(t,1):[]}function qs(t){return t&&t.length?t[0]:n}var Zs=Yi((function(t){var e=ke(t,yr);return e.length&&e[0]===t[0]?Oi(e):[]})),Ks=Yi((function(t){var e=Js(t),i=ke(t,yr);return e===Js(i)?e=n:i.pop(),i.length&&i[0]===t[0]?Oi(i,us(e,2)):[]})),Xs=Yi((function(t){var e=Js(t),i=ke(t,yr);return(e="function"==typeof e?e:n)&&i.pop(),i.length&&i[0]===t[0]?Oi(i,n,e):[]}));function Js(t){var e=null==t?0:t.length;return e?t[e-1]:n}var Ys=Yi(Qs);function Qs(t,e){return t&&t.length&&e&&e.length?Zi(t,e):t}var ta=rs((function(t,e){var n=null==t?0:t.length,i=li(t,e);return Ki(t,ke(e,(function(t){return bs(t,n)?+t:t})).sort(Ar)),i}));function ea(t){return null==t?t:Cn.call(t)}var na=Yi((function(t){return dr(yi(t,1,Za,!0))})),ia=Yi((function(t){var e=Js(t);return Za(e)&&(e=n),dr(yi(t,1,Za,!0),us(e,2))})),ra=Yi((function(t){var e=Js(t);return e="function"==typeof e?e:n,dr(yi(t,1,Za,!0),n,e)}));function sa(t){if(!t||!t.length)return[];var e=0;return t=Le(t,(function(t){if(Za(t))return e=bn(t.length,e),!0})),Je(e,(function(e){return ke(t,qe(e))}))}function aa(t,e){if(!t||!t.length)return[];var i=sa(t);return null==e?i:ke(i,(function(t){return Pe(e,n,t)}))}var oa=Yi((function(t,e){return Za(t)?pi(t,e):[]})),la=Yi((function(t){return vr(Le(t,Za))})),ca=Yi((function(t){var e=Js(t);return Za(e)&&(e=n),vr(Le(t,Za),us(e,2))})),ua=Yi((function(t){var e=Js(t);return e="function"==typeof e?e:n,vr(Le(t,Za),n,e)})),ha=Yi(sa);var da=Yi((function(t){var e=t.length,i=e>1?t[e-1]:n;return i="function"==typeof i?(t.pop(),i):n,aa(t,i)}));function pa(t){var e=Hn(t);return e.__chain__=!0,e}function fa(t,e){return e(t)}var ma=rs((function(t){var e=t.length,i=e?t[0]:0,r=this.__wrapped__,s=function(e){return li(e,t)};return!(e>1||this.__actions__.length)&&r instanceof $n&&bs(i)?((r=r.slice(i,+i+(e?1:0))).__actions__.push({func:fa,args:[s],thisArg:n}),new Wn(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(n),t}))):this.thru(s)}));var ga=Nr((function(t,e,n){Ft.call(t,n)?++t[n]:oi(t,n,1)}));var va=Br(Gs),_a=Br(Ws);function ya(t,e){return(Wa(t)?Te:fi)(t,us(e,3))}function ba(t,e){return(Wa(t)?Ie:mi)(t,us(e,3))}var wa=Nr((function(t,e,n){Ft.call(t,n)?t[n].push(e):oi(t,n,[e])}));var xa=Yi((function(t,e,n){var i=-1,r="function"==typeof e,s=qa(t)?Et(t.length):[];return fi(t,(function(t){s[++i]=r?Pe(e,t,n):Li(t,e,n)})),s})),Sa=Nr((function(t,e,n){oi(t,n,e)}));function Ea(t,e){return(Wa(t)?ke:Vi)(t,us(e,3))}var Ca=Nr((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]}));var Ma=Yi((function(t,e){if(null==t)return[];var n=e.length;return n>1&&ws(t,e[0],e[1])?e=[]:n>2&&ws(e[0],e[1],e[2])&&(e=[e[0]]),$i(t,yi(e,1),[])})),Pa=fe||function(){return me.Date.now()};function Aa(t,e,i){return e=i?n:e,e=t&&null==e?t.length:e,Qr(t,c,n,n,n,n,e)}function Ta(t,e){var r;if("function"!=typeof e)throw new Lt(i);return t=go(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var Ia=Yi((function(t,e,n){var i=1;if(n.length){var r=hn(n,cs(Ia));i|=o}return Qr(t,i,e,n,r)})),Oa=Yi((function(t,e,n){var i=3;if(n.length){var r=hn(n,cs(Oa));i|=o}return Qr(e,i,t,n,r)}));function La(t,e,r){var s,a,o,l,c,u,h=0,d=!1,p=!1,f=!0;if("function"!=typeof t)throw new Lt(i);function m(e){var i=s,r=a;return s=a=n,h=e,l=t.apply(r,i)}function g(t){var i=t-u;return u===n||i>=e||i<0||p&&t-h>=o}function v(){var t=Pa();if(g(t))return _(t);c=Ls(v,function(t){var n=e-(t-u);return p?wn(n,o-(t-h)):n}(t))}function _(t){return c=n,f&&s?m(t):(s=a=n,l)}function y(){var t=Pa(),i=g(t);if(s=arguments,a=this,u=t,i){if(c===n)return function(t){return h=t,c=Ls(v,e),d?m(t):l}(u);if(p)return Er(c),c=Ls(v,e),m(u)}return c===n&&(c=Ls(v,e)),l}return e=_o(e)||0,eo(r)&&(d=!!r.leading,o=(p="maxWait"in r)?bn(_o(r.maxWait)||0,e):o,f="trailing"in r?!!r.trailing:f),y.cancel=function(){c!==n&&Er(c),h=0,s=u=a=c=n},y.flush=function(){return c===n?l:_(Pa())},y}var Na=Yi((function(t,e){return di(t,1,e)})),Ra=Yi((function(t,e,n){return di(t,_o(e)||0,n)}));function ka(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new Lt(i);var n=function(){var i=arguments,r=e?e.apply(this,i):i[0],s=n.cache;if(s.has(r))return s.get(r);var a=t.apply(this,i);return n.cache=s.set(r,a)||s,a};return n.cache=new(ka.Cache||Kn),n}function Da(t){if("function"!=typeof t)throw new Lt(i);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ka.Cache=Kn;var Ua=xr((function(t,e){var n=(e=1==e.length&&Wa(e[0])?ke(e[0],Qe(us())):ke(yi(e,1),Qe(us()))).length;return Yi((function(i){for(var r=-1,s=wn(i.length,n);++r<s;)i[r]=e[r].call(this,i[r]);return Pe(t,this,i)}))})),Fa=Yi((function(t,e){var i=hn(e,cs(Fa));return Qr(t,o,n,e,i)})),za=Yi((function(t,e){var i=hn(e,cs(za));return Qr(t,l,n,e,i)})),Ba=rs((function(t,e){return Qr(t,u,n,n,n,e)}));function Va(t,e){return t===e||t!=t&&e!=e}var Ha=Zr(Ai),ja=Zr((function(t,e){return t>=e})),Ga=Ni(function(){return arguments}())?Ni:function(t){return no(t)&&Ft.call(t,"callee")&&!Jt.call(t,"callee")},Wa=Et.isArray,$a=we?Qe(we):function(t){return no(t)&&Pi(t)==R};function qa(t){return null!=t&&to(t.length)&&!Ya(t)}function Za(t){return no(t)&&qa(t)}var Ka=Be||_l,Xa=xe?Qe(xe):function(t){return no(t)&&Pi(t)==w};function Ja(t){if(!no(t))return!1;var e=Pi(t);return e==x||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!so(t)}function Ya(t){if(!eo(t))return!1;var e=Pi(t);return e==S||e==E||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Qa(t){return"number"==typeof t&&t==go(t)}function to(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=d}function eo(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function no(t){return null!=t&&"object"==typeof t}var io=Se?Qe(Se):function(t){return no(t)&&gs(t)==C};function ro(t){return"number"==typeof t||no(t)&&Pi(t)==M}function so(t){if(!no(t)||Pi(t)!=P)return!1;var e=Kt(t);if(null===e)return!0;var n=Ft.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ut.call(n)==Ht}var ao=Ee?Qe(Ee):function(t){return no(t)&&Pi(t)==T};var oo=Ce?Qe(Ce):function(t){return no(t)&&gs(t)==I};function lo(t){return"string"==typeof t||!Wa(t)&&no(t)&&Pi(t)==O}function co(t){return"symbol"==typeof t||no(t)&&Pi(t)==L}var uo=Me?Qe(Me):function(t){return no(t)&&to(t.length)&&!!le[Pi(t)]};var ho=Zr(Bi),po=Zr((function(t,e){return t<=e}));function fo(t){if(!t)return[];if(qa(t))return lo(t)?fn(t):Or(t);if(ne&&t[ne])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[ne]());var e=gs(t);return(e==C?cn:e==I?dn:Ho)(t)}function mo(t){return t?(t=_o(t))===h||t===-h?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function go(t){var e=mo(t),n=e%1;return e==e?n?e-n:e:0}function vo(t){return t?ci(go(t),0,f):0}function _o(t){if("number"==typeof t)return t;if(co(t))return p;if(eo(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=eo(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ye(t);var n=vt.test(t);return n||yt.test(t)?de(t.slice(2),n?2:8):gt.test(t)?p:+t}function yo(t){return Lr(t,Ro(t))}function bo(t){return null==t?"":hr(t)}var wo=Rr((function(t,e){if(Cs(e)||qa(e))Lr(e,No(e),t);else for(var n in e)Ft.call(e,n)&&ii(t,n,e[n])})),xo=Rr((function(t,e){Lr(e,Ro(e),t)})),So=Rr((function(t,e,n,i){Lr(e,Ro(e),t,i)})),Eo=Rr((function(t,e,n,i){Lr(e,No(e),t,i)})),Co=rs(li);var Mo=Yi((function(t,e){t=Tt(t);var i=-1,r=e.length,s=r>2?e[2]:n;for(s&&ws(e[0],e[1],s)&&(r=1);++i<r;)for(var a=e[i],o=Ro(a),l=-1,c=o.length;++l<c;){var u=o[l],h=t[u];(h===n||Va(h,kt[u])&&!Ft.call(t,u))&&(t[u]=a[u])}return t})),Po=Yi((function(t){return t.push(n,es),Pe(Do,n,t)}));function Ao(t,e,i){var r=null==t?n:Ci(t,e);return r===n?i:r}function To(t,e){return null!=t&&vs(t,e,Ii)}var Io=jr((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Vt.call(e)),t[e]=n}),nl(sl)),Oo=jr((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Vt.call(e)),Ft.call(t,e)?t[e].push(n):t[e]=[n]}),us),Lo=Yi(Li);function No(t){return qa(t)?Yn(t):Fi(t)}function Ro(t){return qa(t)?Yn(t,!0):zi(t)}var ko=Rr((function(t,e,n){Gi(t,e,n)})),Do=Rr((function(t,e,n,i){Gi(t,e,n,i)})),Uo=rs((function(t,e){var n={};if(null==t)return n;var i=!1;e=ke(e,(function(e){return e=wr(e,t),i||(i=e.length>1),e})),Lr(t,as(t),n),i&&(n=ui(n,7,ns));for(var r=e.length;r--;)pr(n,e[r]);return n}));var Fo=rs((function(t,e){return null==t?{}:function(t,e){return qi(t,e,(function(e,n){return To(t,n)}))}(t,e)}));function zo(t,e){if(null==t)return{};var n=ke(as(t),(function(t){return[t]}));return e=us(e),qi(t,n,(function(t,n){return e(t,n[0])}))}var Bo=Yr(No),Vo=Yr(Ro);function Ho(t){return null==t?[]:tn(t,No(t))}var jo=Fr((function(t,e,n){return e=e.toLowerCase(),t+(n?Go(e):e)}));function Go(t){return Yo(bo(t).toLowerCase())}function Wo(t){return(t=bo(t))&&t.replace(wt,sn).replace(ee,"")}var $o=Fr((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),qo=Fr((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),Zo=Ur("toLowerCase");var Ko=Fr((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()}));var Xo=Fr((function(t,e,n){return t+(n?" ":"")+Yo(e)}));var Jo=Fr((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Yo=Ur("toUpperCase");function Qo(t,e,i){return t=bo(t),(e=i?n:e)===n?function(t){return se.test(t)}(t)?function(t){return t.match(ie)||[]}(t):function(t){return t.match(ht)||[]}(t):t.match(e)||[]}var tl=Yi((function(t,e){try{return Pe(t,n,e)}catch(t){return Ja(t)?t:new Mt(t)}})),el=rs((function(t,e){return Te(e,(function(e){e=Fs(e),oi(t,e,Ia(t[e],t))})),t}));function nl(t){return function(){return t}}var il=Vr(),rl=Vr(!0);function sl(t){return t}function al(t){return Ui("function"==typeof t?t:ui(t,1))}var ol=Yi((function(t,e){return function(n){return Li(n,t,e)}})),ll=Yi((function(t,e){return function(n){return Li(t,n,e)}}));function cl(t,e,n){var i=No(e),r=Ei(e,i);null==n&&(!eo(e)||!r.length&&i.length)&&(n=e,e=t,t=this,r=Ei(e,No(e)));var s=!(eo(n)&&"chain"in n&&!n.chain),a=Ya(t);return Te(r,(function(n){var i=e[n];t[n]=i,a&&(t.prototype[n]=function(){var e=this.__chain__;if(s||e){var n=t(this.__wrapped__);return(n.__actions__=Or(this.__actions__)).push({func:i,args:arguments,thisArg:t}),n.__chain__=e,n}return i.apply(t,De([this.value()],arguments))})})),t}function ul(){}var hl=Wr(ke),dl=Wr(Oe),pl=Wr(ze);function fl(t){return xs(t)?qe(Fs(t)):function(t){return function(e){return Ci(e,t)}}(t)}var ml=qr(),gl=qr(!0);function vl(){return[]}function _l(){return!1}var yl=Gr((function(t,e){return t+e}),0),bl=Xr("ceil"),wl=Gr((function(t,e){return t/e}),1),xl=Xr("floor");var Sl=Gr((function(t,e){return t*e}),1),El=Xr("round"),Cl=Gr((function(t,e){return t-e}),0);return Hn.after=function(t,e){if("function"!=typeof e)throw new Lt(i);return t=go(t),function(){if(--t<1)return e.apply(this,arguments)}},Hn.ary=Aa,Hn.assign=wo,Hn.assignIn=xo,Hn.assignInWith=So,Hn.assignWith=Eo,Hn.at=Co,Hn.before=Ta,Hn.bind=Ia,Hn.bindAll=el,Hn.bindKey=Oa,Hn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Wa(t)?t:[t]},Hn.chain=pa,Hn.chunk=function(t,e,i){e=(i?ws(t,e,i):e===n)?1:bn(go(e),0);var r=null==t?0:t.length;if(!r||e<1)return[];for(var s=0,a=0,o=Et(ve(r/e));s<r;)o[a++]=sr(t,s,s+=e);return o},Hn.compact=function(t){for(var e=-1,n=null==t?0:t.length,i=0,r=[];++e<n;){var s=t[e];s&&(r[i++]=s)}return r},Hn.concat=function(){var t=arguments.length;if(!t)return[];for(var e=Et(t-1),n=arguments[0],i=t;i--;)e[i-1]=arguments[i];return De(Wa(n)?Or(n):[n],yi(e,1))},Hn.cond=function(t){var e=null==t?0:t.length,n=us();return t=e?ke(t,(function(t){if("function"!=typeof t[1])throw new Lt(i);return[n(t[0]),t[1]]})):[],Yi((function(n){for(var i=-1;++i<e;){var r=t[i];if(Pe(r[0],this,n))return Pe(r[1],this,n)}}))},Hn.conforms=function(t){return function(t){var e=No(t);return function(n){return hi(n,t,e)}}(ui(t,1))},Hn.constant=nl,Hn.countBy=ga,Hn.create=function(t,e){var n=jn(t);return null==e?n:ai(n,e)},Hn.curry=function t(e,i,r){var s=Qr(e,8,n,n,n,n,n,i=r?n:i);return s.placeholder=t.placeholder,s},Hn.curryRight=function t(e,i,r){var s=Qr(e,a,n,n,n,n,n,i=r?n:i);return s.placeholder=t.placeholder,s},Hn.debounce=La,Hn.defaults=Mo,Hn.defaultsDeep=Po,Hn.defer=Na,Hn.delay=Ra,Hn.difference=Vs,Hn.differenceBy=Hs,Hn.differenceWith=js,Hn.drop=function(t,e,i){var r=null==t?0:t.length;return r?sr(t,(e=i||e===n?1:go(e))<0?0:e,r):[]},Hn.dropRight=function(t,e,i){var r=null==t?0:t.length;return r?sr(t,0,(e=r-(e=i||e===n?1:go(e)))<0?0:e):[]},Hn.dropRightWhile=function(t,e){return t&&t.length?mr(t,us(e,3),!0,!0):[]},Hn.dropWhile=function(t,e){return t&&t.length?mr(t,us(e,3),!0):[]},Hn.fill=function(t,e,i,r){var s=null==t?0:t.length;return s?(i&&"number"!=typeof i&&ws(t,e,i)&&(i=0,r=s),function(t,e,i,r){var s=t.length;for((i=go(i))<0&&(i=-i>s?0:s+i),(r=r===n||r>s?s:go(r))<0&&(r+=s),r=i>r?0:vo(r);i<r;)t[i++]=e;return t}(t,e,i,r)):[]},Hn.filter=function(t,e){return(Wa(t)?Le:_i)(t,us(e,3))},Hn.flatMap=function(t,e){return yi(Ea(t,e),1)},Hn.flatMapDeep=function(t,e){return yi(Ea(t,e),h)},Hn.flatMapDepth=function(t,e,i){return i=i===n?1:go(i),yi(Ea(t,e),i)},Hn.flatten=$s,Hn.flattenDeep=function(t){return(null==t?0:t.length)?yi(t,h):[]},Hn.flattenDepth=function(t,e){return(null==t?0:t.length)?yi(t,e=e===n?1:go(e)):[]},Hn.flip=function(t){return Qr(t,512)},Hn.flow=il,Hn.flowRight=rl,Hn.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,i={};++e<n;){var r=t[e];i[r[0]]=r[1]}return i},Hn.functions=function(t){return null==t?[]:Ei(t,No(t))},Hn.functionsIn=function(t){return null==t?[]:Ei(t,Ro(t))},Hn.groupBy=wa,Hn.initial=function(t){return(null==t?0:t.length)?sr(t,0,-1):[]},Hn.intersection=Zs,Hn.intersectionBy=Ks,Hn.intersectionWith=Xs,Hn.invert=Io,Hn.invertBy=Oo,Hn.invokeMap=xa,Hn.iteratee=al,Hn.keyBy=Sa,Hn.keys=No,Hn.keysIn=Ro,Hn.map=Ea,Hn.mapKeys=function(t,e){var n={};return e=us(e,3),xi(t,(function(t,i,r){oi(n,e(t,i,r),t)})),n},Hn.mapValues=function(t,e){var n={};return e=us(e,3),xi(t,(function(t,i,r){oi(n,i,e(t,i,r))})),n},Hn.matches=function(t){return Hi(ui(t,1))},Hn.matchesProperty=function(t,e){return ji(t,ui(e,1))},Hn.memoize=ka,Hn.merge=ko,Hn.mergeWith=Do,Hn.method=ol,Hn.methodOf=ll,Hn.mixin=cl,Hn.negate=Da,Hn.nthArg=function(t){return t=go(t),Yi((function(e){return Wi(e,t)}))},Hn.omit=Uo,Hn.omitBy=function(t,e){return zo(t,Da(us(e)))},Hn.once=function(t){return Ta(2,t)},Hn.orderBy=function(t,e,i,r){return null==t?[]:(Wa(e)||(e=null==e?[]:[e]),Wa(i=r?n:i)||(i=null==i?[]:[i]),$i(t,e,i))},Hn.over=hl,Hn.overArgs=Ua,Hn.overEvery=dl,Hn.overSome=pl,Hn.partial=Fa,Hn.partialRight=za,Hn.partition=Ca,Hn.pick=Fo,Hn.pickBy=zo,Hn.property=fl,Hn.propertyOf=function(t){return function(e){return null==t?n:Ci(t,e)}},Hn.pull=Ys,Hn.pullAll=Qs,Hn.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?Zi(t,e,us(n,2)):t},Hn.pullAllWith=function(t,e,i){return t&&t.length&&e&&e.length?Zi(t,e,n,i):t},Hn.pullAt=ta,Hn.range=ml,Hn.rangeRight=gl,Hn.rearg=Ba,Hn.reject=function(t,e){return(Wa(t)?Le:_i)(t,Da(us(e,3)))},Hn.remove=function(t,e){var n=[];if(!t||!t.length)return n;var i=-1,r=[],s=t.length;for(e=us(e,3);++i<s;){var a=t[i];e(a,i,t)&&(n.push(a),r.push(i))}return Ki(t,r),n},Hn.rest=function(t,e){if("function"!=typeof t)throw new Lt(i);return Yi(t,e=e===n?e:go(e))},Hn.reverse=ea,Hn.sampleSize=function(t,e,i){return e=(i?ws(t,e,i):e===n)?1:go(e),(Wa(t)?ti:tr)(t,e)},Hn.set=function(t,e,n){return null==t?t:er(t,e,n)},Hn.setWith=function(t,e,i,r){return r="function"==typeof r?r:n,null==t?t:er(t,e,i,r)},Hn.shuffle=function(t){return(Wa(t)?ei:rr)(t)},Hn.slice=function(t,e,i){var r=null==t?0:t.length;return r?(i&&"number"!=typeof i&&ws(t,e,i)?(e=0,i=r):(e=null==e?0:go(e),i=i===n?r:go(i)),sr(t,e,i)):[]},Hn.sortBy=Ma,Hn.sortedUniq=function(t){return t&&t.length?cr(t):[]},Hn.sortedUniqBy=function(t,e){return t&&t.length?cr(t,us(e,2)):[]},Hn.split=function(t,e,i){return i&&"number"!=typeof i&&ws(t,e,i)&&(e=i=n),(i=i===n?f:i>>>0)?(t=bo(t))&&("string"==typeof e||null!=e&&!ao(e))&&(!(e=hr(e))&&ln(t))?Sr(fn(t),0,i):t.split(e,i):[]},Hn.spread=function(t,e){if("function"!=typeof t)throw new Lt(i);return e=null==e?0:bn(go(e),0),Yi((function(n){var i=n[e],r=Sr(n,0,e);return i&&De(r,i),Pe(t,this,r)}))},Hn.tail=function(t){var e=null==t?0:t.length;return e?sr(t,1,e):[]},Hn.take=function(t,e,i){return t&&t.length?sr(t,0,(e=i||e===n?1:go(e))<0?0:e):[]},Hn.takeRight=function(t,e,i){var r=null==t?0:t.length;return r?sr(t,(e=r-(e=i||e===n?1:go(e)))<0?0:e,r):[]},Hn.takeRightWhile=function(t,e){return t&&t.length?mr(t,us(e,3),!1,!0):[]},Hn.takeWhile=function(t,e){return t&&t.length?mr(t,us(e,3)):[]},Hn.tap=function(t,e){return e(t),t},Hn.throttle=function(t,e,n){var r=!0,s=!0;if("function"!=typeof t)throw new Lt(i);return eo(n)&&(r="leading"in n?!!n.leading:r,s="trailing"in n?!!n.trailing:s),La(t,e,{leading:r,maxWait:e,trailing:s})},Hn.thru=fa,Hn.toArray=fo,Hn.toPairs=Bo,Hn.toPairsIn=Vo,Hn.toPath=function(t){return Wa(t)?ke(t,Fs):co(t)?[t]:Or(Us(bo(t)))},Hn.toPlainObject=yo,Hn.transform=function(t,e,n){var i=Wa(t),r=i||Ka(t)||uo(t);if(e=us(e,4),null==n){var s=t&&t.constructor;n=r?i?new s:[]:eo(t)&&Ya(s)?jn(Kt(t)):{}}return(r?Te:xi)(t,(function(t,i,r){return e(n,t,i,r)})),n},Hn.unary=function(t){return Aa(t,1)},Hn.union=na,Hn.unionBy=ia,Hn.unionWith=ra,Hn.uniq=function(t){return t&&t.length?dr(t):[]},Hn.uniqBy=function(t,e){return t&&t.length?dr(t,us(e,2)):[]},Hn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?dr(t,n,e):[]},Hn.unset=function(t,e){return null==t||pr(t,e)},Hn.unzip=sa,Hn.unzipWith=aa,Hn.update=function(t,e,n){return null==t?t:fr(t,e,br(n))},Hn.updateWith=function(t,e,i,r){return r="function"==typeof r?r:n,null==t?t:fr(t,e,br(i),r)},Hn.values=Ho,Hn.valuesIn=function(t){return null==t?[]:tn(t,Ro(t))},Hn.without=oa,Hn.words=Qo,Hn.wrap=function(t,e){return Fa(br(e),t)},Hn.xor=la,Hn.xorBy=ca,Hn.xorWith=ua,Hn.zip=ha,Hn.zipObject=function(t,e){return _r(t||[],e||[],ii)},Hn.zipObjectDeep=function(t,e){return _r(t||[],e||[],er)},Hn.zipWith=da,Hn.entries=Bo,Hn.entriesIn=Vo,Hn.extend=xo,Hn.extendWith=So,cl(Hn,Hn),Hn.add=yl,Hn.attempt=tl,Hn.camelCase=jo,Hn.capitalize=Go,Hn.ceil=bl,Hn.clamp=function(t,e,i){return i===n&&(i=e,e=n),i!==n&&(i=(i=_o(i))==i?i:0),e!==n&&(e=(e=_o(e))==e?e:0),ci(_o(t),e,i)},Hn.clone=function(t){return ui(t,4)},Hn.cloneDeep=function(t){return ui(t,5)},Hn.cloneDeepWith=function(t,e){return ui(t,5,e="function"==typeof e?e:n)},Hn.cloneWith=function(t,e){return ui(t,4,e="function"==typeof e?e:n)},Hn.conformsTo=function(t,e){return null==e||hi(t,e,No(e))},Hn.deburr=Wo,Hn.defaultTo=function(t,e){return null==t||t!=t?e:t},Hn.divide=wl,Hn.endsWith=function(t,e,i){t=bo(t),e=hr(e);var r=t.length,s=i=i===n?r:ci(go(i),0,r);return(i-=e.length)>=0&&t.slice(i,s)==e},Hn.eq=Va,Hn.escape=function(t){return(t=bo(t))&&J.test(t)?t.replace(K,an):t},Hn.escapeRegExp=function(t){return(t=bo(t))&&st.test(t)?t.replace(rt,"\\$&"):t},Hn.every=function(t,e,i){var r=Wa(t)?Oe:gi;return i&&ws(t,e,i)&&(e=n),r(t,us(e,3))},Hn.find=va,Hn.findIndex=Gs,Hn.findKey=function(t,e){return Ve(t,us(e,3),xi)},Hn.findLast=_a,Hn.findLastIndex=Ws,Hn.findLastKey=function(t,e){return Ve(t,us(e,3),Si)},Hn.floor=xl,Hn.forEach=ya,Hn.forEachRight=ba,Hn.forIn=function(t,e){return null==t?t:bi(t,us(e,3),Ro)},Hn.forInRight=function(t,e){return null==t?t:wi(t,us(e,3),Ro)},Hn.forOwn=function(t,e){return t&&xi(t,us(e,3))},Hn.forOwnRight=function(t,e){return t&&Si(t,us(e,3))},Hn.get=Ao,Hn.gt=Ha,Hn.gte=ja,Hn.has=function(t,e){return null!=t&&vs(t,e,Ti)},Hn.hasIn=To,Hn.head=qs,Hn.identity=sl,Hn.includes=function(t,e,n,i){t=qa(t)?t:Ho(t),n=n&&!i?go(n):0;var r=t.length;return n<0&&(n=bn(r+n,0)),lo(t)?n<=r&&t.indexOf(e,n)>-1:!!r&&je(t,e,n)>-1},Hn.indexOf=function(t,e,n){var i=null==t?0:t.length;if(!i)return-1;var r=null==n?0:go(n);return r<0&&(r=bn(i+r,0)),je(t,e,r)},Hn.inRange=function(t,e,i){return e=mo(e),i===n?(i=e,e=0):i=mo(i),function(t,e,n){return t>=wn(e,n)&&t<bn(e,n)}(t=_o(t),e,i)},Hn.invoke=Lo,Hn.isArguments=Ga,Hn.isArray=Wa,Hn.isArrayBuffer=$a,Hn.isArrayLike=qa,Hn.isArrayLikeObject=Za,Hn.isBoolean=function(t){return!0===t||!1===t||no(t)&&Pi(t)==b},Hn.isBuffer=Ka,Hn.isDate=Xa,Hn.isElement=function(t){return no(t)&&1===t.nodeType&&!so(t)},Hn.isEmpty=function(t){if(null==t)return!0;if(qa(t)&&(Wa(t)||"string"==typeof t||"function"==typeof t.splice||Ka(t)||uo(t)||Ga(t)))return!t.length;var e=gs(t);if(e==C||e==I)return!t.size;if(Cs(t))return!Fi(t).length;for(var n in t)if(Ft.call(t,n))return!1;return!0},Hn.isEqual=function(t,e){return Ri(t,e)},Hn.isEqualWith=function(t,e,i){var r=(i="function"==typeof i?i:n)?i(t,e):n;return r===n?Ri(t,e,n,i):!!r},Hn.isError=Ja,Hn.isFinite=function(t){return"number"==typeof t&&Ze(t)},Hn.isFunction=Ya,Hn.isInteger=Qa,Hn.isLength=to,Hn.isMap=io,Hn.isMatch=function(t,e){return t===e||ki(t,e,ds(e))},Hn.isMatchWith=function(t,e,i){return i="function"==typeof i?i:n,ki(t,e,ds(e),i)},Hn.isNaN=function(t){return ro(t)&&t!=+t},Hn.isNative=function(t){if(Es(t))throw new Mt("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Di(t)},Hn.isNil=function(t){return null==t},Hn.isNull=function(t){return null===t},Hn.isNumber=ro,Hn.isObject=eo,Hn.isObjectLike=no,Hn.isPlainObject=so,Hn.isRegExp=ao,Hn.isSafeInteger=function(t){return Qa(t)&&t>=-d&&t<=d},Hn.isSet=oo,Hn.isString=lo,Hn.isSymbol=co,Hn.isTypedArray=uo,Hn.isUndefined=function(t){return t===n},Hn.isWeakMap=function(t){return no(t)&&gs(t)==N},Hn.isWeakSet=function(t){return no(t)&&"[object WeakSet]"==Pi(t)},Hn.join=function(t,e){return null==t?"":_n.call(t,e)},Hn.kebabCase=$o,Hn.last=Js,Hn.lastIndexOf=function(t,e,i){var r=null==t?0:t.length;if(!r)return-1;var s=r;return i!==n&&(s=(s=go(i))<0?bn(r+s,0):wn(s,r-1)),e==e?function(t,e,n){for(var i=n+1;i--;)if(t[i]===e)return i;return i}(t,e,s):He(t,We,s,!0)},Hn.lowerCase=qo,Hn.lowerFirst=Zo,Hn.lt=ho,Hn.lte=po,Hn.max=function(t){return t&&t.length?vi(t,sl,Ai):n},Hn.maxBy=function(t,e){return t&&t.length?vi(t,us(e,2),Ai):n},Hn.mean=function(t){return $e(t,sl)},Hn.meanBy=function(t,e){return $e(t,us(e,2))},Hn.min=function(t){return t&&t.length?vi(t,sl,Bi):n},Hn.minBy=function(t,e){return t&&t.length?vi(t,us(e,2),Bi):n},Hn.stubArray=vl,Hn.stubFalse=_l,Hn.stubObject=function(){return{}},Hn.stubString=function(){return""},Hn.stubTrue=function(){return!0},Hn.multiply=Sl,Hn.nth=function(t,e){return t&&t.length?Wi(t,go(e)):n},Hn.noConflict=function(){return me._===this&&(me._=jt),this},Hn.noop=ul,Hn.now=Pa,Hn.pad=function(t,e,n){t=bo(t);var i=(e=go(e))?pn(t):0;if(!e||i>=e)return t;var r=(e-i)/2;return $r(ye(r),n)+t+$r(ve(r),n)},Hn.padEnd=function(t,e,n){t=bo(t);var i=(e=go(e))?pn(t):0;return e&&i<e?t+$r(e-i,n):t},Hn.padStart=function(t,e,n){t=bo(t);var i=(e=go(e))?pn(t):0;return e&&i<e?$r(e-i,n)+t:t},Hn.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),Sn(bo(t).replace(at,""),e||0)},Hn.random=function(t,e,i){if(i&&"boolean"!=typeof i&&ws(t,e,i)&&(e=i=n),i===n&&("boolean"==typeof e?(i=e,e=n):"boolean"==typeof t&&(i=t,t=n)),t===n&&e===n?(t=0,e=1):(t=mo(t),e===n?(e=t,t=0):e=mo(e)),t>e){var r=t;t=e,e=r}if(i||t%1||e%1){var s=En();return wn(t+s*(e-t+he("1e-"+((s+"").length-1))),e)}return Xi(t,e)},Hn.reduce=function(t,e,n){var i=Wa(t)?Ue:Ke,r=arguments.length<3;return i(t,us(e,4),n,r,fi)},Hn.reduceRight=function(t,e,n){var i=Wa(t)?Fe:Ke,r=arguments.length<3;return i(t,us(e,4),n,r,mi)},Hn.repeat=function(t,e,i){return e=(i?ws(t,e,i):e===n)?1:go(e),Ji(bo(t),e)},Hn.replace=function(){var t=arguments,e=bo(t[0]);return t.length<3?e:e.replace(t[1],t[2])},Hn.result=function(t,e,i){var r=-1,s=(e=wr(e,t)).length;for(s||(s=1,t=n);++r<s;){var a=null==t?n:t[Fs(e[r])];a===n&&(r=s,a=i),t=Ya(a)?a.call(t):a}return t},Hn.round=El,Hn.runInContext=t,Hn.sample=function(t){return(Wa(t)?Qn:Qi)(t)},Hn.size=function(t){if(null==t)return 0;if(qa(t))return lo(t)?pn(t):t.length;var e=gs(t);return e==C||e==I?t.size:Fi(t).length},Hn.snakeCase=Ko,Hn.some=function(t,e,i){var r=Wa(t)?ze:ar;return i&&ws(t,e,i)&&(e=n),r(t,us(e,3))},Hn.sortedIndex=function(t,e){return or(t,e)},Hn.sortedIndexBy=function(t,e,n){return lr(t,e,us(n,2))},Hn.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var i=or(t,e);if(i<n&&Va(t[i],e))return i}return-1},Hn.sortedLastIndex=function(t,e){return or(t,e,!0)},Hn.sortedLastIndexBy=function(t,e,n){return lr(t,e,us(n,2),!0)},Hn.sortedLastIndexOf=function(t,e){if(null==t?0:t.length){var n=or(t,e,!0)-1;if(Va(t[n],e))return n}return-1},Hn.startCase=Xo,Hn.startsWith=function(t,e,n){return t=bo(t),n=null==n?0:ci(go(n),0,t.length),e=hr(e),t.slice(n,n+e.length)==e},Hn.subtract=Cl,Hn.sum=function(t){return t&&t.length?Xe(t,sl):0},Hn.sumBy=function(t,e){return t&&t.length?Xe(t,us(e,2)):0},Hn.template=function(t,e,i){var r=Hn.templateSettings;i&&ws(t,e,i)&&(e=n),t=bo(t),e=So({},e,r,ts);var s,a,o=So({},e.imports,r.imports,ts),l=No(o),c=tn(o,l),u=0,h=e.interpolate||xt,d="__p += '",p=It((e.escape||xt).source+"|"+h.source+"|"+(h===tt?ft:xt).source+"|"+(e.evaluate||xt).source+"|$","g"),f="//# sourceURL="+(Ft.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++oe+"]")+"\n";t.replace(p,(function(e,n,i,r,o,l){return i||(i=r),d+=t.slice(u,l).replace(St,on),n&&(s=!0,d+="' +\n__e("+n+") +\n'"),o&&(a=!0,d+="';\n"+o+";\n__p += '"),i&&(d+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),u=l+e.length,e})),d+="';\n";var m=Ft.call(e,"variable")&&e.variable;if(m){if(dt.test(m))throw new Mt("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(a?d.replace(W,""):d).replace($,"$1").replace(q,"$1;"),d="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=tl((function(){return Pt(l,f+"return "+d).apply(n,c)}));if(g.source=d,Ja(g))throw g;return g},Hn.times=function(t,e){if((t=go(t))<1||t>d)return[];var n=f,i=wn(t,f);e=us(e),t-=f;for(var r=Je(i,e);++n<t;)e(n);return r},Hn.toFinite=mo,Hn.toInteger=go,Hn.toLength=vo,Hn.toLower=function(t){return bo(t).toLowerCase()},Hn.toNumber=_o,Hn.toSafeInteger=function(t){return t?ci(go(t),-d,d):0===t?t:0},Hn.toString=bo,Hn.toUpper=function(t){return bo(t).toUpperCase()},Hn.trim=function(t,e,i){if((t=bo(t))&&(i||e===n))return Ye(t);if(!t||!(e=hr(e)))return t;var r=fn(t),s=fn(e);return Sr(r,nn(r,s),rn(r,s)+1).join("")},Hn.trimEnd=function(t,e,i){if((t=bo(t))&&(i||e===n))return t.slice(0,mn(t)+1);if(!t||!(e=hr(e)))return t;var r=fn(t);return Sr(r,0,rn(r,fn(e))+1).join("")},Hn.trimStart=function(t,e,i){if((t=bo(t))&&(i||e===n))return t.replace(at,"");if(!t||!(e=hr(e)))return t;var r=fn(t);return Sr(r,nn(r,fn(e))).join("")},Hn.truncate=function(t,e){var i=30,r="...";if(eo(e)){var s="separator"in e?e.separator:s;i="length"in e?go(e.length):i,r="omission"in e?hr(e.omission):r}var a=(t=bo(t)).length;if(ln(t)){var o=fn(t);a=o.length}if(i>=a)return t;var l=i-pn(r);if(l<1)return r;var c=o?Sr(o,0,l).join(""):t.slice(0,l);if(s===n)return c+r;if(o&&(l+=c.length-l),ao(s)){if(t.slice(l).search(s)){var u,h=c;for(s.global||(s=It(s.source,bo(mt.exec(s))+"g")),s.lastIndex=0;u=s.exec(h);)var d=u.index;c=c.slice(0,d===n?l:d)}}else if(t.indexOf(hr(s),l)!=l){var p=c.lastIndexOf(s);p>-1&&(c=c.slice(0,p))}return c+r},Hn.unescape=function(t){return(t=bo(t))&&X.test(t)?t.replace(Z,gn):t},Hn.uniqueId=function(t){var e=++zt;return bo(t)+e},Hn.upperCase=Jo,Hn.upperFirst=Yo,Hn.each=ya,Hn.eachRight=ba,Hn.first=qs,cl(Hn,function(){var t={};return xi(Hn,(function(e,n){Ft.call(Hn.prototype,n)||(t[n]=e)})),t}(),{chain:!1}),Hn.VERSION="4.17.21",Te(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Hn[t].placeholder=Hn})),Te(["drop","take"],(function(t,e){$n.prototype[t]=function(i){i=i===n?1:bn(go(i),0);var r=this.__filtered__&&!e?new $n(this):this.clone();return r.__filtered__?r.__takeCount__=wn(i,r.__takeCount__):r.__views__.push({size:wn(i,f),type:t+(r.__dir__<0?"Right":"")}),r},$n.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Te(["filter","map","takeWhile"],(function(t,e){var n=e+1,i=1==n||3==n;$n.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:us(t,3),type:n}),e.__filtered__=e.__filtered__||i,e}})),Te(["head","last"],(function(t,e){var n="take"+(e?"Right":"");$n.prototype[t]=function(){return this[n](1).value()[0]}})),Te(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");$n.prototype[t]=function(){return this.__filtered__?new $n(this):this[n](1)}})),$n.prototype.compact=function(){return this.filter(sl)},$n.prototype.find=function(t){return this.filter(t).head()},$n.prototype.findLast=function(t){return this.reverse().find(t)},$n.prototype.invokeMap=Yi((function(t,e){return"function"==typeof t?new $n(this):this.map((function(n){return Li(n,t,e)}))})),$n.prototype.reject=function(t){return this.filter(Da(us(t)))},$n.prototype.slice=function(t,e){t=go(t);var i=this;return i.__filtered__&&(t>0||e<0)?new $n(i):(t<0?i=i.takeRight(-t):t&&(i=i.drop(t)),e!==n&&(i=(e=go(e))<0?i.dropRight(-e):i.take(e-t)),i)},$n.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},$n.prototype.toArray=function(){return this.take(f)},xi($n.prototype,(function(t,e){var i=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),s=Hn[r?"take"+("last"==e?"Right":""):e],a=r||/^find/.test(e);s&&(Hn.prototype[e]=function(){var e=this.__wrapped__,o=r?[1]:arguments,l=e instanceof $n,c=o[0],u=l||Wa(e),h=function(t){var e=s.apply(Hn,De([t],o));return r&&d?e[0]:e};u&&i&&"function"==typeof c&&1!=c.length&&(l=u=!1);var d=this.__chain__,p=!!this.__actions__.length,f=a&&!d,m=l&&!p;if(!a&&u){e=m?e:new $n(this);var g=t.apply(e,o);return g.__actions__.push({func:fa,args:[h],thisArg:n}),new Wn(g,d)}return f&&m?t.apply(this,o):(g=this.thru(h),f?r?g.value()[0]:g.value():g)})})),Te(["pop","push","shift","sort","splice","unshift"],(function(t){var e=Nt[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:pop|shift)$/.test(t);Hn.prototype[t]=function(){var t=arguments;if(i&&!this.__chain__){var r=this.value();return e.apply(Wa(r)?r:[],t)}return this[n]((function(n){return e.apply(Wa(n)?n:[],t)}))}})),xi($n.prototype,(function(t,e){var n=Hn[e];if(n){var i=n.name+"";Ft.call(Nn,i)||(Nn[i]=[]),Nn[i].push({name:e,func:n})}})),Nn[Hr(n,2).name]=[{name:"wrapper",func:n}],$n.prototype.clone=function(){var t=new $n(this.__wrapped__);return t.__actions__=Or(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Or(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Or(this.__views__),t},$n.prototype.reverse=function(){if(this.__filtered__){var t=new $n(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},$n.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=Wa(t),i=e<0,r=n?t.length:0,s=function(t,e,n){for(var i=-1,r=n.length;++i<r;){var s=n[i],a=s.size;switch(s.type){case"drop":t+=a;break;case"dropRight":e-=a;break;case"take":e=wn(e,t+a);break;case"takeRight":t=bn(t,e-a)}}return{start:t,end:e}}(0,r,this.__views__),a=s.start,o=s.end,l=o-a,c=i?o:a-1,u=this.__iteratees__,h=u.length,d=0,p=wn(l,this.__takeCount__);if(!n||!i&&r==l&&p==l)return gr(t,this.__actions__);var f=[];t:for(;l--&&d<p;){for(var m=-1,g=t[c+=e];++m<h;){var v=u[m],_=v.iteratee,y=v.type,b=_(g);if(2==y)g=b;else if(!b){if(1==y)continue t;break t}}f[d++]=g}return f},Hn.prototype.at=ma,Hn.prototype.chain=function(){return pa(this)},Hn.prototype.commit=function(){return new Wn(this.value(),this.__chain__)},Hn.prototype.next=function(){this.__values__===n&&(this.__values__=fo(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},Hn.prototype.plant=function(t){for(var e,i=this;i instanceof Gn;){var r=Bs(i);r.__index__=0,r.__values__=n,e?s.__wrapped__=r:e=r;var s=r;i=i.__wrapped__}return s.__wrapped__=t,e},Hn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof $n){var e=t;return this.__actions__.length&&(e=new $n(this)),(e=e.reverse()).__actions__.push({func:fa,args:[ea],thisArg:n}),new Wn(e,this.__chain__)}return this.thru(ea)},Hn.prototype.toJSON=Hn.prototype.valueOf=Hn.prototype.value=function(){return gr(this.__wrapped__,this.__actions__)},Hn.prototype.first=Hn.prototype.head,ne&&(Hn.prototype[ne]=function(){return this}),Hn}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(me._=vn,define((function(){return vn}))):ve?((ve.exports=vn)._=vn,ge._=vn):me._=vn}).call(t)})),bf=Ke(((t,e)=>{var n=1e3,i=6e4,r=60*i,s=24*r,a=7*s,o=365.25*s;function l(t,e,n,i){var r=e>=1.5*n;return Math.round(t/n)+" "+i+(r?"s":"")}e.exports=function(t,e){e=e||{};var c=typeof t;if("string"===c&&t.length>0)return function(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var l=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*o;case"weeks":case"week":case"w":return l*a;case"days":case"day":case"d":return l*s;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*i;case"seconds":case"second":case"secs":case"sec":case"s":return l*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}}}(t);if("number"===c&&isFinite(t))return e.long?function(t){var e=Math.abs(t);return e>=s?l(t,e,s,"day"):e>=r?l(t,e,r,"hour"):e>=i?l(t,e,i,"minute"):e>=n?l(t,e,n,"second"):t+" ms"}(t):function(t){var e=Math.abs(t);return e>=s?Math.round(t/s)+"d":e>=r?Math.round(t/r)+"h":e>=i?Math.round(t/i)+"m":e>=n?Math.round(t/n)+"s":t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}})),wf=Ke(((t,e)=>{e.exports=function(t){function e(t){let i,r,s,a=null;function o(...t){if(!o.enabled)return;let n=o,r=Number(new Date),s=r-(i||r);n.diff=s,n.prev=i,n.curr=r,i=r,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let a=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((i,r)=>{if("%%"===i)return"%";a++;let s=e.formatters[r];if("function"==typeof s){let e=t[a];i=s.call(n,e),t.splice(a,1),a--}return i})),e.formatArgs.call(n,t),(n.log||e.log).apply(n,t)}return o.namespace=t,o.useColors=e.useColors(),o.color=e.selectColor(t),o.extend=n,o.destroy=e.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(r!==e.namespaces&&(r=e.namespaces,s=e.enabled(t)),s),set:t=>{a=t}}),"function"==typeof e.init&&e.init(o),o}function n(t,n){let i=e(this.namespace+(typeof n>"u"?":":n)+t);return i.log=this.log,i}function i(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return e.debug=e,e.default=e,e.coerce=function(t){return t instanceof Error?t.stack||t.message:t},e.disable=function(){let t=[...e.names.map(i),...e.skips.map(i).map((t=>"-"+t))].join(",");return e.enable(""),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];let n,i=("string"==typeof t?t:"").split(/[\s,]+/),r=i.length;for(n=0;n<r;n++)i[n]&&("-"===(t=i[n].replace(/\*/g,".*?"))[0]?e.skips.push(new RegExp("^"+t.slice(1)+"$")):e.names.push(new RegExp("^"+t+"$")))},e.enabled=function(t){if("*"===t[t.length-1])return!0;let n,i;for(n=0,i=e.skips.length;n<i;n++)if(e.skips[n].test(t))return!1;for(n=0,i=e.names.length;n<i;n++)if(e.names[n].test(t))return!0;return!1},e.humanize=bf(),e.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach((n=>{e[n]=t[n]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e.colors[Math.abs(n)%e.colors.length]},e.enable(e.load()),e}})),Sf=Ke(((t,e)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;let n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(t=>{"%%"!==t&&(i++,"%c"===t&&(r=i))})),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if(typeof window<"u"&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=wf()(t);var{formatters:n}=e.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}})),To=Ke(((t,e)=>{e.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}})),If=Ke(((t,e)=>{var n="object"==typeof window&&window&&window.Object===Object&&window;e.exports=n})),yc=Ke(((t,e)=>{var n=If(),i="object"==typeof self&&self&&self.Object===Object&&self,r=n||i||Function("return this")();e.exports=r})),Df=Ke(((t,e)=>{var n=yc();e.exports=function(){return n.Date.now()}})),Ff=Ke(((t,e)=>{var n=/\s/;e.exports=function(t){for(var e=t.length;e--&&n.test(t.charAt(e)););return e}})),kf=Ke(((t,e)=>{var n=Ff(),i=/^\s+/;e.exports=function(t){return t&&t.slice(0,n(t)+1).replace(i,"")}})),_c=Ke(((t,e)=>{var n=yc().Symbol;e.exports=n})),Wf=Ke(((t,e)=>{var n=_c(),i=Object.prototype,r=i.hasOwnProperty,s=i.toString,a=n?n.toStringTag:void 0;e.exports=function(t){var e=r.call(t,a),n=t[a];try{t[a]=void 0;var i=!0}catch{}var o=s.call(t);return i&&(e?t[a]=n:delete t[a]),o}})),Xf=Ke(((t,e)=>{var n=Object.prototype.toString;e.exports=function(t){return n.call(t)}})),Yf=Ke(((t,e)=>{var n=_c(),i=Wf(),r=Xf(),s=n?n.toStringTag:void 0;e.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?i(t):r(t)}})),Kf=Ke(((t,e)=>{e.exports=function(t){return null!=t&&"object"==typeof t}})),Qf=Ke(((t,e)=>{var n=Yf(),i=Kf();e.exports=function(t){return"symbol"==typeof t||i(t)&&"[object Symbol]"==n(t)}})),im=Ke(((t,e)=>{var n=kf(),i=To(),r=Qf(),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,l=parseInt;e.exports=function(t){if("number"==typeof t)return t;if(r(t))return NaN;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=n(t);var c=a.test(t);return c||o.test(t)?l(t.slice(2),c?2:8):s.test(t)?NaN:+t}})),om=Ke(((t,e)=>{var n=To(),i=Df(),r=im(),s=Math.max,a=Math.min;e.exports=function(t,e,o){var l,c,u,h,d,p,f=0,m=!1,g=!1,v=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function _(e){var n=l,i=c;return l=c=void 0,f=e,h=t.apply(i,n)}function y(t){var n=t-p;return void 0===p||n>=e||n<0||g&&t-f>=u}function b(){var t=i();if(y(t))return w(t);d=setTimeout(b,function(t){var n=e-(t-p);return g?a(n,u-(t-f)):n}(t))}function w(t){return d=void 0,v&&l?_(t):(l=c=void 0,h)}function x(){var t=i(),n=y(t);if(l=arguments,c=this,p=t,n){if(void 0===d)return function(t){return f=t,d=setTimeout(b,e),m?_(t):h}(p);if(g)return clearTimeout(d),d=setTimeout(b,e),_(p)}return void 0===d&&(d=setTimeout(b,e)),h}return e=r(e)||0,n(o)&&(m=!!o.leading,u=(g="maxWait"in o)?s(r(o.maxWait)||0,e):u,v="trailing"in o?!!o.trailing:v),x.cancel=function(){void 0!==d&&clearTimeout(d),f=0,l=p=c=d=void 0},x.flush=function(){return void 0===d?h:w(i())},x}})),lm=Ke(((t,e)=>{var n=om(),i=To();e.exports=function(t,e,r){var s=!0,a=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return i(r)&&(s="leading"in r?!!r.leading:s,a="trailing"in r?!!r.trailing:a),n(t,e,{leading:s,maxWait:e,trailing:a})}})),Yx=Ge(((t,e)=>{z();var n=1e3,i=60*n,r=60*i,s=24*r,a=7*s,o=365.25*s;function l(t,e,n,i){var r=e>=1.5*n;return Math.round(t/n)+" "+i+(r?"s":"")}e.exports=function(t,e){e=e||{};var c=typeof t;if("string"===c&&t.length>0)return function(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var l=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*o;case"weeks":case"week":case"w":return l*a;case"days":case"day":case"d":return l*s;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*i;case"seconds":case"second":case"secs":case"sec":case"s":return l*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}}}(t);if("number"===c&&isFinite(t))return e.long?function(t){var e=Math.abs(t);return e>=s?l(t,e,s,"day"):e>=r?l(t,e,r,"hour"):e>=i?l(t,e,i,"minute"):e>=n?l(t,e,n,"second"):t+" ms"}(t):function(t){var e=Math.abs(t);return e>=s?Math.round(t/s)+"d":e>=r?Math.round(t/r)+"h":e>=i?Math.round(t/i)+"m":e>=n?Math.round(t/n)+"s":t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}})),Jx=Ge(((t,e)=>{z(),e.exports=function(t){function e(t){let i,r,s,a=null;function o(...t){if(!o.enabled)return;let n=o,r=Number(new Date),s=r-(i||r);n.diff=s,n.prev=i,n.curr=r,i=r,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let a=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((i,r)=>{if("%%"===i)return"%";a++;let s=e.formatters[r];if("function"==typeof s){let e=t[a];i=s.call(n,e),t.splice(a,1),a--}return i})),e.formatArgs.call(n,t),(n.log||e.log).apply(n,t)}return o.namespace=t,o.useColors=e.useColors(),o.color=e.selectColor(t),o.extend=n,o.destroy=e.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(r!==e.namespaces&&(r=e.namespaces,s=e.enabled(t)),s),set:t=>{a=t}}),"function"==typeof e.init&&e.init(o),o}function n(t,n){let i=e(this.namespace+(typeof n>"u"?":":n)+t);return i.log=this.log,i}function i(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return e.debug=e,e.default=e,e.coerce=function(t){return t instanceof Error?t.stack||t.message:t},e.disable=function(){let t=[...e.names.map(i),...e.skips.map(i).map((t=>"-"+t))].join(",");return e.enable(""),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];let n,i=("string"==typeof t?t:"").split(/[\s,]+/),r=i.length;for(n=0;n<r;n++)i[n]&&("-"===(t=i[n].replace(/\*/g,".*?"))[0]?e.skips.push(new RegExp("^"+t.slice(1)+"$")):e.names.push(new RegExp("^"+t+"$")))},e.enabled=function(t){if("*"===t[t.length-1])return!0;let n,i;for(n=0,i=e.skips.length;n<i;n++)if(e.skips[n].test(t))return!1;for(n=0,i=e.names.length;n<i;n++)if(e.names[n].test(t))return!0;return!1},e.humanize=Yx(),e.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach((n=>{e[n]=t[n]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e.colors[Math.abs(n)%e.colors.length]},e.enable(e.load()),e}})),Wd=Ge(((t,e)=>{z(),t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;let n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(t=>{"%%"!==t&&(i++,"%c"===t&&(r=i))})),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=Qa.DEBUG),e},t.useColors=function(){if(typeof window<"u"&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Jx()(t);var{formatters:n}=e.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}})),Il=Ge(((t,e)=>{z(),e.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}})),Kx=Ge(((t,e)=>{z();var n="object"==typeof window&&window&&window.Object===Object&&window;e.exports=n})),Gd=Ge(((t,e)=>{z();var n=Kx(),i="object"==typeof self&&self&&self.Object===Object&&self,r=n||i||Function("return this")();e.exports=r})),jx=Ge(((t,e)=>{z();var n=Gd();e.exports=function(){return n.Date.now()}})),Qx=Ge(((t,e)=>{z();var n=/\s/;e.exports=function(t){for(var e=t.length;e--&&n.test(t.charAt(e)););return e}})),ew=Ge(((t,e)=>{z();var n=Qx(),i=/^\s+/;e.exports=function(t){return t&&t.slice(0,n(t)+1).replace(i,"")}})),Xd=Ge(((t,e)=>{z();var n=Gd().Symbol;e.exports=n})),tw=Ge(((t,e)=>{z();var n=Xd(),i=Object.prototype,r=i.hasOwnProperty,s=i.toString,a=n?n.toStringTag:void 0;e.exports=function(t){var e=r.call(t,a),n=t[a];try{t[a]=void 0;var i=!0}catch{}var o=s.call(t);return i&&(e?t[a]=n:delete t[a]),o}})),nw=Ge(((t,e)=>{z();var n=Object.prototype.toString;e.exports=function(t){return n.call(t)}})),iw=Ge(((t,e)=>{z();var n=Xd(),i=tw(),r=nw(),s=n?n.toStringTag:void 0;e.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?i(t):r(t)}})),sw=Ge(((t,e)=>{z(),e.exports=function(t){return null!=t&&"object"==typeof t}})),rw=Ge(((t,e)=>{z();var n=iw(),i=sw();e.exports=function(t){return"symbol"==typeof t||i(t)&&"[object Symbol]"==n(t)}})),ow=Ge(((t,e)=>{z();var n=ew(),i=Il(),r=rw(),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,l=parseInt;e.exports=function(t){if("number"==typeof t)return t;if(r(t))return NaN;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=n(t);var c=a.test(t);return c||o.test(t)?l(t.slice(2),c?2:8):s.test(t)?NaN:+t}})),aw=Ge(((t,e)=>{z();var n=Il(),i=jx(),r=ow(),s=Math.max,a=Math.min;e.exports=function(t,e,o){var l,c,u,h,d,p,f=0,m=!1,g=!1,v=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function _(e){var n=l,i=c;return l=c=void 0,f=e,h=t.apply(i,n)}function y(t){var n=t-p;return void 0===p||n>=e||n<0||g&&t-f>=u}function b(){var t=i();if(y(t))return w(t);d=setTimeout(b,function(t){var n=e-(t-p);return g?a(n,u-(t-f)):n}(t))}function w(t){return d=void 0,v&&l?_(t):(l=c=void 0,h)}function x(){var t=i(),n=y(t);if(l=arguments,c=this,p=t,n){if(void 0===d)return function(t){return f=t,d=setTimeout(b,e),m?_(t):h}(p);if(g)return clearTimeout(d),d=setTimeout(b,e),_(p)}return void 0===d&&(d=setTimeout(b,e)),h}return e=r(e)||0,n(o)&&(m=!!o.leading,u=(g="maxWait"in o)?s(r(o.maxWait)||0,e):u,v="trailing"in o?!!o.trailing:v),x.cancel=function(){void 0!==d&&clearTimeout(d),f=0,l=p=c=d=void 0},x.flush=function(){return void 0===d?h:w(i())},x}})),qd=Ge(((t,e)=>{z();var n=aw(),i=Il();e.exports=function(t,e,r){var s=!0,a=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return i(r)&&(s="leading"in r?!!r.leading:s,a="trailing"in r?!!r.trailing:a),n(t,e,{leading:s,maxWait:e,trailing:a})}})),lw=Ge(((t,e)=>{var n,i;z(),n=t,i=function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e||4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=90)}({17:function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var i=n(18),r=function(){function t(){}return t.getFirstMatch=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},t.getSecondMatch=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""},t.matchAndReturnConst=function(t,e,n){if(t.test(e))return n},t.getWindowsVersionName=function(t){switch(t){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},t.getMacOSVersionName=function(t){var e=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(e.push(0),10===e[0])switch(e[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},t.getAndroidVersionName=function(t){var e=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(e.push(0),!(1===e[0]&&e[1]<5))return 1===e[0]&&e[1]<6?"Cupcake":1===e[0]&&e[1]>=6?"Donut":2===e[0]&&e[1]<2?"Eclair":2===e[0]&&2===e[1]?"Froyo":2===e[0]&&e[1]>2?"Gingerbread":3===e[0]?"Honeycomb":4===e[0]&&e[1]<1?"Ice Cream Sandwich":4===e[0]&&e[1]<4?"Jelly Bean":4===e[0]&&e[1]>=4?"KitKat":5===e[0]?"Lollipop":6===e[0]?"Marshmallow":7===e[0]?"Nougat":8===e[0]?"Oreo":9===e[0]?"Pie":void 0},t.getVersionPrecision=function(t){return t.split(".").length},t.compareVersions=function(e,n,i){void 0===i&&(i=!1);var r=t.getVersionPrecision(e),s=t.getVersionPrecision(n),a=Math.max(r,s),o=0,l=t.map([e,n],(function(e){var n=a-t.getVersionPrecision(e),i=e+new Array(n+1).join(".0");return t.map(i.split("."),(function(t){return new Array(20-t.length).join("0")+t})).reverse()}));for(i&&(o=a-Math.min(r,s)),a-=1;a>=o;){if(l[0][a]>l[1][a])return 1;if(l[0][a]===l[1][a]){if(a===o)return 0;a-=1}else if(l[0][a]<l[1][a])return-1}},t.map=function(t,e){var n,i=[];if(Array.prototype.map)return Array.prototype.map.call(t,e);for(n=0;n<t.length;n+=1)i.push(e(t[n]));return i},t.find=function(t,e){var n,i;if(Array.prototype.find)return Array.prototype.find.call(t,e);for(n=0,i=t.length;n<i;n+=1){var r=t[n];if(e(r,n))return r}},t.assign=function(t){for(var e,n,i=t,r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];if(Object.assign)return Object.assign.apply(Object,[t].concat(s));var o=function(){var t=s[e];"object"==typeof t&&null!==t&&Object.keys(t).forEach((function(e){i[e]=t[e]}))};for(e=0,n=s.length;e<n;e+=1)o();return t},t.getBrowserAlias=function(t){return i.BROWSER_ALIASES_MAP[t]},t.getBrowserTypeByAlias=function(t){return i.BROWSER_MAP[t]||""},t}();e.default=r,t.exports=e.default},18:function(t,e,n){"use strict";e.__esModule=!0,e.ENGINE_MAP=e.OS_MAP=e.PLATFORMS_MAP=e.BROWSER_MAP=e.BROWSER_ALIASES_MAP=void 0,e.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},e.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},e.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},e.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},e.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var i,r=(i=n(91))&&i.__esModule?i:{default:i},s=n(18);function a(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var o=function(){function t(){}var e,n;return t.getParser=function(t,e){if(void 0===e&&(e=!1),"string"!=typeof t)throw new Error("UserAgent should be a string");return new r.default(t,e)},t.parse=function(t){return new r.default(t).getResult()},e=t,(n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}])&&a(e,n),t}();e.default=o,t.exports=e.default},91:function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var i=l(n(92)),r=l(n(93)),s=l(n(94)),a=l(n(95)),o=l(n(17));function l(t){return t&&t.__esModule?t:{default:t}}var c=function(){function t(t,e){if(void 0===e&&(e=!1),null==t||""===t)throw new Error("UserAgent parameter can't be empty");this._ua=t,this.parsedResult={},!0!==e&&this.parse()}var e=t.prototype;return e.getUA=function(){return this._ua},e.test=function(t){return t.test(this._ua)},e.parseBrowser=function(){var t=this;this.parsedResult.browser={};var e=o.default.find(i.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser},e.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},e.getBrowserName=function(t){return t?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},e.getBrowserVersion=function(){return this.getBrowser().version},e.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},e.parseOS=function(){var t=this;this.parsedResult.os={};var e=o.default.find(r.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os},e.getOSName=function(t){var e=this.getOS().name;return t?String(e).toLowerCase()||"":e||""},e.getOSVersion=function(){return this.getOS().version},e.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},e.getPlatformType=function(t){void 0===t&&(t=!1);var e=this.getPlatform().type;return t?String(e).toLowerCase()||"":e||""},e.parsePlatform=function(){var t=this;this.parsedResult.platform={};var e=o.default.find(s.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform},e.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},e.getEngineName=function(t){return t?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},e.parseEngine=function(){var t=this;this.parsedResult.engine={};var e=o.default.find(a.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine},e.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},e.getResult=function(){return o.default.assign({},this.parsedResult)},e.satisfies=function(t){var e=this,n={},i=0,r={},s=0;if(Object.keys(t).forEach((function(e){var a=t[e];"string"==typeof a?(r[e]=a,s+=1):"object"==typeof a&&(n[e]=a,i+=1)})),i>0){var a=Object.keys(n),l=o.default.find(a,(function(t){return e.isOS(t)}));if(l){var c=this.satisfies(n[l]);if(void 0!==c)return c}var u=o.default.find(a,(function(t){return e.isPlatform(t)}));if(u){var h=this.satisfies(n[u]);if(void 0!==h)return h}}if(s>0){var d=Object.keys(r),p=o.default.find(d,(function(t){return e.isBrowser(t,!0)}));if(void 0!==p)return this.compareVersion(r[p])}},e.isBrowser=function(t,e){void 0===e&&(e=!1);var n=this.getBrowserName().toLowerCase(),i=t.toLowerCase(),r=o.default.getBrowserTypeByAlias(i);return e&&r&&(i=r.toLowerCase()),i===n},e.compareVersion=function(t){var e=[0],n=t,i=!1,r=this.getBrowserVersion();if("string"==typeof r)return">"===t[0]||"<"===t[0]?(n=t.substr(1),"="===t[1]?(i=!0,n=t.substr(2)):e=[],">"===t[0]?e.push(1):e.push(-1)):"="===t[0]?n=t.substr(1):"~"===t[0]&&(i=!0,n=t.substr(1)),e.indexOf(o.default.compareVersions(r,n,i))>-1},e.isOS=function(t){return this.getOSName(!0)===String(t).toLowerCase()},e.isPlatform=function(t){return this.getPlatformType(!0)===String(t).toLowerCase()},e.isEngine=function(t){return this.getEngineName(!0)===String(t).toLowerCase()},e.is=function(t,e){return void 0===e&&(e=!1),this.isBrowser(t,e)||this.isOS(t)||this.isPlatform(t)},e.some=function(t){var e=this;return void 0===t&&(t=[]),t.some((function(t){return e.is(t)}))},t}();e.default=c,t.exports=e.default},92:function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var i,r=(i=n(17))&&i.__esModule?i:{default:i},s=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(t){var e={name:"Googlebot"},n=r.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/opera/i],describe:function(t){var e={name:"Opera"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/opr\/|opios/i],describe:function(t){var e={name:"Opera"},n=r.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/SamsungBrowser/i],describe:function(t){var e={name:"Samsung Internet for Android"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/Whale/i],describe:function(t){var e={name:"NAVER Whale Browser"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/MZBrowser/i],describe:function(t){var e={name:"MZ Browser"},n=r.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/focus/i],describe:function(t){var e={name:"Focus"},n=r.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/swing/i],describe:function(t){var e={name:"Swing"},n=r.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/coast/i],describe:function(t){var e={name:"Opera Coast"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(t){var e={name:"Opera Touch"},n=r.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/yabrowser/i],describe:function(t){var e={name:"Yandex Browser"},n=r.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/ucbrowser/i],describe:function(t){var e={name:"UC Browser"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/Maxthon|mxios/i],describe:function(t){var e={name:"Maxthon"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/epiphany/i],describe:function(t){var e={name:"Epiphany"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/puffin/i],describe:function(t){var e={name:"Puffin"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/sleipnir/i],describe:function(t){var e={name:"Sleipnir"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/k-meleon/i],describe:function(t){var e={name:"K-Meleon"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/micromessenger/i],describe:function(t){var e={name:"WeChat"},n=r.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/qqbrowser/i],describe:function(t){var e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},n=r.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/msie|trident/i],describe:function(t){var e={name:"Internet Explorer"},n=r.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=r.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=r.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/vivaldi/i],describe:function(t){var e={name:"Vivaldi"},n=r.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/seamonkey/i],describe:function(t){var e={name:"SeaMonkey"},n=r.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/sailfish/i],describe:function(t){var e={name:"Sailfish"},n=r.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return n&&(e.version=n),e}},{test:[/silk/i],describe:function(t){var e={name:"Amazon Silk"},n=r.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/phantom/i],describe:function(t){var e={name:"PhantomJS"},n=r.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/slimerjs/i],describe:function(t){var e={name:"SlimerJS"},n=r.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var e={name:"BlackBerry"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var e={name:"WebOS Browser"},n=r.default.getFirstMatch(s,t)||r.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/bada/i],describe:function(t){var e={name:"Bada"},n=r.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/tizen/i],describe:function(t){var e={name:"Tizen"},n=r.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/qupzilla/i],describe:function(t){var e={name:"QupZilla"},n=r.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=r.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/electron/i],describe:function(t){var e={name:"Electron"},n=r.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/MiuiBrowser/i],describe:function(t){var e={name:"Miui"},n=r.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=r.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=r.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/GSA/i],describe:function(t){var e={name:"Google Search"},n=r.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:function(t){var e=!t.test(/like android/i),n=t.test(/android/i);return e&&n},describe:function(t){var e={name:"Android Browser"},n=r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/playstation 4/i],describe:function(t){var e={name:"PlayStation 4"},n=r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=r.default.getFirstMatch(s,t);return n&&(e.version=n),e}},{test:[/.*/i],describe:function(t){var e=-1!==t.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:r.default.getFirstMatch(e,t),version:r.default.getSecondMatch(e,t)}}}];e.default=a,t.exports=e.default},93:function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var i,r=(i=n(17))&&i.__esModule?i:{default:i},s=n(18),a=[{test:[/Roku\/DVP/],describe:function(t){var e=r.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:s.OS_MAP.Roku,version:e}}},{test:[/windows phone/i],describe:function(t){var e=r.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:s.OS_MAP.WindowsPhone,version:e}}},{test:[/windows /i],describe:function(t){var e=r.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),n=r.default.getWindowsVersionName(e);return{name:s.OS_MAP.Windows,version:e,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(t){var e={name:s.OS_MAP.iOS},n=r.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return n&&(e.version=n),e}},{test:[/macintosh/i],describe:function(t){var e=r.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),n=r.default.getMacOSVersionName(e),i={name:s.OS_MAP.MacOS,version:e};return n&&(i.versionName=n),i}},{test:[/(ipod|iphone|ipad)/i],describe:function(t){var e=r.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:s.OS_MAP.iOS,version:e}}},{test:function(t){var e=!t.test(/like android/i),n=t.test(/android/i);return e&&n},describe:function(t){var e=r.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),n=r.default.getAndroidVersionName(e),i={name:s.OS_MAP.Android,version:e};return n&&(i.versionName=n),i}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var e=r.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),n={name:s.OS_MAP.WebOS};return e&&e.length&&(n.version=e),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var e=r.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||r.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||r.default.getFirstMatch(/\bbb(\d+)/i,t);return{name:s.OS_MAP.BlackBerry,version:e}}},{test:[/bada/i],describe:function(t){var e=r.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:s.OS_MAP.Bada,version:e}}},{test:[/tizen/i],describe:function(t){var e=r.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:s.OS_MAP.Tizen,version:e}}},{test:[/linux/i],describe:function(){return{name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(t){var e=r.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:s.OS_MAP.PlayStation4,version:e}}}];e.default=a,t.exports=e.default},94:function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var i,r=(i=n(17))&&i.__esModule?i:{default:i},s=n(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(t){var e=r.default.getFirstMatch(/(can-l01)/i,t)&&"Nova",n={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return e&&(n.model=e),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(t){var e=t.test(/ipod|iphone/i),n=t.test(/like (ipod|iphone)/i);return e&&!n},describe:function(t){var e=r.default.getFirstMatch(/(ipod|iphone)/i,t);return{type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(t){return"blackberry"===t.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(t){return"bada"===t.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(t){return"windows phone"===t.getBrowserName()},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(t){var e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(t){return"android"===t.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(t){return"macos"===t.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(t){return"windows"===t.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(t){return"linux"===t.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(t){return"playstation 4"===t.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}},{test:function(t){return"roku"===t.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}}];e.default=a,t.exports=e.default},95:function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var i,r=(i=n(17))&&i.__esModule?i:{default:i},s=n(18),a=[{test:function(t){return"microsoft edge"===t.getBrowserName(!0)},describe:function(t){if(/\sedg\//i.test(t))return{name:s.ENGINE_MAP.Blink};var e=r.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:s.ENGINE_MAP.EdgeHTML,version:e}}},{test:[/trident/i],describe:function(t){var e={name:s.ENGINE_MAP.Trident},n=r.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:function(t){return t.test(/presto/i)},describe:function(t){var e={name:s.ENGINE_MAP.Presto},n=r.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:function(t){var e=t.test(/gecko/i),n=t.test(/like gecko/i);return e&&!n},describe:function(t){var e={name:s.ENGINE_MAP.Gecko},n=r.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(t){var e={name:s.ENGINE_MAP.WebKit},n=r.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}}];e.default=a,t.exports=e.default}})},"object"==typeof t&&"object"==typeof e?e.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof t?t.bowser=i():n.bowser=i()}));z(),z();var yd=Zt(Wd());z();var $d=(t=>(t.svPrimary="sv-primary",t.svPrimary900="sv-primary-900",t.svPrimary200="sv-primary-200",t.svSecondary="sv-secondary",t.svGray="sv-gray",t.svSuccess="sv-success",t.svDanger="sv-danger",t.svBlack="sv-black",t.svWhite="sv-white",t.svGray100="sv-gray-100",t.svGray200="sv-gray-200",t.svGray300="sv-gray-300",t.svGray400="sv-gray-400",t.svGray500="sv-gray-500",t.svGray600="sv-gray-600",t.svGray700="sv-gray-700",t.svGray800="sv-gray-800",t))($d||{});z(),z(),z(),z();var et=(t,e,n,...i)=>ce(void 0,[t,e,n,...i],(function*(t,e,n,i={}){let r=yield fetch(t,{method:e,headers:B({"Content-Type":"application/json"},i),body:n?JSON.stringify(n):null});if(!r.ok)throw r;try{return yield r.json()}catch{return r.ok}}));z();var cw=Zt(Wd()),st=class{constructor(t){this.debug=(0,cw.default)(t)}log(t,...e){this.debug(t,...e)}};z(),z();var hw=Zt(qd()),Xe=class{constructor(t={}){this.subscribe=t=>{this.callbacks.push(t)},this.unsubscribe=t=>{this.callbacks=this.callbacks.filter((e=>e!==t))},this.publish=(...t)=>{this.callbacks&&this.callbacks.forEach((e=>{this.callListener(e,t).catch((n=>{var i;null==(i=this.logger)||i.log("superviz-sdk:observer-helper:publish:error",`\n            Failed to execute callback on publish value.\n            Callback: ${e.name}\n            Event: ${JSON.stringify(t)}\n            Error: ${n}\n          `)}))}))},this.reset=()=>{this.callbacks=[]},this.destroy=()=>{delete this.logger,delete this.callbacks},this.callListener=(t,e)=>new Promise(((n,i)=>{try{n(t(...e))}catch(t){i(t)}}));let{logger:e,throttleTime:n}=t;this.logger=e||new st("@superviz/sdk/observer-helper"),this.throttle=n,this.callbacks=[],this.throttle&&(this.publish=(0,hw.default)(this.publish,this.throttle))}},Ll=class{constructor(){this.observers={},this.subscribe=(t,e)=>{this.logger.log(`subscribed to ${t} event`),this.observers[t]||(this.observers[t]=new Xe({logger:this.logger})),this.observers[t].subscribe(e)},this.unsubscribe=(t,e)=>{if(this.logger.log(`unsubscribed from ${t} event`),this.observers[t]){if(!e)return this.observers[t].destroy(),void delete this.observers[t];this.observers[t].unsubscribe(e)}},this.publish=(t,e)=>{t in this.observers&&this.observers[t].publish(e)}}};z();var it=class{static createUrl(t,e,n={}){let i=new URL(e,t);return Object.keys(n).forEach((t=>i.searchParams.append(t,n[t]))),i.toString()}static validateApiKey(t,e){let n=this.createUrl(t,"/user/checkapikey");return et(n,"POST",{apiKey:e})}static fetchConfig(t,e){let n=this.createUrl(t,"/immersive-config");return et(n,"POST",{apiKey:e})}static fetchLimits(t,e){return ce(this,null,(function*(){let n=this.createUrl(t,"/user/check_limits_v2");return(yield et(n,"GET","",{apikey:e})).limits}))}static fetchWaterMark(t,e){return ce(this,null,(function*(){let n=this.createUrl(t,"/user/watermark"),{message:i}=yield et(n,"POST",{apiKey:e});return i}))}static createAnnotations(t,e,n){return ce(this,null,(function*(){let i=this.createUrl(t,"/annotations");return et(i,"POST",B({},n),{apikey:e})}))}static updateComment(t,e,n,i){return ce(this,null,(function*(){let r=`/comments/${n}`,s=this.createUrl(t,r);return et(s,"PUT",{text:i},{apikey:e})}))}static createComment(t,e,n){return ce(this,null,(function*(){let i=this.createUrl(t,"/comments");return et(i,"POST",B({},n),{apikey:e})}))}static fetchAnnotation(t,e,n){return ce(this,null,(function*(){let i=this.createUrl(t,"/annotations",{roomId:n.roomId});return et(i,"GET",void 0,{apikey:e})}))}static resolveAnnotation(t,e,n){return ce(this,null,(function*(){let i=`/annotations/resolve/${n}`,r=this.createUrl(t,i);return et(r,"POST",{},{apikey:e})}))}static deleteComment(t,e,n){return ce(this,null,(function*(){let i=`/comments/${n}`,r=this.createUrl(t,i);return et(r,"DELETE",{},{apikey:e})}))}static deleteAnnotation(t,e,n){return ce(this,null,(function*(){let i=`/annotations/${n}`,r=this.createUrl(t,i);return et(r,"DELETE",{},{apikey:e})}))}static createParticipant(t){return ce(this,null,(function*(){let e=Q.get("apiUrl"),n=this.createUrl(e,"/participants");return et(n,"POST",B({},t),{apikey:Q.get("apiKey")})}))}static fetchParticipant(t){return ce(this,null,(function*(){let e=Q.get("apiUrl"),n=`/participants/${t}`,i=this.createUrl(e,n);return et(i,"GET",void 0,{apikey:Q.get("apiKey")})}))}static sendActivity(t,e,n,i){return ce(this,null,(function*(){let r=Q.get("apiUrl"),s=Q.get("roomId"),a=Q.get("apiKey"),o=this.createUrl(r,"/activity");return et(o,"POST",{groupId:e,groupName:n,meetingId:s,product:i,userId:t},{apikey:a})}))}static fetchParticipantsByGroup(t){return ce(this,null,(function*(){let e=`/groups/participants/${t}`,n=Q.get("apiUrl"),i=this.createUrl(n,e,{take:1e4});return et(i,"GET",void 0,{apikey:Q.get("apiKey")})}))}static createMentions(t){return ce(this,null,(function*(){let e=Q.get("apiUrl"),n=this.createUrl(e,"/mentions");return et(n,"POST",t,{apikey:Q.get("apiKey")})}))}};function uw(t,e){return ce(this,null,(function*(){try{return!0===(yield it.validateApiKey(t,e))}catch(t){if(404===t.status)return!1;throw new Error("Unable to validate API key")}}))}z();var dw=uw;z();var Yr=class{static getRemoteConfig(){return ce(this,arguments,(function*(t="prod"){if("local"===t)return(yield import("./chunks/.remote-config-BL2BKACS-LEN2M4YF.js")).default.remoteConfig;let{version:e}=yield import("./chunks/package-NUPYE74L-VB74JE4L.js");console.log(`[SuperViz] - v.${e}`);let n={version:e,environment:t},i=this.createUrl(n);return et(i,"GET",null)}))}static getFeatures(t){return ce(this,null,(function*(){return et(`${this.REMOTE_CONFIG_BASE_URL}/features/${t}`,"GET",void 0)}))}static createUrl({version:t,environment:e}){return`${this.REMOTE_CONFIG_BASE_URL}/sdk/${t}?env=${e}`}};Yr.REMOTE_CONFIG_BASE_URL="https://remote-config.superviz.com",z(),z();var pw=Object.create,co=Object.defineProperty,fw=Object.defineProperties,mw=Object.getOwnPropertyDescriptor,gw=Object.getOwnPropertyDescriptors,vw=Object.getOwnPropertyNames,_d=Object.getOwnPropertySymbols,yw=Object.getPrototypeOf,Zd=Object.prototype.hasOwnProperty,_w=Object.prototype.propertyIsEnumerable,bd=(t,e,n)=>e in t?co(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,I=(t,e)=>{for(var n in e||(e={}))Zd.call(e,n)&&bd(t,n,e[n]);if(_d)for(var n of _d(e))_w.call(e,n)&&bd(t,n,e[n]);return t},ie=(t,e)=>fw(t,gw(e)),Ol=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bw=(t,e)=>{for(var n in e)co(t,n,{get:e[n],enumerable:!0})},xw=(t,e,n,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let r of vw(e))!Zd.call(t,r)&&r!==n&&co(t,r,{get:()=>e[r],enumerable:!(i=mw(e,r))||i.enumerable});return t},ww=(t,e,n)=>(n=null!=t?pw(yw(t)):{},xw(!e&&t&&t.__esModule?n:co(n,"default",{value:t,enumerable:!0}),t)),Cn=(t,e,n)=>new Promise(((i,r)=>{var s=t=>{try{o(n.next(t))}catch(t){r(t)}},a=t=>{try{o(n.throw(t))}catch(t){r(t)}},o=t=>t.done?i(t.value):Promise.resolve(t.value).then(s,a);o((n=n.apply(t,e)).next())})),Sw=Ol(((t,e)=>{var n=1e3,i=60*n,r=60*i,s=24*r,a=7*s,o=365.25*s;function l(t,e,n,i){var r=e>=1.5*n;return Math.round(t/n)+" "+i+(r?"s":"")}e.exports=function(t,e){e=e||{};var c=typeof t;if("string"===c&&t.length>0)return function(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var l=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*o;case"weeks":case"week":case"w":return l*a;case"days":case"day":case"d":return l*s;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*i;case"seconds":case"second":case"secs":case"sec":case"s":return l*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}}}(t);if("number"===c&&isFinite(t))return e.long?function(t){var e=Math.abs(t);return e>=s?l(t,e,s,"day"):e>=r?l(t,e,r,"hour"):e>=i?l(t,e,i,"minute"):e>=n?l(t,e,n,"second"):t+" ms"}(t):function(t){var e=Math.abs(t);return e>=s?Math.round(t/s)+"d":e>=r?Math.round(t/r)+"h":e>=i?Math.round(t/i)+"m":e>=n?Math.round(t/n)+"s":t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}})),Mw=Ol(((t,e)=>{e.exports=function(t){function e(t){let i,r,s,a=null;function o(...t){if(!o.enabled)return;let n=o,r=Number(new Date),s=r-(i||r);n.diff=s,n.prev=i,n.curr=r,i=r,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let a=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((i,r)=>{if("%%"===i)return"%";a++;let s=e.formatters[r];if("function"==typeof s){let e=t[a];i=s.call(n,e),t.splice(a,1),a--}return i})),e.formatArgs.call(n,t),(n.log||e.log).apply(n,t)}return o.namespace=t,o.useColors=e.useColors(),o.color=e.selectColor(t),o.extend=n,o.destroy=e.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(r!==e.namespaces&&(r=e.namespaces,s=e.enabled(t)),s),set:t=>{a=t}}),"function"==typeof e.init&&e.init(o),o}function n(t,n){let i=e(this.namespace+(typeof n>"u"?":":n)+t);return i.log=this.log,i}function i(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return e.debug=e,e.default=e,e.coerce=function(t){return t instanceof Error?t.stack||t.message:t},e.disable=function(){let t=[...e.names.map(i),...e.skips.map(i).map((t=>"-"+t))].join(",");return e.enable(""),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];let n,i=("string"==typeof t?t:"").split(/[\s,]+/),r=i.length;for(n=0;n<r;n++)i[n]&&("-"===(t=i[n].replace(/\*/g,".*?"))[0]?e.skips.push(new RegExp("^"+t.slice(1)+"$")):e.names.push(new RegExp("^"+t+"$")))},e.enabled=function(t){if("*"===t[t.length-1])return!0;let n,i;for(n=0,i=e.skips.length;n<i;n++)if(e.skips[n].test(t))return!1;for(n=0,i=e.names.length;n<i;n++)if(e.names[n].test(t))return!0;return!1},e.humanize=Sw(),e.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach((n=>{e[n]=t[n]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e.colors[Math.abs(n)%e.colors.length]},e.enable(e.load()),e}})),Ew=Ol(((t,e)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;let n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(t=>{"%%"!==t&&(i++,"%c"===t&&(r=i))})),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=Qa.DEBUG),e},t.useColors=function(){if(typeof window<"u"&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Mw()(t);var{formatters:n}=e.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}})),Aw=(t=>(t.JOIN_ROOM="room.join",t.JOINED_ROOM="room.joined",t.LEAVE_ROOM="room.leave",t.UPDATE="room.update",t.ERROR="room.error",t))(Aw||{}),se=(t=>(t.JOINED_ROOM="presence.joined-room",t.LEAVE="presence.leave",t.UPDATE="presence.update",t))(se||{}),Yd=(t=>(t.CONNECTED="CONNECTED",t.CONNECTING="CONNECTING",t.DISCONNECTED="DISCONNECTED",t.CONNECTION_ERROR="CONNECTION_ERROR",t.RECONNECTING="RECONNECTING",t.RECONNECT_ERROR="RECONNECT_ERROR",t))(Yd||{}),ul=function(t,e){return(ul=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function ho(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}ul(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function dl(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Jr(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,s=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)a.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return a}function Kr(t,e,n){if(n||2===arguments.length)for(var i,r=0,s=e.length;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function Tn(t){return"function"==typeof t}function Jd(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var il=Jd((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=e}}));function pl(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var uo=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var t,e,n,i,r;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=dl(s),o=a.next();!o.done;o=a.next()){o.value.remove(this)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else s.remove(this);var l=this.initialTeardown;if(Tn(l))try{l()}catch(t){r=t instanceof il?t.errors:[t]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=dl(c),h=u.next();!h.done;h=u.next()){var d=h.value;try{xd(d)}catch(t){r=r??[],t instanceof il?r=Kr(Kr([],Jr(r)),Jr(t.errors)):r.push(t)}}}catch(t){n={error:t}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}if(r)throw new il(r)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)xd(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&pl(e,t)},t.prototype.remove=function(e){var n=this._finalizers;n&&pl(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=((e=new t).closed=!0,e),t;var e}(),Kd=uo.EMPTY;function jd(t){return t instanceof uo||t&&"closed"in t&&Tn(t.remove)&&Tn(t.add)&&Tn(t.unsubscribe)}function xd(t){Tn(t)?t():t.unsubscribe()}var hi={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},jr={setTimeout:function(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var r=jr.delegate;return null!=r&&r.setTimeout?r.setTimeout.apply(r,Kr([t,e],Jr(n))):setTimeout.apply(void 0,Kr([t,e],Jr(n)))},clearTimeout:function(t){var e=jr.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function Tw(t){jr.setTimeout((function(){var e=hi.onUnhandledError;if(!e)throw t;e(t)}))}function wd(){}var Cw=Dl("C",void 0,void 0);function Pw(t){return Dl("E",void 0,t)}function Rw(t){return Dl("N",t,void 0)}function Dl(t,e,n){return{kind:t,value:e,error:n}}var ai=null;function Wr(t){if(hi.useDeprecatedSynchronousErrorHandling){var e=!ai;if(e&&(ai={errorThrown:!1,error:null}),t(),e){var n=ai,i=n.errorThrown,r=n.error;if(ai=null,i)throw r}}else t()}function Iw(t){hi.useDeprecatedSynchronousErrorHandling&&ai&&(ai.errorThrown=!0,ai.error=t)}var Qd=function(t){function e(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,jd(e)&&e.add(n)):n.destination=Nw,n}return ho(e,t),e.create=function(t,e,n){return new fl(t,e,n)},e.prototype.next=function(t){this.isStopped?rl(Rw(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?rl(Pw(t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?rl(Cw,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(uo),Lw=Function.prototype.bind;function sl(t,e){return Lw.call(t,e)}var Ow=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){kr(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){kr(t)}else kr(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){kr(t)}},t}(),fl=function(t){function e(e,n,i){var r,s,a=t.call(this)||this;Tn(e)||!e?r={next:e??void 0,error:n??void 0,complete:i??void 0}:a&&hi.useDeprecatedNextContext?((s=Object.create(e)).unsubscribe=function(){return a.unsubscribe()},r={next:e.next&&sl(e.next,s),error:e.error&&sl(e.error,s),complete:e.complete&&sl(e.complete,s)}):r=e;return a.destination=new Ow(r),a}return ho(e,t),e}(Qd);function kr(t){hi.useDeprecatedSynchronousErrorHandling?Iw(t):Tw(t)}function Dw(t){throw t}function rl(t,e){var n=hi.onStoppedNotification;n&&jr.setTimeout((function(){return n(t,e)}))}var Nw={closed:!0,next:wd,error:Dw,complete:wd},Fw="function"==typeof Symbol&&Symbol.observable||"@@observable";function Uw(t){return t}function kw(t){return 0===t.length?Uw:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}var Sd=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var i=this,r=zw(t)?t:new fl(t,e,n);return Wr((function(){var t=i,e=t.operator,n=t.source;r.add(e?e.call(r,n):n?i._subscribe(r):i._trySubscribe(r))})),r},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=Md(e))((function(e,i){var r=new fl({next:function(e){try{t(e)}catch(t){i(t),r.unsubscribe()}},error:i,complete:e});n.subscribe(r)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[Fw]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return kw(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=Md(t))((function(t,n){var i;e.subscribe((function(t){return i=t}),(function(t){return n(t)}),(function(){return t(i)}))}))},t.create=function(e){return new t(e)},t}();function Md(t){var e;return null!==(e=t??hi.Promise)&&void 0!==e?e:Promise}function Bw(t){return t&&Tn(t.next)&&Tn(t.error)&&Tn(t.complete)}function zw(t){return t&&t instanceof Qd||Bw(t)&&jd(t)}var Vw=Jd((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),cn=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return ho(e,t),e.prototype.lift=function(t){var e=new Ed(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new Vw},e.prototype.next=function(t){var e=this;Wr((function(){var n,i;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var r=dl(e.currentObservers),s=r.next();!s.done;s=r.next()){s.value.next(t)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}}}))},e.prototype.error=function(t){var e=this;Wr((function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var n=e.observers;n.length;)n.shift().error(t)}}))},e.prototype.complete=function(){var t=this;Wr((function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}}))},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,n=this,i=n.hasError,r=n.isStopped,s=n.observers;return i||r?Kd:(this.currentObservers=null,s.push(t),new uo((function(){e.currentObservers=null,pl(s,t)})))},e.prototype._checkFinalizedStatuses=function(t){var e=this,n=e.hasError,i=e.thrownError,r=e.isStopped;n?t.error(i):r&&t.complete()},e.prototype.asObservable=function(){var t=new Sd;return t.source=this,t},e.create=function(t,e){return new Ed(t,e)},e}(Sd),Ed=function(t){function e(e,n){var i=t.call(this)||this;return i.destination=e,i.source=n,i}return ho(e,t),e.prototype.next=function(t){var e,n;null===(n=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===n||n.call(e,t)},e.prototype.error=function(t){var e,n;null===(n=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===n||n.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,n;return null!==(n=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==n?n:Kd},e}(cn),Ad=ww(Ew()),Nl=class{constructor(t){this.debug=(0,Ad.default)(t),Ad.default.enable("*")}log(t,...e){this.debug(t,...e)}},Hw=class t{constructor(t,e,n){this.io=t,this.presence=e,this.roomId=n,this.presences=new Set,this.observers=new Map,this.onPresenceJoin=t=>{t?.roomId===this.roomId&&(this.logger.log("presence room @ presence join",t),this.presences.add(t),this.observers.get("presence.joined-room").next({connectionId:t.connectionId,data:t.data,id:t.id,name:t.name,timestamp:t.timestamp}))},this.onPresenceLeave=t=>{t?.roomId===this.roomId&&(this.logger.log("presence room @ presence leave",t),this.presences.delete(t),this.observers.get("presence.leave").next(t))},this.onPresenceUpdate=t=>{t?.roomId===this.roomId&&(this.logger.log("presence room @ presence update",t),this.observers.get("presence.update").next({connectionId:t.connectionId,data:t.data,id:t.id,name:t.name,roomId:t?.roomId,timestamp:t.timestamp}))},this.logger=new Nl("@superviz/socket-client/presence"),this.registerSubjects(),this.subscribeToPresenceEvents()}static register(e,n,i){return new t(e,n,i)}get(t,e){let n=new cn;n.subscribe({next:t,error:e});let i=t=>{let e=t.presences.map((t=>({connectionId:t.connectionId,data:t.data,id:t.id,name:t.name,timestamp:t.timestamp})));this.logger.log("presence room @ get",t),this.io.off("presence.get",i),n.next(e),n.complete()};this.io.on("presence.get",i),this.io.emit("presence.get",this.roomId)}update(t){let e={connectionId:this.io.id,data:t,id:this.presence.id,name:this.presence.name,timestamp:Date.now()};this.io.emit("presence.update",this.roomId,e),this.logger.log("presence room @ update",this.roomId,e)}destroy(){this.io.off("presence.joined-room",this.onPresenceJoin),this.io.off("presence.leave",this.onPresenceLeave),this.io.off("presence.update",this.onPresenceUpdate),this.observers.forEach((t=>t.unsubscribe())),this.observers.clear()}registerSubjects(){this.observers.set("presence.joined-room",new cn),this.observers.set("presence.leave",new cn),this.observers.set("presence.update",new cn)}on(t,e,n){this.observers.get(t).subscribe({error:n,next:e})}off(t){var e;null==(e=this.observers.get(t))||e.unsubscribe(),this.observers.delete(t),this.observers.set(t,new cn)}subscribeToPresenceEvents(){this.io.on("presence.joined-room",this.onPresenceJoin),this.io.on("presence.leave",this.onPresenceLeave),this.io.on("presence.update",this.onPresenceUpdate)}},un=Object.create(null);un.open="0",un.close="1",un.ping="2",un.pong="3",un.message="4",un.upgrade="5",un.noop="6";var Gr=Object.create(null);Object.keys(un).forEach((t=>{Gr[un[t]]=t}));var ol,ml={type:"error",data:"parser error"},tp="function"==typeof Blob||typeof Blob<"u"&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),np="function"==typeof ArrayBuffer,ip=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Fl=({type:t,data:e},n,i)=>tp&&e instanceof Blob?n?i(e):Td(e,i):np&&(e instanceof ArrayBuffer||ip(e))?n?i(e):Td(new Blob([e]),i):i(un[t]+(e||"")),Td=(t,e)=>{let n=new FileReader;return n.onload=function(){let t=n.result.split(",")[1];e("b"+(t||""))},n.readAsDataURL(t)};function Cd(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Ww(t,e){return tp&&t.data instanceof Blob?t.data.arrayBuffer().then(Cd).then(e):np&&(t.data instanceof ArrayBuffer||ip(t.data))?e(Cd(t.data)):void Fl(t,!1,(t=>{ol||(ol=new TextEncoder),e(ol.encode(t))}))}var Pd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Pd.length;t++)bs[Pd.charCodeAt(t)]=t;var al,Gw=t=>{let e,n,i,r,s,a=.75*t.length,o=t.length,l=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);let c=new ArrayBuffer(a),u=new Uint8Array(c);for(e=0;e<o;e+=4)n=bs[t.charCodeAt(e)],i=bs[t.charCodeAt(e+1)],r=bs[t.charCodeAt(e+2)],s=bs[t.charCodeAt(e+3)],u[l++]=n<<2|i>>4,u[l++]=(15&i)<<4|r>>2,u[l++]=(3&r)<<6|63&s;return c},Xw="function"==typeof ArrayBuffer,Ul=(t,e)=>{if("string"!=typeof t)return{type:"message",data:sp(t,e)};let n=t.charAt(0);return"b"===n?{type:"message",data:qw(t.substring(1),e)}:Gr[n]?t.length>1?{type:Gr[n],data:t.substring(1)}:{type:Gr[n]}:ml},qw=(t,e)=>{if(Xw){let n=Gw(t);return sp(n,e)}return{base64:!0,data:t}},sp=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,rp="",$w=(t,e)=>{let n=t.length,i=new Array(n),r=0;t.forEach(((t,s)=>{Fl(t,!1,(t=>{i[s]=t,++r===n&&e(i.join(rp))}))}))},Zw=(t,e)=>{let n=t.split(rp),i=[];for(let t=0;t<n.length;t++){let r=Ul(n[t],e);if(i.push(r),"error"===r.type)break}return i};function Yw(){return new TransformStream({transform(t,e){Ww(t,(n=>{let i,r=n.length;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let t=new DataView(i.buffer);t.setUint8(0,126),t.setUint16(1,r)}else{i=new Uint8Array(9);let t=new DataView(i.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(r))}t.data&&"string"!=typeof t.data&&(i[0]|=128),e.enqueue(i),e.enqueue(n)}))}})}function Br(t){return t.reduce(((t,e)=>t+e.length),0)}function zr(t,e){if(t[0].length===e)return t.shift();let n=new Uint8Array(e),i=0;for(let r=0;r<e;r++)n[r]=t[0][i++],i===t[0].length&&(t.shift(),i=0);return t.length&&i<t[0].length&&(t[0]=t[0].slice(i)),n}function Jw(t,e){al||(al=new TextDecoder);let n=[],i=0,r=-1,s=!1;return new TransformStream({transform(a,o){for(n.push(a);;){if(0===i){if(Br(n)<1)break;let t=zr(n,1);s=!(128&~t[0]),r=127&t[0],i=r<126?3:126===r?1:2}else if(1===i){if(Br(n)<2)break;let t=zr(n,2);r=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),i=3}else if(2===i){if(Br(n)<8)break;let t=zr(n,8),e=new DataView(t.buffer,t.byteOffset,t.length),s=e.getUint32(0);if(s>Math.pow(2,21)-1){o.enqueue(ml);break}r=s*Math.pow(2,32)+e.getUint32(4),i=3}else{if(Br(n)<r)break;let t=zr(n,r);o.enqueue(Ul(s?t:al.decode(t),e)),i=0}if(0===r||r>t){o.enqueue(ml);break}}}})}var op=4;function qe(t){if(t)return Kw(t)}function Kw(t){for(var e in qe.prototype)t[e]=qe.prototype[e];return t}qe.prototype.on=qe.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},qe.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},qe.prototype.off=qe.prototype.removeListener=qe.prototype.removeAllListeners=qe.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i,r=0;r<n.length;r++)if((i=n[r])===e||i.fn===e){n.splice(r,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},qe.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(n){i=0;for(var r=(n=n.slice(0)).length;i<r;++i)n[i].apply(this,e)}return this},qe.prototype.emitReserved=qe.prototype.emit,qe.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},qe.prototype.hasListeners=function(t){return!!this.listeners(t).length};var zt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();function ap(t,...e){return e.reduce(((e,n)=>(t.hasOwnProperty(n)&&(e[n]=t[n]),e)),{})}var jw=zt.setTimeout,Qw=zt.clearTimeout;function po(t,e){e.useNativeTimers?(t.setTimeoutFn=jw.bind(zt),t.clearTimeoutFn=Qw.bind(zt)):(t.setTimeoutFn=zt.setTimeout.bind(zt),t.clearTimeoutFn=zt.clearTimeout.bind(zt))}var eS=1.33;function tS(t){return"string"==typeof t?nS(t):Math.ceil((t.byteLength||t.size)*eS)}function nS(t){let e=0,n=0;for(let i=0,r=t.length;i<r;i++)e=t.charCodeAt(i),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(i++,n+=4);return n}function iS(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function sS(t){let e={},n=t.split("&");for(let t=0,i=n.length;t<i;t++){let i=n[t].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}var Id,rS=class extends Error{constructor(t,e,n){super(t),this.description=e,this.context=n,this.type="TransportError"}},kl=class extends qe{constructor(t){super(),this.writable=!1,po(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,n){return super.emitReserved("error",new rS(t,e,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return("opening"===this.readyState||"open"===this.readyState)&&(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){let e=Ul(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){let t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){let e=iS(t);return e.length?"?"+e:""}},lp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),gl=64,oS={},Rd=0,Vr=0;function Ld(t){let e="";do{e=lp[t%gl]+e,t=Math.floor(t/gl)}while(t>0);return e}function cp(){let t=Ld(+new Date);return t!==Id?(Rd=0,Id=t):t+"."+Ld(Rd++)}for(;Vr<gl;Vr++)oS[lp[Vr]]=Vr;var hp=!1;try{hp=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var aS=hp;function up(t){let e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||aS))return new XMLHttpRequest}catch{}if(!e)try{return new(zt[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch{}}function lS(){}var cS=null!=new up({xdomain:!1}).responseType,hS=class extends kl{constructor(t){if(super(t),this.polling=!1,typeof location<"u"){let e="https:"===location.protocol,n=location.port;n||(n=e?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||n!==t.port}let e=t&&t.forceBase64;this.supportsBinary=cS&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";let e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){Zw(t,this.socket.binaryType).forEach((t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){let t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,$w(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){let t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=cp()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ni(this.uri(),t)}doWrite(t,e){let n=this.request({method:"POST",data:t});n.on("success",e),n.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){let t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}},Ni=class t extends qe{constructor(t,e){super(),po(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=void 0!==e.data?e.data:null,this.create()}create(){var e;let n=ap(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this.opts.xd;let i=this.xhr=new up(n);try{i.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&i.setRequestHeader(t,this.opts.extraHeaders[t])}}catch{}if("POST"===this.method)try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(i.timeout=this.opts.requestTimeout),i.onreadystatechange=()=>{var t;3===i.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(i)),4===i.readyState&&(200===i.status||1223===i.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof i.status?i.status:0)}),0))},i.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}typeof document<"u"&&(this.index=t.requestsCount++,t.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||null===this.xhr)){if(this.xhr.onreadystatechange=lS,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete t.requests[this.index],this.xhr=null}}onLoad(){let t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};if(Ni.requestsCount=0,Ni.requests={},typeof document<"u")if("function"==typeof attachEvent)attachEvent("onunload",Od);else if("function"==typeof addEventListener){addEventListener("onpagehide"in zt?"pagehide":"unload",Od,!1)}function Od(){for(let t in Ni.requests)Ni.requests.hasOwnProperty(t)&&Ni.requests[t].abort()}var Bl="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),Hr=zt.WebSocket||zt.MozWebSocket,ll=!0,uS="arraybuffer",Dd=typeof navigator<"u"&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),dS=class extends kl{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let t=this.uri(),e=this.opts.protocols,n=Dd?{}:ap(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=ll&&!Dd?e?new Hr(t,e):new Hr(t):new Hr(t,e,n)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){let n=t[e],i=e===t.length-1;Fl(n,this.supportsBinary,(t=>{let e={};ll||(n.options&&(e.compress=n.options.compress),this.opts.perMessageDeflate&&("string"==typeof t?Buffer.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(e.compress=!1));try{ll?this.ws.send(t):this.ws.send(t,e)}catch{}i&&Bl((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=cp()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!Hr}},pS=class extends kl{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{let e=Jw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=t.readable.pipeThrough(e).getReader(),i=Yw();i.readable.pipeTo(t.writable),this.writer=i.writable.getWriter();let r=()=>{n.read().then((({done:t,value:e})=>{t||(this.onPacket(e),r())})).catch((t=>{}))};r();let s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this.writer.write(s).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e<t.length;e++){let n=t[e],i=e===t.length-1;this.writer.write(n).then((()=>{i&&Bl((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},fS={websocket:dS,webtransport:pS,polling:hS},mS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,gS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function vl(t){if(t.length>2e3)throw"URI too long";let e=t,n=t.indexOf("["),i=t.indexOf("]");-1!=n&&-1!=i&&(t=t.substring(0,n)+t.substring(n,i).replace(/:/g,";")+t.substring(i,t.length));let r=mS.exec(t||""),s={},a=14;for(;a--;)s[gS[a]]=r[a]||"";return-1!=n&&-1!=i&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=vS(s,s.path),s.queryKey=yS(s,s.query),s}function vS(t,e){let n=e.replace(/\/{2,9}/g,"/").split("/");return("/"==e.slice(0,1)||0===e.length)&&n.splice(0,1),"/"==e.slice(-1)&&n.splice(n.length-1,1),n}function yS(t,e){let n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,i){e&&(n[e]=i)})),n}var zl=class t extends qe{constructor(t,e={}){super(),this.binaryType=uS,this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=vl(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=vl(e.host).host),po(this,e),this.secure=null!=e.secure?e.secure:typeof location<"u"&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=sS(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){let e=Object.assign({},this.opts.query);e.EIO=op,e.transport=t,this.id&&(e.sid=this.id);let n=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new fS[t](n)}open(){let e;if(this.opts.rememberUpgrade&&t.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch{return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(e){let n=this.createTransport(e),i=!1;t.priorWebsocketSuccess=!1;let r=()=>{i||(n.send([{type:"ping",data:"probe"}]),n.once("packet",(e=>{if(!i)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;t.priorWebsocketSuccess="websocket"===n.name,this.transport.pause((()=>{i||"closed"!==this.readyState&&(u(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())}))}else{let t=new Error("probe error");t.transport=n.name,this.emitReserved("upgradeError",t)}})))};function s(){i||(i=!0,u(),n.close(),n=null)}let a=t=>{let e=new Error("probe error: "+t);e.transport=n.name,s(),this.emitReserved("upgradeError",e)};function o(){a("transport closed")}function l(){a("socket closed")}function c(t){n&&t.name!==n.name&&s()}let u=()=>{n.removeListener("open",r),n.removeListener("error",a),n.removeListener("close",o),this.off("close",l),this.off("upgrading",c)};n.once("open",r),n.once("error",a),n.once("close",o),this.once("close",l),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{i||n.open()}),200):n.open()}onOpen(){if(this.readyState="open",t.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0,e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let e=0;e<this.writeBuffer.length;e++){let n=this.writeBuffer[e].data;if(n&&(t+=tS(n)),e>0&&t>this.maxPayload)return this.writeBuffer.slice(0,e);t+=2}return this.writeBuffer}write(t,e,n){return this.sendPacket("message",t,e,n),this}send(t,e,n){return this.sendPacket("message",t,e,n),this}sendPacket(t,e,n,i){if("function"==typeof e&&(i=e,e=void 0),"function"==typeof n&&(i=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;let r={type:t,data:e,options:n};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){let t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},n=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return("opening"===this.readyState||"open"===this.readyState)&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():t()})):this.upgrading?n():t()),this}onError(e){t.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(t,e){("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){let e=[],n=0,i=t.length;for(;n<i;n++)~this.transports.indexOf(t[n])&&e.push(t[n]);return e}};zl.protocol=op;var H1=zl.protocol;function _S(t,e="",n){let i=t;n=n||typeof location<"u"&&location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(t=typeof n<"u"?n.protocol+"//"+t:"https://"+t),i=vl(t)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";let r=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+r+":"+i.port+e,i.href=i.protocol+"://"+r+(n&&n.port===i.port?"":":"+i.port),i}var dp={};bw(dp,{Decoder:()=>PS,Encoder:()=>CS,PacketType:()=>Ee,protocol:()=>TS});var bS="function"==typeof ArrayBuffer,xS=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,pp=Object.prototype.toString,wS="function"==typeof Blob||typeof Blob<"u"&&"[object BlobConstructor]"===pp.call(Blob),SS="function"==typeof File||typeof File<"u"&&"[object FileConstructor]"===pp.call(File);function Vl(t){return bS&&(t instanceof ArrayBuffer||xS(t))||wS&&t instanceof Blob||SS&&t instanceof File}function qr(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,n=t.length;e<n;e++)if(qr(t[e]))return!0;return!1}if(Vl(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return qr(t.toJSON(),!0);for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&qr(t[e]))return!0;return!1}function MS(t){let e=[],n=t.data,i=t;return i.data=yl(n,e),i.attachments=e.length,{packet:i,buffers:e}}function yl(t,e){if(!t)return t;if(Vl(t)){let n={_placeholder:!0,num:e.length};return e.push(t),n}if(Array.isArray(t)){let n=new Array(t.length);for(let i=0;i<t.length;i++)n[i]=yl(t[i],e);return n}if("object"==typeof t&&!(t instanceof Date)){let n={};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=yl(t[i],e));return n}return t}function ES(t,e){return t.data=_l(t.data,e),delete t.attachments,t}function _l(t,e){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=_l(t[n],e);else if("object"==typeof t)for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=_l(t[n],e));return t}var Ee,AS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],TS=5;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(Ee||(Ee={}));var CS=class{constructor(t){this.replacer=t}encode(t){return t.type!==Ee.EVENT&&t.type!==Ee.ACK||!qr(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===Ee.EVENT?Ee.BINARY_EVENT:Ee.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return(t.type===Ee.BINARY_EVENT||t.type===Ee.BINARY_ACK)&&(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){let e=MS(t),n=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(n),i}};function Nd(t){return"[object Object]"===Object.prototype.toString.call(t)}var PS=class t extends qe{constructor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);let n=e.type===Ee.BINARY_EVENT;n||e.type===Ee.BINARY_ACK?(e.type=n?Ee.EVENT:Ee.ACK,this.reconstructor=new RS(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!Vl(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e))}}decodeString(e){let n=0,i={type:Number(e.charAt(0))};if(void 0===Ee[i.type])throw new Error("unknown packet type "+i.type);if(i.type===Ee.BINARY_EVENT||i.type===Ee.BINARY_ACK){let t=n+1;for(;"-"!==e.charAt(++n)&&n!=e.length;);let r=e.substring(t,n);if(r!=Number(r)||"-"!==e.charAt(n))throw new Error("Illegal attachments");i.attachments=Number(r)}if("/"===e.charAt(n+1)){let t=n+1;for(;++n&&","!==e.charAt(n)&&n!==e.length;);i.nsp=e.substring(t,n)}else i.nsp="/";let r=e.charAt(n+1);if(""!==r&&Number(r)==r){let t=n+1;for(;++n;){let t=e.charAt(n);if(null==t||Number(t)!=t){--n;break}if(n===e.length)break}i.id=Number(e.substring(t,n+1))}if(e.charAt(++n)){let r=this.tryParse(e.substr(n));if(!t.isPayloadValid(i.type,r))throw new Error("invalid payload");i.data=r}return i}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case Ee.CONNECT:return Nd(e);case Ee.DISCONNECT:return void 0===e;case Ee.CONNECT_ERROR:return"string"==typeof e||Nd(e);case Ee.EVENT:case Ee.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===AS.indexOf(e[0]));case Ee.ACK:case Ee.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},RS=class{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){let t=ES(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function jt(t,e,n){return t.on(e,n),function(){t.off(e,n)}}var IS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),mp=class extends qe{constructor(t,e,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let t=this.io;this.subs=[jt(t,"open",this.onopen.bind(this)),jt(t,"packet",this.onpacket.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(IS.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;let n={type:Ee.EVENT,data:e,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){let t=this.ids++,i=e.pop();this._registerAckCallback(t,i),n.id=t}let i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(t,e){var n;let i=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===i)return void(this.acks[t]=e);let r=this.io.setTimeoutFn((()=>{delete this.acks[t];for(let e=0;e<this.sendBuffer.length;e++)this.sendBuffer[e].id===t&&this.sendBuffer.splice(e,1);e.call(this,new Error("operation has timed out"))}),i),s=(...t)=>{this.io.clearTimeoutFn(r),e.apply(this,t)};s.withError=!0,this.acks[t]=s}emitWithAck(t,...e){return new Promise(((n,i)=>{let r=(t,e)=>t?i(t):n(e);r.withError=!0,e.push(r),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...i)=>n!==this._queue[0]?void 0:(null!==t?n.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...i)),n.pending=!1,this._drainQueue()))),this._queue.push(n),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;let e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Ee.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((t=>{if(!this.sendBuffer.some((e=>String(e.id)===t))){let e=this.acks[t];delete this.acks[t],e.withError&&e.call(this,new Error("socket has been disconnected"))}}))}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Ee.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ee.EVENT:case Ee.BINARY_EVENT:this.onevent(t);break;case Ee.ACK:case Ee.BINARY_ACK:this.onack(t);break;case Ee.DISCONNECT:this.ondisconnect();break;case Ee.CONNECT_ERROR:this.destroy();let e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){let e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){let e=this._anyListeners.slice();for(let n of e)n.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){let e=this,n=!1;return function(...i){n||(n=!0,e.packet({type:Ee.ACK,id:t,data:i}))}}onack(t){let e=this.acks[t.id];"function"==typeof e&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ee.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){let e=this._anyListeners;for(let n=0;n<e.length;n++)if(t===e[n])return e.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){let e=this._anyOutgoingListeners;for(let n=0;n<e.length;n++)if(t===e[n])return e.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let e=this._anyOutgoingListeners.slice();for(let n of e)n.apply(this,t.data)}}};function zi(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}zi.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=1&Math.floor(10*e)?t+n:t-n}return 0|Math.min(t,this.max)},zi.prototype.reset=function(){this.attempts=0},zi.prototype.setMin=function(t){this.ms=t},zi.prototype.setMax=function(t){this.max=t},zi.prototype.setJitter=function(t){this.jitter=t};var Te,bl,Qr=class extends qe{constructor(t,e){var n;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,po(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=e.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new zi({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;let i=e.parser||dp;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new zl(this.uri,this.opts);let e=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let i=jt(e,"open",(function(){n.onopen(),t&&t()})),r=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},s=jt(e,"error",r);if(!1!==this._timeout){let t=this._timeout,n=this.setTimeoutFn((()=>{i(),r(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(i),this.subs.push(s),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let t=this.engine;this.subs.push(jt(t,"ping",this.onping.bind(this)),jt(t,"data",this.ondata.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this)),jt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){Bl((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let n=this.nsps[t];return n?this._autoConnect&&!n.active&&n.connect():(n=new mp(this,t,e),this.nsps[t]=n),n}_destroy(t){let e=Object.keys(this.nsps);for(let t of e)if(this.nsps[t].active)return;this._close()}_packet(t){let e=this.encoder.encode(t);for(let n=0;n<e.length;n++)this.engine.write(e[n],t.options)}cleanup(){this.subs.forEach((t=>t())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let e=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){let t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}},_s={};function cl(t,e){"object"==typeof t&&(e=t,t=void 0);let n,i=_S(t,(e=e||{}).path||"/socket.io"),r=i.source,s=i.id,a=i.path,o=_s[s]&&a in _s[s].nsps;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?n=new Qr(r,e):(_s[s]||(_s[s]=new Qr(r,e)),n=_s[s]),i.query&&!e.query&&(e.query=i.queryKey),n.socket(i.path,e)}Object.assign(cl,{Manager:Qr,Socket:mp,io:cl,connect:cl}),function(t){t.assertEqual=t=>t,t.assertIs=function(t){},t.assertNever=function(t){throw new Error},t.arrayToEnum=t=>{let e={};for(let n of t)e[n]=n;return e},t.getValidEnumValues=e=>{let n=t.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),i={};for(let t of n)i[t]=e[t];return t.objectValues(i)},t.objectValues=e=>t.objectKeys(e).map((function(t){return e[t]})),t.objectKeys="function"==typeof Object.keys?t=>Object.keys(t):t=>{let e=[];for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e},t.find=(t,e)=>{for(let n of t)if(e(n))return n},t.isInteger="function"==typeof Number.isInteger?t=>Number.isInteger(t):t=>"number"==typeof t&&isFinite(t)&&Math.floor(t)===t,t.joinValues=function(t,e=" | "){return t.map((t=>"string"==typeof t?`'${t}'`:t)).join(e)},t.jsonStringifyReplacer=(t,e)=>"bigint"==typeof e?e.toString():e}(Te||(Te={})),(bl||(bl={})).mergeShapes=(t,e)=>I(I({},t),e);var X=Te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Wn=t=>{switch(typeof t){case"undefined":return X.undefined;case"string":return X.string;case"number":return isNaN(t)?X.nan:X.number;case"boolean":return X.boolean;case"function":return X.function;case"bigint":return X.bigint;case"symbol":return X.symbol;case"object":return Array.isArray(t)?X.array:null===t?X.null:t.then&&"function"==typeof t.then&&t.catch&&"function"==typeof t.catch?X.promise:typeof Map<"u"&&t instanceof Map?X.map:typeof Set<"u"&&t instanceof Set?X.set:typeof Date<"u"&&t instanceof Date?X.date:X.object;default:return X.unknown}},N=Te.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),LS=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Qt=class t extends Error{constructor(t){super(),this.issues=[],this.addIssue=t=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};let e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let e=t||function(t){return t.message},n={_errors:[]},i=t=>{for(let r of t.issues)if("invalid_union"===r.code)r.unionErrors.map(i);else if("invalid_return_type"===r.code)i(r.returnTypeError);else if("invalid_arguments"===r.code)i(r.argumentsError);else if(0===r.path.length)n._errors.push(e(r));else{let t=n,i=0;for(;i<r.path.length;){let n=r.path[i];i===r.path.length-1?(t[n]=t[n]||{_errors:[]},t[n]._errors.push(e(r))):t[n]=t[n]||{_errors:[]},t=t[n],i++}}};return i(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Te.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(t=t=>t.message){let e={},n=[];for(let i of this.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:e}}get formErrors(){return this.flatten()}};Qt.create=t=>new Qt(t);var Fi=(t,e)=>{let n;switch(t.code){case N.invalid_type:n=t.received===X.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case N.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Te.jsonStringifyReplacer)}`;break;case N.unrecognized_keys:n=`Unrecognized key(s) in object: ${Te.joinValues(t.keys,", ")}`;break;case N.invalid_union:n="Invalid input";break;case N.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Te.joinValues(t.options)}`;break;case N.invalid_enum_value:n=`Invalid enum value. Expected ${Te.joinValues(t.options)}, received '${t.received}'`;break;case N.invalid_arguments:n="Invalid function arguments";break;case N.invalid_return_type:n="Invalid function return type";break;case N.invalid_date:n="Invalid date";break;case N.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Te.assertNever(t.validation):n="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case N.too_small:n="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case N.too_big:n="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case N.custom:n="Invalid input";break;case N.invalid_intersection_types:n="Intersection results could not be merged";break;case N.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case N.not_finite:n="Number must be finite";break;default:n=e.defaultError,Te.assertNever(t)}return{message:n}},vp=Fi;function OS(t){vp=t}function eo(){return vp}var to=t=>{let{data:e,path:n,errorMaps:i,issueData:r}=t,s=[...n,...r.path||[]],a=ie(I({},r),{path:s});if(void 0!==r.message)return ie(I({},r),{path:s,message:r.message});let o="",l=i.filter((t=>!!t)).slice().reverse();for(let t of l)o=t(a,{data:e,defaultError:o}).message;return ie(I({},r),{path:s,message:o})},DS=[];function H(t,e){let n=eo(),i=to({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Fi?void 0:Fi].filter((t=>!!t))});t.common.issues.push(i)}var K,yt=class t{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(t,e){let n=[];for(let i of e){if("aborted"===i.status)return re;"dirty"===i.status&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static mergeObjectAsync(e,n){return Cn(this,null,(function*(){let i=[];for(let t of n){let e=yield t.key,n=yield t.value;i.push({key:e,value:n})}return t.mergeObjectSync(e,i)}))}static mergeObjectSync(t,e){let n={};for(let i of e){let{key:e,value:r}=i;if("aborted"===e.status||"aborted"===r.status)return re;"dirty"===e.status&&t.dirty(),"dirty"===r.status&&t.dirty(),"__proto__"!==e.value&&(typeof r.value<"u"||i.alwaysSet)&&(n[e.value]=r.value)}return{status:t.value,value:n}}},re=Object.freeze({status:"aborted"}),no=t=>({status:"dirty",value:t}),pt=t=>({status:"valid",value:t}),xl=t=>"aborted"===t.status,wl=t=>"dirty"===t.status,Ms=t=>"valid"===t.status,Es=t=>typeof Promise<"u"&&t instanceof Promise;function io(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function _p(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n}!function(t){t.errToObj=t=>"string"==typeof t?{message:t}:t||{},t.toString=t=>"string"==typeof t?t:t?.message}(K||(K={}));var xs,ws,dn=class{constructor(t,e,n,i){this._cachedPath=[],this.parent=t,this.data=e,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Fd=(t,e)=>{if(Ms(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let e=new Qt(t.common.issues);return this._error=e,this._error}}};function he(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:i,description:r}=t;if(e&&(n||i))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return e?{errorMap:e,description:r}:{errorMap:(e,r)=>{var s,a;let{message:o}=t;return"invalid_enum_value"===e.code?{message:o??r.defaultError}:typeof r.data>"u"?{message:null!==(s=o??i)&&void 0!==s?s:r.defaultError}:"invalid_type"!==e.code?{message:r.defaultError}:{message:null!==(a=o??n)&&void 0!==a?a:r.defaultError}},description:r}}var hl,fe=class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return Wn(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Wn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new yt,ctx:{common:t.parent.common,data:t.data,parsedType:Wn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(Es(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let n=this.safeParse(t,e);if(n.success)return n.data;throw n.error}safeParse(t,e){var n;let i={common:{issues:[],async:null!==(n=e?.async)&&void 0!==n&&n,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Wn(t)},r=this._parseSync({data:t,path:i.path,parent:i});return Fd(i,r)}parseAsync(t,e){return Cn(this,null,(function*(){let n=yield this.safeParseAsync(t,e);if(n.success)return n.data;throw n.error}))}safeParseAsync(t,e){return Cn(this,null,(function*(){let n={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Wn(t)},i=this._parse({data:t,path:n.path,parent:n}),r=yield Es(i)?i:Promise.resolve(i);return Fd(n,r)}))}refine(t,e){return this._refinement(((n,i)=>{let r=t(n),s=()=>i.addIssue(I({code:N.custom},(t=>"string"==typeof e||typeof e>"u"?{message:e}:"function"==typeof e?e(t):e)(n)));return typeof Promise<"u"&&r instanceof Promise?r.then((t=>!!t||(s(),!1))):!!r||(s(),!1)}))}refinement(t,e){return this._refinement(((n,i)=>!!t(n)||(i.addIssue("function"==typeof e?e(n,i):e),!1)))}_refinement(t){return new en({schema:this,typeName:ne.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return hn.create(this,this._def)}nullable(){return Xn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ci.create(this,this._def)}promise(){return Bi.create(this,this._def)}or(t){return Ls.create([this,t],this._def)}and(t){return Os.create(this,t,this._def)}transform(t){return new en(ie(I({},he(this._def)),{schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:t}}))}default(t){let e="function"==typeof t?t:()=>t;return new Us(ie(I({},he(this._def)),{innerType:this,defaultValue:e,typeName:ne.ZodDefault}))}brand(){return new Hl(I({typeName:ne.ZodBranded,type:this},he(this._def)))}catch(t){let e="function"==typeof t?t:()=>t;return new ks(ie(I({},he(this._def)),{innerType:this,catchValue:e,typeName:ne.ZodCatch}))}describe(t){return new(0,this.constructor)(ie(I({},this._def),{description:t}))}pipe(t){return Wl.create(this,t)}readonly(){return Bs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},NS=/^c[^\s-]{8,}$/i,FS=/^[0-9a-z]+$/,US=/^[0-9A-HJKMNP-TV-Z]{26}$/,kS=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,BS=/^[a-z0-9_-]{21}$/i,zS=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,VS=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,HS="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",WS=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,GS=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,XS=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,bp="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",qS=new RegExp(`^${bp}$`);function xp(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:null==t.precision&&(e=`${e}(\\.\\d+)?`),e}function $S(t){return new RegExp(`^${xp(t)}$`)}function wp(t){let e=`${bp}T${xp(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ZS(t,e){return!(("v4"!==e&&e||!WS.test(t))&&("v6"!==e&&e||!GS.test(t)))}var Ui=class t extends fe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==X.string){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.string,received:e.parsedType}),re}let e,n=new yt;for(let i of this._def.checks)if("min"===i.kind)t.data.length<i.value&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if("max"===i.kind)t.data.length>i.value&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if("length"===i.kind){let r=t.data.length>i.value,s=t.data.length<i.value;(r||s)&&(e=this._getOrReturnCtx(t,e),r?H(e,{code:N.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&H(e,{code:N.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if("email"===i.kind)VS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"email",code:N.invalid_string,message:i.message}),n.dirty());else if("emoji"===i.kind)hl||(hl=new RegExp(HS,"u")),hl.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"emoji",code:N.invalid_string,message:i.message}),n.dirty());else if("uuid"===i.kind)kS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"uuid",code:N.invalid_string,message:i.message}),n.dirty());else if("nanoid"===i.kind)BS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"nanoid",code:N.invalid_string,message:i.message}),n.dirty());else if("cuid"===i.kind)NS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"cuid",code:N.invalid_string,message:i.message}),n.dirty());else if("cuid2"===i.kind)FS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"cuid2",code:N.invalid_string,message:i.message}),n.dirty());else if("ulid"===i.kind)US.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"ulid",code:N.invalid_string,message:i.message}),n.dirty());else if("url"===i.kind)try{new URL(t.data)}catch{e=this._getOrReturnCtx(t,e),H(e,{validation:"url",code:N.invalid_string,message:i.message}),n.dirty()}else"regex"===i.kind?(i.regex.lastIndex=0,i.regex.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"regex",code:N.invalid_string,message:i.message}),n.dirty())):"trim"===i.kind?t.data=t.data.trim():"includes"===i.kind?t.data.includes(i.value,i.position)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):"toLowerCase"===i.kind?t.data=t.data.toLowerCase():"toUpperCase"===i.kind?t.data=t.data.toUpperCase():"startsWith"===i.kind?t.data.startsWith(i.value)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):"endsWith"===i.kind?t.data.endsWith(i.value)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):"datetime"===i.kind?wp(i).test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.invalid_string,validation:"datetime",message:i.message}),n.dirty()):"date"===i.kind?qS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.invalid_string,validation:"date",message:i.message}),n.dirty()):"time"===i.kind?$S(i).test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.invalid_string,validation:"time",message:i.message}),n.dirty()):"duration"===i.kind?zS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"duration",code:N.invalid_string,message:i.message}),n.dirty()):"ip"===i.kind?ZS(t.data,i.version)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"ip",code:N.invalid_string,message:i.message}),n.dirty()):"base64"===i.kind?XS.test(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{validation:"base64",code:N.invalid_string,message:i.message}),n.dirty()):Te.assertNever(i);return{status:n.value,value:t.data}}_regex(t,e,n){return this.refinement((e=>t.test(e)),I({validation:e,code:N.invalid_string},K.errToObj(n)))}_addCheck(e){return new t(ie(I({},this._def),{checks:[...this._def.checks,e]}))}email(t){return this._addCheck(I({kind:"email"},K.errToObj(t)))}url(t){return this._addCheck(I({kind:"url"},K.errToObj(t)))}emoji(t){return this._addCheck(I({kind:"emoji"},K.errToObj(t)))}uuid(t){return this._addCheck(I({kind:"uuid"},K.errToObj(t)))}nanoid(t){return this._addCheck(I({kind:"nanoid"},K.errToObj(t)))}cuid(t){return this._addCheck(I({kind:"cuid"},K.errToObj(t)))}cuid2(t){return this._addCheck(I({kind:"cuid2"},K.errToObj(t)))}ulid(t){return this._addCheck(I({kind:"ulid"},K.errToObj(t)))}base64(t){return this._addCheck(I({kind:"base64"},K.errToObj(t)))}ip(t){return this._addCheck(I({kind:"ip"},K.errToObj(t)))}datetime(t){var e,n;return"string"==typeof t?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck(I({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:null!==(e=t?.offset)&&void 0!==e&&e,local:null!==(n=t?.local)&&void 0!==n&&n},K.errToObj(t?.message)))}date(t){return this._addCheck({kind:"date",message:t})}time(t){return"string"==typeof t?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck(I({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision},K.errToObj(t?.message)))}duration(t){return this._addCheck(I({kind:"duration"},K.errToObj(t)))}regex(t,e){return this._addCheck(I({kind:"regex",regex:t},K.errToObj(e)))}includes(t,e){return this._addCheck(I({kind:"includes",value:t,position:e?.position},K.errToObj(e?.message)))}startsWith(t,e){return this._addCheck(I({kind:"startsWith",value:t},K.errToObj(e)))}endsWith(t,e){return this._addCheck(I({kind:"endsWith",value:t},K.errToObj(e)))}min(t,e){return this._addCheck(I({kind:"min",value:t},K.errToObj(e)))}max(t,e){return this._addCheck(I({kind:"max",value:t},K.errToObj(e)))}length(t,e){return this._addCheck(I({kind:"length",value:t},K.errToObj(e)))}nonempty(t){return this.min(1,K.errToObj(t))}trim(){return new t(ie(I({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new t(ie(I({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new t(ie(I({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find((t=>"datetime"===t.kind))}get isDate(){return!!this._def.checks.find((t=>"date"===t.kind))}get isTime(){return!!this._def.checks.find((t=>"time"===t.kind))}get isDuration(){return!!this._def.checks.find((t=>"duration"===t.kind))}get isEmail(){return!!this._def.checks.find((t=>"email"===t.kind))}get isURL(){return!!this._def.checks.find((t=>"url"===t.kind))}get isEmoji(){return!!this._def.checks.find((t=>"emoji"===t.kind))}get isUUID(){return!!this._def.checks.find((t=>"uuid"===t.kind))}get isNANOID(){return!!this._def.checks.find((t=>"nanoid"===t.kind))}get isCUID(){return!!this._def.checks.find((t=>"cuid"===t.kind))}get isCUID2(){return!!this._def.checks.find((t=>"cuid2"===t.kind))}get isULID(){return!!this._def.checks.find((t=>"ulid"===t.kind))}get isIP(){return!!this._def.checks.find((t=>"ip"===t.kind))}get isBase64(){return!!this._def.checks.find((t=>"base64"===t.kind))}get minLength(){let t=null;for(let e of this._def.checks)"min"===e.kind&&(null===t||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(let e of this._def.checks)"max"===e.kind&&(null===t||e.value<t)&&(t=e.value);return t}};function YS(t,e){let n=(t.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,r=n>i?n:i;return parseInt(t.toFixed(r).replace(".",""))%parseInt(e.toFixed(r).replace(".",""))/Math.pow(10,r)}Ui.create=t=>{var e;return new Ui(I({checks:[],typeName:ne.ZodString,coerce:null!==(e=t?.coerce)&&void 0!==e&&e},he(t)))};var As=class t extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==X.number){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.number,received:e.parsedType}),re}let e,n=new yt;for(let i of this._def.checks)"int"===i.kind?Te.isInteger(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):"min"===i.kind?(i.inclusive?t.data<i.value:t.data<=i.value)&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):"max"===i.kind?(i.inclusive?t.data>i.value:t.data>=i.value)&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):"multipleOf"===i.kind?0!==YS(t.data,i.value)&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):"finite"===i.kind?Number.isFinite(t.data)||(e=this._getOrReturnCtx(t,e),H(e,{code:N.not_finite,message:i.message}),n.dirty()):Te.assertNever(i);return{status:n.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,K.toString(e))}gt(t,e){return this.setLimit("min",t,!1,K.toString(e))}lte(t,e){return this.setLimit("max",t,!0,K.toString(e))}lt(t,e){return this.setLimit("max",t,!1,K.toString(e))}setLimit(e,n,i,r){return new t(ie(I({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:i,message:K.toString(r)}]}))}_addCheck(e){return new t(ie(I({},this._def),{checks:[...this._def.checks,e]}))}int(t){return this._addCheck({kind:"int",message:K.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:K.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:K.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.toString(t)})}get minValue(){let t=null;for(let e of this._def.checks)"min"===e.kind&&(null===t||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(let e of this._def.checks)"max"===e.kind&&(null===t||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find((t=>"int"===t.kind||"multipleOf"===t.kind&&Te.isInteger(t.value)))}get isFinite(){let t=null,e=null;for(let n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===e||n.value>e)&&(e=n.value):"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}return Number.isFinite(e)&&Number.isFinite(t)}};As.create=t=>new As(I({checks:[],typeName:ne.ZodNumber,coerce:t?.coerce||!1},he(t)));var Ts=class t extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==X.bigint){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.bigint,received:e.parsedType}),re}let e,n=new yt;for(let i of this._def.checks)"min"===i.kind?(i.inclusive?t.data<i.value:t.data<=i.value)&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):"max"===i.kind?(i.inclusive?t.data>i.value:t.data>=i.value)&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):"multipleOf"===i.kind?t.data%i.value!==BigInt(0)&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):Te.assertNever(i);return{status:n.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,K.toString(e))}gt(t,e){return this.setLimit("min",t,!1,K.toString(e))}lte(t,e){return this.setLimit("max",t,!0,K.toString(e))}lt(t,e){return this.setLimit("max",t,!1,K.toString(e))}setLimit(e,n,i,r){return new t(ie(I({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:i,message:K.toString(r)}]}))}_addCheck(e){return new t(ie(I({},this._def),{checks:[...this._def.checks,e]}))}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:K.toString(e)})}get minValue(){let t=null;for(let e of this._def.checks)"min"===e.kind&&(null===t||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(let e of this._def.checks)"max"===e.kind&&(null===t||e.value<t)&&(t=e.value);return t}};Ts.create=t=>{var e;return new Ts(I({checks:[],typeName:ne.ZodBigInt,coerce:null!==(e=t?.coerce)&&void 0!==e&&e},he(t)))};var Cs=class extends fe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==X.boolean){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.boolean,received:e.parsedType}),re}return pt(t.data)}};Cs.create=t=>new Cs(I({typeName:ne.ZodBoolean,coerce:t?.coerce||!1},he(t)));var Ps=class t extends fe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==X.date){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.date,received:e.parsedType}),re}if(isNaN(t.data.getTime())){return H(this._getOrReturnCtx(t),{code:N.invalid_date}),re}let e,n=new yt;for(let i of this._def.checks)"min"===i.kind?t.data.getTime()<i.value&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):"max"===i.kind?t.data.getTime()>i.value&&(e=this._getOrReturnCtx(t,e),H(e,{code:N.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Te.assertNever(i);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t(ie(I({},this._def),{checks:[...this._def.checks,e]}))}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:K.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:K.toString(e)})}get minDate(){let t=null;for(let e of this._def.checks)"min"===e.kind&&(null===t||e.value>t)&&(t=e.value);return null!=t?new Date(t):null}get maxDate(){let t=null;for(let e of this._def.checks)"max"===e.kind&&(null===t||e.value<t)&&(t=e.value);return null!=t?new Date(t):null}};Ps.create=t=>new Ps(I({checks:[],coerce:t?.coerce||!1,typeName:ne.ZodDate},he(t)));var so=class extends fe{_parse(t){if(this._getType(t)!==X.symbol){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.symbol,received:e.parsedType}),re}return pt(t.data)}};so.create=t=>new so(I({typeName:ne.ZodSymbol},he(t)));var Rs=class extends fe{_parse(t){if(this._getType(t)!==X.undefined){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.undefined,received:e.parsedType}),re}return pt(t.data)}};Rs.create=t=>new Rs(I({typeName:ne.ZodUndefined},he(t)));var Is=class extends fe{_parse(t){if(this._getType(t)!==X.null){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.null,received:e.parsedType}),re}return pt(t.data)}};Is.create=t=>new Is(I({typeName:ne.ZodNull},he(t)));var ki=class extends fe{constructor(){super(...arguments),this._any=!0}_parse(t){return pt(t.data)}};ki.create=t=>new ki(I({typeName:ne.ZodAny},he(t)));var li=class extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return pt(t.data)}};li.create=t=>new li(I({typeName:ne.ZodUnknown},he(t)));var Pn=class extends fe{_parse(t){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.never,received:e.parsedType}),re}};Pn.create=t=>new Pn(I({typeName:ne.ZodNever},he(t)));var ro=class extends fe{_parse(t){if(this._getType(t)!==X.undefined){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.void,received:e.parsedType}),re}return pt(t.data)}};ro.create=t=>new ro(I({typeName:ne.ZodVoid},he(t)));var ci=class t extends fe{_parse(t){let{ctx:e,status:n}=this._processInputParams(t),i=this._def;if(e.parsedType!==X.array)return H(e,{code:N.invalid_type,expected:X.array,received:e.parsedType}),re;if(null!==i.exactLength){let t=e.data.length>i.exactLength.value,r=e.data.length<i.exactLength.value;(t||r)&&(H(e,{code:t?N.too_big:N.too_small,minimum:r?i.exactLength.value:void 0,maximum:t?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(null!==i.minLength&&e.data.length<i.minLength.value&&(H(e,{code:N.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),null!==i.maxLength&&e.data.length>i.maxLength.value&&(H(e,{code:N.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),e.common.async)return Promise.all([...e.data].map(((t,n)=>i.type._parseAsync(new dn(e,t,e.path,n))))).then((t=>yt.mergeArray(n,t)));let r=[...e.data].map(((t,n)=>i.type._parseSync(new dn(e,t,e.path,n))));return yt.mergeArray(n,r)}get element(){return this._def.type}min(e,n){return new t(ie(I({},this._def),{minLength:{value:e,message:K.toString(n)}}))}max(e,n){return new t(ie(I({},this._def),{maxLength:{value:e,message:K.toString(n)}}))}length(e,n){return new t(ie(I({},this._def),{exactLength:{value:e,message:K.toString(n)}}))}nonempty(t){return this.min(1,t)}};function Di(t){if(t instanceof Vt){let e={};for(let n in t.shape){let i=t.shape[n];e[n]=hn.create(Di(i))}return new Vt(ie(I({},t._def),{shape:()=>e}))}return t instanceof ci?new ci(ie(I({},t._def),{type:Di(t.element)})):t instanceof hn?hn.create(Di(t.unwrap())):t instanceof Xn?Xn.create(Di(t.unwrap())):t instanceof Gn?Gn.create(t.items.map((t=>Di(t)))):t}ci.create=(t,e)=>new ci(I({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ne.ZodArray},he(e)));var Vt=class t extends fe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let t=this._def.shape(),e=Te.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==X.object){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.object,received:e.parsedType}),re}let{status:e,ctx:n}=this._processInputParams(t),{shape:i,keys:r}=this._getCached(),s=[];if(!(this._def.catchall instanceof Pn&&"strip"===this._def.unknownKeys))for(let t in n.data)r.includes(t)||s.push(t);let a=[];for(let t of r){let e=i[t],r=n.data[t];a.push({key:{status:"valid",value:t},value:e._parse(new dn(n,r,n.path,t)),alwaysSet:t in n.data})}if(this._def.catchall instanceof Pn){let t=this._def.unknownKeys;if("passthrough"===t)for(let t of s)a.push({key:{status:"valid",value:t},value:{status:"valid",value:n.data[t]}});else if("strict"===t)s.length>0&&(H(n,{code:N.unrecognized_keys,keys:s}),e.dirty());else if("strip"!==t)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let t=this._def.catchall;for(let e of s){let i=n.data[e];a.push({key:{status:"valid",value:e},value:t._parse(new dn(n,i,n.path,e)),alwaysSet:e in n.data})}}return n.common.async?Promise.resolve().then((()=>Cn(this,null,(function*(){let t=[];for(let e of a){let n=yield e.key,i=yield e.value;t.push({key:n,value:i,alwaysSet:e.alwaysSet})}return t})))).then((t=>yt.mergeObjectSync(e,t))):yt.mergeObjectSync(e,a)}get shape(){return this._def.shape()}strict(e){return K.errToObj,new t(I(ie(I({},this._def),{unknownKeys:"strict"}),void 0!==e?{errorMap:(t,n)=>{var i,r,s,a;let o=null!==(s=null===(r=(i=this._def).errorMap)||void 0===r?void 0:r.call(i,t,n).message)&&void 0!==s?s:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(a=K.errToObj(e).message)&&void 0!==a?a:o}:{message:o}}}:{}))}strip(){return new t(ie(I({},this._def),{unknownKeys:"strip"}))}passthrough(){return new t(ie(I({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new t(ie(I({},this._def),{shape:()=>I(I({},this._def.shape()),e)}))}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>I(I({},this._def.shape()),e._def.shape()),typeName:ne.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(e){return new t(ie(I({},this._def),{catchall:e}))}pick(e){let n={};return Te.objectKeys(e).forEach((t=>{e[t]&&this.shape[t]&&(n[t]=this.shape[t])})),new t(ie(I({},this._def),{shape:()=>n}))}omit(e){let n={};return Te.objectKeys(this.shape).forEach((t=>{e[t]||(n[t]=this.shape[t])})),new t(ie(I({},this._def),{shape:()=>n}))}deepPartial(){return Di(this)}partial(e){let n={};return Te.objectKeys(this.shape).forEach((t=>{let i=this.shape[t];e&&!e[t]?n[t]=i:n[t]=i.optional()})),new t(ie(I({},this._def),{shape:()=>n}))}required(e){let n={};return Te.objectKeys(this.shape).forEach((t=>{if(e&&!e[t])n[t]=this.shape[t];else{let e=this.shape[t];for(;e instanceof hn;)e=e._def.innerType;n[t]=e}})),new t(ie(I({},this._def),{shape:()=>n}))}keyof(){return Pp(Te.objectKeys(this.shape))}};Vt.create=(t,e)=>new Vt(I({shape:()=>t,unknownKeys:"strip",catchall:Pn.create(),typeName:ne.ZodObject},he(e))),Vt.strictCreate=(t,e)=>new Vt(I({shape:()=>t,unknownKeys:"strict",catchall:Pn.create(),typeName:ne.ZodObject},he(e))),Vt.lazycreate=(t,e)=>new Vt(I({shape:t,unknownKeys:"strip",catchall:Pn.create(),typeName:ne.ZodObject},he(e)));var Ls=class extends fe{_parse(t){let{ctx:e}=this._processInputParams(t),n=this._def.options;if(e.common.async)return Promise.all(n.map((t=>Cn(this,null,(function*(){let n=ie(I({},e),{common:ie(I({},e.common),{issues:[]}),parent:null});return{result:yield t._parseAsync({data:e.data,path:e.path,parent:n}),ctx:n}}))))).then((function(t){for(let e of t)if("valid"===e.result.status)return e.result;for(let n of t)if("dirty"===n.result.status)return e.common.issues.push(...n.ctx.common.issues),n.result;let n=t.map((t=>new Qt(t.ctx.common.issues)));return H(e,{code:N.invalid_union,unionErrors:n}),re}));{let t,i=[];for(let r of n){let n=ie(I({},e),{common:ie(I({},e.common),{issues:[]}),parent:null}),s=r._parseSync({data:e.data,path:e.path,parent:n});if("valid"===s.status)return s;"dirty"===s.status&&!t&&(t={result:s,ctx:n}),n.common.issues.length&&i.push(n.common.issues)}if(t)return e.common.issues.push(...t.ctx.common.issues),t.result;let r=i.map((t=>new Qt(t)));return H(e,{code:N.invalid_union,unionErrors:r}),re}}get options(){return this._def.options}};Ls.create=(t,e)=>new Ls(I({options:t,typeName:ne.ZodUnion},he(e)));var Hn=t=>t instanceof Ds?Hn(t.schema):t instanceof en?Hn(t.innerType()):t instanceof Ns?[t.value]:t instanceof zs?t.options:t instanceof Fs?Te.objectValues(t.enum):t instanceof Us?Hn(t._def.innerType):t instanceof Rs?[void 0]:t instanceof Is?[null]:t instanceof hn?[void 0,...Hn(t.unwrap())]:t instanceof Xn?[null,...Hn(t.unwrap())]:t instanceof Hl||t instanceof Bs?Hn(t.unwrap()):t instanceof ks?Hn(t._def.innerType):[],Mp=class t extends fe{_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==X.object)return H(e,{code:N.invalid_type,expected:X.object,received:e.parsedType}),re;let n=this.discriminator,i=e.data[n],r=this.optionsMap.get(i);return r?e.common.async?r._parseAsync({data:e.data,path:e.path,parent:e}):r._parseSync({data:e.data,path:e.path,parent:e}):(H(e,{code:N.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),re)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,i){let r=new Map;for(let t of n){let n=Hn(t.shape[e]);if(!n.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of n){if(r.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);r.set(i,t)}}return new t(I({typeName:ne.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:r},he(i)))}};function El(t,e){let n=Wn(t),i=Wn(e);if(t===e)return{valid:!0,data:t};if(n===X.object&&i===X.object){let n=Te.objectKeys(e),i=Te.objectKeys(t).filter((t=>-1!==n.indexOf(t))),r=I(I({},t),e);for(let n of i){let i=El(t[n],e[n]);if(!i.valid)return{valid:!1};r[n]=i.data}return{valid:!0,data:r}}if(n===X.array&&i===X.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let r=El(t[i],e[i]);if(!r.valid)return{valid:!1};n.push(r.data)}return{valid:!0,data:n}}return n===X.date&&i===X.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Os=class extends fe{_parse(t){let{status:e,ctx:n}=this._processInputParams(t),i=(t,i)=>{if(xl(t)||xl(i))return re;let r=El(t.value,i.value);return r.valid?((wl(t)||wl(i))&&e.dirty(),{status:e.value,value:r.data}):(H(n,{code:N.invalid_intersection_types}),re)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((([t,e])=>i(t,e))):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Os.create=(t,e,n)=>new Os(I({left:t,right:e,typeName:ne.ZodIntersection},he(n)));var Gn=class t extends fe{_parse(t){let{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.array)return H(n,{code:N.invalid_type,expected:X.array,received:n.parsedType}),re;if(n.data.length<this._def.items.length)return H(n,{code:N.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),re;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:N.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());let i=[...n.data].map(((t,e)=>{let i=this._def.items[e]||this._def.rest;return i?i._parse(new dn(n,t,n.path,e)):null})).filter((t=>!!t));return n.common.async?Promise.all(i).then((t=>yt.mergeArray(e,t))):yt.mergeArray(e,i)}get items(){return this._def.items}rest(e){return new t(ie(I({},this._def),{rest:e}))}};Gn.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gn(I({items:t,typeName:ne.ZodTuple,rest:null},he(e)))};var Tp=class t extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.object)return H(n,{code:N.invalid_type,expected:X.object,received:n.parsedType}),re;let i=[],r=this._def.keyType,s=this._def.valueType;for(let t in n.data)i.push({key:r._parse(new dn(n,t,n.path,t)),value:s._parse(new dn(n,n.data[t],n.path,t)),alwaysSet:t in n.data});return n.common.async?yt.mergeObjectAsync(e,i):yt.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(e,n,i){return new t(n instanceof fe?I({keyType:e,valueType:n,typeName:ne.ZodRecord},he(i)):I({keyType:Ui.create(),valueType:e,typeName:ne.ZodRecord},he(n)))}},oo=class extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.map)return H(n,{code:N.invalid_type,expected:X.map,received:n.parsedType}),re;let i=this._def.keyType,r=this._def.valueType,s=[...n.data.entries()].map((([t,e],s)=>({key:i._parse(new dn(n,t,n.path,[s,"key"])),value:r._parse(new dn(n,e,n.path,[s,"value"]))})));if(n.common.async){let t=new Map;return Promise.resolve().then((()=>Cn(this,null,(function*(){for(let n of s){let i=yield n.key,r=yield n.value;if("aborted"===i.status||"aborted"===r.status)return re;("dirty"===i.status||"dirty"===r.status)&&e.dirty(),t.set(i.value,r.value)}return{status:e.value,value:t}}))))}{let t=new Map;for(let n of s){let i=n.key,r=n.value;if("aborted"===i.status||"aborted"===r.status)return re;("dirty"===i.status||"dirty"===r.status)&&e.dirty(),t.set(i.value,r.value)}return{status:e.value,value:t}}}};oo.create=(t,e,n)=>new oo(I({valueType:e,keyType:t,typeName:ne.ZodMap},he(n)));var ao=class t extends fe{_parse(t){let{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.set)return H(n,{code:N.invalid_type,expected:X.set,received:n.parsedType}),re;let i=this._def;null!==i.minSize&&n.data.size<i.minSize.value&&(H(n,{code:N.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),e.dirty()),null!==i.maxSize&&n.data.size>i.maxSize.value&&(H(n,{code:N.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),e.dirty());let r=this._def.valueType;function s(t){let n=new Set;for(let i of t){if("aborted"===i.status)return re;"dirty"===i.status&&e.dirty(),n.add(i.value)}return{status:e.value,value:n}}let a=[...n.data.values()].map(((t,e)=>r._parse(new dn(n,t,n.path,e))));return n.common.async?Promise.all(a).then((t=>s(t))):s(a)}min(e,n){return new t(ie(I({},this._def),{minSize:{value:e,message:K.toString(n)}}))}max(e,n){return new t(ie(I({},this._def),{maxSize:{value:e,message:K.toString(n)}}))}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}};ao.create=(t,e)=>new ao(I({valueType:t,minSize:null,maxSize:null,typeName:ne.ZodSet},he(e)));var Cp=class t extends fe{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==X.function)return H(e,{code:N.invalid_type,expected:X.function,received:e.parsedType}),re;function n(t,n){return to({data:t,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,eo(),Fi].filter((t=>!!t)),issueData:{code:N.invalid_arguments,argumentsError:n}})}function i(t,n){return to({data:t,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,eo(),Fi].filter((t=>!!t)),issueData:{code:N.invalid_return_type,returnTypeError:n}})}let r={errorMap:e.common.contextualErrorMap},s=e.data;if(this._def.returns instanceof Bi){let t=this;return pt((function(...e){return Cn(this,null,(function*(){let a=new Qt([]),o=yield t._def.args.parseAsync(e,r).catch((t=>{throw a.addIssue(n(e,t)),a})),l=yield Reflect.apply(s,this,o);return yield t._def.returns._def.type.parseAsync(l,r).catch((t=>{throw a.addIssue(i(l,t)),a}))}))}))}{let t=this;return pt((function(...e){let a=t._def.args.safeParse(e,r);if(!a.success)throw new Qt([n(e,a.error)]);let o=Reflect.apply(s,this,a.data),l=t._def.returns.safeParse(o,r);if(!l.success)throw new Qt([i(o,l.error)]);return l.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t(ie(I({},this._def),{args:Gn.create(e).rest(li.create())}))}returns(e){return new t(ie(I({},this._def),{returns:e}))}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(e,n,i){return new t(I({args:e||Gn.create([]).rest(li.create()),returns:n||li.create(),typeName:ne.ZodFunction},he(i)))}},Ds=class extends fe{get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};Ds.create=(t,e)=>new Ds(I({getter:t,typeName:ne.ZodLazy},he(e)));var Ns=class extends fe{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return H(e,{received:e.data,code:N.invalid_literal,expected:this._def.value}),re}return{status:"valid",value:t.data}}get value(){return this._def.value}};function Pp(t,e){return new zs(I({values:t,typeName:ne.ZodEnum},he(e)))}Ns.create=(t,e)=>new Ns(I({value:t,typeName:ne.ZodLiteral},he(e)));var zs=class t extends fe{constructor(){super(...arguments),xs.set(this,void 0)}_parse(t){if("string"!=typeof t.data){let e=this._getOrReturnCtx(t),n=this._def.values;return H(e,{expected:Te.joinValues(n),received:e.parsedType,code:N.invalid_type}),re}if(io(this,xs,"f")||_p(this,xs,new Set(this._def.values),"f"),!io(this,xs,"f").has(t.data)){let e=this._getOrReturnCtx(t),n=this._def.values;return H(e,{received:e.data,code:N.invalid_enum_value,options:n}),re}return pt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let e of this._def.values)t[e]=e;return t}get Values(){let t={};for(let e of this._def.values)t[e]=e;return t}get Enum(){let t={};for(let e of this._def.values)t[e]=e;return t}extract(e,n=this._def){return t.create(e,I(I({},this._def),n))}exclude(e,n=this._def){return t.create(this.options.filter((t=>!e.includes(t))),I(I({},this._def),n))}};xs=new WeakMap,zs.create=Pp;var Fs=class extends fe{constructor(){super(...arguments),ws.set(this,void 0)}_parse(t){let e=Te.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==X.string&&n.parsedType!==X.number){let t=Te.objectValues(e);return H(n,{expected:Te.joinValues(t),received:n.parsedType,code:N.invalid_type}),re}if(io(this,ws,"f")||_p(this,ws,new Set(Te.getValidEnumValues(this._def.values)),"f"),!io(this,ws,"f").has(t.data)){let t=Te.objectValues(e);return H(n,{received:n.data,code:N.invalid_enum_value,options:t}),re}return pt(t.data)}get enum(){return this._def.values}};ws=new WeakMap,Fs.create=(t,e)=>new Fs(I({values:t,typeName:ne.ZodNativeEnum},he(e)));var Bi=class extends fe{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==X.promise&&!1===e.common.async)return H(e,{code:N.invalid_type,expected:X.promise,received:e.parsedType}),re;let n=e.parsedType===X.promise?e.data:Promise.resolve(e.data);return pt(n.then((t=>this._def.type.parseAsync(t,{path:e.path,errorMap:e.common.contextualErrorMap}))))}};Bi.create=(t,e)=>new Bi(I({type:t,typeName:ne.ZodPromise},he(e)));var en=class extends fe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ne.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:n}=this._processInputParams(t),i=this._def.effect||null,r={addIssue:t=>{H(n,t),t.fatal?e.abort():e.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===i.type){let t=i.transform(n.data,r);if(n.common.async)return Promise.resolve(t).then((t=>Cn(this,null,(function*(){if("aborted"===e.value)return re;let i=yield this._def.schema._parseAsync({data:t,path:n.path,parent:n});return"aborted"===i.status?re:"dirty"===i.status||"dirty"===e.value?no(i.value):i}))));{if("aborted"===e.value)return re;let i=this._def.schema._parseSync({data:t,path:n.path,parent:n});return"aborted"===i.status?re:"dirty"===i.status||"dirty"===e.value?no(i.value):i}}if("refinement"===i.type){let t=t=>{let e=i.refinement(t,r);if(n.common.async)return Promise.resolve(e);if(e instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return t};if(!1===n.common.async){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===i.status?re:("dirty"===i.status&&e.dirty(),t(i.value),{status:e.value,value:i.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((n=>"aborted"===n.status?re:("dirty"===n.status&&e.dirty(),t(n.value).then((()=>({status:e.value,value:n.value}))))))}if("transform"===i.type){if(!1===n.common.async){let t=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ms(t))return t;let s=i.transform(t.value,r);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((t=>Ms(t)?Promise.resolve(i.transform(t.value,r)).then((t=>({status:e.value,value:t}))):t))}Te.assertNever(i)}};en.create=(t,e,n)=>new en(I({schema:t,typeName:ne.ZodEffects,effect:e},he(n))),en.createWithPreprocess=(t,e,n)=>new en(I({schema:e,effect:{type:"preprocess",transform:t},typeName:ne.ZodEffects},he(n)));var hn=class extends fe{_parse(t){return this._getType(t)===X.undefined?pt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};hn.create=(t,e)=>new hn(I({innerType:t,typeName:ne.ZodOptional},he(e)));var Xn=class extends fe{_parse(t){return this._getType(t)===X.null?pt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Xn.create=(t,e)=>new Xn(I({innerType:t,typeName:ne.ZodNullable},he(e)));var Us=class extends fe{_parse(t){let{ctx:e}=this._processInputParams(t),n=e.data;return e.parsedType===X.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};Us.create=(t,e)=>new Us(I({innerType:t,typeName:ne.ZodDefault,defaultValue:"function"==typeof e.default?e.default:()=>e.default},he(e)));var ks=class extends fe{_parse(t){let{ctx:e}=this._processInputParams(t),n=ie(I({},e),{common:ie(I({},e.common),{issues:[]})}),i=this._def.innerType._parse({data:n.data,path:n.path,parent:I({},n)});return Es(i)?i.then((t=>({status:"valid",value:"valid"===t.status?t.value:this._def.catchValue({get error(){return new Qt(n.common.issues)},input:n.data})}))):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new Qt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ks.create=(t,e)=>new ks(I({innerType:t,typeName:ne.ZodCatch,catchValue:"function"==typeof e.catch?e.catch:()=>e.catch},he(e)));var lo=class extends fe{_parse(t){if(this._getType(t)!==X.nan){let e=this._getOrReturnCtx(t);return H(e,{code:N.invalid_type,expected:X.nan,received:e.parsedType}),re}return{status:"valid",value:t.data}}};lo.create=t=>new lo(I({typeName:ne.ZodNaN},he(t)));var JS=Symbol("zod_brand"),Hl=class extends fe{_parse(t){let{ctx:e}=this._processInputParams(t),n=e.data;return this._def.type._parse({data:n,path:e.path,parent:e})}unwrap(){return this._def.type}},Wl=class t extends fe{_parse(t){let{status:e,ctx:n}=this._processInputParams(t);if(n.common.async)return Cn(this,null,(function*(){let t=yield this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===t.status?re:"dirty"===t.status?(e.dirty(),no(t.value)):this._def.out._parseAsync({data:t.value,path:n.path,parent:n})}));{let t=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===t.status?re:"dirty"===t.status?(e.dirty(),{status:"dirty",value:t.value}):this._def.out._parseSync({data:t.value,path:n.path,parent:n})}}static create(e,n){return new t({in:e,out:n,typeName:ne.ZodPipeline})}},Bs=class extends fe{_parse(t){let e=this._def.innerType._parse(t),n=t=>(Ms(t)&&(t.value=Object.freeze(t.value)),t);return Es(e)?e.then((t=>n(t))):n(e)}unwrap(){return this._def.innerType}};function Ip(t,e={},n){return t?ki.create().superRefine(((i,r)=>{var s,a;if(!t(i)){let t="function"==typeof e?e(i):"string"==typeof e?{message:e}:e,o=null===(a=null!==(s=t.fatal)&&void 0!==s?s:n)||void 0===a||a,l="string"==typeof t?{message:t}:t;r.addIssue(ie(I({code:"custom"},l),{fatal:o}))}})):ki.create()}Bs.create=(t,e)=>new Bs(I({innerType:t,typeName:ne.ZodReadonly},he(e)));var ne,KS={object:Vt.lazycreate};!function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"}(ne||(ne={}));var jS=(t,e={message:`Input not instance of ${t.name}`})=>Ip((e=>e instanceof t),e),Lp=Ui.create,Op=As.create,QS=lo.create,eM=Ts.create,Dp=Cs.create,tM=Ps.create,nM=so.create,iM=Rs.create,sM=Is.create,rM=ki.create,oM=li.create,aM=Pn.create,lM=ro.create,cM=ci.create,hM=Vt.create,uM=Vt.strictCreate,dM=Ls.create,pM=Mp.create,fM=Os.create,mM=Gn.create,gM=Tp.create,vM=oo.create,yM=ao.create,_M=Cp.create,bM=Ds.create,xM=Ns.create,wM=zs.create,SM=Fs.create,MM=Bi.create,Ud=en.create,EM=hn.create,AM=Xn.create,TM=en.createWithPreprocess,CM=Wl.create,PM=()=>Lp().optional(),RM=()=>Op().optional(),IM=()=>Dp().optional(),LM={string:t=>Ui.create(ie(I({},t),{coerce:!0})),number:t=>As.create(ie(I({},t),{coerce:!0})),boolean:t=>Cs.create(ie(I({},t),{coerce:!0})),bigint:t=>Ts.create(ie(I({},t),{coerce:!0})),date:t=>Ps.create(ie(I({},t),{coerce:!0}))},OM=re,Kt=Object.freeze({__proto__:null,defaultErrorMap:Fi,setErrorMap:OS,getErrorMap:eo,makeIssue:to,EMPTY_PATH:DS,addIssueToContext:H,ParseStatus:yt,INVALID:re,DIRTY:no,OK:pt,isAborted:xl,isDirty:wl,isValid:Ms,isAsync:Es,get util(){return Te},get objectUtil(){return bl},ZodParsedType:X,getParsedType:Wn,ZodType:fe,datetimeRegex:wp,ZodString:Ui,ZodNumber:As,ZodBigInt:Ts,ZodBoolean:Cs,ZodDate:Ps,ZodSymbol:so,ZodUndefined:Rs,ZodNull:Is,ZodAny:ki,ZodUnknown:li,ZodNever:Pn,ZodVoid:ro,ZodArray:ci,ZodObject:Vt,ZodUnion:Ls,ZodDiscriminatedUnion:Mp,ZodIntersection:Os,ZodTuple:Gn,ZodRecord:Tp,ZodMap:oo,ZodSet:ao,ZodFunction:Cp,ZodLazy:Ds,ZodLiteral:Ns,ZodEnum:zs,ZodNativeEnum:Fs,ZodPromise:Bi,ZodEffects:en,ZodTransformer:en,ZodOptional:hn,ZodNullable:Xn,ZodDefault:Us,ZodCatch:ks,ZodNaN:lo,BRAND:JS,ZodBranded:Hl,ZodPipeline:Wl,ZodReadonly:Bs,custom:Ip,Schema:fe,ZodSchema:fe,late:KS,get ZodFirstPartyTypeKind(){return ne},coerce:LM,any:rM,array:cM,bigint:eM,boolean:Dp,date:tM,discriminatedUnion:pM,effect:Ud,enum:wM,function:_M,instanceof:jS,intersection:fM,lazy:bM,literal:xM,map:vM,nan:QS,nativeEnum:SM,never:aM,null:sM,nullable:AM,number:Op,object:hM,oboolean:IM,onumber:RM,optional:EM,ostring:PM,pipeline:CM,preprocess:TM,promise:MM,record:gM,set:yM,strictObject:uM,string:Lp,symbol:nM,transformer:Ud,tuple:mM,undefined:iM,union:dM,unknown:oM,void:lM,NEVER:OM,ZodIssueCode:N,quotelessJson:LS,ZodError:Qt}),DM=Kt.object({serverUrl:Kt.string()}),NM=DM.parse({serverUrl:"https://io.superviz.com"}),FM=class{constructor(t){this.socket=t,this.onConnect=()=>{this.logger.log("connection @ on connect","Connected to the socket"),this.changeState("CONNECTED")},this.onDisconnect=t=>{this.logger.log("connection @ on disconnect","Disconnected from the socket"),this.changeState("DISCONNECTED",t)},this.onConnectError=t=>{this.logger.log("connection @ on connect error","Connection error",t),this.changeState("CONNECTION_ERROR",t.message)},this.onConnectionError=t=>{this.logger.log("connection @ on connection error","Connection error",t),this.changeState("CONNECTION_ERROR",t.message)},this.onReconnect=()=>{this.logger.log("connection @ on reconnect","Reconnected to the socket"),this.changeState("CONNECTED")},this.onReconnectError=t=>{this.logger.log("connection @ on reconnect error","Reconnect error",t),this.changeState("RECONNECT_ERROR",t.message)},this.onReconnectFailed=()=>{this.logger.log("connection @ on reconnect failed","Failed to reconnect to the socket"),this.changeState("RECONNECT_ERROR")},this.onReconnecAttempt=t=>{this.logger.log("connection @ on reconnect attempt",`Reconnect attempt #${t}`),this.changeState("RECONNECTING",`Reconnect attempt #${t}`)},this.onCustomError=t=>{t.needsToDisconnect&&(this.socket.disconnect(),this.changeState("DISCONNECTED",t.errorType));let e=`[SuperViz] \n    - Error: ${t.errorType}\n    - Message: ${t.message}\n    `;"error"!==t.level?console.warn(e):console.error(e)},this.logger=new Nl("@superviz/socket-client/connection"),this.subscribeToManagerEvents(),this.stateObserver=new cn}on(t,e){this.stateObserver.closed&&(this.stateObserver=new cn),this.stateObserver.subscribe({next:t,error:e})}off(){this.stateObserver.closed||this.stateObserver.unsubscribe()}subscribeToManagerEvents(){this.socket.on("connect",this.onConnect),this.socket.on("disconnect",this.onDisconnect),this.socket.on("connect_error",this.onConnectError),this.socket.io.on("error",this.onConnectionError),this.socket.io.on("reconnect",this.onReconnect),this.socket.io.on("reconnect_attempt",this.onReconnecAttempt),this.socket.io.on("reconnect_error",this.onReconnectError),this.socket.io.on("reconnect_failed",this.onReconnectFailed),this.socket.on("socket-event.error",this.onCustomError)}changeState(t,e){this.state=t,!this.stateObserver.closed&&this.stateObserver.next({state:t,reason:e})}},UM=class t{constructor(t,e,n,i,r=100){this.io=t,this.user=e,this.roomId=n,this.apiKey=i,this.maxConnections=r,this.isJoined=!1,this.subscriptions=new Map,this.observers=new Map,this.onJoinedRoom=t=>{var e;this.roomId===(null==(e=t?.data)?void 0:e.name)&&(this.isJoined=!0,this.io.emit("room.joined",this.roomId,t.data),this.logger.log("room @ joined",t))},this.onHttpEvent=t=>{this.publishEventToClient(t.name,t)},this.logger=new Nl("@superviz/socket-client/room");let s={name:n,user:e,maxConnections:r};this.presence=Hw.register(t,e,n),this.io.emit("room.join",s),this.subscribeToRoomEvents()}static register(e,n,i,r,s){return new t(e,n,i,r,s)}on(t,e){this.logger.log("room @ on",t);let n=this.observers.get(t);n||(n=new cn,this.observers.set(t,n),this.io.on(t,(e=>{this.publishEventToClient(t,e)}))),this.subscriptions.set(e,n.subscribe(e))}off(t,e){var n;if(this.logger.log("room @ off",t),!e)return this.observers.delete(t),void this.io.off(t);null==(n=this.subscriptions.get(e))||n.unsubscribe()}emit(t,e){if(!this.isJoined)return void this.logger.log("Cannot emit event. Not joined to room");let n={name:t,roomId:this.roomId,presence:this.user,connectionId:this.io.id,data:e,timestamp:Date.now()};this.io.emit("room.update",this.roomId,n),this.logger.log("room @ emit",t,e)}history(t,e){let n=new cn;n.subscribe({next:t,error:e});let i=t=>{this.logger.log("room @ history",t),this.io.off("room.get",i),n.next(t),n.complete(),n.unsubscribe()};this.io.on("room.get",i),this.io.emit("room.get",this.roomId)}disconnect(){this.logger.log("room @ disconnect","Leaving room...",this.roomId),this.io.emit("room.leave",this.roomId),this.subscriptions.forEach((t=>t.unsubscribe())),this.subscriptions.clear(),this.observers.forEach((t=>t.unsubscribe())),this.observers.clear(),this.presence.destroy()}publishEventToClient(t,e){let n=this.observers.get(t);!n||e.roomId!==this.roomId||n.next(e)}subscribeToRoomEvents(){this.io.on("room.joined",this.onJoinedRoom),this.io.on("room.error",(t=>{this.logger.log("Error:",t.data)})),this.io.on(`http:${this.roomId}:${this.apiKey}`,this.onHttpEvent)}},kM=class{constructor(t,e,n,i,r){let s;this.apiKey=t,this.environment=e,this.presence=n,this.secret=i,this.clientId=r,this.manager=new Qr(NM.serverUrl,{addTrailingSlash:!1,secure:!0,withCredentials:!0,reconnection:!0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,reconnectionAttempts:5,extraHeaders:{"sv-api-key":this.apiKey}}),typeof window<"u"&&(s=window.location.origin),this.socket=this.manager.socket(`/${e}`,{auth:{apiKey:this.apiKey,origin:s,envirioment:this.environment,secret:this.secret,clientId:this.clientId}}),this.connection=new FM(this.socket)}get state(){return this.connection.state}connect(t,e){return UM.register(this.socket,this.presence,t,this.apiKey,e)}destroy(){this.socket.disconnect(),this.connection.off()}},W1=Kt.object({name:Kt.string(),user:Kt.object({id:Kt.string(),name:Kt.string().nullable()}),maxConnections:Kt.union([Kt.number(),Kt.literal("unlimited"),Kt.undefined()])}),BM=Zt(Li());z();var kd=class{constructor(){this.observers=new Map,this.subscribe=(t,e)=>{this.logger.log("event bus service @ subscribe",{event:t,callback:e}),this.observers.has(t)||this.observers.set(t,new Xe),this.observers.get(t).subscribe(e)},this.unsubscribe=(t,e)=>{this.logger.log("event bus service @ unsubscribe",{event:t,callback:e}),this.observers.has(t)&&(this.observers.get(t).reset(),this.observers.delete(t))},this.publish=(t,e)=>{this.logger.log("event bus service @ publish",{event:t,data:e}),this.observers.has(t)&&this.observers.get(t).publish(e)},this.destroy=()=>{this.logger.log("event bus service @ destroy"),this.observers.forEach((t=>{t.reset(),t.destroy()})),this.observers.clear()},this.logger=new st("@superviz/sdk/event-bus"),this.logger.log("event bus created")}};z(),z();var zM=class{constructor(t){this.participant=t,this.stateSubject=new fd,this.handleConnectionState=t=>"Unauthorized connection"===t.reason?(console.error("[Superviz] Unauthorized connection. Please check your API key and if your domain is white listed."),this.state={state:Yd.DISCONNECTED,reason:"Unauthorized connection"},void this.stateSubject.next("AUTH_ERROR")):"user-already-in-room"===t.reason?(this.state=t,void this.stateSubject.next("SAME_ACCOUNT_ERROR")):(this.state=t,void this.stateSubject.next(t.state)),this.createClient()}destroy(){this.stateSubject.complete(),this.client.destroy()}subscribeToDefaultEvents(){this.client.connection.on(this.handleConnectionState)}createClient(){let t=Q.get("environment");t=["dev","prod"].includes(t)?t:"dev",this.client=new kM(Q.get("apiKey"),t,{id:this.participant.id,name:this.participant.name}),this.subscribeToDefaultEvents()}createRoom(t,e=50){let n=Q.get("roomId");return this.client.connect(`${n}:${t}`,e)}};z(),z();var Fp=(t=>(t.comments="presence",t.presence3dMatterport="presence",t.presence3dAutodesk="presence",t.presence3dThreejs="presence",t.whoIsOnline="presence",t.formElements="presence",t.yjsProvider="presence",t))(Fp||{}),Bd=class{static checkComponentLimit(t){var e,n;let i=Q.get("limits"),r=null!=(e=Fp[t])?e:t;return null!=(n=i?.[r])?n:{canUse:!1,maxParticipants:50}}};z(),z();var Up=(t=>(t.HOST="host",t.GUEST="guest",t.AUDIENCE="audience",t))(Up||{}),VM=class{constructor(t,e){this.room=t,this.useStore=e,this.isAssigningSlot=!1,this.slot={index:null,color:Yt.gray,textColor:"#fff",colorName:"gray",timestamp:Date.now()},this.onPresenceUpdate=t=>ce(this,null,(function*(){var e,n,i;let{localParticipant:r}=this.useStore("global-store");if(t.id!==r.value.id){if(null!==(null==(e=t.data.slot)?void 0:e.index)&&null!==this.slot.index&&(null==(n=t.data.slot)?void 0:n.index)===(null==(i=this.slot)?void 0:i.index)){let t=yield this.assignSlot();r.publish(ge(B({},r.value),{slot:t})),console.debug(`[SuperViz] - Slot reassigned to ${r.value.id}, slot: ${t.colorName}`)}}else{let e=yield this.validateSlotType(t.data);r.publish(ge(B({},r.value),{slot:e}))}})),this.participantNeedsSlot=t=>{var e;let n=["formElements","whoIsOnline","presence","presence3dAutodesk","presence3dMatterport","presence3dThreejs","yjsProvider"].some((e=>{var n;return null==(n=t?.activeComponents)?void 0:n.includes(e)})),i=(null==(e=t?.activeComponents)?void 0:e.includes("videoConference"))&&"audience"!==t.type;return n||i},this.validateSlotType=t=>ce(this,null,(function*(){var e,n;if(this.isAssigningSlot)return this.slot;let i=this.participantNeedsSlot(t);if(null===(null==(e=t.slot)?void 0:e.index)&&i){let t=yield this.assignSlot();this.slot=t}return null!==(null==(n=t.slot)?void 0:n.index)&&!i&&this.setDefaultSlot(),this.slot})),this.room=t,this.room.presence.on(se.UPDATE,this.onPresenceUpdate)}assignSlot(){return ce(this,null,(function*(){if(this.isAssigningSlot)return this.slot;this.isAssigningSlot=!0;let t=Array.from({length:50},((t,e)=>e)),e=Math.floor(50*Math.random()),{localParticipant:n,participants:i}=Pt("global-store");try{yield new Promise(((e,i)=>{this.room.presence.get((r=>{if((!r||!r.length)&&e(!0),r.length>=50)return t=[],void i(new Error("[SuperViz] - No more slots available"));r.forEach((e=>{e.id!==n.value.id&&(t=t.filter((t=>{var n,i;return t!==(null==(i=null==(n=e.data)?void 0:n.slot)?void 0:i.index)})))})),e(!0)}))})),!t.includes(e)&&(e=t.shift());let r=Object.keys(Yt)[e],s={index:e,color:Yt[r],textColor:cd.includes(r)?"#fff":"#000",colorName:r,timestamp:Date.now()};return this.slot=s,n.publish(ge(B({},n.value),{slot:s})),i.publish(ge(B({},i.value),{[n.value.id]:ge(B({},i.value[n.value.id]),{slot:s})})),this.room.presence.update({slot:s}),this.isAssigningSlot=!1,s}catch(t){return console.error(t),null}}))}setDefaultSlot(){let{localParticipant:t,participants:e}=Pt("global-store"),n={index:null,color:Yt.gray,textColor:"#fff",colorName:"gray",timestamp:Date.now()};this.slot=n,t.publish(ge(B({},t.value),{slot:n})),e.publish(ge(B({},e.value),{[t.value.id]:ge(B({},e.value[t.value.id]),{slot:n})})),this.room.presence.update({slot:n})}};z();var HM=class extends Ll{constructor({participant:t,group:e}){super(),this.isDestroyed=!1,this.activeComponents=[],this.componentsToAttachAfterJoin=[],this.activeComponentsInstances=[],this.eventBus=new kd,this.useStore=Pt.bind(this),this.addComponent=t=>ce(this,null,(function*(){if(!this.canAddComponent(t))return;let{hasJoinedRoom:e,group:n,localParticipant:i}=Pt("global-store");if(!e.value)return this.logger.log("launcher service @ addComponent - not joined yet"),void this.componentsToAttachAfterJoin.push(t);let r=Bd.checkComponentLimit(t.name);t.attach({ioc:this.ioc,config:Q.configuration,eventBus:this.eventBus,useStore:Pt,connectionLimit:r.maxParticipants}),this.activeComponents.push(t.name),this.activeComponentsInstances.some((e=>e.name===t.name))?this.activeComponentsInstances=this.activeComponentsInstances.map((e=>e.name===t.name?t:e)):this.activeComponentsInstances.push(t),i.publish(ge(B({},i.value),{activeComponents:this.activeComponents})),this.room.presence.update(ge(B({},i.value),{slot:this.slotService.slot,activeComponents:this.activeComponents})),it.sendActivity(this.participant.id,n.value.id,n.value.name,t.name)})),this.attachComponentsAfterJoin=()=>{this.logger.log("launcher service @ attachComponentsAfterJoin"),this.componentsToAttachAfterJoin.forEach((t=>{this.logger.log("launcher service @ attachComponentsAfterJoin - attaching component",t.name),this.addComponent(t)})),this.componentsToAttachAfterJoin=[]},this.removeComponent=t=>{if(!this.activeComponents.includes(t.name)){let e=`[SuperViz] Component ${t.name} is not initialized yet.`;return this.logger.log(e),void console.error(e)}t.detach(),this.activeComponentsInstances=this.activeComponentsInstances.filter((e=>e.name!==t.name)),this.activeComponents.splice(this.activeComponents.indexOf(t.name),1),this.room.presence.update(ge(B({},this.participant),{activeComponents:this.activeComponents}))},this.destroy=()=>{var t,e,n,i,r,s;this.logger.log("launcher service @ destroy"),this.activeComponentsInstances.forEach((t=>{this.logger.log("launcher service @ destroy - removing component",t.name),this.removeComponent(t)})),this.activeComponents=[],this.activeComponentsInstances=[],null==(t=nl())||t.destroy(),null==(e=this.eventBus)||e.destroy(),this.eventBus=void 0,null==(n=this.room)||n.presence.off(se.JOINED_ROOM),null==(i=this.room)||i.presence.off(se.LEAVE),null==(r=this.room)||r.presence.off(se.UPDATE),null==(s=this.ioc)||s.destroy(),this.isDestroyed=!0,typeof window<"u"&&(window.SUPERVIZ=void 0)},this.canAddComponent=t=>{var e;let n=Q.get(`features.${t.name}`),i=Bd.checkComponentLimit(t.name),r=null==(e=this.activeComponents)?void 0:e.includes(t.name),s=[{isValid:n,message:`[SuperViz] Component ${t.name} is not enabled in the room`},{isValid:!this.isDestroyed,message:"[SuperViz] Component can not be added because the superviz room is destroyed. Initialize a new room to add and use components."},{isValid:!r,message:`[SuperViz] Component ${t.name} is already active. Please remove it first`},{isValid:i.canUse,message:`[SuperViz] You reached the limit usage of ${t.name}`}];for(let t=0;t<s.length;t++){let{isValid:e,message:n}=s[t];if(!e)return this.logger.log(n),console.error(n),!1}return!0},this.onAuthentication=t=>{t||(this.destroy(),console.error("[SuperViz] Room cannot be initialized because this website's domain is not whitelisted. If you are the developer, please add your domain in https://dashboard.superviz.com/developer"))},this.onLocalParticipantUpdateOnStore=t=>{this.participant=t,this.activeComponents=t.activeComponents||[]},this.onLocalParticipantUpdateOnCore=t=>{if(!this.room)return;let{localParticipant:e}=Pt("global-store");e.publish(t),this.room.presence.update(t)},this.onParticipantsListUpdateOnCore=t=>{let{participants:e}=this.useStore("global-store");e.publish(t)},this.onSameAccount=()=>{this.publish("participant.same-account-error"),this.destroy()},this.startIOC=()=>{this.logger.log("launcher service @ startIOC");let{participants:t}=Pt("global-store");this.ioc.stateSubject.subscribe(this.onConnectionStateChange),this.room.presence.get((e=>{let n={};e.forEach((t=>{var e;n[t.id]=ge(B({},t.data),{name:null!=(e=t.data.name)?e:t.name,id:t.id,timestamp:t.timestamp})})),n[this.participant.id]=B(B({},n[this.participant.id]),this.participant),t.publish(n)})),this.room.presence.on(se.JOINED_ROOM,this.onParticipantJoinedIOC),this.room.presence.on(se.LEAVE,this.onParticipantLeaveIOC),this.room.presence.on(se.UPDATE,this.onParticipantUpdatedIOC)},this.onConnectionStateChange=t=>{"AUTH_ERROR"!==t?"SAME_ACCOUNT_ERROR"===t&&this.onSameAccount():this.onAuthentication(!1)},this.onParticipantJoinedIOC=t=>ce(this,null,(function*(){if(t.id!==this.participant.id)return;this.room.presence.update(this.participant),this.logger.log("launcher service @ onParticipantJoined - local participant joined");let{hasJoinedRoom:e}=Pt("global-store");e.publish(!0),this.attachComponentsAfterJoin(),this.publish("participant.local-joined",this.participant),this.publish("participant.joined",this.participant)})),this.onParticipantLeaveIOC=t=>{let{participants:e,localParticipant:n}=Pt("global-store"),i=B({},e.value);delete i[t.id],e.publish(i),t.id===n.value.id&&(this.logger.log("launcher service @ onParticipantLeave - local participant left"),this.publish("participant.local-left",t.data)),this.logger.log("launcher service @ onParticipantLeave - participant left",t.data),this.publish("participant.left",t.data),this.publish("participant.list-updated",Object.values(i))},this.onParticipantUpdatedIOC=t=>{let{localParticipant:e}=Pt("global-store");if(e.value&&t.id===e.value.id){let n=B(B({},e.value),t.data);e.publish(ge(B({},n),{timestamp:t.timestamp})),this.publish("participant.updated",n),this.logger.log("Publishing ParticipantEvent.UPDATED",t.data)}let{participants:n}=Pt("global-store"),i=B({id:t.id,name:t.data.name,timestamp:t.timestamp},t.data);n.value[t.id]||this.publish("participant.joined",i);let r=Object.assign({},n.value);if(r[t.id]=i,(0,BM.isEqual)(r,n.value))return;n.publish(r);let s=Object.values(n.value);this.logger.log("Publishing ParticipantEvent.LIST_UPDATED",n.value),this.publish("participant.list-updated",s)},this.logger=new st("@superviz/sdk/launcher");let{localParticipant:n,group:i}=this.useStore("global-store");n.publish(B({},t)),n.subscribe(this.onLocalParticipantUpdateOnStore),i.publish(e),this.ioc=new zM(n.value),this.room=this.ioc.createRoom("launcher","unlimited"),this.slotService=new VM(this.room,this.useStore),n.publish(ge(B({},n.value),{slot:this.slotService.slot,activeComponents:[]})),this.participant=n.value,this.eventBus=new kd,this.eventBus.subscribe("update-participant",this.onLocalParticipantUpdateOnCore),this.eventBus.subscribe("update-participant-list",this.onParticipantsListUpdateOnCore),this.logger.log("launcher created"),this.startIOC()}},WM=t=>{if(typeof window<"u"&&window.SUPERVIZ)return console.warn("[SUPERVIZ] Room already initialized"),{destroy:window.SUPERVIZ.destroy,subscribe:window.SUPERVIZ.subscribe,unsubscribe:window.SUPERVIZ.unsubscribe,addComponent:window.SUPERVIZ.addComponent,removeComponent:window.SUPERVIZ.removeComponent};let e=new HM(t);return typeof window<"u"&&(window.SUPERVIZ=e),{destroy:e.destroy,subscribe:e.subscribe,unsubscribe:e.unsubscribe,addComponent:e.addComponent,removeComponent:e.removeComponent}};function zd(t){return!(!/^.{2,64}$/.test(t)||!/^[-_&@+=,(){}\[\]\/«».|'"#a-zA-Z0-9À-ÿ\s]*$/.test(t))}function GM(t){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t)}var XM=({group:t,participant:e,roomId:n,customColors:i})=>{if(i&&qM(i),!t||!t.name||!t.id)throw new Error("[SuperViz] Group fields is required");if(!e||!e.id)throw new Error("[SuperViz] Participant id is required");if(!n)throw new Error("[SuperViz] Room id is required");if(!zd(n))throw new Error("[SuperViz] Room id is invalid, it should be between 2 and 64 characters and only accept letters, numbers and special characters: -_&@+=,(){}[]/«».|'\"");if(!zd(e.id))throw new Error("[SuperViz] Participant id is invalid, it should be between 2 and 64 characters and only accept letters, numbers and special characters: -_&@+=,(){}[]/«».|'\"");if(e.email&&!GM(e.email))throw new Error("[SuperViz] Participant email is invalid")},qM=t=>{Object.entries(t).forEach((([t,e])=>{if(!Object.values($d).includes(t))throw new Error(`[SuperViz] Color ${t} is not a valid color variable name. Please check the documentation for more information.`);if(!/^(\d{1,3}\s){2}\d{1,3}$/.test(e))throw new Error(`[SuperViz] Color ${t} is not a valid color variable value. Please check the documentation for more information.`)}))},$M=t=>{t&&Object.entries(t).forEach((([t,e])=>{let n=e.replace(/\s/g,", ");document.documentElement.style.setProperty(`--${t}`,n)}))},ZM=(t,e)=>ce(void 0,null,(function*(){var n,i,r,s,a;if(!t||!t.trim())throw new Error("API key is required");if(!e)throw new Error("Options is required");XM(e),e.debug?yd.debug.enable("*"):yd.debug.disable();let[{apiUrl:o,conferenceLayerUrl:l},c]=yield Promise.all([Yr.getRemoteConfig(e.environment),Yr.getFeatures(t)]),[u,h,d]=yield Promise.all([dw(o,t),it.fetchWaterMark(o,t),it.fetchLimits(o,t)]).catch((()=>{throw new Error("[SuperViz] Failed to load configuration from server")}));if(!u)throw new Error("Failed to validate API key");let{participant:p,roomId:f,customColors:m}=e;Q.setConfig({apiUrl:o,apiKey:t,conferenceLayerUrl:l,environment:null!=(n=e.environment)?n:"prod",roomId:f,debug:e.debug,limits:d,waterMark:h,colors:m,features:c}),$M(m);let g=yield it.fetchParticipant(p.id).catch((()=>null));if(!g&&!p.name)throw new Error("[SuperViz] - Participant does not exist, create the user in the API or add the name in the initialization to initialize the SuperViz room.");return g||(yield it.createParticipant({participantId:p.id,name:p?.name,avatar:null==(i=p.avatar)?void 0:i.imageUrl,email:p?.email})),WM(ge(B({},e),{participant:{id:p.id,name:null!=(r=p.name)?r:g?.name,avatar:null!=(s=p.avatar)?s:g?.avatar,email:null!=(a=p.email)?a:g?.email}}))})),YM=ZM;function JM(t){if(typeof document<"u"){let e=document.createElement("style");e.id="superviz-style";let n=document.createTextNode(t);e.appendChild(n),document.head.appendChild(e)}}z(),typeof window<"u"&&typeof HTMLElement<"u"&&(import("./chunks/icon-DEXUGMFN-XB46R5AM.js"),import("./chunks/dropdown-PUI7CLAT-D7ULXLKK.js"),import("./chunks/tooltip-Z66PXWT6-Q2VB4OLF.js"),import("./chunks/modal-DTJ4P2SW-SB3O36DG.js"),import("./chunks/comments-ICRLFPDE-5CV2GX2O.js"),import("./chunks/topbar-JG6KALH4-5XIRGW46.js"),import("./chunks/content-C7IMV24R-V7IGEDQT.js"),import("./chunks/comment-item-G25K4WAN-2VBANUYL.js"),import("./chunks/comment-input-TWBS2WIL-7B2KKOTW.js"),import("./chunks/annotation-pin-EPBBK7B4-NPKTSIQJ.js"),import("./chunks/annotation-item-WEI4EQKA-A5DUUKJO.js"),import("./chunks/delete-comment-modal-JPUDT6WW-7S7GGXDQ.js"),import("./chunks/annotation-resolved-3FRZZFUJ-OR225SMA.js"),import("./chunks/annotation-filter-TMZTMURB-IAWMUU5O.js"),import("./chunks/float-button-5EP5PM2N-F4GVPLMC.js"),import("./chunks/mention-list-Q54NG7QO-DD2DEL3P.js"),import("./chunks/who-is-online-3SUEHTWU-UBL4TIG7.js"),import("./chunks/hello-world-CC6DNEKG-B5WAWXDQ.js")),z(),z();var KM='@import"https://unpkg.com/@superviz/sv-icons@0.8.13/css/style.css";@import"https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap";:root{--sv-primary: 98, 16, 204}html,body{width:100%;height:100%;overflow:hidden}#sv-video-wrapper iframe{position:fixed;border:none;margin:0;padding:0;overflow:hidden;z-index:1000}#sv-video-wrapper iframe.sv-video-frame--right{top:var(--superviz-offset-top);right:var(--superviz-offset-right)}#sv-video-wrapper iframe.sv-video-frame--left{top:var(--superviz-offset-top);left:var(--superviz-offset-left)}#sv-video-wrapper iframe.sv-video-frame--bottom{bottom:var(--superviz-offset-bottom);right:var(--superviz-offset-right);width:100%}#sv-video-wrapper iframe.sv-video-frame--top{top:var(--superviz-offset-top);right:var(--superviz-offset-right);width:100%}#sv-video-wrapper iframe.sv-video-frame--no-overlay{display:none}.pointer-mouse{display:flex;height:15px;width:16px;background-image:url(https://production.cdn.superviz.com/static/pointers/0.svg);background-repeat:no-repeat}.mouse-user-name{display:block;position:absolute;border-radius:30px;padding:2px 8px;font-weight:700;font-size:14px;font-family:Roboto,sans-serif;line-height:22px;margin-left:10px;margin-top:-6px;background:#ff0;white-space:nowrap}.mouse-follower{position:absolute;display:block;z-index:2}\n';JM(KM),z(),z(),z();var ui=class extends Ll{constructor(){super(...arguments),this.isAttached=!1,this.unsubscribeFrom=[],this.useStore=Pt.bind(this),this.attach=t=>{var e;if(this.useStore=t.useStore.bind(this),Object.values(t).includes(null)||Object.values(t).includes(void 0)){let t=`${this.name} @ attach - params are required`;throw this.logger.log(t),new Error(t)}let{config:n,eventBus:i,ioc:r}=t,{hasJoinedRoom:s}=this.useStore("global-store");if(Q.setConfig(n),this.eventBus=i,this.isAttached=!0,this.ioc=r,this.connectionLimit=null!=(e=t.connectionLimit)?e:50,this.room=r.createRoom(this.name,this.connectionLimit),!s.value)return this.logger.log(`${this.name} @ attach - not joined yet`),void setTimeout((()=>{this.logger.log(`${this.name} @ attach - retrying`),this.attach(t)}),1e3);this.logger.log(`${this.name} @ attached`),this.start(),this.publish("mount")},this.detach=()=>{this.isAttached?(this.logger.log("detached"),this.publish("unmount"),this.destroy(),this.room.disconnect(),this.room=void 0,this.unsubscribeFrom.forEach((t=>t(this))),Object.values(this.observers).forEach((t=>{t.reset(),t.destroy()})),this.observers={},this.isAttached=!1):this.logger.log(`${this.name} @ detach - component is not attached`)}}},jM=class extends ui{constructor(t,e){var n,i,r;super(),this.sidebarOpen=!1,this.layoutOptions={},this.openThreads=()=>{var t;this.sidebarOpen||(null==(t=this.element)||t.setAttribute("open",""),this.sidebarOpen=!0,document.body.dispatchEvent(new CustomEvent("toggle-annotation-sidebar",{detail:{open:this.sidebarOpen},composed:!0,bubbles:!0})))},this.closeThreads=()=>{var t;this.sidebarOpen&&(null==(t=this.element)||t.removeAttribute("open"),this.sidebarOpen=!1,document.body.dispatchEvent(new CustomEvent("toggle-annotation-sidebar",{detail:{open:this.sidebarOpen},composed:!0,bubbles:!0})))},this.togglePinActive=()=>{this.pinActive?this.disable():this.enable()},this.onPinFixed=t=>{this.coordinates=t},this.toggleAnnotationSidebar=()=>{this.element.toggleAttribute("open"),this.sidebarOpen=this.element.hasAttribute("open"),document.body.dispatchEvent(new CustomEvent("prepare-to-create-annotation",{detail:void 0,composed:!0,bubbles:!0})),document.body.dispatchEvent(new CustomEvent("toggle-annotation-sidebar",{detail:{open:this.sidebarOpen},composed:!0,bubbles:!0}))},this.onSelectAnnotation=t=>{this.sidebarOpen||this.toggleAnnotationSidebar()},this.positionFloatingButton=()=>{var t,e;this.button=document.createElement("superviz-comments-button");let n=null==(t=this.layoutOptions)?void 0:t.buttonLocation,i=null==(e=this.layoutOptions)?void 0:e.position;if(!n)return document.body.appendChild(this.button),void(this.button.commentsPosition=i);let r="",s=!1,a=!Object.values(ud).includes(n.toLocaleLowerCase());if(a){let t=window.document.body.querySelector(`#${n}`);t?(t.appendChild(this.button),r="position: relative"):(s=!0,n="top-left")}if(!a||s){document.body.appendChild(this.button);let[t,e]=n.split("-");r=`${t}: 20px; ${e}: 20px;`}this.button.positionStyles=r,this.button.commentsPosition=i},this.positionComments=()=>{var t;this.element=document.createElement("superviz-comments"),this.element.setAttribute("comments",JSON.stringify([])),this.element.side="left",this.element.offset=this.offset,document.body.appendChild(this.element);let e=null==(t=this.layoutOptions)?void 0:t.position;if(!e)return;let n=e.toUpperCase();tl[n]&&(this.element.side=tl[n])},this.createAnnotation=t=>ce(this,[t],(function*({detail:t}){try{let{text:e,mentions:n}=t,i=B({},this.coordinates),r=yield it.createAnnotations(Q.get("apiUrl"),Q.get("apiKey"),{roomId:Q.get("roomId"),position:JSON.stringify(i),userId:this.localParticipantId}),s=yield this.createComment(r.uuid,e,n);this.addAnnotation(ge(B({},r),{comments:[s]})),this.pinAdapter.removeAnnotationPin("temporary-pin"),document.body.dispatchEvent(new CustomEvent("select-annotation",{detail:{uuid:r.uuid,haltGoToPin:!0,newPin:!0},composed:!0,bubbles:!0}))}catch(t){this.logger.log("error when creating annotation",t)}})),this.deleteAnnotation=t=>ce(this,[t],(function*({detail:t}){try{let{uuid:e}=t;yield it.deleteAnnotation(Q.get("apiUrl"),Q.get("apiKey"),e);let n=this.annotations.filter((t=>t.uuid!==e));this.updateAnnotationList(n),this.pinAdapter.removeAnnotationPin(e),this.element.updateAnnotations(this.annotations)}catch(t){this.logger.log("error when deleting annotation",t)}})),this.updateComment=t=>ce(this,[t],(function*({detail:t}){try{let{uuid:e,text:n,mentions:i}=t,r=yield it.updateComment(Q.get("apiUrl"),Q.get("apiKey"),e,n);yield it.createMentions({commentsId:r.uuid,participants:i.map((t=>({id:t.userId})))});let s=this.annotations.map((t=>Object.assign({},t,{comments:t.comments.map((t=>t.uuid===e?Object.assign({},t,{text:n,mentions:i}):t))})));this.updateAnnotationList(s)}catch(t){this.logger.log("error when updating comment",t)}})),this.resolveAnnotation=t=>ce(this,[t],(function*({detail:t}){try{let{uuid:e}=t,{resolved:n}=yield it.resolveAnnotation(Q.get("apiUrl"),Q.get("apiKey"),e),i=this.annotations.map((t=>t.uuid===e?Object.assign({},t,{resolved:n}):t));if(this.updateAnnotationList(i),n)return void this.pinAdapter.removeAnnotationPin(e);this.pinAdapter.updateAnnotations(this.annotations)}catch(t){this.logger.log("error when resolve annotation",t)}})),this.deleteComment=t=>ce(this,[t],(function*({detail:t}){try{let{uuid:e,annotationId:n}=t;if(!e||!n)return;yield it.deleteComment(Q.get("apiUrl"),Q.get("apiKey"),e);let i=this.annotations.find((t=>t.uuid===n));i.comments=i.comments.filter((t=>t.uuid!==e));let r=this.annotations.map((t=>t.uuid===n?i:t));this.element.updateAnnotations(r),this.updateAnnotationList(r)}catch(t){this.logger.log("error when deleting comment",t)}})),this.onAnnotationListUpdate=t=>{let{data:e,clientId:n}=t;this.localParticipantId!==n&&(this.annotations=e,this.element.updateAnnotations(this.annotations),this.pinAdapter.updateAnnotations(this.annotations))},this.name="comments",this.logger=new st("@superviz/sdk/comments-component"),this.annotations=[],this.layoutOptions={buttonLocation:null!=(n=e?.buttonLocation)?n:"top-left",position:null!=(i=e?.position)?i:"left"},this.hideDefaultButton=null!=(r=e?.hideDefaultButton)&&r,this.setStyles(e?.styles),this.offset=e?.offset,setTimeout((()=>{var e,n;t.setCommentsMetadata(null!=(n=null==(e=this.layoutOptions)?void 0:e.position)?n:"left")})),this.pinAdapter=t}enable(){this.pinAdapter.setActive(!0),this.pinActive=!0,this.publish("pin-mode.active"),document.body.dispatchEvent(new CustomEvent("toggle-pin-active",{detail:{isActive:!0}}))}disable(){this.pinAdapter.setActive(!1),this.pinActive=!1,this.publish("pin-mode.inactive"),document.body.dispatchEvent(new CustomEvent("toggle-pin-active",{detail:{isActive:!1}}))}start(){if(typeof window>"u")return;let{group:t,localParticipant:e}=this.useStore("global-store");t.subscribe(),e.subscribe((t=>{this.localParticipantId=t.id})),this.clientUrl=window.location.href,this.positionComments(),this.hideDefaultButton||this.positionFloatingButton(),this.fetchAnnotations(),this.waterMarkState(),this.participantsList(),this.addListeners(),this.pinAdapter.setPinsVisibility(!0)}destroy(){var t;this.logger.log("comments component @ destroy"),this.destroyListeners(),null==(t=this.button)||t.remove(),this.element.remove(),this.element=void 0,this.pinAdapter.destroy()}addListeners(){var t;null==(t=this.button)||t.addEventListener("toggle",this.togglePinActive),this.element.addEventListener("close-threads",this.closeThreads),document.body.addEventListener("create-annotation",this.createAnnotation),this.element.addEventListener("resolve-annotation",this.resolveAnnotation),this.element.addEventListener("delete-annotation",this.deleteAnnotation),this.element.addEventListener("create-comment",(({detail:t})=>{this.createComment(t.uuid,t.text,t.mentions,!0)})),this.element.addEventListener("update-comment",this.updateComment),this.element.addEventListener("delete-comment",this.deleteComment),document.body.addEventListener("select-annotation",this.onSelectAnnotation),this.room.on("update-comments",this.onAnnotationListUpdate),this.pinAdapter.onPinFixedObserver.subscribe(this.onPinFixed)}destroyListeners(){var t;null==(t=this.button)||t.removeEventListener("toggle",this.togglePinActive),this.element.removeEventListener("close-threads",this.closeThreads),this.element.removeEventListener("resolve-annotation",this.resolveAnnotation),this.element.removeEventListener("create-comment",(({detail:t})=>{this.createComment(t.uuid,t.text,t.mentions,!0)})),this.element.removeEventListener("update-comment",this.updateComment),this.element.removeEventListener("delete-comment",this.deleteComment),document.body.removeEventListener("select-annotation",this.onSelectAnnotation),document.body.removeEventListener("create-annotation",this.createAnnotation),this.room.off("update-comments",this.onAnnotationListUpdate),this.pinAdapter.onPinFixedObserver.unsubscribe(this.onPinFixed)}setStyles(t=""){if(!t)return;let e=document.createElement("style");e.textContent=t,e.id="superviz-comments-styles",document.head.appendChild(e)}createComment(t,e){return ce(this,arguments,(function*(t,e,n=[],i=!1){try{let r=yield it.createComment(Q.get("apiUrl"),Q.get("apiKey"),{annotationId:t,userId:this.localParticipantId,text:e});return yield it.createMentions({commentsId:r.uuid,participants:n.map((t=>({id:t.userId,readed:0})))}),r.mentions=n,i&&this.addComment(t,r),r}catch(t){this.logger.log("error when creating comment",t)}}))}addAnnotation(t){let e=[t,...this.annotations];this.element.updateAnnotations(e),this.pinAdapter.updateAnnotations(e),this.updateAnnotationList(e)}updateAnnotationList(t){this.annotations=t,this.room.emit("update-comments",t)}addComment(t,e){let n=this.annotations.find((e=>e.uuid===t));n.comments.push(e);let i=this.annotations.map((e=>e.uuid===t?n:e));this.updateAnnotationList(i),this.element.updateAnnotations(i)}fetchAnnotations(){return ce(this,null,(function*(){try{let t=yield it.fetchAnnotation(Q.get("apiUrl"),Q.get("apiKey"),{roomId:Q.get("roomId")});this.annotations=t,this.element.updateAnnotations(this.annotations),this.pinAdapter.updateAnnotations(this.annotations)}catch(t){this.logger.log("error when fetching annotations",t)}}))}waterMarkState(){return ce(this,null,(function*(){try{let t=yield it.fetchWaterMark(Q.get("apiUrl"),Q.get("apiKey"));this.element.waterMarkStatus(t)}catch(t){this.logger.log("error when fetching waterMark",t)}}))}participantsList(){return ce(this,null,(function*(){try{let t=(yield it.fetchParticipantsByGroup(this.group.id)).data;this.pinAdapter.participantsList=t,this.element.participantsList=t}catch(t){this.logger.log("error when fetching participantsList",t)}}))}};z();var QM=class{constructor(t,e){if(this.isPinsVisible=!0,this.selectedPin=null,this.temporaryPinCoordinates=null,this.commentsSide="left",this.setCommentsMetadata=t=>{this.commentsSide=t},this.resetPins=t=>{t&&"Escape"!==t?.key||(this.resetSelectedPin(),this.removeAnnotationPin("temporary-pin"),this.temporaryPinCoordinates=null)},this.animate=()=>{(this.isActive||this.isPinsVisible)&&(this.renderAnnotationsPins(),this.divWrapper=this.renderDivWrapper()),this.temporaryPinCoordinates&&this.renderTemporaryPin(),this.animateFrame=requestAnimationFrame(this.animate)},this.setMouseDownCoordinates=({x:t,y:e})=>{this.mouseDownCoordinates={x:t,y:e}},this.annotationSelected=({detail:{uuid:t,haltGoToPin:e,newPin:n}})=>{var i,r;if(!t)return;n&&this.pins.get(t).setAttribute("newPin","");let s=JSON.parse(null!=(r=null==(i=this.selectedPin)?void 0:i.getAttribute("annotation"))?r:"{}");if(this.resetPins(),s?.uuid===t)return;document.body.dispatchEvent(new CustomEvent("close-temporary-annotation"));let a=this.pins.get(t);a&&(a.setAttribute("active",""),this.selectedPin=a,!e&&this.goToPin(t))},this.onClick=t=>{if(!this.isActive)return;let e=this.canvas.getBoundingClientRect(),{x:n,y:i}=this.mouseDownCoordinates,r=n-e.x,s=i-e.y,a=t.clientX-e.left,o=t.clientY-e.top;if(Math.hypot(a-r,o-s)>10)return;let l=this.canvas.getContext("2d").getTransform().inverse(),c=new DOMPoint(a,o-31).matrixTransform(l);this.onPinFixedObserver.publish({x:c.x,y:c.y,type:"canvas"}),this.resetSelectedPin(),this.temporaryPinCoordinates={x:c.x,y:c.y},this.renderTemporaryPin();let u=document.getElementById("superviz-temporary-pin");this.movedTemporaryPin=!this.movedTemporaryPin,u.setAttribute("movedPosition",String(this.movedTemporaryPin)),!this.selectedPin&&document.body.dispatchEvent(new CustomEvent("unselect-annotation"))},this.onToggleAnnotationSidebar=({detail:t})=>{let{open:e}=t;e||(this.pins.forEach((t=>{t.removeAttribute("active")})),this.pins.has("temporary-pin")&&this.removeAnnotationPin("temporary-pin"))},this.hideTemporaryPin=t=>{var e;let n=t.target,i=n.contains(this.canvas),{x:r,y:s}=t,{left:a,top:o,right:l,bottom:c}=this.canvas.getBoundingClientRect(),u=r>a&&r<l&&s>o&&s<c;this.canvas.contains(n)||null!=(e=this.pins.get("temporary-pin"))&&e.contains(n)||i&&u||(this.removeAnnotationPin("temporary-pin"),this.temporaryPinCoordinates=null)},this.logger=new st("@superviz/sdk/comments-component/canvas-pin-adapter"),this.canvas=document.getElementById(t),this.isActive=!1,this.pins=new Map,this.goToPinCallback=e?.onGoToPin,!this.canvas){let e=`Canvas with id ${t} not found`;throw this.logger.log(e),new Error(e)}this.canvasSides=this.canvas.getBoundingClientRect(),document.body.style.position="relative",this.onPinFixedObserver=new Xe({logger:this.logger}),this.divWrapper=this.renderDivWrapper(),this.annotations=[],this.renderAnnotationsPins(),this.animateFrame=requestAnimationFrame(this.animate),document.body.addEventListener("select-annotation",this.annotationSelected),document.body.addEventListener("keyup",this.resetPins)}destroy(){this.isActive=!1,this.removeListeners(),this.removeAnnotationsPins(),this.pins=new Map,this.divWrapper.remove(),this.divWrapper=null,this.onPinFixedObserver.destroy(),this.onPinFixedObserver=null,this.canvas.style.cursor="default",this.annotations=[],cancelAnimationFrame(this.animateFrame),document.body.removeEventListener("select-annotation",this.annotationSelected),document.body.removeEventListener("keyup",this.resetPins)}setPinsVisibility(t){this.isPinsVisible=t,this.isPinsVisible?this.renderAnnotationsPins():this.removeAnnotationsPins()}setActive(t){if(this.isActive!==t){if(this.isActive=t,this.isActive)return this.originalCanvasCursor=this.canvas.style.cursor,this.canvas.style.cursor='url("https://production.cdn.superviz.com/static/pin-html.png") 0 100, pointer',void this.addListeners();this.resetPins(),this.removeListeners(),this.canvas.style.cursor=this.originalCanvasCursor}}updateAnnotations(t){this.logger.log("updateAnnotations",t),this.annotations=t,(this.isActive||this.isPinsVisible)&&(this.removeAnnotationsPins(),this.renderAnnotationsPins())}removeAnnotationPin(t){let e=this.pins.get(t);e&&(e.remove(),this.pins.delete(t),"temporary-pin"!==t&&(this.annotations=this.annotations.filter((e=>e.uuid!==t))))}renderTemporaryPin(){let t=document.getElementById("superviz-temporary-pin");t||(t=document.createElement("superviz-comments-annotation-pin"),t.id="superviz-temporary-pin",t.setAttribute("type","add"),t.setAttribute("showInput",""),t.setAttribute("containerSides",JSON.stringify(this.canvasSides)),t.setAttribute("commentsSide",this.commentsSide),t.setAttribute("position",JSON.stringify(this.temporaryPinCoordinates)),t.setAttribute("annotation",JSON.stringify({})),t.setAttribute("participantsList",JSON.stringify(this.participants)),t.setAttributeNode(document.createAttribute("active")),this.divWrapper.appendChild(t));let{x:e,y:n}=this.temporaryPinCoordinates,i=this.canvas.getContext("2d").getTransform(),r=i.e,s=i.f,a=e*i.a+r,o=n*i.d+s;t.setAttribute("position",JSON.stringify({x:a,y:o})),this.pins.set("temporary-pin",t)}addListeners(){this.canvas.addEventListener("click",this.onClick),this.canvas.addEventListener("mousedown",this.setMouseDownCoordinates),document.body.addEventListener("toggle-annotation-sidebar",this.onToggleAnnotationSidebar),document.body.addEventListener("click",this.hideTemporaryPin)}removeListeners(){this.canvas.removeEventListener("click",this.onClick),this.canvas.removeEventListener("mousedown",this.setMouseDownCoordinates),document.body.removeEventListener("toggle-annotation-sidebar",this.onToggleAnnotationSidebar),document.body.addEventListener("click",this.hideTemporaryPin)}resetSelectedPin(){this.selectedPin&&(this.selectedPin.removeAttribute("active"),this.selectedPin=null)}renderDivWrapper(){let t=this.canvas.getBoundingClientRect(),e=this.divWrapper;return e||(e=document.createElement("div"),e.id="superviz-canvas-wrapper",["","static"].includes(this.canvas.parentElement.style.position)&&(this.canvas.parentElement.style.position="relative")),e.style.position="absolute",e.style.top=`${this.canvas.offsetTop}px`,e.style.left=`${this.canvas.offsetLeft}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,e.style.pointerEvents="none",e.style.overflow="hidden",document.getElementById("superviz-canvas-wrapper")||this.canvas.parentElement.appendChild(e),e}renderAnnotationsPins(){this.annotations.length&&"none"!==this.canvas.style.display||this.pins.get("temporary-pin")?this.annotations.forEach((t=>{if(t.resolved)return;let e=JSON.parse(t.position);if("canvas"!==e?.type)return;let{x:n,y:i}=e,r=this.canvas.getContext("2d").getTransform(),s=r.e,a=r.f,o=n*r.a+s,l=i*r.d+a;if(this.pins.has(t.uuid)){let e=this.pins.get(t.uuid);return this.divWrapper.clientWidth>o&&this.divWrapper.clientHeight>l?(e.setAttribute("style","opacity: 1"),void this.pins.get(t.uuid).setAttribute("position",JSON.stringify({x:o,y:l}))):void e.setAttribute("style","opacity: 0")}let c=document.createElement("superviz-comments-annotation-pin");c.setAttribute("type","show"),c.setAttribute("participantsList",JSON.stringify(this.participants)),c.setAttribute("annotation",JSON.stringify(t)),c.setAttribute("position",JSON.stringify({x:o,y:l})),c.id=t.uuid,this.divWrapper.appendChild(c),this.pins.set(t.uuid,c)})):this.removeAnnotationsPins()}removeAnnotationsPins(){this.pins.forEach((t=>{t.remove()})),this.pins.clear()}set participantsList(t){this.participants=t}goToPin(t){let e=this.annotations.find((e=>e.uuid===t));if(!e)return;let n=JSON.parse(e.position);if("canvas"!==n?.type)return;let i=this.canvas.getBoundingClientRect(),{width:r,height:s}=i,{x:a,y:o}=n,l=r/2-a,c=s/2-o;this.goToPinCallback&&this.goToPinCallback({x:l,y:c})}};z();var eE=Zt(Li()),tE=class{constructor(t,e={}){if(this.isPinsVisible=!0,this.selectedPin=null,this.dataAttribute="data-superviz-id",this.commentsSide="left",this.temporaryPinCoordinates={},this.elementsWithDataId={},this.divWrappers=new Map,this.voidElementsWrappers=new Map,this.VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","svg","rect","ellipse"],this.animate=()=>{this.voidElementsWrappers&&(this.updatePinsPositions(),this.animateFrame=requestAnimationFrame(this.animate))},this.setCommentsMetadata=t=>{this.commentsSide=t},this.hideTemporaryPin=t=>{var e;let n=t.target,i=this.divWrappers.get(this.temporaryPinCoordinates.elementId);if(!i)return;let r=i.contains(n),s=null==(e=this.pins.get("temporary-pin"))?void 0:e.contains(n);r||s||(this.removeAnnotationPin("temporary-pin"),this.temporaryPinCoordinates={})},this.resetPins=t=>{t&&"Escape"!==t?.key||(this.resetSelectedPin(),this.resetHoveredWrapper(),this.temporaryPinCoordinates.elementId&&(this.removeAnnotationPin("temporary-pin"),this.temporaryPinCoordinates={}))},this.annotationSelected=({detail:{uuid:t,newPin:e}})=>{if(!t)return;e&&this.pins.get(t).setAttribute("newPin","");let n=this.annotations.find((t=>{var e;return t.uuid===(null==(e=this.selectedPin)?void 0:e.id)}));if(this.resetPins(),n?.uuid===t)return;document.body.dispatchEvent(new CustomEvent("close-temporary-annotation"));let i=this.pins.get(t);if(!i)return;i.setAttribute("active",""),this.selectedPin=i;let r=this.annotations.find((e=>e.uuid===t));this.selectedPin.setAttribute("elementId",JSON.parse(r.position).elementId)},this.onClick=t=>{if(!this.isActive||t.target===this.pins.get("temporary-pin"))return;let e=t.target,n=t.currentTarget;if(e!==n&&this.pins.has(e.id))return;let i=n.getAttribute("data-wrapper-id"),r=n.getBoundingClientRect(),{x:s,y:a}=this.mouseDownCoordinates,o=t.clientX-r.left,l=t.clientY-r.top,c=s-r.x,u=a-r.y;if(Math.hypot(o-c,l-u)>10)return;let{width:h,height:d}=n.getBoundingClientRect();o=100*o/h,l=100*(l-32*(n.getBoundingClientRect().width/n.offsetWidth||1))/d,this.onPinFixedObserver.publish({x:o,y:l,type:"html",elementId:i}),this.resetSelectedPin(),this.temporaryPinCoordinates=ge(B({},this.temporaryPinCoordinates),{x:o,y:l}),this.renderTemporaryPin(i);let p=this.pins.get("temporary-pin");this.movedTemporaryPin=!this.movedTemporaryPin,p.setAttribute("movedPosition",String(this.movedTemporaryPin)),document.body.dispatchEvent(new CustomEvent("unselect-annotation"))},this.onMouseDown=({x:t,y:e})=>{this.mouseDownCoordinates={x:t,y:e}},this.handleMutationObserverChanges=t=>{t.forEach((t=>{var e;let{target:n,oldValue:i}=t,r=n.getAttribute(this.dataAttribute);if(!r&&!i||r===i)return;let s=this.dataAttributeValueFilters.some((t=>i.match(t)));if(!r&&i&&!s)return this.removeAnnotationPin("temporary-pin"),this.clearElement(i),void((null==(e=this.selectedPin)?void 0:e.getAttribute("elementId"))===i&&(document.body.dispatchEvent(new CustomEvent("unselect-annotation")),this.selectedPin=null));let a=this.dataAttributeValueFilters.some((t=>r.match(t)));(i&&this.elementsWithDataId[i]||a)&&this.clearElement(i),!a&&(this.setElementReadyToPin(n,r),this.renderAnnotationsPins())}))},this.onToggleAnnotationSidebar=({detail:t})=>{let{open:e}=t;e||(this.resetSelectedPin(),this.pins.has("temporary-pin")&&(this.removeAnnotationPin("temporary-pin"),this.temporaryPinCoordinates.elementId=void 0))},this.onMouseEnter=t=>{var e;let n=t.target;if(this.hoveredWrapper=n,null==(e=n.getAttribute("data-wrapper-type"))||!e.includes("ellipse"))return void this.hoveredWrapper.style.setProperty("outline","1px solid rgb(var(--sv-primary))");let i=n.querySelector("ellipse");i.setAttribute("stroke","rgb(var(--sv-primary))"),i.setAttribute("stroke-width","1")},this.onMouseLeave=t=>{var e;let n=t.target;if(this.hoveredWrapper=n,null==(e=n.getAttribute("data-wrapper-type"))||!e.includes("ellipse"))return void this.hoveredWrapper.style.setProperty("outline","");let i=n.querySelector("ellipse");i.removeAttribute("stroke"),i.removeAttribute("stroke-width")},this.logger=new st("@superviz/sdk/comments-component/container-pin-adapter"),this.container=document.getElementById(t),!this.container){let e=`Element with id ${t} not found`;throw this.logger.log(e),new Error(e)}if("object"!=typeof e)throw new Error("Second argument of the HTMLPin constructor must be an object");let{dataAttributeName:n,dataAttributeValueFilters:i}=e;if(""===n)throw new Error("dataAttributeName must be a non-empty string");if(null===n)throw new Error("dataAttributeName cannot be null");if(void 0!==n&&"string"!=typeof n)throw new Error("dataAttributeName must be a non-empty string");this.dataAttribute=n||this.dataAttribute,this.dataAttributeValueFilters=i||[],this.isActive=!1,this.prepareElements(),this.mutationObserver=new MutationObserver(this.handleMutationObserverChanges),this.observeContainer(),this.pins=new Map,this.onPinFixedObserver=new Xe({logger:this.logger}),this.annotations=[],document.body.addEventListener("select-annotation",this.annotationSelected),document.body.addEventListener("keyup",this.resetPins),this.voidElementsWrappers.size&&(this.animateFrame=requestAnimationFrame(this.animate))}destroy(){var t;this.logger.log("Destroying HTML Pin Adapter for Comments"),this.removeListeners(),this.removeObservers(),this.divWrappers.forEach((t=>t.remove())),this.divWrappers.clear(),this.pins.forEach((t=>t.remove())),this.pins.clear(),this.divWrappers=void 0,this.pins=void 0,this.elementsWithDataId=void 0,this.logger=void 0,this.onPinFixedObserver.destroy(),this.onPinFixedObserver=void 0,this.container=void 0,this.voidElementsWrappers.clear(),this.voidElementsWrappers=void 0,this.annotations=[],null==(t=this.svgWrappers)||t.remove(),this.svgWrappers=void 0,document.body.removeEventListener("select-annotation",this.annotationSelected),document.body.removeEventListener("toggle-annotation-sidebar",this.onToggleAnnotationSidebar),cancelAnimationFrame(this.animateFrame)}addElementListeners(t){this.divWrappers.get(t).addEventListener("click",this.onClick,!0),this.divWrappers.get(t).addEventListener("mousedown",this.onMouseDown),this.divWrappers.get(t).addEventListener("mouseenter",this.onMouseEnter),this.divWrappers.get(t).addEventListener("mouseleave",this.onMouseLeave)}removeElementListeners(t){this.divWrappers.get(t).removeEventListener("click",this.onClick,!0),this.divWrappers.get(t).removeEventListener("mousedown",this.onMouseDown),this.divWrappers.get(t).removeEventListener("mouseenter",this.onMouseEnter),this.divWrappers.get(t).removeEventListener("mouseleave",this.onMouseLeave)}set participantsList(t){this.participants=t}removeObservers(){this.mutationObserver.disconnect(),this.mutationObserver=void 0}addListeners(){this.divWrappers.forEach(((t,e)=>this.addElementListeners(e))),document.body.addEventListener("toggle-annotation-sidebar",this.onToggleAnnotationSidebar),document.body.addEventListener("click",this.hideTemporaryPin)}removeListeners(){this.divWrappers.forEach(((t,e)=>this.removeElementListeners(e))),document.body.removeEventListener("keyup",this.resetPins),document.body.removeEventListener("click",this.hideTemporaryPin)}observeContainer(){this.mutationObserver.observe(this.container,{subtree:!0,attributes:!0,attributeFilter:[this.dataAttribute],attributeOldValue:!0})}prepareElements(){this.container.querySelectorAll(`[${this.dataAttribute}]`).forEach((t=>{let e=t.getAttribute(this.dataAttribute);this.dataAttributeValueFilters.some((t=>e.match(t)))||this.setElementReadyToPin(t,e)}))}addAllCursors(){this.divWrappers.forEach(((t,e)=>{this.addCursor(t,e)}))}removeAddCursor(){this.divWrappers.forEach(((t,e)=>{let n=t,i=t.getAttribute("data-wrapper-type");if(i){let t=i.split("-")[1];n=this.divWrappers.get(e).querySelector(t)}n.style.setProperty("cursor","default"),n.style.setProperty("pointer-events","none")}))}setPinsVisibility(t){this.isPinsVisible=t,this.isPinsVisible&&this.renderAnnotationsPins(),this.removeAnnotationsPins()}removeAnnotationPin(t){let e=this.pins.get(t);!e&&"temporary-pin"===t||(e&&(e.remove(),this.pins.delete(t)),"temporary-pin"!==t&&(this.annotations=this.annotations.filter((e=>e.uuid!==t))))}updateAnnotations(t){this.logger.log("updateAnnotations",t),this.annotations=t,this.isPinsVisible&&(this.removeAnnotationsPins(),this.renderAnnotationsPins())}setActive(t){if(this.isActive!==t){if(this.isActive=t,this.isActive)return this.addListeners(),this.addAllCursors(),void this.prepareElements();this.resetPins(),this.removeListeners(),this.removeAddCursor()}}renderTemporaryPin(t){var e,n;(e=this.temporaryPinCoordinates).elementId||(e.elementId=t);let i=this.pins.get("temporary-pin");if(t&&t!==this.temporaryPinCoordinates.elementId&&(this.pins.get("temporary-pin").remove(),this.pins.delete("temporary-pin"),this.temporaryPinCoordinates.elementId=t,i=null),!i){let e=null==(n=this.elementsWithDataId[t])?void 0:n.getBoundingClientRect();i=document.createElement("superviz-comments-annotation-pin"),i.id="superviz-temporary-pin",i.setAttribute("type","add"),i.setAttribute("showInput",""),i.setAttribute("containerSides",JSON.stringify(e)),i.setAttribute("commentsSide",this.commentsSide),i.setAttribute("position",JSON.stringify(this.temporaryPinCoordinates)),i.setAttribute("annotation",JSON.stringify({})),i.setAttribute("participantsList",JSON.stringify(this.participants)),i.setAttribute("keepPositionRatio",""),i.setAttributeNode(document.createAttribute("active")),this.addTemporaryPinToElement(t,i)}let{x:r,y:s}=this.temporaryPinCoordinates;i.setAttribute("position",JSON.stringify({x:r,y:s})),this.pins.set("temporary-pin",i)}renderAnnotationsPins(){this.annotations.length?this.annotations.forEach((t=>{if(t.resolved)return;let{x:e,y:n,elementId:i,type:r}=JSON.parse(t.position);if("html"!==r||this.pins.has(t.uuid)||!this.elementsWithDataId[i])return;let s=this.divWrappers.get(i);if(!s)return;let a=this.createPin(t,e,n);s.appendChild(a),this.pins.set(t.uuid,a)})):this.removeAnnotationsPins()}updatePinsPositions(){this.voidElementsWrappers.forEach(((t,e)=>{let n=JSON.stringify(t.getBoundingClientRect()),i=this.elementsWithDataId[e].getBoundingClientRect();"ellipse"===this.elementsWithDataId[e].tagName.toLowerCase()&&(i=this.elementsWithDataId[e].viewportElement.getBoundingClientRect()),!(0,eE.isEqual)(JSON.stringify(i),n)&&(t.style.setProperty("top",`${i.top}px`),t.style.setProperty("left",`${i.left}px`),t.style.setProperty("width",`${i.width}px`),t.style.setProperty("height",`${i.height}px`))}))}clearElement(t){if(!this.elementsWithDataId[t])return;let e=this.divWrappers.get(t);if(e){let t=e.children,{length:n}=t;for(let e=0;e<n;++e){let n=t.item(e);this.pins.delete(n.id)}e.remove()}this.voidElementsWrappers.delete(t),this.removeElementListeners(t),this.divWrappers.delete(t),this.elementsWithDataId[t]=void 0,this.voidElementsWrappers.size||(cancelAnimationFrame(this.animateFrame),this.animateFrame=void 0)}resetSelectedPin(){this.selectedPin&&(this.selectedPin.removeAttribute("active"),this.selectedPin=null)}resetHoveredWrapper(){this.hoveredWrapper&&this.onMouseLeave({target:this.hoveredWrapper})}removeAnnotationsPins(){this.pins.forEach((t=>{t.remove()})),this.pins.clear()}setElementReadyToPin(t,e){if(!this.elementsWithDataId[e]){if(this.elementsWithDataId[e]=t,!this.divWrappers.get(e)){let n=this.createWrapper(t,e);this.divWrappers.set(e,n)}!this.isActive||!this.isPinsVisible||(this.addCursor(this.divWrappers.get(e),e),this.addElementListeners(e))}}handleSvgElement(t,e){let n=t.viewportElement;if(void 0===n)return;if("svg"===t.tagName.toLowerCase()){let n=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");return n.setAttribute("height","100%"),n.setAttribute("width","100%"),n.style.setProperty("overflow","visible"),n.appendChild(e),t.appendChild(n),t.style.setProperty("overflow","visible"),e}let i=t.tagName.toLowerCase(),r="ellipse"===i,s="rect"===i;if(!r&&!s)return;let a,o,l,c,u,h,d=document.createElementNS("http://www.w3.org/2000/svg","svg"),p=document.createElementNS("http://www.w3.org/2000/svg",i);if(s){let e=t;a=e.getAttribute("x"),o=e.getAttribute("y"),l=e.getAttribute("width"),c=e.getAttribute("height"),u=e.getAttribute("rx"),h=e.getAttribute("ry"),p.setAttribute("fill","transparent"),p.setAttribute("stroke","transparent"),p.setAttribute("x","0"),p.setAttribute("y","0"),p.setAttribute("rx",u),p.setAttribute("ry",h)}if(r){let e=t.getAttribute("cx"),i=t.getAttribute("cy");u=t.getAttribute("rx"),h=t.getAttribute("ry"),a=Number(e)-Number(u),o=Number(i)-Number(h);let{width:r,height:s}=n.getBoundingClientRect();l=`${r}px`,c=`${s}px`,p.setAttribute("fill","transparent"),p.setAttribute("stroke","transparent"),p.setAttribute("cx",e),p.setAttribute("cy",i),p.setAttribute("rx",u),p.setAttribute("ry",h)}return p.setAttribute("height",c),p.setAttribute("width",l),d.setAttribute("height",c),d.setAttribute("width",l),d.appendChild(p),e.appendChild(d),t.style.setProperty("overflow","visible"),e.setAttribute("data-wrapper-type",`svg-${i}`),e}addTemporaryPinToElement(t,e){if(!this.elementsWithDataId[t])return;let n=this.divWrappers.get(t);n&&n.appendChild(e)}createPin(t,e,n){let i=document.createElement("superviz-comments-annotation-pin");return i.setAttribute("type","show"),i.setAttribute("annotation",JSON.stringify(t)),i.setAttribute("position",JSON.stringify({x:e,y:n})),i.setAttribute("keepPositionRatio",""),i.setAttribute("participantsList",JSON.stringify(this.participants)),i.id=t.uuid,i}addCursor(t,e){let n=t,i=t.getAttribute("data-wrapper-type");if(i){let t=i.split("-")[1];n=this.divWrappers.get(e).querySelector(t)}n.style.setProperty("cursor",'url("https://production.cdn.superviz.com/static/pin-html.png") 0 100, pointer'),n.style.setProperty("pointer-events","auto")}createWrapper(t,e){var n;let i=`superviz-id-${e}`;if(this.divWrappers.get(e))return;let r=t.getBoundingClientRect(),s=document.createElement("div");s.setAttribute("data-wrapper-id",e),s.id=i,s.style.position="absolute",s.style.pointerEvents="none",s.style.transform="translateX(0) translateY(0) scale(1)",s.style.cursor="default",s.style.top="0",s.style.left="0",s.style.width="100%",s.style.height="100%",s.style.pointerEvents="none";let a=window.getComputedStyle(t).getPropertyValue("border-radius");if(s.style.borderRadius=a,!this.VOID_ELEMENTS.includes(this.elementsWithDataId[e].tagName.toLowerCase()))return this.elementsWithDataId[e].appendChild(s),this.setPositionNotStatic(this.elementsWithDataId[e]),s;s=null!=(n=this.handleSvgElement(t,s))?n:s,s.style.position="fixed",s.style.top=`${r.top}px`,s.style.left=`${r.left}px`,s.style.width=`${r.width}px`,s.style.height=`${r.height}px`;let o=this.elementsWithDataId[e].parentElement;return(!o||t.viewportElement)&&(o=document.body),this.setPositionNotStatic(o),o.appendChild(s),this.voidElementsWrappers.set(e,s),this.animateFrame||(this.animateFrame=requestAnimationFrame(this.animate)),s}setPositionNotStatic(t){let{position:e}=window.getComputedStyle(t);"static"===e&&t.style.setProperty("position","relative")}};z(),z();var En=Zt(lw()),nE=class{constructor(){this.browser=En.default.getParser(navigator.userAgent)}get clientStats(){return this.browser.getResult()}get isFirefox(){return this.browser.isBrowser(En.default.BROWSER_MAP.firefox)}get isSafari(){return this.browser.isBrowser(En.default.BROWSER_MAP.safari)}get isChrome(){return this.browser.isBrowser(En.default.BROWSER_MAP.chrome)}get isIE(){return this.browser.isBrowser(En.default.BROWSER_MAP.ie)}get isEdge(){return this.browser.isBrowser(En.default.BROWSER_MAP.edge)}get isMobileDevice(){return(this.browser.is(En.default.PLATFORMS_MAP.mobile)||this.browser.is(En.default.PLATFORMS_MAP.tablet))&&!navigator.userAgent.match(/iPad/i)}get isTabletDevice(){return this.browser.is(En.default.PLATFORMS_MAP.tablet)}get isAndroid(){return this.isMobileDevice&&!!navigator.userAgent.match(/Android/i)}get isIpad(){return!!navigator.userAgent.match(/iPad/i)}get isIphone(){return this.isMobileDevice&&!!navigator.userAgent.match(/iPhone/i)}get isAppleMobileDevice(){return this.isIpad||this.isIphone}};z();var iE=class{constructor(){this.updateMeetingConnectionStatus=t=>{this.oldConnectionStatus=this.connectionStatus,this.connectionStatus=t,this.connectionStatusObserver.publish(t),this.logger.log("CONNECTION STATUS CHANGE",t)},this.onUpdateBrowserOnlineStatus=t=>{let{type:e}=t;"online"!==e?this.updateMeetingConnectionStatus(4):this.updateMeetingConnectionStatus(1)},this.logger=new st("@superviz/sdk/connection-service"),this.connectionStatus=0,this.connectionStatusObserver=new Xe({logger:this.logger})}addListeners(){typeof window<"u"&&(window.addEventListener("online",this.onUpdateBrowserOnlineStatus),window.addEventListener("offline",this.onUpdateBrowserOnlineStatus))}removeListeners(){typeof window<"u"&&(window.removeEventListener("online",this.onUpdateBrowserOnlineStatus),window.removeEventListener("offline",this.onUpdateBrowserOnlineStatus))}};z(),z();var sE=class{constructor(t,e,n,i){this.myParticipant={},this.localRoomProperties=null,this.drawingData=null,this.state=0,this.MESSAGE_SIZE_LIMIT=6e4,this.join=()=>{this.room.presence.on(se.LEAVE,this.onParticipantLeave),this.room.presence.on(se.JOINED_ROOM,this.onPresenceEnter),this.enableSync&&(this.room.on("update",this.updateLocalRoomState),this.drawingRoom.presence.on(se.UPDATE,this.updateDrawing))},this.updateMyProperties=t=>{let e=t??{};this.isMessageTooBig(e)||this.left||!this.enableSync||this.isSyncFrozen||(void 0===e.avatar&&delete e.avatar,this.myParticipant=B(B({},this.myParticipant),e),this.room.presence.update(this.myParticipant),this.logger.log("REALTIME","updating my properties",this.myParticipant))},this.isMessageTooBig=(t,e=this.MESSAGE_SIZE_LIMIT)=>{let n=JSON.stringify(t);return(new TextEncoder).encode(n).length>e&&(this.logger.log("Message too long, the message limit size is 60kb."),!0)},this.updateRoomProperties=t=>{if(this.isMessageTooBig(t)||this.isSyncFrozen||this.left)return;let e=B(B({},this.localRoomProperties),t);this.localRoomProperties=e,this.room.emit("update",e)},this.updateDrawingProperties=t=>{this.isMessageTooBig(t)||this.isSyncFrozen||this.left||(this.drawingData=B(B({},this.drawingData),t),this.drawingRoom.presence.update(this.drawingData))},this.setHost=t=>{this.updateRoomProperties({hostClientId:t})},this.setKickParticipant=t=>{if(!t)return;let{participants:e}=this.useStore("global-store"),n=e.value[t];this.updateRoomProperties({kickParticipant:n})},this.initializeRoomProperties=()=>{let t={isGridModeEnabled:!1,hostClientId:null,followParticipantId:null,gather:!1,transcript:"transcript.stop",kickParticipant:null};this.localRoomProperties=t,this.updateRoomProperties(t)},this.onParticipantLeave=t=>{var e;t.id===this.myParticipant.id&&(this.left=!0),t.id===(null==(e=this.localRoomProperties)?void 0:e.followParticipantId)&&this.setFollowParticipant()},this.start=()=>ce(this,null,(function*(){this.started||(this.started=!0,this.room.isJoined||(this.logger.log("room state service - not joined room yet"),setTimeout((()=>{this.logger.log("room state service - retrying"),this.start()}),2e3)),this.localRoomProperties=yield this.fetchRoomProperties(),this.localRoomProperties?this.updateLocalRoomState({data:this.localRoomProperties}):this.initializeRoomProperties(),this.publishStateUpdate(4),this.logger.log("REALTIME","Joined realtime room"))})),this.onPresenceEnter=()=>{this.updateMyProperties()},this.updateLocalRoomState=t=>ce(this,[t],(function*({data:t}){this.logger.log("REALTIME","Room update received",t),this.localRoomProperties=Object.assign({},this.localRoomProperties,t);let{followParticipantId:e,gather:n,hostId:i,isGridModeEnabled:r,transcript:s}=this.useStore("video-store");e.publish(t.followParticipantId),n.publish(t.gather),i.publish(t.hostClientId),r.publish(t.isGridModeEnabled),s.publish(t.transcript),t.kickParticipant&&t.kickParticipant.id===this.myParticipant.id&&(this.updateRoomProperties({kickParticipant:null}),this.kickParticipantObserver.publish(this.myParticipant.id))})),this.updateDrawing=t=>{if(t.id===this.myParticipant.id)return;let{drawing:e}=this.useStore("video-store");e.publish(t.data)},this.freezeSync=t=>{this.isSyncFrozen=t,t?this.destroy():this.join()},this.room=t,this.drawingRoom=e,this.useStore=i.bind(this),this.logger=n,this.kickParticipantObserver=new Xe({logger:this.logger});let{localParticipant:r,participants:s}=this.useStore("global-store");r.subscribe((t=>{this.enableSync="audience"!==t.type,this.myParticipant=B(B({},this.myParticipant),t)})),s.subscribe(),this.join()}setGridMode(t){this.updateRoomProperties({isGridModeEnabled:t})}setDrawing(t){this.updateDrawingProperties(t)}setTranscript(t){this.updateRoomProperties({transcript:t})}fetchRoomProperties(){return ce(this,null,(function*(){if((yield new Promise((t=>{this.room.presence.get((e=>{e||t(0),t(e.length)}))})))<=1)return null;let t=yield new Promise(((t,e)=>{this.room.history((n=>{n||e(n),n.events.length||t(null);let i=n.events.pop();t(i)}))})),e=t?.timestamp<Date.now()-36e5;return null==t||!t.data||e?null:t.data}))}publishStateUpdate(t){if(this.state===t)return;this.state=t,this.logger.log("REALTIME",`Realtime state did change. New state: ${vd[this.state]}`);let{meetingState:e}=this.useStore("video-store");e.publish(this.state)}setFollowParticipant(t){this.updateRoomProperties({followParticipantId:t})}setGather(t){this.updateRoomProperties({gather:t})}destroy(){this.room.presence.off(se.LEAVE),this.room.presence.off(se.JOINED_ROOM),this.drawingRoom.presence.off(se.UPDATE),this.room.off("update",this.updateLocalRoomState)}};z(),z();var rE=class{build(t,e,n,i={},r={}){let s=document.querySelector(`#${t}`),a=new URL(e);if(this.wrapperId||this.element)throw new Error("Tried to initialize two frames with the same FrameBricklayer instance");this.element=document.createElement("iframe"),Object.entries(i).forEach((([t,e])=>{a.searchParams.set(t,e)})),Object.entries(r).forEach((([t,e])=>{this.element.setAttribute(t,e)})),this.element.src=a.toString(),this.element.id=n,s.appendChild(this.element),this.wrapperId=t}destroy(){if(!this.wrapperId)throw new Error("Tried to destroy a frame before it was initialized");let t=document.querySelector(`#${this.wrapperId}`);t&&t.querySelector(`#${this.element.id}`)&&t.removeChild(this.element),this.wrapperId=null,this.element=null}};z();var oE=class{constructor(t){this.observers={},this.sourceBlockList=["vue-devtools-proxy","vue-devtools-backend"],this.originBlockList=["https://sketchfab.com"],this.publish=(t,e={})=>{this.logger.log("MessageBridge","Posting message to frame",t,e),this.contentWindow.postMessage({type:t,data:e},this.allowedOrigins)},this.listen=(t,e)=>{this.observers[t]||(this.observers[t]=new Xe({logger:this.logger})),this.observers[t].subscribe(e)},this.onReceiveMessage=t=>{let{type:e,data:n,source:i}=t.data;if(this.sourceBlockList.includes(i)||this.originBlockList.includes(t.origin))return;let r=!!e,s=!this.domains.length||this.domains.includes(t.origin),a=this.observers.hasOwnProperty(e);this.logger.log("MessageBridge",`Message received -\n        TYPE: ${t.type}\n        ORIGIN: ${t.origin}\n        DATA: ${JSON.stringify(t.data)} `),r&&s&&a?this.observers[e].publish(n):this.logger.log("MessageBridge","Message discarded")};let{contentWindow:e,domains:n=[],allowedOrigins:i="*",sourceBlockList:r=[],logger:s}=t;if(this.logger=s,this.domains=n,this.allowedOrigins=i,this.sourceBlockList.push(...r),typeof window>"u")throw new Error("MessageBridge: window is undefined");this.contentWindow=e,window.addEventListener("message",this.onReceiveMessage)}destroy(){Object.entries(this.observers).forEach((([t,e])=>{e.reset(),delete this.observers[t]})),typeof window<"u"&&window.removeEventListener("message",this.onReceiveMessage),delete this.logger,delete this.allowedOrigins,delete this.contentWindow,delete this.domains,delete this.observers,delete this.sourceBlockList}};z();var kp=(t=>(t.RIGHT="right",t.CENTER="center",t.LEFT="left",t))(kp||{}),Bp=(t=>(t.GRID="grid",t.LIST="list",t))(Bp||{}),zp=(t=>(t.RIGHT="right",t.LEFT="left",t.TOP="top",t.BOTTOM="bottom",t))(zp||{}),Vd="sv-video-frame",aE=class{constructor(t){var e,n,i,r;this.logger=new st("@superviz/sdk/video-conference-manager"),this.frameStateObserver=new Xe({logger:this.logger}),this.frameSizeObserver=new Xe({logger:this.logger}),this.waitingForHostObserver=new Xe({logger:this.logger}),this.realtimeEventsObserver=new Xe({logger:this.logger}),this.sameAccountErrorObserver=new Xe({logger:this.logger}),this.devicesObserver=new Xe({logger:this.logger}),this.meetingStateObserver=new Xe({logger:this.logger}),this.meetingConnectionObserver=new Xe({logger:this.logger}),this.participantJoinedObserver=new Xe({logger:this.logger}),this.participantLeftObserver=new Xe({logger:this.logger}),this.participantListObserver=new Xe({logger:this.logger}),this.frameState=0,this.layoutModalsAndCamerasConfig=(t,e)=>{let n=t,i=e;return["left","right","bottom","top"].includes(i)||(i="right"),["left","right","center"].includes(n)||(n="right"),this.browserService.isMobileDevice?(i="bottom",{layoutPosition:n,camerasPosition:i}):("left"===n&&"right"===i&&(n="right"),"right"===n&&"left"===i&&(n="left"),{layoutPosition:n,camerasPosition:i})},this.onFrameLoad=()=>{this.messageBridge=new oE({logger:this.logger,contentWindow:this.bricklayer.element.contentWindow}),this.addMessagesListeners(),this.updateFrameState(2),this.updateFrameLocale(),this.updateMeetingAvatars(),this.onWindowResize(),this.setCustomColors(),this.setCallbacks()},this.setFrameOffset=t=>{let e=t??{};["top","bottom","left","right"].forEach((t=>{Object.keys(e).includes(t)||(e[t]=0)})),this.frameOffset=e},this.setCustomColors=()=>{this.customColors&&this.messageBridge.publish("frame.color-list-update",this.customColors),this.styles&&this.messageBridge.publish("frame.styles-update",this.styles)},this.setCallbacks=()=>{if(!this.callbacks)return;let t={onToggleMicrophone:!!this.callbacks.onToggleMicrophone,onToggleCam:!!this.callbacks.onToggleCam,onToggleRecording:!!this.callbacks.onToggleRecording,onToggleChat:!!this.callbacks.onToggleChat,onToggleScreenShare:!!this.callbacks.onToggleScreenShare,onClickHangup:!!this.callbacks.onClickHangup,onToggleMeetingSetup:!!this.callbacks.onToggleMeetingSetup};this.messageBridge.listen("callback-called",(t=>{var e,n;null==(n=(e=this.callbacks)[t])||n.call(e)})),this.messageBridge.publish("frame.callbacks-update",JSON.stringify(t))},this.setFrameStyle=t=>{let e=document.createElement("style"),{bottom:n,left:i,right:r,top:s}=this.frameOffset;e.innerHTML=`\n      :root {\n        --superviz-offset-top: ${s}px;\n        --superviz-offset-right: ${r}px;\n        --superviz-offset-left: ${i}px;\n        --superviz-offset-bottom: ${n}px;\n      }     \n    `,document.head.appendChild(e),this.browserService.isMobileDevice?this.bricklayer.element.classList.add("sv-video-frame--bottom"):this.bricklayer.element.classList.add(`sv-video-frame--${t}`)},this.onFrameDimensionsUpdate=({width:t,height:e})=>{if(typeof window>"u")return;let n=document.getElementById(Vd),{bottom:i,right:r,left:s,top:a}=this.frameOffset,o=`${t}px`,l=`${e+(this.isWaterMarkEnabled?40:0)}px`;(t>=window.innerWidth||this.isHorizontalCameraEnabled)&&(o=`calc(100% - ${r}px - ${s}px)`),e>=window.innerHeight&&(l=`calc(100% - ${a}px - ${i}px)`),n.style.width=o,n.style.height=l,this.frameSizeObserver.publish({width:n.offsetWidth,height:n.offsetHeight})},this.onWindowResize=()=>{let{top:t,bottom:e,right:n,left:i}=this.frameOffset,{innerHeight:r,innerWidth:s}=window,a=r-t-e,o=s-n-i;this.messageBridge&&this.messageBridge.publish("frame.parent-window-size-update",{height:a,width:o})},this.updateFrameLocale=()=>{var t,e;if(!this.frameLocale||(null==(t=this.frameLocale)||!t.language)&&null!=(e=this.frameLocale)&&e.locales)return;let{language:n,locales:i}=this.frameLocale,r=["en",...i.map((t=>t?.language))];if(n&&!r.includes(n))throw new Error("The default language is not available in the language listing.");this.messageBridge.publish("frame.locales-update",this.frameLocale)},this.updateMeetingAvatars=()=>{this.messageBridge.publish("frame.avatar-list-update",this.meetingAvatars)},this.onParticipantJoined=t=>{this.participantJoinedObserver.publish(t)},this.onParticipantLeft=t=>{this.participantLeftObserver.publish(t)},this.onMeetingHostChange=t=>{this.realtimeEventsObserver.publish({event:"realtime.host-change",data:t})},this.onMeetingKickParticipant=t=>{this.realtimeEventsObserver.publish({event:"meeting.kick-participant",data:t})},this.onFollowParticipantDidChange=t=>{this.realtimeEventsObserver.publish({event:"realtime.follow-participant",data:t})},this.onGoToDidChange=t=>{this.realtimeEventsObserver.publish({event:"realtime.go-to-participant",data:t})},this.onGather=()=>{this.realtimeEventsObserver.publish({event:"realtime.gather",data:!0})},this.onGridModeChange=t=>{this.realtimeEventsObserver.publish({event:"realtime.grid-mode-change",data:t})},this.onDrawingChange=t=>{this.realtimeEventsObserver.publish({event:"realtime.drawing-change",data:t})},this.onTranscriptChange=t=>{this.realtimeEventsObserver.publish({event:"realtime.transcript-change",data:t})},this.onSameAccountError=t=>{this.sameAccountErrorObserver.publish(t)},this.onDevicesChange=t=>{this.devicesObserver.publish(t)},this.meetingStateUpdate=t=>{this.meetingStateObserver.publish(t)},this.onConnectionStatusChange=t=>{this.meetingConnectionObserver.publish(t)},this.onWaitingForHostDidChange=t=>{this.waitingForHostObserver.publish(t)},this.onParticipantListUpdate=t=>{this.participantListObserver.publish(t)};let{language:s,canUseCams:a,canUseChat:o,canUseScreenshare:l,canUseDefaultAvatars:c,canUseFollow:u,canUseGoTo:h,canUseGather:d,canShowAudienceList:p,canUseDefaultToolbar:f,canUseRecording:m,browserService:g,offset:v,locales:_,avatars:y,customColors:b,styles:w,waterMark:x,layoutPosition:S,camerasPosition:E,skipMeetingSettings:C,devices:M,layoutMode:P,collaborationMode:A,callbacks:T}=t;this.browserService=g;let I=this.layoutModalsAndCamerasConfig(S,E),O=document.createElement("div");this.frameConfig={apiKey:Q.get("apiKey"),apiUrl:Q.get("apiUrl"),debug:Q.get("debug"),roomId:Q.get("roomId"),limits:Q.get("limits"),collaborationMode:A,canUseFollow:u,canUseGoTo:h,canUseCams:a,canUseChat:o,canUseGather:d,canUseScreenshare:l,canUseDefaultAvatars:c,canUseRecording:m,canShowAudienceList:p,camerasPosition:null!=(e=I.camerasPosition)?e:"right",canUseDefaultToolbar:f,devices:{audioInput:null==(n=M?.audioInput)||n,audioOutput:null==(i=M?.audioOutput)||i,videoInput:null==(r=M?.videoInput)||r},waterMark:x,layoutMode:P,skipMeetingSettings:C,layoutPosition:I.layoutPosition,transcriptLangs:Q.get("features.transcriptLangs")},this.customColors=b,this.callbacks=T,this.styles=w,O.classList.add("sv_video_wrapper"),O.id="sv-video-wrapper",document.body.appendChild(O),this.updateFrameState(1),this.bricklayer=new rE,this.bricklayer.build(O.id,Q.get("conferenceLayerUrl"),Vd,void 0,{allow:"camera *;microphone *; display-capture *;"}),this.setFrameOffset(v),this.setFrameStyle(I.camerasPosition),this.bricklayer.element.addEventListener("load",this.onFrameLoad),this.frameLocale={language:s,locales:_},this.meetingAvatars=y,typeof window<"u"&&(window.addEventListener("resize",this.onWindowResize),window.addEventListener("orientationchange",this.onWindowResize))}get isWaterMarkEnabled(){return!this.browserService.isMobileDevice&&this.frameConfig.waterMark}get isHorizontalCameraEnabled(){return!this.browserService.isMobileDevice&&["top","bottom"].includes(this.frameConfig.camerasPosition)}addMessagesListeners(){this.messageBridge.listen("meeting.waiting-for-host",this.onWaitingForHostDidChange),this.messageBridge.listen("meeting.participant-joined",this.onParticipantJoined),this.messageBridge.listen("meeting.participant-list-update",this.onParticipantListUpdate),this.messageBridge.listen("meeting.participant-left",this.onParticipantLeft),this.messageBridge.listen("meeting.host-change",this.onMeetingHostChange),this.messageBridge.listen("meeting.kick-participant",this.onMeetingKickParticipant),this.messageBridge.listen("meeting.same-participant-error",this.onSameAccountError),this.messageBridge.listen("meeting.state-update",this.meetingStateUpdate),this.messageBridge.listen("meeting.connection-status-change",this.onConnectionStatusChange),this.messageBridge.listen("meeting.devices-change",this.onDevicesChange),this.messageBridge.listen("realtime.grid-mode-change",this.onGridModeChange),this.messageBridge.listen("realtime.drawing-change",this.onDrawingChange),this.messageBridge.listen("realtime.transcript-change",this.onTranscriptChange),this.messageBridge.listen("frame.dimensions-update",this.onFrameDimensionsUpdate),this.messageBridge.listen("realtime.follow-participant",this.onFollowParticipantDidChange),this.messageBridge.listen("realtime.go-to-participant",this.onGoToDidChange),this.messageBridge.listen("realtime.gather",this.onGather)}updateFrameState(t){t!==this.frameState&&(this.frameState=t,this.frameStateObserver.publish(this.frameState));this.meetingStateUpdate({1:6,2:7,0:8}[t])}start(t){this.messageBridge.publish("meeting.start",ge(B({},t),{config:this.frameConfig}))}leave(){this.messageBridge.publish("meeting.leave"),this.destroy()}destroy(){var t,e,n,i,r,s,a,o,l,c;null==(t=this.messageBridge)||t.destroy(),null==(e=this.bricklayer)||e.destroy(),null==(n=this.frameSizeObserver)||n.destroy(),null==(i=this.realtimeEventsObserver)||i.destroy(),null==(r=this.sameAccountErrorObserver)||r.destroy(),null==(s=this.devicesObserver)||s.destroy(),null==(a=this.meetingStateObserver)||a.destroy(),null==(o=this.meetingConnectionObserver)||o.destroy(),null==(l=this.participantJoinedObserver)||l.destroy(),null==(c=this.participantLeftObserver)||c.destroy(),this.bricklayer=null,this.frameState=null,typeof window<"u"&&(window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("orientationchange",this.onWindowResize))}publishMessageToFrame(t,e){this.messageBridge&&this.messageBridge.publish(t,e)}},lE=6e4,An=null,cE=class extends ui{constructor(t){var e,n;super(),this.participantsOnMeeting=[],this.kickParticipantsOnHostLeave=!1,this.startVideo=()=>ce(this,null,(function*(){var t,e,n,i,r,s,a,o,l,c,u,h,d,p,f,m,g,v,_,y,b,w,x,S,E,C,M,P,A,T,I,O,L,N,R,k,D,U;let F="audience"!==(null==(t=this.params)?void 0:t.userType)&&!0===(null==(e=this.params)?void 0:e.defaultAvatars);if(!Q.get("conferenceLayerUrl")){let{conferenceLayerUrl:t}=yield Yr.getRemoteConfig(Q.get("environment"));Q.set("conferenceLayerUrl",t)}this.videoConfig={language:null==(n=this.params)?void 0:n.language,canUseRecording:!(null==(i=this.params)||!i.enableRecording),canShowAudienceList:null==(s=null==(r=this.params)?void 0:r.showAudienceList)||s,canUseChat:!(null!=(a=this.params)&&a.chatOff),canUseCams:!(null!=(o=this.params)&&o.camsOff),canUseScreenshare:!(null!=(l=this.params)&&l.screenshareOff),canUseDefaultAvatars:F&&!(null!=(u=null==(c=this.localParticipant)?void 0:c.avatar)&&u.model3DUrl),canUseGather:!(null==(h=this.params)||!h.enableGather),canUseFollow:!(null==(d=this.params)||!d.enableFollow),canUseGoTo:!(null==(p=this.params)||!p.enableGoTo),canUseDefaultToolbar:null==(m=null==(f=this.params)?void 0:f.defaultToolbar)||m,camerasPosition:null==(v=null==(g=this.params)?void 0:g.collaborationMode)?void 0:v.position,devices:null==(_=this.params)?void 0:_.devices,skipMeetingSettings:null==(y=this.params)?void 0:y.skipMeetingSettings,browserService:this.browserService,offset:null==(b=this.params)?void 0:b.offset,locales:null!=(x=null==(w=this.params)?void 0:w.locales)?x:[],avatars:null!=(E=null==(S=this.params)?void 0:S.avatars)?E:[],customColors:Q.get("colors"),waterMark:Q.get("waterMark"),styles:null==(C=this.params)?void 0:C.styles,collaborationMode:null==(A=null==(P=null==(M=this.params)?void 0:M.collaborationMode)?void 0:P.enabled)||A,layoutPosition:!1===(null==(I=null==(T=this.params)?void 0:T.collaborationMode)?void 0:I.enabled)?"center":null!=(N=null==(L=null==(O=this.params)?void 0:O.collaborationMode)?void 0:L.modalPosition)?N:"center",layoutMode:null!=(D=null==(k=null==(R=this.params)?void 0:R.collaborationMode)?void 0:k.initialView)?D:"list",callbacks:null==(U=this.params)?void 0:U.callbacks},this.logger.log("video conference @ start video",this.videoConfig),this.videoManager=new aE(this.videoConfig),this.subscribeToVideoEvents()})),this.subscribeToVideoEvents=()=>{this.logger.log("video conference @ subscribe to video events"),this.videoManager.meetingConnectionObserver.subscribe(this.connectionService.updateMeetingConnectionStatus),this.videoManager.participantListObserver.subscribe(this.onParticipantListUpdate),this.videoManager.waitingForHostObserver.subscribe(this.onWaitingForHost),this.videoManager.frameSizeObserver.subscribe(this.onFrameSizeDidChange),this.videoManager.meetingStateObserver.subscribe(this.onMeetingStateChange),this.videoManager.frameStateObserver.subscribe(this.onFrameStateChange),this.videoManager.realtimeEventsObserver.subscribe(this.onRealtimeEventFromFrame),this.videoManager.participantJoinedObserver.subscribe(this.onParticipantJoined),this.videoManager.participantLeftObserver.subscribe(this.onParticipantLeft),this.videoManager.sameAccountErrorObserver.subscribe(this.onSameAccountError),this.videoManager.devicesObserver.subscribe(this.onDevicesChange)},this.unsubscribeFromVideoEvents=()=>{this.videoManager&&(this.logger.log("video conference @ unsubscribe from video events"),this.videoManager.meetingConnectionObserver.unsubscribe(this.connectionService.updateMeetingConnectionStatus),this.videoManager.participantListObserver.unsubscribe(this.onParticipantListUpdate),this.videoManager.waitingForHostObserver.unsubscribe(this.onWaitingForHost),this.videoManager.frameSizeObserver.unsubscribe(this.onFrameSizeDidChange),this.videoManager.meetingStateObserver.unsubscribe(this.onMeetingStateChange),this.videoManager.frameStateObserver.unsubscribe(this.onFrameStateChange),this.videoManager.realtimeEventsObserver.unsubscribe(this.onRealtimeEventFromFrame),this.videoManager.participantJoinedObserver.unsubscribe(this.onParticipantJoined),this.videoManager.participantLeftObserver.unsubscribe(this.onParticipantLeft),this.videoManager.sameAccountErrorObserver.unsubscribe(this.onSameAccountError),this.videoManager.devicesObserver.unsubscribe(this.onDevicesChange))},this.suscribeToRealtimeEvents=()=>{this.logger.log("video conference @ subscribe to realtime events"),this.room.presence.on(se.UPDATE,this.onParticipantUpdateOnRealtime),this.room.presence.on(se.JOINED_ROOM,this.onParticipantJoinedOnRealtime),this.room.presence.on(se.LEAVE,this.onParticipantLeftOnRealtime)},this.unsubscribeFromRealtimeEvents=()=>{var t;this.logger.log("video conference @ unsubscribe from realtime events"),this.room.presence.off(se.UPDATE),this.room.presence.off(se.LEAVE),this.room.presence.off(se.JOINED_ROOM),null==(t=this.roomState)||t.kickParticipantObserver.unsubscribe(this.onKickLocalParticipant)},this.subscribeToStoreUpdates=()=>{let{localParticipant:t,group:e,participants:n}=this.useStore("global-store");n.subscribe((t=>{let e=Object.values(t);this.onRealtimeParticipantsDidChange(e)}));let{drawing:i,hostId:r,isGridModeEnabled:s,transcript:a,followParticipantId:o,gather:l}=this.useStore("video-store");t.subscribe((t=>{this.localParticipant=ge(B(B({},this.localParticipant),t),{type:this.params.userType})})),i.subscribe(this.setDrawing),r.subscribe(this.setHost),s.subscribe(this.setGridMode),a.subscribe(this.setTranscript),o.subscribe(this.setFollowParticipant),l.subscribe(this.setGather),e.subscribe()},this.createParticipantFromPresence=t=>{var e;return{participantId:t.id,id:t.id,color:(null==(e=t.data.slot)?void 0:e.color)||Yt.gray,avatar:t.data.avatar,type:t.data.type,name:t.data.name,isHost:t.data.isHost,timestamp:t.timestamp,slot:t.data.slot}},this.onFrameSizeDidChange=t=>{this.publish("frame.dimensions-update",t)},this.onWaitingForHost=t=>{this.publish("meeting.waiting-for-host",t)},this.onConnectionStatusChange=t=>{this.logger.log("video conference @ on connection status change",t);let e=[2,4,3,6];e.includes(t)&&this.roomState.freezeSync(!0),e.includes(this.connectionService.oldConnectionStatus)&&!e.includes(t)&&this.roomState.freezeSync(!1),this.publish("meeting.connection-status-change",t)},this.onMeetingStateChange=t=>{this.logger.log("video conference @ on meeting state change",t),this.publish("meeting.state-update",t)},this.onSameAccountError=t=>{this.publish("meeting.same-participant-error",t),this.detach()},this.onDevicesChange=t=>{this.publish("meeting.devices-change",t)},this.onFrameStateChange=t=>{this.logger.log("video conference @ on frame state change",t),2===t&&(this.roomState=new sE(this.room,this.drawingRoom,this.logger,this.useStore),this.roomState.kickParticipantObserver.subscribe(this.onKickLocalParticipant),this.roomState.start(),"guest"!==this.params.userType&&(this.localParticipant=Object.assign(this.localParticipant,{type:this.params.userType}),this.roomState.updateMyProperties(B({},this.localParticipant))),this.videoManager.start({group:this.group,participant:this.localParticipant,roomId:Q.get("roomId")}),this.publish("meeting.start"))},this.onRealtimeEventFromFrame=({event:t,data:e})=>{this.logger.log("video conference @ on realtime event from frame",t,e);({"realtime.host-change":t=>this.roomState.setHost(t),"realtime.gather":t=>this.roomState.setGather(t),"realtime.grid-mode-change":t=>this.roomState.setGridMode(t),"realtime.drawing-change":t=>{this.roomState.setDrawing(t)},"realtime.follow-participant":t=>{this.roomState.setFollowParticipant(t)},"meeting.kick-participant":t=>{this.roomState.setKickParticipant(t)},"realtime.transcript-change":t=>{this.roomState.setTranscript(t)},"realtime.go-to-participant":t=>{this.eventBus.publish("realtime.go-to-participant",t)}})[t](e);this.publish(t,e)},this.onParticipantJoined=t=>{var e;this.logger.log("video conference @ on participant joined",t),this.publish("meeting.participant-joined",t),this.publish("my-participant.joined",t),this.kickParticipantsOnHostLeave=!(null!=(e=this.params)&&e.allowGuests);let{localParticipant:n,participants:i}=this.useStore("global-store"),r=t.name.trim();if(this.videoConfig.canUseDefaultAvatars)return this.roomState.updateMyProperties({avatar:t.avatar,name:r,type:t.type,joinedMeeting:!0}),this.eventBus.publish("update-participant",ge(B({},n.value),{avatar:t.avatar,name:r,type:this.params.userType})),void this.eventBus.publish("update-participant-list",ge(B({},i.value),{[t.id]:ge(B({},i.value[t.id]),{avatar:t.avatar,name:r})}));this.eventBus.publish("update-participant",ge(B({},n.value),{name:r,type:this.params.userType})),this.eventBus.publish("update-participant-list",ge(B({},i.value),{[t.id]:ge(B({},i.value[t.id]),{name:r,type:this.params.userType})})),this.roomState.updateMyProperties({name:t.name,type:t.type,joinedMeeting:!0})},this.onParticipantLeft=t=>{var e,n;this.logger.log("video conference @ on participant left",this.localParticipant);let{localParticipant:i,participants:r}=this.useStore("global-store");i.publish(ge(B({},i.value),{activeComponents:null==(e=i.value.activeComponents)?void 0:e.filter((t=>"videoConference"!==t))})),r.publish(ge(B({},r.value),{[this.localParticipant.id]:ge(B({},i.value),{activeComponents:null==(n=i.value.activeComponents)?void 0:n.filter((t=>"videoConference"!==t))})})),this.connectionService.removeListeners(),this.publish("my-participant.left",this.localParticipant),this.unsubscribeFromVideoEvents(),this.videoManager.leave(),this.videoManager=void 0,this.connectionService=void 0,this.detach()},this.onParticipantListUpdate=t=>{this.logger.log("video conference @ on participant list update",t);let e=Object.values(t).map((t=>{var e,n;return{id:t.id,slot:t.slot,avatar:t.avatar,name:t.name,type:t.type,isHost:null!=(e=t.isHost)&&e,timestamp:t.timestamp,color:(null==(n=t.slot)?void 0:n.color)||Yt.gray}}));this.publish("meeting.participant-list-update",e),this.participantsOnMeeting.length!==e.length&&this.publish("meeting.amount-of-participants-update",e.length),this.participantsOnMeeting=e,this.validateIfInTheRoomHasHost()},this.onKickLocalParticipant=()=>{this.logger.log("video conference @ on kick local participant"),this.publish("meeting.kick-participant",this.localParticipant),this.detach()},this.setDrawing=t=>{var e;null==(e=this.videoManager)||e.publishMessageToFrame("realtime.drawing-change",t)},this.setHost=t=>{var e;null==(e=this.videoManager)||e.publishMessageToFrame("realtime.host-change",t),this.onHostParticipantDidChange(t)},this.setGridMode=t=>{var e;null==(e=this.videoManager)||e.publishMessageToFrame("realtime.grid-mode-change",t)},this.setTranscript=t=>{var e;null==(e=this.videoManager)||e.publishMessageToFrame("realtime.transcript-change",t)},this.setFollowParticipant=t=>{var e;null==(e=this.videoManager)||e.publishMessageToFrame("realtime.follow-participant",t),this.eventBus.publish("realtime.follow-participant",t)},this.setGather=t=>{if(!this.videoManager||!t)return;let{hostId:e,gather:n}=this.useStore("video-store");n.publish(!1),e.value===this.localParticipant.id?this.videoManager.publishMessageToFrame("realtime.gather",t):this.eventBus.publish("realtime.go-to-participant",e.value)},this.onRealtimeParticipantsDidChange=t=>{var e;this.logger.log("video conference @ on participants did change",t);let n=t.map((t=>{var e,n;return{id:t.id,timestamp:t.timestamp,participantId:t.id,color:(null==(e=t.slot)?void 0:e.color)||Yt.gray,name:t.name,isHost:null!=(n=t.isHost)&&n,avatar:t.avatar,type:t.type,slot:t.slot}}));null==(e=this.videoManager)||e.publishMessageToFrame("realtime.participant-list-update",n)},this.onHostParticipantDidChange=t=>{var e,n;this.logger.log("video conference @ on host participant did change",t),null==(e=this.videoManager)||e.publishMessageToFrame("realtime.host-change",t);let{participants:i}=this.useStore("global-store"),r=Object.values(i.value).find((e=>e.id===t)),s=r?{id:r.id,color:(null==(n=r.slot)?void 0:n.color)||Yt.gray,avatar:r.avatar,type:r.type,name:r.name,isHost:r.id===t}:null;An&&s&&(this.logger.log("video conference @ on host participant did change - clear kick all participants timeout"),clearTimeout(An),An=null),this.publish("meeting.host-change",s)},this.onHostAvailabilityChange=t=>{this.logger.log("launcher service @ onHostAvailabilityChange"),t?this.publish("meeting.host-available"):this.publish("meeting.no-host-available")},this.onParticipantJoinedOnRealtime=t=>{this.logger.log("video conference @ on participant joined on realtime",t),this.publish("meeting.participant-joined",this.createParticipantFromPresence(t)),t.id===this.localParticipant.id&&this.room.presence.update(this.localParticipant)},this.onParticipantLeftOnRealtime=t=>{this.logger.log("video conference @ on participant left on realtime",t),this.publish("meeting.participant-left",this.createParticipantFromPresence(t))},this.onParticipantUpdateOnRealtime=t=>{this.logger.log("video conference @ on participant update on realtime",t);let{localParticipant:e,participants:n}=this.useStore("global-store");t.data.id===this.localParticipant.id&&this.publish("my-participant.update",this.createParticipantFromPresence(t)),n.publish(ge(B({},n.value),{[t.data.id]:B(B({},e.value),t.data)}))},this.validateIfInTheRoomHasHost=()=>ce(this,null,(function*(){var t,e,n;if(!this.roomState)return;let{hostId:i}=this.useStore("video-store"),r=yield new Promise(((t,e)=>{this.room.presence.get((e=>t(e)),(t=>{let n=`[SuperViz] ${t.name} - ${t.message}`;this.logger.log(t),console.error(n),e(t)}))})),s=r.filter((t=>"host"===t.data.type&&t.data.joinedMeeting));this.logger.log("video conference @ validate if in the room has host - conditions to init kick all participants timeout",{participantsCanBeHost:s,participantListInTheStore:r,participantsOnMeeting:this.participantsOnMeeting,kickParticipantsOnHostLeave:this.kickParticipantsOnHostLeave,localParticipantCanBeHost:"host"===(null==(t=this.localParticipant)?void 0:t.type),kickParticipantsTimeout:An}),!s.length&&this.kickParticipantsOnHostLeave&&"host"!==(null==(e=this.localParticipant)?void 0:e.type)&&!An&&(this.logger.log("video conference @ validate if in the room has host - init kick all participants timeout"),An=setTimeout((()=>{this.logger.log("video conference @ validate if in the room has host - kick all participants"),this.onKickLocalParticipant()}),lE)),s.length&&An&&(this.logger.log("video conference @ validade if in the room has host - clear kick all participants timeout"),clearTimeout(An),An=null),this.onHostAvailabilityChange(!!s.length);let a=r.find((t=>t?.id===i?.value));if(!s.length||a)return;let o=s.reduce(((t,e)=>(this.logger.log("video conference @ validate if in the room has host - reducing participants",{previous:t,current:e}),t&&e?.id!==i.value&&e?.timestamp>t.timestamp?t:e)),null);this.room.presence.update(ge(B({},this.localParticipant),{isHost:o.id===this.localParticipant.id})),o&&o.id===(null==(n=this.localParticipant)?void 0:n.id)&&(this.logger.log("video conference @ validate if in the room has host - set host",o),i.publish(o.id),this.roomState.setHost(o.id))})),this.params=ge(B({},t),{userType:null!=(n=null!=(e=t?.participantType)?e:t?.userType)?n:"guest"}),this.name="videoConference",this.logger=new st("@superviz/sdk/videoConference"),this.browserService=new nE,this.connectionService=new iE,this.connectionService.addListeners(),this.connectionService.connectionStatusObserver.subscribe(this.onConnectionStatusChange)}toggleMeetingSetup(){var t;return null==(t=this.videoManager)?void 0:t.publishMessageToFrame("meeting-controls.toggle-setup")}toggleMicrophone(){var t;if("audience"!==this.localParticipant.type)return null==(t=this.videoManager)?void 0:t.publishMessageToFrame("meeting-controls.toggle-microphone");console.warn("[SuperViz] Audience cannot toggle microphone")}toggleCam(){var t;"audience"!==this.localParticipant.type?null==(t=this.videoManager)||t.publishMessageToFrame("meeting-controls.toggle-cam"):console.warn("[SuperViz] Audience cannot toggle camera")}toggleScreenShare(){var t;if("audience"!==this.localParticipant.type)return null==(t=this.videoManager)?void 0:t.publishMessageToFrame("meeting-controls.toggle-screenshare");console.warn("[SuperViz] Audience cannot toggle screen share")}toggleChat(){var t;return null==(t=this.videoManager)?void 0:t.publishMessageToFrame("meeting-controls.toggle-chat")}toggleRecording(){var t;if(!this.localParticipant.isHost)return null==(t=this.videoManager)?void 0:t.publishMessageToFrame("meeting-controls.toggle-recording");console.warn("[SuperViz] Only host can toggle recording")}hangUp(){var t;null==(t=this.videoManager)||t.publishMessageToFrame("hang-up")}start(){this.logger.log("video conference @ start"),this.drawingRoom=this.ioc.createRoom("drawing"),this.subscribeToStoreUpdates(),this.suscribeToRealtimeEvents(),this.startVideo()}destroy(){var t,e,n;this.logger.log("video conference @ destroy");let{destroy:i}=this.useStore("video-store");i(),null==(t=this.roomState)||t.destroy(),this.drawingRoom.disconnect(),this.kickParticipantsOnHostLeave=!1,this.publish("destroy"),this.unsubscribeFromRealtimeEvents(),this.unsubscribeFromVideoEvents(),null==(e=this.videoManager)||e.leave(),null==(n=this.connectionService)||n.removeListeners()}};z(),z();var hE=Zt(Li()),uE=class extends ui{constructor(t,e){var n;if(super(),this.camera={x:0,y:0,screen:{width:0,height:0},scale:1},this.subscribeToRealtimeEvents=()=>{this.logger.log("presence-mouse component @ subscribe to realtime events"),this.room.presence.on(se.JOINED_ROOM,this.onPresenceJoinedRoom),this.room.presence.on(se.LEAVE,this.onPresenceLeftRoom),this.room.presence.on(se.UPDATE,this.onPresenceUpdate)},this.unsubscribeFromRealtimeEvents=()=>{this.logger.log("presence-mouse component @ unsubscribe from realtime events"),this.room.presence.off(se.JOINED_ROOM),this.room.presence.off(se.LEAVE),this.room.presence.off(se.UPDATE)},this.setParticipantPrivate=t=>{this.isPrivate=t,this.room.presence.update({visible:!t})},this.onPresenceJoinedRoom=t=>{t.id===this.localParticipant.id&&this.room.presence.update(this.localParticipant)},this.onPresenceLeftRoom=t=>{this.removePresenceMouseParticipant(t.id)},this.onPresenceUpdate=t=>{if(this.following&&this.presences.get(this.following)&&this.goToMouse(this.following),t.id===this.localParticipant.id)return;let e=t.data;this.following&&e.id!==this.following&&this.presences.has(e.id)?this.removePresenceMouseParticipant(e.id):this.presences.set(e.id,e)},this.animate=()=>{this.getCamera(),this.renderDivWrapper(),this.updateParticipantsMouses(),requestAnimationFrame(this.animate)},this.goToMouse=t=>{let e=this.presences.get(t);if(null==e||!e.camera)return;let n=e.camera.x,i=e.camera.y,r=this.divWrapper.clientHeight/e.camera.screen.height,s=Math.min(r,1),a=this.divWrapper.clientWidth/e.camera.screen.width,o=Math.min(a,1);this.goToMouseCallback&&this.goToMouseCallback({x:n,y:i,scaleX:s,scaleY:o})},this.onMyParticipantMouseMove=(0,hE.throttle)((t=>{let e=this.canvas.getContext("2d"),n=this.canvas.getBoundingClientRect(),i=t.x-n.left,r=t.y-n.top,s=(e?.getTransform()).inverse(),a=new DOMPoint(i,r).matrixTransform(s),o={x:a.x,y:a.y};this.room.presence.update(ge(B(B({},this.localParticipant),o),{visible:!this.isPrivate,camera:this.camera}))}),30),this.onMyParticipantMouseOut=t=>{let{x:e,y:n,width:i,height:r}=this.canvas.getBoundingClientRect();t.x>0&&t.y>0&&t.x<e+i&&t.y<n+r||this.room.presence.update({visible:!1})},this.updateParticipantsMouses=()=>{this.presences.forEach((t=>{null==t||!t.visible||this.following&&this.following!==t.id?this.removePresenceMouseParticipant(t.id):this.renderPresenceMouses(t)}))},this.getCamera=()=>{var t;let e=null==(t=this.canvas)?void 0:t.getContext("2d"),n=e?.getTransform(),i=n?.e,r=n?.f,s=n?.a;this.camera={screen:{width:this.divWrapper.clientHeight,height:this.divWrapper.clientWidth},x:i,y:r,scale:s}},this.renderPresenceMouses=t=>{var e,n,i,r,s;let a=document.getElementById(`mouse-${t.id}`);a||(a=this.createMouseElement(t));let o=document.getElementById(`mouse-${t.id}`),l=document.getElementById(`mouse-${t.id}`);if(!o||!l)return;let c=o.getElementsByClassName("mouse-user-name")[0],u=l.getElementsByClassName("pointer-mouse")[0];u&&(u.style.backgroundImage=`url(https://production.cdn.superviz.com/static/mouse-pointers/${null==(e=t.slot)?void 0:e.colorName}.svg)`),c&&(c.style.color=null!=(i=null==(n=t.slot)?void 0:n.textColor)?i:"#fff",c.style.backgroundColor=null!=(s=null==(r=t.slot)?void 0:r.color)?s:Yt.gray,c.innerHTML=t.name);let{x:h,y:d}=t,p=this.canvas.getContext("2d"),f=p?.getTransform(),m=f?.e,g=f?.f,v=h*f.a+m,_=d*f.d+g,y=this.divWrapper.clientWidth>v&&this.divWrapper.clientHeight>_&&t.visible;a.style.opacity=y?"1":"0",a.style.left=`${v}px`,a.style.top=`${_}px`},this.followMouse=t=>{this.following=t,this.goToMouse(t)},this.name="presence",this.logger=new st("@superviz/sdk/presence"),this.canvas=document.getElementById(t),this.presences=new Map,!this.canvas){let e=`Canvas with id ${t} not found`;throw this.logger.log(e),new Error(e)}this.divWrapper=this.renderDivWrapper(),this.animateFrame=requestAnimationFrame(this.animate),this.goToMouseCallback=null==(n=e?.callbacks)?void 0:n.onGoToPresence,this.getCamera()}start(){this.logger.log("presence-mouse component @ start");let{localParticipant:t}=this.useStore("global-store");t.subscribe(),this.canvas.addEventListener("mousemove",this.onMyParticipantMouseMove),this.canvas.addEventListener("mouseout",this.onMyParticipantMouseOut),this.eventBus.subscribe("realtime.go-to-participant",this.goToMouse),this.eventBus.subscribe("realtime.local-follow-participant",this.followMouse),this.eventBus.subscribe("realtime.private-mode",this.setParticipantPrivate),this.subscribeToRealtimeEvents()}destroy(){this.logger.log("presence-mouse component @ destroy"),this.eventBus.unsubscribe("realtime.go-to-participant",this.goToMouse),this.eventBus.unsubscribe("realtime.local-follow-participant",this.followMouse),this.eventBus.unsubscribe("realtime.private-mode",this.setParticipantPrivate),this.unsubscribeFromRealtimeEvents(),cancelAnimationFrame(this.animateFrame),this.canvas.removeEventListener("mousemove",this.onMyParticipantMouseMove),this.canvas.removeEventListener("mouseout",this.onMyParticipantMouseOut),this.divWrapper.remove()}renderDivWrapper(){let t=this.canvas.getBoundingClientRect(),e=document.getElementById("superviz-presence-mouse-wrapper");return e||(e=document.createElement("div"),e.id="superviz-presence-mouse-wrapper",this.canvas.parentElement.style.position="relative",this.canvas.parentElement.appendChild(e)),e.style.position="fixed",e.style.top=`${t.top}px`,e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,e.style.pointerEvents="none",e.style.overflow="hidden",e.style.zIndex="2",e}removePresenceMouseParticipant(t){let e=document.getElementById(`mouse-${t}`);e&&(e.remove(),this.presences.delete(t))}createMouseElement(t){let e=document.createElement("div");e.setAttribute("id",`mouse-${t.id}`),e.setAttribute("class","mouse-follower");let n=document.createElement("div");n.setAttribute("class","pointer-mouse");let i=document.createElement("div");return i.setAttribute("class","mouse-user-name"),i.innerHTML=t.name,e.appendChild(n),e.appendChild(i),e.style.left="0px",e.style.top="0px",this.divWrapper.appendChild(e),e}transform(t){console.warn("[SuperViz] - transform method not available when container is a canvas element.")}};z();var dE=Zt(Li());z();var Pl=(t=>(t.AREA="area",t.BASE="base",t.BR="br",t.COL="col",t.EMBED="embed",t.HR="hr",t.IMG="img",t.INPUT="input",t.LINK="link",t.META="meta",t.PARAM="param",t.SOURCE="source",t.TRACK="track",t.WBR="wbr",t))(Pl||{}),Rl=(t=>(t.RECT="rect",t.ELLIPSE="ellipse",t.SVG="svg",t))(Rl||{}),pE=class extends ui{constructor(t,e){var n;if(super(),this.presences=new Map,this.mouses=new Map,this.transformation={translate:{x:0,y:0},scale:1},this.onMyParticipantMouseMove=t=>{if(this.isPrivate)return;let e=t.currentTarget,{left:n,top:i}=e.getBoundingClientRect(),r=(t.x-n-this.transformation.translate.x)/this.transformation.scale,s=(t.y-i-this.transformation.translate.y)/this.transformation.scale;this.room.presence.update(ge(B({},this.localParticipant),{x:r,y:s,visible:!0,camera:this.camera}))},this.onMyParticipantMouseLeave=t=>{if(typeof window>"u")return;let{left:e,top:n,right:i,bottom:r}=this.container.getBoundingClientRect(),s=t.x>e&&t.y>n&&t.x<i&&t.y<r,a=t.x>0&&t.y>0&&t.x<window.innerWidth&&t.y<window.innerHeight;s&&a||this.room.presence.update({visible:!1})},this.goToMouse=t=>{let e=this.mouses.get(t),n=this.presences.get(t);if(n){if(this.goToPresenceCallback){let t=this.camera.screen.width/n.camera.screen.width,e=this.camera.screen.height/n.camera.screen.height,i=n.camera.x*t,r=n.camera.y*e,s=n.camera.scale*t,a=n.camera.scale*e;return void this.goToPresenceCallback({x:i,y:r,scaleX:s,scaleY:a})}e&&e.scrollIntoView({block:"center",inline:"center",behavior:"smooth"})}},this.followMouse=t=>{this.userBeingFollowedId=t,this.goToMouse(t)},this.setParticipantPrivate=t=>{this.isPrivate=t,this.room.presence.update({visible:!t})},this.onPresenceJoinedRoom=t=>{t.id===this.localParticipant.id&&this.room.presence.update(this.localParticipant)},this.onPresenceLeftRoom=t=>{this.removePresenceMouseParticipant(t.id)},this.onPresenceUpdate=t=>{if(t.id===this.localParticipant.id)return;let e=t.data;this.userBeingFollowedId&&e.id!==this.userBeingFollowedId&&this.presences.has(e.id)?this.removePresenceMouseParticipant(e.id):(this.presences.set(e.id,e),this.animate(),this.updateParticipantsMouses())},this.animate=()=>{Pl[this.containerTagname]&&this.updateVoidElementWrapper(),Rl[this.containerTagname]&&this.updateSVGElementWrapper(),this.animationFrame=requestAnimationFrame(this.animate)},this.updateParticipantsMouses=t=>{this.presences.forEach((t=>{if(t.id!==this.localParticipant.id){if(null==t||!t.visible)return void this.removePresenceMouseParticipant(t.id);this.renderPresenceMouses(t)}})),!t&&this.presences.has(this.userBeingFollowedId)&&this.goToMouse(this.userBeingFollowedId)},this.renderPresenceMouses=t=>{var e,n,i,r,s;if(t.id===this.localParticipant.id)return;let a=document.getElementById(`mouse-${t.id}`);if(a||(a=this.createMouseElement(t)),!a)return;let o=a.getElementsByClassName("mouse-user-name")[0],l=a.getElementsByClassName("pointer-mouse")[0];l&&(l.style.backgroundImage=`url(https://production.cdn.superviz.com/static/mouse-pointers/${null==(e=t.slot)?void 0:e.colorName}.svg)`),o&&(o.style.color=null!=(i=null==(n=t.slot)?void 0:n.textColor)?i:Yt.gray,o.style.backgroundColor=null!=(s=null==(r=t.slot)?void 0:r.color)?s:"#fff",o.innerHTML=t.name);let{x:c,y:u}=t,{translate:{x:h,y:d},scale:p}=this.transformation;a.style.left=`${h+c*p}px`,a.style.top=`${d+u*p}px`},this.renderVoidElementWrapper=()=>{let t=document.createElement("div"),{width:e,height:n,left:i,top:r}=this.container.getBoundingClientRect();t.style.position="absolute",t.style.width=`${e}px`,t.style.height=`${n}px`,t.style.top=`${r}px`,t.style.left=`${i}px`,t.style.overflow="visible",t.style.pointerEvents="none",this.container.parentElement.appendChild(t),this.wrapper=t},this.renderSVGElementWrapper=()=>{let t=this.containerTagname.toLowerCase();"svg"!==t?"rect"!==t?"ellipse"===t&&this.createEllipseWrapper():this.createRectWrapper():this.createSVGWrapper()},this.container=document.getElementById(t),this.logger=new st("@superviz/sdk/presence"),!this.container){let e=`Element with id ${t} not found`;throw this.logger.log(e),new Error(e)}this.camera={x:0,y:0,scale:1,screen:{width:this.container.clientWidth,height:this.container.clientHeight}},this.name="presence",this.containerTagname=this.container.tagName.toUpperCase(),this.goToPresenceCallback=null==(n=e?.callbacks)?void 0:n.onGoToPresence}start(){this.logger.log("presence-mouse component @ start");let{localParticipant:t}=this.useStore("global-store");t.subscribe(),this.renderWrapper(),this.addListeners(),this.subscribeToRealtimeEvents(),this.eventBus.subscribe("realtime.private-mode",this.setParticipantPrivate),this.animationFrame=requestAnimationFrame(this.animate),this.eventBus.subscribe("realtime.go-to-participant",this.goToMouse),this.eventBus.subscribe("realtime.local-follow-participant",this.followMouse)}destroy(){cancelAnimationFrame(this.animationFrame),this.logger.log("presence-mouse component @ destroy"),this.removeListeners(),this.wrapper.remove(),this.presences.clear(),this.presences=void 0,this.container=void 0,this.wrapper=void 0,this.unsubscribeFromRealtimeEvents(),this.eventBus.unsubscribe("realtime.private-mode",this.setParticipantPrivate),this.eventBus.unsubscribe("realtime.go-to-participant",this.goToMouse),this.eventBus.unsubscribe("realtime.local-follow-participant",this.followMouse),this.logger=void 0}subscribeToRealtimeEvents(){this.logger.log("presence-mouse component @ subscribe to realtime events"),this.room.presence.on(se.JOINED_ROOM,this.onPresenceJoinedRoom),this.room.presence.on(se.LEAVE,this.onPresenceLeftRoom),this.room.presence.on(se.UPDATE,this.onPresenceUpdate)}unsubscribeFromRealtimeEvents(){this.logger.log("presence-mouse component @ unsubscribe from realtime events"),this.room.presence.off(se.JOINED_ROOM),this.room.presence.off(se.LEAVE),this.room.presence.off(se.UPDATE)}addListeners(){this.pointerMoveObserver=md(this.container,"pointermove").pipe(gd(30)).subscribe(this.onMyParticipantMouseMove),this.container.addEventListener("pointerleave",this.onMyParticipantMouseLeave)}removeListeners(){var t;null==(t=this.pointerMoveObserver)||t.unsubscribe(),this.container.removeEventListener("pointerleave",this.onMyParticipantMouseLeave)}setPositionNotStatic(){let{position:t}=window.getComputedStyle(this.container);"static"===t&&this.container.style.setProperty("position","relative")}createMouseElement(t){if(!this.wrapper)return;let e=document.createElement("div");e.setAttribute("id",`mouse-${t.id}`),e.setAttribute("class","mouse-follower");let n=document.createElement("div");n.setAttribute("class","pointer-mouse");let i=document.createElement("div");return i.setAttribute("class","mouse-user-name"),i.innerHTML=t.name,e.appendChild(n),e.appendChild(i),e.style.left="0px",e.style.top="0px",this.wrapper.appendChild(e),this.mouses.set(t.id,e),e}updateSVGPosition(){let t=this.container.parentElement.getBoundingClientRect(),e=this.container.getBoundingClientRect(),n=e.left-t.left,i=e.top-t.top,{width:r,height:s}=this.container.getBoundingClientRect();this.wrapper.style.setProperty("width",`${r}px`),this.wrapper.style.setProperty("height",`${s}px`),this.wrapper.style.setProperty("top",`${i}px`),this.wrapper.style.setProperty("left",`${n}px`)}createSVGWrapper(){let t=document.createElement("div"),e=this.container.parentElement.getBoundingClientRect(),n=this.container.getBoundingClientRect(),i=n.left-e.left,r=n.top-e.top,{width:s,height:a}=this.container.getBoundingClientRect();t.style.position="fixed",t.style.width=`${s}px`,t.style.height=`${a}px`,t.style.top=`${r}px`,t.style.left=`${i}px`,t.style.overflow="visible",t.style.pointerEvents="none",t.id="superviz-svg-wrapper",this.container.parentElement.appendChild(t),this.wrapper=t}createRectWrapper(){let t=document.createElementNS("http://www.w3.org/2000/svg","svg"),e=document.createElementNS("http://www.w3.org/2000/svg","rect"),n=document.createElement("div"),i=this.container.getAttribute("width"),r=this.container.getAttribute("height"),s=this.container.getAttribute("rx"),a=this.container.getAttribute("ry");e.setAttribute("fill","transparent"),e.setAttribute("stroke","transparent"),e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("rx",s),e.setAttribute("ry",a),e.setAttribute("height",r),e.setAttribute("width",i),t.setAttribute("height",r),t.setAttribute("width",i),t.appendChild(e),n.appendChild(t);let o=this.container.getBoundingClientRect();n.style.position="fixed",n.style.top=`${o.top}px`,n.style.left=`${o.left}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`,n.style.overflow="visible",n.style.pointerEvents="none",n.id="superviz-rect-wrapper";let l=this.container.viewportElement;for(;l.viewportElement;)l=l.viewportElement;l.parentElement.appendChild(n),this.wrapper=n}createEllipseWrapper(){let t=document.createElementNS("http://www.w3.org/2000/svg","svg"),e=document.createElementNS("http://www.w3.org/2000/svg","ellipse"),n=document.createElement("div"),i=this.container.getAttribute("cx"),r=this.container.getAttribute("cy"),s=this.container.getAttribute("rx"),a=this.container.getAttribute("ry"),o=Number(i)-Number(s),l=Number(r)-Number(a),c=String(2*Number(i)),u=String(2*Number(r));e.setAttribute("fill","transparent"),e.setAttribute("stroke","transparent"),e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("rx",s),e.setAttribute("ry",a),e.setAttribute("cx",""+(Number(i)-o)),e.setAttribute("cy",""+(Number(r)-l)),e.setAttribute("height",u),e.setAttribute("width",c),t.setAttribute("height",u),t.setAttribute("width",c),t.appendChild(e),n.appendChild(t);let h=this.container.getBoundingClientRect();n.style.position="fixed",n.style.top=`${h.top}px`,n.style.left=`${h.left}px`,n.style.width=`${h.width}px`,n.style.height=`${h.height}px`,n.style.overflow="visible",n.style.pointerEvents="none",n.id="superviz-ellipse-wrapper";let d=this.container.viewportElement;for(;d.viewportElement;)d=d.viewportElement;d.parentElement.appendChild(n),this.wrapper=n}transform(t){var e,n;this.transformation=t,this.camera={x:t.translate.x,y:t.translate.y,scale:t.scale,screen:{width:(null==(e=this.wrapper)?void 0:e.clientWidth)||1,height:(null==(n=this.wrapper)?void 0:n.clientHeight)||1}},this.updateParticipantsMouses(!0)}updateVoidElementWrapper(){let t=this.container.getBoundingClientRect(),e=this.wrapper.getBoundingClientRect(),n=this.container;if((0,dE.isEqual)(t,e))return;let i=n.offsetLeft,r=n.offsetTop;this.wrapper.style.setProperty("width",`${t.width}px`),this.wrapper.style.setProperty("height",`${t.height}px`),this.wrapper.style.setProperty("top",`${r}px`),this.wrapper.style.setProperty("left",`${i}px`),this.wrapper.id="superviz-void-wrapper"}updateSVGElementWrapper(){let{left:t,top:e,width:n,height:i}=this.container.getBoundingClientRect(),{left:r,top:s,width:a,height:o}=this.wrapper.getBoundingClientRect();if(t!==r||e!==s||n!==a||i!==o){if("svg"===this.containerTagname.toLowerCase())return void this.updateSVGPosition();this.wrapper.style.setProperty("width",`${n}px`),this.wrapper.style.setProperty("height",`${i}px`),this.wrapper.style.setProperty("top",`${e}px`),this.wrapper.style.setProperty("left",`${t}px`)}}renderWrapper(){if(!this.wrapper){if(Pl[this.containerTagname])return void this.renderVoidElementWrapper();if(Rl[this.containerTagname])return void this.renderSVGElementWrapper();this.renderElementWrapper()}}removePresenceMouseParticipant(t){let e=document.getElementById(`mouse-${t}`);e&&(e.remove(),this.presences.delete(t),this.mouses.delete(t))}renderElementWrapper(){let t=document.createElement("div");t.style.position="absolute",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.overflow="visible",t.style.pointerEvents="none",this.setPositionNotStatic(),this.container.appendChild(t),this.wrapper=t}},fE=class{constructor(t,e){let n=document.getElementById(t);if(!n)throw new Error(`[Superviz] Container with id ${t} not found`);return"canvas"===n.tagName.toLowerCase()?new uE(t,e):new pE(t,e)}transform(t){}};z(),z();var mE=Zt(qd());z();var Vp=(t=>(t.STARTED="STARTED",t.STOPPED="STOPPED",t))(Vp||{}),Hp=(t=>(t.REALTIME_STATE_CHANGED="realtime-component.state-changed",t))(Hp||{});z();var gE=class{constructor(t){this.room=t,this.logger=new st("@superviz/sdk/realtime-presence")}update(t){this.logger.log("Realtime Presence @ update presence",t),this.room.presence.update(t)}subscribe(t,e){this.logger.log("Realtime Presence @ subscribe",t),this.room.presence.on(t,e)}unsubscribe(t){this.logger.log("Realtime Presence @ unsubscribe",t),this.room.presence.off(t)}getAll(){return ce(this,null,(function*(){return this.logger.log("Realtime Presence @ get all"),new Promise(((t,e)=>{this.room.presence.get((e=>t(e)),(t=>{let n=`[SuperViz] ${t.name} - ${t.message}`;this.logger.log(t),console.error(n),e(t)}))}))}))}},Hd=class extends Ll{constructor(t,e,n,i){super(),this.state="DISCONNECTED",this.callbacksToSubscribeWhenJoined=[],this.publish=(0,mE.default)(((t,e)=>{if("CONNECTED"!==this.state){let e=`Realtime channel ${this.name} is not started yet. You can't publish event ${t} before start`;return this.logger.log(e),void console.warn(`[SuperViz] ${e}`)}this.channel.emit(`message:${this.name}`,{name:t,payload:e})}),30),this.subscribe=(t,e)=>{"CONNECTED"===this.state?(this.observers[t]||(this.observers[t]=new Xe),this.observers[t].subscribe(e)):this.callbacksToSubscribeWhenJoined.push({event:t,callback:e})},this.unsubscribe=(t,e)=>{var n;null==(n=this.observers[t])||n.unsubscribe(e)},this.fetchHistory=t=>ce(this,null,(function*(){if("CONNECTED"!==this.state){let t="Realtime component is not started yet. You can't retrieve history before start";return this.logger.log(t),console.warn(`[SuperViz] ${t}`),null}return yield new Promise(((e,n)=>{this.channel.history((i=>{var r;null!=(r=i.events)&&r.length||e(null);let s=i.events.reduce(((t,e)=>{var n;return t[e.data.name]||(t[e.data.name]=[]),t[e.data.name].push({data:e.data.payload,connectionId:e.connectionId,name:e.data.name,participantId:null==(n=e.presence)?void 0:n.id,timestamp:e.timestamp}),t}),{});t&&!s[t]&&n(new Error(`Event ${t} not found in the history`)),t&&e(s[t]),e(s)}))}))})),this.publishEventToClient=(t,e)=>{var n;this.logger.log("realtime channel @ publishEventToClient",{event:t,data:e}),null==(n=this.observers[t])||n.publish(e)},this.name=t,this.ioc=e,this.logger=new st("@superviz/sdk/realtime-channel"),this.channel=this.ioc.createRoom(`realtime:${this.name}`,i),this.localParticipant=n,this.subscribeToRealtimeEvents(),this.logger.log("started"),this.participant=new gE(this.channel)}disconnect(){return ce(this,null,(function*(){"DISCONNECTED"!==this.state?(this.logger.log("destroyed"),this.changeState("DISCONNECTED"),this.channel.disconnect()):this.logger.log("Realtime channel is already disconnected")}))}changeState(t){this.logger.log("realtime component @ changeState - state changed",t),this.state=t,this.publishEventToClient("realtime-channel.state-changed",this.state)}subscribeToRealtimeEvents(){this.channel.presence.on(se.JOINED_ROOM,(t=>{t.id===this.localParticipant.id&&(this.changeState("CONNECTED"),this.callbacksToSubscribeWhenJoined.forEach((({event:t,callback:e})=>{this.subscribe(t,e)})),this.logger.log("joined room"),this.changeState("CONNECTED"))})),this.channel.on(`message:${this.name}`,(t=>{var e,n;this.logger.log("message received",t),this.publishEventToClient(t.data.name,{data:t.data.payload,participantId:null!=(n=null==(e=t?.presence)?void 0:e.id)?n:null,name:t.data.name,timestamp:t.timestamp,connectionId:t.connectionId})}))}},vE=class extends ui{constructor(){super(),this.state="STOPPED",this.channels=new Map,this.callbacksToSubscribeWhenJoined=[],this.subscribe=(t,e)=>{this.channel?this.channel.subscribe(t,e):this.callbacksToSubscribeWhenJoined.push({event:t,callback:e})},this.publish=(t,e)=>{var n;el[t.toUpperCase()]?this.channel.publishEventToClient(t,e):null==(n=this.channel)||n.publish(t,e)},this.unsubscribe=(t,e)=>{var n;null==(n=this.channel)||n.unsubscribe(t,e)},this.name="realtime",this.logger=new st("@superviz/sdk/realtime-component");let{localParticipant:t}=this.useStore("global-store");t.subscribe()}connect(t){if(!this.channel)return new Promise((e=>{let{localParticipant:n}=nl();n.subscribe("connect-after-init",(i=>{i.activeComponents.includes("realtime")&&(n.unsubscribe("connect-after-init"),e(this.connect(t)))}))}));let e=this.channels.get(t);return e||(e=new Hd(t,this.ioc,this.localParticipant,this.connectionLimit),this.channels.set(t,e),"STARTED"===this.state)?e:new Promise((t=>{this.subscribe("realtime-component.state-changed",(n=>{"STARTED"===n&&t(e)}))}))}start(){this.logger.log("started"),this.channel=new Hd("default",this.ioc,this.localParticipant,this.connectionLimit),this.channel.subscribe("realtime-channel.state-changed",(t=>{"CONNECTED"===t&&(this.callbacksToSubscribeWhenJoined.forEach((({event:t,callback:e})=>{this.channel.subscribe(t,e)})),this.changeState("STARTED"),this.callbacksToSubscribeWhenJoined=[],this.channel.unsubscribe("realtime-channel.state-changed"),this.participant=this.channel.participant,this.channels.set("default",this.channel))}))}destroy(){this.logger.log("destroyed"),this.changeState("STOPPED"),this.disconnectFromAllChannels()}disconnectFromAllChannels(){this.channels.forEach((t=>t.disconnect()))}changeState(t){var e;this.logger.log("realtime component @ changeState - state changed",t),this.state=t,null==(e=this.channel)||e.publishEventToClient("realtime-component.state-changed",this.state)}};z();var yE=class extends ui{constructor(t){super(),this.options=t,this.onParticipantListUpdate=t=>{if(void 0===this.localParticipantId||""===this.localParticipantId)return;if(!this.initialized)return this.initialized=!0,void this.initializeList();let e=ge(B({},t.data),{tooltip:this.getTooltipData(t.data),controls:this.getControls(t.data)}),{participants:n,extras:i}=this.useStore("who-is-online-store");n.value.some((({id:e})=>e===t.data.id))?this.updateParticipant(e):i.value.some((({id:e})=>e===t.data.id))?this.updateExtra(e):n.value.length<4?n.publish([...n.value,e]):i.publish([...i.value,e])},this.onParticipantLeave=t=>{let{participants:e,extras:n}=this.useStore("who-is-online-store");if(-1===e.value.findIndex((e=>e.id===t.id))){let e=n.value.filter((e=>e.id!==t.id));return void n.publish(e)}let i=e.value.filter((e=>e.id!==t.id));if(n.value.length){i.push(n.value[0]);let t=n.value.slice(1);n.publish(t)}e.publish(i)},this.updateParticipant=t=>{let{participants:e,extras:n}=this.useStore("who-is-online-store");if(t.isPrivate&&t.id!==this.localParticipantId){let i=e.value.filter((({id:e})=>e!==t.id)),r=n.value.splice(0,1);return e.publish([...i,...r]),void n.publish([...n.value])}let i=e.value.map((e=>e.id===t.id?t:e));e.publish(i)},this.updateExtra=t=>{let{extras:e}=this.useStore("who-is-online-store");if(t.isPrivate&&t.id!==this.localParticipantId){let n=e.value.filter((({id:e})=>e!==t.id));return void e.publish(n)}let n=e.value.map((e=>e.id===t.id?t:e));e.publish(n)},this.subscribeToLocalParticipantUpdates=t=>{if(!t.slot)return;this.localParticipantId=t.id;let{privateMode:e,joinedPresence:n}=this.useStore("who-is-online-store"),i=this.isInPresence(t.activeComponents);n.publish(i);let r=this.getParticipant(t);this.room.presence.update(ge(B({},r),{isPrivate:e.value}))},this.goToMousePointer=t=>{var e,n,i;let r=null!=(i=null==(e=t.presence)?void 0:e.id)?i:null==(n=t.detail)?void 0:n.id;r!==this.localParticipantId&&(this.eventBus.publish("realtime.go-to-participant",r),this.publish("who-is-online.go-to-participant",r))},this.followMousePointer=({detail:t})=>{this.eventBus.publish("realtime.local-follow-participant",t.id),this.following&&this.publish("who-is-online.start-following-participant",this.following),this.following||this.publish("who-is-online.stop-following-participant"),"extras"===t.source&&this.highlightParticipantBeingFollowed(),this.updateParticipantsControls(t.id)},this.setPrivate=({detail:{isPrivate:t,id:e}})=>{let{privateMode:n,participants:i}=this.useStore("who-is-online-store"),r=i.value.find((t=>t.id===e));n.publish(t),this.eventBus.publish("realtime.private-mode",t),this.room.presence.update(ge(B({},r),{isPrivate:t})),t&&this.publish("who-is-online.enter-private-mode"),t||this.publish("who-is-online.leave-private-mode")},this.setFollow=t=>{let{id:e}=t.presence;if(e===this.localParticipantId)return;let{data:n}=t,{following:i}=this.useStore("who-is-online-store");i.publish(n),this.followMousePointer({detail:{id:n}})},this.follow=({detail:t})=>{let{everyoneFollowsMe:e}=this.useStore("who-is-online-store");e.publish(!(null==t||!t.id)),this.room.emit("who-is-online.start-follow-me",t),this.following&&this.publish("who-is-online.start-follow-me",this.following),this.following||this.publish("who-is-online.stop-follow-me"),this.updateParticipantsControls(t?.id)},this.stopFollowing=t=>{var e;if(t.id!==(null==(e=this.following)?void 0:e.id))return;let{following:n}=this.useStore("who-is-online-store");n.publish(void 0),this.eventBus.publish("realtime.local-follow-participant",void 0),this.publish("who-is-online.stop-following-participant")},this.gather=t=>{this.room.emit("who-is-online.gather-all",t.detail.id),this.publish("who-is-online.gather-all",t.detail.id)},this.onJoinedRoom=t=>{if(t.id!==this.localParticipantId)return;let{localParticipant:e}=this.useStore("global-store");e.subscribe(this.subscribeToLocalParticipantUpdates)},this.name="whoIsOnline",this.logger=new st("@superviz/sdk/who-is-online-component")}start(){var t,e;let{localParticipant:n}=this.useStore("global-store");this.localParticipantId=n.value.id;let{disablePresenceControls:i,disableGoToParticipant:r,disableFollowParticipant:s,disablePrivateMode:a,disableGatherAll:o,disableFollowMe:l,following:c}=this.useStore("who-is-online-store");c.subscribe(),"object"!=typeof this.options&&(this.position=null!=(t=this.options)?t:"top-right"),"object"==typeof this.options&&(this.position=null!=(e=this.options.position)?e:"top-right",this.setStyles(this.options.styles),i.publish(this.options.disablePresenceControls),r.publish(this.options.disableGoToParticipant),s.publish(this.options.disableFollowParticipant),a.publish(this.options.disablePrivateMode),o.publish(this.options.disableGatherAll),l.publish(this.options.disableFollowMe)),this.subscribeToRealtimeEvents(),this.positionWhoIsOnline(),this.addListeners()}destroy(){this.unsubscribeFromRealtimeEvents(),this.removeListeners(),this.element.remove(),this.element=null,this.initialized=!1;let{destroy:t}=this.useStore("who-is-online-store");t()}addListeners(){this.element.addEventListener("realtime.local-follow-participant",this.followMousePointer),this.element.addEventListener("realtime.go-to-participant",this.goToMousePointer),this.element.addEventListener("realtime.private-mode",this.setPrivate),this.element.addEventListener("realtime.follow-participant",this.follow),this.element.addEventListener("realtime.gather",this.gather)}removeListeners(){this.element.removeEventListener("realtime.local-follow-participant",this.followMousePointer),this.element.removeEventListener("realtime.go-to-participant",this.goToMousePointer),this.element.removeEventListener("realtime.private-mode",this.setPrivate),this.element.removeEventListener("realtime.follow-participant",this.follow),this.element.removeEventListener("realtime.gather",this.gather)}subscribeToRealtimeEvents(){this.room.presence.on(se.UPDATE,this.onParticipantListUpdate),this.room.presence.on(se.LEAVE,this.onParticipantLeave),this.room.presence.on(se.LEAVE,this.stopFollowing),this.room.presence.on(se.JOINED_ROOM,this.onJoinedRoom),this.room.on("who-is-online.gather-all",this.goToMousePointer),this.room.on("who-is-online.start-follow-me",this.setFollow)}unsubscribeFromRealtimeEvents(){this.room.presence.off(se.UPDATE),this.room.presence.off(se.LEAVE),this.room.presence.off(se.JOINED_ROOM),this.room.off("who-is-online.gather-all",this.goToMousePointer),this.room.off("who-is-online.start-follow-me",this.setFollow)}initializeList(){let{participants:t,extras:e}=this.useStore("who-is-online-store");this.room.presence.get((n=>{let i=n.filter((t=>t.data.id)).map((({data:t})=>{let{avatar:e}=t;e||(e=this.getAvatar({avatar:t.avatar,color:t.slot.color,name:t.name,letterColor:t.slot.textColor}));let n=this.getTooltipData(t),i=this.getControls(t);return ge(B({},t),{tooltip:n,controls:i,avatar:e,isLocalParticipant:t.id===this.localParticipantId})}));if(!i.length)return;let r=i.findIndex((t=>t.id===this.localParticipantId)),s=i.splice(r,1)[0],a=i.splice(0,3);t.publish([s,...a]),e.publish(i)}))}setStyles(t=""){if(!t)return;let e=document.createElement("style");e.textContent=t,e.id="superviz-who-is-online-styles",document.head.appendChild(e)}positionWhoIsOnline(){if(this.element=document.createElement("superviz-who-is-online"),Object.values(hd).includes(this.position.toLowerCase())){document.body.appendChild(this.element);let[t,e]=this.position.split("-");return void(this.element.position=`${t}: 20px; ${e}: 40px;`)}let t=document.getElementById(this.position);if(!t)return this.element.position="top: 20px; right: 40px;",void document.body.appendChild(this.element);t.appendChild(this.element),this.element.position="position: relative;"}getParticipant(t){let{avatar:e,activeComponents:n,id:i,name:r,slot:{color:s,textColor:a}}=t,o=this.shouldDisableDropdown({activeComponents:n,participantId:i});return{id:i,name:r,avatar:this.getAvatar({avatar:e,color:s,name:r,letterColor:a}),disableDropdown:o,activeComponents:n,isPrivate:!1}}shouldDisableDropdown({activeComponents:t,participantId:e}){let{joinedPresence:{value:n},disablePresenceControls:{value:i},disableFollowMe:{value:r},disableFollowParticipant:{value:s},disableGoToParticipant:{value:a},disableGatherAll:{value:o},disablePrivateMode:{value:l}}=this.useStore("who-is-online-store");return!!(!1===n||!0===i||e===this.localParticipantId&&r&&l&&o||e!==this.localParticipantId&&s&&a)||!(null!=t&&t.some((t=>t.toLowerCase().includes("presence"))))}getTooltipData(t){let{name:e,disableDropdown:n,id:i}=t,r=i===this.localParticipantId,s={name:e};return r&&(s.name+=" (You)"),!n&&!r&&(s.info="Click to follow"),s}getAvatar({avatar:t,color:e,name:n,letterColor:i}){var r,s;let a=t?.imageUrl;return{imageUrl:a,firstLetter:null!=(s=null==(r=n?.at(0))?void 0:r.toUpperCase())?s:"A",color:e,letterColor:i}}getControls(t){let{disablePresenceControls:e}=this.useStore("who-is-online-store"),{disableDropdown:n,id:i}=t;return e.value||n?[]:i===this.localParticipantId?this.getLocalParticipantControls():this.getOtherParticipantsControls(i)}getOtherParticipantsControls(t){var e;let{disableGoToParticipant:n,disableFollowParticipant:i,following:r}=this.useStore("who-is-online-store"),s=[];if(n.value||s.push({label:"go to",icon:"place"}),!i.value){let n=(null==(e=r.value)?void 0:e.id)===t,i=n?"unfollow":"follow",a=n?"send-off":"send";s.push({label:i,icon:a})}return s}getLocalParticipantControls(){let{disableFollowMe:{value:t},disableGatherAll:{value:e},disablePrivateMode:{value:n},everyoneFollowsMe:{value:i},privateMode:{value:r}}=this.useStore("who-is-online-store"),s=[];if(e||s.push({label:"gather all",icon:"gather"}),!t){let t=i?"send-off":"send",e=i?"stop followers":"everyone follows me";s.push({label:e,icon:t})}if(!n){let t=r?"eye_inative":"eye",e=r?"leave private mode":"private mode";s.push({label:e,icon:t})}return s}updateParticipantsControls(t){let{participants:e}=this.useStore("who-is-online-store"),n=e.value.map((e=>{if(t&&e.id!==t)return e;let{id:n}=e,i=this.getControls(e);return ge(B({},e),{controls:i})}));e.publish(n)}highlightParticipantBeingFollowed(){let{extras:t,participants:e,following:{value:n}}=this.useStore("who-is-online-store"),i=e.value[0],r=t.value.findIndex((t=>t.id===n.id)),s=t.value.splice(r,1)[0];e.value.unshift(i),e.value[1]=s;let a=e.value.pop();t.value.push(a),t.publish(t.value),e.publish(e.value)}isInPresence(t){return t?.some((t=>t.includes("presence")))}};z(),z();var Wp=(t=>(t.BLUR="field.blur",t.FOCUS="field.focus",t.CONTENT_CHANGE="field.content-change",t.INTERACTION="field.interaction",t))(Wp||{}),_E=class extends ui{constructor(t={}){super(),this.fields={},this.fieldsOriginalOutline={},this.focusList={},this.enabledOutlineFields={},this.enabledRealtimeSyncFields={},this.flags={},this.allowedTagNames=["input","textarea"],this.allowedInputTypes=["text","email","date","color","datetime-local","month","number","password","range","search","tel","time","url","week","checkbox","radio"],this.throwError={onInvalidFieldsProp:t=>{throw new Error(`"Fields" property must be either a string or an array of strings. Received type: ${t}`)},onFieldNotFound:t=>{throw new Error(`You must pass the id of an existing element. Element with id ${t} not found`)},onInvalidTagName:t=>{throw new Error(`You can't register an element with tag ${t}. Only the tags "${this.allowedTagNames.join(", ")}" are allowed`)},onInvalidInputType:t=>{throw new Error(`You can't register an input element of type ${t}. Only the types "${this.allowedInputTypes.join(", ")}" are allowed`)},onDeregisterInvalidField:t=>{throw new Error(`You can't deregister field of id ${t}. No field was registered with id ${t} `)}},this.sync=t=>{var e,n;let i=this.fields[t],r=this.hasCheckedProperty(i),s={value:r?i.checked:i.value,color:this.localParticipant.slot.color,fieldId:t,showOutline:this.canUpdateColor(t),syncContent:this.canSyncContent(t),attribute:r?"checked":"value"};null==(e=this.room)||e.emit("field.content-change"+t,s),null==(n=this.room)||n.emit("field.interaction"+t,s)},this.handleInput=t=>{var e,n,i,r;let s=t.target;null==(n=this.room)||n.emit("field.interaction"+s.id,{fieldId:s.id,color:null==(e=this.localParticipant.slot)?void 0:e.color});let a=this.canSyncContent(s.id);if(!a)return;let o={value:s.value,color:null==(i=this.localParticipant.slot)?void 0:i.color,fieldId:s.id,showOutline:this.canUpdateColor(s.id),syncContent:a,attribute:"value"};null==(r=this.room)||r.emit("field.content-change"+s.id,o)},this.handleChange=t=>{var e;let n=t.target;if(!this.canSyncContent(n.id))return;let i={fieldId:n.id,value:n.checked,color:this.localParticipant.slot.color,showOutline:this.canUpdateColor(n.id),syncContent:this.canSyncContent(n.id),attribute:"checked"};null==(e=this.room)||e.emit("field.content-change"+n.id,i)},this.handleFocus=t=>{var e;let n=t.target,i={color:this.localParticipant.slot.color,fieldId:n.id};null==(e=this.room)||e.emit("field.focus"+n.id,i)},this.handleBlur=t=>{var e;let n=t.target,i={fieldId:n.id};null==(e=this.room)||e.emit("field.blur"+n.id,i)},this.removeFieldColor=({presence:t,data:{fieldId:e}})=>{var n,i;(null==(n=this.focusList[e])?void 0:n.id)!==t.id||!this.fields[e]||(this.fields[e].style.outline=null!=(i=this.fieldsOriginalOutline[e])?i:"",delete this.fieldsOriginalOutline[e],delete this.focusList[e])},this.updateFieldColor=({presence:t,data:{color:e,fieldId:n},timestamp:i})=>{var r;let s=null!=(r=this.focusList[n])?r:{},a=!s.id,o=t.id===this.localParticipant.id;if(a&&o)return void(this.focusList[n]={id:t.id,color:e,firstInteraction:i,lastInteraction:i});if(s.id===t.id)return void(this.focusList[n].lastInteraction=i);let l=i-s.lastInteraction>=3e3,c=i-s.firstInteraction>=1e4;if(!(l||c||a))return;this.focusList[n]={id:t.id,color:e,firstInteraction:i,lastInteraction:i};let u=o?this.fieldsOriginalOutline[n]:`1px solid ${e}`;this.fields[n].style.outline=u},this.updateFieldContent=t=>{var e=t,{presence:n,data:{value:i,fieldId:r,color:s,showOutline:a,syncContent:o,attribute:l},timestamp:c}=e,u=ja(e,["presence","data","timestamp"]);this.publish("field.content-change",{value:i,fieldId:r,attribute:l,userId:n.id,userName:n.name,timestamp:c}),o&&this.canSyncContent(r)&&n.id!==this.localParticipant.id&&(this.fields[r][l]=i),a&&this.canUpdateColor(r)&&this.updateFieldColor(B({presence:n,data:{color:s,fieldId:r},timestamp:c},u))},this.publishTypedEvent=({presence:t,data:{fieldId:e,color:n}})=>{this.publish("field.interaction",{fieldId:e,userId:t.id,userName:t.name,color:n})},this.canSyncContent=t=>!this.flags.disableRealtimeSync&&!1!==this.enabledRealtimeSyncFields[t]||!!this.enabledRealtimeSyncFields[t],this.name="formElements",this.logger=new st("@superviz/sdk/presence-input-component");let e=t,{fields:n}=e,i=ja(e,["fields"]);if(this.flags=i??{},"string"==typeof n)return this.validateField(n),void(this.fields[n]=null);Array.isArray(n)?n.forEach((t=>{this.validateField(t),this.fields[t]=null})):void 0!==n&&this.throwError.onInvalidFieldsProp(typeof n)}enableOutline(t){let e=this.fields[t];e&&(this.enabledOutlineFields[t]=!0,this.fieldsOriginalOutline[t]=e.style.outline,e.addEventListener("focus",this.handleFocus),e.addEventListener("blur",this.handleBlur),this.room.on("field.focus"+t,this.updateFieldColor),this.room.on("field.blur"+t,this.removeFieldColor))}disableOutline(t){var e,n;let i=this.fields[t];i&&(this.enabledOutlineFields[t]=!1,i.style.outline=null!=(e=this.fieldsOriginalOutline[t])?e:"",i.removeEventListener("focus",this.handleFocus),i.removeEventListener("blur",this.handleBlur),this.room.off("field.focus"+t,this.updateFieldColor),this.room.off("field.blur"+t,this.removeFieldColor),null==(n=this.room)||n.emit("field.blur"+t,{fieldId:t}))}enableRealtimeSync(t){this.enabledRealtimeSyncFields[t]=!0}disableRealtimeSync(t){this.enabledRealtimeSyncFields[t]=!1}registerField(t){this.validateField(t);let e=document.getElementById(t);this.fields[t]=e,this.addListenersToField(e),this.addRealtimeListenersToField(t),this.fieldsOriginalOutline[t]=e.style.outline}deregisterField(t){var e;this.fields[t]||this.throwError.onDeregisterInvalidField(t),this.removeListenersFromField(this.fields[t]),this.removeRealtimeListenersFromField(t),this.fields[t].style.outline=this.fieldsOriginalOutline[t],this.fields[t]=void 0,delete this.enabledOutlineFields[t],delete this.enabledRealtimeSyncFields[t],delete this.fieldsOriginalOutline[t],delete this.focusList[t],null==(e=this.room)||e.emit("field.blur"+t,{fieldId:t})}start(){let{localParticipant:t}=this.useStore("global-store");t.subscribe(),Object.entries(this.fields).forEach((([t])=>{this.registerField(t)}))}destroy(){this.restoreOutlines(),this.deregisterAllFields(),this.fieldsOriginalOutline=void 0,this.focusList=void 0}addListenersToField(t){let{type:e}=t;this.hasCheckedProperty(t)?t.addEventListener("change",this.handleChange):t.addEventListener("input",this.handleInput),!this.flags.disableOutline&&(t.addEventListener("focus",this.handleFocus),t.addEventListener("blur",this.handleBlur))}addRealtimeListenersToField(t){this.room&&(this.room.on("field.content-change"+t,this.updateFieldContent),this.room.on("field.interaction"+t,this.publishTypedEvent),!this.flags.disableOutline&&(this.room.on("field.focus"+t,this.updateFieldColor),this.room.on("field.blur"+t,this.removeFieldColor)))}removeListenersFromField(t){this.hasCheckedProperty(t)?t.removeEventListener("change",this.handleChange):t.removeEventListener("input",this.handleInput),!this.flags.disableOutline&&(t.removeEventListener("focus",this.handleFocus),t.removeEventListener("blur",this.handleBlur))}removeRealtimeListenersFromField(t){this.room&&(this.room.off("field.content-change"+t,this.updateFieldContent),this.room.off("field.interaction"+t,this.publishTypedEvent),!this.flags.disableOutline&&(this.room.off("field.focus"+t,this.updateFieldColor),this.room.off("field.blur"+t,this.removeFieldColor)))}deregisterAllFields(){Object.keys(this.fields).forEach((t=>{this.deregisterField(t)})),this.fields=void 0}validateField(t){this.validateFieldId(t);let e=document.getElementById(t);this.validateFieldTagName(e),this.validateFieldType(e)}validateFieldTagName(t){let e=t.tagName.toLowerCase();this.allowedTagNames.includes(e)||(this.logger.log("invalid element tagname"),this.throwError.onInvalidTagName(e))}validateFieldType(t){if("input"!==t.tagName.toLowerCase())return;let e=t.getAttribute("type"),n=this.allowedInputTypes.includes(e);e&&!n&&(this.logger.log("invalid input type"),this.throwError.onInvalidInputType(e))}validateFieldId(t){document.getElementById(t)||this.throwError.onFieldNotFound(t)}restoreOutlines(){Object.entries(this.fields).forEach((([t])=>{this.fields[t].style.outline=this.fieldsOriginalOutline[t]}))}hasCheckedProperty(t){let e=t.tagName.toLowerCase(),n=t.getAttribute("type");return"input"===e&&("radio"===n||"checkbox"===n)}canUpdateColor(t){return!this.flags.disableOutline&&!1!==this.enabledOutlineFields[t]||this.enabledOutlineFields[t]}};z();var bE=Zt(Li());z();var xE=1e3,Gp=class{constructor(t,e){this.participants3DObservers=[],this.initializeParticipantsList=()=>{this.room.presence.get((t=>{t.forEach((t=>{this.unthrottledUpdatePresence3D(t.data)}))}))},this.onLocalParticipantJoined=t=>{var e;if(!t.slot||null===(null==(e=t.slot)?void 0:e.index))return void setTimeout((()=>{this.onLocalParticipantJoined(this.localParticipant)}),2e3);if(!this.room.isJoined)return void setTimeout((()=>{this.onLocalParticipantJoined(t)}),2e3);let{hasJoined3D:n}=this.useStore("presence-3d-store");n.publish(!0),this.room.emit("participant-joined",t),this.room.presence.update(t),this.initializeParticipantsList()},this.subscribeToRoomEvents=()=>{this.room.on("participant-joined",this.onJoinedRoom),this.room.presence.on(se.LEAVE,this.onLeaveRoom),this.room.presence.on(se.UPDATE,this.onParticipantUpdate),this.room.presence.on(se.JOINED_ROOM,this.onJoinedPresence)},this.unsubscribeFromRoomEvents=()=>{this.room.off("participant-joined",this.onJoinedRoom),this.room.presence.off(se.LEAVE),this.room.presence.off(se.UPDATE),this.room.presence.off(se.JOINED_ROOM)},this.onJoinedRoom=t=>{let{participants:e}=this.useStore("presence-3d-store"),n=e.value.find((e=>e.id===t.data.id));e.publish([...e.value.filter((e=>e.id!==t.data.id)),B(B({},n),t.data)])},this.onLeaveRoom=t=>{if(t.id===this.localParticipant.id)return this.unsubscribeFromRoomEvents(),void this.useStore("presence-3d-store").destroy();let{participants:e}=this.useStore("presence-3d-store"),n=e.value.filter((e=>e.id!==t.id));e.publish(n)},this.unthrottledUpdatePresence3D=t=>{if(null==t||!t.id)return;let{participants:e,hasJoined3D:n}=this.useStore("presence-3d-store"),i=B(B({},e.value.find((e=>e.id===t.id))),t);e.publish([...e.value.filter((e=>e.id!==t.id)),i]),n.value&&i.id===this.localParticipant.id&&this.room.presence.update(i)},this.onJoinedPresence=t=>{t.id===this.localParticipant.id&&(this.logger.log("participant joined 3D room",t.id,this.localParticipant),this.onLocalParticipantJoined(this.localParticipant))},this.updatePresence3D=(0,bE.throttle)((t=>{this.unthrottledUpdatePresence3D(t)}),xE),this.onParticipantUpdate=t=>{if(t.id===this.localParticipant.id)return;let{participants:e}=this.useStore("presence-3d-store"),n=B(B({},e.value.filter((e=>e.id===t.id))[0]),t.data),i=e.value.map((e=>e.id===t.id?n:e));e.publish(i),this.participants3DObservers[t.id]&&this.participants3DObservers[t.id].publish(n)},this.setParticipantData=t=>{this.updatePresence3D(t)},this.room=t,this.logger=new st("@superviz/sdk/presence3D-manager"),this.useStore=e,this.subscribeToRoomEvents();let{localParticipant:n}=this.useStore("global-store");n.subscribe((t=>{let{participants:e}=this.useStore("presence-3d-store"),n=B(B({},e.value.find((e=>e.id===t.id))),t);e.publish([...e.value.filter((e=>e.id!==t.id)),n]),this.localParticipant=n,this.unthrottledUpdatePresence3D(t)}))}subscribeToUpdates(t,e){this.participants3DObservers[t]||(this.participants3DObservers[t]=new Xe({logger:this.logger})),this.participants3DObservers[t].subscribe(e)}unsubscribeFromUpdates(t,e){this.participants3DObservers[t]&&this.participants3DObservers[t].unsubscribe(e)}get getParticipants(){return this.useStore("presence-3d-store").participants.value}};typeof window<"u"&&(window.SuperVizRoom={init:YM,CommentEvent:ad,MeetingEvent:Qu,DeviceEvent:od,RealtimeEvent:nd,MeetingState:id,MeetingConnectionStatus:rd,MeetingControlsEvent:td,ParticipantEvent:sd,FrameEvent:ed,LayoutMode:Bp,VideoConference:cE,MousePointers:fE,Realtime:vE,Comments:jM,CanvasPin:QM,HTMLPin:tE,WhoIsOnline:yE,FormElements:_E,ParticipantType:Up,LayoutPosition:kp,CamerasPosition:zp,RealtimeComponentState:Vp,RealtimeComponentEvent:Hp,ComponentLifeCycleEvent:el,WhoIsOnlineEvent:ld,StoreType:pd,PresenceEvents:se,FieldEvents:Wp,PinMode:dd,Comment:Comment});var Cf=Ka(Xp()),ff="167",mf=300,qp=1e3,fo=1001,$p=1002,wE=1006,SE=1008,ME=1009,EE=1023,bo=2300,jl=2301,Gl=2302,Zp=2400,Yp=2401,Jp=2402,gf="",Zn="srgb",pc="srgb-linear",AE="display-p3",vf="display-p3-linear",Ql="linear",Kp="srgb",jp="rec709",Qp="p3",mo=2e3,ef=2001,xo=class{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;let n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;let n=this._listeners[t];if(void 0!==n){let t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;let e=this._listeners[t.type];if(void 0!==e){t.target=this;let n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}},lt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],sR=Math.PI/180,rR=180/Math.PI;function fc(){let t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(lt[255&t]+lt[t>>8&255]+lt[t>>16&255]+lt[t>>24&255]+"-"+lt[255&e]+lt[e>>8&255]+"-"+lt[e>>16&15|64]+lt[e>>24&255]+"-"+lt[63&n|128]+lt[n>>8&255]+"-"+lt[n>>16&255]+lt[n>>24&255]+lt[255&i]+lt[i>>8&255]+lt[i>>16&255]+lt[i>>24&255]).toLowerCase()}function bt(t,e,n){return Math.max(e,Math.min(n,t))}function TE(t,e){return(t%e+e)%e}function Xl(t,e,n){return(1-n)*t+n*e}var pn=class t{constructor(e=0,n=0){t.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,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,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;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,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,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,e){return this.x=t.x-e.x,this.y=t.y-e.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){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(bt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},_e=class t{constructor(e,n,i,r,s,a,o,l,c){t.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,n,i,r,s,a,o,l,c)}set(t,e,n,i,r,s,a,o,l){let c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],u=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],y=i[7],b=i[2],w=i[5],x=i[8];return r[0]=s*f+a*v+o*b,r[3]=s*m+a*_+o*w,r[6]=s*g+a*y+o*x,r[1]=l*f+c*v+u*b,r[4]=l*m+c*_+u*w,r[7]=l*g+c*y+u*x,r[2]=h*f+d*v+p*b,r[5]=h*m+d*_+p*w,r[8]=h*g+d*y+p*x,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=c*s-a*l,h=a*o-c*r,d=l*r-s*o,p=e*u+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return t[0]=u*f,t[1]=(i*l-c*n)*f,t[2]=(a*n-i*s)*f,t[3]=h*f,t[4]=(c*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=d*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){let o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ql.makeScale(t,e)),this}rotate(t){return this.premultiply(ql.makeRotation(-t)),this}translate(t,e){return this.premultiply(ql.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}},ql=new _e;function tf(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}var nf=(new _e).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),sf=(new _e).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Hs={[pc]:{transfer:Ql,primaries:jp,luminanceCoefficients:[.2126,.7152,.0722],toReference:t=>t,fromReference:t=>t},[Zn]:{transfer:Kp,primaries:jp,luminanceCoefficients:[.2126,.7152,.0722],toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[vf]:{transfer:Ql,primaries:Qp,luminanceCoefficients:[.2289,.6917,.0793],toReference:t=>t.applyMatrix3(sf),fromReference:t=>t.applyMatrix3(nf)},[AE]:{transfer:Kp,primaries:Qp,luminanceCoefficients:[.2289,.6917,.0793],toReference:t=>t.convertSRGBToLinear().applyMatrix3(sf),fromReference:t=>t.applyMatrix3(nf).convertLinearToSRGB()}},CE=new Set([pc,vf]),tn={enabled:!0,_workingColorSpace:pc,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!CE.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(!1===this.enabled||e===n||!e||!n)return t;let i=Hs[e].toReference;return(0,Hs[n].fromReference)(i(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return Hs[t].primaries},getTransfer:function(t){return t===gf?Ql:Hs[t].transfer},getLuminanceCoefficients:function(t,e=this._workingColorSpace){return t.fromArray(Hs[e].luminanceCoefficients)}};function $i(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function $l(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}var Hi,ec=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Hi&&(Hi=tf("canvas")),Hi.width=t.width,Hi.height=t.height;let n=Hi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Hi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.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){let e=tf("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*$i(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){let e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*$i(e[t]/255)):e[t]=$i(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},PE=0,tc=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:PE++}),this.uuid=fc(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){let e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(Zl(i[e].image)):t.push(Zl(i[e]))}else t=Zl(i);n.url=t}return e||(t.images[this.uuid]=n),n}};function Zl(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?ec.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var RE=0,Gs=class t extends xo{constructor(e=t.DEFAULT_IMAGE,n=t.DEFAULT_MAPPING,i=fo,r=fo,s=wE,a=SE,o=EE,l=ME,c=t.DEFAULT_ANISOTROPY,u=gf){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:RE++}),this.uuid=fc(),this.name="",this.source=new tc(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new pn(0,0),this.repeat=new pn(1,1),this.center=new pn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new _e,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){let e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];let n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==mf)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case qp:t.x=t.x-Math.floor(t.x);break;case fo:t.x=t.x<0?0:1;break;case $p:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case qp:t.y=t.y-Math.floor(t.y);break;case fo:t.y=t.y<0?0:1;break;case $p:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}};Gs.DEFAULT_IMAGE=null,Gs.DEFAULT_MAPPING=mf,Gs.DEFAULT_ANISOTROPY=1;var fn=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,s,a){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],h=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=c,void(t[e+3]=u);if(1===a)return t[e+0]=h,t[e+1]=d,t[e+2]=p,void(t[e+3]=f);if(u!==f||o!==h||l!==d||c!==p){let t=1-a,e=o*h+l*d+c*p+u*f,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){let r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}let r=a*n;if(o=o*t+h*r,l=l*t+d*r,c=c*t+p*r,u=u*t+f*r,t===1-a){let t=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=t,l*=t,c*=t,u*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,s){let a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=r[s],h=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*u+o*d-l*h,t[e+1]=o*p+c*h+l*u-a*d,t[e+2]=l*p+c*d+a*h-o*u,t[e+3]=c*p-a*u-o*h-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,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,e=!0){let n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),u=a(r/2),h=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"YXZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"ZXY":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"ZYX":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"YZX":this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p;break;case"XZY":this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],u=e[10],h=n+a+u;if(h>0){let t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>u){let t=2*Math.sqrt(1+n-a-u);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>u){let t=2*Math.sqrt(1+a-n-u);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{let t=2*Math.sqrt(1+u-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(bt(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(0===n)return this;let i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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 0===t?(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,e){let n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);let n=this._x,i=this._y,r=this._z,s=this._w,a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;let o=1-a*a;if(o<=Number.EPSILON){let t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}let l=Math.sqrt(o),c=Math.atan2(l,a),u=Math.sin((1-e)*c)/l,h=Math.sin(e*c)/l;return this._w=s*u+this._w*h,this._x=n*u+this._x*h,this._y=i*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),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}},be=class t{constructor(e=0,n=0,i=0){t.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,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,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;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,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,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,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.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,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(rf.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(rf.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),c=2*(a*e-r*i),u=2*(r*n-s*e);return this.x=e+o*l+s*u-a*c,this.y=n+o*c+a*l-r*u,this.z=i+o*u+r*c-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,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,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){let e=t.lengthSq();if(0===e)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Yl.copy(this).projectOnVector(t),this.sub(Yl)}reflect(t){return this.sub(Yl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(bt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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,e,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}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,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Yl=new be,rf=new fn,Yn=class t{constructor(e,n,i,r,s,a,o,l,c,u,h,d,p,f,m,g){t.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,n,i,r,s,a,o,l,c,u,h,d,p,f,m,g)}set(t,e,n,i,r,s,a,o,l,c,u,h,d,p,f,m){let g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new t).fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,i=1/Wi.setFromMatrixColumn(t,0).length(),r=1/Wi.setFromMatrixColumn(t,1).length(),s=1/Wi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),u=Math.sin(r);if("XYZ"===t.order){let t=s*c,n=s*u,i=a*c,r=a*u;e[0]=o*c,e[4]=-o*u,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){let t=o*c,n=o*u,i=l*c,r=l*u;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*u,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){let t=o*c,n=o*u,i=l*c,r=l*u;e[0]=t-r*a,e[4]=-s*u,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){let t=s*c,n=s*u,i=a*c,r=a*u;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*u,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){let t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*u,e[8]=i*u+n,e[1]=u,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*u+i,e[10]=t-r*u}else if("XZY"===t.order){let t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-u,e[8]=l*c,e[1]=t*u+r,e[5]=s*c,e[9]=n*u-i,e[2]=i*u-n,e[6]=a*c,e[10]=r*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(IE,t,LE)}lookAt(t,e,n){let i=this.elements;return Rt.subVectors(t,e),0===Rt.lengthSq()&&(Rt.z=1),Rt.normalize(),qn.crossVectors(n,Rt),0===qn.lengthSq()&&(1===Math.abs(n.z)?Rt.x+=1e-4:Rt.z+=1e-4,Rt.normalize(),qn.crossVectors(n,Rt)),qn.normalize(),go.crossVectors(Rt,qn),i[0]=qn.x,i[4]=go.x,i[8]=Rt.x,i[1]=qn.y,i[5]=go.y,i[9]=Rt.y,i[2]=qn.z,i[6]=go.z,i[10]=Rt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],y=n[11],b=n[15],w=i[0],x=i[4],S=i[8],E=i[12],C=i[1],M=i[5],P=i[9],A=i[13],T=i[2],I=i[6],O=i[10],L=i[14],N=i[3],R=i[7],k=i[11],D=i[15];return r[0]=s*w+a*C+o*T+l*N,r[4]=s*x+a*M+o*I+l*R,r[8]=s*S+a*P+o*O+l*k,r[12]=s*E+a*A+o*L+l*D,r[1]=c*w+u*C+h*T+d*N,r[5]=c*x+u*M+h*I+d*R,r[9]=c*S+u*P+h*O+d*k,r[13]=c*E+u*A+h*L+d*D,r[2]=p*w+f*C+m*T+g*N,r[6]=p*x+f*M+m*I+g*R,r[10]=p*S+f*P+m*O+g*k,r[14]=p*E+f*A+m*L+g*D,r[3]=v*w+_*C+y*T+b*N,r[7]=v*x+_*M+y*I+b*R,r[11]=v*S+_*P+y*O+b*k,r[15]=v*E+_*A+y*L+b*D,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],u=t[6],h=t[10],d=t[14];return t[3]*(+r*o*u-i*l*u-r*a*h+n*l*h+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*h+r*s*h-i*s*d+i*l*c-r*o*c)+t[11]*(+e*l*u-e*a*d-r*s*u+n*s*d+r*a*c-n*l*c)+t[15]*(-i*a*c-e*o*u+e*a*h+i*s*u-n*s*h+n*o*c)}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(t,e,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],v=u*m*l-f*h*l+f*o*d-a*m*d-u*o*g+a*h*g,_=p*h*l-c*m*l-p*o*d+s*m*d+c*o*g-s*h*g,y=c*f*l-p*u*l+p*a*d-s*f*d-c*a*g+s*u*g,b=p*u*o-c*f*o-p*a*h+s*f*h+c*a*m-s*u*m,w=e*v+n*_+i*y+r*b;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let x=1/w;return t[0]=v*x,t[1]=(f*h*r-u*m*r-f*i*d+n*m*d+u*i*g-n*h*g)*x,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*x,t[3]=(u*o*r-a*h*r-u*i*l+n*h*l+a*i*d-n*o*d)*x,t[4]=_*x,t[5]=(c*m*r-p*h*r+p*i*d-e*m*d-c*i*g+e*h*g)*x,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*x,t[7]=(s*h*r-c*o*r+c*i*l-e*h*l-s*i*d+e*o*d)*x,t[8]=y*x,t[9]=(p*u*r-c*f*r-p*n*d+e*f*d+c*n*g-e*u*g)*x,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*x,t[11]=(c*a*r-s*u*r-c*n*l+e*u*l+s*n*d-e*a*d)*x,t[12]=b*x,t[13]=(c*f*i-p*u*i+p*n*h-e*f*h-c*n*m+e*u*m)*x,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*x,t[15]=(s*u*i-c*a*i+c*n*o-e*u*o-s*n*h+e*a*h)*x,this}scale(t){let e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,u=a+a,h=r*l,d=r*c,p=r*u,f=s*c,m=s*u,g=a*u,v=o*l,_=o*c,y=o*u,b=n.x,w=n.y,x=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+y)*b,i[2]=(p-_)*b,i[3]=0,i[4]=(d-y)*w,i[5]=(1-(h+g))*w,i[6]=(m+v)*w,i[7]=0,i[8]=(p+_)*x,i[9]=(m-v)*x,i[10]=(1-(h+f))*x,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements,r=Wi.set(i[0],i[1],i[2]).length(),s=Wi.set(i[4],i[5],i[6]).length(),a=Wi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],nn.copy(this);let o=1/r,l=1/s,c=1/a;return nn.elements[0]*=o,nn.elements[1]*=o,nn.elements[2]*=o,nn.elements[4]*=l,nn.elements[5]*=l,nn.elements[6]*=l,nn.elements[8]*=c,nn.elements[9]*=c,nn.elements[10]*=c,e.setFromRotationMatrix(nn),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=mo){let o,l,c=this.elements,u=2*r/(e-t),h=2*r/(n-i),d=(e+t)/(e-t),p=(n+i)/(n-i);if(a===mo)o=-(s+r)/(s-r),l=-2*s*r/(s-r);else{if(a!==ef)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);o=-s/(s-r),l=-s*r/(s-r)}return c[0]=u,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=o,c[14]=l,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=mo){let o,l,c=this.elements,u=1/(e-t),h=1/(n-i),d=1/(s-r),p=(e+t)*u,f=(n+i)*h;if(a===mo)o=(s+r)*d,l=-2*d;else{if(a!==ef)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);o=r*d,l=-1*d}return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=l,c[14]=-o,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},Wi=new be,nn=new Yn,IE=new be(0,0,0),LE=new be(1,1,1),qn=new be,go=new be,Rt=new be,of=new Yn,af=new fn,wo=class t{constructor(e=0,n=0,i=0,r=t.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}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,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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,e=this._order,n=!0){let i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],u=i[2],h=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(bt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-bt(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(bt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-bt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(bt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-bt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return of.makeRotationFromQuaternion(t),this.setFromRotationMatrix(of,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return af.setFromEuler(this),this.setFromQuaternion(af,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],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+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}};wo.DEFAULT_ORDER="XYZ";var nc=class{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return!!(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}},OE=0,lf=new be,Gi=new fn,Rn=new Yn,vo=new be,Ws=new be,DE=new be,NE=new fn,cf=new be(1,0,0),hf=new be(0,1,0),uf=new be(0,0,1),df={type:"added"},FE={type:"removed"},Xi={type:"childadded",child:null},Jl={type:"childremoved",child:null},Xs=class t extends xo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:OE++}),this.uuid=fc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=t.DEFAULT_UP.clone();let e=new be,n=new wo,i=new fn,r=new be(1,1,1);n._onChange((function(){i.setFromEuler(n,!1)})),i._onChange((function(){n.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Yn},normalMatrix:{value:new _e}}),this.matrix=new Yn,this.matrixWorld=new Yn,this.matrixAutoUpdate=t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Gi.setFromAxisAngle(t,e),this.quaternion.multiply(Gi),this}rotateOnWorldAxis(t,e){return Gi.setFromAxisAngle(t,e),this.quaternion.premultiply(Gi),this}rotateX(t){return this.rotateOnAxis(cf,t)}rotateY(t){return this.rotateOnAxis(hf,t)}rotateZ(t){return this.rotateOnAxis(uf,t)}translateOnAxis(t,e){return lf.copy(t).applyQuaternion(this.quaternion),this.position.add(lf.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(cf,t)}translateY(t){return this.translateOnAxis(hf,t)}translateZ(t){return this.translateOnAxis(uf,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Rn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?vo.copy(t):vo.set(t,e,n);let i=this.parent;this.updateWorldMatrix(!0,!1),Ws.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Rn.lookAt(Ws,vo,this.up):Rn.lookAt(vo,Ws,this.up),this.quaternion.setFromRotationMatrix(Rn),i&&(Rn.extractRotation(i.matrixWorld),Gi.setFromRotationMatrix(Rn),this.quaternion.premultiply(Gi.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(df),Xi.child=t,this.dispatchEvent(Xi),Xi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}let e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(FE),Jl.child=t,this.dispatchEvent(Jl),Jl.child=null),this}removeFromParent(){let t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Rn.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Rn.multiply(t.parent.matrixWorld)),t.applyMatrix4(Rn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(df),Xi.child=t,this.dispatchEvent(Xi),Xi.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){let i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ws,t,DE),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ws,NE,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){let t=this.children;for(let e=0,n=t.length;e<n;e++)t[e].updateWorldMatrix(!1,!0)}}toJSON(t){let e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);let e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){let n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){let i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){let e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){let n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){let e=s(t.geometries),i=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),c=s(t.animations),u=s(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=i,n;function s(t){let e=[];for(let n in t){let i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!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)),!0===e)for(let e=0;e<t.children.length;e++){let n=t.children[e];this.add(n.clone())}return this}};Xs.DEFAULT_UP=new be(0,1,0),Xs.DEFAULT_MATRIX_AUTO_UPDATE=!0,Xs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var yf={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},$n={h:0,s:0,l:0},yo={h:0,s:0,l:0};function Kl(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}var rt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){let e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Zn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,tn.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=tn.workingColorSpace){return this.r=t,this.g=e,this.b=n,tn.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=tn.workingColorSpace){if(t=TE(t,1),e=bt(e,0,1),n=bt(n,0,1),0===e)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Kl(r,i,t+1/3),this.g=Kl(r,i,t),this.b=Kl(r,i,t-1/3)}return tn.toWorkingColorSpace(this,i),this}setStyle(t,e=Zn){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Zn){let n=yf[t.toLowerCase()];return void 0!==n?this.setHex(n,e):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=$i(t.r),this.g=$i(t.g),this.b=$i(t.b),this}copyLinearToSRGB(t){return this.r=$l(t.r),this.g=$l(t.g),this.b=$l(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Zn){return tn.fromWorkingColorSpace(ct.copy(this),t),65536*Math.round(bt(255*ct.r,0,255))+256*Math.round(bt(255*ct.g,0,255))+Math.round(bt(255*ct.b,0,255))}getHexString(t=Zn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=tn.workingColorSpace){tn.fromWorkingColorSpace(ct.copy(this),e);let n,i,r=ct.r,s=ct.g,a=ct.b,o=Math.max(r,s,a),l=Math.min(r,s,a),c=(l+o)/2;if(l===o)n=0,i=0;else{let t=o-l;switch(i=c<=.5?t/(o+l):t/(2-o-l),o){case r:n=(s-a)/t+(s<a?6:0);break;case s:n=(a-r)/t+2;break;case a:n=(r-s)/t+4}n/=6}return t.h=n,t.s=i,t.l=c,t}getRGB(t,e=tn.workingColorSpace){return tn.fromWorkingColorSpace(ct.copy(this),e),t.r=ct.r,t.g=ct.g,t.b=ct.b,t}getStyle(t=Zn){tn.fromWorkingColorSpace(ct.copy(this),t);let e=ct.r,n=ct.g,i=ct.b;return t!==Zn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL($n),this.setHSL($n.h+t,$n.s+e,$n.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL($n),t.getHSL(yo);let n=Xl($n.h,yo.h,e),i=Xl($n.s,yo.s,e),r=Xl($n.l,yo.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},ct=new rt;function UE(t){let e={};for(let n in t){e[n]={};for(let i in t[n]){let r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function _t(t){let e={};for(let n=0;n<t.length;n++){let i=UE(t[n]);for(let t in i)e[t]=i[t]}return e}rt.NAMES=yf;var kE="#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",BE="#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",zE="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",VE="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",HE="#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",WE="#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",GE="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",XE="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",qE="#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",$E="#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",ZE="vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",YE="vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",JE="float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",KE="#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660,  0.0556434,\n\t\t-1.5371385,  1.8760108, -0.2040259,\n\t\t-0.4985314,  0.0415560,  1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",jE="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",QE="#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",eA="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",tA="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",nA="#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",iA="#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",sA="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",rA="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",oA="#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",aA="#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",lA="#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",cA="vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",hA="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",uA="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",dA="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",pA="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",fA="gl_FragColor = linearToOutputTexel( gl_FragColor );",mA="\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",gA="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",vA="#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",yA="#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",_A="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",bA="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",xA="#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",wA="#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",SA="#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",MA="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",EA="#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",AA="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",TA="LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",CA="varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",PA="uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",RA="#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",IA="ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",LA="varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",OA="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",DA="varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",NA="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",FA="struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n    float x2 = x * x;\n    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",UA="\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",kA="#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",BA="#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",zA="#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",VA="#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",HA="#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",WA="#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",GA="#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",XA="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",qA="#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",$A="#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",ZA="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",YA="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",JA="#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",KA="#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",jA="#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",QA="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",eT="#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",tT="float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",nT="#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",iT="#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",sT="#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",rT="#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",oT="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",aT="#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",lT="#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",cT="#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",hT="#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",uT="#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",dT="vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",pT="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",fT="vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",mT="#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",gT="#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",vT="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",yT="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",_T="#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",bT="#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",xT="#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",wT="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",ST="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",MT="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",ET="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",AT="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",TT="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",CT="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",PT="#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",RT="#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(  1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,  1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,  1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",IT="#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",LT="#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",OT="#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",DT="#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",NT="#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",FT="#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",UT="varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",kT="uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",BT="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",zT="#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",VT="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",HT="uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",WT="#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",GT="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",XT="#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",qT="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",$T="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",ZT="uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",YT="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",JT="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",KT="#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",jT="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",QT="#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",eC="#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",tC="#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",nC="#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",iC="#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",sC="#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",rC="#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",oC="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",aC="#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",lC="#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",cC="#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",hC="#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",uC="uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",dC="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",pC="#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",fC="uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",mC="uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",gC="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",we={alphahash_fragment:kE,alphahash_pars_fragment:BE,alphamap_fragment:zE,alphamap_pars_fragment:VE,alphatest_fragment:HE,alphatest_pars_fragment:WE,aomap_fragment:GE,aomap_pars_fragment:XE,batching_pars_vertex:qE,batching_vertex:$E,begin_vertex:ZE,beginnormal_vertex:YE,bsdfs:JE,iridescence_fragment:KE,bumpmap_pars_fragment:jE,clipping_planes_fragment:QE,clipping_planes_pars_fragment:eA,clipping_planes_pars_vertex:tA,clipping_planes_vertex:nA,color_fragment:iA,color_pars_fragment:sA,color_pars_vertex:rA,color_vertex:oA,common:aA,cube_uv_reflection_fragment:lA,defaultnormal_vertex:cA,displacementmap_pars_vertex:hA,displacementmap_vertex:uA,emissivemap_fragment:dA,emissivemap_pars_fragment:pA,colorspace_fragment:fA,colorspace_pars_fragment:mA,envmap_fragment:gA,envmap_common_pars_fragment:vA,envmap_pars_fragment:yA,envmap_pars_vertex:_A,envmap_physical_pars_fragment:RA,envmap_vertex:bA,fog_vertex:xA,fog_pars_vertex:wA,fog_fragment:SA,fog_pars_fragment:MA,gradientmap_pars_fragment:EA,lightmap_pars_fragment:AA,lights_lambert_fragment:TA,lights_lambert_pars_fragment:CA,lights_pars_begin:PA,lights_toon_fragment:IA,lights_toon_pars_fragment:LA,lights_phong_fragment:OA,lights_phong_pars_fragment:DA,lights_physical_fragment:NA,lights_physical_pars_fragment:FA,lights_fragment_begin:UA,lights_fragment_maps:kA,lights_fragment_end:BA,logdepthbuf_fragment:zA,logdepthbuf_pars_fragment:VA,logdepthbuf_pars_vertex:HA,logdepthbuf_vertex:WA,map_fragment:GA,map_pars_fragment:XA,map_particle_fragment:qA,map_particle_pars_fragment:$A,metalnessmap_fragment:ZA,metalnessmap_pars_fragment:YA,morphinstance_vertex:JA,morphcolor_vertex:KA,morphnormal_vertex:jA,morphtarget_pars_vertex:QA,morphtarget_vertex:eT,normal_fragment_begin:tT,normal_fragment_maps:nT,normal_pars_fragment:iT,normal_pars_vertex:sT,normal_vertex:rT,normalmap_pars_fragment:oT,clearcoat_normal_fragment_begin:aT,clearcoat_normal_fragment_maps:lT,clearcoat_pars_fragment:cT,iridescence_pars_fragment:hT,opaque_fragment:uT,packing:dT,premultiplied_alpha_fragment:pT,project_vertex:fT,dithering_fragment:mT,dithering_pars_fragment:gT,roughnessmap_fragment:vT,roughnessmap_pars_fragment:yT,shadowmap_pars_fragment:_T,shadowmap_pars_vertex:bT,shadowmap_vertex:xT,shadowmask_pars_fragment:wT,skinbase_vertex:ST,skinning_pars_vertex:MT,skinning_vertex:ET,skinnormal_vertex:AT,specularmap_fragment:TT,specularmap_pars_fragment:CT,tonemapping_fragment:PT,tonemapping_pars_fragment:RT,transmission_fragment:IT,transmission_pars_fragment:LT,uv_pars_fragment:OT,uv_pars_vertex:DT,uv_vertex:NT,worldpos_vertex:FT,background_vert:UT,background_frag:kT,backgroundCube_vert:BT,backgroundCube_frag:zT,cube_vert:VT,cube_frag:HT,depth_vert:WT,depth_frag:GT,distanceRGBA_vert:XT,distanceRGBA_frag:qT,equirect_vert:$T,equirect_frag:ZT,linedashed_vert:YT,linedashed_frag:JT,meshbasic_vert:KT,meshbasic_frag:jT,meshlambert_vert:QT,meshlambert_frag:eC,meshmatcap_vert:tC,meshmatcap_frag:nC,meshnormal_vert:iC,meshnormal_frag:sC,meshphong_vert:rC,meshphong_frag:oC,meshphysical_vert:aC,meshphysical_frag:lC,meshtoon_vert:cC,meshtoon_frag:hC,points_vert:uC,points_frag:dC,shadow_vert:pC,shadow_frag:fC,sprite_vert:mC,sprite_frag:gC},G={common:{diffuse:{value:new rt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new _e},alphaMap:{value:null},alphaMapTransform:{value:new _e},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new _e}},envmap:{envMap:{value:null},envMapRotation:{value:new _e},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new _e}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new _e}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new _e},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new _e},normalScale:{value:new pn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new _e},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new _e}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new _e}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new _e}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new rt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new rt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new _e},alphaTest:{value:0},uvTransform:{value:new _e}},sprite:{diffuse:{value:new rt(16777215)},opacity:{value:1},center:{value:new pn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new _e},alphaMap:{value:null},alphaMapTransform:{value:new _e},alphaTest:{value:0}}},pf={basic:{uniforms:_t([G.common,G.specularmap,G.envmap,G.aomap,G.lightmap,G.fog]),vertexShader:we.meshbasic_vert,fragmentShader:we.meshbasic_frag},lambert:{uniforms:_t([G.common,G.specularmap,G.envmap,G.aomap,G.lightmap,G.emissivemap,G.bumpmap,G.normalmap,G.displacementmap,G.fog,G.lights,{emissive:{value:new rt(0)}}]),vertexShader:we.meshlambert_vert,fragmentShader:we.meshlambert_frag},phong:{uniforms:_t([G.common,G.specularmap,G.envmap,G.aomap,G.lightmap,G.emissivemap,G.bumpmap,G.normalmap,G.displacementmap,G.fog,G.lights,{emissive:{value:new rt(0)},specular:{value:new rt(1118481)},shininess:{value:30}}]),vertexShader:we.meshphong_vert,fragmentShader:we.meshphong_frag},standard:{uniforms:_t([G.common,G.envmap,G.aomap,G.lightmap,G.emissivemap,G.bumpmap,G.normalmap,G.displacementmap,G.roughnessmap,G.metalnessmap,G.fog,G.lights,{emissive:{value:new rt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:we.meshphysical_vert,fragmentShader:we.meshphysical_frag},toon:{uniforms:_t([G.common,G.aomap,G.lightmap,G.emissivemap,G.bumpmap,G.normalmap,G.displacementmap,G.gradientmap,G.fog,G.lights,{emissive:{value:new rt(0)}}]),vertexShader:we.meshtoon_vert,fragmentShader:we.meshtoon_frag},matcap:{uniforms:_t([G.common,G.bumpmap,G.normalmap,G.displacementmap,G.fog,{matcap:{value:null}}]),vertexShader:we.meshmatcap_vert,fragmentShader:we.meshmatcap_frag},points:{uniforms:_t([G.points,G.fog]),vertexShader:we.points_vert,fragmentShader:we.points_frag},dashed:{uniforms:_t([G.common,G.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:we.linedashed_vert,fragmentShader:we.linedashed_frag},depth:{uniforms:_t([G.common,G.displacementmap]),vertexShader:we.depth_vert,fragmentShader:we.depth_frag},normal:{uniforms:_t([G.common,G.bumpmap,G.normalmap,G.displacementmap,{opacity:{value:1}}]),vertexShader:we.meshnormal_vert,fragmentShader:we.meshnormal_frag},sprite:{uniforms:_t([G.sprite,G.fog]),vertexShader:we.sprite_vert,fragmentShader:we.sprite_frag},background:{uniforms:{uvTransform:{value:new _e},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:we.background_vert,fragmentShader:we.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new _e}},vertexShader:we.backgroundCube_vert,fragmentShader:we.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:we.cube_vert,fragmentShader:we.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:we.equirect_vert,fragmentShader:we.equirect_frag},distanceRGBA:{uniforms:_t([G.common,G.displacementmap,{referencePosition:{value:new be},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:we.distanceRGBA_vert,fragmentShader:we.distanceRGBA_frag},shadow:{uniforms:_t([G.lights,G.fog,{color:{value:new rt(0)},opacity:{value:1}}]),vertexShader:we.shadow_vert,fragmentShader:we.shadow_frag}};pf.physical={uniforms:_t([pf.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new _e},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new _e},clearcoatNormalScale:{value:new pn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new _e},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new _e},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new _e},sheen:{value:0},sheenColor:{value:new rt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new _e},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new _e},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new _e},transmissionSamplerSize:{value:new pn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new _e},attenuationDistance:{value:0},attenuationColor:{value:new rt(0)},specularColor:{value:new rt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new _e},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new _e},anisotropyVector:{value:new pn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new _e}}]),vertexShader:we.meshphysical_vert,fragmentShader:we.meshphysical_frag};var di=(1+Math.sqrt(5))/2,qi=1/di,oR=[new be(-di,qi,0),new be(di,qi,0),new be(-qi,0,di),new be(qi,0,di),new be(0,di,-qi),new be(0,di,qi),new be(-1,1,-1),new be(1,1,-1),new be(-1,1,1),new be(1,1,1)],aR=new Float32Array(16),lR=new Float32Array(9),cR=new Float32Array(4);function _o(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function vC(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}var Zi=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let s;n:{i:if(!(t<i)){for(let s=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(r=i,i=e[++n],t<i)break e}s=e.length;break n}if(t>=r)break t;{let a=e[1];t<a&&(n=2,r=a);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(i=r,r=e[--n-1],t>=r)break e}s=n,n=0}}for(;n<s;){let i=n+s>>>1;t<e[i]?s=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},ic=class extends Zi{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Zp,endingEnd:Zp}}intervalChanged_(t,e,n){let i=this.parameterPositions,r=t-2,s=t+1,a=i[r],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case Yp:r=t,a=2*e-n;break;case Jp:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case Yp:s=t,o=2*n-e;break;case Jp:s=1,o=n+i[1]-i[0];break;default:s=t-1,o=e}let l=.5*(n-e),c=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(t,e,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),f=p*p,m=f*p,g=-h*m+2*h*f-h*p,v=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,_=(-1-d)*m+(1.5+d)*f+.5*p,y=d*m-d*f;for(let t=0;t!==a;++t)r[t]=g*s[c+t]+v*s[l+t]+_*s[o+t]+y*s[u+t];return r}},sc=class extends Zi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=(n-e)/(i-e),u=1-c;for(let t=0;t!==a;++t)r[t]=s[l+t]*u+s[o+t]*c;return r}},rc=class extends Zi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},sn=class{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=_o(e,this.TimeBufferType),this.values=_o(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e,n=t.constructor;if(n.toJSON!==this.toJSON)e=n.toJSON(t);else{e={name:t.name,times:_o(t.times,Array),values:_o(t.values,Array)};let n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e}InterpolantFactoryMethodDiscrete(t){return new rc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new sc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ic(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case bo:e=this.InterpolantFactoryMethodDiscrete;break;case jl:e=this.InterpolantFactoryMethodLinear;break;case Gl:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){let e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return bo;case this.InterpolantFactoryMethodLinear:return jl;case this.InterpolantFactoryMethodSmooth:return Gl}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,r=0,s=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==s&&n[s]>e;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);let t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){let i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&vC(i))for(let e=0,n=i.length;e!==n;++e){let n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Gl,r=t.length-1,s=1;for(let a=1;a<r;++a){let r=!1,o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(i)r=!0;else{let t=a*n,i=t-n,s=t+n;for(let a=0;a!==n;++a){let n=e[t+a];if(n!==e[i+a]||n!==e[s+a]){r=!0;break}}}if(r){if(a!==s){t[s]=t[a];let i=a*n,r=s*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}};sn.prototype.TimeBufferType=Float32Array,sn.prototype.ValueBufferType=Float32Array,sn.prototype.DefaultInterpolation=jl;var pi=class extends sn{constructor(t,e,n){super(t,e,n)}};pi.prototype.ValueTypeName="bool",pi.prototype.ValueBufferType=Array,pi.prototype.DefaultInterpolation=bo,pi.prototype.InterpolantFactoryMethodLinear=void 0,pi.prototype.InterpolantFactoryMethodSmooth=void 0;var oc=class extends sn{};oc.prototype.ValueTypeName="color";var ac=class extends sn{};ac.prototype.ValueTypeName="number";var lc=class extends Zi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e),l=t*a;for(let t=l+a;l!==t;l+=4)fn.slerpFlat(r,0,s,l-a,s,l,o);return r}},So=class extends sn{InterpolantFactoryMethodLinear(t){return new lc(this.times,this.values,this.getValueSize(),t)}};So.prototype.ValueTypeName="quaternion",So.prototype.InterpolantFactoryMethodSmooth=void 0;var fi=class extends sn{constructor(t,e,n){super(t,e,n)}};fi.prototype.ValueTypeName="string",fi.prototype.ValueBufferType=Array,fi.prototype.DefaultInterpolation=bo,fi.prototype.InterpolantFactoryMethodLinear=void 0,fi.prototype.InterpolantFactoryMethodSmooth=void 0;var cc=class extends sn{};cc.prototype.ValueTypeName="vector";var hc=class{constructor(t,e,n){let i,r=this,s=!1,a=0,o=0,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===s&&void 0!==r.onStart&&r.onStart(t,a,o),s=!0},this.itemEnd=function(t){a++,void 0!==r.onProgress&&r.onProgress(t,a,o),a===o&&(s=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(t){void 0!==r.onError&&r.onError(t)},this.resolveURL=function(t){return i?i(t):t},this.setURLModifier=function(t){return i=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){let e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){let n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}}},yC=new hc,uc=class{constructor(t){this.manager=void 0!==t?t:yC,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};uc.DEFAULT_MATERIAL_NAME="__DEFAULT";var mc="\\[\\]\\.:\\/",_C=new RegExp("["+mc+"]","g"),gc="[^"+mc+"]",bC="[^"+mc.replace("\\.","")+"]",xC=/((?:WC+[\/:])*)/.source.replace("WC",gc),wC=/(WCOD+)?/.source.replace("WCOD",bC),SC=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gc),MC=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gc),EC=new RegExp("^"+xC+wC+SC+MC+"$"),AC=["material","materials","bones","map"],dc=class{constructor(t,e,n){let i=n||ke.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},ke=class t{constructor(e,n,i){this.path=n,this.parsedPath=i||t.parseTrackName(n),this.node=t.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,n,i){return e&&e.isAnimationObjectGroup?new t.Composite(e,n,i):new t(e,n,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(_C,"")}static parseTrackName(t){let e=EC.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){let t=n.nodeName.substring(i+1);-1!==AC.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){let n=function(t){for(let i=0;i<t.length;i++){let r=t[i];if(r.name===e||r.uuid===e)return r;let s=n(r.children);if(s)return s}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let e=this.node,n=this.parsedPath,i=n.objectName,r=n.propertyName,s=n.propertyIndex;if(e||(e=t.findNode(this.rootNode,n.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(i){let t=n.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let n=0;n<e.length;n++)if(e[n].name===t){t=n;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==t){if(void 0===e[t])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[t]}}let a=e[r];if(void 0===a){let t=n.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+t+"."+r+" but it wasn't found.",e)}let o=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?o=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(void 0!==s){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[s]&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else void 0!==a.fromArray&&void 0!==a.toArray?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ke.Composite=dc,ke.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},ke.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},ke.prototype.GetterByBindingType=[ke.prototype._getValue_direct,ke.prototype._getValue_array,ke.prototype._getValue_arrayElement,ke.prototype._getValue_toArray],ke.prototype.SetterByBindingTypeAndVersioning=[[ke.prototype._setValue_direct,ke.prototype._setValue_direct_setNeedsUpdate,ke.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ke.prototype._setValue_array,ke.prototype._setValue_array_setNeedsUpdate,ke.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ke.prototype._setValue_arrayElement,ke.prototype._setValue_arrayElement_setNeedsUpdate,ke.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ke.prototype._setValue_fromArray,ke.prototype._setValue_fromArray_setNeedsUpdate,ke.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var hR=new Float32Array(1);typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ff}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ff);var hm,mi=(t=>(t[t.x=0]="x",t[t.y=0]="y",t[t.z=0]="z",t))(mi||{}),Mf=Ka(Sf()),Jn=class{constructor(t){this.debug=(0,Mf.default)(t)}log(t,...e){this.debug(t,...e)}},BC=function(){this.onInit=function(){this.THREE=this.context.three,this.curVector=new this.THREE.Vector3(0,0,0),this.destVector=new this.THREE.Vector3(0,0,0),this.curQuaternion=new this.THREE.Quaternion(0,0,0,0),this.destQuaternion=new this.THREE.Quaternion(0,0,0,0),this.vectorToSet=null,this.quatToSet=null,this.vectorCounter=0,this.quatCounter=0,this.speed=1.25},this.onTick=function(t){if(this.vectorToSet){if(this.vectorToSet.equals(this.destVector)&&this.vectorCounter>120)return;this.vectorCounter++,this.curVector.lerp(this.destVector,t/1e3*this.speed),this.vectorToSet.set(this.curVector.x,this.curVector.y,this.curVector.z)}if(this.quatToSet){if(this.quatToSet.equals(this.destQuaternion)&&this.quatCounter>120)return;this.quatCounter++,this.curQuaternion.slerp(this.destQuaternion,t/1e3*this.speed),this.quatToSet.set(this.curQuaternion.x,this.curQuaternion.y,this.curQuaternion.z,this.curQuaternion.w)}},this.animateVector=function(t,e){this.vectorCounter=0,this.destVector=e,this.vectorToSet=t},this.animateQuaternion=function(t,e){this.quatCounter=0,this.destQuaternion=e,this.quatToSet=t},this.onEvent=function(){},this.onInputsUpdated=function(){},this.onDestroy=function(){}},Ef=()=>new BC,zC=function(){this.onInit=function(){this.THREE=this.context.three},this.onTick=function(t){},this.onEvent=function(){},this.onInputsUpdated=function(){},this.onDestroy=function(){},this.createName=async(t,e,n,i)=>{let r=t,s=i,a=n?.color??"#878291",o=n?.textColor??"#fff",l=new FontFace("OpenSans-SemiBold","url(https://superviz2homologmediaserver.s3.amazonaws.com/static/fonts/OpenSans-SemiBold.woff)");await l.load(),document.fonts.add(l);let c=this.createText(e,o,a);return c.position.set(0,s,0),r.add(c),c},this.createText=(t,e,n)=>{let i=document.createElement("canvas"),r=i.getContext("2d"),s=1e3,a=.03,o=100*r.measureText(t).width*1.12;i.width=o,i.height=s,r.font="1000px OpenSans-SemiBold",r.textBaseline="middle",r.fillStyle=e,r.fillText(t,0,500);let l=new this.THREE.Texture(i);l.needsUpdate=!0;let c=new this.THREE.SpriteMaterial({map:l,useScreenCoordinates:!1,opacity:1,alphaTest:.5,depthTest:!0,transparent:!0}),u=new this.THREE.Sprite(c);u.raycast=()=>null;let h=new this.THREE.Object3D;h.textHeight=a,h.textWidth=o/s*h.textHeight,u.scale.set(o/s*a,a,1);let d=document.createElement("canvas");d.width=o+10,d.height=1010;let p=d.getContext("2d"),f=this.addAlpha(n.split("#")[1],.99);p.fillStyle=`#${f}`,p.beginPath(),p.roundRect(-15,0,d.width,.9*d.height,d.width),p.fill();let m=new this.THREE.Texture(d);m.needsUpdate=!0;let g=new this.THREE.SpriteMaterial({opacity:.99,transparent:!1,useScreenCoordinates:!1,alphaTest:.1,color:new this.THREE.Color(n),map:m}),v=new this.THREE.Sprite(g);return v.scale.set(1.18,1.25,1.1),u.add(v),h.add(u),h},this.addAlpha=(t,e)=>t+Math.round(255*Math.min(Math.max(e||1,0),1)).toString(16).toUpperCase()},Af=()=>new zC,VC=function(){this.inputs={origin:{x:0,y:0,z:0}},this.onInit=function(){this.THREE=this.context.three,this.destPos=new this.THREE.Vector3(0,0,0),this.curPos=new this.THREE.Vector3(0,0,0),this.startPos=new this.THREE.Vector3(0,0,0),this.counter=0,this.slot=null,this.lastIndex=-1,this.lastDestPos=new this.THREE.Vector3(1e3,1e3,1e3),this.lastStartPos=new this.THREE.Vector3(1e3,1e3,1e3),this.speed=.95,this.tempStartPos=new this.THREE.Vector3(0,0,0),this.quat=new this.THREE.Quaternion(0,0,0,0)},this.onTick=function(t){this.createdMaterial&&(this.counter>60&&this.lastDestPos.equals(this.destPos)&&this.lastStartPos.distanceTo(this.startPos)<.2||(this.counter++,this.lastIndex!==this.slot?.index&&this.material&&(this.material.color.set(""),this.lastIndex=this.slot?.index),this.curPos.lerp(this.destPos,t/1e3*this.speed),this.lastDestPos.x=this.destPos.x,this.lastDestPos.y=this.destPos.y,this.lastDestPos.z=this.destPos.z,this.lastStartPos.x=this.startPos.x,this.lastStartPos.y=this.startPos.y,this.lastStartPos.z=this.startPos.z,this._updateMesh(this.startPos,this.curPos),this.outputs.objectRoot.visible=this.isOn&&this.shouldRenderAvatars))},this.onDestroy=function(){this.material&&this.material.dispose()},this.createMaterial=t=>{this.createdMaterial=!0;let e=this.createTextureCanvas(),n=new this.THREE.Texture(e);n.needsUpdate=!0;let i=this.slot?.color??t??"#878291";this.material=new this.THREE.MeshBasicMaterial({map:n,blending:this.THREE.AdditiveBlending,color:i,side:this.THREE.DoubleSide,depthWrite:!0,transparent:!0})},this._updateMesh=(t,e)=>{this.tempStartPos.copy(this.inputs.origin),this.tempStartPos.applyQuaternion(this.quat),this.tempStartPos.add(t);let n=new this.THREE.LineCurve3(this.tempStartPos,e);this.outputs.objectRoot&&this.outputs.objectRoot.geometry&&this.outputs.objectRoot.geometry.dispose();let i=new this.THREE.TubeGeometry(n,1,.003,4,!1);this.material&&(this.outputs.objectRoot=new this.THREE.Mesh(i,this.material))},this._doUpdateGeometry=(t,e,n,i,r={x:0,y:0,z:0},s={x:0,y:0,z:0})=>{this.slot=n,this.createdMaterial||this.createMaterial(this.slot),this.destPos.x=s.x,this.destPos.y=s.y,this.destPos.z=s.z,this.startPos.x=r.x,this.startPos.y=r.y,this.startPos.z=r.z,this.quat.set(i.x,i.y,i.z,i.w),this.counter=0,this.isOn=t,this.shouldRenderAvatars=e},this.updateGeometry=(t,e,n,i,r,s)=>{this._doUpdateGeometry(n,i,r,s,t,e)},this.createTextureCanvas=()=>{let t=document.createElement("canvas"),e=t.getContext("2d");t.width=1,t.height=64;let n=e.createLinearGradient(0,0,t.width,t.height);return n.addColorStop(0,"rgba(  0,  0,  0,0.1)"),n.addColorStop(.1,"rgba(160,160,160,0.3)"),n.addColorStop(.5,"rgba(255,255,255,0.5)"),n.addColorStop(.9,"rgba(160,160,160,0.3)"),n.addColorStop(1,"rgba(  0,  0,  0,0.1)"),e.fillStyle=n,e.fillRect(0,0,t.width,t.height),t},this.onEvent=function(t,e){},this.onInputsUpdated=function(t){}},Tf=()=>new VC,HC=500,WC={model3DUrl:"https://production.storage.superviz.com/readyplayerme/1.glb",imageUrl:"https://production.cdn.superviz.com/static/default-avatars/1.png"},vc={GLOBAL:"global-store",PRESENCE_3D:"presence-3d-store"},Ao=class{constructor(t,e){this.participants=[],this.roomParticipants={},this.isAttached=!1,this.localSlot=-1,this.currentCirclePosition=mi,this.currentLocalPosition=mi,this.currentLocalRotation=mi,this.currentLocalLaserDest=mi,this.circlePositions=[],this.avatars={},this.lasers={},this.laserUpdateIntervals={},this.positionInfos={},this.tempQuaternion=new fn(0,0,0,0),this.isSweeping=!1,this.unsubscribeFrom=[],this.hasJoinedRoom=!1,this.hasJoined3D=!1,this.attach=t=>{if(Object.values(t).includes(null)||Object.values(t).includes(void 0)){let t=`${this.name} @ attach - params are required`;throw this.logger.log(t),new Error(t)}this.logger.log("attached");let{eventBus:e,useStore:n,ioc:i}=t;this.useStore=n.bind(this),this.room=i.createRoom(this.name),this.presence3DManager=new Gp(this.room,this.useStore);let{localParticipant:r,hasJoinedRoom:s}=this.useStore(vc.GLOBAL);r.subscribe(),s.subscribe();let{hasJoined3D:a,participants:o}=this.useStore(vc.PRESENCE_3D);a.subscribe(),o.subscribe(this.onParticipantsUpdated),this.isAttached=!0,this.eventBus=e,this.start()},this.detach=()=>{this.isAttached?(this.logger.log("detached"),this.destroy(),this.unsubscribeFrom.forEach((t=>t(this))),this.localParticipant=void 0,this.isAttached=!1):this.logger.log(`${this.name} @ detach - component is not attached}`)},this.destroy=()=>{this.unsubscribeToRealtimeEvents(),this.unsubscribeToEventBusEvents(),this.room.disconnect(),this.room=void 0,this.participants.forEach((t=>{this.presence3DManager.unsubscribeFromUpdates(t.id,this.onParticipantUpdated)})),this.presence3DManager=void 0,this.useStore=void 0,this.isAttached=!1,this.ambientLight?.stop(),this.directionalLight?.stop(),this.participants.forEach((t=>{this.removeParticipant(t,!0)})),Object.keys(this.laserUpdateIntervals).forEach((t=>{clearInterval(this.laserUpdateIntervals[t])})),this.participants=[],this.laserUpdateIntervals={},this.avatars={},this.lasers={}},this.start=()=>{if(!this.hasJoinedRoom||!this.hasJoined3D)return this.logger.log("matterport component @ start - not joined yet"),void setTimeout((()=>{this.logger.log("matterport component @ start - retrying"),this.start()}),1e3);this.subscribeToRealtimeEvents(),this.subscribeToEventBusEvents(),this.createParticipantList()},this.subscribeToRealtimeEvents=()=>{this.logger.log("matterport component @ subscribeToRealtimeEvents"),this.room.on("participant-joined",this.onParticipantJoined),this.room.presence.on("presence.leave",this.onParticipantLeave),this.room.on("gather",this.onGatherUpdate),this.room.on("follow-me",this.onFollowParticipantUpdate)},this.unsubscribeToRealtimeEvents=()=>{this.logger.log("matterport component @ unsubscribeToRealtimeEvents"),this.room.presence.off("presence.leave"),this.room.off("participant-joined",this.onParticipantJoined),this.room.off("gather",this.onGatherUpdate),this.room.off("follow-me",this.onFollowParticipantUpdate)},this.subscribeToEventBusEvents=()=>{this.logger.log("matterport component @ subscribeToEventBusEvents"),this.eventBus.subscribe("realtime.go-to-participant",this.goTo),this.eventBus.subscribe("realtime.local-follow-participant",this.localFollow),this.eventBus.subscribe("realtime.follow-participant",this.follow),this.eventBus.subscribe("realtime.private-mode",this.setPrivate)},this.unsubscribeToEventBusEvents=()=>{this.logger.log("matterport component @ unsubscribeToEventBusEvents"),this.eventBus.unsubscribe("realtime.go-to-participant",this.goTo),this.eventBus.unsubscribe("realtime.local-follow-participant",this.localFollow),this.eventBus.unsubscribe("realtime.private-mode",this.setPrivate),this.eventBus.unsubscribe("realtime.follow-participant",this.follow)},this.onParticipantJoined=t=>{if(!t.data)return;this.logger.log("matterport component @ onParticipantJoined",t);let{id:e,name:n,avatar:i,avatarConfig:r,type:s,slot:a}=t.data;e!==this.localParticipantId?this.addParticipant({id:e,name:n,avatar:i,avatarConfig:r,type:s,slot:a}):this.onLocalParticipantJoined(t.data)},this.onLocalParticipantJoined=t=>{this.createParticipantList(),this.config.avatarConfig&&this.presence3DManager.setParticipantData({avatarConfig:this.config.avatarConfig}),t.avatar?.model3DUrl&&this.presence3DManager.setParticipantData({avatar:{model3DUrl:t?.avatar.model3DUrl,imageUrl:t?.avatar?.imageUrl}}),t.avatar?.model3DUrl||this.presence3DManager.setParticipantData({avatar:{model3DUrl:WC.model3DUrl,imageUrl:t?.avatar?.imageUrl}})},this.onParticipantLeave=t=>{this.logger.log("matterport component @ onParticipantLeave",t.data);let e=this.participants.find((e=>e.id===t.id));e&&this.removeParticipant(e,!0)},this.onParticipantUpdated=t=>{this.logger.log("matterport component @ onParticipantUpdated",t);let{id:e,name:n,avatar:i,avatarConfig:r,position:s,rotation:a,type:o,slot:l}=t.data??t;this.updateParticipant({position:s,rotation:a,id:e,name:n,avatar:i,avatarConfig:r,type:o,slot:l}),(this.localFollowParticipantId||this.followParticipantId)&&this.moveToAnotherParticipant(this.localFollowParticipantId??this.followParticipantId)},this.updateParticipant=async t=>{if(!this.participants||0===this.participants.length||!t||!t.id||t.id===this.localParticipantId)return;let e=this.participants.find((e=>e.id===t.id));if(e){if(e.avatar?.model3DUrl===t.avatar?.model3DUrl&&(0,Cf.isEqual)(e.avatarConfig,t.avatarConfig)&&e.name===t.name){let e=this.participants.findIndex((e=>e.id===t.id));-1!==e&&(this.participants[e]=t)}else{this.removeParticipant(t,!1);let e=this.createParticipantOn3D(t);this.participants.push(e),this.config.isAvatarsEnabled&&await this.createAvatar(e),this.config.isLaserEnabled&&this.createLaser(e),this.config.isNameEnabled&&this.createName(e,this.avatars[t.id])}this.logger.log("matterport component @ updateParticipant",{participant:t,participants:this.participants})}else this.addParticipant(t)},this.onFollowParticipantUpdate=t=>{t.data.id!==this.localParticipantId&&(this.logger.log("three js component @ onFollowParticipantUpdate",t.data.id),this.followParticipantId=t.data.id,this.moveToAnotherParticipant(t.data.id))},this.onGatherUpdate=t=>{this.logger.log("three js component @ onGatherUpdate",t.data.id),t.data.id!==this.localParticipantId&&this.eventBus.publish("realtime.go-to-participant",t.data.id)},this.createParticipantList=()=>{let t=this.useStore(vc.PRESENCE_3D).participants.value;Object.values(t).forEach((t=>{t.isPrivate||this.addParticipant(t)})),this.logger.log("matterport component @ createParticipantList",this.participants)},this.createParticipantOn3D=({id:t,name:e,avatar:n,avatarConfig:i,type:r,slot:s})=>{let a={id:t,name:e,avatar:n,isAudience:"audience"===r,avatarConfig:t===this.localParticipantId?this.config.avatarConfig:i,position:{x:0,y:0,z:0},rotation:{x:0,y:0},slot:s};return this.logger.log("matterport component @ createParticipantOn3D",a),a},this.removeParticipant=(t,e)=>{this.logger.log("matterport component @ removeParticipant",{participant:t,unsubscribe:e}),this.participants=this.participants.filter((e=>e.id!==t.id)),delete this.roomParticipants[t.id],this.destroyAvatar(t),this.destroyLaser(t),e&&this.presence3DManager?.unsubscribeFromUpdates(t.id,this.onParticipantUpdated),this.createCircleOfPositions()},this.addParticipant=async t=>{if(!t||!t.id||"audience"===t.type)return;let e=this.createParticipantOn3D(t);if(this.participants.find((t=>t.id===e.id)))return this.logger.log("matterport component @ addParticipant - participant already exists"),void this.onParticipantUpdated(t);this.participants.push(e),this.logger.log("matterport component @ addParticipant",{participant:t,participantOn3D:e,participants:this.participants}),this.roomParticipants[t.id]=t,this.presence3DManager.subscribeToUpdates(e.id,this.onParticipantUpdated),this.localParticipantId!==e.id&&(this.config.isAvatarsEnabled&&await this.createAvatar(e),this.config.isLaserEnabled&&this.createLaser(e),this.config.isNameEnabled&&this.createName(e,this.avatars[t.id]),this.createCircleOfPositions())},this.goTo=t=>{this.logger.log("matterport component @ goTo",t),this.moveToAnotherParticipant(t)},this.gather=()=>{this.logger.log("matterport component @ gather"),this.room.emit("gather",{id:this.localParticipant.id})},this.setPrivate=t=>{this.logger.log("matterport component @ private mode"),this.presence3DManager.updatePresence3D({id:this.localParticipantId,isPrivate:!!t}),this.isPrivate=!!t},this.follow=t=>{this.logger.log("matterport component @ follow"),this.room.emit("follow-me",{id:t})},this.localFollow=t=>{this.localFollowParticipantId=t},this.moveToAnotherParticipant=t=>{if(!this.positionInfos[t]||!this.isAttached||t===this.localParticipantId)return;let{mode:e,sweep:n}=this.positionInfos[t];if("mode.inside"===e&&n){let e=this.positionInfos[t].rotation||{x:0,y:0};this.moveToSweep(n,e)}if("mode.dollhouse"===e||"mode.floorplan"===e){let n=this.matterportSdk.Mode.TransitionType.FLY,{position:i,rotation:r,floor:s}=this.positionInfos[t];this.matterportSdk.Mode.moveTo(e,{position:i,rotation:r,transition:n,zoom:25}).then((t=>{this.currentLocalMode=t})),"mode.floorplan"===e&&this.currentLocalFloorId!==s&&(-1===s?this.matterportSdk.Floor.showAll():this.matterportSdk.Floor.moveTo(s).then((()=>{this.currentLocalFloorId=s})))}},this._onLocalSweepChangeObserver=t=>{this.presence3DManager&&(this.currentSweepId=t.id,!this.isPrivate&&this.presence3DManager.updatePresence3D({id:this.localParticipantId,sweep:this.currentSweepId}))},this._onLocalFloorChangeObserver=t=>{this.presence3DManager&&(""!==t.id&&(this.currentLocalFloorId=parseFloat(t.id)),"all"===t.name&&(this.currentLocalFloorId=-1),!this.isPrivate&&this.presence3DManager.updatePresence3D({id:this.localParticipantId,floor:this.currentLocalFloorId}))},this._onLocalModeChangeObserver=t=>{this.presence3DManager&&(this.currentLocalMode=t,!this.isPrivate&&this.presence3DManager.updatePresence3D({id:this.localParticipantId,mode:this.currentLocalMode}))},this._onLocalCameraMoveObserver=({position:t,rotation:e,sweep:n})=>{this.presence3DManager&&(this.currentLocalPosition=this.adjustMyPositionToCircle(t),this.currentLocalRotation=e,!this.isPrivate&&this.presence3DManager.updatePresence3D({id:this.localParticipantId,position:this.currentLocalPosition,rotation:this.currentLocalRotation,laser:this.currentLocalLaserDest,sweep:this.currentSweepId,mode:this.currentLocalMode,floor:this.currentLocalFloorId}))},this._onLocalMouseMoveObserver=t=>{!this.presence3DManager||this.isPrivate||(this.currentLocalLaserDest=t.position,!this.isPrivate&&this.presence3DManager.updatePresence3D({id:this.localParticipantId,position:this.currentLocalPosition,rotation:this.currentLocalRotation,laser:this.currentLocalLaserDest,mode:this.currentLocalMode,sweep:this.currentSweepId}))},this.addInputComponent=async()=>{if(!this.matterportSdk.Scene)return;let[t]=await this.matterportSdk.Scene.createObjects(1),e=t.addNode();this.mpInputComponent=e.addComponent("mp.input",{eventsEnabled:!1,userNavigationEnabled:!0}),e.start()},this.addSceneLight=async()=>{this.directionalLight=await this.createDirectionLight(),this.ambientLight=await this.createAmbientLight()},this.createDirectionLight=async()=>{if(!this.matterportSdk.Scene)return;let[t]=await this.matterportSdk.Scene.createObjects(1),e=t.addNode(),n=e.addComponent("mp.directionalLight",{enabled:!0,color:{r:1,g:1,b:1},intensity:1,position:{x:.2,y:1,z:0},target:{x:.5,y:0,z:0},debug:!1});return this.THREE=n.context.three,e.start(),e},this.createAmbientLight=async()=>{if(!this.matterportSdk.Scene)return;let[t]=await this.matterportSdk.Scene.createObjects(1),e=t.addNode();return e.addComponent("mp.ambientLight",{enabled:!0,color:{r:1,g:1,b:1},intensity:1}),e.start(),e},this.adjustMyPositionToCircle=t=>{if(!this.presence3DManager||(this.localSlot=this.localParticipant.slot?.index??-1,!this.THREE||-1===this.localSlot))return t;let e=new this.THREE.Vector3(t?.x,t?.y,t?.z),n=this.circlePositions.find((t=>t.slot===this.localSlot));return n?(this.currentCirclePosition?.isVector3||(this.currentCirclePosition=new this.THREE.Vector3(n.x,t.y,n.z)),this.currentCirclePosition.set(n.x,t.y,n.z),e.add(this.currentCirclePosition.multiplyScalar(.13)),{x:e.x,y:t.y,z:e.z}):t},this.onParticipantsUpdated=t=>{this.isAttached&&(this.logger.log("matterport component @ onParticipantsUpdated",t),this.roomParticipants={},t.forEach((t=>{this.roomParticipants[t.id]=t})),Object.values(t).forEach((t=>{if(t.id===this.localParticipantId)return;let e=t.id,{position:n,rotation:i,sweep:r,floor:s,mode:a,isPrivate:o}=t;if(this.positionInfos[e]={position:n,rotation:i,mode:a,sweep:r,floor:s},o&&this.avatars[e]&&this.removeParticipant(t,!0),!o&&!this.avatars[e]&&this.addParticipant(t),this.avatars[e]){let r=this.avatars[e],s=this.lasers[e],a=t.laser;n&&i&&this.updateAvatar(r,n,i),s&&(this.laserUpdateIntervals[e]&&clearInterval(this.laserUpdateIntervals[e]),this.laserUpdateIntervals[e]=setInterval((()=>{this.updateLaser(e,r,s,a)}),30))}})))},this.name="presence3dMatterport",this.logger=new Jn("@superviz/sdk/matterport-component"),this.logger.log("matterport component @ constructor",{matterportSdk:t,options:e}),this.config={isAvatarsEnabled:e?.isAvatarsEnabled??!0,isLaserEnabled:e?.isLaserEnabled??!0,isNameEnabled:e?.isNameEnabled??!0,avatarConfig:{height:e?.avatarConfig?.height||.25,scale:e?.avatarConfig?.scale||.55,laserOrigin:e?.avatarConfig?.laserOrigin??{x:0,y:-.2,z:.07}}},this.logger.log("matterport component @ constructor - config",this.config),this.matterportSdk=t,this.matterportSdk.Scene&&(this.matterportSdk.Scene.register("lerper",Ef),this.matterportSdk.Scene.register("name",Af),this.matterportSdk.Scene.register("laser",Tf)),this.addInputComponent(),this.addSceneLight(),this.createCircleOfPositions(),this.subscribeToMatterportEvents()}get localParticipantId(){return this.localParticipant?.id}async destroyAvatar(t){this.logger.log("matterport component @ destroyAvatar",t),this.avatars[t.id]&&(this.avatars[t.id].stop(),delete this.avatars[t.id])}async destroyLaser(t){this.logger.log("matterport component @ destroyLaser",t),this.lasers[t.id]&&(this.lasers[t.id].stop(),delete this.lasers[t.id])}async createAvatar(t){if(this.logger.log("matterport component @ createAvatar",t),!this.isAttached||!this.matterportSdk.Scene)return;let e=t?.avatarConfig?.scale||.55,n=t?.avatarConfig?.height||.25,[i]=await this.matterportSdk.Scene.createObjects(1),r=i.addNode(),s=mi;r.obj3D.rotation.set(s.x,s.y,s.z),r.obj3D.name="avatar",r.obj3D.userData={uuid:t.id,name:t.name,height:n};let a=t.avatar?.model3DUrl??"https://production.storage.superviz.com/readyplayerme/1.glb",o={x:e,y:e,z:e};return r.lerper=r.addComponent("lerper"),r.avatarName=r.addComponent("name"),this.avatars[t.id]=r,new Promise((t=>{r.addComponent("mp.gltfLoader",{url:a,localScale:o,onLoaded:()=>{this.matterportSdk.Camera.getPose().then((e=>{this._onLocalCameraMoveObserver({position:e.position,rotation:e.rotation,sweep:e.sweep}),t(r)}))}}),r.start()}))}async createName(t,e){if(this.logger.log("createName",t,e),!e)return;let n,i=Number(this.THREE.REVISION),r=(t.avatar?.model3DUrl??"https://production.storage.superviz.com/readyplayerme/1.glb")?.includes("readyplayerme"),s=e.avatarName,a=t.slot??this.roomParticipants[t.id]?.slot,o=(new this.THREE.Box3).setFromObject(e.obj3D),l=new be(0,0,0);o.getSize(l),i<=146?n=o.min.y-e.position.y+1.1*l.y:(n=1.2*l.y,r&&(n=4.1*l.y)),s.createName(e.obj3D,t.name,a,n)}async createLaser(t){if(this.logger.log("matterport component @ createLaser",t),!this.isAttached||!this.matterportSdk.Scene)return;let e=new be(0,-.2,.07);t.avatarConfig?.laserOrigin&&(e=new be(t.avatarConfig.laserOrigin.x,t.avatarConfig.laserOrigin.y,t.avatarConfig.laserOrigin.z));let[n]=await this.matterportSdk.Scene.createObjects(1),i=n.addNode();i.laserPointer=i.addComponent("laser",{origin:e}),i.start(),i.obj3D.userData={uuid:t.id},this.lasers[t.id]=i}subscribeToMatterportEvents(){this.matterportSdk.Camera.pose.subscribe(this._onLocalCameraMoveObserver),this.matterportSdk.Pointer.intersection.subscribe(this._onLocalMouseMoveObserver),this.matterportSdk.Floor.current.subscribe(this._onLocalFloorChangeObserver),this.matterportSdk.Mode.current.subscribe(this._onLocalModeChangeObserver),this.matterportSdk.Sweep.current.subscribe(this._onLocalSweepChangeObserver)}createCircleOfPositions(){this.circlePositions=[];let t=[...Object.values(this.participants),this.localParticipant].sort(((t,e)=>(t.slot?.index||0)-(e.slot?.index||0))),e=t.length;if(0===e)return;let n=Math.max(.3*e,2),i=2*Math.PI/e;for(let r=0;r<e;r++){let e=r*i,s=n*Math.cos(e),a=n*Math.sin(e);this.circlePositions.push({x:s,y:0,z:a,slot:t[r]?.slot?.index??-1})}this.adjustMyPositionToCircle(this.currentLocalPosition),this.logger.log("Updated circle positions:",this.circlePositions)}moveToSweep(t,e){this.isSweeping||!this.isAttached||(this.mpInputComponent&&(this.mpInputComponent.inputs.userNavigationEnabled=!1),this.isSweeping=!0,this.matterportSdk.Sweep.moveTo(t,{transitionTime:HC,transition:this.matterportSdk.Sweep.Transition.FLY,rotation:e||this.currentLocalRotation}).catch((t=>{console.log("[SuperViz] Error when trying to sweep",t)})).finally((()=>{this.isSweeping=!1,this.mpInputComponent&&(this.mpInputComponent.inputs.userNavigationEnabled=!0)})))}updateAvatar(t,e,n){if(!this.isAttached)return;let i=new this.THREE.Vector3(1,0,0),r=new this.THREE.Vector3(0,1,0),s=(new this.THREE.Quaternion).setFromAxisAngle(i,this.THREE.MathUtils.degToRad(-n.x)),a=(new this.THREE.Quaternion).setFromAxisAngle(r,this.THREE.MathUtils.degToRad(n?.y)+Math.PI),{lerper:o}=t;o.animateQuaternion(t.obj3D.quaternion,a.multiply(s));let l=parseFloat(t?.obj3D?.userData?.height??0)-.62,c=new this.THREE.Vector3(this.currentCirclePosition.x,0,this.currentCirclePosition.z),u=new this.THREE.Vector3(e?.x,0,e?.z).sub(c);u.y=e.y+l,o.animateVector(t.obj3D.position,u)}updateLaser(t,e,n,i){let r=this.roomParticipants[t];if(!(e&&n&&i&&this.isAttached&&r))return;let s=n.laserPointer,{x:a,y:o,z:l}=e.obj3D.position,c={x:a,y:o+.35,z:l};if(e.obj3D.getWorldQuaternion(this.tempQuaternion),s){let{slot:t}=r;s.updateGeometry(c,i,!0,!0,t,this.tempQuaternion)}}},cm=Ka(lm()),Co=class{constructor(t={}){this.subscribe=t=>{this.callbacks.push(t)},this.unsubscribe=t=>{this.callbacks=this.callbacks.filter((e=>e!==t))},this.publish=(...t)=>{this.callbacks&&this.callbacks.forEach((e=>{this.callListener(e,t).catch((n=>{this.logger.log("superviz-sdk:observer-helper:publish:error",`\n            Failed to execute callback on publish value.\n            Callback: ${e}\n            Event: ${JSON.stringify(t)}\n            Error: ${n}\n          `)}))}))},this.reset=()=>{this.callbacks=[]},this.destroy=()=>{delete this.logger,delete this.callbacks},this.callListener=(t,e)=>new Promise(((n,i)=>{try{n(t(...e))}catch(t){i(t)}}));let{logger:e,throttleTime:n}=t;this.logger=e??new Jn("@superviz/sdk/observer-helper"),this.throttle=n,this.callbacks=[],this.throttle&&(this.publish=(0,cm.default)(this.publish,this.throttle))}},xc=class{constructor(){this.eventType="INTERACTION.CLICK"}onEvent(){hm.onClick()}},Po=class{constructor(t,e){if(this.isPinsVisible=!0,this.divWrapperReplacementInterval=null,this.isSweeping=!1,this.commentsSide="left",this.selectedPin=null,this.setCommentsMetadata=t=>{this.commentsSide=t},this.hideTemporaryPin=t=>{let e=t.target;this.showcaseDiv.contains(e)||this.pins.get("temporary-pin")?.contains(e)||this.removeAnnotationPin("temporary-pin")},this.resetPins=t=>{t&&"Escape"!==t?.key||(this.resetSelectedPin(),this.removeAnnotationPin("temporary-pin"),this.temporaryPinCoordinates=null)},this.annotationSelected=({detail:t})=>{let{uuid:e,haltGoToPin:n,newPin:i}=t;if(!e)return;i&&this.pins.get(e).setAttribute("newPin","");let r=JSON.parse(this.selectedPin?.getAttribute("annotation")??"{}");if(this.resetPins(),r?.uuid===e)return;document.body.dispatchEvent(new CustomEvent("close-temporary-annotation"));let s=this.pins.get(e);if(!s)return;s.setAttribute("active",""),this.selectedPin=s;let a=this.annotations.find((t=>t.uuid===e));if(a){let t=JSON.parse(a.position);if(t&&!n){let e=t.camera;this.moveToSweep(e.sweep,e.rotation)}}},this.onClick=()=>{if(!this.isActive)return;let t={x:this.intersection.position.x,y:this.intersection.position.y,z:this.intersection.position.z,type:"matterport"},e={position:t,camera:this.cameraPose};this.resetSelectedPin(),this.onPinFixedObserver.publish(e),this.createTemporaryPin(t)},this.onToggleAnnotationSidebar=({detail:t})=>{let{open:e}=t;e||(this.pins.forEach((t=>{t.removeAttribute("active")})),this.pins.has("temporary-pin")&&this.removeAnnotationPin("temporary-pin"))},typeof window>"u")throw new Error("[SuperViz] MatterportPin cannot be initialized in a non-browser environment. Window is not defined");hm=this,this.showcaseDiv=e,this.matterportSdk=t,this.logger=new Jn("@superviz/sdk/comments-component/matterport-adapter"),this.isActive=!1,this.pins=new Map,this.divWrapper=this.createDivWrapper(),this.matterportSdk.Asset.registerTexture("pointer","https://production.cdn.superviz.com/static/pin-add.png"),this.createInputListener(),document.body.addEventListener("select-annotation",this.annotationSelected),document.body.addEventListener("toggle-annotation-sidebar",this.onToggleAnnotationSidebar),document.body.style.position="relative",this.onPinFixedObserver=new Co,this.annotations=[],this.renderAnnotationsPins(),this.matterportSdk.Camera.pose.subscribe((t=>{this.cameraPose=t,(this.isActive||this.isPinsVisible)&&this.renderAnnotationsPins()})),this.showcaseSides=this.showcaseDiv.getBoundingClientRect()}destroy(){this.removeAnnotationsPins(),this.removeListeners()}setActive(t){if(this.isActive=t,this.isActive)return this.addListeners(),void this.matterportSdk.Pointer.editTexture("pointer");this.matterportSdk.Pointer.resetTexture()}setPinsVisibility(t){this.isPinsVisible=t,this.isPinsVisible?this.renderAnnotationsPins():this.removeAnnotationsPins()}updateAnnotations(t){this.logger.log("updateAnnotations",t),this.annotations=t,(this.isActive||this.isPinsVisible)&&this.renderAnnotationsPins()}removeAnnotationPin(t){let e=this.pins.get(t);e&&(e.remove(),this.pins.delete(t),this.annotations=this.annotations.filter((e=>e.uuid!==t)))}createTemporaryPin(t){let e=document.getElementById("superviz-temporary-pin");this.temporaryPinCoordinates=t,e||(e=document.createElement("superviz-comments-annotation-pin"),e.id="superviz-temporary-pin",e.setAttribute("type","add"),e.setAttribute("showInput",""),e.setAttribute("containerSides",JSON.stringify(this.showcaseSides)),e.setAttribute("commentsSide",this.commentsSide),e.setAttribute("participantsList",JSON.stringify(this.participants)),e.setAttribute("position",JSON.stringify(this.temporaryPinCoordinates)),e.setAttribute("annotation",JSON.stringify({})),e.setAttributeNode(document.createAttribute("active")));let n=this.showcaseDiv,{width:i,height:r}=n.getBoundingClientRect(),s=this.position3DToScreen(t,i,r,0,-32),a={x:s.left,y:s.top,type:t.type};e.setAttribute("position",JSON.stringify(a)),this.divWrapper.appendChild(e),this.pins.set("temporary-pin",e)}addListeners(){this.intersectionObserver=this.matterportSdk.Pointer.intersection.subscribe((t=>{this.intersection=t})),this.inputComponent.inputs.eventsEnabled=!0,this.inputComponent.inputs.userNavigationEnabled=!1,document.body.addEventListener("keyup",this.resetPins),document.body.addEventListener("click",this.hideTemporaryPin)}removeListeners(){document.body.removeEventListener("select-annotation",this.annotationSelected),document.body.removeEventListener("toggle-annotation-sidebar",this.onToggleAnnotationSidebar),this.intersectionObserver?.cancel(),this.inputComponent.inputs.eventsEnabled=!1,this.inputComponent.inputs.userNavigationEnabled=!0,document.body.removeEventListener("keyup",this.resetPins),document.body.removeEventListener("click",this.hideTemporaryPin)}async renderAnnotationsPins(){this.annotations.forEach((async t=>{let e=JSON.parse(t.position).position;if("matterport"!==e?.type||t.resolved)return;this.pins.has(t.uuid)||this.createPin(t,e);let{width:n,height:i}=this.showcaseDiv.getBoundingClientRect(),r=this.position3DToScreen(e,n,i,0,-32),s=await this.checkIsVisible(r,e),a=this.pins.get(t.uuid);s?(a.setAttribute("style","opacity: 1"),this.pins.get(t.uuid).setAttribute("position",JSON.stringify({x:r.left,y:r.top}))):a.setAttribute("style","opacity: 0")}));let t=this.pins.get("temporary-pin");if(t){let{width:e,height:n}=this.showcaseDiv.getBoundingClientRect(),i=this.position3DToScreen(this.temporaryPinCoordinates,e,n,0,-32);await this.checkIsVisible(i,this.temporaryPinCoordinates)?(t.setAttribute("style","opacity: 1"),t.setAttribute("position",JSON.stringify({x:i.left,y:i.top}))):t.setAttribute("style","opacity: 0")}}createPin(t,e){let{width:n,height:i}=this.showcaseDiv.getBoundingClientRect(),r=this.position3DToScreen(e,n,i,0,-32),s=document.createElement("superviz-comments-annotation-pin");this.divWrapper.appendChild(s),s.setAttribute("type","show"),s.setAttribute("annotation",JSON.stringify(t)),s.setAttribute("position",JSON.stringify({x:r.left,y:r.top})),s.setAttribute("participantsList",JSON.stringify(this.participants)),this.pins.set(t.uuid,s)}removeAnnotationsPins(){this.pins.forEach((t=>{t.remove()})),this.pins.clear()}set participantsList(t){this.participants=t}resetSelectedPin(){this.selectedPin&&(this.selectedPin.removeAttribute("active"),this.selectedPin=null)}moveToSweep(t,e){this.isSweeping||(this.isSweeping=!0,this.matterportSdk.Sweep.moveTo(t,{transitionTime:500,transition:this.matterportSdk.Sweep.Transition.FLY,rotation:e}).finally((()=>{this.isSweeping=!1})))}createDivWrapper(){let t=this.showcaseDiv.getBoundingClientRect(),e=document.createElement("div");return this.showcaseDiv.parentElement.style.position="relative",e.style.position="fixed",e.style.top=`${t.top}px`,e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,e.style.pointerEvents="none",e.style.overflow="hidden",this.divWrapperReplacementInterval||(this.divWrapperReplacementInterval=setInterval((()=>{let t=this.showcaseDiv.getBoundingClientRect();e.style.top=`${t.top}px`,e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`}),1)),this.showcaseDiv.parentElement.appendChild(e),e}async createInputListener(){let[t]=await this.matterportSdk.Scene.createObjects(1),e=t.addNode();this.inputComponent=e.addComponent("mp.input",{eventsEnabled:!1,userNavigationEnabled:!0}),e.start(),this.inputComponent.spyOnEvent(new xc)}position3DToScreen(t,e,n,i,r){let s={w:e,h:n},a=this.matterportSdk.Conversion.worldToScreen(t,this.cameraPose,s);return{top:Math.abs(a.y)+r,left:Math.abs(a.x)+i}}async checkIsVisible(t,e){let n=new be(e.x,e.y,e.z),i=await this.matterportSdk.Renderer.getWorldPositionData({x:t.left,y:t.top});return!(!i||!i.position)&&new be(i.position.x,i.position.y,i.position.z).distanceTo(n)<3}};typeof window<"u"&&(window.Presence3D=Ao,window.MatterportPin=Po);export{Po as MatterportPin,Ao as Presence3D};
/*! Bundled license information:

lodash/lodash.js:
  (**
   * @license
   * Lodash <https://lodash.com/>
   * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
   * Released under MIT license <https://lodash.com/license>
   * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
   * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
   *)

three/build/three.module.js:
  (**
   * @license
   * Copyright 2010-2024 Three.js Authors
   * SPDX-License-Identifier: MIT
   *)
*/
//# sourceMappingURL=/sm/a5f2abdcc257f7584502443570fd3a09a3841da8fece934ac91c527c29b75d75.map