@iebh/tera-fy 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/api.md +410 -392
- package/dist/plugin.vue2.es2019.js +1 -1
- package/dist/terafy.es2019.js +1 -1
- package/dist/terafy.js +1 -1
- package/lib/projectFile.js +19 -0
- package/lib/terafy.client.js +1 -1
- package/lib/terafy.server.js +42 -67
- package/package.json +3 -3
- package/plugins/base.js +1 -1
- package/plugins/vue2.js +24 -66
- package/utils/pathTools.js +138 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var fr=Object.defineProperty;var sr=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var H=(t,e,r)=>(sr(t,typeof e!="symbol"?e+"":e,r),r);var pr=typeof global=="object"&&global&&global.Object===Object&&global,$=pr;var ir=typeof self=="object"&&self&&self.Object===Object&&self,nr=$||ir||Function("return this")(),u=nr;var ur=u.Symbol,h=ur;var Ot=Object.prototype,mr=Ot.hasOwnProperty,lr=Ot.toString,K=h?h.toStringTag:void 0;function dr(t){var e=mr.call(t,K),r=t[K];try{t[K]=void 0;var o=!0}catch{}var a=lr.call(t);return o&&(e?t[K]=r:delete t[K]),a}var At=dr;var cr=Object.prototype,xr=cr.toString;function gr(t){return xr.call(t)}var wt=gr;var hr="[object Null]",yr="[object Undefined]",St=h?h.toStringTag:void 0;function br(t){return t==null?t===void 0?yr:hr:St&&St in Object(t)?At(t):wt(t)}var y=br;function jr(t){return t!=null&&typeof t=="object"}var x=jr;var vr=Array.isArray,E=vr;function Tr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var g=Tr;var _r="[object AsyncFunction]",Or="[object Function]",Ar="[object GeneratorFunction]",wr="[object Proxy]";function Sr(t){if(!g(t))return!1;var e=y(t);return e==Or||e==Ar||e==_r||e==wr}var k=Sr;var Ir=u["__core-js_shared__"],J=Ir;var It=function(){var t=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Pr(t){return!!It&&It in t}var Pt=Pr;var Cr=Function.prototype,Er=Cr.toString;function Br(t){if(t!=null){try{return Er.call(t)}catch{}try{return t+""}catch{}}return""}var b=Br;var Lr=/[\\^$.*+?()[\]{}|]/g,Mr=/^\[object .+?Constructor\]$/,Dr=Function.prototype,Nr=Object.prototype,Fr=Dr.toString,Ur=Nr.hasOwnProperty,Rr=RegExp("^"+Fr.call(Ur).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vr(t){if(!g(t)||Pt(t))return!1;var e=k(t)?Rr:Mr;return e.test(b(t))}var Ct=Vr;function Gr(t,e){return t==null?void 0:t[e]}var Et=Gr;function Wr(t,e){var r=Et(t,e);return Ct(r)?r:void 0}var d=Wr;var Kr=d(u,"WeakMap"),Y=Kr;var Bt=Object.create,zr=function(){function t(){}return function(e){if(!g(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Lt=zr;function qr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Mt=qr;var Hr=function(){try{var t=d(Object,"defineProperty");return t({},"",{}),t}catch{}}(),xt=Hr;function $r(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Dt=$r;var kr=9007199254740991,Jr=/^(?:0|[1-9]\d*)$/;function Yr(t,e){var r=typeof t;return e=e==null?kr:e,!!e&&(r=="number"||r!="symbol"&&Jr.test(t))&&t>-1&&t%1==0&&t<e}var Nt=Yr;function Xr(t,e,r){e=="__proto__"&&xt?xt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var X=Xr;function Zr(t,e){return t===e||t!==t&&e!==e}var Z=Zr;var Qr=Object.prototype,to=Qr.hasOwnProperty;function eo(t,e,r){var o=t[e];(!(to.call(t,e)&&Z(o,r))||r===void 0&&!(e in t))&&X(t,e,r)}var Q=eo;function ro(t,e,r,o){var a=!r;r||(r={});for(var p=-1,s=e.length;++p<s;){var f=e[p],m=o?o(r[f],t[f],f,r,t):void 0;m===void 0&&(m=t[f]),a?X(r,f,m):Q(r,f,m)}return r}var O=ro;var oo=9007199254740991;function ao(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=oo}var tt=ao;function fo(t){return t!=null&&tt(t.length)&&!k(t)}var et=fo;var so=Object.prototype;function po(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||so;return t===r}var B=po;function io(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ft=io;var no="[object Arguments]";function uo(t){return x(t)&&y(t)==no}var gt=uo;var Ut=Object.prototype,mo=Ut.hasOwnProperty,lo=Ut.propertyIsEnumerable,co=gt(function(){return arguments}())?gt:function(t){return x(t)&&mo.call(t,"callee")&&!lo.call(t,"callee")},Rt=co;function xo(){return!1}var Vt=xo;var Kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gt=Kt&&typeof module=="object"&&module&&!module.nodeType&&module,go=Gt&&Gt.exports===Kt,Wt=go?u.Buffer:void 0,ho=Wt?Wt.isBuffer:void 0,yo=ho||Vt,rt=yo;var bo="[object Arguments]",jo="[object Array]",vo="[object Boolean]",To="[object Date]",_o="[object Error]",Oo="[object Function]",Ao="[object Map]",wo="[object Number]",So="[object Object]",Io="[object RegExp]",Po="[object Set]",Co="[object String]",Eo="[object WeakMap]",Bo="[object ArrayBuffer]",Lo="[object DataView]",Mo="[object Float32Array]",Do="[object Float64Array]",No="[object Int8Array]",Fo="[object Int16Array]",Uo="[object Int32Array]",Ro="[object Uint8Array]",Vo="[object Uint8ClampedArray]",Go="[object Uint16Array]",Wo="[object Uint32Array]",n={};n[Mo]=n[Do]=n[No]=n[Fo]=n[Uo]=n[Ro]=n[Vo]=n[Go]=n[Wo]=!0;n[bo]=n[jo]=n[Bo]=n[vo]=n[Lo]=n[To]=n[_o]=n[Oo]=n[Ao]=n[wo]=n[So]=n[Io]=n[Po]=n[Co]=n[Eo]=!1;function Ko(t){return x(t)&&tt(t.length)&&!!n[y(t)]}var zt=Ko;function zo(t){return function(e){return t(e)}}var L=zo;var qt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,z=qt&&typeof module=="object"&&module&&!module.nodeType&&module,qo=z&&z.exports===qt,ht=qo&&$.process,Ho=function(){try{var t=z&&z.require&&z.require("util").types;return t||ht&&ht.binding&&ht.binding("util")}catch{}}(),j=Ho;var Ht=j&&j.isTypedArray,$o=Ht?L(Ht):zt,$t=$o;var ko=Object.prototype,Jo=ko.hasOwnProperty;function Yo(t,e){var r=E(t),o=!r&&Rt(t),a=!r&&!o&&rt(t),p=!r&&!o&&!a&&$t(t),s=r||o||a||p,f=s?Ft(t.length,String):[],m=f.length;for(var l in t)(e||Jo.call(t,l))&&!(s&&(l=="length"||a&&(l=="offset"||l=="parent")||p&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Nt(l,m)))&&f.push(l);return f}var ot=Yo;function Xo(t,e){return function(r){return t(e(r))}}var at=Xo;var Zo=at(Object.keys,Object),kt=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t){if(!B(t))return kt(t);var e=[];for(var r in Object(t))ta.call(t,r)&&r!="constructor"&&e.push(r);return e}var Jt=ea;function ra(t){return et(t)?ot(t):Jt(t)}var M=ra;function oa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Yt=oa;var aa=Object.prototype,fa=aa.hasOwnProperty;function sa(t){if(!g(t))return Yt(t);var e=B(t),r=[];for(var o in t)o=="constructor"&&(e||!fa.call(t,o))||r.push(o);return r}var Xt=sa;function pa(t){return et(t)?ot(t,!0):Xt(t)}var D=pa;var ia=d(Object,"create"),v=ia;function na(){this.__data__=v?v(null):{},this.size=0}var Zt=na;function ua(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Qt=ua;var ma="__lodash_hash_undefined__",la=Object.prototype,da=la.hasOwnProperty;function ca(t){var e=this.__data__;if(v){var r=e[t];return r===ma?void 0:r}return da.call(e,t)?e[t]:void 0}var te=ca;var xa=Object.prototype,ga=xa.hasOwnProperty;function ha(t){var e=this.__data__;return v?e[t]!==void 0:ga.call(e,t)}var ee=ha;var ya="__lodash_hash_undefined__";function ba(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=v&&e===void 0?ya:e,this}var re=ba;function N(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])}}N.prototype.clear=Zt;N.prototype.delete=Qt;N.prototype.get=te;N.prototype.has=ee;N.prototype.set=re;var yt=N;function ja(){this.__data__=[],this.size=0}var oe=ja;function va(t,e){for(var r=t.length;r--;)if(Z(t[r][0],e))return r;return-1}var A=va;var Ta=Array.prototype,_a=Ta.splice;function Oa(t){var e=this.__data__,r=A(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():_a.call(e,r,1),--this.size,!0}var ae=Oa;function Aa(t){var e=this.__data__,r=A(e,t);return r<0?void 0:e[r][1]}var fe=Aa;function wa(t){return A(this.__data__,t)>-1}var se=wa;function Sa(t,e){var r=this.__data__,o=A(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var pe=Sa;function F(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])}}F.prototype.clear=oe;F.prototype.delete=ae;F.prototype.get=fe;F.prototype.has=se;F.prototype.set=pe;var w=F;var Ia=d(u,"Map"),S=Ia;function Pa(){this.size=0,this.__data__={hash:new yt,map:new(S||w),string:new yt}}var ie=Pa;function Ca(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ne=Ca;function Ea(t,e){var r=t.__data__;return ne(e)?r[typeof e=="string"?"string":"hash"]:r.map}var I=Ea;function Ba(t){var e=I(this,t).delete(t);return this.size-=e?1:0,e}var ue=Ba;function La(t){return I(this,t).get(t)}var me=La;function Ma(t){return I(this,t).has(t)}var le=Ma;function Da(t,e){var r=I(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var de=Da;function U(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])}}U.prototype.clear=ie;U.prototype.delete=ue;U.prototype.get=me;U.prototype.has=le;U.prototype.set=de;var ce=U;function Na(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ft=Na;var Fa=at(Object.getPrototypeOf,Object),st=Fa;function Ua(){this.__data__=new w,this.size=0}var xe=Ua;function Ra(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ge=Ra;function Va(t){return this.__data__.get(t)}var he=Va;function Ga(t){return this.__data__.has(t)}var ye=Ga;var Wa=200;function Ka(t,e){var r=this.__data__;if(r instanceof w){var o=r.__data__;if(!S||o.length<Wa-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(o)}return r.set(t,e),this.size=r.size,this}var be=Ka;function R(t){var e=this.__data__=new w(t);this.size=e.size}R.prototype.clear=xe;R.prototype.delete=ge;R.prototype.get=he;R.prototype.has=ye;R.prototype.set=be;var je=R;function za(t,e){return t&&O(e,M(e),t)}var ve=za;function qa(t,e){return t&&O(e,D(e),t)}var Te=qa;var we=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_e=we&&typeof module=="object"&&module&&!module.nodeType&&module,Ha=_e&&_e.exports===we,Oe=Ha?u.Buffer:void 0,Ae=Oe?Oe.allocUnsafe:void 0;function $a(t,e){if(e)return t.slice();var r=t.length,o=Ae?Ae(r):new t.constructor(r);return t.copy(o),o}var Se=$a;function ka(t,e){for(var r=-1,o=t==null?0:t.length,a=0,p=[];++r<o;){var s=t[r];e(s,r,t)&&(p[a++]=s)}return p}var Ie=ka;function Ja(){return[]}var pt=Ja;var Ya=Object.prototype,Xa=Ya.propertyIsEnumerable,Pe=Object.getOwnPropertySymbols,Za=Pe?function(t){return t==null?[]:(t=Object(t),Ie(Pe(t),function(e){return Xa.call(t,e)}))}:pt,V=Za;function Qa(t,e){return O(t,V(t),e)}var Ce=Qa;var tf=Object.getOwnPropertySymbols,ef=tf?function(t){for(var e=[];t;)ft(e,V(t)),t=st(t);return e}:pt,it=ef;function rf(t,e){return O(t,it(t),e)}var Ee=rf;function of(t,e,r){var o=e(t);return E(t)?o:ft(o,r(t))}var nt=of;function af(t){return nt(t,M,V)}var Be=af;function ff(t){return nt(t,D,it)}var Le=ff;var sf=d(u,"DataView"),ut=sf;var pf=d(u,"Promise"),mt=pf;var nf=d(u,"Set"),lt=nf;var Me="[object Map]",uf="[object Object]",De="[object Promise]",Ne="[object Set]",Fe="[object WeakMap]",Ue="[object DataView]",mf=b(ut),lf=b(S),df=b(mt),cf=b(lt),xf=b(Y),C=y;(ut&&C(new ut(new ArrayBuffer(1)))!=Ue||S&&C(new S)!=Me||mt&&C(mt.resolve())!=De||lt&&C(new lt)!=Ne||Y&&C(new Y)!=Fe)&&(C=function(t){var e=y(t),r=e==uf?t.constructor:void 0,o=r?b(r):"";if(o)switch(o){case mf:return Ue;case lf:return Me;case df:return De;case cf:return Ne;case xf:return Fe}return e});var G=C;var gf=Object.prototype,hf=gf.hasOwnProperty;function yf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&hf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Re=yf;var bf=u.Uint8Array,bt=bf;function jf(t){var e=new t.constructor(t.byteLength);return new bt(e).set(new bt(t)),e}var W=jf;function vf(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ve=vf;var Tf=/\w*$/;function _f(t){var e=new t.constructor(t.source,Tf.exec(t));return e.lastIndex=t.lastIndex,e}var Ge=_f;var We=h?h.prototype:void 0,Ke=We?We.valueOf:void 0;function Of(t){return Ke?Object(Ke.call(t)):{}}var ze=Of;function Af(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var qe=Af;var wf="[object Boolean]",Sf="[object Date]",If="[object Map]",Pf="[object Number]",Cf="[object RegExp]",Ef="[object Set]",Bf="[object String]",Lf="[object Symbol]",Mf="[object ArrayBuffer]",Df="[object DataView]",Nf="[object Float32Array]",Ff="[object Float64Array]",Uf="[object Int8Array]",Rf="[object Int16Array]",Vf="[object Int32Array]",Gf="[object Uint8Array]",Wf="[object Uint8ClampedArray]",Kf="[object Uint16Array]",zf="[object Uint32Array]";function qf(t,e,r){var o=t.constructor;switch(e){case Mf:return W(t);case wf:case Sf:return new o(+t);case Df:return Ve(t,r);case Nf:case Ff:case Uf:case Rf:case Vf:case Gf:case Wf:case Kf:case zf:return qe(t,r);case If:return new o;case Pf:case Bf:return new o(t);case Cf:return Ge(t);case Ef:return new o;case Lf:return ze(t)}}var He=qf;function Hf(t){return typeof t.constructor=="function"&&!B(t)?Lt(st(t)):{}}var $e=Hf;var $f="[object Map]";function kf(t){return x(t)&&G(t)==$f}var ke=kf;var Je=j&&j.isMap,Jf=Je?L(Je):ke,Ye=Jf;var Yf="[object Set]";function Xf(t){return x(t)&&G(t)==Yf}var Xe=Xf;var Ze=j&&j.isSet,Zf=Ze?L(Ze):Xe,Qe=Zf;var Qf=1,ts=2,es=4,tr="[object Arguments]",rs="[object Array]",os="[object Boolean]",as="[object Date]",fs="[object Error]",er="[object Function]",ss="[object GeneratorFunction]",ps="[object Map]",is="[object Number]",rr="[object Object]",ns="[object RegExp]",us="[object Set]",ms="[object String]",ls="[object Symbol]",ds="[object WeakMap]",cs="[object ArrayBuffer]",xs="[object DataView]",gs="[object Float32Array]",hs="[object Float64Array]",ys="[object Int8Array]",bs="[object Int16Array]",js="[object Int32Array]",vs="[object Uint8Array]",Ts="[object Uint8ClampedArray]",_s="[object Uint16Array]",Os="[object Uint32Array]",i={};i[tr]=i[rs]=i[cs]=i[xs]=i[os]=i[as]=i[gs]=i[hs]=i[ys]=i[bs]=i[js]=i[ps]=i[is]=i[rr]=i[ns]=i[us]=i[ms]=i[ls]=i[vs]=i[Ts]=i[_s]=i[Os]=!0;i[fs]=i[er]=i[ds]=!1;function dt(t,e,r,o,a,p){var s,f=e&Qf,m=e&ts,l=e&es;if(r&&(s=a?r(t,o,a,p):r(t)),s!==void 0)return s;if(!g(t))return t;var T=E(t);if(T){if(s=Re(t),!f)return Mt(t,s)}else{var c=G(t),vt=c==er||c==ss;if(rt(t))return Se(t,f);if(c==rr||c==tr||vt&&!a){if(s=m||vt?{}:$e(t),!f)return m?Ee(t,Te(s,t)):Ce(t,ve(s,t))}else{if(!i[c])return a?t:{};s=He(t,c,f)}}p||(p=new je);var Tt=p.get(t);if(Tt)return Tt;p.set(t,s),Qe(t)?t.forEach(function(_){s.add(dt(_,e,r,_,t,p))}):Ye(t)&&t.forEach(function(_,P){s.set(P,dt(_,e,r,P,t,p))});var ar=l?m?Le:Be:m?D:M,_t=T?void 0:ar(t);return Dt(_t||t,function(_,P){_t&&(P=_,_=t[P]),Q(s,P,dt(_,e,r,P,t,p))}),s}var or=dt;var As=1,ws=4;function Ss(t){return or(t,As|ws)}var ct=Ss;var q=class{init(){}constructor(e,r){}};var jt=class extends q{constructor(){super(...arguments);H(this,"Vue");H(this,"projects");H(this,"state",null)}bindProjectState(r){let o={component:null,componentKey:null,autoRequire:!0,write:!0,...r};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:o.autoRequire}),(()=>{if(!o.componentKey){for(let a=0;a<50;a++){let p=`terafy_${a}`;if(!Object.hasOwnProperty(o.component,p)){o.componentKey=p;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([a])=>{this.debug("Got project snapshot",a);let p=this.Vue.observable(a);o.component[o.componentKey]=p;let s=0;if(o.read&&this.events.on(`update:projects/${p.id}`,f=>{s++,Object.assign(p,f)}),o.write){if(!o.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let f=ct(a);o.component.$watch(o.componentKey,m=>{if(s>0){s--;return}this.createProjectStatePatch(m,f),f=ct(a)},{deep:!0})}return p})}init(r){let o={app:null,Vue:null,globalName:"$tera",requireProject:!0,subscribeState:!0,subscribeProjects:!0,stateOptions:{read:!0,write:!0},...r};if(!o.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=r.Vue,!this.settings.app)throw new Error("Need to specify the root level Vue2 app during init");return o.stateOptions.app=this.settings.app,this.projects=this.Vue.observable([]),o.globalName&&(this.Vue.prototype[o.globalName]=this),this.state=null,Promise.resolve().then(()=>o.requireProject&&this.requireProject()).then(()=>Promise.all([o.subscribeState&&this.bindProjectState({...o.stateOptions,component:this.settings.app.$root}).then(a=>this.state=a).then(()=>this.debug("INFO","Loaded project state",this.state)),o.subscribeProjects&&this.getProjects().then(a=>this.projects=this.Vue.observable(a)).then(()=>this.debug("INFO","Loaded projects",this.projects))]))}_pathSet(r,o,a,p){if(typeof r!="object")throw new Error("Cannot use _pathSet on non-object target");let s={arrayNumeric:!0,debug:!1,removeUndefined:!0,...p};s.debug&&console.log("[_pathSet]",o,"=",a,{target:r,options:p});let f=r;if(!o)throw new Error("Cannot _pathSet with undefined path");return(typeof o=="string"?o.split("."):o).some((m,l,T)=>{if(l==T.length-1)s.removeUndefined&&a===void 0?this.Vue.$delete(f,m):this.Vue.set(f,m,a);else return f[m]===void 0?(T.slice(l,T.length-1).forEach(c=>{s.arrayNumeric&&isFinite(c)?this.Vue.set(f,c,[]):this.Vue.set(f,c,{}),f=f[c]}),this.Vue.set(f,T[T.length-1],a),!0):(f=f[m],!1)}),a}};export{jt as default};
|
|
1
|
+
var fr=Object.defineProperty;var sr=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var k=(t,e,r)=>(sr(t,typeof e!="symbol"?e+"":e,r),r);var pr=typeof global=="object"&&global&&global.Object===Object&&global,q=pr;var ir=typeof self=="object"&&self&&self.Object===Object&&self,nr=q||ir||Function("return this")(),u=nr;var ur=u.Symbol,g=ur;var _t=Object.prototype,mr=_t.hasOwnProperty,lr=_t.toString,V=g?g.toStringTag:void 0;function dr(t){var e=mr.call(t,V),r=t[V];try{t[V]=void 0;var o=!0}catch{}var a=lr.call(t);return o&&(e?t[V]=r:delete t[V]),a}var At=dr;var cr=Object.prototype,xr=cr.toString;function gr(t){return xr.call(t)}var wt=gr;var hr="[object Null]",yr="[object Undefined]",St=g?g.toStringTag:void 0;function br(t){return t==null?t===void 0?yr:hr:St&&St in Object(t)?At(t):wt(t)}var h=br;function vr(t){return t!=null&&typeof t=="object"}var c=vr;var jr=Array.isArray,C=jr;function Tr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var x=Tr;var Or="[object AsyncFunction]",_r="[object Function]",Ar="[object GeneratorFunction]",wr="[object Proxy]";function Sr(t){if(!x(t))return!1;var e=h(t);return e==_r||e==Ar||e==Or||e==wr}var H=Sr;var Ir=u["__core-js_shared__"],$=Ir;var It=function(){var t=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Pr(t){return!!It&&It in t}var Pt=Pr;var Cr=Function.prototype,Er=Cr.toString;function Br(t){if(t!=null){try{return Er.call(t)}catch{}try{return t+""}catch{}}return""}var y=Br;var Lr=/[\\^$.*+?()[\]{}|]/g,Mr=/^\[object .+?Constructor\]$/,Dr=Function.prototype,Fr=Object.prototype,Nr=Dr.toString,Rr=Fr.hasOwnProperty,Ur=RegExp("^"+Nr.call(Rr).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Gr(t){if(!x(t)||Pt(t))return!1;var e=H(t)?Ur:Mr;return e.test(y(t))}var Ct=Gr;function Wr(t,e){return t==null?void 0:t[e]}var Et=Wr;function Vr(t,e){var r=Et(t,e);return Ct(r)?r:void 0}var m=Vr;var Kr=m(u,"WeakMap"),J=Kr;var Bt=Object.create,zr=function(){function t(){}return function(e){if(!x(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Lt=zr;function kr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Mt=kr;var qr=function(){try{var t=m(Object,"defineProperty");return t({},"",{}),t}catch{}}(),ct=qr;function Hr(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Dt=Hr;var $r=9007199254740991,Jr=/^(?:0|[1-9]\d*)$/;function Yr(t,e){var r=typeof t;return e=e==null?$r:e,!!e&&(r=="number"||r!="symbol"&&Jr.test(t))&&t>-1&&t%1==0&&t<e}var Ft=Yr;function Xr(t,e,r){e=="__proto__"&&ct?ct(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Y=Xr;function Zr(t,e){return t===e||t!==t&&e!==e}var X=Zr;var Qr=Object.prototype,to=Qr.hasOwnProperty;function eo(t,e,r){var o=t[e];(!(to.call(t,e)&&X(o,r))||r===void 0&&!(e in t))&&Y(t,e,r)}var Z=eo;function ro(t,e,r,o){var a=!r;r||(r={});for(var f=-1,s=e.length;++f<s;){var n=e[f],l=o?o(r[n],t[n],n,r,t):void 0;l===void 0&&(l=t[n]),a?Y(r,n,l):Z(r,n,l)}return r}var T=ro;var oo=9007199254740991;function ao(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=oo}var Q=ao;function fo(t){return t!=null&&Q(t.length)&&!H(t)}var tt=fo;var so=Object.prototype;function po(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||so;return t===r}var E=po;function io(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Nt=io;var no="[object Arguments]";function uo(t){return c(t)&&h(t)==no}var xt=uo;var Rt=Object.prototype,mo=Rt.hasOwnProperty,lo=Rt.propertyIsEnumerable,co=xt(function(){return arguments}())?xt:function(t){return c(t)&&mo.call(t,"callee")&&!lo.call(t,"callee")},Ut=co;function xo(){return!1}var Gt=xo;var Kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wt=Kt&&typeof module=="object"&&module&&!module.nodeType&&module,go=Wt&&Wt.exports===Kt,Vt=go?u.Buffer:void 0,ho=Vt?Vt.isBuffer:void 0,yo=ho||Gt,et=yo;var bo="[object Arguments]",vo="[object Array]",jo="[object Boolean]",To="[object Date]",Oo="[object Error]",_o="[object Function]",Ao="[object Map]",wo="[object Number]",So="[object Object]",Io="[object RegExp]",Po="[object Set]",Co="[object String]",Eo="[object WeakMap]",Bo="[object ArrayBuffer]",Lo="[object DataView]",Mo="[object Float32Array]",Do="[object Float64Array]",Fo="[object Int8Array]",No="[object Int16Array]",Ro="[object Int32Array]",Uo="[object Uint8Array]",Go="[object Uint8ClampedArray]",Wo="[object Uint16Array]",Vo="[object Uint32Array]",i={};i[Mo]=i[Do]=i[Fo]=i[No]=i[Ro]=i[Uo]=i[Go]=i[Wo]=i[Vo]=!0;i[bo]=i[vo]=i[Bo]=i[jo]=i[Lo]=i[To]=i[Oo]=i[_o]=i[Ao]=i[wo]=i[So]=i[Io]=i[Po]=i[Co]=i[Eo]=!1;function Ko(t){return c(t)&&Q(t.length)&&!!i[h(t)]}var zt=Ko;function zo(t){return function(e){return t(e)}}var B=zo;var kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,K=kt&&typeof module=="object"&&module&&!module.nodeType&&module,ko=K&&K.exports===kt,gt=ko&&q.process,qo=function(){try{var t=K&&K.require&&K.require("util").types;return t||gt&>.binding&>.binding("util")}catch{}}(),b=qo;var qt=b&&b.isTypedArray,Ho=qt?B(qt):zt,Ht=Ho;var $o=Object.prototype,Jo=$o.hasOwnProperty;function Yo(t,e){var r=C(t),o=!r&&Ut(t),a=!r&&!o&&et(t),f=!r&&!o&&!a&&Ht(t),s=r||o||a||f,n=s?Nt(t.length,String):[],l=n.length;for(var d in t)(e||Jo.call(t,d))&&!(s&&(d=="length"||a&&(d=="offset"||d=="parent")||f&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Ft(d,l)))&&n.push(d);return n}var rt=Yo;function Xo(t,e){return function(r){return t(e(r))}}var ot=Xo;var Zo=ot(Object.keys,Object),$t=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t){if(!E(t))return $t(t);var e=[];for(var r in Object(t))ta.call(t,r)&&r!="constructor"&&e.push(r);return e}var Jt=ea;function ra(t){return tt(t)?rt(t):Jt(t)}var L=ra;function oa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Yt=oa;var aa=Object.prototype,fa=aa.hasOwnProperty;function sa(t){if(!x(t))return Yt(t);var e=E(t),r=[];for(var o in t)o=="constructor"&&(e||!fa.call(t,o))||r.push(o);return r}var Xt=sa;function pa(t){return tt(t)?rt(t,!0):Xt(t)}var M=pa;var ia=m(Object,"create"),v=ia;function na(){this.__data__=v?v(null):{},this.size=0}var Zt=na;function ua(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Qt=ua;var ma="__lodash_hash_undefined__",la=Object.prototype,da=la.hasOwnProperty;function ca(t){var e=this.__data__;if(v){var r=e[t];return r===ma?void 0:r}return da.call(e,t)?e[t]:void 0}var te=ca;var xa=Object.prototype,ga=xa.hasOwnProperty;function ha(t){var e=this.__data__;return v?e[t]!==void 0:ga.call(e,t)}var ee=ha;var ya="__lodash_hash_undefined__";function ba(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=v&&e===void 0?ya:e,this}var re=ba;function D(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])}}D.prototype.clear=Zt;D.prototype.delete=Qt;D.prototype.get=te;D.prototype.has=ee;D.prototype.set=re;var ht=D;function va(){this.__data__=[],this.size=0}var oe=va;function ja(t,e){for(var r=t.length;r--;)if(X(t[r][0],e))return r;return-1}var O=ja;var Ta=Array.prototype,Oa=Ta.splice;function _a(t){var e=this.__data__,r=O(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Oa.call(e,r,1),--this.size,!0}var ae=_a;function Aa(t){var e=this.__data__,r=O(e,t);return r<0?void 0:e[r][1]}var fe=Aa;function wa(t){return O(this.__data__,t)>-1}var se=wa;function Sa(t,e){var r=this.__data__,o=O(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var pe=Sa;function F(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])}}F.prototype.clear=oe;F.prototype.delete=ae;F.prototype.get=fe;F.prototype.has=se;F.prototype.set=pe;var _=F;var Ia=m(u,"Map"),A=Ia;function Pa(){this.size=0,this.__data__={hash:new ht,map:new(A||_),string:new ht}}var ie=Pa;function Ca(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ne=Ca;function Ea(t,e){var r=t.__data__;return ne(e)?r[typeof e=="string"?"string":"hash"]:r.map}var w=Ea;function Ba(t){var e=w(this,t).delete(t);return this.size-=e?1:0,e}var ue=Ba;function La(t){return w(this,t).get(t)}var me=La;function Ma(t){return w(this,t).has(t)}var le=Ma;function Da(t,e){var r=w(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var de=Da;function N(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])}}N.prototype.clear=ie;N.prototype.delete=ue;N.prototype.get=me;N.prototype.has=le;N.prototype.set=de;var ce=N;function Fa(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var at=Fa;var Na=ot(Object.getPrototypeOf,Object),ft=Na;function Ra(){this.__data__=new _,this.size=0}var xe=Ra;function Ua(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ge=Ua;function Ga(t){return this.__data__.get(t)}var he=Ga;function Wa(t){return this.__data__.has(t)}var ye=Wa;var Va=200;function Ka(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!A||o.length<Va-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(o)}return r.set(t,e),this.size=r.size,this}var be=Ka;function R(t){var e=this.__data__=new _(t);this.size=e.size}R.prototype.clear=xe;R.prototype.delete=ge;R.prototype.get=he;R.prototype.has=ye;R.prototype.set=be;var ve=R;function za(t,e){return t&&T(e,L(e),t)}var je=za;function ka(t,e){return t&&T(e,M(e),t)}var Te=ka;var we=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=we&&typeof module=="object"&&module&&!module.nodeType&&module,qa=Oe&&Oe.exports===we,_e=qa?u.Buffer:void 0,Ae=_e?_e.allocUnsafe:void 0;function Ha(t,e){if(e)return t.slice();var r=t.length,o=Ae?Ae(r):new t.constructor(r);return t.copy(o),o}var Se=Ha;function $a(t,e){for(var r=-1,o=t==null?0:t.length,a=0,f=[];++r<o;){var s=t[r];e(s,r,t)&&(f[a++]=s)}return f}var Ie=$a;function Ja(){return[]}var st=Ja;var Ya=Object.prototype,Xa=Ya.propertyIsEnumerable,Pe=Object.getOwnPropertySymbols,Za=Pe?function(t){return t==null?[]:(t=Object(t),Ie(Pe(t),function(e){return Xa.call(t,e)}))}:st,U=Za;function Qa(t,e){return T(t,U(t),e)}var Ce=Qa;var tf=Object.getOwnPropertySymbols,ef=tf?function(t){for(var e=[];t;)at(e,U(t)),t=ft(t);return e}:st,pt=ef;function rf(t,e){return T(t,pt(t),e)}var Ee=rf;function of(t,e,r){var o=e(t);return C(t)?o:at(o,r(t))}var it=of;function af(t){return it(t,L,U)}var Be=af;function ff(t){return it(t,M,pt)}var Le=ff;var sf=m(u,"DataView"),nt=sf;var pf=m(u,"Promise"),ut=pf;var nf=m(u,"Set"),mt=nf;var Me="[object Map]",uf="[object Object]",De="[object Promise]",Fe="[object Set]",Ne="[object WeakMap]",Re="[object DataView]",mf=y(nt),lf=y(A),df=y(ut),cf=y(mt),xf=y(J),I=h;(nt&&I(new nt(new ArrayBuffer(1)))!=Re||A&&I(new A)!=Me||ut&&I(ut.resolve())!=De||mt&&I(new mt)!=Fe||J&&I(new J)!=Ne)&&(I=function(t){var e=h(t),r=e==uf?t.constructor:void 0,o=r?y(r):"";if(o)switch(o){case mf:return Re;case lf:return Me;case df:return De;case cf:return Fe;case xf:return Ne}return e});var G=I;var gf=Object.prototype,hf=gf.hasOwnProperty;function yf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&hf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ue=yf;var bf=u.Uint8Array,yt=bf;function vf(t){var e=new t.constructor(t.byteLength);return new yt(e).set(new yt(t)),e}var W=vf;function jf(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ge=jf;var Tf=/\w*$/;function Of(t){var e=new t.constructor(t.source,Tf.exec(t));return e.lastIndex=t.lastIndex,e}var We=Of;var Ve=g?g.prototype:void 0,Ke=Ve?Ve.valueOf:void 0;function _f(t){return Ke?Object(Ke.call(t)):{}}var ze=_f;function Af(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var ke=Af;var wf="[object Boolean]",Sf="[object Date]",If="[object Map]",Pf="[object Number]",Cf="[object RegExp]",Ef="[object Set]",Bf="[object String]",Lf="[object Symbol]",Mf="[object ArrayBuffer]",Df="[object DataView]",Ff="[object Float32Array]",Nf="[object Float64Array]",Rf="[object Int8Array]",Uf="[object Int16Array]",Gf="[object Int32Array]",Wf="[object Uint8Array]",Vf="[object Uint8ClampedArray]",Kf="[object Uint16Array]",zf="[object Uint32Array]";function kf(t,e,r){var o=t.constructor;switch(e){case Mf:return W(t);case wf:case Sf:return new o(+t);case Df:return Ge(t,r);case Ff:case Nf:case Rf:case Uf:case Gf:case Wf:case Vf:case Kf:case zf:return ke(t,r);case If:return new o;case Pf:case Bf:return new o(t);case Cf:return We(t);case Ef:return new o;case Lf:return ze(t)}}var qe=kf;function qf(t){return typeof t.constructor=="function"&&!E(t)?Lt(ft(t)):{}}var He=qf;var Hf="[object Map]";function $f(t){return c(t)&&G(t)==Hf}var $e=$f;var Je=b&&b.isMap,Jf=Je?B(Je):$e,Ye=Jf;var Yf="[object Set]";function Xf(t){return c(t)&&G(t)==Yf}var Xe=Xf;var Ze=b&&b.isSet,Zf=Ze?B(Ze):Xe,Qe=Zf;var Qf=1,ts=2,es=4,tr="[object Arguments]",rs="[object Array]",os="[object Boolean]",as="[object Date]",fs="[object Error]",er="[object Function]",ss="[object GeneratorFunction]",ps="[object Map]",is="[object Number]",rr="[object Object]",ns="[object RegExp]",us="[object Set]",ms="[object String]",ls="[object Symbol]",ds="[object WeakMap]",cs="[object ArrayBuffer]",xs="[object DataView]",gs="[object Float32Array]",hs="[object Float64Array]",ys="[object Int8Array]",bs="[object Int16Array]",vs="[object Int32Array]",js="[object Uint8Array]",Ts="[object Uint8ClampedArray]",Os="[object Uint16Array]",_s="[object Uint32Array]",p={};p[tr]=p[rs]=p[cs]=p[xs]=p[os]=p[as]=p[gs]=p[hs]=p[ys]=p[bs]=p[vs]=p[ps]=p[is]=p[rr]=p[ns]=p[us]=p[ms]=p[ls]=p[js]=p[Ts]=p[Os]=p[_s]=!0;p[fs]=p[er]=p[ds]=!1;function lt(t,e,r,o,a,f){var s,n=e&Qf,l=e&ts,d=e&es;if(r&&(s=a?r(t,o,a,f):r(t)),s!==void 0)return s;if(!x(t))return t;var vt=C(t);if(vt){if(s=Ue(t),!n)return Mt(t,s)}else{var P=G(t),jt=P==er||P==ss;if(et(t))return Se(t,n);if(P==rr||P==tr||jt&&!a){if(s=l||jt?{}:He(t),!n)return l?Ee(t,Te(s,t)):Ce(t,je(s,t))}else{if(!p[P])return a?t:{};s=qe(t,P,n)}}f||(f=new ve);var Tt=f.get(t);if(Tt)return Tt;f.set(t,s),Qe(t)?t.forEach(function(j){s.add(lt(j,e,r,j,t,f))}):Ye(t)&&t.forEach(function(j,S){s.set(S,lt(j,e,r,S,t,f))});var ar=d?l?Le:Be:l?M:L,Ot=vt?void 0:ar(t);return Dt(Ot||t,function(j,S){Ot&&(S=j,j=t[S]),Z(s,S,lt(j,e,r,S,t,f))}),s}var or=lt;var As=1,ws=4;function Ss(t){return or(t,As|ws)}var dt=Ss;var z=class{init(){}constructor(e,r){}};var bt=class extends z{constructor(){super(...arguments);k(this,"Vue");k(this,"projects");k(this,"state",null)}bindProjectState(r){let o={component:null,componentKey:null,autoRequire:!0,write:!0,...r};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:o.autoRequire}),(()=>{if(!o.componentKey){for(let a=0;a<50;a++){let f=`terafy_${a}`;if(!Object.hasOwnProperty(o.component,f)){o.componentKey=f;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([a])=>{this.debug("Got project snapshot",a);let f=this.Vue.observable(a);o.component[o.componentKey]=f;let s=0;if(o.read&&this.events.on(`update:projects/${f.id}`,n=>{s++,this.merge(f,n)}),o.write){if(!o.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let n=dt(a);o.component.$watch(o.componentKey,l=>{if(s>0){s--;return}this.createProjectStatePatch(l,n),n=dt(a)},{deep:!0})}return f})}merge(r,o){return o.forEach(a=>Object.keys(a).forEach(f=>this.Vue.set(r,f,a[f]))),r}init(r){let o={app:null,Vue:null,globalName:"$tera",requireProject:!0,subscribeState:!0,subscribeProjects:!0,stateOptions:{read:!0,write:!0},...r};if(!o.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=r.Vue,!this.settings.app)throw new Error("Need to specify the root level Vue2 app during init");return o.stateOptions.app=this.settings.app,this.projects=this.Vue.observable([]),o.globalName&&(this.Vue.prototype[o.globalName]=this),this.state=null,Promise.resolve().then(()=>o.requireProject&&this.requireProject()).then(()=>Promise.all([o.subscribeState&&this.bindProjectState({...o.stateOptions,component:this.settings.app.$root}).then(a=>this.state=a).then(()=>this.debug("INFO","Loaded project state",this.state)),o.subscribeProjects&&this.getProjects().then(a=>this.projects=this.Vue.observable(a)).then(()=>this.debug("INFO","Loaded projects",this.projects))]))}};export{bt as default};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
lodash-es/lodash.js:
|
package/dist/terafy.es2019.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var uo=Object.defineProperty;var co=(t,e,r)=>e in t?uo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var x=(t,e,r)=>(co(t,typeof e!="symbol"?e+"":e,r),r);function Yt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:v}){var P=Object.keys(i),A=P.length,y=Object.keys(n),I=y.length,b,p=i.length-n.length;if(xo(i,n)){for(var u=0;u<A;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in n||(b=h.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<I;u++){var l=Array.isArray(n)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=h.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<I;u++)s({key:u,obj1:E,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:v})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:v,diffs:P}){var A=n[i],y=m[i];if(!(i in n)&&i in m){var I=y;P.add.push({op:"add",path:r(h),value:I})}else A!==y&&(Object(A)!==A||Object(y)!==y||ho(A,y)||!Object.keys(A).length&&!Object.keys(y).length&&String(A)!=String(y)?f(h,P,y):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:v,diffs:P}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Vt(t){return[""].concat(t).join("/")}function ho(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function xo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var go=typeof global=="object"&&global&&global.Object===Object&&global,dt=go;var yo=typeof self=="object"&&self&&self.Object===Object&&self,bo=dt||yo||Function("return this")(),g=bo;var vo=g.Symbol,T=vo;var Zt=Object.prototype,wo=Zt.hasOwnProperty,To=Zt.toString,pt=T?T.toStringTag:void 0;function Ao(t){var e=wo.call(t,pt),r=t[pt];try{t[pt]=void 0;var o=!0}catch{}var a=To.call(t);return o&&(e?t[pt]=r:delete t[pt]),a}var Jt=Ao;var So=Object.prototype,Po=So.toString;function jo(t){return Po.call(t)}var Xt=jo;var Oo="[object Null]",_o="[object Undefined]",Qt=T?T.toStringTag:void 0;function Io(t){return t==null?t===void 0?_o:Oo:Qt&&Qt in Object(t)?Jt(t):Xt(t)}var _=Io;function Eo(t){return t!=null&&typeof t=="object"}var O=Eo;var Co="[object Symbol]";function Mo(t){return typeof t=="symbol"||O(t)&&_(t)==Co}var K=Mo;function Ro(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 te=Ro;var Bo=Array.isArray,w=Bo;var Fo=1/0,ee=T?T.prototype:void 0,re=ee?ee.toString:void 0;function oe(t){if(typeof t=="string")return t;if(w(t))return te(t,oe)+"";if(K(t))return re?re.call(t):"";var e=t+"";return e=="0"&&1/t==-Fo?"-0":e}var ae=oe;function Lo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var j=Lo;function No(t){return t}var ie=No;var Do="[object AsyncFunction]",ko="[object Function]",Uo="[object GeneratorFunction]",zo="[object Proxy]";function Ko(t){if(!j(t))return!1;var e=_(t);return e==ko||e==Uo||e==Do||e==zo}var ct=Ko;var Go=g["__core-js_shared__"],ht=Go;var se=function(){var t=/[^.]+$/.exec(ht&&ht.keys&&ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Wo(t){return!!se&&se in t}var fe=Wo;var Ho=Function.prototype,$o=Ho.toString;function qo(t){if(t!=null){try{return $o.call(t)}catch{}try{return t+""}catch{}}return""}var C=qo;var Yo=/[\\^$.*+?()[\]{}|]/g,Vo=/^\[object .+?Constructor\]$/,Zo=Function.prototype,Jo=Object.prototype,Xo=Zo.toString,Qo=Jo.hasOwnProperty,ta=RegExp("^"+Xo.call(Qo).replace(Yo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ea(t){if(!j(t)||fe(t))return!1;var e=ct(t)?ta:Vo;return e.test(C(t))}var ne=ea;function ra(t,e){return t==null?void 0:t[e]}var pe=ra;function oa(t,e){var r=pe(t,e);return ne(r)?r:void 0}var S=oa;var aa=S(g,"WeakMap"),xt=aa;var le=Object.create,ia=function(){function t(){}return function(e){if(!j(e))return{};if(le)return le(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),me=ia;function sa(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 ue=sa;function fa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var de=fa;var na=800,pa=16,la=Date.now;function ma(t){var e=0,r=0;return function(){var o=la(),a=pa-(o-r);if(r=o,a>0){if(++e>=na)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ce=ma;function ua(t){return function(){return t}}var he=ua;var da=function(){try{var t=S(Object,"defineProperty");return t({},"",{}),t}catch{}}(),G=da;var ca=G?function(t,e){return G(t,"toString",{configurable:!0,enumerable:!1,value:he(e),writable:!0})}:ie,xe=ca;var ha=ce(xe),ge=ha;function xa(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ye=xa;var ga=9007199254740991,ya=/^(?:0|[1-9]\d*)$/;function ba(t,e){var r=typeof t;return e=e==null?ga:e,!!e&&(r=="number"||r!="symbol"&&ya.test(t))&&t>-1&&t%1==0&&t<e}var W=ba;function va(t,e,r){e=="__proto__"&&G?G(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var gt=va;function wa(t,e){return t===e||t!==t&&e!==e}var yt=wa;var Ta=Object.prototype,Aa=Ta.hasOwnProperty;function Sa(t,e,r){var o=t[e];(!(Aa.call(t,e)&&yt(o,r))||r===void 0&&!(e in t))&>(t,e,r)}var H=Sa;function Pa(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?gt(r,i,n):H(r,i,n)}return r}var B=Pa;var be=Math.max;function ja(t,e,r){return e=be(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=be(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),ue(t,this,i)}}var ve=ja;var Oa=9007199254740991;function _a(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Oa}var $=_a;function Ia(t){return t!=null&&$(t.length)&&!ct(t)}var bt=Ia;var Ea=Object.prototype;function Ca(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ea;return t===r}var q=Ca;function Ma(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var we=Ma;var Ra="[object Arguments]";function Ba(t){return O(t)&&_(t)==Ra}var Rt=Ba;var Te=Object.prototype,Fa=Te.hasOwnProperty,La=Te.propertyIsEnumerable,Na=Rt(function(){return arguments}())?Rt:function(t){return O(t)&&Fa.call(t,"callee")&&!La.call(t,"callee")},Y=Na;function Da(){return!1}var Ae=Da;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=je&&typeof module=="object"&&module&&!module.nodeType&&module,ka=Se&&Se.exports===je,Pe=ka?g.Buffer:void 0,Ua=Pe?Pe.isBuffer:void 0,za=Ua||Ae,vt=za;var Ka="[object Arguments]",Ga="[object Array]",Wa="[object Boolean]",Ha="[object Date]",$a="[object Error]",qa="[object Function]",Ya="[object Map]",Va="[object Number]",Za="[object Object]",Ja="[object RegExp]",Xa="[object Set]",Qa="[object String]",ti="[object WeakMap]",ei="[object ArrayBuffer]",ri="[object DataView]",oi="[object Float32Array]",ai="[object Float64Array]",ii="[object Int8Array]",si="[object Int16Array]",fi="[object Int32Array]",ni="[object Uint8Array]",pi="[object Uint8ClampedArray]",li="[object Uint16Array]",mi="[object Uint32Array]",c={};c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=c[pi]=c[li]=c[mi]=!0;c[Ka]=c[Ga]=c[ei]=c[Wa]=c[ri]=c[Ha]=c[$a]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=c[Xa]=c[Qa]=c[ti]=!1;function ui(t){return O(t)&&$(t.length)&&!!c[_(t)]}var Oe=ui;function di(t){return function(e){return t(e)}}var V=di;var _e=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lt=_e&&typeof module=="object"&&module&&!module.nodeType&&module,ci=lt&<.exports===_e,Bt=ci&&dt.process,hi=function(){try{var t=lt&<.require&<.require("util").types;return t||Bt&&Bt.binding&&Bt.binding("util")}catch{}}(),M=hi;var Ie=M&&M.isTypedArray,xi=Ie?V(Ie):Oe,Ee=xi;var gi=Object.prototype,yi=gi.hasOwnProperty;function bi(t,e){var r=w(t),o=!r&&Y(t),a=!r&&!o&&vt(t),s=!r&&!o&&!a&&Ee(t),f=r||o||a||s,i=f?we(t.length,String):[],n=i.length;for(var m in t)(e||yi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||W(m,n)))&&i.push(m);return i}var wt=bi;function vi(t,e){return function(r){return t(e(r))}}var Tt=vi;var wi=Tt(Object.keys,Object),Ce=wi;var Ti=Object.prototype,Ai=Ti.hasOwnProperty;function Si(t){if(!q(t))return Ce(t);var e=[];for(var r in Object(t))Ai.call(t,r)&&r!="constructor"&&e.push(r);return e}var Me=Si;function Pi(t){return bt(t)?wt(t):Me(t)}var Z=Pi;function ji(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Re=ji;var Oi=Object.prototype,_i=Oi.hasOwnProperty;function Ii(t){if(!j(t))return Re(t);var e=q(t),r=[];for(var o in t)o=="constructor"&&(e||!_i.call(t,o))||r.push(o);return r}var Be=Ii;function Ei(t){return bt(t)?wt(t,!0):Be(t)}var J=Ei;var Ci=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mi=/^\w*$/;function Ri(t,e){if(w(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||K(t)?!0:Mi.test(t)||!Ci.test(t)||e!=null&&t in Object(e)}var Fe=Ri;var Bi=S(Object,"create"),R=Bi;function Fi(){this.__data__=R?R(null):{},this.size=0}var Le=Fi;function Li(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ne=Li;var Ni="__lodash_hash_undefined__",Di=Object.prototype,ki=Di.hasOwnProperty;function Ui(t){var e=this.__data__;if(R){var r=e[t];return r===Ni?void 0:r}return ki.call(e,t)?e[t]:void 0}var De=Ui;var zi=Object.prototype,Ki=zi.hasOwnProperty;function Gi(t){var e=this.__data__;return R?e[t]!==void 0:Ki.call(e,t)}var ke=Gi;var Wi="__lodash_hash_undefined__";function Hi(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=R&&e===void 0?Wi:e,this}var Ue=Hi;function X(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])}}X.prototype.clear=Le;X.prototype.delete=Ne;X.prototype.get=De;X.prototype.has=ke;X.prototype.set=Ue;var Ft=X;function $i(){this.__data__=[],this.size=0}var ze=$i;function qi(t,e){for(var r=t.length;r--;)if(yt(t[r][0],e))return r;return-1}var F=qi;var Yi=Array.prototype,Vi=Yi.splice;function Zi(t){var e=this.__data__,r=F(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Vi.call(e,r,1),--this.size,!0}var Ke=Zi;function Ji(t){var e=this.__data__,r=F(e,t);return r<0?void 0:e[r][1]}var Ge=Ji;function Xi(t){return F(this.__data__,t)>-1}var We=Xi;function Qi(t,e){var r=this.__data__,o=F(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var He=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=ze;Q.prototype.delete=Ke;Q.prototype.get=Ge;Q.prototype.has=We;Q.prototype.set=He;var L=Q;var ts=S(g,"Map"),N=ts;function es(){this.size=0,this.__data__={hash:new Ft,map:new(N||L),string:new Ft}}var $e=es;function rs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var qe=rs;function os(t,e){var r=t.__data__;return qe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var D=os;function as(t){var e=D(this,t).delete(t);return this.size-=e?1:0,e}var Ye=as;function is(t){return D(this,t).get(t)}var Ve=is;function ss(t){return D(this,t).has(t)}var Ze=ss;function fs(t,e){var r=D(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Je=fs;function tt(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])}}tt.prototype.clear=$e;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var mt=tt;var ns="Expected a function";function Lt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ns);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Lt.Cache||mt),r}Lt.Cache=mt;var Xe=Lt;var ps=500;function ls(t){var e=Xe(t,function(o){return r.size===ps&&r.clear(),o}),r=e.cache;return e}var Qe=ls;var ms=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,us=/\\(\\)?/g,ds=Qe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ms,function(r,o,a,s){e.push(a?s.replace(us,"$1"):o||r)}),e}),tr=ds;function cs(t){return t==null?"":ae(t)}var er=cs;function hs(t,e){return w(t)?t:Fe(t,e)?[t]:tr(er(t))}var k=hs;var xs=1/0;function gs(t){if(typeof t=="string"||K(t))return t;var e=t+"";return e=="0"&&1/t==-xs?"-0":e}var et=gs;function ys(t,e){e=k(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[et(e[r++])];return r&&r==o?t:void 0}var rr=ys;function bs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var rt=bs;var or=T?T.isConcatSpreadable:void 0;function vs(t){return w(t)||Y(t)||!!(or&&t&&t[or])}var ar=vs;function ir(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=ar),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ir(i,e-1,r,o,a):rt(a,i):o||(a[a.length]=i)}return a}var sr=ir;function ws(t){var e=t==null?0:t.length;return e?sr(t,1):[]}var fr=ws;function Ts(t){return ge(ve(t,void 0,fr),t+"")}var nr=Ts;var As=Tt(Object.getPrototypeOf,Object),At=As;function Ss(){this.__data__=new L,this.size=0}var pr=Ss;function Ps(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var lr=Ps;function js(t){return this.__data__.get(t)}var mr=js;function Os(t){return this.__data__.has(t)}var ur=Os;var _s=200;function Is(t,e){var r=this.__data__;if(r instanceof L){var o=r.__data__;if(!N||o.length<_s-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new mt(o)}return r.set(t,e),this.size=r.size,this}var dr=Is;function ot(t){var e=this.__data__=new L(t);this.size=e.size}ot.prototype.clear=pr;ot.prototype.delete=lr;ot.prototype.get=mr;ot.prototype.has=ur;ot.prototype.set=dr;var cr=ot;function Es(t,e){return t&&B(e,Z(e),t)}var hr=Es;function Cs(t,e){return t&&B(e,J(e),t)}var xr=Cs;var vr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,gr=vr&&typeof module=="object"&&module&&!module.nodeType&&module,Ms=gr&&gr.exports===vr,yr=Ms?g.Buffer:void 0,br=yr?yr.allocUnsafe:void 0;function Rs(t,e){if(e)return t.slice();var r=t.length,o=br?br(r):new t.constructor(r);return t.copy(o),o}var wr=Rs;function Bs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var Tr=Bs;function Fs(){return[]}var St=Fs;var Ls=Object.prototype,Ns=Ls.propertyIsEnumerable,Ar=Object.getOwnPropertySymbols,Ds=Ar?function(t){return t==null?[]:(t=Object(t),Tr(Ar(t),function(e){return Ns.call(t,e)}))}:St,at=Ds;function ks(t,e){return B(t,at(t),e)}var Sr=ks;var Us=Object.getOwnPropertySymbols,zs=Us?function(t){for(var e=[];t;)rt(e,at(t)),t=At(t);return e}:St,Pt=zs;function Ks(t,e){return B(t,Pt(t),e)}var Pr=Ks;function Gs(t,e,r){var o=e(t);return w(t)?o:rt(o,r(t))}var jt=Gs;function Ws(t){return jt(t,Z,at)}var jr=Ws;function Hs(t){return jt(t,J,Pt)}var Or=Hs;var $s=S(g,"DataView"),Ot=$s;var qs=S(g,"Promise"),_t=qs;var Ys=S(g,"Set"),It=Ys;var _r="[object Map]",Vs="[object Object]",Ir="[object Promise]",Er="[object Set]",Cr="[object WeakMap]",Mr="[object DataView]",Zs=C(Ot),Js=C(N),Xs=C(_t),Qs=C(It),tf=C(xt),U=_;(Ot&&U(new Ot(new ArrayBuffer(1)))!=Mr||N&&U(new N)!=_r||_t&&U(_t.resolve())!=Ir||It&&U(new It)!=Er||xt&&U(new xt)!=Cr)&&(U=function(t){var e=_(t),r=e==Vs?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case Zs:return Mr;case Js:return _r;case Xs:return Ir;case Qs:return Er;case tf:return Cr}return e});var it=U;var ef=Object.prototype,rf=ef.hasOwnProperty;function of(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&rf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Rr=of;var af=g.Uint8Array,Nt=af;function sf(t){var e=new t.constructor(t.byteLength);return new Nt(e).set(new Nt(t)),e}var st=sf;function ff(t,e){var r=e?st(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Br=ff;var nf=/\w*$/;function pf(t){var e=new t.constructor(t.source,nf.exec(t));return e.lastIndex=t.lastIndex,e}var Fr=pf;var Lr=T?T.prototype:void 0,Nr=Lr?Lr.valueOf:void 0;function lf(t){return Nr?Object(Nr.call(t)):{}}var Dr=lf;function mf(t,e){var r=e?st(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var kr=mf;var uf="[object Boolean]",df="[object Date]",cf="[object Map]",hf="[object Number]",xf="[object RegExp]",gf="[object Set]",yf="[object String]",bf="[object Symbol]",vf="[object ArrayBuffer]",wf="[object DataView]",Tf="[object Float32Array]",Af="[object Float64Array]",Sf="[object Int8Array]",Pf="[object Int16Array]",jf="[object Int32Array]",Of="[object Uint8Array]",_f="[object Uint8ClampedArray]",If="[object Uint16Array]",Ef="[object Uint32Array]";function Cf(t,e,r){var o=t.constructor;switch(e){case vf:return st(t);case uf:case df:return new o(+t);case wf:return Br(t,r);case Tf:case Af:case Sf:case Pf:case jf:case Of:case _f:case If:case Ef:return kr(t,r);case cf:return new o;case hf:case yf:return new o(t);case xf:return Fr(t);case gf:return new o;case bf:return Dr(t)}}var Ur=Cf;function Mf(t){return typeof t.constructor=="function"&&!q(t)?me(At(t)):{}}var zr=Mf;var Rf="[object Map]";function Bf(t){return O(t)&&it(t)==Rf}var Kr=Bf;var Gr=M&&M.isMap,Ff=Gr?V(Gr):Kr,Wr=Ff;var Lf="[object Set]";function Nf(t){return O(t)&&it(t)==Lf}var Hr=Nf;var $r=M&&M.isSet,Df=$r?V($r):Hr,qr=Df;var kf=1,Uf=2,zf=4,Yr="[object Arguments]",Kf="[object Array]",Gf="[object Boolean]",Wf="[object Date]",Hf="[object Error]",Vr="[object Function]",$f="[object GeneratorFunction]",qf="[object Map]",Yf="[object Number]",Zr="[object Object]",Vf="[object RegExp]",Zf="[object Set]",Jf="[object String]",Xf="[object Symbol]",Qf="[object WeakMap]",tn="[object ArrayBuffer]",en="[object DataView]",rn="[object Float32Array]",on="[object Float64Array]",an="[object Int8Array]",sn="[object Int16Array]",fn="[object Int32Array]",nn="[object Uint8Array]",pn="[object Uint8ClampedArray]",ln="[object Uint16Array]",mn="[object Uint32Array]",d={};d[Yr]=d[Kf]=d[tn]=d[en]=d[Gf]=d[Wf]=d[rn]=d[on]=d[an]=d[sn]=d[fn]=d[qf]=d[Yf]=d[Zr]=d[Vf]=d[Zf]=d[Jf]=d[Xf]=d[nn]=d[pn]=d[ln]=d[mn]=!0;d[Hf]=d[Vr]=d[Qf]=!1;function Et(t,e,r,o,a,s){var f,i=e&kf,n=e&Uf,m=e&zf;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!j(t))return t;var h=w(t);if(h){if(f=Rr(t),!i)return de(t,f)}else{var v=it(t),P=v==Vr||v==$f;if(vt(t))return wr(t,i);if(v==Zr||v==Yr||P&&!a){if(f=n||P?{}:zr(t),!i)return n?Pr(t,xr(f,t)):Sr(t,hr(f,t))}else{if(!d[v])return a?t:{};f=Ur(t,v,i)}}s||(s=new cr);var A=s.get(t);if(A)return A;s.set(t,f),qr(t)?t.forEach(function(b){f.add(Et(b,e,r,b,t,s))}):Wr(t)&&t.forEach(function(b,p){f.set(p,Et(b,e,r,p,t,s))});var y=m?n?Or:jr:n?J:Z,I=h?void 0:y(t);return ye(I||t,function(b,p){I&&(p=b,b=t[p]),H(f,p,Et(b,e,r,p,t,s))}),f}var Jr=Et;var un=1,dn=4;function cn(t){return Jr(t,un|dn)}var Dt=cn;function hn(t,e){return t!=null&&e in Object(t)}var Xr=hn;function xn(t,e,r){e=k(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=et(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&$(a)&&W(f,a)&&(w(t)||Y(t)))}var Qr=xn;function gn(t,e){return t!=null&&Qr(t,e,Xr)}var to=gn;function yn(t,e,r,o){if(!j(t))return t;e=k(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=et(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=j(h)?h:W(e[a+1])?[]:{})}H(i,n,m),i=i[n]}return t}var eo=yn;function bn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=rr(t,f);r(i,f)&&eo(s,k(f,t),i)}return s}var ro=bn;function vn(t,e){return ro(t,e,function(r,o){return to(t,o)})}var oo=vn;var wn=nr(function(t,e){return t==null?{}:oo(t,e)}),Ct=wn;function ao(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 kt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Tn="array",An="bit",io="bits",Sn="byte",so="bytes",ft="",Pn="exponent",jn="function",fo="iec",On="Invalid number",_n="Invalid rounding method",Ut="jedec",In="object",no=".",En="round",Cn="s",Mn="si",Rn="kbit",Bn="kB",Fn=" ",Ln="string",Nn="0",zt={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 po(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=ft,localeOptions:f={},separator:i=ft,spacer:n=Fn,symbols:m={},standard:h=ft,output:v=Ln,fullform:P=!1,fullforms:A=[],exponent:y=-1,roundingMethod:I=En,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Mt=ft;h===Mn?(o=10,h=Ut):h===fo||h===Ut?o=2:o===2?h=fo:(o=10,h=Ut);let ut=o===10?1e3:1024,lo=P===!0,Gt=u<0,Wt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(On);if(typeof Wt!==jn)throw new TypeError(_n);if(Gt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ut)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Pn)return p;if(u===0)l[0]=0,Mt=l[1]=zt.symbol[h][e?io:so][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ut&&p<8&&(E=E/ut,p++));let nt=Math.pow(10,p>0?a:0);l[0]=Wt(E*nt)/nt,l[0]===ut&&p<8&&y===-1&&(l[0]=1,p++),Mt=l[1]=o===10&&p===1?e?Rn:Bn:zt.symbol[h][e?io:so][p]}if(Gt&&(l[0]=-l[0]),b>0&&(l[0]=l[0].toPrecision(b)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(no,i)),r&&Number.isInteger(l[0])===!1&&a>0){let nt=i||no,Ht=l[0].toString().split(nt),$t=Ht[1]||ft,qt=$t.length,mo=a-qt;l[0]=`${Ht[0]}${nt}${$t.padEnd(qt+mo,Nn)}`}return lo&&(l[1]=A[p]?A[p]:zt.fullform[h][p]+(e?An:Sn)+(l[0]===1?ft:Cn)),v===Tn?l:v===In?{value:l[0],symbol:l[1],exponent:p,unit:Mt}:l.join(n)}var z=class t{constructor(e){x(this,"tera");x(this,"id");x(this,"name");x(this,"path");x(this,"parsedName");x(this,"created");x(this,"createdFormatted");x(this,"modified");x(this,"modifiedFormatted");x(this,"accessed");x(this,"accessedFormatted");x(this,"size");x(this,"sizeFormatted");x(this,"mime");if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=po(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(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.getProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}serialize(){return Ct(this,["id","name","path","parsedName","created","modified","accessed","size","mime"])}static deserialize(e){return new t(Ct(e,["id","name","path","parsedName","created","modified","accessed","size","mime"]))}};var Kt=class{constructor(e){x(this,"settings",{devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",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});x(this,"events",ao());x(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});x(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"]);x(this,"plugins",[]);x(this,"acceptPostboxes",{});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(),...Dt(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","Message compose client->server:",o),this.debug("ERROR","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;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",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);else{if((r==null?void 0:r.action)=="rpc")return 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()})});if((r==null?void 0:r.action)=="event")return 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(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=Yt(r,e,Vt);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("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"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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(`
|
|
1
|
+
var uo=Object.defineProperty;var co=(t,e,r)=>e in t?uo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var x=(t,e,r)=>(co(t,typeof e!="symbol"?e+"":e,r),r);function Yt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:v}){var P=Object.keys(i),A=P.length,y=Object.keys(n),I=y.length,b,p=i.length-n.length;if(xo(i,n)){for(var u=0;u<A;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in n||(b=h.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<I;u++){var l=Array.isArray(n)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=h.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<I;u++)s({key:u,obj1:E,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:v})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:v,diffs:P}){var A=n[i],y=m[i];if(!(i in n)&&i in m){var I=y;P.add.push({op:"add",path:r(h),value:I})}else A!==y&&(Object(A)!==A||Object(y)!==y||ho(A,y)||!Object.keys(A).length&&!Object.keys(y).length&&String(A)!=String(y)?f(h,P,y):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:v,diffs:P}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Vt(t){return[""].concat(t).join("/")}function ho(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function xo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var go=typeof global=="object"&&global&&global.Object===Object&&global,dt=go;var yo=typeof self=="object"&&self&&self.Object===Object&&self,bo=dt||yo||Function("return this")(),g=bo;var vo=g.Symbol,T=vo;var Zt=Object.prototype,wo=Zt.hasOwnProperty,To=Zt.toString,pt=T?T.toStringTag:void 0;function Ao(t){var e=wo.call(t,pt),r=t[pt];try{t[pt]=void 0;var o=!0}catch{}var a=To.call(t);return o&&(e?t[pt]=r:delete t[pt]),a}var Jt=Ao;var So=Object.prototype,Po=So.toString;function jo(t){return Po.call(t)}var Xt=jo;var Oo="[object Null]",_o="[object Undefined]",Qt=T?T.toStringTag:void 0;function Io(t){return t==null?t===void 0?_o:Oo:Qt&&Qt in Object(t)?Jt(t):Xt(t)}var _=Io;function Eo(t){return t!=null&&typeof t=="object"}var O=Eo;var Co="[object Symbol]";function Mo(t){return typeof t=="symbol"||O(t)&&_(t)==Co}var K=Mo;function Ro(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 te=Ro;var Bo=Array.isArray,w=Bo;var Fo=1/0,ee=T?T.prototype:void 0,re=ee?ee.toString:void 0;function oe(t){if(typeof t=="string")return t;if(w(t))return te(t,oe)+"";if(K(t))return re?re.call(t):"";var e=t+"";return e=="0"&&1/t==-Fo?"-0":e}var ae=oe;function Lo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var j=Lo;function No(t){return t}var ie=No;var Do="[object AsyncFunction]",ko="[object Function]",Uo="[object GeneratorFunction]",zo="[object Proxy]";function Ko(t){if(!j(t))return!1;var e=_(t);return e==ko||e==Uo||e==Do||e==zo}var ct=Ko;var Go=g["__core-js_shared__"],ht=Go;var se=function(){var t=/[^.]+$/.exec(ht&&ht.keys&&ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Wo(t){return!!se&&se in t}var fe=Wo;var Ho=Function.prototype,$o=Ho.toString;function qo(t){if(t!=null){try{return $o.call(t)}catch{}try{return t+""}catch{}}return""}var C=qo;var Yo=/[\\^$.*+?()[\]{}|]/g,Vo=/^\[object .+?Constructor\]$/,Zo=Function.prototype,Jo=Object.prototype,Xo=Zo.toString,Qo=Jo.hasOwnProperty,ta=RegExp("^"+Xo.call(Qo).replace(Yo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ea(t){if(!j(t)||fe(t))return!1;var e=ct(t)?ta:Vo;return e.test(C(t))}var ne=ea;function ra(t,e){return t==null?void 0:t[e]}var pe=ra;function oa(t,e){var r=pe(t,e);return ne(r)?r:void 0}var S=oa;var aa=S(g,"WeakMap"),xt=aa;var le=Object.create,ia=function(){function t(){}return function(e){if(!j(e))return{};if(le)return le(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),me=ia;function sa(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 ue=sa;function fa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var de=fa;var na=800,pa=16,la=Date.now;function ma(t){var e=0,r=0;return function(){var o=la(),a=pa-(o-r);if(r=o,a>0){if(++e>=na)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ce=ma;function ua(t){return function(){return t}}var he=ua;var da=function(){try{var t=S(Object,"defineProperty");return t({},"",{}),t}catch{}}(),G=da;var ca=G?function(t,e){return G(t,"toString",{configurable:!0,enumerable:!1,value:he(e),writable:!0})}:ie,xe=ca;var ha=ce(xe),ge=ha;function xa(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ye=xa;var ga=9007199254740991,ya=/^(?:0|[1-9]\d*)$/;function ba(t,e){var r=typeof t;return e=e==null?ga:e,!!e&&(r=="number"||r!="symbol"&&ya.test(t))&&t>-1&&t%1==0&&t<e}var W=ba;function va(t,e,r){e=="__proto__"&&G?G(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var gt=va;function wa(t,e){return t===e||t!==t&&e!==e}var yt=wa;var Ta=Object.prototype,Aa=Ta.hasOwnProperty;function Sa(t,e,r){var o=t[e];(!(Aa.call(t,e)&&yt(o,r))||r===void 0&&!(e in t))&>(t,e,r)}var H=Sa;function Pa(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?gt(r,i,n):H(r,i,n)}return r}var B=Pa;var be=Math.max;function ja(t,e,r){return e=be(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=be(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),ue(t,this,i)}}var ve=ja;var Oa=9007199254740991;function _a(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Oa}var $=_a;function Ia(t){return t!=null&&$(t.length)&&!ct(t)}var bt=Ia;var Ea=Object.prototype;function Ca(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ea;return t===r}var q=Ca;function Ma(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var we=Ma;var Ra="[object Arguments]";function Ba(t){return O(t)&&_(t)==Ra}var Rt=Ba;var Te=Object.prototype,Fa=Te.hasOwnProperty,La=Te.propertyIsEnumerable,Na=Rt(function(){return arguments}())?Rt:function(t){return O(t)&&Fa.call(t,"callee")&&!La.call(t,"callee")},Y=Na;function Da(){return!1}var Ae=Da;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=je&&typeof module=="object"&&module&&!module.nodeType&&module,ka=Se&&Se.exports===je,Pe=ka?g.Buffer:void 0,Ua=Pe?Pe.isBuffer:void 0,za=Ua||Ae,vt=za;var Ka="[object Arguments]",Ga="[object Array]",Wa="[object Boolean]",Ha="[object Date]",$a="[object Error]",qa="[object Function]",Ya="[object Map]",Va="[object Number]",Za="[object Object]",Ja="[object RegExp]",Xa="[object Set]",Qa="[object String]",ti="[object WeakMap]",ei="[object ArrayBuffer]",ri="[object DataView]",oi="[object Float32Array]",ai="[object Float64Array]",ii="[object Int8Array]",si="[object Int16Array]",fi="[object Int32Array]",ni="[object Uint8Array]",pi="[object Uint8ClampedArray]",li="[object Uint16Array]",mi="[object Uint32Array]",c={};c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=c[pi]=c[li]=c[mi]=!0;c[Ka]=c[Ga]=c[ei]=c[Wa]=c[ri]=c[Ha]=c[$a]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=c[Xa]=c[Qa]=c[ti]=!1;function ui(t){return O(t)&&$(t.length)&&!!c[_(t)]}var Oe=ui;function di(t){return function(e){return t(e)}}var V=di;var _e=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lt=_e&&typeof module=="object"&&module&&!module.nodeType&&module,ci=lt&<.exports===_e,Bt=ci&&dt.process,hi=function(){try{var t=lt&<.require&<.require("util").types;return t||Bt&&Bt.binding&&Bt.binding("util")}catch{}}(),M=hi;var Ie=M&&M.isTypedArray,xi=Ie?V(Ie):Oe,Ee=xi;var gi=Object.prototype,yi=gi.hasOwnProperty;function bi(t,e){var r=w(t),o=!r&&Y(t),a=!r&&!o&&vt(t),s=!r&&!o&&!a&&Ee(t),f=r||o||a||s,i=f?we(t.length,String):[],n=i.length;for(var m in t)(e||yi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||W(m,n)))&&i.push(m);return i}var wt=bi;function vi(t,e){return function(r){return t(e(r))}}var Tt=vi;var wi=Tt(Object.keys,Object),Ce=wi;var Ti=Object.prototype,Ai=Ti.hasOwnProperty;function Si(t){if(!q(t))return Ce(t);var e=[];for(var r in Object(t))Ai.call(t,r)&&r!="constructor"&&e.push(r);return e}var Me=Si;function Pi(t){return bt(t)?wt(t):Me(t)}var Z=Pi;function ji(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Re=ji;var Oi=Object.prototype,_i=Oi.hasOwnProperty;function Ii(t){if(!j(t))return Re(t);var e=q(t),r=[];for(var o in t)o=="constructor"&&(e||!_i.call(t,o))||r.push(o);return r}var Be=Ii;function Ei(t){return bt(t)?wt(t,!0):Be(t)}var J=Ei;var Ci=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mi=/^\w*$/;function Ri(t,e){if(w(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||K(t)?!0:Mi.test(t)||!Ci.test(t)||e!=null&&t in Object(e)}var Fe=Ri;var Bi=S(Object,"create"),R=Bi;function Fi(){this.__data__=R?R(null):{},this.size=0}var Le=Fi;function Li(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ne=Li;var Ni="__lodash_hash_undefined__",Di=Object.prototype,ki=Di.hasOwnProperty;function Ui(t){var e=this.__data__;if(R){var r=e[t];return r===Ni?void 0:r}return ki.call(e,t)?e[t]:void 0}var De=Ui;var zi=Object.prototype,Ki=zi.hasOwnProperty;function Gi(t){var e=this.__data__;return R?e[t]!==void 0:Ki.call(e,t)}var ke=Gi;var Wi="__lodash_hash_undefined__";function Hi(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=R&&e===void 0?Wi:e,this}var Ue=Hi;function X(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])}}X.prototype.clear=Le;X.prototype.delete=Ne;X.prototype.get=De;X.prototype.has=ke;X.prototype.set=Ue;var Ft=X;function $i(){this.__data__=[],this.size=0}var ze=$i;function qi(t,e){for(var r=t.length;r--;)if(yt(t[r][0],e))return r;return-1}var F=qi;var Yi=Array.prototype,Vi=Yi.splice;function Zi(t){var e=this.__data__,r=F(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Vi.call(e,r,1),--this.size,!0}var Ke=Zi;function Ji(t){var e=this.__data__,r=F(e,t);return r<0?void 0:e[r][1]}var Ge=Ji;function Xi(t){return F(this.__data__,t)>-1}var We=Xi;function Qi(t,e){var r=this.__data__,o=F(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var He=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=ze;Q.prototype.delete=Ke;Q.prototype.get=Ge;Q.prototype.has=We;Q.prototype.set=He;var L=Q;var ts=S(g,"Map"),N=ts;function es(){this.size=0,this.__data__={hash:new Ft,map:new(N||L),string:new Ft}}var $e=es;function rs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var qe=rs;function os(t,e){var r=t.__data__;return qe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var D=os;function as(t){var e=D(this,t).delete(t);return this.size-=e?1:0,e}var Ye=as;function is(t){return D(this,t).get(t)}var Ve=is;function ss(t){return D(this,t).has(t)}var Ze=ss;function fs(t,e){var r=D(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Je=fs;function tt(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])}}tt.prototype.clear=$e;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var mt=tt;var ns="Expected a function";function Lt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ns);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Lt.Cache||mt),r}Lt.Cache=mt;var Xe=Lt;var ps=500;function ls(t){var e=Xe(t,function(o){return r.size===ps&&r.clear(),o}),r=e.cache;return e}var Qe=ls;var ms=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,us=/\\(\\)?/g,ds=Qe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ms,function(r,o,a,s){e.push(a?s.replace(us,"$1"):o||r)}),e}),tr=ds;function cs(t){return t==null?"":ae(t)}var er=cs;function hs(t,e){return w(t)?t:Fe(t,e)?[t]:tr(er(t))}var k=hs;var xs=1/0;function gs(t){if(typeof t=="string"||K(t))return t;var e=t+"";return e=="0"&&1/t==-xs?"-0":e}var et=gs;function ys(t,e){e=k(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[et(e[r++])];return r&&r==o?t:void 0}var rr=ys;function bs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var rt=bs;var or=T?T.isConcatSpreadable:void 0;function vs(t){return w(t)||Y(t)||!!(or&&t&&t[or])}var ar=vs;function ir(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=ar),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ir(i,e-1,r,o,a):rt(a,i):o||(a[a.length]=i)}return a}var sr=ir;function ws(t){var e=t==null?0:t.length;return e?sr(t,1):[]}var fr=ws;function Ts(t){return ge(ve(t,void 0,fr),t+"")}var nr=Ts;var As=Tt(Object.getPrototypeOf,Object),At=As;function Ss(){this.__data__=new L,this.size=0}var pr=Ss;function Ps(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var lr=Ps;function js(t){return this.__data__.get(t)}var mr=js;function Os(t){return this.__data__.has(t)}var ur=Os;var _s=200;function Is(t,e){var r=this.__data__;if(r instanceof L){var o=r.__data__;if(!N||o.length<_s-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new mt(o)}return r.set(t,e),this.size=r.size,this}var dr=Is;function ot(t){var e=this.__data__=new L(t);this.size=e.size}ot.prototype.clear=pr;ot.prototype.delete=lr;ot.prototype.get=mr;ot.prototype.has=ur;ot.prototype.set=dr;var cr=ot;function Es(t,e){return t&&B(e,Z(e),t)}var hr=Es;function Cs(t,e){return t&&B(e,J(e),t)}var xr=Cs;var vr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,gr=vr&&typeof module=="object"&&module&&!module.nodeType&&module,Ms=gr&&gr.exports===vr,yr=Ms?g.Buffer:void 0,br=yr?yr.allocUnsafe:void 0;function Rs(t,e){if(e)return t.slice();var r=t.length,o=br?br(r):new t.constructor(r);return t.copy(o),o}var wr=Rs;function Bs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var Tr=Bs;function Fs(){return[]}var St=Fs;var Ls=Object.prototype,Ns=Ls.propertyIsEnumerable,Ar=Object.getOwnPropertySymbols,Ds=Ar?function(t){return t==null?[]:(t=Object(t),Tr(Ar(t),function(e){return Ns.call(t,e)}))}:St,at=Ds;function ks(t,e){return B(t,at(t),e)}var Sr=ks;var Us=Object.getOwnPropertySymbols,zs=Us?function(t){for(var e=[];t;)rt(e,at(t)),t=At(t);return e}:St,Pt=zs;function Ks(t,e){return B(t,Pt(t),e)}var Pr=Ks;function Gs(t,e,r){var o=e(t);return w(t)?o:rt(o,r(t))}var jt=Gs;function Ws(t){return jt(t,Z,at)}var jr=Ws;function Hs(t){return jt(t,J,Pt)}var Or=Hs;var $s=S(g,"DataView"),Ot=$s;var qs=S(g,"Promise"),_t=qs;var Ys=S(g,"Set"),It=Ys;var _r="[object Map]",Vs="[object Object]",Ir="[object Promise]",Er="[object Set]",Cr="[object WeakMap]",Mr="[object DataView]",Zs=C(Ot),Js=C(N),Xs=C(_t),Qs=C(It),tf=C(xt),U=_;(Ot&&U(new Ot(new ArrayBuffer(1)))!=Mr||N&&U(new N)!=_r||_t&&U(_t.resolve())!=Ir||It&&U(new It)!=Er||xt&&U(new xt)!=Cr)&&(U=function(t){var e=_(t),r=e==Vs?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case Zs:return Mr;case Js:return _r;case Xs:return Ir;case Qs:return Er;case tf:return Cr}return e});var it=U;var ef=Object.prototype,rf=ef.hasOwnProperty;function of(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&rf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Rr=of;var af=g.Uint8Array,Nt=af;function sf(t){var e=new t.constructor(t.byteLength);return new Nt(e).set(new Nt(t)),e}var st=sf;function ff(t,e){var r=e?st(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Br=ff;var nf=/\w*$/;function pf(t){var e=new t.constructor(t.source,nf.exec(t));return e.lastIndex=t.lastIndex,e}var Fr=pf;var Lr=T?T.prototype:void 0,Nr=Lr?Lr.valueOf:void 0;function lf(t){return Nr?Object(Nr.call(t)):{}}var Dr=lf;function mf(t,e){var r=e?st(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var kr=mf;var uf="[object Boolean]",df="[object Date]",cf="[object Map]",hf="[object Number]",xf="[object RegExp]",gf="[object Set]",yf="[object String]",bf="[object Symbol]",vf="[object ArrayBuffer]",wf="[object DataView]",Tf="[object Float32Array]",Af="[object Float64Array]",Sf="[object Int8Array]",Pf="[object Int16Array]",jf="[object Int32Array]",Of="[object Uint8Array]",_f="[object Uint8ClampedArray]",If="[object Uint16Array]",Ef="[object Uint32Array]";function Cf(t,e,r){var o=t.constructor;switch(e){case vf:return st(t);case uf:case df:return new o(+t);case wf:return Br(t,r);case Tf:case Af:case Sf:case Pf:case jf:case Of:case _f:case If:case Ef:return kr(t,r);case cf:return new o;case hf:case yf:return new o(t);case xf:return Fr(t);case gf:return new o;case bf:return Dr(t)}}var Ur=Cf;function Mf(t){return typeof t.constructor=="function"&&!q(t)?me(At(t)):{}}var zr=Mf;var Rf="[object Map]";function Bf(t){return O(t)&&it(t)==Rf}var Kr=Bf;var Gr=M&&M.isMap,Ff=Gr?V(Gr):Kr,Wr=Ff;var Lf="[object Set]";function Nf(t){return O(t)&&it(t)==Lf}var Hr=Nf;var $r=M&&M.isSet,Df=$r?V($r):Hr,qr=Df;var kf=1,Uf=2,zf=4,Yr="[object Arguments]",Kf="[object Array]",Gf="[object Boolean]",Wf="[object Date]",Hf="[object Error]",Vr="[object Function]",$f="[object GeneratorFunction]",qf="[object Map]",Yf="[object Number]",Zr="[object Object]",Vf="[object RegExp]",Zf="[object Set]",Jf="[object String]",Xf="[object Symbol]",Qf="[object WeakMap]",tn="[object ArrayBuffer]",en="[object DataView]",rn="[object Float32Array]",on="[object Float64Array]",an="[object Int8Array]",sn="[object Int16Array]",fn="[object Int32Array]",nn="[object Uint8Array]",pn="[object Uint8ClampedArray]",ln="[object Uint16Array]",mn="[object Uint32Array]",d={};d[Yr]=d[Kf]=d[tn]=d[en]=d[Gf]=d[Wf]=d[rn]=d[on]=d[an]=d[sn]=d[fn]=d[qf]=d[Yf]=d[Zr]=d[Vf]=d[Zf]=d[Jf]=d[Xf]=d[nn]=d[pn]=d[ln]=d[mn]=!0;d[Hf]=d[Vr]=d[Qf]=!1;function Et(t,e,r,o,a,s){var f,i=e&kf,n=e&Uf,m=e&zf;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!j(t))return t;var h=w(t);if(h){if(f=Rr(t),!i)return de(t,f)}else{var v=it(t),P=v==Vr||v==$f;if(vt(t))return wr(t,i);if(v==Zr||v==Yr||P&&!a){if(f=n||P?{}:zr(t),!i)return n?Pr(t,xr(f,t)):Sr(t,hr(f,t))}else{if(!d[v])return a?t:{};f=Ur(t,v,i)}}s||(s=new cr);var A=s.get(t);if(A)return A;s.set(t,f),qr(t)?t.forEach(function(b){f.add(Et(b,e,r,b,t,s))}):Wr(t)&&t.forEach(function(b,p){f.set(p,Et(b,e,r,p,t,s))});var y=m?n?Or:jr:n?J:Z,I=h?void 0:y(t);return ye(I||t,function(b,p){I&&(p=b,b=t[p]),H(f,p,Et(b,e,r,p,t,s))}),f}var Jr=Et;var un=1,dn=4;function cn(t){return Jr(t,un|dn)}var Dt=cn;function hn(t,e){return t!=null&&e in Object(t)}var Xr=hn;function xn(t,e,r){e=k(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=et(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&$(a)&&W(f,a)&&(w(t)||Y(t)))}var Qr=xn;function gn(t,e){return t!=null&&Qr(t,e,Xr)}var to=gn;function yn(t,e,r,o){if(!j(t))return t;e=k(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=et(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=j(h)?h:W(e[a+1])?[]:{})}H(i,n,m),i=i[n]}return t}var eo=yn;function bn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=rr(t,f);r(i,f)&&eo(s,k(f,t),i)}return s}var ro=bn;function vn(t,e){return ro(t,e,function(r,o){return to(t,o)})}var oo=vn;var wn=nr(function(t,e){return t==null?{}:oo(t,e)}),Ct=wn;function ao(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 kt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Tn="array",An="bit",io="bits",Sn="byte",so="bytes",ft="",Pn="exponent",jn="function",fo="iec",On="Invalid number",_n="Invalid rounding method",Ut="jedec",In="object",no=".",En="round",Cn="s",Mn="si",Rn="kbit",Bn="kB",Fn=" ",Ln="string",Nn="0",zt={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 po(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=ft,localeOptions:f={},separator:i=ft,spacer:n=Fn,symbols:m={},standard:h=ft,output:v=Ln,fullform:P=!1,fullforms:A=[],exponent:y=-1,roundingMethod:I=En,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Mt=ft;h===Mn?(o=10,h=Ut):h===fo||h===Ut?o=2:o===2?h=fo:(o=10,h=Ut);let ut=o===10?1e3:1024,lo=P===!0,Gt=u<0,Wt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(On);if(typeof Wt!==jn)throw new TypeError(_n);if(Gt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ut)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Pn)return p;if(u===0)l[0]=0,Mt=l[1]=zt.symbol[h][e?io:so][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ut&&p<8&&(E=E/ut,p++));let nt=Math.pow(10,p>0?a:0);l[0]=Wt(E*nt)/nt,l[0]===ut&&p<8&&y===-1&&(l[0]=1,p++),Mt=l[1]=o===10&&p===1?e?Rn:Bn:zt.symbol[h][e?io:so][p]}if(Gt&&(l[0]=-l[0]),b>0&&(l[0]=l[0].toPrecision(b)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(no,i)),r&&Number.isInteger(l[0])===!1&&a>0){let nt=i||no,Ht=l[0].toString().split(nt),$t=Ht[1]||ft,qt=$t.length,mo=a-qt;l[0]=`${Ht[0]}${nt}${$t.padEnd(qt+mo,Nn)}`}return lo&&(l[1]=A[p]?A[p]:zt.fullform[h][p]+(e?An:Sn)+(l[0]===1?ft:Cn)),v===Tn?l:v===In?{value:l[0],symbol:l[1],exponent:p,unit:Mt}:l.join(n)}var z=class t{constructor(e){x(this,"tera");x(this,"id");x(this,"name");x(this,"icon");x(this,"path");x(this,"parsedName");x(this,"created");x(this,"createdFormatted");x(this,"modified");x(this,"modifiedFormatted");x(this,"accessed");x(this,"accessedFormatted");x(this,"size");x(this,"sizeFormatted");x(this,"mime");x(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=po(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(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.getProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}serialize(){return Ct(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Ct(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};var Kt=class{constructor(e){x(this,"settings",{devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",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});x(this,"events",ao());x(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});x(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"]);x(this,"plugins",[]);x(this,"acceptPostboxes",{});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(),...Dt(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","Message compose client->server:",o),this.debug("ERROR","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;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",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);else{if((r==null?void 0:r.action)=="rpc")return 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()})});if((r==null?void 0:r.action)=="event")return 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(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=Yt(r,e,Vt);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("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"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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
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){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),!(["INFO","LOG"].includes(r)&&!this.settings.devMode)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new z({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new z({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new z({tera:this,...r}))}};export{Kt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/dist/terafy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function qt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:b}){var S=Object.keys(i),T=S.length,g=Object.keys(n),_=g.length,y,p=i.length-n.length;if(uo(i,n)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(S[u]):S[u];l in n||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<_;u++){var l=Array.isArray(n)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:b})}}else{for(var u=0;u<p;u++)y=h.concat(u),b.remove.push({op:"remove",path:r(y)});for(var I=i.slice(p),u=0;u<_;u++)s({key:u,obj1:I,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:b})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:b,diffs:S}){var T=n[i],g=m[i];if(!(i in n)&&i in m){var _=g;S.add.push({op:"add",path:r(h),value:_})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?f(h,S,g):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:S}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Yt(t){return[""].concat(t).join("/")}function mo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function uo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var co=typeof global=="object"&&global&&global.Object===Object&&global,ut=co;var ho=typeof self=="object"&&self&&self.Object===Object&&self,xo=ut||ho||Function("return this")(),x=xo;var go=x.Symbol,w=go;var Vt=Object.prototype,yo=Vt.hasOwnProperty,bo=Vt.toString,nt=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Ao(t){return To.call(t)}var Jt=Ao;var So="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function jo(t){return t==null?t===void 0?Po:So:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var O=jo;function Oo(t){return t!=null&&typeof t=="object"}var j=Oo;var _o="[object Symbol]";function Io(t){return typeof t=="symbol"||j(t)&&O(t)==_o}var z=Io;function Eo(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 Qt=Eo;var Co=Array.isArray,v=Co;var Mo=1/0,te=w?w.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(v(t))return Qt(t,re)+"";if(z(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-Mo?"-0":e}var oe=re;function Ro(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Ro;function Bo(t){return t}var ae=Bo;var Fo="[object AsyncFunction]",Lo="[object Function]",No="[object GeneratorFunction]",Do="[object Proxy]";function ko(t){if(!P(t))return!1;var e=O(t);return e==Lo||e==No||e==Fo||e==Do}var dt=ko;var Uo=x["__core-js_shared__"],ct=Uo;var ie=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function zo(t){return!!ie&&ie in t}var se=zo;var Ko=Function.prototype,Go=Ko.toString;function Wo(t){if(t!=null){try{return Go.call(t)}catch{}try{return t+""}catch{}}return""}var E=Wo;var Ho=/[\\^$.*+?()[\]{}|]/g,$o=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!P(t)||se(t))return!1;var e=dt(t)?Jo:$o;return e.test(E(t))}var fe=Xo;function Qo(t,e){return t?.[e]}var ne=Qo;function ta(t,e){var r=ne(t,e);return fe(r)?r:void 0}var A=ta;var ea=A(x,"WeakMap"),ht=ea;var pe=Object.create,ra=function(){function t(){}return function(e){if(!P(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=ra;function oa(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 me=oa;function aa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=aa;var ia=800,sa=16,fa=Date.now;function na(t){var e=0,r=0;return function(){var o=fa(),a=sa-(o-r);if(r=o,a>0){if(++e>=ia)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=na;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=A(Object,"defineProperty");return t({},"",{}),t}catch{}}(),K=la;var ma=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ma;var ua=de(he),xe=ua;function da(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=da;var ca=9007199254740991,ha=/^(?:0|[1-9]\d*)$/;function xa(t,e){var r=typeof t;return e=e??ca,!!e&&(r=="number"||r!="symbol"&&ha.test(t))&&t>-1&&t%1==0&&t<e}var G=xa;function ga(t,e,r){e=="__proto__"&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ga;function ya(t,e){return t===e||t!==t&&e!==e}var gt=ya;var ba=Object.prototype,va=ba.hasOwnProperty;function wa(t,e,r){var o=t[e];(!(va.call(t,e)&>(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var W=wa;function Ta(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?xt(r,i,n):W(r,i,n)}return r}var R=Ta;var ye=Math.max;function Aa(t,e,r){return e=ye(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ye(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),me(t,this,i)}}var be=Aa;var Sa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Sa}var H=Pa;function ja(t){return t!=null&&H(t.length)&&!dt(t)}var yt=ja;var Oa=Object.prototype;function _a(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Oa;return t===r}var $=_a;function Ia(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=Ia;var Ea="[object Arguments]";function Ca(t){return j(t)&&O(t)==Ea}var Mt=Ca;var we=Object.prototype,Ma=we.hasOwnProperty,Ra=we.propertyIsEnumerable,Ba=Mt(function(){return arguments}())?Mt:function(t){return j(t)&&Ma.call(t,"callee")&&!Ra.call(t,"callee")},q=Ba;function Fa(){return!1}var Te=Fa;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ae=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,La=Ae&&Ae.exports===Pe,Se=La?x.Buffer:void 0,Na=Se?Se.isBuffer:void 0,Da=Na||Te,bt=Da;var ka="[object Arguments]",Ua="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",Ha="[object Map]",$a="[object Number]",qa="[object Object]",Ya="[object RegExp]",Va="[object Set]",Za="[object String]",Ja="[object WeakMap]",Xa="[object ArrayBuffer]",Qa="[object DataView]",ti="[object Float32Array]",ei="[object Float64Array]",ri="[object Int8Array]",oi="[object Int16Array]",ai="[object Int32Array]",ii="[object Uint8Array]",si="[object Uint8ClampedArray]",fi="[object Uint16Array]",ni="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=!0;c[ka]=c[Ua]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[Ha]=c[$a]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return j(t)&&H(t.length)&&!!c[O(t)]}var je=pi;function li(t){return function(e){return t(e)}}var Y=li;var Oe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=Oe&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===Oe,Rt=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Rt&&Rt.binding&&Rt.binding("util")}catch{}}(),C=ui;var _e=C&&C.isTypedArray,di=_e?Y(_e):je,Ie=di;var ci=Object.prototype,hi=ci.hasOwnProperty;function xi(t,e){var r=v(t),o=!r&&q(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&Ie(t),f=r||o||a||s,i=f?ve(t.length,String):[],n=i.length;for(var m in t)(e||hi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,n)))&&i.push(m);return i}var vt=xi;function gi(t,e){return function(r){return t(e(r))}}var wt=gi;var yi=wt(Object.keys,Object),Ee=yi;var bi=Object.prototype,vi=bi.hasOwnProperty;function wi(t){if(!$(t))return Ee(t);var e=[];for(var r in Object(t))vi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=wi;function Ti(t){return yt(t)?vt(t):Ce(t)}var V=Ti;function Ai(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Me=Ai;var Si=Object.prototype,Pi=Si.hasOwnProperty;function ji(t){if(!P(t))return Me(t);var e=$(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Re=ji;function Oi(t){return yt(t)?vt(t,!0):Re(t)}var Z=Oi;var _i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ii=/^\w*$/;function Ei(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||z(t)?!0:Ii.test(t)||!_i.test(t)||e!=null&&t in Object(e)}var Be=Ei;var Ci=A(Object,"create"),M=Ci;function Mi(){this.__data__=M?M(null):{},this.size=0}var Fe=Mi;function Ri(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Le=Ri;var Bi="__lodash_hash_undefined__",Fi=Object.prototype,Li=Fi.hasOwnProperty;function Ni(t){var e=this.__data__;if(M){var r=e[t];return r===Bi?void 0:r}return Li.call(e,t)?e[t]:void 0}var Ne=Ni;var Di=Object.prototype,ki=Di.hasOwnProperty;function Ui(t){var e=this.__data__;return M?e[t]!==void 0:ki.call(e,t)}var De=Ui;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?zi:e,this}var ke=Ki;function J(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])}}J.prototype.clear=Fe;J.prototype.delete=Le;J.prototype.get=Ne;J.prototype.has=De;J.prototype.set=ke;var Bt=J;function Gi(){this.__data__=[],this.size=0}var Ue=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var B=Wi;var Hi=Array.prototype,$i=Hi.splice;function qi(t){var e=this.__data__,r=B(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():$i.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=B(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return B(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=B(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=Zi;function X(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])}}X.prototype.clear=Ue;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var F=X;var Ji=A(x,"Map"),L=Ji;function Xi(){this.size=0,this.__data__={hash:new Bt,map:new(L||F),string:new Bt}}var He=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Qi;function ts(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var N=ts;function es(t){var e=N(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return N(this,t).get(t)}var Ye=rs;function os(t){return N(this,t).has(t)}var Ve=os;function as(t,e){var r=N(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=as;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=He;Q.prototype.delete=qe;Q.prototype.get=Ye;Q.prototype.has=Ve;Q.prototype.set=Ze;var lt=Q;var is="Expected a function";function Ft(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(is);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Ft.Cache||lt),r}Ft.Cache=lt;var Je=Ft;var ss=500;function fs(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ns=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ns,function(r,o,a,s){e.push(a?s.replace(ps,"$1"):o||r)}),e}),Qe=ls;function ms(t){return t==null?"":oe(t)}var tr=ms;function us(t,e){return v(t)?t:Be(t,e)?[t]:Qe(tr(t))}var D=us;var ds=1/0;function cs(t){if(typeof t=="string"||z(t))return t;var e=t+"";return e=="0"&&1/t==-ds?"-0":e}var tt=cs;function hs(t,e){e=D(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[tt(e[r++])];return r&&r==o?t:void 0}var er=hs;function xs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var et=xs;var rr=w?w.isConcatSpreadable:void 0;function gs(t){return v(t)||q(t)||!!(rr&&t&&t[rr])}var or=gs;function ar(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=or),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ar(i,e-1,r,o,a):et(a,i):o||(a[a.length]=i)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function bs(t){return xe(be(t,void 0,sr),t+"")}var fr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new F,this.size=0}var nr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function As(t){return this.__data__.get(t)}var lr=As;function Ss(t){return this.__data__.has(t)}var mr=Ss;var Ps=200;function js(t,e){var r=this.__data__;if(r instanceof F){var o=r.__data__;if(!L||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new lt(o)}return r.set(t,e),this.size=r.size,this}var ur=js;function rt(t){var e=this.__data__=new F(t);this.size=e.size}rt.prototype.clear=nr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function Os(t,e){return t&&R(e,V(e),t)}var cr=Os;function _s(t,e){return t&&R(e,Z(e),t)}var hr=_s;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,Is=xr&&xr.exports===br,gr=Is?x.Buffer:void 0,yr=gr?gr.allocUnsafe:void 0;function Es(t,e){if(e)return t.slice();var r=t.length,o=yr?yr(r):new t.constructor(r);return t.copy(o),o}var vr=Es;function Cs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var wr=Cs;function Ms(){return[]}var At=Ms;var Rs=Object.prototype,Bs=Rs.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Fs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Bs.call(t,e)}))}:At,ot=Fs;function Ls(t,e){return R(t,ot(t),e)}var Ar=Ls;var Ns=Object.getOwnPropertySymbols,Ds=Ns?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:At,St=Ds;function ks(t,e){return R(t,St(t),e)}var Sr=ks;function Us(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=Us;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,St)}var jr=Ks;var Gs=A(x,"DataView"),jt=Gs;var Ws=A(x,"Promise"),Ot=Ws;var Hs=A(x,"Set"),_t=Hs;var Or="[object Map]",$s="[object Object]",_r="[object Promise]",Ir="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(jt),Ys=E(L),Vs=E(Ot),Zs=E(_t),Js=E(ht),k=O;(jt&&k(new jt(new ArrayBuffer(1)))!=Cr||L&&k(new L)!=Or||Ot&&k(Ot.resolve())!=_r||_t&&k(new _t)!=Ir||ht&&k(new ht)!=Er)&&(k=function(t){var e=O(t),r=e==$s?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Or;case Vs:return _r;case Zs:return Ir;case Js:return Er}return e});var at=k;var Xs=Object.prototype,Qs=Xs.hasOwnProperty;function tf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Qs.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Mr=tf;var ef=x.Uint8Array,Lt=ef;function rf(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var it=rf;function of(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Rr=of;var af=/\w*$/;function sf(t){var e=new t.constructor(t.source,af.exec(t));return e.lastIndex=t.lastIndex,e}var Br=sf;var Fr=w?w.prototype:void 0,Lr=Fr?Fr.valueOf:void 0;function ff(t){return Lr?Object(Lr.call(t)):{}}var Nr=ff;function nf(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=nf;var pf="[object Boolean]",lf="[object Date]",mf="[object Map]",uf="[object Number]",df="[object RegExp]",cf="[object Set]",hf="[object String]",xf="[object Symbol]",gf="[object ArrayBuffer]",yf="[object DataView]",bf="[object Float32Array]",vf="[object Float64Array]",wf="[object Int8Array]",Tf="[object Int16Array]",Af="[object Int32Array]",Sf="[object Uint8Array]",Pf="[object Uint8ClampedArray]",jf="[object Uint16Array]",Of="[object Uint32Array]";function _f(t,e,r){var o=t.constructor;switch(e){case gf:return it(t);case pf:case lf:return new o(+t);case yf:return Rr(t,r);case bf:case vf:case wf:case Tf:case Af:case Sf:case Pf:case jf:case Of:return Dr(t,r);case mf:return new o;case uf:case hf:return new o(t);case df:return Br(t);case cf:return new o;case xf:return Nr(t)}}var kr=_f;function If(t){return typeof t.constructor=="function"&&!$(t)?le(Tt(t)):{}}var Ur=If;var Ef="[object Map]";function Cf(t){return j(t)&&at(t)==Ef}var zr=Cf;var Kr=C&&C.isMap,Mf=Kr?Y(Kr):zr,Gr=Mf;var Rf="[object Set]";function Bf(t){return j(t)&&at(t)==Rf}var Wr=Bf;var Hr=C&&C.isSet,Ff=Hr?Y(Hr):Wr,$r=Ff;var Lf=1,Nf=2,Df=4,qr="[object Arguments]",kf="[object Array]",Uf="[object Boolean]",zf="[object Date]",Kf="[object Error]",Yr="[object Function]",Gf="[object GeneratorFunction]",Wf="[object Map]",Hf="[object Number]",Vr="[object Object]",$f="[object RegExp]",qf="[object Set]",Yf="[object String]",Vf="[object Symbol]",Zf="[object WeakMap]",Jf="[object ArrayBuffer]",Xf="[object DataView]",Qf="[object Float32Array]",tn="[object Float64Array]",en="[object Int8Array]",rn="[object Int16Array]",on="[object Int32Array]",an="[object Uint8Array]",sn="[object Uint8ClampedArray]",fn="[object Uint16Array]",nn="[object Uint32Array]",d={};d[qr]=d[kf]=d[Jf]=d[Xf]=d[Uf]=d[zf]=d[Qf]=d[tn]=d[en]=d[rn]=d[on]=d[Wf]=d[Hf]=d[Vr]=d[$f]=d[qf]=d[Yf]=d[Vf]=d[an]=d[sn]=d[fn]=d[nn]=!0;d[Kf]=d[Yr]=d[Zf]=!1;function It(t,e,r,o,a,s){var f,i=e&Lf,n=e&Nf,m=e&Df;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!P(t))return t;var h=v(t);if(h){if(f=Mr(t),!i)return ue(t,f)}else{var b=at(t),S=b==Yr||b==Gf;if(bt(t))return vr(t,i);if(b==Vr||b==qr||S&&!a){if(f=n||S?{}:Ur(t),!i)return n?Sr(t,hr(f,t)):Ar(t,cr(f,t))}else{if(!d[b])return a?t:{};f=kr(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,f),$r(t)?t.forEach(function(y){f.add(It(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){f.set(p,It(y,e,r,p,t,s))});var g=m?n?jr:Pr:n?Z:V,_=h?void 0:g(t);return ge(_||t,function(y,p){_&&(p=y,y=t[p]),W(f,p,It(y,e,r,p,t,s))}),f}var Zr=It;var pn=1,ln=4;function mn(t){return Zr(t,pn|ln)}var Nt=mn;function un(t,e){return t!=null&&e in Object(t)}var Jr=un;function dn(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=tt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&H(a)&&G(f,a)&&(v(t)||q(t)))}var Xr=dn;function cn(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cn;function hn(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=tt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,n,m),i=i[n]}return t}var to=hn;function xn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=er(t,f);r(i,f)&&to(s,D(f,t),i)}return s}var eo=xn;function gn(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gn;var yn=fr(function(t,e){return t==null?{}:ro(t,e)}),Et=yn;function oo(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 Dt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var bn="array",vn="bit",ao="bits",wn="byte",io="bytes",st="",Tn="exponent",An="function",so="iec",Sn="Invalid number",Pn="Invalid rounding method",kt="jedec",jn="object",fo=".",On="round",_n="s",In="si",En="kbit",Cn="kB",Mn=" ",Rn="string",Bn="0",Ut={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 no(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:f={},separator:i=st,spacer:n=Mn,symbols:m={},standard:h=st,output:b=Rn,fullform:S=!1,fullforms:T=[],exponent:g=-1,roundingMethod:_=On,precision:y=0}={}){let p=g,u=Number(t),l=[],I=0,Ct=st;h===In?(o=10,h=kt):h===so||h===kt?o=2:o===2?h=so:(o=10,h=kt);let mt=o===10?1e3:1024,po=S===!0,Kt=u<0,Gt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Sn);if(typeof Gt!==An)throw new TypeError(Pn);if(Kt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(mt)),p<0&&(p=0)),p>8&&(y>0&&(y+=8-p),p=8),b===Tn)return p;if(u===0)l[0]=0,Ct=l[1]=Ut.symbol[h][e?ao:io][p];else{I=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(I=I*8,I>=mt&&p<8&&(I=I/mt,p++));let ft=Math.pow(10,p>0?a:0);l[0]=Gt(I*ft)/ft,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?En:Cn:Ut.symbol[h][e?ao:io][p]}if(Kt&&(l[0]=-l[0]),y>0&&(l[0]=l[0].toPrecision(y)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(fo,i)),r&&Number.isInteger(l[0])===!1&&a>0){let ft=i||fo,Wt=l[0].toString().split(ft),Ht=Wt[1]||st,$t=Ht.length,lo=a-$t;l[0]=`${Wt[0]}${ft}${Ht.padEnd($t+lo,Bn)}`}return po&&(l[1]=T[p]?T[p]:Ut.fullform[h][p]+(e?vn:wn)+(l[0]===1?st:_n)),b===bn?l:b===jn?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(n)}var U=class t{tera;id;name;path;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=no(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(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.getProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}serialize(){return Et(this,["id","name","path","parsedName","created","modified","accessed","size","mime"])}static deserialize(e){return new t(Et(e,["id","name","path","parsedName","created","modified","accessed","size","mime"]))}};var zt=class{settings={devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",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};events=oo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=Dt();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||Dt(),...Nt(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","Message compose client->server:",o),this.debug("ERROR","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;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",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);else{if(r?.action=="rpc")return 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()})});if(r?.action=="event")return 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(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=qt(r,e,Yt);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("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"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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(`
|
|
1
|
+
function qt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:b}){var S=Object.keys(i),T=S.length,g=Object.keys(n),_=g.length,y,p=i.length-n.length;if(uo(i,n)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(S[u]):S[u];l in n||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<_;u++){var l=Array.isArray(n)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:b})}}else{for(var u=0;u<p;u++)y=h.concat(u),b.remove.push({op:"remove",path:r(y)});for(var I=i.slice(p),u=0;u<_;u++)s({key:u,obj1:I,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:b})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:b,diffs:S}){var T=n[i],g=m[i];if(!(i in n)&&i in m){var _=g;S.add.push({op:"add",path:r(h),value:_})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?f(h,S,g):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:S}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Yt(t){return[""].concat(t).join("/")}function mo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function uo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var co=typeof global=="object"&&global&&global.Object===Object&&global,ut=co;var ho=typeof self=="object"&&self&&self.Object===Object&&self,xo=ut||ho||Function("return this")(),x=xo;var go=x.Symbol,w=go;var Vt=Object.prototype,yo=Vt.hasOwnProperty,bo=Vt.toString,nt=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Ao(t){return To.call(t)}var Jt=Ao;var So="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function jo(t){return t==null?t===void 0?Po:So:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var O=jo;function Oo(t){return t!=null&&typeof t=="object"}var j=Oo;var _o="[object Symbol]";function Io(t){return typeof t=="symbol"||j(t)&&O(t)==_o}var z=Io;function Eo(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 Qt=Eo;var Co=Array.isArray,v=Co;var Mo=1/0,te=w?w.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(v(t))return Qt(t,re)+"";if(z(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-Mo?"-0":e}var oe=re;function Ro(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Ro;function Bo(t){return t}var ae=Bo;var Fo="[object AsyncFunction]",Lo="[object Function]",No="[object GeneratorFunction]",Do="[object Proxy]";function ko(t){if(!P(t))return!1;var e=O(t);return e==Lo||e==No||e==Fo||e==Do}var dt=ko;var Uo=x["__core-js_shared__"],ct=Uo;var ie=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function zo(t){return!!ie&&ie in t}var se=zo;var Ko=Function.prototype,Go=Ko.toString;function Wo(t){if(t!=null){try{return Go.call(t)}catch{}try{return t+""}catch{}}return""}var E=Wo;var Ho=/[\\^$.*+?()[\]{}|]/g,$o=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!P(t)||se(t))return!1;var e=dt(t)?Jo:$o;return e.test(E(t))}var fe=Xo;function Qo(t,e){return t?.[e]}var ne=Qo;function ta(t,e){var r=ne(t,e);return fe(r)?r:void 0}var A=ta;var ea=A(x,"WeakMap"),ht=ea;var pe=Object.create,ra=function(){function t(){}return function(e){if(!P(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=ra;function oa(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 me=oa;function aa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=aa;var ia=800,sa=16,fa=Date.now;function na(t){var e=0,r=0;return function(){var o=fa(),a=sa-(o-r);if(r=o,a>0){if(++e>=ia)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=na;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=A(Object,"defineProperty");return t({},"",{}),t}catch{}}(),K=la;var ma=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ma;var ua=de(he),xe=ua;function da(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=da;var ca=9007199254740991,ha=/^(?:0|[1-9]\d*)$/;function xa(t,e){var r=typeof t;return e=e??ca,!!e&&(r=="number"||r!="symbol"&&ha.test(t))&&t>-1&&t%1==0&&t<e}var G=xa;function ga(t,e,r){e=="__proto__"&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ga;function ya(t,e){return t===e||t!==t&&e!==e}var gt=ya;var ba=Object.prototype,va=ba.hasOwnProperty;function wa(t,e,r){var o=t[e];(!(va.call(t,e)&>(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var W=wa;function Ta(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?xt(r,i,n):W(r,i,n)}return r}var R=Ta;var ye=Math.max;function Aa(t,e,r){return e=ye(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ye(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),me(t,this,i)}}var be=Aa;var Sa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Sa}var H=Pa;function ja(t){return t!=null&&H(t.length)&&!dt(t)}var yt=ja;var Oa=Object.prototype;function _a(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Oa;return t===r}var $=_a;function Ia(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=Ia;var Ea="[object Arguments]";function Ca(t){return j(t)&&O(t)==Ea}var Mt=Ca;var we=Object.prototype,Ma=we.hasOwnProperty,Ra=we.propertyIsEnumerable,Ba=Mt(function(){return arguments}())?Mt:function(t){return j(t)&&Ma.call(t,"callee")&&!Ra.call(t,"callee")},q=Ba;function Fa(){return!1}var Te=Fa;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ae=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,La=Ae&&Ae.exports===Pe,Se=La?x.Buffer:void 0,Na=Se?Se.isBuffer:void 0,Da=Na||Te,bt=Da;var ka="[object Arguments]",Ua="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",Ha="[object Map]",$a="[object Number]",qa="[object Object]",Ya="[object RegExp]",Va="[object Set]",Za="[object String]",Ja="[object WeakMap]",Xa="[object ArrayBuffer]",Qa="[object DataView]",ti="[object Float32Array]",ei="[object Float64Array]",ri="[object Int8Array]",oi="[object Int16Array]",ai="[object Int32Array]",ii="[object Uint8Array]",si="[object Uint8ClampedArray]",fi="[object Uint16Array]",ni="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=!0;c[ka]=c[Ua]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[Ha]=c[$a]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return j(t)&&H(t.length)&&!!c[O(t)]}var je=pi;function li(t){return function(e){return t(e)}}var Y=li;var Oe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=Oe&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===Oe,Rt=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Rt&&Rt.binding&&Rt.binding("util")}catch{}}(),C=ui;var _e=C&&C.isTypedArray,di=_e?Y(_e):je,Ie=di;var ci=Object.prototype,hi=ci.hasOwnProperty;function xi(t,e){var r=v(t),o=!r&&q(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&Ie(t),f=r||o||a||s,i=f?ve(t.length,String):[],n=i.length;for(var m in t)(e||hi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,n)))&&i.push(m);return i}var vt=xi;function gi(t,e){return function(r){return t(e(r))}}var wt=gi;var yi=wt(Object.keys,Object),Ee=yi;var bi=Object.prototype,vi=bi.hasOwnProperty;function wi(t){if(!$(t))return Ee(t);var e=[];for(var r in Object(t))vi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=wi;function Ti(t){return yt(t)?vt(t):Ce(t)}var V=Ti;function Ai(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Me=Ai;var Si=Object.prototype,Pi=Si.hasOwnProperty;function ji(t){if(!P(t))return Me(t);var e=$(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Re=ji;function Oi(t){return yt(t)?vt(t,!0):Re(t)}var Z=Oi;var _i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ii=/^\w*$/;function Ei(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||z(t)?!0:Ii.test(t)||!_i.test(t)||e!=null&&t in Object(e)}var Be=Ei;var Ci=A(Object,"create"),M=Ci;function Mi(){this.__data__=M?M(null):{},this.size=0}var Fe=Mi;function Ri(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Le=Ri;var Bi="__lodash_hash_undefined__",Fi=Object.prototype,Li=Fi.hasOwnProperty;function Ni(t){var e=this.__data__;if(M){var r=e[t];return r===Bi?void 0:r}return Li.call(e,t)?e[t]:void 0}var Ne=Ni;var Di=Object.prototype,ki=Di.hasOwnProperty;function Ui(t){var e=this.__data__;return M?e[t]!==void 0:ki.call(e,t)}var De=Ui;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?zi:e,this}var ke=Ki;function J(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])}}J.prototype.clear=Fe;J.prototype.delete=Le;J.prototype.get=Ne;J.prototype.has=De;J.prototype.set=ke;var Bt=J;function Gi(){this.__data__=[],this.size=0}var Ue=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var B=Wi;var Hi=Array.prototype,$i=Hi.splice;function qi(t){var e=this.__data__,r=B(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():$i.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=B(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return B(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=B(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=Zi;function X(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])}}X.prototype.clear=Ue;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var F=X;var Ji=A(x,"Map"),L=Ji;function Xi(){this.size=0,this.__data__={hash:new Bt,map:new(L||F),string:new Bt}}var He=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Qi;function ts(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var N=ts;function es(t){var e=N(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return N(this,t).get(t)}var Ye=rs;function os(t){return N(this,t).has(t)}var Ve=os;function as(t,e){var r=N(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=as;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=He;Q.prototype.delete=qe;Q.prototype.get=Ye;Q.prototype.has=Ve;Q.prototype.set=Ze;var lt=Q;var is="Expected a function";function Ft(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(is);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Ft.Cache||lt),r}Ft.Cache=lt;var Je=Ft;var ss=500;function fs(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ns=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ns,function(r,o,a,s){e.push(a?s.replace(ps,"$1"):o||r)}),e}),Qe=ls;function ms(t){return t==null?"":oe(t)}var tr=ms;function us(t,e){return v(t)?t:Be(t,e)?[t]:Qe(tr(t))}var D=us;var ds=1/0;function cs(t){if(typeof t=="string"||z(t))return t;var e=t+"";return e=="0"&&1/t==-ds?"-0":e}var tt=cs;function hs(t,e){e=D(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[tt(e[r++])];return r&&r==o?t:void 0}var er=hs;function xs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var et=xs;var rr=w?w.isConcatSpreadable:void 0;function gs(t){return v(t)||q(t)||!!(rr&&t&&t[rr])}var or=gs;function ar(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=or),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ar(i,e-1,r,o,a):et(a,i):o||(a[a.length]=i)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function bs(t){return xe(be(t,void 0,sr),t+"")}var fr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new F,this.size=0}var nr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function As(t){return this.__data__.get(t)}var lr=As;function Ss(t){return this.__data__.has(t)}var mr=Ss;var Ps=200;function js(t,e){var r=this.__data__;if(r instanceof F){var o=r.__data__;if(!L||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new lt(o)}return r.set(t,e),this.size=r.size,this}var ur=js;function rt(t){var e=this.__data__=new F(t);this.size=e.size}rt.prototype.clear=nr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function Os(t,e){return t&&R(e,V(e),t)}var cr=Os;function _s(t,e){return t&&R(e,Z(e),t)}var hr=_s;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,Is=xr&&xr.exports===br,gr=Is?x.Buffer:void 0,yr=gr?gr.allocUnsafe:void 0;function Es(t,e){if(e)return t.slice();var r=t.length,o=yr?yr(r):new t.constructor(r);return t.copy(o),o}var vr=Es;function Cs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var wr=Cs;function Ms(){return[]}var At=Ms;var Rs=Object.prototype,Bs=Rs.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Fs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Bs.call(t,e)}))}:At,ot=Fs;function Ls(t,e){return R(t,ot(t),e)}var Ar=Ls;var Ns=Object.getOwnPropertySymbols,Ds=Ns?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:At,St=Ds;function ks(t,e){return R(t,St(t),e)}var Sr=ks;function Us(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=Us;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,St)}var jr=Ks;var Gs=A(x,"DataView"),jt=Gs;var Ws=A(x,"Promise"),Ot=Ws;var Hs=A(x,"Set"),_t=Hs;var Or="[object Map]",$s="[object Object]",_r="[object Promise]",Ir="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(jt),Ys=E(L),Vs=E(Ot),Zs=E(_t),Js=E(ht),k=O;(jt&&k(new jt(new ArrayBuffer(1)))!=Cr||L&&k(new L)!=Or||Ot&&k(Ot.resolve())!=_r||_t&&k(new _t)!=Ir||ht&&k(new ht)!=Er)&&(k=function(t){var e=O(t),r=e==$s?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Or;case Vs:return _r;case Zs:return Ir;case Js:return Er}return e});var at=k;var Xs=Object.prototype,Qs=Xs.hasOwnProperty;function tf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Qs.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Mr=tf;var ef=x.Uint8Array,Lt=ef;function rf(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var it=rf;function of(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Rr=of;var af=/\w*$/;function sf(t){var e=new t.constructor(t.source,af.exec(t));return e.lastIndex=t.lastIndex,e}var Br=sf;var Fr=w?w.prototype:void 0,Lr=Fr?Fr.valueOf:void 0;function ff(t){return Lr?Object(Lr.call(t)):{}}var Nr=ff;function nf(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=nf;var pf="[object Boolean]",lf="[object Date]",mf="[object Map]",uf="[object Number]",df="[object RegExp]",cf="[object Set]",hf="[object String]",xf="[object Symbol]",gf="[object ArrayBuffer]",yf="[object DataView]",bf="[object Float32Array]",vf="[object Float64Array]",wf="[object Int8Array]",Tf="[object Int16Array]",Af="[object Int32Array]",Sf="[object Uint8Array]",Pf="[object Uint8ClampedArray]",jf="[object Uint16Array]",Of="[object Uint32Array]";function _f(t,e,r){var o=t.constructor;switch(e){case gf:return it(t);case pf:case lf:return new o(+t);case yf:return Rr(t,r);case bf:case vf:case wf:case Tf:case Af:case Sf:case Pf:case jf:case Of:return Dr(t,r);case mf:return new o;case uf:case hf:return new o(t);case df:return Br(t);case cf:return new o;case xf:return Nr(t)}}var kr=_f;function If(t){return typeof t.constructor=="function"&&!$(t)?le(Tt(t)):{}}var Ur=If;var Ef="[object Map]";function Cf(t){return j(t)&&at(t)==Ef}var zr=Cf;var Kr=C&&C.isMap,Mf=Kr?Y(Kr):zr,Gr=Mf;var Rf="[object Set]";function Bf(t){return j(t)&&at(t)==Rf}var Wr=Bf;var Hr=C&&C.isSet,Ff=Hr?Y(Hr):Wr,$r=Ff;var Lf=1,Nf=2,Df=4,qr="[object Arguments]",kf="[object Array]",Uf="[object Boolean]",zf="[object Date]",Kf="[object Error]",Yr="[object Function]",Gf="[object GeneratorFunction]",Wf="[object Map]",Hf="[object Number]",Vr="[object Object]",$f="[object RegExp]",qf="[object Set]",Yf="[object String]",Vf="[object Symbol]",Zf="[object WeakMap]",Jf="[object ArrayBuffer]",Xf="[object DataView]",Qf="[object Float32Array]",tn="[object Float64Array]",en="[object Int8Array]",rn="[object Int16Array]",on="[object Int32Array]",an="[object Uint8Array]",sn="[object Uint8ClampedArray]",fn="[object Uint16Array]",nn="[object Uint32Array]",d={};d[qr]=d[kf]=d[Jf]=d[Xf]=d[Uf]=d[zf]=d[Qf]=d[tn]=d[en]=d[rn]=d[on]=d[Wf]=d[Hf]=d[Vr]=d[$f]=d[qf]=d[Yf]=d[Vf]=d[an]=d[sn]=d[fn]=d[nn]=!0;d[Kf]=d[Yr]=d[Zf]=!1;function It(t,e,r,o,a,s){var f,i=e&Lf,n=e&Nf,m=e&Df;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!P(t))return t;var h=v(t);if(h){if(f=Mr(t),!i)return ue(t,f)}else{var b=at(t),S=b==Yr||b==Gf;if(bt(t))return vr(t,i);if(b==Vr||b==qr||S&&!a){if(f=n||S?{}:Ur(t),!i)return n?Sr(t,hr(f,t)):Ar(t,cr(f,t))}else{if(!d[b])return a?t:{};f=kr(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,f),$r(t)?t.forEach(function(y){f.add(It(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){f.set(p,It(y,e,r,p,t,s))});var g=m?n?jr:Pr:n?Z:V,_=h?void 0:g(t);return ge(_||t,function(y,p){_&&(p=y,y=t[p]),W(f,p,It(y,e,r,p,t,s))}),f}var Zr=It;var pn=1,ln=4;function mn(t){return Zr(t,pn|ln)}var Nt=mn;function un(t,e){return t!=null&&e in Object(t)}var Jr=un;function dn(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=tt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&H(a)&&G(f,a)&&(v(t)||q(t)))}var Xr=dn;function cn(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cn;function hn(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=tt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,n,m),i=i[n]}return t}var to=hn;function xn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=er(t,f);r(i,f)&&to(s,D(f,t),i)}return s}var eo=xn;function gn(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gn;var yn=fr(function(t,e){return t==null?{}:ro(t,e)}),Et=yn;function oo(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 Dt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var bn="array",vn="bit",ao="bits",wn="byte",io="bytes",st="",Tn="exponent",An="function",so="iec",Sn="Invalid number",Pn="Invalid rounding method",kt="jedec",jn="object",fo=".",On="round",_n="s",In="si",En="kbit",Cn="kB",Mn=" ",Rn="string",Bn="0",Ut={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 no(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:f={},separator:i=st,spacer:n=Mn,symbols:m={},standard:h=st,output:b=Rn,fullform:S=!1,fullforms:T=[],exponent:g=-1,roundingMethod:_=On,precision:y=0}={}){let p=g,u=Number(t),l=[],I=0,Ct=st;h===In?(o=10,h=kt):h===so||h===kt?o=2:o===2?h=so:(o=10,h=kt);let mt=o===10?1e3:1024,po=S===!0,Kt=u<0,Gt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Sn);if(typeof Gt!==An)throw new TypeError(Pn);if(Kt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(mt)),p<0&&(p=0)),p>8&&(y>0&&(y+=8-p),p=8),b===Tn)return p;if(u===0)l[0]=0,Ct=l[1]=Ut.symbol[h][e?ao:io][p];else{I=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(I=I*8,I>=mt&&p<8&&(I=I/mt,p++));let ft=Math.pow(10,p>0?a:0);l[0]=Gt(I*ft)/ft,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?En:Cn:Ut.symbol[h][e?ao:io][p]}if(Kt&&(l[0]=-l[0]),y>0&&(l[0]=l[0].toPrecision(y)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(fo,i)),r&&Number.isInteger(l[0])===!1&&a>0){let ft=i||fo,Wt=l[0].toString().split(ft),Ht=Wt[1]||st,$t=Ht.length,lo=a-$t;l[0]=`${Wt[0]}${ft}${Ht.padEnd($t+lo,Bn)}`}return po&&(l[1]=T[p]?T[p]:Ut.fullform[h][p]+(e?vn:wn)+(l[0]===1?st:_n)),b===bn?l:b===jn?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(n)}var U=class t{tera;id;name;icon;path;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=no(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(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.getProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}serialize(){return Et(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",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};events=oo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=Dt();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||Dt(),...Nt(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","Message compose client->server:",o),this.debug("ERROR","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;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",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);else{if(r?.action=="rpc")return 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()})});if(r?.action=="event")return 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(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=qt(r,e,Yt);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("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"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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
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){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),!(["INFO","LOG"].includes(r)&&!this.settings.devMode)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new U({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new U({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new U({tera:this,...r}))}};export{zt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/lib/projectFile.js
CHANGED
|
@@ -28,6 +28,13 @@ export default class ProjectFile {
|
|
|
28
28
|
name;
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* CSS class to use as the file icon
|
|
33
|
+
* @type {String}
|
|
34
|
+
*/
|
|
35
|
+
icon;
|
|
36
|
+
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Full path to the file
|
|
33
40
|
* This is also used as the unique identifier within the project
|
|
@@ -110,6 +117,13 @@ export default class ProjectFile {
|
|
|
110
117
|
mime;
|
|
111
118
|
|
|
112
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Additional meta information for the file
|
|
122
|
+
* @type {Object}
|
|
123
|
+
*/
|
|
124
|
+
meta = {};
|
|
125
|
+
|
|
126
|
+
|
|
113
127
|
/**
|
|
114
128
|
* ProjectFile constructor
|
|
115
129
|
* Takes the input basic file type from Supabase and adds additional formatted fields
|
|
@@ -190,6 +204,7 @@ export default class ProjectFile {
|
|
|
190
204
|
return pick(this, [
|
|
191
205
|
'id',
|
|
192
206
|
'name',
|
|
207
|
+
'icon',
|
|
193
208
|
'path',
|
|
194
209
|
'parsedName',
|
|
195
210
|
'created',
|
|
@@ -197,6 +212,7 @@ export default class ProjectFile {
|
|
|
197
212
|
'accessed',
|
|
198
213
|
'size',
|
|
199
214
|
'mime',
|
|
215
|
+
'meta',
|
|
200
216
|
// Note that computed values such as `*Formatted` are omitted as they can be computed during the constructor stage
|
|
201
217
|
]);
|
|
202
218
|
}
|
|
@@ -210,8 +226,10 @@ export default class ProjectFile {
|
|
|
210
226
|
*/
|
|
211
227
|
static deserialize(data) {
|
|
212
228
|
return new ProjectFile(pick(data, [
|
|
229
|
+
'tera',
|
|
213
230
|
'id',
|
|
214
231
|
'name',
|
|
232
|
+
'icon',
|
|
215
233
|
'path',
|
|
216
234
|
'parsedName',
|
|
217
235
|
'created',
|
|
@@ -219,6 +237,7 @@ export default class ProjectFile {
|
|
|
219
237
|
'accessed',
|
|
220
238
|
'size',
|
|
221
239
|
'mime',
|
|
240
|
+
'meta',
|
|
222
241
|
]));
|
|
223
242
|
}
|
|
224
243
|
}
|
package/lib/terafy.client.js
CHANGED
|
@@ -290,7 +290,7 @@ export default class TeraFy {
|
|
|
290
290
|
*
|
|
291
291
|
* @returns {Promise} A promise which will resolve when the operation has completed
|
|
292
292
|
*/
|
|
293
|
-
applyProjectStatePatchLocal(patch) {
|
|
293
|
+
applyProjectStatePatchLocal(patch) { // eslint-disable-line
|
|
294
294
|
throw new Error('applyProjectStatePatchLocal() has not been sub-classed by a plugin');
|
|
295
295
|
}
|
|
296
296
|
// }}}
|