@iebh/tera-fy 2.2.4 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- var mo=typeof global=="object"&&global&&global.Object===Object&&global,ut=mo;var uo=typeof self=="object"&&self&&self.Object===Object&&self,co=ut||uo||Function("return this")(),d=co;var ho=d.Symbol,g=ho;var qt=Object.prototype,xo=qt.hasOwnProperty,go=qt.toString,it=g?g.toStringTag:void 0;function yo(t){var e=xo.call(t,it),r=t[it];try{t[it]=void 0;var o=!0}catch{}var a=go.call(t);return o&&(e?t[it]=r:delete t[it]),a}var Yt=yo;var bo=Object.prototype,vo=bo.toString;function wo(t){return vo.call(t)}var Zt=wo;var To="[object Null]",Po="[object Undefined]",Jt=g?g.toStringTag:void 0;function jo(t){return t==null?t===void 0?Po:To:Jt&&Jt in Object(t)?Yt(t):Zt(t)}var T=jo;function Ao(t){return t!=null&&typeof t=="object"}var w=Ao;var Oo="[object Symbol]";function So(t){return typeof t=="symbol"||w(t)&&T(t)==Oo}var B=So;function Io(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Xt=Io;var _o=Array.isArray,x=_o;var Eo=1/0,Qt=g?g.prototype:void 0,te=Qt?Qt.toString:void 0;function ee(t){if(typeof t=="string")return t;if(x(t))return Xt(t,ee)+"";if(B(t))return te?te.call(t):"";var e=t+"";return e=="0"&&1/t==-Eo?"-0":e}var re=ee;function Fo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=Fo;function Co(t){return t}var oe=Co;var No="[object AsyncFunction]",Mo="[object Function]",Ro="[object GeneratorFunction]",Lo="[object Proxy]";function Bo(t){if(!v(t))return!1;var e=T(t);return e==Mo||e==Ro||e==No||e==Lo}var dt=Bo;var ko=d["__core-js_shared__"],ct=ko;var ae=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Uo(t){return!!ae&&ae in t}var ie=Uo;var Do=Function.prototype,zo=Do.toString;function Go(t){if(t!=null){try{return zo.call(t)}catch{}try{return t+""}catch{}}return""}var j=Go;var Wo=/[\\^$.*+?()[\]{}|]/g,Ko=/^\[object .+?Constructor\]$/,$o=Function.prototype,Ho=Object.prototype,Vo=$o.toString,qo=Ho.hasOwnProperty,Yo=RegExp("^"+Vo.call(qo).replace(Wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zo(t){if(!v(t)||ie(t))return!1;var e=dt(t)?Yo:Ko;return e.test(j(t))}var se=Zo;function Jo(t,e){return t==null?void 0:t[e]}var ne=Jo;function Xo(t,e){var r=ne(t,e);return se(r)?r:void 0}var y=Xo;var Qo=y(d,"WeakMap"),ht=Qo;var fe=Object.create,ta=function(){function t(){}return function(e){if(!v(e))return{};if(fe)return fe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),pe=ta;function ea(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var le=ea;function ra(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var me=ra;var oa=800,aa=16,ia=Date.now;function sa(t){var e=0,r=0;return function(){var o=ia(),a=aa-(o-r);if(r=o,a>0){if(++e>=oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ue=sa;function na(t){return function(){return t}}var de=na;var fa=function(){try{var t=y(Object,"defineProperty");return t({},"",{}),t}catch{}}(),k=fa;var pa=k?function(t,e){return k(t,"toString",{configurable:!0,enumerable:!1,value:de(e),writable:!0})}:oe,ce=pa;var la=ue(ce),he=la;function ma(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var xe=ma;var ua=9007199254740991,da=/^(?:0|[1-9]\d*)$/;function ca(t,e){var r=typeof t;return e=e==null?ua:e,!!e&&(r=="number"||r!="symbol"&&da.test(t))&&t>-1&&t%1==0&&t<e}var U=ca;function ha(t,e,r){e=="__proto__"&&k?k(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ha;function xa(t,e){return t===e||t!==t&&e!==e}var gt=xa;var ga=Object.prototype,ya=ga.hasOwnProperty;function ba(t,e,r){var o=t[e];(!(ya.call(t,e)&&gt(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var D=ba;function va(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],u=o?o(r[n],t[n],n,r,t):void 0;u===void 0&&(u=t[n]),a?xt(r,n,u):D(r,n,u)}return r}var I=va;var ge=Math.max;function wa(t,e,r){return e=ge(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ge(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),le(t,this,n)}}var ye=wa;var Ta=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ta}var z=Pa;function ja(t){return t!=null&&z(t.length)&&!dt(t)}var yt=ja;var Aa=Object.prototype;function Oa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var G=Oa;function Sa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var be=Sa;var Ia="[object Arguments]";function _a(t){return w(t)&&T(t)==Ia}var Ct=_a;var ve=Object.prototype,Ea=ve.hasOwnProperty,Fa=ve.propertyIsEnumerable,Ca=Ct(function(){return arguments}())?Ct:function(t){return w(t)&&Ea.call(t,"callee")&&!Fa.call(t,"callee")},W=Ca;function Na(){return!1}var we=Na;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ma=Te&&Te.exports===je,Pe=Ma?d.Buffer:void 0,Ra=Pe?Pe.isBuffer:void 0,La=Ra||we,bt=La;var Ba="[object Arguments]",ka="[object Array]",Ua="[object Boolean]",Da="[object Date]",za="[object Error]",Ga="[object Function]",Wa="[object Map]",Ka="[object Number]",$a="[object Object]",Ha="[object RegExp]",Va="[object Set]",qa="[object String]",Ya="[object WeakMap]",Za="[object ArrayBuffer]",Ja="[object DataView]",Xa="[object Float32Array]",Qa="[object Float64Array]",ti="[object Int8Array]",ei="[object Int16Array]",ri="[object Int32Array]",oi="[object Uint8Array]",ai="[object Uint8ClampedArray]",ii="[object Uint16Array]",si="[object Uint32Array]",m={};m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=m[ai]=m[ii]=m[si]=!0;m[Ba]=m[ka]=m[Za]=m[Ua]=m[Ja]=m[Da]=m[za]=m[Ga]=m[Wa]=m[Ka]=m[$a]=m[Ha]=m[Va]=m[qa]=m[Ya]=!1;function ni(t){return w(t)&&z(t.length)&&!!m[T(t)]}var Ae=ni;function fi(t){return function(e){return t(e)}}var K=fi;var Oe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Oe&&typeof module=="object"&&module&&!module.nodeType&&module,pi=st&&st.exports===Oe,Nt=pi&&ut.process,li=function(){try{var t=st&&st.require&&st.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),A=li;var Se=A&&A.isTypedArray,mi=Se?K(Se):Ae,Ie=mi;var ui=Object.prototype,di=ui.hasOwnProperty;function ci(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&Ie(t),i=r||o||a||s,n=i?be(t.length,String):[],u=n.length;for(var c in t)(e||di.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||U(c,u)))&&n.push(c);return n}var vt=ci;function hi(t,e){return function(r){return t(e(r))}}var wt=hi;var xi=wt(Object.keys,Object),_e=xi;var gi=Object.prototype,yi=gi.hasOwnProperty;function bi(t){if(!G(t))return _e(t);var e=[];for(var r in Object(t))yi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ee=bi;function vi(t){return yt(t)?vt(t):Ee(t)}var $=vi;function wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=wi;var Ti=Object.prototype,Pi=Ti.hasOwnProperty;function ji(t){if(!v(t))return Fe(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Ce=ji;function Ai(t){return yt(t)?vt(t,!0):Ce(t)}var H=Ai;var Oi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/;function Ii(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||B(t)?!0:Si.test(t)||!Oi.test(t)||e!=null&&t in Object(e)}var Ne=Ii;var _i=y(Object,"create"),O=_i;function Ei(){this.__data__=O?O(null):{},this.size=0}var Me=Ei;function Fi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re=Fi;var Ci="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Ri(t){var e=this.__data__;if(O){var r=e[t];return r===Ci?void 0:r}return Mi.call(e,t)?e[t]:void 0}var Le=Ri;var Li=Object.prototype,Bi=Li.hasOwnProperty;function ki(t){var e=this.__data__;return O?e[t]!==void 0:Bi.call(e,t)}var Be=ki;var Ui="__lodash_hash_undefined__";function Di(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=O&&e===void 0?Ui:e,this}var ke=Di;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=Me;V.prototype.delete=Re;V.prototype.get=Le;V.prototype.has=Be;V.prototype.set=ke;var Mt=V;function zi(){this.__data__=[],this.size=0}var Ue=zi;function Gi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var _=Gi;var Wi=Array.prototype,Ki=Wi.splice;function $i(t){var e=this.__data__,r=_(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ki.call(e,r,1),--this.size,!0}var De=$i;function Hi(t){var e=this.__data__,r=_(e,t);return r<0?void 0:e[r][1]}var ze=Hi;function Vi(t){return _(this.__data__,t)>-1}var Ge=Vi;function qi(t,e){var r=this.__data__,o=_(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=qi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Ue;q.prototype.delete=De;q.prototype.get=ze;q.prototype.has=Ge;q.prototype.set=We;var E=q;var Yi=y(d,"Map"),F=Yi;function Zi(){this.size=0,this.__data__={hash:new Mt,map:new(F||E),string:new Mt}}var Ke=Zi;function Ji(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Ji;function Xi(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var C=Xi;function Qi(t){var e=C(this,t).delete(t);return this.size-=e?1:0,e}var He=Qi;function ts(t){return C(this,t).get(t)}var Ve=ts;function es(t){return C(this,t).has(t)}var qe=es;function rs(t,e){var r=C(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ye=rs;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ke;Y.prototype.delete=He;Y.prototype.get=Ve;Y.prototype.has=qe;Y.prototype.set=Ye;var nt=Y;var os="Expected a function";function Rt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Rt.Cache||nt),r}Rt.Cache=nt;var Ze=Rt;var as=500;function is(t){var e=Ze(t,function(o){return r.size===as&&r.clear(),o}),r=e.cache;return e}var Je=is;var ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/\\(\\)?/g,fs=Je(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ss,function(r,o,a,s){e.push(a?s.replace(ns,"$1"):o||r)}),e}),Xe=fs;function ps(t){return t==null?"":re(t)}var Qe=ps;function ls(t,e){return x(t)?t:Ne(t,e)?[t]:Xe(Qe(t))}var N=ls;var ms=1/0;function us(t){if(typeof t=="string"||B(t))return t;var e=t+"";return e=="0"&&1/t==-ms?"-0":e}var Z=us;function ds(t,e){e=N(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[Z(e[r++])];return r&&r==o?t:void 0}var tr=ds;function cs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=cs;var er=g?g.isConcatSpreadable:void 0;function hs(t){return x(t)||W(t)||!!(er&&t&&t[er])}var rr=hs;function or(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=rr),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?or(n,e-1,r,o,a):J(a,n):o||(a[a.length]=n)}return a}var ar=or;function xs(t){var e=t==null?0:t.length;return e?ar(t,1):[]}var ir=xs;function gs(t){return he(ye(t,void 0,ir),t+"")}var sr=gs;var ys=wt(Object.getPrototypeOf,Object),Tt=ys;function bs(){this.__data__=new E,this.size=0}var nr=bs;function vs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var fr=vs;function ws(t){return this.__data__.get(t)}var pr=ws;function Ts(t){return this.__data__.has(t)}var lr=Ts;var Ps=200;function js(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!F||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new nt(o)}return r.set(t,e),this.size=r.size,this}var mr=js;function X(t){var e=this.__data__=new E(t);this.size=e.size}X.prototype.clear=nr;X.prototype.delete=fr;X.prototype.get=pr;X.prototype.has=lr;X.prototype.set=mr;var ur=X;function As(t,e){return t&&I(e,$(e),t)}var dr=As;function Os(t,e){return t&&I(e,H(e),t)}var cr=Os;var yr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hr=yr&&typeof module=="object"&&module&&!module.nodeType&&module,Ss=hr&&hr.exports===yr,xr=Ss?d.Buffer:void 0,gr=xr?xr.allocUnsafe:void 0;function Is(t,e){if(e)return t.slice();var r=t.length,o=gr?gr(r):new t.constructor(r);return t.copy(o),o}var br=Is;function _s(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var vr=_s;function Es(){return[]}var Pt=Es;var Fs=Object.prototype,Cs=Fs.propertyIsEnumerable,wr=Object.getOwnPropertySymbols,Ns=wr?function(t){return t==null?[]:(t=Object(t),vr(wr(t),function(e){return Cs.call(t,e)}))}:Pt,Q=Ns;function Ms(t,e){return I(t,Q(t),e)}var Tr=Ms;var Rs=Object.getOwnPropertySymbols,Ls=Rs?function(t){for(var e=[];t;)J(e,Q(t)),t=Tt(t);return e}:Pt,jt=Ls;function Bs(t,e){return I(t,jt(t),e)}var Pr=Bs;function ks(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var At=ks;function Us(t){return At(t,$,Q)}var jr=Us;function Ds(t){return At(t,H,jt)}var Ar=Ds;var zs=y(d,"DataView"),Ot=zs;var Gs=y(d,"Promise"),St=Gs;var Ws=y(d,"Set"),It=Ws;var Or="[object Map]",Ks="[object Object]",Sr="[object Promise]",Ir="[object Set]",_r="[object WeakMap]",Er="[object DataView]",$s=j(Ot),Hs=j(F),Vs=j(St),qs=j(It),Ys=j(ht),R=T;(Ot&&R(new Ot(new ArrayBuffer(1)))!=Er||F&&R(new F)!=Or||St&&R(St.resolve())!=Sr||It&&R(new It)!=Ir||ht&&R(new ht)!=_r)&&(R=function(t){var e=T(t),r=e==Ks?t.constructor:void 0,o=r?j(r):"";if(o)switch(o){case $s:return Er;case Hs:return Or;case Vs:return Sr;case qs:return Ir;case Ys:return _r}return e});var tt=R;var Zs=Object.prototype,Js=Zs.hasOwnProperty;function Xs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Js.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Fr=Xs;var Qs=d.Uint8Array,Lt=Qs;function tn(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var et=tn;function en(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Cr=en;var rn=/\w*$/;function on(t){var e=new t.constructor(t.source,rn.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=on;var Mr=g?g.prototype:void 0,Rr=Mr?Mr.valueOf:void 0;function an(t){return Rr?Object(Rr.call(t)):{}}var Lr=an;function sn(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Br=sn;var nn="[object Boolean]",fn="[object Date]",pn="[object Map]",ln="[object Number]",mn="[object RegExp]",un="[object Set]",dn="[object String]",cn="[object Symbol]",hn="[object ArrayBuffer]",xn="[object DataView]",gn="[object Float32Array]",yn="[object Float64Array]",bn="[object Int8Array]",vn="[object Int16Array]",wn="[object Int32Array]",Tn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",jn="[object Uint16Array]",An="[object Uint32Array]";function On(t,e,r){var o=t.constructor;switch(e){case hn:return et(t);case nn:case fn:return new o(+t);case xn:return Cr(t,r);case gn:case yn:case bn:case vn:case wn:case Tn:case Pn:case jn:case An:return Br(t,r);case pn:return new o;case ln:case dn:return new o(t);case mn:return Nr(t);case un:return new o;case cn:return Lr(t)}}var kr=On;function Sn(t){return typeof t.constructor=="function"&&!G(t)?pe(Tt(t)):{}}var Ur=Sn;var In="[object Map]";function _n(t){return w(t)&&tt(t)==In}var Dr=_n;var zr=A&&A.isMap,En=zr?K(zr):Dr,Gr=En;var Fn="[object Set]";function Cn(t){return w(t)&&tt(t)==Fn}var Wr=Cn;var Kr=A&&A.isSet,Nn=Kr?K(Kr):Wr,$r=Nn;var Mn=1,Rn=2,Ln=4,Hr="[object Arguments]",Bn="[object Array]",kn="[object Boolean]",Un="[object Date]",Dn="[object Error]",Vr="[object Function]",zn="[object GeneratorFunction]",Gn="[object Map]",Wn="[object Number]",qr="[object Object]",Kn="[object RegExp]",$n="[object Set]",Hn="[object String]",Vn="[object Symbol]",qn="[object WeakMap]",Yn="[object ArrayBuffer]",Zn="[object DataView]",Jn="[object Float32Array]",Xn="[object Float64Array]",Qn="[object Int8Array]",tf="[object Int16Array]",ef="[object Int32Array]",rf="[object Uint8Array]",of="[object Uint8ClampedArray]",af="[object Uint16Array]",sf="[object Uint32Array]",l={};l[Hr]=l[Bn]=l[Yn]=l[Zn]=l[kn]=l[Un]=l[Jn]=l[Xn]=l[Qn]=l[tf]=l[ef]=l[Gn]=l[Wn]=l[qr]=l[Kn]=l[$n]=l[Hn]=l[Vn]=l[rf]=l[of]=l[af]=l[sf]=!0;l[Dn]=l[Vr]=l[qn]=!1;function _t(t,e,r,o,a,s){var i,n=e&Mn,u=e&Rn,c=e&Ln;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!v(t))return t;var h=x(t);if(h){if(i=Fr(t),!n)return me(t,i)}else{var P=tt(t),ft=P==Vr||P==zn;if(bt(t))return br(t,n);if(P==qr||P==Hr||ft&&!a){if(i=u||ft?{}:Ur(t),!n)return u?Pr(t,cr(i,t)):Tr(t,dr(i,t))}else{if(!l[P])return a?t:{};i=kr(t,P,n)}}s||(s=new ur);var ot=s.get(t);if(ot)return ot;s.set(t,i),$r(t)?t.forEach(function(b){i.add(_t(b,e,r,b,t,s))}):Gr(t)&&t.forEach(function(b,f){i.set(f,_t(b,e,r,f,t,s))});var pt=c?u?Ar:jr:u?H:$,lt=h?void 0:pt(t);return xe(lt||t,function(b,f){lt&&(f=b,b=t[f]),D(i,f,_t(b,e,r,f,t,s))}),i}var Yr=_t;var nf=1,ff=4;function pf(t){return Yr(t,nf|ff)}var Bt=pf;function lf(t,e){return t!=null&&e in Object(t)}var Zr=lf;function mf(t,e,r){e=N(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=Z(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&z(a)&&U(i,a)&&(x(t)||W(t)))}var Jr=mf;function uf(t,e){return t!=null&&Jr(t,e,Zr)}var Xr=uf;function df(t,e,r,o){if(!v(t))return t;e=N(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var u=Z(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=n[u];c=o?o(h,u,n):void 0,c===void 0&&(c=v(h)?h:U(e[a+1])?[]:{})}D(n,u,c),n=n[u]}return t}var Qr=df;function cf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=tr(t,i);r(n,i)&&Qr(s,N(i,t),n)}return s}var to=cf;function hf(t,e){return to(t,e,function(r,o){return Xr(t,o)})}var eo=hf;var xf=sr(function(t,e){return t==null?{}:eo(t,e)}),Et=xf;function ro(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var oo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var kt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=oo[r[t]&63];return e};var gf="array",yf="bit",ao="bits",bf="byte",io="bytes",rt="",vf="exponent",wf="function",so="iec",Tf="Invalid number",Pf="Invalid rounding method",Ut="jedec",jf="object",no=".",Af="round",Of="s",Sf="si",If="kbit",_f="kB",Ef=" ",Ff="string",Cf="0",Dt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=rt,localeOptions:i={},separator:n=rt,spacer:u=Ef,symbols:c={},standard:h=rt,output:P=Ff,fullform:ft=!1,fullforms:ot=[],exponent:pt=-1,roundingMethod:lt=Af,precision:b=0}={}){let f=pt,L=Number(t),p=[],M=0,Ft=rt;h===Sf?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=ft===!0,Gt=L<0,Wt=Math[lt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Tf);if(typeof Wt!==wf)throw new TypeError(Pf);if(Gt&&(L=-L),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(L)/Math.log(mt)),f<0&&(f=0)),f>8&&(b>0&&(b+=8-f),f=8),P===vf)return f;if(L===0)p[0]=0,Ft=p[1]=Dt.symbol[h][e?ao:io][f];else{M=L/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(M=M*8,M>=mt&&f<8&&(M=M/mt,f++));let at=Math.pow(10,f>0?a:0);p[0]=Wt(M*at)/at,p[0]===mt&&f<8&&pt===-1&&(p[0]=1,f++),Ft=p[1]=o===10&&f===1?e?If:_f:Dt.symbol[h][e?ao:io][f]}if(Gt&&(p[0]=-p[0]),b>0&&(p[0]=p[0].toPrecision(b)),p[1]=c[p[1]]||p[1],s===!0?p[0]=p[0].toLocaleString():s.length>0?p[0]=p[0].toLocaleString(s,i):n.length>0&&(p[0]=p[0].toString().replace(no,n)),r&&a>0){let at=p[0].toString(),Kt=n||(at.match(/(\D)/g)||[]).pop()||no,$t=at.toString().split(Kt),Ht=$t[1]||rt,Vt=Ht.length,lo=a-Vt;p[0]=`${$t[0]}${Kt}${Ht.padEnd(Vt+lo,Cf)}`}return po&&(p[1]=ot[f]?ot[f]:Dt.fullform[h][f]+(e?yf:bf)+(p[0]===1?rt:Of)),P===gf?p:P===jf?{value:p[0],symbol:p[1],exponent:f,unit:Ft}:p.join(u)}var S=class t{constructor(e){this.meta={};if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){let r=Et(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]);return new t(r)}};var zt=class{constructor(e){this.settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};this.events=ro();this.dom={el:null,iframe:null,popup:null,stylesheet:null};this.methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","createProjectFolder","deleteProjectFolder","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];this.plugins=[];this.namespaces={};this.acceptPostboxes={};this.initPromise=null;e&&this.set(e)}send(e){let r=kt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||kt(),...Bt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):(r==null?void 0:r.action)=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):(r==null?void 0:r.action)=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r!=null&&r.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.initPromise)return this.initPromise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.initPromise=Promise.resolve().then(()=>{var o;return(o=this.settings).session||(o.session="tfy-"+this.getEntropicString(16))}).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths?this.settings.debugPaths=this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):this.settings.debugPaths=null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>(this.debug("INFO",4,"[6/6] Init complete"),r)).catch(o=>{throw this.debug("WARN",0,"Init process fault",o),o}),this.initPromise}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e(void 0)).catch(r)})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e(void 0)}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o(void 0)).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
- `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(s=>Object.getOwnPropertyNames(s).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){var r;return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),(r=this.dom)!=null&&r.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new S({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new S({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new S({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new S({tera:this,...r}))}moveProjectFile(e,r,o){return this.rpc("moveProjectFile",e,r,o).then(a=>a?new S({tera:this,...a}):null)}};export{zt as default};
1
+ var vo=typeof global=="object"&&global&&global.Object===Object&&global,dt=vo;var wo=typeof self=="object"&&self&&self.Object===Object&&self,To=dt||wo||Function("return this")(),d=To;var Po=d.Symbol,g=Po;var te=Object.prototype,jo=te.hasOwnProperty,Oo=te.toString,nt=g?g.toStringTag:void 0;function Ao(t){var e=jo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=Oo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var ee=Ao;var So=Object.prototype,Io=So.toString;function _o(t){return Io.call(t)}var re=_o;var Eo="[object Null]",Fo="[object Undefined]",oe=g?g.toStringTag:void 0;function Co(t){return t==null?t===void 0?Fo:Eo:oe&&oe in Object(t)?ee(t):re(t)}var w=Co;function No(t){return t!=null&&typeof t=="object"}var y=No;var Mo="[object Symbol]";function Ro(t){return typeof t=="symbol"||y(t)&&w(t)==Mo}var k=Ro;function Lo(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var ct=Lo;var Bo=Array.isArray,x=Bo;var ko=1/0,ae=g?g.prototype:void 0,ie=ae?ae.toString:void 0;function ne(t){if(typeof t=="string")return t;if(x(t))return ct(t,ne)+"";if(k(t))return ie?ie.call(t):"";var e=t+"";return e=="0"&&1/t==-ko?"-0":e}var se=ne;function Uo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var T=Uo;function Do(t){return t}var fe=Do;var Go="[object AsyncFunction]",zo="[object Function]",Ko="[object GeneratorFunction]",Wo="[object Proxy]";function $o(t){if(!T(t))return!1;var e=w(t);return e==zo||e==Ko||e==Go||e==Wo}var ht=$o;var Ho=d["__core-js_shared__"],xt=Ho;var pe=function(){var t=/[^.]+$/.exec(xt&&xt.keys&&xt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Vo(t){return!!pe&&pe in t}var le=Vo;var Yo=Function.prototype,qo=Yo.toString;function Zo(t){if(t!=null){try{return qo.call(t)}catch{}try{return t+""}catch{}}return""}var A=Zo;var Jo=/[\\^$.*+?()[\]{}|]/g,Xo=/^\[object .+?Constructor\]$/,Qo=Function.prototype,ta=Object.prototype,ea=Qo.toString,ra=ta.hasOwnProperty,oa=RegExp("^"+ea.call(ra).replace(Jo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function aa(t){if(!T(t)||le(t))return!1;var e=ht(t)?oa:Xo;return e.test(A(t))}var me=aa;function ia(t,e){return t==null?void 0:t[e]}var ue=ia;function na(t,e){var r=ue(t,e);return me(r)?r:void 0}var b=na;var sa=b(d,"WeakMap"),gt=sa;var de=Object.create,fa=function(){function t(){}return function(e){if(!T(e))return{};if(de)return de(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ce=fa;function pa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var he=pa;function la(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var xe=la;var ma=800,ua=16,da=Date.now;function ca(t){var e=0,r=0;return function(){var o=da(),a=ua-(o-r);if(r=o,a>0){if(++e>=ma)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ge=ca;function ha(t){return function(){return t}}var ye=ha;var xa=function(){try{var t=b(Object,"defineProperty");return t({},"",{}),t}catch{}}(),U=xa;var ga=U?function(t,e){return U(t,"toString",{configurable:!0,enumerable:!1,value:ye(e),writable:!0})}:fe,be=ga;var ya=ge(be),ve=ya;function ba(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var we=ba;var va=9007199254740991,wa=/^(?:0|[1-9]\d*)$/;function Ta(t,e){var r=typeof t;return e=e==null?va:e,!!e&&(r=="number"||r!="symbol"&&wa.test(t))&&t>-1&&t%1==0&&t<e}var D=Ta;function Pa(t,e,r){e=="__proto__"&&U?U(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var yt=Pa;function ja(t,e){return t===e||t!==t&&e!==e}var bt=ja;var Oa=Object.prototype,Aa=Oa.hasOwnProperty;function Sa(t,e,r){var o=t[e];(!(Aa.call(t,e)&&bt(o,r))||r===void 0&&!(e in t))&&yt(t,e,r)}var G=Sa;function Ia(t,e,r,o){var a=!r;r||(r={});for(var n=-1,i=e.length;++n<i;){var s=e[n],u=o?o(r[s],t[s],s,r,t):void 0;u===void 0&&(u=t[s]),a?yt(r,s,u):G(r,s,u)}return r}var O=Ia;var Te=Math.max;function _a(t,e,r){return e=Te(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,n=Te(o.length-e,0),i=Array(n);++a<n;)i[a]=o[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=o[a];return s[e]=r(i),he(t,this,s)}}var Pe=_a;var Ea=9007199254740991;function Fa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ea}var z=Fa;function Ca(t){return t!=null&&z(t.length)&&!ht(t)}var vt=Ca;var Na=Object.prototype;function Ma(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Na;return t===r}var K=Ma;function Ra(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var je=Ra;var La="[object Arguments]";function Ba(t){return y(t)&&w(t)==La}var Bt=Ba;var Oe=Object.prototype,ka=Oe.hasOwnProperty,Ua=Oe.propertyIsEnumerable,Da=Bt(function(){return arguments}())?Bt:function(t){return y(t)&&ka.call(t,"callee")&&!Ua.call(t,"callee")},W=Da;function Ga(){return!1}var Ae=Ga;var _e=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=_e&&typeof module=="object"&&module&&!module.nodeType&&module,za=Se&&Se.exports===_e,Ie=za?d.Buffer:void 0,Ka=Ie?Ie.isBuffer:void 0,Wa=Ka||Ae,wt=Wa;var $a="[object Arguments]",Ha="[object Array]",Va="[object Boolean]",Ya="[object Date]",qa="[object Error]",Za="[object Function]",Ja="[object Map]",Xa="[object Number]",Qa="[object Object]",ti="[object RegExp]",ei="[object Set]",ri="[object String]",oi="[object WeakMap]",ai="[object ArrayBuffer]",ii="[object DataView]",ni="[object Float32Array]",si="[object Float64Array]",fi="[object Int8Array]",pi="[object Int16Array]",li="[object Int32Array]",mi="[object Uint8Array]",ui="[object Uint8ClampedArray]",di="[object Uint16Array]",ci="[object Uint32Array]",m={};m[ni]=m[si]=m[fi]=m[pi]=m[li]=m[mi]=m[ui]=m[di]=m[ci]=!0;m[$a]=m[Ha]=m[ai]=m[Va]=m[ii]=m[Ya]=m[qa]=m[Za]=m[Ja]=m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=!1;function hi(t){return y(t)&&z(t.length)&&!!m[w(t)]}var Ee=hi;function xi(t){return function(e){return t(e)}}var $=xi;var Fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Fe&&typeof module=="object"&&module&&!module.nodeType&&module,gi=st&&st.exports===Fe,kt=gi&&dt.process,yi=function(){try{var t=st&&st.require&&st.require("util").types;return t||kt&&kt.binding&&kt.binding("util")}catch{}}(),S=yi;var Ce=S&&S.isTypedArray,bi=Ce?$(Ce):Ee,Ne=bi;var vi=Object.prototype,wi=vi.hasOwnProperty;function Ti(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&wt(t),n=!r&&!o&&!a&&Ne(t),i=r||o||a||n,s=i?je(t.length,String):[],u=s.length;for(var c in t)(e||wi.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||D(c,u)))&&s.push(c);return s}var Tt=Ti;function Pi(t,e){return function(r){return t(e(r))}}var Pt=Pi;var ji=Pt(Object.keys,Object),Me=ji;var Oi=Object.prototype,Ai=Oi.hasOwnProperty;function Si(t){if(!K(t))return Me(t);var e=[];for(var r in Object(t))Ai.call(t,r)&&r!="constructor"&&e.push(r);return e}var Re=Si;function Ii(t){return vt(t)?Tt(t):Re(t)}var H=Ii;function _i(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Le=_i;var Ei=Object.prototype,Fi=Ei.hasOwnProperty;function Ci(t){if(!T(t))return Le(t);var e=K(t),r=[];for(var o in t)o=="constructor"&&(e||!Fi.call(t,o))||r.push(o);return r}var Be=Ci;function Ni(t){return vt(t)?Tt(t,!0):Be(t)}var V=Ni;var Mi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ri=/^\w*$/;function Li(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||k(t)?!0:Ri.test(t)||!Mi.test(t)||e!=null&&t in Object(e)}var ke=Li;var Bi=b(Object,"create"),I=Bi;function ki(){this.__data__=I?I(null):{},this.size=0}var Ue=ki;function Ui(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var De=Ui;var Di="__lodash_hash_undefined__",Gi=Object.prototype,zi=Gi.hasOwnProperty;function Ki(t){var e=this.__data__;if(I){var r=e[t];return r===Di?void 0:r}return zi.call(e,t)?e[t]:void 0}var Ge=Ki;var Wi=Object.prototype,$i=Wi.hasOwnProperty;function Hi(t){var e=this.__data__;return I?e[t]!==void 0:$i.call(e,t)}var ze=Hi;var Vi="__lodash_hash_undefined__";function Yi(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=I&&e===void 0?Vi:e,this}var Ke=Yi;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ue;Y.prototype.delete=De;Y.prototype.get=Ge;Y.prototype.has=ze;Y.prototype.set=Ke;var Ut=Y;function qi(){this.__data__=[],this.size=0}var We=qi;function Zi(t,e){for(var r=t.length;r--;)if(bt(t[r][0],e))return r;return-1}var E=Zi;var Ji=Array.prototype,Xi=Ji.splice;function Qi(t){var e=this.__data__,r=E(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Xi.call(e,r,1),--this.size,!0}var $e=Qi;function tn(t){var e=this.__data__,r=E(e,t);return r<0?void 0:e[r][1]}var He=tn;function en(t){return E(this.__data__,t)>-1}var Ve=en;function rn(t,e){var r=this.__data__,o=E(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Ye=rn;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=We;q.prototype.delete=$e;q.prototype.get=He;q.prototype.has=Ve;q.prototype.set=Ye;var F=q;var on=b(d,"Map"),C=on;function an(){this.size=0,this.__data__={hash:new Ut,map:new(C||F),string:new Ut}}var qe=an;function nn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Ze=nn;function sn(t,e){var r=t.__data__;return Ze(e)?r[typeof e=="string"?"string":"hash"]:r.map}var N=sn;function fn(t){var e=N(this,t).delete(t);return this.size-=e?1:0,e}var Je=fn;function pn(t){return N(this,t).get(t)}var Xe=pn;function ln(t){return N(this,t).has(t)}var Qe=ln;function mn(t,e){var r=N(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var tr=mn;function Z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Z.prototype.clear=qe;Z.prototype.delete=Je;Z.prototype.get=Xe;Z.prototype.has=Qe;Z.prototype.set=tr;var ft=Z;var un="Expected a function";function Dt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(un);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],n=r.cache;if(n.has(a))return n.get(a);var i=t.apply(this,o);return r.cache=n.set(a,i)||n,i};return r.cache=new(Dt.Cache||ft),r}Dt.Cache=ft;var er=Dt;var dn=500;function cn(t){var e=er(t,function(o){return r.size===dn&&r.clear(),o}),r=e.cache;return e}var rr=cn;var hn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xn=/\\(\\)?/g,gn=rr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(hn,function(r,o,a,n){e.push(a?n.replace(xn,"$1"):o||r)}),e}),or=gn;function yn(t){return t==null?"":se(t)}var ar=yn;function bn(t,e){return x(t)?t:ke(t,e)?[t]:or(ar(t))}var P=bn;var vn=1/0;function wn(t){if(typeof t=="string"||k(t))return t;var e=t+"";return e=="0"&&1/t==-vn?"-0":e}var M=wn;function Tn(t,e){e=P(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[M(e[r++])];return r&&r==o?t:void 0}var jt=Tn;function Pn(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=Pn;var ir=g?g.isConcatSpreadable:void 0;function jn(t){return x(t)||W(t)||!!(ir&&t&&t[ir])}var nr=jn;function sr(t,e,r,o,a){var n=-1,i=t.length;for(r||(r=nr),a||(a=[]);++n<i;){var s=t[n];e>0&&r(s)?e>1?sr(s,e-1,r,o,a):J(a,s):o||(a[a.length]=s)}return a}var fr=sr;function On(t){var e=t==null?0:t.length;return e?fr(t,1):[]}var pr=On;function An(t){return ve(Pe(t,void 0,pr),t+"")}var Ot=An;var Sn=Pt(Object.getPrototypeOf,Object),X=Sn;var In="[object Object]",_n=Function.prototype,En=Object.prototype,lr=_n.toString,Fn=En.hasOwnProperty,Cn=lr.call(Object);function Nn(t){if(!y(t)||w(t)!=In)return!1;var e=X(t);if(e===null)return!0;var r=Fn.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&lr.call(r)==Cn}var mr=Nn;function Mn(t,e,r){var o=-1,a=t.length;e<0&&(e=-e>a?0:a+e),r=r>a?a:r,r<0&&(r+=a),a=e>r?0:r-e>>>0,e>>>=0;for(var n=Array(a);++o<a;)n[o]=t[o+e];return n}var ur=Mn;function Rn(){this.__data__=new F,this.size=0}var dr=Rn;function Ln(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var cr=Ln;function Bn(t){return this.__data__.get(t)}var hr=Bn;function kn(t){return this.__data__.has(t)}var xr=kn;var Un=200;function Dn(t,e){var r=this.__data__;if(r instanceof F){var o=r.__data__;if(!C||o.length<Un-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ft(o)}return r.set(t,e),this.size=r.size,this}var gr=Dn;function Q(t){var e=this.__data__=new F(t);this.size=e.size}Q.prototype.clear=dr;Q.prototype.delete=cr;Q.prototype.get=hr;Q.prototype.has=xr;Q.prototype.set=gr;var yr=Q;function Gn(t,e){return t&&O(e,H(e),t)}var br=Gn;function zn(t,e){return t&&O(e,V(e),t)}var vr=zn;var jr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wr=jr&&typeof module=="object"&&module&&!module.nodeType&&module,Kn=wr&&wr.exports===jr,Tr=Kn?d.Buffer:void 0,Pr=Tr?Tr.allocUnsafe:void 0;function Wn(t,e){if(e)return t.slice();var r=t.length,o=Pr?Pr(r):new t.constructor(r);return t.copy(o),o}var Or=Wn;function $n(t,e){for(var r=-1,o=t==null?0:t.length,a=0,n=[];++r<o;){var i=t[r];e(i,r,t)&&(n[a++]=i)}return n}var Ar=$n;function Hn(){return[]}var At=Hn;var Vn=Object.prototype,Yn=Vn.propertyIsEnumerable,Sr=Object.getOwnPropertySymbols,qn=Sr?function(t){return t==null?[]:(t=Object(t),Ar(Sr(t),function(e){return Yn.call(t,e)}))}:At,tt=qn;function Zn(t,e){return O(t,tt(t),e)}var Ir=Zn;var Jn=Object.getOwnPropertySymbols,Xn=Jn?function(t){for(var e=[];t;)J(e,tt(t)),t=X(t);return e}:At,St=Xn;function Qn(t,e){return O(t,St(t),e)}var _r=Qn;function ts(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var It=ts;function es(t){return It(t,H,tt)}var Er=es;function rs(t){return It(t,V,St)}var _t=rs;var os=b(d,"DataView"),Et=os;var as=b(d,"Promise"),Ft=as;var is=b(d,"Set"),Ct=is;var Fr="[object Map]",ns="[object Object]",Cr="[object Promise]",Nr="[object Set]",Mr="[object WeakMap]",Rr="[object DataView]",ss=A(Et),fs=A(C),ps=A(Ft),ls=A(Ct),ms=A(gt),L=w;(Et&&L(new Et(new ArrayBuffer(1)))!=Rr||C&&L(new C)!=Fr||Ft&&L(Ft.resolve())!=Cr||Ct&&L(new Ct)!=Nr||gt&&L(new gt)!=Mr)&&(L=function(t){var e=w(t),r=e==ns?t.constructor:void 0,o=r?A(r):"";if(o)switch(o){case ss:return Rr;case fs:return Fr;case ps:return Cr;case ls:return Nr;case ms:return Mr}return e});var et=L;var us=Object.prototype,ds=us.hasOwnProperty;function cs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&ds.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Lr=cs;var hs=d.Uint8Array,Gt=hs;function xs(t){var e=new t.constructor(t.byteLength);return new Gt(e).set(new Gt(t)),e}var rt=xs;function gs(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Br=gs;var ys=/\w*$/;function bs(t){var e=new t.constructor(t.source,ys.exec(t));return e.lastIndex=t.lastIndex,e}var kr=bs;var Ur=g?g.prototype:void 0,Dr=Ur?Ur.valueOf:void 0;function vs(t){return Dr?Object(Dr.call(t)):{}}var Gr=vs;function ws(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var zr=ws;var Ts="[object Boolean]",Ps="[object Date]",js="[object Map]",Os="[object Number]",As="[object RegExp]",Ss="[object Set]",Is="[object String]",_s="[object Symbol]",Es="[object ArrayBuffer]",Fs="[object DataView]",Cs="[object Float32Array]",Ns="[object Float64Array]",Ms="[object Int8Array]",Rs="[object Int16Array]",Ls="[object Int32Array]",Bs="[object Uint8Array]",ks="[object Uint8ClampedArray]",Us="[object Uint16Array]",Ds="[object Uint32Array]";function Gs(t,e,r){var o=t.constructor;switch(e){case Es:return rt(t);case Ts:case Ps:return new o(+t);case Fs:return Br(t,r);case Cs:case Ns:case Ms:case Rs:case Ls:case Bs:case ks:case Us:case Ds:return zr(t,r);case js:return new o;case Os:case Is:return new o(t);case As:return kr(t);case Ss:return new o;case _s:return Gr(t)}}var Kr=Gs;function zs(t){return typeof t.constructor=="function"&&!K(t)?ce(X(t)):{}}var Wr=zs;var Ks="[object Map]";function Ws(t){return y(t)&&et(t)==Ks}var $r=Ws;var Hr=S&&S.isMap,$s=Hr?$(Hr):$r,Vr=$s;var Hs="[object Set]";function Vs(t){return y(t)&&et(t)==Hs}var Yr=Vs;var qr=S&&S.isSet,Ys=qr?$(qr):Yr,Zr=Ys;var qs=1,Zs=2,Js=4,Jr="[object Arguments]",Xs="[object Array]",Qs="[object Boolean]",tf="[object Date]",ef="[object Error]",Xr="[object Function]",rf="[object GeneratorFunction]",of="[object Map]",af="[object Number]",Qr="[object Object]",nf="[object RegExp]",sf="[object Set]",ff="[object String]",pf="[object Symbol]",lf="[object WeakMap]",mf="[object ArrayBuffer]",uf="[object DataView]",df="[object Float32Array]",cf="[object Float64Array]",hf="[object Int8Array]",xf="[object Int16Array]",gf="[object Int32Array]",yf="[object Uint8Array]",bf="[object Uint8ClampedArray]",vf="[object Uint16Array]",wf="[object Uint32Array]",l={};l[Jr]=l[Xs]=l[mf]=l[uf]=l[Qs]=l[tf]=l[df]=l[cf]=l[hf]=l[xf]=l[gf]=l[of]=l[af]=l[Qr]=l[nf]=l[sf]=l[ff]=l[pf]=l[yf]=l[bf]=l[vf]=l[wf]=!0;l[ef]=l[Xr]=l[lf]=!1;function Nt(t,e,r,o,a,n){var i,s=e&qs,u=e&Zs,c=e&Js;if(r&&(i=a?r(t,o,a,n):r(t)),i!==void 0)return i;if(!T(t))return t;var h=x(t);if(h){if(i=Lr(t),!s)return xe(t,i)}else{var j=et(t),pt=j==Xr||j==rf;if(wt(t))return Or(t,s);if(j==Qr||j==Jr||pt&&!a){if(i=u||pt?{}:Wr(t),!s)return u?_r(t,vr(i,t)):Ir(t,br(i,t))}else{if(!l[j])return a?t:{};i=Kr(t,j,s)}}n||(n=new yr);var at=n.get(t);if(at)return at;n.set(t,i),Zr(t)?t.forEach(function(v){i.add(Nt(v,e,r,v,t,n))}):Vr(t)&&t.forEach(function(v,f){i.set(f,Nt(v,e,r,f,t,n))});var lt=c?u?_t:Er:u?V:H,mt=h?void 0:lt(t);return we(mt||t,function(v,f){mt&&(f=v,v=t[f]),G(i,f,Nt(v,e,r,f,t,n))}),i}var Mt=Nt;var Tf=1,Pf=4;function jf(t){return Mt(t,Tf|Pf)}var zt=jf;function Of(t,e){return t!=null&&e in Object(t)}var to=Of;function Af(t,e,r){e=P(e,t);for(var o=-1,a=e.length,n=!1;++o<a;){var i=M(e[o]);if(!(n=t!=null&&r(t,i)))break;t=t[i]}return n||++o!=a?n:(a=t==null?0:t.length,!!a&&z(a)&&D(i,a)&&(x(t)||W(t)))}var eo=Af;function Sf(t,e){return t!=null&&eo(t,e,to)}var ro=Sf;function If(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}var oo=If;function _f(t,e){return e.length<2?t:jt(t,ur(e,0,-1))}var ao=_f;function Ef(t,e){return e=P(e,t),t=ao(t,e),t==null||delete t[M(oo(e))]}var io=Ef;function Ff(t){return mr(t)?void 0:t}var no=Ff;var Cf=1,Nf=2,Mf=4,Rf=Ot(function(t,e){var r={};if(t==null)return r;var o=!1;e=ct(e,function(n){return n=P(n,t),o||(o=n.length>1),n}),O(t,_t(t),r),o&&(r=Mt(r,Cf|Nf|Mf,no));for(var a=e.length;a--;)io(r,e[a]);return r}),Kt=Rf;function Lf(t,e,r,o){if(!T(t))return t;e=P(e,t);for(var a=-1,n=e.length,i=n-1,s=t;s!=null&&++a<n;){var u=M(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=s[u];c=o?o(h,u,s):void 0,c===void 0&&(c=T(h)?h:D(e[a+1])?[]:{})}G(s,u,c),s=s[u]}return t}var so=Lf;function Bf(t,e,r){for(var o=-1,a=e.length,n={};++o<a;){var i=e[o],s=jt(t,i);r(s,i)&&so(n,P(i,t),s)}return n}var fo=Bf;function kf(t,e){return fo(t,e,function(r,o){return ro(t,o)})}var po=kf;var Uf=Ot(function(t,e){return t==null?{}:po(t,e)}),Rt=Uf;function lo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var mo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Wt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=mo[r[t]&63];return e};var Df="array",Gf="bit",uo="bits",zf="byte",co="bytes",ot="",Kf="exponent",Wf="function",ho="iec",$f="Invalid number",Hf="Invalid rounding method",$t="jedec",Vf="object",xo=".",Yf="round",qf="s",Zf="si",Jf="kbit",Xf="kB",Qf=" ",tp="string",ep="0",Ht={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function go(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:n=ot,localeOptions:i={},separator:s=ot,spacer:u=Qf,symbols:c={},standard:h=ot,output:j=tp,fullform:pt=!1,fullforms:at=[],exponent:lt=-1,roundingMethod:mt=Yf,precision:v=0}={}){let f=lt,B=Number(t),p=[],R=0,Lt=ot;h===Zf?(o=10,h=$t):h===ho||h===$t?o=2:o===2?h=ho:(o=10,h=$t);let ut=o===10?1e3:1024,yo=pt===!0,Yt=B<0,qt=Math[mt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError($f);if(typeof qt!==Wf)throw new TypeError(Hf);if(Yt&&(B=-B),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(B)/Math.log(ut)),f<0&&(f=0)),f>8&&(v>0&&(v+=8-f),f=8),j===Kf)return f;if(B===0)p[0]=0,Lt=p[1]=Ht.symbol[h][e?uo:co][f];else{R=B/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(R=R*8,R>=ut&&f<8&&(R=R/ut,f++));let it=Math.pow(10,f>0?a:0);p[0]=qt(R*it)/it,p[0]===ut&&f<8&&lt===-1&&(p[0]=1,f++),Lt=p[1]=o===10&&f===1?e?Jf:Xf:Ht.symbol[h][e?uo:co][f]}if(Yt&&(p[0]=-p[0]),v>0&&(p[0]=p[0].toPrecision(v)),p[1]=c[p[1]]||p[1],n===!0?p[0]=p[0].toLocaleString():n.length>0?p[0]=p[0].toLocaleString(n,i):s.length>0&&(p[0]=p[0].toString().replace(xo,s)),r&&a>0){let it=p[0].toString(),Zt=s||(it.match(/(\D)/g)||[]).pop()||xo,Jt=it.toString().split(Zt),Xt=Jt[1]||ot,Qt=Xt.length,bo=a-Qt;p[0]=`${Jt[0]}${Zt}${Xt.padEnd(Qt+bo,ep)}`}return yo&&(p[1]=at[f]?at[f]:Ht.fullform[h][f]+(e?Gf:zf)+(p[0]===1?ot:qf)),j===Df?p:j===Vf?{value:p[0],symbol:p[1],exponent:f,unit:Lt}:p.join(u)}var _=class t{constructor(e){this.meta={};var o;if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,Kt(e,"encodeIdFunction")),e.encodeIdFunction&&typeof e.encodeIdFunction=="function"&&(this.id=e.encodeIdFunction(this.id));let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.isFolder&&(this.files=(o=this.files)==null?void 0:o.map(a=>{let n=a.path.split(/\//).slice(3).join("/"),i=this.url+"/"+a.name;return a.meta.reflib&&(i=i.replace(/\/project\/download\//,"/project/library/")),new t({tera:this._tera,...a,sbId:a.id,id:a.path,encodeIdFunction:e.encodeIdFunction,path:n,url:i})})),this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=go(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Rt(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){let r=Rt(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]);return new t(r)}};var Vt=class{constructor(e){this.settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};this.events=lo();this.dom={el:null,iframe:null,popup:null,stylesheet:null};this.methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","createProjectFolder","deleteProjectFolder","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];this.plugins=[];this.namespaces={};this.acceptPostboxes={};this.initPromise=null;e&&this.set(e)}send(e){let r=Wt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Wt(),...zt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):(r==null?void 0:r.action)=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):(r==null?void 0:r.action)=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r!=null&&r.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.initPromise)return this.initPromise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.initPromise=Promise.resolve().then(()=>{var o;return(o=this.settings).session||(o.session="tfy-"+this.getEntropicString(16))}).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths?this.settings.debugPaths=this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):this.settings.debugPaths=null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>(this.debug("INFO",4,"[6/6] Init complete"),r)).catch(o=>{throw this.debug("WARN",0,"Init process fault",o),o}),this.initPromise}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e(void 0)).catch(r)})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e(void 0)}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let n=0,i,s=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++n),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(s),clearTimeout(i)}).then(()=>o(void 0)).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
+ `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(n=>Object.getOwnPropertyNames(n).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){var r;return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),(r=this.dom)!=null&&r.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new _({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new _({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new _({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new _({tera:this,...r}))}moveProjectFile(e,r,o){return this.rpc("moveProjectFile",e,r,o).then(a=>a?new _({tera:this,...a}):null)}};export{Vt as default};
3
3
  /*! Bundled license information:
4
4
 
5
5
  lodash-es/lodash.js:
package/dist/terafy.js CHANGED
@@ -1,5 +1,5 @@
1
- var mo=typeof global=="object"&&global&&global.Object===Object&&global,ut=mo;var uo=typeof self=="object"&&self&&self.Object===Object&&self,co=ut||uo||Function("return this")(),d=co;var ho=d.Symbol,g=ho;var qt=Object.prototype,xo=qt.hasOwnProperty,go=qt.toString,it=g?g.toStringTag:void 0;function yo(t){var e=xo.call(t,it),r=t[it];try{t[it]=void 0;var o=!0}catch{}var a=go.call(t);return o&&(e?t[it]=r:delete t[it]),a}var Yt=yo;var bo=Object.prototype,vo=bo.toString;function wo(t){return vo.call(t)}var Zt=wo;var To="[object Null]",Po="[object Undefined]",Jt=g?g.toStringTag:void 0;function jo(t){return t==null?t===void 0?Po:To:Jt&&Jt in Object(t)?Yt(t):Zt(t)}var T=jo;function Ao(t){return t!=null&&typeof t=="object"}var w=Ao;var Oo="[object Symbol]";function So(t){return typeof t=="symbol"||w(t)&&T(t)==Oo}var B=So;function Io(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Xt=Io;var _o=Array.isArray,x=_o;var Eo=1/0,Qt=g?g.prototype:void 0,te=Qt?Qt.toString:void 0;function ee(t){if(typeof t=="string")return t;if(x(t))return Xt(t,ee)+"";if(B(t))return te?te.call(t):"";var e=t+"";return e=="0"&&1/t==-Eo?"-0":e}var re=ee;function Fo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=Fo;function Co(t){return t}var oe=Co;var No="[object AsyncFunction]",Mo="[object Function]",Ro="[object GeneratorFunction]",Lo="[object Proxy]";function Bo(t){if(!v(t))return!1;var e=T(t);return e==Mo||e==Ro||e==No||e==Lo}var dt=Bo;var ko=d["__core-js_shared__"],ct=ko;var ae=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Uo(t){return!!ae&&ae in t}var ie=Uo;var Do=Function.prototype,zo=Do.toString;function Go(t){if(t!=null){try{return zo.call(t)}catch{}try{return t+""}catch{}}return""}var j=Go;var Wo=/[\\^$.*+?()[\]{}|]/g,Ko=/^\[object .+?Constructor\]$/,$o=Function.prototype,Ho=Object.prototype,Vo=$o.toString,qo=Ho.hasOwnProperty,Yo=RegExp("^"+Vo.call(qo).replace(Wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zo(t){if(!v(t)||ie(t))return!1;var e=dt(t)?Yo:Ko;return e.test(j(t))}var se=Zo;function Jo(t,e){return t?.[e]}var ne=Jo;function Xo(t,e){var r=ne(t,e);return se(r)?r:void 0}var y=Xo;var Qo=y(d,"WeakMap"),ht=Qo;var fe=Object.create,ta=function(){function t(){}return function(e){if(!v(e))return{};if(fe)return fe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),pe=ta;function ea(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var le=ea;function ra(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var me=ra;var oa=800,aa=16,ia=Date.now;function sa(t){var e=0,r=0;return function(){var o=ia(),a=aa-(o-r);if(r=o,a>0){if(++e>=oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ue=sa;function na(t){return function(){return t}}var de=na;var fa=function(){try{var t=y(Object,"defineProperty");return t({},"",{}),t}catch{}}(),k=fa;var pa=k?function(t,e){return k(t,"toString",{configurable:!0,enumerable:!1,value:de(e),writable:!0})}:oe,ce=pa;var la=ue(ce),he=la;function ma(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var xe=ma;var ua=9007199254740991,da=/^(?:0|[1-9]\d*)$/;function ca(t,e){var r=typeof t;return e=e??ua,!!e&&(r=="number"||r!="symbol"&&da.test(t))&&t>-1&&t%1==0&&t<e}var U=ca;function ha(t,e,r){e=="__proto__"&&k?k(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ha;function xa(t,e){return t===e||t!==t&&e!==e}var gt=xa;var ga=Object.prototype,ya=ga.hasOwnProperty;function ba(t,e,r){var o=t[e];(!(ya.call(t,e)&&gt(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var D=ba;function va(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],u=o?o(r[n],t[n],n,r,t):void 0;u===void 0&&(u=t[n]),a?xt(r,n,u):D(r,n,u)}return r}var I=va;var ge=Math.max;function wa(t,e,r){return e=ge(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ge(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),le(t,this,n)}}var ye=wa;var Ta=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ta}var z=Pa;function ja(t){return t!=null&&z(t.length)&&!dt(t)}var yt=ja;var Aa=Object.prototype;function Oa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var G=Oa;function Sa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var be=Sa;var Ia="[object Arguments]";function _a(t){return w(t)&&T(t)==Ia}var Ct=_a;var ve=Object.prototype,Ea=ve.hasOwnProperty,Fa=ve.propertyIsEnumerable,Ca=Ct(function(){return arguments}())?Ct:function(t){return w(t)&&Ea.call(t,"callee")&&!Fa.call(t,"callee")},W=Ca;function Na(){return!1}var we=Na;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ma=Te&&Te.exports===je,Pe=Ma?d.Buffer:void 0,Ra=Pe?Pe.isBuffer:void 0,La=Ra||we,bt=La;var Ba="[object Arguments]",ka="[object Array]",Ua="[object Boolean]",Da="[object Date]",za="[object Error]",Ga="[object Function]",Wa="[object Map]",Ka="[object Number]",$a="[object Object]",Ha="[object RegExp]",Va="[object Set]",qa="[object String]",Ya="[object WeakMap]",Za="[object ArrayBuffer]",Ja="[object DataView]",Xa="[object Float32Array]",Qa="[object Float64Array]",ti="[object Int8Array]",ei="[object Int16Array]",ri="[object Int32Array]",oi="[object Uint8Array]",ai="[object Uint8ClampedArray]",ii="[object Uint16Array]",si="[object Uint32Array]",m={};m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=m[ai]=m[ii]=m[si]=!0;m[Ba]=m[ka]=m[Za]=m[Ua]=m[Ja]=m[Da]=m[za]=m[Ga]=m[Wa]=m[Ka]=m[$a]=m[Ha]=m[Va]=m[qa]=m[Ya]=!1;function ni(t){return w(t)&&z(t.length)&&!!m[T(t)]}var Ae=ni;function fi(t){return function(e){return t(e)}}var K=fi;var Oe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Oe&&typeof module=="object"&&module&&!module.nodeType&&module,pi=st&&st.exports===Oe,Nt=pi&&ut.process,li=function(){try{var t=st&&st.require&&st.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),A=li;var Se=A&&A.isTypedArray,mi=Se?K(Se):Ae,Ie=mi;var ui=Object.prototype,di=ui.hasOwnProperty;function ci(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&Ie(t),i=r||o||a||s,n=i?be(t.length,String):[],u=n.length;for(var c in t)(e||di.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||U(c,u)))&&n.push(c);return n}var vt=ci;function hi(t,e){return function(r){return t(e(r))}}var wt=hi;var xi=wt(Object.keys,Object),_e=xi;var gi=Object.prototype,yi=gi.hasOwnProperty;function bi(t){if(!G(t))return _e(t);var e=[];for(var r in Object(t))yi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ee=bi;function vi(t){return yt(t)?vt(t):Ee(t)}var $=vi;function wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=wi;var Ti=Object.prototype,Pi=Ti.hasOwnProperty;function ji(t){if(!v(t))return Fe(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Ce=ji;function Ai(t){return yt(t)?vt(t,!0):Ce(t)}var H=Ai;var Oi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/;function Ii(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||B(t)?!0:Si.test(t)||!Oi.test(t)||e!=null&&t in Object(e)}var Ne=Ii;var _i=y(Object,"create"),O=_i;function Ei(){this.__data__=O?O(null):{},this.size=0}var Me=Ei;function Fi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re=Fi;var Ci="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Ri(t){var e=this.__data__;if(O){var r=e[t];return r===Ci?void 0:r}return Mi.call(e,t)?e[t]:void 0}var Le=Ri;var Li=Object.prototype,Bi=Li.hasOwnProperty;function ki(t){var e=this.__data__;return O?e[t]!==void 0:Bi.call(e,t)}var Be=ki;var Ui="__lodash_hash_undefined__";function Di(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=O&&e===void 0?Ui:e,this}var ke=Di;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=Me;V.prototype.delete=Re;V.prototype.get=Le;V.prototype.has=Be;V.prototype.set=ke;var Mt=V;function zi(){this.__data__=[],this.size=0}var Ue=zi;function Gi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var _=Gi;var Wi=Array.prototype,Ki=Wi.splice;function $i(t){var e=this.__data__,r=_(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ki.call(e,r,1),--this.size,!0}var De=$i;function Hi(t){var e=this.__data__,r=_(e,t);return r<0?void 0:e[r][1]}var ze=Hi;function Vi(t){return _(this.__data__,t)>-1}var Ge=Vi;function qi(t,e){var r=this.__data__,o=_(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=qi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Ue;q.prototype.delete=De;q.prototype.get=ze;q.prototype.has=Ge;q.prototype.set=We;var E=q;var Yi=y(d,"Map"),F=Yi;function Zi(){this.size=0,this.__data__={hash:new Mt,map:new(F||E),string:new Mt}}var Ke=Zi;function Ji(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Ji;function Xi(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var C=Xi;function Qi(t){var e=C(this,t).delete(t);return this.size-=e?1:0,e}var He=Qi;function ts(t){return C(this,t).get(t)}var Ve=ts;function es(t){return C(this,t).has(t)}var qe=es;function rs(t,e){var r=C(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ye=rs;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ke;Y.prototype.delete=He;Y.prototype.get=Ve;Y.prototype.has=qe;Y.prototype.set=Ye;var nt=Y;var os="Expected a function";function Rt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Rt.Cache||nt),r}Rt.Cache=nt;var Ze=Rt;var as=500;function is(t){var e=Ze(t,function(o){return r.size===as&&r.clear(),o}),r=e.cache;return e}var Je=is;var ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/\\(\\)?/g,fs=Je(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ss,function(r,o,a,s){e.push(a?s.replace(ns,"$1"):o||r)}),e}),Xe=fs;function ps(t){return t==null?"":re(t)}var Qe=ps;function ls(t,e){return x(t)?t:Ne(t,e)?[t]:Xe(Qe(t))}var N=ls;var ms=1/0;function us(t){if(typeof t=="string"||B(t))return t;var e=t+"";return e=="0"&&1/t==-ms?"-0":e}var Z=us;function ds(t,e){e=N(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[Z(e[r++])];return r&&r==o?t:void 0}var tr=ds;function cs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=cs;var er=g?g.isConcatSpreadable:void 0;function hs(t){return x(t)||W(t)||!!(er&&t&&t[er])}var rr=hs;function or(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=rr),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?or(n,e-1,r,o,a):J(a,n):o||(a[a.length]=n)}return a}var ar=or;function xs(t){var e=t==null?0:t.length;return e?ar(t,1):[]}var ir=xs;function gs(t){return he(ye(t,void 0,ir),t+"")}var sr=gs;var ys=wt(Object.getPrototypeOf,Object),Tt=ys;function bs(){this.__data__=new E,this.size=0}var nr=bs;function vs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var fr=vs;function ws(t){return this.__data__.get(t)}var pr=ws;function Ts(t){return this.__data__.has(t)}var lr=Ts;var Ps=200;function js(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!F||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new nt(o)}return r.set(t,e),this.size=r.size,this}var mr=js;function X(t){var e=this.__data__=new E(t);this.size=e.size}X.prototype.clear=nr;X.prototype.delete=fr;X.prototype.get=pr;X.prototype.has=lr;X.prototype.set=mr;var ur=X;function As(t,e){return t&&I(e,$(e),t)}var dr=As;function Os(t,e){return t&&I(e,H(e),t)}var cr=Os;var yr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hr=yr&&typeof module=="object"&&module&&!module.nodeType&&module,Ss=hr&&hr.exports===yr,xr=Ss?d.Buffer:void 0,gr=xr?xr.allocUnsafe:void 0;function Is(t,e){if(e)return t.slice();var r=t.length,o=gr?gr(r):new t.constructor(r);return t.copy(o),o}var br=Is;function _s(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var vr=_s;function Es(){return[]}var Pt=Es;var Fs=Object.prototype,Cs=Fs.propertyIsEnumerable,wr=Object.getOwnPropertySymbols,Ns=wr?function(t){return t==null?[]:(t=Object(t),vr(wr(t),function(e){return Cs.call(t,e)}))}:Pt,Q=Ns;function Ms(t,e){return I(t,Q(t),e)}var Tr=Ms;var Rs=Object.getOwnPropertySymbols,Ls=Rs?function(t){for(var e=[];t;)J(e,Q(t)),t=Tt(t);return e}:Pt,jt=Ls;function Bs(t,e){return I(t,jt(t),e)}var Pr=Bs;function ks(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var At=ks;function Us(t){return At(t,$,Q)}var jr=Us;function Ds(t){return At(t,H,jt)}var Ar=Ds;var zs=y(d,"DataView"),Ot=zs;var Gs=y(d,"Promise"),St=Gs;var Ws=y(d,"Set"),It=Ws;var Or="[object Map]",Ks="[object Object]",Sr="[object Promise]",Ir="[object Set]",_r="[object WeakMap]",Er="[object DataView]",$s=j(Ot),Hs=j(F),Vs=j(St),qs=j(It),Ys=j(ht),R=T;(Ot&&R(new Ot(new ArrayBuffer(1)))!=Er||F&&R(new F)!=Or||St&&R(St.resolve())!=Sr||It&&R(new It)!=Ir||ht&&R(new ht)!=_r)&&(R=function(t){var e=T(t),r=e==Ks?t.constructor:void 0,o=r?j(r):"";if(o)switch(o){case $s:return Er;case Hs:return Or;case Vs:return Sr;case qs:return Ir;case Ys:return _r}return e});var tt=R;var Zs=Object.prototype,Js=Zs.hasOwnProperty;function Xs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Js.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Fr=Xs;var Qs=d.Uint8Array,Lt=Qs;function tn(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var et=tn;function en(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Cr=en;var rn=/\w*$/;function on(t){var e=new t.constructor(t.source,rn.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=on;var Mr=g?g.prototype:void 0,Rr=Mr?Mr.valueOf:void 0;function an(t){return Rr?Object(Rr.call(t)):{}}var Lr=an;function sn(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Br=sn;var nn="[object Boolean]",fn="[object Date]",pn="[object Map]",ln="[object Number]",mn="[object RegExp]",un="[object Set]",dn="[object String]",cn="[object Symbol]",hn="[object ArrayBuffer]",xn="[object DataView]",gn="[object Float32Array]",yn="[object Float64Array]",bn="[object Int8Array]",vn="[object Int16Array]",wn="[object Int32Array]",Tn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",jn="[object Uint16Array]",An="[object Uint32Array]";function On(t,e,r){var o=t.constructor;switch(e){case hn:return et(t);case nn:case fn:return new o(+t);case xn:return Cr(t,r);case gn:case yn:case bn:case vn:case wn:case Tn:case Pn:case jn:case An:return Br(t,r);case pn:return new o;case ln:case dn:return new o(t);case mn:return Nr(t);case un:return new o;case cn:return Lr(t)}}var kr=On;function Sn(t){return typeof t.constructor=="function"&&!G(t)?pe(Tt(t)):{}}var Ur=Sn;var In="[object Map]";function _n(t){return w(t)&&tt(t)==In}var Dr=_n;var zr=A&&A.isMap,En=zr?K(zr):Dr,Gr=En;var Fn="[object Set]";function Cn(t){return w(t)&&tt(t)==Fn}var Wr=Cn;var Kr=A&&A.isSet,Nn=Kr?K(Kr):Wr,$r=Nn;var Mn=1,Rn=2,Ln=4,Hr="[object Arguments]",Bn="[object Array]",kn="[object Boolean]",Un="[object Date]",Dn="[object Error]",Vr="[object Function]",zn="[object GeneratorFunction]",Gn="[object Map]",Wn="[object Number]",qr="[object Object]",Kn="[object RegExp]",$n="[object Set]",Hn="[object String]",Vn="[object Symbol]",qn="[object WeakMap]",Yn="[object ArrayBuffer]",Zn="[object DataView]",Jn="[object Float32Array]",Xn="[object Float64Array]",Qn="[object Int8Array]",tf="[object Int16Array]",ef="[object Int32Array]",rf="[object Uint8Array]",of="[object Uint8ClampedArray]",af="[object Uint16Array]",sf="[object Uint32Array]",l={};l[Hr]=l[Bn]=l[Yn]=l[Zn]=l[kn]=l[Un]=l[Jn]=l[Xn]=l[Qn]=l[tf]=l[ef]=l[Gn]=l[Wn]=l[qr]=l[Kn]=l[$n]=l[Hn]=l[Vn]=l[rf]=l[of]=l[af]=l[sf]=!0;l[Dn]=l[Vr]=l[qn]=!1;function _t(t,e,r,o,a,s){var i,n=e&Mn,u=e&Rn,c=e&Ln;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!v(t))return t;var h=x(t);if(h){if(i=Fr(t),!n)return me(t,i)}else{var P=tt(t),ft=P==Vr||P==zn;if(bt(t))return br(t,n);if(P==qr||P==Hr||ft&&!a){if(i=u||ft?{}:Ur(t),!n)return u?Pr(t,cr(i,t)):Tr(t,dr(i,t))}else{if(!l[P])return a?t:{};i=kr(t,P,n)}}s||(s=new ur);var ot=s.get(t);if(ot)return ot;s.set(t,i),$r(t)?t.forEach(function(b){i.add(_t(b,e,r,b,t,s))}):Gr(t)&&t.forEach(function(b,f){i.set(f,_t(b,e,r,f,t,s))});var pt=c?u?Ar:jr:u?H:$,lt=h?void 0:pt(t);return xe(lt||t,function(b,f){lt&&(f=b,b=t[f]),D(i,f,_t(b,e,r,f,t,s))}),i}var Yr=_t;var nf=1,ff=4;function pf(t){return Yr(t,nf|ff)}var Bt=pf;function lf(t,e){return t!=null&&e in Object(t)}var Zr=lf;function mf(t,e,r){e=N(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=Z(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&z(a)&&U(i,a)&&(x(t)||W(t)))}var Jr=mf;function uf(t,e){return t!=null&&Jr(t,e,Zr)}var Xr=uf;function df(t,e,r,o){if(!v(t))return t;e=N(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var u=Z(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=n[u];c=o?o(h,u,n):void 0,c===void 0&&(c=v(h)?h:U(e[a+1])?[]:{})}D(n,u,c),n=n[u]}return t}var Qr=df;function cf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=tr(t,i);r(n,i)&&Qr(s,N(i,t),n)}return s}var to=cf;function hf(t,e){return to(t,e,function(r,o){return Xr(t,o)})}var eo=hf;var xf=sr(function(t,e){return t==null?{}:eo(t,e)}),Et=xf;function ro(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var oo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var kt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=oo[r[t]&63];return e};var gf="array",yf="bit",ao="bits",bf="byte",io="bytes",rt="",vf="exponent",wf="function",so="iec",Tf="Invalid number",Pf="Invalid rounding method",Ut="jedec",jf="object",no=".",Af="round",Of="s",Sf="si",If="kbit",_f="kB",Ef=" ",Ff="string",Cf="0",Dt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=rt,localeOptions:i={},separator:n=rt,spacer:u=Ef,symbols:c={},standard:h=rt,output:P=Ff,fullform:ft=!1,fullforms:ot=[],exponent:pt=-1,roundingMethod:lt=Af,precision:b=0}={}){let f=pt,L=Number(t),p=[],M=0,Ft=rt;h===Sf?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=ft===!0,Gt=L<0,Wt=Math[lt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Tf);if(typeof Wt!==wf)throw new TypeError(Pf);if(Gt&&(L=-L),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(L)/Math.log(mt)),f<0&&(f=0)),f>8&&(b>0&&(b+=8-f),f=8),P===vf)return f;if(L===0)p[0]=0,Ft=p[1]=Dt.symbol[h][e?ao:io][f];else{M=L/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(M=M*8,M>=mt&&f<8&&(M=M/mt,f++));let at=Math.pow(10,f>0?a:0);p[0]=Wt(M*at)/at,p[0]===mt&&f<8&&pt===-1&&(p[0]=1,f++),Ft=p[1]=o===10&&f===1?e?If:_f:Dt.symbol[h][e?ao:io][f]}if(Gt&&(p[0]=-p[0]),b>0&&(p[0]=p[0].toPrecision(b)),p[1]=c[p[1]]||p[1],s===!0?p[0]=p[0].toLocaleString():s.length>0?p[0]=p[0].toLocaleString(s,i):n.length>0&&(p[0]=p[0].toString().replace(no,n)),r&&a>0){let at=p[0].toString(),Kt=n||(at.match(/(\D)/g)||[]).pop()||no,$t=at.toString().split(Kt),Ht=$t[1]||rt,Vt=Ht.length,lo=a-Vt;p[0]=`${$t[0]}${Kt}${Ht.padEnd(Vt+lo,Cf)}`}return po&&(p[1]=ot[f]?ot[f]:Dt.fullform[h][f]+(e?yf:bf)+(p[0]===1?rt:Of)),P===gf?p:P===jf?{value:p[0],symbol:p[1],exponent:f,unit:Ft}:p.join(u)}var S=class t{constructor(e){this.meta={};if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){let r=Et(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]);return new t(r)}};var zt=class{constructor(e){this.settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};this.events=ro();this.dom={el:null,iframe:null,popup:null,stylesheet:null};this.methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","createProjectFolder","deleteProjectFolder","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];this.plugins=[];this.namespaces={};this.acceptPostboxes={};this.initPromise=null;e&&this.set(e)}send(e){let r=kt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||kt(),...Bt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):r?.action=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):r?.action=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r?.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.initPromise)return this.initPromise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.initPromise=Promise.resolve().then(()=>this.settings.session||="tfy-"+this.getEntropicString(16)).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths?this.settings.debugPaths=this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):this.settings.debugPaths=null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>(this.debug("INFO",4,"[6/6] Init complete"),r)).catch(o=>{throw this.debug("WARN",0,"Init process fault",o),o}),this.initPromise}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e(void 0)).catch(r)})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e(void 0)}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o(void 0)).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
- `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(s=>Object.getOwnPropertyNames(s).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),this.dom?.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new S({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new S({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new S({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new S({tera:this,...r}))}moveProjectFile(e,r,o){return this.rpc("moveProjectFile",e,r,o).then(a=>a?new S({tera:this,...a}):null)}};export{zt as default};
1
+ var vo=typeof global=="object"&&global&&global.Object===Object&&global,dt=vo;var wo=typeof self=="object"&&self&&self.Object===Object&&self,To=dt||wo||Function("return this")(),d=To;var Po=d.Symbol,x=Po;var te=Object.prototype,jo=te.hasOwnProperty,Oo=te.toString,nt=x?x.toStringTag:void 0;function Ao(t){var e=jo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=Oo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var ee=Ao;var So=Object.prototype,Io=So.toString;function _o(t){return Io.call(t)}var re=_o;var Eo="[object Null]",Fo="[object Undefined]",oe=x?x.toStringTag:void 0;function Co(t){return t==null?t===void 0?Fo:Eo:oe&&oe in Object(t)?ee(t):re(t)}var w=Co;function No(t){return t!=null&&typeof t=="object"}var y=No;var Mo="[object Symbol]";function Ro(t){return typeof t=="symbol"||y(t)&&w(t)==Mo}var k=Ro;function Lo(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var ct=Lo;var Bo=Array.isArray,g=Bo;var ko=1/0,ae=x?x.prototype:void 0,ie=ae?ae.toString:void 0;function ne(t){if(typeof t=="string")return t;if(g(t))return ct(t,ne)+"";if(k(t))return ie?ie.call(t):"";var e=t+"";return e=="0"&&1/t==-ko?"-0":e}var se=ne;function Uo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var T=Uo;function Do(t){return t}var fe=Do;var Go="[object AsyncFunction]",zo="[object Function]",Ko="[object GeneratorFunction]",Wo="[object Proxy]";function $o(t){if(!T(t))return!1;var e=w(t);return e==zo||e==Ko||e==Go||e==Wo}var ht=$o;var Ho=d["__core-js_shared__"],gt=Ho;var pe=function(){var t=/[^.]+$/.exec(gt&&gt.keys&&gt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Vo(t){return!!pe&&pe in t}var le=Vo;var Yo=Function.prototype,qo=Yo.toString;function Zo(t){if(t!=null){try{return qo.call(t)}catch{}try{return t+""}catch{}}return""}var A=Zo;var Jo=/[\\^$.*+?()[\]{}|]/g,Xo=/^\[object .+?Constructor\]$/,Qo=Function.prototype,ta=Object.prototype,ea=Qo.toString,ra=ta.hasOwnProperty,oa=RegExp("^"+ea.call(ra).replace(Jo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function aa(t){if(!T(t)||le(t))return!1;var e=ht(t)?oa:Xo;return e.test(A(t))}var me=aa;function ia(t,e){return t?.[e]}var ue=ia;function na(t,e){var r=ue(t,e);return me(r)?r:void 0}var b=na;var sa=b(d,"WeakMap"),xt=sa;var de=Object.create,fa=function(){function t(){}return function(e){if(!T(e))return{};if(de)return de(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ce=fa;function pa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var he=pa;function la(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ge=la;var ma=800,ua=16,da=Date.now;function ca(t){var e=0,r=0;return function(){var o=da(),a=ua-(o-r);if(r=o,a>0){if(++e>=ma)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var xe=ca;function ha(t){return function(){return t}}var ye=ha;var ga=function(){try{var t=b(Object,"defineProperty");return t({},"",{}),t}catch{}}(),U=ga;var xa=U?function(t,e){return U(t,"toString",{configurable:!0,enumerable:!1,value:ye(e),writable:!0})}:fe,be=xa;var ya=xe(be),ve=ya;function ba(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var we=ba;var va=9007199254740991,wa=/^(?:0|[1-9]\d*)$/;function Ta(t,e){var r=typeof t;return e=e??va,!!e&&(r=="number"||r!="symbol"&&wa.test(t))&&t>-1&&t%1==0&&t<e}var D=Ta;function Pa(t,e,r){e=="__proto__"&&U?U(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var yt=Pa;function ja(t,e){return t===e||t!==t&&e!==e}var bt=ja;var Oa=Object.prototype,Aa=Oa.hasOwnProperty;function Sa(t,e,r){var o=t[e];(!(Aa.call(t,e)&&bt(o,r))||r===void 0&&!(e in t))&&yt(t,e,r)}var G=Sa;function Ia(t,e,r,o){var a=!r;r||(r={});for(var i=-1,n=e.length;++i<n;){var s=e[i],u=o?o(r[s],t[s],s,r,t):void 0;u===void 0&&(u=t[s]),a?yt(r,s,u):G(r,s,u)}return r}var O=Ia;var Te=Math.max;function _a(t,e,r){return e=Te(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,i=Te(o.length-e,0),n=Array(i);++a<i;)n[a]=o[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=o[a];return s[e]=r(n),he(t,this,s)}}var Pe=_a;var Ea=9007199254740991;function Fa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ea}var z=Fa;function Ca(t){return t!=null&&z(t.length)&&!ht(t)}var vt=Ca;var Na=Object.prototype;function Ma(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Na;return t===r}var K=Ma;function Ra(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var je=Ra;var La="[object Arguments]";function Ba(t){return y(t)&&w(t)==La}var Bt=Ba;var Oe=Object.prototype,ka=Oe.hasOwnProperty,Ua=Oe.propertyIsEnumerable,Da=Bt(function(){return arguments}())?Bt:function(t){return y(t)&&ka.call(t,"callee")&&!Ua.call(t,"callee")},W=Da;function Ga(){return!1}var Ae=Ga;var _e=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=_e&&typeof module=="object"&&module&&!module.nodeType&&module,za=Se&&Se.exports===_e,Ie=za?d.Buffer:void 0,Ka=Ie?Ie.isBuffer:void 0,Wa=Ka||Ae,wt=Wa;var $a="[object Arguments]",Ha="[object Array]",Va="[object Boolean]",Ya="[object Date]",qa="[object Error]",Za="[object Function]",Ja="[object Map]",Xa="[object Number]",Qa="[object Object]",ti="[object RegExp]",ei="[object Set]",ri="[object String]",oi="[object WeakMap]",ai="[object ArrayBuffer]",ii="[object DataView]",ni="[object Float32Array]",si="[object Float64Array]",fi="[object Int8Array]",pi="[object Int16Array]",li="[object Int32Array]",mi="[object Uint8Array]",ui="[object Uint8ClampedArray]",di="[object Uint16Array]",ci="[object Uint32Array]",m={};m[ni]=m[si]=m[fi]=m[pi]=m[li]=m[mi]=m[ui]=m[di]=m[ci]=!0;m[$a]=m[Ha]=m[ai]=m[Va]=m[ii]=m[Ya]=m[qa]=m[Za]=m[Ja]=m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=!1;function hi(t){return y(t)&&z(t.length)&&!!m[w(t)]}var Ee=hi;function gi(t){return function(e){return t(e)}}var $=gi;var Fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Fe&&typeof module=="object"&&module&&!module.nodeType&&module,xi=st&&st.exports===Fe,kt=xi&&dt.process,yi=function(){try{var t=st&&st.require&&st.require("util").types;return t||kt&&kt.binding&&kt.binding("util")}catch{}}(),S=yi;var Ce=S&&S.isTypedArray,bi=Ce?$(Ce):Ee,Ne=bi;var vi=Object.prototype,wi=vi.hasOwnProperty;function Ti(t,e){var r=g(t),o=!r&&W(t),a=!r&&!o&&wt(t),i=!r&&!o&&!a&&Ne(t),n=r||o||a||i,s=n?je(t.length,String):[],u=s.length;for(var c in t)(e||wi.call(t,c))&&!(n&&(c=="length"||a&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||D(c,u)))&&s.push(c);return s}var Tt=Ti;function Pi(t,e){return function(r){return t(e(r))}}var Pt=Pi;var ji=Pt(Object.keys,Object),Me=ji;var Oi=Object.prototype,Ai=Oi.hasOwnProperty;function Si(t){if(!K(t))return Me(t);var e=[];for(var r in Object(t))Ai.call(t,r)&&r!="constructor"&&e.push(r);return e}var Re=Si;function Ii(t){return vt(t)?Tt(t):Re(t)}var H=Ii;function _i(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Le=_i;var Ei=Object.prototype,Fi=Ei.hasOwnProperty;function Ci(t){if(!T(t))return Le(t);var e=K(t),r=[];for(var o in t)o=="constructor"&&(e||!Fi.call(t,o))||r.push(o);return r}var Be=Ci;function Ni(t){return vt(t)?Tt(t,!0):Be(t)}var V=Ni;var Mi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ri=/^\w*$/;function Li(t,e){if(g(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||k(t)?!0:Ri.test(t)||!Mi.test(t)||e!=null&&t in Object(e)}var ke=Li;var Bi=b(Object,"create"),I=Bi;function ki(){this.__data__=I?I(null):{},this.size=0}var Ue=ki;function Ui(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var De=Ui;var Di="__lodash_hash_undefined__",Gi=Object.prototype,zi=Gi.hasOwnProperty;function Ki(t){var e=this.__data__;if(I){var r=e[t];return r===Di?void 0:r}return zi.call(e,t)?e[t]:void 0}var Ge=Ki;var Wi=Object.prototype,$i=Wi.hasOwnProperty;function Hi(t){var e=this.__data__;return I?e[t]!==void 0:$i.call(e,t)}var ze=Hi;var Vi="__lodash_hash_undefined__";function Yi(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=I&&e===void 0?Vi:e,this}var Ke=Yi;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ue;Y.prototype.delete=De;Y.prototype.get=Ge;Y.prototype.has=ze;Y.prototype.set=Ke;var Ut=Y;function qi(){this.__data__=[],this.size=0}var We=qi;function Zi(t,e){for(var r=t.length;r--;)if(bt(t[r][0],e))return r;return-1}var E=Zi;var Ji=Array.prototype,Xi=Ji.splice;function Qi(t){var e=this.__data__,r=E(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Xi.call(e,r,1),--this.size,!0}var $e=Qi;function tn(t){var e=this.__data__,r=E(e,t);return r<0?void 0:e[r][1]}var He=tn;function en(t){return E(this.__data__,t)>-1}var Ve=en;function rn(t,e){var r=this.__data__,o=E(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Ye=rn;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=We;q.prototype.delete=$e;q.prototype.get=He;q.prototype.has=Ve;q.prototype.set=Ye;var F=q;var on=b(d,"Map"),C=on;function an(){this.size=0,this.__data__={hash:new Ut,map:new(C||F),string:new Ut}}var qe=an;function nn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Ze=nn;function sn(t,e){var r=t.__data__;return Ze(e)?r[typeof e=="string"?"string":"hash"]:r.map}var N=sn;function fn(t){var e=N(this,t).delete(t);return this.size-=e?1:0,e}var Je=fn;function pn(t){return N(this,t).get(t)}var Xe=pn;function ln(t){return N(this,t).has(t)}var Qe=ln;function mn(t,e){var r=N(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var tr=mn;function Z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Z.prototype.clear=qe;Z.prototype.delete=Je;Z.prototype.get=Xe;Z.prototype.has=Qe;Z.prototype.set=tr;var ft=Z;var un="Expected a function";function Dt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(un);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],i=r.cache;if(i.has(a))return i.get(a);var n=t.apply(this,o);return r.cache=i.set(a,n)||i,n};return r.cache=new(Dt.Cache||ft),r}Dt.Cache=ft;var er=Dt;var dn=500;function cn(t){var e=er(t,function(o){return r.size===dn&&r.clear(),o}),r=e.cache;return e}var rr=cn;var hn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gn=/\\(\\)?/g,xn=rr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(hn,function(r,o,a,i){e.push(a?i.replace(gn,"$1"):o||r)}),e}),or=xn;function yn(t){return t==null?"":se(t)}var ar=yn;function bn(t,e){return g(t)?t:ke(t,e)?[t]:or(ar(t))}var P=bn;var vn=1/0;function wn(t){if(typeof t=="string"||k(t))return t;var e=t+"";return e=="0"&&1/t==-vn?"-0":e}var M=wn;function Tn(t,e){e=P(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[M(e[r++])];return r&&r==o?t:void 0}var jt=Tn;function Pn(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=Pn;var ir=x?x.isConcatSpreadable:void 0;function jn(t){return g(t)||W(t)||!!(ir&&t&&t[ir])}var nr=jn;function sr(t,e,r,o,a){var i=-1,n=t.length;for(r||(r=nr),a||(a=[]);++i<n;){var s=t[i];e>0&&r(s)?e>1?sr(s,e-1,r,o,a):J(a,s):o||(a[a.length]=s)}return a}var fr=sr;function On(t){var e=t==null?0:t.length;return e?fr(t,1):[]}var pr=On;function An(t){return ve(Pe(t,void 0,pr),t+"")}var Ot=An;var Sn=Pt(Object.getPrototypeOf,Object),X=Sn;var In="[object Object]",_n=Function.prototype,En=Object.prototype,lr=_n.toString,Fn=En.hasOwnProperty,Cn=lr.call(Object);function Nn(t){if(!y(t)||w(t)!=In)return!1;var e=X(t);if(e===null)return!0;var r=Fn.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&lr.call(r)==Cn}var mr=Nn;function Mn(t,e,r){var o=-1,a=t.length;e<0&&(e=-e>a?0:a+e),r=r>a?a:r,r<0&&(r+=a),a=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(a);++o<a;)i[o]=t[o+e];return i}var ur=Mn;function Rn(){this.__data__=new F,this.size=0}var dr=Rn;function Ln(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var cr=Ln;function Bn(t){return this.__data__.get(t)}var hr=Bn;function kn(t){return this.__data__.has(t)}var gr=kn;var Un=200;function Dn(t,e){var r=this.__data__;if(r instanceof F){var o=r.__data__;if(!C||o.length<Un-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ft(o)}return r.set(t,e),this.size=r.size,this}var xr=Dn;function Q(t){var e=this.__data__=new F(t);this.size=e.size}Q.prototype.clear=dr;Q.prototype.delete=cr;Q.prototype.get=hr;Q.prototype.has=gr;Q.prototype.set=xr;var yr=Q;function Gn(t,e){return t&&O(e,H(e),t)}var br=Gn;function zn(t,e){return t&&O(e,V(e),t)}var vr=zn;var jr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wr=jr&&typeof module=="object"&&module&&!module.nodeType&&module,Kn=wr&&wr.exports===jr,Tr=Kn?d.Buffer:void 0,Pr=Tr?Tr.allocUnsafe:void 0;function Wn(t,e){if(e)return t.slice();var r=t.length,o=Pr?Pr(r):new t.constructor(r);return t.copy(o),o}var Or=Wn;function $n(t,e){for(var r=-1,o=t==null?0:t.length,a=0,i=[];++r<o;){var n=t[r];e(n,r,t)&&(i[a++]=n)}return i}var Ar=$n;function Hn(){return[]}var At=Hn;var Vn=Object.prototype,Yn=Vn.propertyIsEnumerable,Sr=Object.getOwnPropertySymbols,qn=Sr?function(t){return t==null?[]:(t=Object(t),Ar(Sr(t),function(e){return Yn.call(t,e)}))}:At,tt=qn;function Zn(t,e){return O(t,tt(t),e)}var Ir=Zn;var Jn=Object.getOwnPropertySymbols,Xn=Jn?function(t){for(var e=[];t;)J(e,tt(t)),t=X(t);return e}:At,St=Xn;function Qn(t,e){return O(t,St(t),e)}var _r=Qn;function ts(t,e,r){var o=e(t);return g(t)?o:J(o,r(t))}var It=ts;function es(t){return It(t,H,tt)}var Er=es;function rs(t){return It(t,V,St)}var _t=rs;var os=b(d,"DataView"),Et=os;var as=b(d,"Promise"),Ft=as;var is=b(d,"Set"),Ct=is;var Fr="[object Map]",ns="[object Object]",Cr="[object Promise]",Nr="[object Set]",Mr="[object WeakMap]",Rr="[object DataView]",ss=A(Et),fs=A(C),ps=A(Ft),ls=A(Ct),ms=A(xt),L=w;(Et&&L(new Et(new ArrayBuffer(1)))!=Rr||C&&L(new C)!=Fr||Ft&&L(Ft.resolve())!=Cr||Ct&&L(new Ct)!=Nr||xt&&L(new xt)!=Mr)&&(L=function(t){var e=w(t),r=e==ns?t.constructor:void 0,o=r?A(r):"";if(o)switch(o){case ss:return Rr;case fs:return Fr;case ps:return Cr;case ls:return Nr;case ms:return Mr}return e});var et=L;var us=Object.prototype,ds=us.hasOwnProperty;function cs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&ds.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Lr=cs;var hs=d.Uint8Array,Gt=hs;function gs(t){var e=new t.constructor(t.byteLength);return new Gt(e).set(new Gt(t)),e}var rt=gs;function xs(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Br=xs;var ys=/\w*$/;function bs(t){var e=new t.constructor(t.source,ys.exec(t));return e.lastIndex=t.lastIndex,e}var kr=bs;var Ur=x?x.prototype:void 0,Dr=Ur?Ur.valueOf:void 0;function vs(t){return Dr?Object(Dr.call(t)):{}}var Gr=vs;function ws(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var zr=ws;var Ts="[object Boolean]",Ps="[object Date]",js="[object Map]",Os="[object Number]",As="[object RegExp]",Ss="[object Set]",Is="[object String]",_s="[object Symbol]",Es="[object ArrayBuffer]",Fs="[object DataView]",Cs="[object Float32Array]",Ns="[object Float64Array]",Ms="[object Int8Array]",Rs="[object Int16Array]",Ls="[object Int32Array]",Bs="[object Uint8Array]",ks="[object Uint8ClampedArray]",Us="[object Uint16Array]",Ds="[object Uint32Array]";function Gs(t,e,r){var o=t.constructor;switch(e){case Es:return rt(t);case Ts:case Ps:return new o(+t);case Fs:return Br(t,r);case Cs:case Ns:case Ms:case Rs:case Ls:case Bs:case ks:case Us:case Ds:return zr(t,r);case js:return new o;case Os:case Is:return new o(t);case As:return kr(t);case Ss:return new o;case _s:return Gr(t)}}var Kr=Gs;function zs(t){return typeof t.constructor=="function"&&!K(t)?ce(X(t)):{}}var Wr=zs;var Ks="[object Map]";function Ws(t){return y(t)&&et(t)==Ks}var $r=Ws;var Hr=S&&S.isMap,$s=Hr?$(Hr):$r,Vr=$s;var Hs="[object Set]";function Vs(t){return y(t)&&et(t)==Hs}var Yr=Vs;var qr=S&&S.isSet,Ys=qr?$(qr):Yr,Zr=Ys;var qs=1,Zs=2,Js=4,Jr="[object Arguments]",Xs="[object Array]",Qs="[object Boolean]",tf="[object Date]",ef="[object Error]",Xr="[object Function]",rf="[object GeneratorFunction]",of="[object Map]",af="[object Number]",Qr="[object Object]",nf="[object RegExp]",sf="[object Set]",ff="[object String]",pf="[object Symbol]",lf="[object WeakMap]",mf="[object ArrayBuffer]",uf="[object DataView]",df="[object Float32Array]",cf="[object Float64Array]",hf="[object Int8Array]",gf="[object Int16Array]",xf="[object Int32Array]",yf="[object Uint8Array]",bf="[object Uint8ClampedArray]",vf="[object Uint16Array]",wf="[object Uint32Array]",l={};l[Jr]=l[Xs]=l[mf]=l[uf]=l[Qs]=l[tf]=l[df]=l[cf]=l[hf]=l[gf]=l[xf]=l[of]=l[af]=l[Qr]=l[nf]=l[sf]=l[ff]=l[pf]=l[yf]=l[bf]=l[vf]=l[wf]=!0;l[ef]=l[Xr]=l[lf]=!1;function Nt(t,e,r,o,a,i){var n,s=e&qs,u=e&Zs,c=e&Js;if(r&&(n=a?r(t,o,a,i):r(t)),n!==void 0)return n;if(!T(t))return t;var h=g(t);if(h){if(n=Lr(t),!s)return ge(t,n)}else{var j=et(t),pt=j==Xr||j==rf;if(wt(t))return Or(t,s);if(j==Qr||j==Jr||pt&&!a){if(n=u||pt?{}:Wr(t),!s)return u?_r(t,vr(n,t)):Ir(t,br(n,t))}else{if(!l[j])return a?t:{};n=Kr(t,j,s)}}i||(i=new yr);var at=i.get(t);if(at)return at;i.set(t,n),Zr(t)?t.forEach(function(v){n.add(Nt(v,e,r,v,t,i))}):Vr(t)&&t.forEach(function(v,f){n.set(f,Nt(v,e,r,f,t,i))});var lt=c?u?_t:Er:u?V:H,mt=h?void 0:lt(t);return we(mt||t,function(v,f){mt&&(f=v,v=t[f]),G(n,f,Nt(v,e,r,f,t,i))}),n}var Mt=Nt;var Tf=1,Pf=4;function jf(t){return Mt(t,Tf|Pf)}var zt=jf;function Of(t,e){return t!=null&&e in Object(t)}var to=Of;function Af(t,e,r){e=P(e,t);for(var o=-1,a=e.length,i=!1;++o<a;){var n=M(e[o]);if(!(i=t!=null&&r(t,n)))break;t=t[n]}return i||++o!=a?i:(a=t==null?0:t.length,!!a&&z(a)&&D(n,a)&&(g(t)||W(t)))}var eo=Af;function Sf(t,e){return t!=null&&eo(t,e,to)}var ro=Sf;function If(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}var oo=If;function _f(t,e){return e.length<2?t:jt(t,ur(e,0,-1))}var ao=_f;function Ef(t,e){return e=P(e,t),t=ao(t,e),t==null||delete t[M(oo(e))]}var io=Ef;function Ff(t){return mr(t)?void 0:t}var no=Ff;var Cf=1,Nf=2,Mf=4,Rf=Ot(function(t,e){var r={};if(t==null)return r;var o=!1;e=ct(e,function(i){return i=P(i,t),o||(o=i.length>1),i}),O(t,_t(t),r),o&&(r=Mt(r,Cf|Nf|Mf,no));for(var a=e.length;a--;)io(r,e[a]);return r}),Kt=Rf;function Lf(t,e,r,o){if(!T(t))return t;e=P(e,t);for(var a=-1,i=e.length,n=i-1,s=t;s!=null&&++a<i;){var u=M(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=n){var h=s[u];c=o?o(h,u,s):void 0,c===void 0&&(c=T(h)?h:D(e[a+1])?[]:{})}G(s,u,c),s=s[u]}return t}var so=Lf;function Bf(t,e,r){for(var o=-1,a=e.length,i={};++o<a;){var n=e[o],s=jt(t,n);r(s,n)&&so(i,P(n,t),s)}return i}var fo=Bf;function kf(t,e){return fo(t,e,function(r,o){return ro(t,o)})}var po=kf;var Uf=Ot(function(t,e){return t==null?{}:po(t,e)}),Rt=Uf;function lo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var mo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Wt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=mo[r[t]&63];return e};var Df="array",Gf="bit",uo="bits",zf="byte",co="bytes",ot="",Kf="exponent",Wf="function",ho="iec",$f="Invalid number",Hf="Invalid rounding method",$t="jedec",Vf="object",go=".",Yf="round",qf="s",Zf="si",Jf="kbit",Xf="kB",Qf=" ",tp="string",ep="0",Ht={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function xo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:i=ot,localeOptions:n={},separator:s=ot,spacer:u=Qf,symbols:c={},standard:h=ot,output:j=tp,fullform:pt=!1,fullforms:at=[],exponent:lt=-1,roundingMethod:mt=Yf,precision:v=0}={}){let f=lt,B=Number(t),p=[],R=0,Lt=ot;h===Zf?(o=10,h=$t):h===ho||h===$t?o=2:o===2?h=ho:(o=10,h=$t);let ut=o===10?1e3:1024,yo=pt===!0,Yt=B<0,qt=Math[mt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError($f);if(typeof qt!==Wf)throw new TypeError(Hf);if(Yt&&(B=-B),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(B)/Math.log(ut)),f<0&&(f=0)),f>8&&(v>0&&(v+=8-f),f=8),j===Kf)return f;if(B===0)p[0]=0,Lt=p[1]=Ht.symbol[h][e?uo:co][f];else{R=B/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(R=R*8,R>=ut&&f<8&&(R=R/ut,f++));let it=Math.pow(10,f>0?a:0);p[0]=qt(R*it)/it,p[0]===ut&&f<8&&lt===-1&&(p[0]=1,f++),Lt=p[1]=o===10&&f===1?e?Jf:Xf:Ht.symbol[h][e?uo:co][f]}if(Yt&&(p[0]=-p[0]),v>0&&(p[0]=p[0].toPrecision(v)),p[1]=c[p[1]]||p[1],i===!0?p[0]=p[0].toLocaleString():i.length>0?p[0]=p[0].toLocaleString(i,n):s.length>0&&(p[0]=p[0].toString().replace(go,s)),r&&a>0){let it=p[0].toString(),Zt=s||(it.match(/(\D)/g)||[]).pop()||go,Jt=it.toString().split(Zt),Xt=Jt[1]||ot,Qt=Xt.length,bo=a-Qt;p[0]=`${Jt[0]}${Zt}${Xt.padEnd(Qt+bo,ep)}`}return yo&&(p[1]=at[f]?at[f]:Ht.fullform[h][f]+(e?Gf:zf)+(p[0]===1?ot:qf)),j===Df?p:j===Vf?{value:p[0],symbol:p[1],exponent:f,unit:Lt}:p.join(u)}var _=class t{constructor(e){this.meta={};if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,Kt(e,"encodeIdFunction")),e.encodeIdFunction&&typeof e.encodeIdFunction=="function"&&(this.id=e.encodeIdFunction(this.id));let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.isFolder&&(this.files=this.files?.map(o=>{let a=o.path.split(/\//).slice(3).join("/"),i=this.url+"/"+o.name;return o.meta.reflib&&(i=i.replace(/\/project\/download\//,"/project/library/")),new t({tera:this._tera,...o,sbId:o.id,id:o.path,encodeIdFunction:e.encodeIdFunction,path:a,url:i})})),this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=xo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Rt(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){let r=Rt(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]);return new t(r)}};var Vt=class{constructor(e){this.settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};this.events=lo();this.dom={el:null,iframe:null,popup:null,stylesheet:null};this.methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","createProjectFolder","deleteProjectFolder","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];this.plugins=[];this.namespaces={};this.acceptPostboxes={};this.initPromise=null;e&&this.set(e)}send(e){let r=Wt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Wt(),...zt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):r?.action=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):r?.action=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r?.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.initPromise)return this.initPromise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.initPromise=Promise.resolve().then(()=>this.settings.session||="tfy-"+this.getEntropicString(16)).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths?this.settings.debugPaths=this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):this.settings.debugPaths=null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>(this.debug("INFO",4,"[6/6] Init complete"),r)).catch(o=>{throw this.debug("WARN",0,"Init process fault",o),o}),this.initPromise}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e(void 0)).catch(r)})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e(void 0)}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let i=0,n,s=setTimeout(()=>{clearTimeout(n),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++i),clearTimeout(n),n=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(s),clearTimeout(n)}).then(()=>o(void 0)).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
+ `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(i=>Object.getOwnPropertyNames(i).filter(n=>!["constructor","init","prototype","name"].includes(n)&&!n.startsWith("__")).forEach(n=>{typeof r[n]=="function"?Object.defineProperty(e,n,{enumerable:!1,value:r[n].bind(e)}):e[n]=r[n]}))}toggleDevMode(e="toggle"){return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),this.dom?.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new _({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new _({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new _({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new _({tera:this,...r}))}moveProjectFile(e,r,o){return this.rpc("moveProjectFile",e,r,o).then(a=>a?new _({tera:this,...a}):null)}};export{Vt as default};
3
3
  /*! Bundled license information:
4
4
 
5
5
  lodash-es/lodash.js:
@@ -1,5 +1,5 @@
1
1
  import { filesize } from 'filesize';
2
- import { pick } from 'lodash-es';
2
+ import { pick, omit } from 'lodash-es';
3
3
  import type TeraFy from './terafy.client.ts';
4
4
 
5
5
  // TODO: Refactor terafy.client.ts so that we don't need to extend the class with injected functions
@@ -165,6 +165,15 @@ export default class ProjectFile {
165
165
  // Using Record<string, any> for a generic object, adjust if meta has a known structure
166
166
  meta: Record<string, any> = {};
167
167
 
168
+ /**
169
+ * Whether this is a folder or not
170
+ */
171
+ isFolder!: boolean;
172
+
173
+ /**
174
+ * If it is a folder, it will have an array of files in the folder
175
+ */
176
+ files?: ProjectFile[];
168
177
 
169
178
  /**
170
179
  * ProjectFile constructor
@@ -176,7 +185,12 @@ export default class ProjectFile {
176
185
  constructor(baseFile: SupabaseFile) {
177
186
  // Note: baseFile.tera is assumed to exist based on the check below and the SupabaseFile type definition above
178
187
  if (!baseFile.tera) throw new Error('Basic file requires a `tera` key to access the Tera instance');
179
- Object.assign(this, baseFile);
188
+ Object.assign(this, omit(baseFile, 'encodeIdFunction')); // don't copy encodeIdFunction
189
+
190
+ // Check whether encodeIdFunction exists and if it does then parse the id
191
+ if (baseFile.encodeIdFunction && typeof baseFile.encodeIdFunction === 'function') {
192
+ this.id = baseFile.encodeIdFunction(this.id);
193
+ }
180
194
 
181
195
  // Translate baseFile.tera -> this._tera (non-enumerable, non-configurable)
182
196
  const tera = (this as any).tera;
@@ -191,6 +205,27 @@ export default class ProjectFile {
191
205
 
192
206
  delete (this as any).tera; // Remove original ref we merged above
193
207
 
208
+ if (this.isFolder) {
209
+ // Process all files in the folder
210
+ this.files = this.files?.map(file => {
211
+ let path = file.path.split(/\//).slice(3).join('/');
212
+ let url = this.url + '/' + file.name // Add file name to url
213
+ // Parse url to show library instead of download if reflib file
214
+ if (file.meta.reflib) {
215
+ url = url.replace(/\/project\/download\//, '/project/library/');
216
+ }
217
+ return new ProjectFile({
218
+ tera: this._tera,
219
+ ...file,
220
+ sbId: file.id, // Sash the original Supabase ID under sbId
221
+ id: file.path,
222
+ encodeIdFunction: baseFile.encodeIdFunction,
223
+ path,
224
+ url,
225
+ })
226
+ })
227
+ }
228
+
194
229
  // Calculate `teraUrl` from URL
195
230
  // Assuming this.url is always defined after Object.assign
196
231
  this.teraUrl = this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/, '/project/$1');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/tera-fy",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "TERA website worker",
5
5
  "scripts": {
6
6
  "dev": "esbuild --platform=browser --format=esm --bundle lib/terafy.client.ts --outfile=dist/terafy.js --minify --serve --servedir=.",
@@ -104,7 +104,7 @@
104
104
  "node": ">=18"
105
105
  },
106
106
  "dependencies": {
107
- "@iebh/supabasey": "^1.1.0",
107
+ "@iebh/supabasey": "^1.1.4",
108
108
  "@momsfriendlydevco/marshal": "^2.1.4",
109
109
  "detect-port": "^2.1.0",
110
110
  "filesize": "^10.1.6",