@iebh/tera-fy 1.7.2 → 1.7.4
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 +14 -0
- package/api.md +358 -372
- package/dist/terafy.es2019.js +2 -2
- package/dist/terafy.js +1 -1
- package/lib/projectFile.js +19 -8
- package/lib/terafy.server.js +10 -3
- package/package.json +1 -1
- package/plugins/vue3.js +1 -1
package/dist/terafy.es2019.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var bo=Object.defineProperty;var vo=(t,e,r)=>e in t?bo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>(vo(t,typeof e!="symbol"?e+"":e,r),r),Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var lt=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Xt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Qt=(t,e,r,o)=>(Jt(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r);function te(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:f,basePath:m,basePathForRemoves:x,diffs:v}){var P=Object.keys(i),O=P.length,y=Object.keys(f),_=y.length,b,p=i.length-f.length;if(To(i,f)){for(var u=0;u<O;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in f||(b=x.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<_;u++){var l=Array.isArray(f)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:f,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=x.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<_;u++)s({key:u,obj1:E,obj2:f,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:f,obj2:m,path:x,pathForRemoves:v,diffs:P}){var O=f[i],y=m[i];if(!(i in f)&&i in m){var _=y;P.add.push({op:"add",path:r(x),value:_})}else O!==y&&(Object(O)!==O||Object(y)!==y||wo(O,y)||!Object.keys(O).length&&!Object.keys(y).length&&String(O)!=String(y)?n(x,P,y):o({obj1:f[i],obj2:m[i],basePath:x,basePathForRemoves:v,diffs:P}))}function n(i,f,m){f.replace.push({op:"replace",path:r(i),value:m})}}function ee(t){return[""].concat(t).join("/")}function wo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function To(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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var Oo=typeof global=="object"&&global&&global.Object===Object&&global,ht=Oo;var jo=typeof self=="object"&&self&&self.Object===Object&&self,Po=ht||jo||Function("return this")(),g=Po;var So=g.Symbol,T=So;var re=Object.prototype,Ao=re.hasOwnProperty,Io=re.toString,mt=T?T.toStringTag:void 0;function _o(t){var e=Ao.call(t,mt),r=t[mt];try{t[mt]=void 0;var o=!0}catch{}var a=Io.call(t);return o&&(e?t[mt]=r:delete t[mt]),a}var oe=_o;var Eo=Object.prototype,Co=Eo.toString;function Fo(t){return Co.call(t)}var ae=Fo;var Mo="[object Null]",No="[object Undefined]",ie=T?T.toStringTag:void 0;function Ro(t){return t==null?t===void 0?No:Mo:ie&&ie in Object(t)?oe(t):ae(t)}var I=Ro;function Bo(t){return t!=null&&typeof t=="object"}var A=Bo;var Lo="[object Symbol]";function Do(t){return typeof t=="symbol"||A(t)&&I(t)==Lo}var G=Do;function Uo(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 se=Uo;var ko=Array.isArray,w=ko;var zo=1/0,ne=T?T.prototype:void 0,fe=ne?ne.toString:void 0;function pe(t){if(typeof t=="string")return t;if(w(t))return se(t,pe)+"";if(G(t))return fe?fe.call(t):"";var e=t+"";return e=="0"&&1/t==-zo?"-0":e}var le=pe;function Ko(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var S=Ko;function Go(t){return t}var me=Go;var Wo="[object AsyncFunction]",$o="[object Function]",Ho="[object GeneratorFunction]",qo="[object Proxy]";function Yo(t){if(!S(t))return!1;var e=I(t);return e==$o||e==Ho||e==Wo||e==qo}var xt=Yo;var Vo=g["__core-js_shared__"],gt=Vo;var ue=function(){var t=/[^.]+$/.exec(gt&>.keys&>.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Zo(t){return!!ue&&ue in t}var de=Zo;var Jo=Function.prototype,Xo=Jo.toString;function Qo(t){if(t!=null){try{return Xo.call(t)}catch{}try{return t+""}catch{}}return""}var C=Qo;var ta=/[\\^$.*+?()[\]{}|]/g,ea=/^\[object .+?Constructor\]$/,ra=Function.prototype,oa=Object.prototype,aa=ra.toString,ia=oa.hasOwnProperty,sa=RegExp("^"+aa.call(ia).replace(ta,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function na(t){if(!S(t)||de(t))return!1;var e=xt(t)?sa:ea;return e.test(C(t))}var ce=na;function fa(t,e){return t==null?void 0:t[e]}var he=fa;function pa(t,e){var r=he(t,e);return ce(r)?r:void 0}var j=pa;var la=j(g,"WeakMap"),yt=la;var xe=Object.create,ma=function(){function t(){}return function(e){if(!S(e))return{};if(xe)return xe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ge=ma;function ua(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 ye=ua;function da(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var be=da;var ca=800,ha=16,xa=Date.now;function ga(t){var e=0,r=0;return function(){var o=xa(),a=ha-(o-r);if(r=o,a>0){if(++e>=ca)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ve=ga;function ya(t){return function(){return t}}var we=ya;var ba=function(){try{var t=j(Object,"defineProperty");return t({},"",{}),t}catch{}}(),W=ba;var va=W?function(t,e){return W(t,"toString",{configurable:!0,enumerable:!1,value:we(e),writable:!0})}:me,Te=va;var wa=ve(Te),Oe=wa;function Ta(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var je=Ta;var Oa=9007199254740991,ja=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e==null?Oa:e,!!e&&(r=="number"||r!="symbol"&&ja.test(t))&&t>-1&&t%1==0&&t<e}var $=Pa;function Sa(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=Sa;function Aa(t,e){return t===e||t!==t&&e!==e}var vt=Aa;var Ia=Object.prototype,_a=Ia.hasOwnProperty;function Ea(t,e,r){var o=t[e];(!(_a.call(t,e)&&vt(o,r))||r===void 0&&!(e in t))&&bt(t,e,r)}var H=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?bt(r,i,f):H(r,i,f)}return r}var N=Ca;var Pe=Math.max;function Fa(t,e,r){return e=Pe(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=Pe(o.length-e,0),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),ye(t,this,i)}}var Se=Fa;var Ma=9007199254740991;function Na(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ma}var q=Na;function Ra(t){return t!=null&&q(t.length)&&!xt(t)}var wt=Ra;var Ba=Object.prototype;function La(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ba;return t===r}var Y=La;function Da(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ae=Da;var Ua="[object Arguments]";function ka(t){return A(t)&&I(t)==Ua}var Rt=ka;var Ie=Object.prototype,za=Ie.hasOwnProperty,Ka=Ie.propertyIsEnumerable,Ga=Rt(function(){return arguments}())?Rt:function(t){return A(t)&&za.call(t,"callee")&&!Ka.call(t,"callee")},V=Ga;function Wa(){return!1}var _e=Wa;var Fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=Fe&&typeof module=="object"&&module&&!module.nodeType&&module,$a=Ee&&Ee.exports===Fe,Ce=$a?g.Buffer:void 0,Ha=Ce?Ce.isBuffer:void 0,qa=Ha||_e,Tt=qa;var Ya="[object Arguments]",Va="[object Array]",Za="[object Boolean]",Ja="[object Date]",Xa="[object Error]",Qa="[object Function]",ti="[object Map]",ei="[object Number]",ri="[object Object]",oi="[object RegExp]",ai="[object Set]",ii="[object String]",si="[object WeakMap]",ni="[object ArrayBuffer]",fi="[object DataView]",pi="[object Float32Array]",li="[object Float64Array]",mi="[object Int8Array]",ui="[object Int16Array]",di="[object Int32Array]",ci="[object Uint8Array]",hi="[object Uint8ClampedArray]",xi="[object Uint16Array]",gi="[object Uint32Array]",h={};h[pi]=h[li]=h[mi]=h[ui]=h[di]=h[ci]=h[hi]=h[xi]=h[gi]=!0;h[Ya]=h[Va]=h[ni]=h[Za]=h[fi]=h[Ja]=h[Xa]=h[Qa]=h[ti]=h[ei]=h[ri]=h[oi]=h[ai]=h[ii]=h[si]=!1;function yi(t){return A(t)&&q(t.length)&&!!h[I(t)]}var Me=yi;function bi(t){return function(e){return t(e)}}var Z=bi;var Ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ut=Ne&&typeof module=="object"&&module&&!module.nodeType&&module,vi=ut&&ut.exports===Ne,Bt=vi&&ht.process,wi=function(){try{var t=ut&&ut.require&&ut.require("util").types;return t||Bt&&Bt.binding&&Bt.binding("util")}catch{}}(),F=wi;var Re=F&&F.isTypedArray,Ti=Re?Z(Re):Me,Be=Ti;var Oi=Object.prototype,ji=Oi.hasOwnProperty;function Pi(t,e){var r=w(t),o=!r&&V(t),a=!r&&!o&&Tt(t),s=!r&&!o&&!a&&Be(t),n=r||o||a||s,i=n?Ae(t.length,String):[],f=i.length;for(var m in t)(e||ji.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||$(m,f)))&&i.push(m);return i}var Ot=Pi;function Si(t,e){return function(r){return t(e(r))}}var jt=Si;var Ai=jt(Object.keys,Object),Le=Ai;var Ii=Object.prototype,_i=Ii.hasOwnProperty;function Ei(t){if(!Y(t))return Le(t);var e=[];for(var r in Object(t))_i.call(t,r)&&r!="constructor"&&e.push(r);return e}var De=Ei;function Ci(t){return wt(t)?Ot(t):De(t)}var J=Ci;function Fi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ue=Fi;var Mi=Object.prototype,Ni=Mi.hasOwnProperty;function Ri(t){if(!S(t))return Ue(t);var e=Y(t),r=[];for(var o in t)o=="constructor"&&(e||!Ni.call(t,o))||r.push(o);return r}var ke=Ri;function Bi(t){return wt(t)?Ot(t,!0):ke(t)}var X=Bi;var Li=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Di=/^\w*$/;function Ui(t,e){if(w(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||G(t)?!0:Di.test(t)||!Li.test(t)||e!=null&&t in Object(e)}var ze=Ui;var ki=j(Object,"create"),M=ki;function zi(){this.__data__=M?M(null):{},this.size=0}var Ke=zi;function Ki(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ge=Ki;var Gi="__lodash_hash_undefined__",Wi=Object.prototype,$i=Wi.hasOwnProperty;function Hi(t){var e=this.__data__;if(M){var r=e[t];return r===Gi?void 0:r}return $i.call(e,t)?e[t]:void 0}var We=Hi;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return M?e[t]!==void 0:Yi.call(e,t)}var $e=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?Zi:e,this}var He=Ji;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=Ke;Q.prototype.delete=Ge;Q.prototype.get=We;Q.prototype.has=$e;Q.prototype.set=He;var Lt=Q;function Xi(){this.__data__=[],this.size=0}var qe=Xi;function Qi(t,e){for(var r=t.length;r--;)if(vt(t[r][0],e))return r;return-1}var R=Qi;var ts=Array.prototype,es=ts.splice;function rs(t){var e=this.__data__,r=R(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():es.call(e,r,1),--this.size,!0}var Ye=rs;function os(t){var e=this.__data__,r=R(e,t);return r<0?void 0:e[r][1]}var Ve=os;function as(t){return R(this.__data__,t)>-1}var Ze=as;function is(t,e){var r=this.__data__,o=R(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Je=is;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=qe;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var B=tt;var ss=j(g,"Map"),L=ss;function ns(){this.size=0,this.__data__={hash:new Lt,map:new(L||B),string:new Lt}}var Xe=ns;function fs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Qe=fs;function ps(t,e){var r=t.__data__;return Qe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var D=ps;function ls(t){var e=D(this,t).delete(t);return this.size-=e?1:0,e}var tr=ls;function ms(t){return D(this,t).get(t)}var er=ms;function us(t){return D(this,t).has(t)}var rr=us;function ds(t,e){var r=D(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var or=ds;function et(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])}}et.prototype.clear=Xe;et.prototype.delete=tr;et.prototype.get=er;et.prototype.has=rr;et.prototype.set=or;var dt=et;var cs="Expected a function";function Dt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(cs);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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Dt.Cache||dt),r}Dt.Cache=dt;var ar=Dt;var hs=500;function xs(t){var e=ar(t,function(o){return r.size===hs&&r.clear(),o}),r=e.cache;return e}var ir=xs;var gs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ys=/\\(\\)?/g,bs=ir(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(gs,function(r,o,a,s){e.push(a?s.replace(ys,"$1"):o||r)}),e}),sr=bs;function vs(t){return t==null?"":le(t)}var nr=vs;function ws(t,e){return w(t)?t:ze(t,e)?[t]:sr(nr(t))}var U=ws;var Ts=1/0;function Os(t){if(typeof t=="string"||G(t))return t;var e=t+"";return e=="0"&&1/t==-Ts?"-0":e}var rt=Os;function js(t,e){e=U(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[rt(e[r++])];return r&&r==o?t:void 0}var fr=js;function Ps(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ot=Ps;var pr=T?T.isConcatSpreadable:void 0;function Ss(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=Ss;function mr(t,e,r,o,a){var s=-1,n=t.length;for(r||(r=lr),a||(a=[]);++s<n;){var i=t[s];e>0&&r(i)?e>1?mr(i,e-1,r,o,a):ot(a,i):o||(a[a.length]=i)}return a}var ur=mr;function As(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=As;function Is(t){return Oe(Se(t,void 0,dr),t+"")}var cr=Is;var _s=jt(Object.getPrototypeOf,Object),Pt=_s;function Es(){this.__data__=new B,this.size=0}var hr=Es;function Cs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var xr=Cs;function Fs(t){return this.__data__.get(t)}var gr=Fs;function Ms(t){return this.__data__.has(t)}var yr=Ms;var Ns=200;function Rs(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<Ns-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new dt(o)}return r.set(t,e),this.size=r.size,this}var br=Rs;function at(t){var e=this.__data__=new B(t);this.size=e.size}at.prototype.clear=hr;at.prototype.delete=xr;at.prototype.get=gr;at.prototype.has=yr;at.prototype.set=br;var vr=at;function Bs(t,e){return t&&N(e,J(e),t)}var wr=Bs;function Ls(t,e){return t&&N(e,X(e),t)}var Tr=Ls;var Sr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Or=Sr&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Or&&Or.exports===Sr,jr=Ds?g.Buffer:void 0,Pr=jr?jr.allocUnsafe:void 0;function Us(t,e){if(e)return t.slice();var r=t.length,o=Pr?Pr(r):new t.constructor(r);return t.copy(o),o}var Ar=Us;function ks(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var Ir=ks;function zs(){return[]}var St=zs;var Ks=Object.prototype,Gs=Ks.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,Ws=_r?function(t){return t==null?[]:(t=Object(t),Ir(_r(t),function(e){return Gs.call(t,e)}))}:St,it=Ws;function $s(t,e){return N(t,it(t),e)}var Er=$s;var Hs=Object.getOwnPropertySymbols,qs=Hs?function(t){for(var e=[];t;)ot(e,it(t)),t=Pt(t);return e}:St,At=qs;function Ys(t,e){return N(t,At(t),e)}var Cr=Ys;function Vs(t,e,r){var o=e(t);return w(t)?o:ot(o,r(t))}var It=Vs;function Zs(t){return It(t,J,it)}var Fr=Zs;function Js(t){return It(t,X,At)}var Mr=Js;var Xs=j(g,"DataView"),_t=Xs;var Qs=j(g,"Promise"),Et=Qs;var tn=j(g,"Set"),Ct=tn;var Nr="[object Map]",en="[object Object]",Rr="[object Promise]",Br="[object Set]",Lr="[object WeakMap]",Dr="[object DataView]",rn=C(_t),on=C(L),an=C(Et),sn=C(Ct),nn=C(yt),K=I;(_t&&K(new _t(new ArrayBuffer(1)))!=Dr||L&&K(new L)!=Nr||Et&&K(Et.resolve())!=Rr||Ct&&K(new Ct)!=Br||yt&&K(new yt)!=Lr)&&(K=function(t){var e=I(t),r=e==en?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case rn:return Dr;case on:return Nr;case an:return Rr;case sn:return Br;case nn:return Lr}return e});var st=K;var fn=Object.prototype,pn=fn.hasOwnProperty;function ln(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&pn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ur=ln;var mn=g.Uint8Array,Ut=mn;function un(t){var e=new t.constructor(t.byteLength);return new Ut(e).set(new Ut(t)),e}var nt=un;function dn(t,e){var r=e?nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var kr=dn;var cn=/\w*$/;function hn(t){var e=new t.constructor(t.source,cn.exec(t));return e.lastIndex=t.lastIndex,e}var zr=hn;var Kr=T?T.prototype:void 0,Gr=Kr?Kr.valueOf:void 0;function xn(t){return Gr?Object(Gr.call(t)):{}}var Wr=xn;function gn(t,e){var r=e?nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var $r=gn;var yn="[object Boolean]",bn="[object Date]",vn="[object Map]",wn="[object Number]",Tn="[object RegExp]",On="[object Set]",jn="[object String]",Pn="[object Symbol]",Sn="[object ArrayBuffer]",An="[object DataView]",In="[object Float32Array]",_n="[object Float64Array]",En="[object Int8Array]",Cn="[object Int16Array]",Fn="[object Int32Array]",Mn="[object Uint8Array]",Nn="[object Uint8ClampedArray]",Rn="[object Uint16Array]",Bn="[object Uint32Array]";function Ln(t,e,r){var o=t.constructor;switch(e){case Sn:return nt(t);case yn:case bn:return new o(+t);case An:return kr(t,r);case In:case _n:case En:case Cn:case Fn:case Mn:case Nn:case Rn:case Bn:return $r(t,r);case vn:return new o;case wn:case jn:return new o(t);case Tn:return zr(t);case On:return new o;case Pn:return Wr(t)}}var Hr=Ln;function Dn(t){return typeof t.constructor=="function"&&!Y(t)?ge(Pt(t)):{}}var qr=Dn;var Un="[object Map]";function kn(t){return A(t)&&st(t)==Un}var Yr=kn;var Vr=F&&F.isMap,zn=Vr?Z(Vr):Yr,Zr=zn;var Kn="[object Set]";function Gn(t){return A(t)&&st(t)==Kn}var Jr=Gn;var Xr=F&&F.isSet,Wn=Xr?Z(Xr):Jr,Qr=Wn;var $n=1,Hn=2,qn=4,to="[object Arguments]",Yn="[object Array]",Vn="[object Boolean]",Zn="[object Date]",Jn="[object Error]",eo="[object Function]",Xn="[object GeneratorFunction]",Qn="[object Map]",tf="[object Number]",ro="[object Object]",ef="[object RegExp]",rf="[object Set]",of="[object String]",af="[object Symbol]",sf="[object WeakMap]",nf="[object ArrayBuffer]",ff="[object DataView]",pf="[object Float32Array]",lf="[object Float64Array]",mf="[object Int8Array]",uf="[object Int16Array]",df="[object Int32Array]",cf="[object Uint8Array]",hf="[object Uint8ClampedArray]",xf="[object Uint16Array]",gf="[object Uint32Array]",d={};d[to]=d[Yn]=d[nf]=d[ff]=d[Vn]=d[Zn]=d[pf]=d[lf]=d[mf]=d[uf]=d[df]=d[Qn]=d[tf]=d[ro]=d[ef]=d[rf]=d[of]=d[af]=d[cf]=d[hf]=d[xf]=d[gf]=!0;d[Jn]=d[eo]=d[sf]=!1;function Ft(t,e,r,o,a,s){var n,i=e&$n,f=e&Hn,m=e&qn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!S(t))return t;var x=w(t);if(x){if(n=Ur(t),!i)return be(t,n)}else{var v=st(t),P=v==eo||v==Xn;if(Tt(t))return Ar(t,i);if(v==ro||v==to||P&&!a){if(n=f||P?{}:qr(t),!i)return f?Cr(t,Tr(n,t)):Er(t,wr(n,t))}else{if(!d[v])return a?t:{};n=Hr(t,v,i)}}s||(s=new vr);var O=s.get(t);if(O)return O;s.set(t,n),Qr(t)?t.forEach(function(b){n.add(Ft(b,e,r,b,t,s))}):Zr(t)&&t.forEach(function(b,p){n.set(p,Ft(b,e,r,p,t,s))});var y=m?f?Mr:Fr:f?X:J,_=x?void 0:y(t);return je(_||t,function(b,p){_&&(p=b,b=t[p]),H(n,p,Ft(b,e,r,p,t,s))}),n}var oo=Ft;var yf=1,bf=4;function vf(t){return oo(t,yf|bf)}var kt=vf;function wf(t,e){return t!=null&&e in Object(t)}var ao=wf;function Tf(t,e,r){e=U(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=rt(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&q(a)&&$(n,a)&&(w(t)||V(t)))}var io=Tf;function Of(t,e){return t!=null&&io(t,e,ao)}var so=Of;function jf(t,e,r,o){if(!S(t))return t;e=U(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=rt(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var x=i[f];m=o?o(x,f,i):void 0,m===void 0&&(m=S(x)?x:$(e[a+1])?[]:{})}H(i,f,m),i=i[f]}return t}var no=jf;function Pf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=fr(t,n);r(i,n)&&no(s,U(n,t),i)}return s}var fo=Pf;function Sf(t,e){return fo(t,e,function(r,o){return so(t,o)})}var po=Sf;var Af=cr(function(t,e){return t==null?{}:po(t,e)}),Mt=Af;function lo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var zt=(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 If="array",_f="bit",mo="bits",Ef="byte",uo="bytes",ft="",Cf="exponent",Ff="function",co="iec",Mf="Invalid number",Nf="Invalid rounding method",Kt="jedec",Rf="object",ho=".",Bf="round",Lf="s",Df="si",Uf="kbit",kf="kB",zf=" ",Kf="string",Gf="0",Gt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function xo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=ft,localeOptions:n={},separator:i=ft,spacer:f=zf,symbols:m={},standard:x=ft,output:v=Kf,fullform:P=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Bf,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Nt=ft;x===Df?(o=10,x=Kt):x===co||x===Kt?o=2:o===2?x=co:(o=10,x=Kt);let ct=o===10?1e3:1024,go=P===!0,Ht=u<0,qt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Mf);if(typeof qt!==Ff)throw new TypeError(Nf);if(Ht&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ct)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Cf)return p;if(u===0)l[0]=0,Nt=l[1]=Gt.symbol[x][e?mo:uo][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ct&&p<8&&(E=E/ct,p++));let pt=Math.pow(10,p>0?a:0);l[0]=qt(E*pt)/pt,l[0]===ct&&p<8&&y===-1&&(l[0]=1,p++),Nt=l[1]=o===10&&p===1?e?Uf:kf:Gt.symbol[x][e?mo:uo][p]}if(Ht&&(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,n):i.length>0&&(l[0]=l[0].toString().replace(ho,i)),r&&Number.isInteger(l[0])===!1&&a>0){let pt=i||ho,Yt=l[0].toString().split(pt),Vt=Yt[1]||ft,Zt=Vt.length,yo=a-Zt;l[0]=`${Yt[0]}${pt}${Vt.padEnd(Zt+yo,Gf)}`}return go&&(l[1]=O[p]?O[p]:Gt.fullform[x][p]+(e?_f:Ef)+(l[0]===1?ft:Lf)),v===If?l:v===Rf?{value:l[0],symbol:l[1],exponent:p,unit:Nt}:l.join(f)}var k,Wt=class Wt{constructor(e){Xt(this,k,void 0);c(this,"id");c(this,"name");c(this,"icon");c(this,"path");c(this,"url");c(this,"teraUrl");c(this,"parsedName");c(this,"created");c(this,"createdFormatted");c(this,"modified");c(this,"modifiedFormatted");c(this,"accessed");c(this,"accessedFormatted");c(this,"size");c(this,"sizeFormatted");c(this,"mime");c(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),delete this.tera,Qt(this,k,e.tera),this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),this.sizeFormatted=xo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return lt(this,k).getProjectFile(this.id)}setContents(e){return lt(this,k).setProjectFile(this.id,e)}getRefs(){return lt(this,k).getProjectLibrary(this.id)}setRefs(e){return lt(this,k).setProjectLibrary(this.id,e)}serialize(){return Mt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Mt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};k=new WeakMap;var z=Wt;var $t=class{constructor(e){c(this,"settings",{devMode:!0,verbosity:1,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});c(this,"events",lo());c(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});c(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","uiAlert","uiSplat","uiWindow"]);c(this,"plugins",[]);c(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=zt();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||zt(),...kt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);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("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=te(r,e,ee);return this.debug("INFO",3,"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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}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("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),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("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"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
|
-
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){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("INFO",2,"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
|
|
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 d=(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:f,basePath:m,basePathForRemoves:x,diffs:v}){var P=Object.keys(i),O=P.length,y=Object.keys(f),_=y.length,b,p=i.length-f.length;if(xo(i,f)){for(var u=0;u<O;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in f||(b=x.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<_;u++){var l=Array.isArray(f)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:f,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=x.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<_;u++)s({key:u,obj1:E,obj2:f,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:f,obj2:m,path:x,pathForRemoves:v,diffs:P}){var O=f[i],y=m[i];if(!(i in f)&&i in m){var _=y;P.add.push({op:"add",path:r(x),value:_})}else O!==y&&(Object(O)!==O||Object(y)!==y||ho(O,y)||!Object.keys(O).length&&!Object.keys(y).length&&String(O)!=String(y)?n(x,P,y):o({obj1:f[i],obj2:m[i],basePath:x,basePathForRemoves:v,diffs:P}))}function n(i,f,m){f.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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)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 Oo(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=Oo;var jo=Object.prototype,Po=jo.toString;function So(t){return Po.call(t)}var Xt=So;var Ao="[object Null]",Io="[object Undefined]",Qt=T?T.toStringTag:void 0;function _o(t){return t==null?t===void 0?Io:Ao:Qt&&Qt in Object(t)?Jt(t):Xt(t)}var I=_o;function Eo(t){return t!=null&&typeof t=="object"}var A=Eo;var Co="[object Symbol]";function Fo(t){return typeof t=="symbol"||A(t)&&I(t)==Co}var K=Fo;function Mo(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=Mo;var No=Array.isArray,w=No;var Ro=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==-Ro?"-0":e}var ae=oe;function Bo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var S=Bo;function Lo(t){return t}var ie=Lo;var Do="[object AsyncFunction]",Uo="[object Function]",ko="[object GeneratorFunction]",zo="[object Proxy]";function Ko(t){if(!S(t))return!1;var e=I(t);return e==Uo||e==ko||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 ne=Wo;var $o=Function.prototype,Ho=$o.toString;function qo(t){if(t!=null){try{return Ho.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(!S(t)||ne(t))return!1;var e=ct(t)?ta:Vo;return e.test(C(t))}var fe=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 fe(r)?r:void 0}var j=oa;var aa=j(g,"WeakMap"),xt=aa;var le=Object.create,ia=function(){function t(){}return function(e){if(!S(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 na(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var de=na;var fa=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>=fa)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=j(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,Oa=Ta.hasOwnProperty;function ja(t,e,r){var o=t[e];(!(Oa.call(t,e)&&yt(o,r))||r===void 0&&!(e in t))&>(t,e,r)}var $=ja;function Pa(t,e,r,o){var a=!r;r||(r={});for(var s=-1,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?gt(r,i,f):$(r,i,f)}return r}var N=Pa;var be=Math.max;function Sa(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),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),ue(t,this,i)}}var ve=Sa;var Aa=9007199254740991;function Ia(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Aa}var H=Ia;function _a(t){return t!=null&&H(t.length)&&!ct(t)}var bt=_a;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 Fa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var we=Fa;var Ma="[object Arguments]";function Na(t){return A(t)&&I(t)==Ma}var Mt=Na;var Te=Object.prototype,Ra=Te.hasOwnProperty,Ba=Te.propertyIsEnumerable,La=Mt(function(){return arguments}())?Mt:function(t){return A(t)&&Ra.call(t,"callee")&&!Ba.call(t,"callee")},Y=La;function Da(){return!1}var Oe=Da;var Se=typeof exports=="object"&&exports&&!exports.nodeType&&exports,je=Se&&typeof module=="object"&&module&&!module.nodeType&&module,Ua=je&&je.exports===Se,Pe=Ua?g.Buffer:void 0,ka=Pe?Pe.isBuffer:void 0,za=ka||Oe,vt=za;var Ka="[object Arguments]",Ga="[object Array]",Wa="[object Boolean]",$a="[object Date]",Ha="[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]",ni="[object Int32Array]",fi="[object Uint8Array]",pi="[object Uint8ClampedArray]",li="[object Uint16Array]",mi="[object Uint32Array]",h={};h[oi]=h[ai]=h[ii]=h[si]=h[ni]=h[fi]=h[pi]=h[li]=h[mi]=!0;h[Ka]=h[Ga]=h[ei]=h[Wa]=h[ri]=h[$a]=h[Ha]=h[qa]=h[Ya]=h[Va]=h[Za]=h[Ja]=h[Xa]=h[Qa]=h[ti]=!1;function ui(t){return A(t)&&H(t.length)&&!!h[I(t)]}var Ae=ui;function di(t){return function(e){return t(e)}}var V=di;var Ie=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lt=Ie&&typeof module=="object"&&module&&!module.nodeType&&module,ci=lt&<.exports===Ie,Nt=ci&&dt.process,hi=function(){try{var t=lt&<.require&<.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),F=hi;var _e=F&&F.isTypedArray,xi=_e?V(_e):Ae,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),n=r||o||a||s,i=n?we(t.length,String):[],f=i.length;for(var m in t)(e||yi.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||W(m,f)))&&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,Oi=Ti.hasOwnProperty;function ji(t){if(!q(t))return Ce(t);var e=[];for(var r in Object(t))Oi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Fe=ji;function Pi(t){return bt(t)?wt(t):Fe(t)}var Z=Pi;function Si(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Me=Si;var Ai=Object.prototype,Ii=Ai.hasOwnProperty;function _i(t){if(!S(t))return Me(t);var e=q(t),r=[];for(var o in t)o=="constructor"&&(e||!Ii.call(t,o))||r.push(o);return r}var Ne=_i;function Ei(t){return bt(t)?wt(t,!0):Ne(t)}var J=Ei;var Ci=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Fi=/^\w*$/;function Mi(t,e){if(w(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||K(t)?!0:Fi.test(t)||!Ci.test(t)||e!=null&&t in Object(e)}var Re=Mi;var Ni=j(Object,"create"),M=Ni;function Ri(){this.__data__=M?M(null):{},this.size=0}var Be=Ri;function Bi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Le=Bi;var Li="__lodash_hash_undefined__",Di=Object.prototype,Ui=Di.hasOwnProperty;function ki(t){var e=this.__data__;if(M){var r=e[t];return r===Li?void 0:r}return Ui.call(e,t)?e[t]:void 0}var De=ki;var zi=Object.prototype,Ki=zi.hasOwnProperty;function Gi(t){var e=this.__data__;return M?e[t]!==void 0:Ki.call(e,t)}var Ue=Gi;var Wi="__lodash_hash_undefined__";function $i(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?Wi:e,this}var ke=$i;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=Be;X.prototype.delete=Le;X.prototype.get=De;X.prototype.has=Ue;X.prototype.set=ke;var Rt=X;function Hi(){this.__data__=[],this.size=0}var ze=Hi;function qi(t,e){for(var r=t.length;r--;)if(yt(t[r][0],e))return r;return-1}var R=qi;var Yi=Array.prototype,Vi=Yi.splice;function Zi(t){var e=this.__data__,r=R(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=R(e,t);return r<0?void 0:e[r][1]}var Ge=Ji;function Xi(t){return R(this.__data__,t)>-1}var We=Xi;function Qi(t,e){var r=this.__data__,o=R(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var $e=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=$e;var B=Q;var ts=j(g,"Map"),L=ts;function es(){this.size=0,this.__data__={hash:new Rt,map:new(L||B),string:new Rt}}var He=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 ns(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=ns;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=He;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var mt=tt;var fs="Expected a function";function Bt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(fs);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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Bt.Cache||mt),r}Bt.Cache=mt;var Xe=Bt;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:Re(t,e)?[t]:tr(er(t))}var U=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=U(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,n=t.length;for(r||(r=ar),a||(a=[]);++s<n;){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 nr=ws;function Ts(t){return ge(ve(t,void 0,nr),t+"")}var fr=Ts;var Os=Tt(Object.getPrototypeOf,Object),Ot=Os;function js(){this.__data__=new B,this.size=0}var pr=js;function Ps(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var lr=Ps;function Ss(t){return this.__data__.get(t)}var mr=Ss;function As(t){return this.__data__.has(t)}var ur=As;var Is=200;function _s(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<Is-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=_s;function ot(t){var e=this.__data__=new B(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&&N(e,Z(e),t)}var hr=Es;function Cs(t,e){return t&&N(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,Fs=gr&&gr.exports===vr,yr=Fs?g.Buffer:void 0,br=yr?yr.allocUnsafe:void 0;function Ms(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=Ms;function Ns(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var Tr=Ns;function Rs(){return[]}var jt=Rs;var Bs=Object.prototype,Ls=Bs.propertyIsEnumerable,Or=Object.getOwnPropertySymbols,Ds=Or?function(t){return t==null?[]:(t=Object(t),Tr(Or(t),function(e){return Ls.call(t,e)}))}:jt,at=Ds;function Us(t,e){return N(t,at(t),e)}var jr=Us;var ks=Object.getOwnPropertySymbols,zs=ks?function(t){for(var e=[];t;)rt(e,at(t)),t=Ot(t);return e}:jt,Pt=zs;function Ks(t,e){return N(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 St=Gs;function Ws(t){return St(t,Z,at)}var Sr=Ws;function $s(t){return St(t,J,Pt)}var Ar=$s;var Hs=j(g,"DataView"),At=Hs;var qs=j(g,"Promise"),It=qs;var Ys=j(g,"Set"),_t=Ys;var Ir="[object Map]",Vs="[object Object]",_r="[object Promise]",Er="[object Set]",Cr="[object WeakMap]",Fr="[object DataView]",Zs=C(At),Js=C(L),Xs=C(It),Qs=C(_t),tn=C(xt),z=I;(At&&z(new At(new ArrayBuffer(1)))!=Fr||L&&z(new L)!=Ir||It&&z(It.resolve())!=_r||_t&&z(new _t)!=Er||xt&&z(new xt)!=Cr)&&(z=function(t){var e=I(t),r=e==Vs?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case Zs:return Fr;case Js:return Ir;case Xs:return _r;case Qs:return Er;case tn:return Cr}return e});var it=z;var en=Object.prototype,rn=en.hasOwnProperty;function on(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&rn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Mr=on;var an=g.Uint8Array,Lt=an;function sn(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var st=sn;function nn(t,e){var r=e?st(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Nr=nn;var fn=/\w*$/;function pn(t){var e=new t.constructor(t.source,fn.exec(t));return e.lastIndex=t.lastIndex,e}var Rr=pn;var Br=T?T.prototype:void 0,Lr=Br?Br.valueOf:void 0;function ln(t){return Lr?Object(Lr.call(t)):{}}var Dr=ln;function mn(t,e){var r=e?st(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Ur=mn;var un="[object Boolean]",dn="[object Date]",cn="[object Map]",hn="[object Number]",xn="[object RegExp]",gn="[object Set]",yn="[object String]",bn="[object Symbol]",vn="[object ArrayBuffer]",wn="[object DataView]",Tn="[object Float32Array]",On="[object Float64Array]",jn="[object Int8Array]",Pn="[object Int16Array]",Sn="[object Int32Array]",An="[object Uint8Array]",In="[object Uint8ClampedArray]",_n="[object Uint16Array]",En="[object Uint32Array]";function Cn(t,e,r){var o=t.constructor;switch(e){case vn:return st(t);case un:case dn:return new o(+t);case wn:return Nr(t,r);case Tn:case On:case jn:case Pn:case Sn:case An:case In:case _n:case En:return Ur(t,r);case cn:return new o;case hn:case yn:return new o(t);case xn:return Rr(t);case gn:return new o;case bn:return Dr(t)}}var kr=Cn;function Fn(t){return typeof t.constructor=="function"&&!q(t)?me(Ot(t)):{}}var zr=Fn;var Mn="[object Map]";function Nn(t){return A(t)&&it(t)==Mn}var Kr=Nn;var Gr=F&&F.isMap,Rn=Gr?V(Gr):Kr,Wr=Rn;var Bn="[object Set]";function Ln(t){return A(t)&&it(t)==Bn}var $r=Ln;var Hr=F&&F.isSet,Dn=Hr?V(Hr):$r,qr=Dn;var Un=1,kn=2,zn=4,Yr="[object Arguments]",Kn="[object Array]",Gn="[object Boolean]",Wn="[object Date]",$n="[object Error]",Vr="[object Function]",Hn="[object GeneratorFunction]",qn="[object Map]",Yn="[object Number]",Zr="[object Object]",Vn="[object RegExp]",Zn="[object Set]",Jn="[object String]",Xn="[object Symbol]",Qn="[object WeakMap]",tf="[object ArrayBuffer]",ef="[object DataView]",rf="[object Float32Array]",of="[object Float64Array]",af="[object Int8Array]",sf="[object Int16Array]",nf="[object Int32Array]",ff="[object Uint8Array]",pf="[object Uint8ClampedArray]",lf="[object Uint16Array]",mf="[object Uint32Array]",c={};c[Yr]=c[Kn]=c[tf]=c[ef]=c[Gn]=c[Wn]=c[rf]=c[of]=c[af]=c[sf]=c[nf]=c[qn]=c[Yn]=c[Zr]=c[Vn]=c[Zn]=c[Jn]=c[Xn]=c[ff]=c[pf]=c[lf]=c[mf]=!0;c[$n]=c[Vr]=c[Qn]=!1;function Et(t,e,r,o,a,s){var n,i=e&Un,f=e&kn,m=e&zn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!S(t))return t;var x=w(t);if(x){if(n=Mr(t),!i)return de(t,n)}else{var v=it(t),P=v==Vr||v==Hn;if(vt(t))return wr(t,i);if(v==Zr||v==Yr||P&&!a){if(n=f||P?{}:zr(t),!i)return f?Pr(t,xr(n,t)):jr(t,hr(n,t))}else{if(!c[v])return a?t:{};n=kr(t,v,i)}}s||(s=new cr);var O=s.get(t);if(O)return O;s.set(t,n),qr(t)?t.forEach(function(b){n.add(Et(b,e,r,b,t,s))}):Wr(t)&&t.forEach(function(b,p){n.set(p,Et(b,e,r,p,t,s))});var y=m?f?Ar:Sr:f?J:Z,_=x?void 0:y(t);return ye(_||t,function(b,p){_&&(p=b,b=t[p]),$(n,p,Et(b,e,r,p,t,s))}),n}var Jr=Et;var uf=1,df=4;function cf(t){return Jr(t,uf|df)}var Dt=cf;function hf(t,e){return t!=null&&e in Object(t)}var Xr=hf;function xf(t,e,r){e=U(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=et(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&H(a)&&W(n,a)&&(w(t)||Y(t)))}var Qr=xf;function gf(t,e){return t!=null&&Qr(t,e,Xr)}var to=gf;function yf(t,e,r,o){if(!S(t))return t;e=U(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=et(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var x=i[f];m=o?o(x,f,i):void 0,m===void 0&&(m=S(x)?x:W(e[a+1])?[]:{})}$(i,f,m),i=i[f]}return t}var eo=yf;function bf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=rr(t,n);r(i,n)&&eo(s,U(n,t),i)}return s}var ro=bf;function vf(t,e){return ro(t,e,function(r,o){return to(t,o)})}var oo=vf;var wf=fr(function(t,e){return t==null?{}:oo(t,e)}),Ct=wf;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 Ut=(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 Tf="array",Of="bit",io="bits",jf="byte",so="bytes",nt="",Pf="exponent",Sf="function",no="iec",Af="Invalid number",If="Invalid rounding method",kt="jedec",_f="object",fo=".",Ef="round",Cf="s",Ff="si",Mf="kbit",Nf="kB",Rf=" ",Bf="string",Lf="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=nt,localeOptions:n={},separator:i=nt,spacer:f=Rf,symbols:m={},standard:x=nt,output:v=Bf,fullform:P=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Ef,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Ft=nt;x===Ff?(o=10,x=kt):x===no||x===kt?o=2:o===2?x=no:(o=10,x=kt);let ut=o===10?1e3:1024,lo=P===!0,Gt=u<0,Wt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Af);if(typeof Wt!==Sf)throw new TypeError(If);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===Pf)return p;if(u===0)l[0]=0,Ft=l[1]=zt.symbol[x][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 ft=Math.pow(10,p>0?a:0);l[0]=Wt(E*ft)/ft,l[0]===ut&&p<8&&y===-1&&(l[0]=1,p++),Ft=l[1]=o===10&&p===1?e?Mf:Nf:zt.symbol[x][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,n):i.length>0&&(l[0]=l[0].toString().replace(fo,i)),r&&Number.isInteger(l[0])===!1&&a>0){let ft=i||fo,$t=l[0].toString().split(ft),Ht=$t[1]||nt,qt=Ht.length,mo=a-qt;l[0]=`${$t[0]}${ft}${Ht.padEnd(qt+mo,Lf)}`}return lo&&(l[1]=O[p]?O[p]:zt.fullform[x][p]+(e?Of:jf)+(l[0]===1?nt:Cf)),v===Tf?l:v===_f?{value:l[0],symbol:l[1],exponent:p,unit:Ft}:l.join(f)}var k=class t{constructor(e){d(this,"_tera");d(this,"id");d(this,"name");d(this,"icon");d(this,"path");d(this,"url");d(this,"teraUrl");d(this,"parsedName");d(this,"created");d(this,"createdFormatted");d(this,"modified");d(this,"modifiedFormatted");d(this,"accessed");d(this,"accessedFormatted");d(this,"size");d(this,"sizeFormatted");d(this,"mime");d(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),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.id)}setContents(e){return this._tera.setProjectFile(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Ct(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Ct(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var Kt=class{constructor(e){d(this,"settings",{devMode:!0,verbosity:1,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});d(this,"events",ao());d(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});d(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","uiAlert","uiSplat","uiWindow"]);d(this,"plugins",[]);d(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Ut();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||Ut(),...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",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);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("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=Yt(r,e,Vt);return this.debug("INFO",3,"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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}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("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),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("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"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
|
+
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){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("INFO",2,"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 k({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new k({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new k({tera:this,...r}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new k({tera:this,...r}))}};export{Kt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
lodash-es/lodash.js:
|
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:f,basePath:m,basePathForRemoves:h,diffs:b}){var j=Object.keys(i),T=j.length,g=Object.keys(f),I=g.length,y,p=i.length-f.length;if(uo(i,f)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(j[u]):j[u];l in f||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<I;u++){var l=Array.isArray(f)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:f,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.slice(p),u=0;u<I;u++)s({key:u,obj1:_,obj2:f,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:f,obj2:m,path:h,pathForRemoves:b,diffs:j}){var T=f[i],g=m[i];if(!(i in f)&&i in m){var I=g;j.add.push({op:"add",path:r(h),value:I})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?n(h,j,g):o({obj1:f[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:j}))}function n(i,f,m){f.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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)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,ft=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,ft),r=t[ft];try{t[ft]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[ft]=r:delete t[ft]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Oo(t){return To.call(t)}var Jt=Oo;var jo="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:jo:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var A=So;function Ao(t){return t!=null&&typeof t=="object"}var S=Ao;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||S(t)&&A(t)==Io}var z=_o;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 Fo=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==-Fo?"-0":e}var oe=re;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Mo;function No(t){return t}var ae=No;var Ro="[object AsyncFunction]",Bo="[object Function]",Lo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!P(t))return!1;var e=A(t);return e==Bo||e==Lo||e==Ro||e==Do}var dt=Uo;var ko=x["__core-js_shared__"],ct=ko;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 $o=/[\\^$.*+?()[\]{}|]/g,Ho=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace($o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!P(t)||se(t))return!1;var e=dt(t)?Jo:Ho;return e.test(E(t))}var ne=Xo;function Qo(t,e){return t?.[e]}var fe=Qo;function ta(t,e){var r=fe(t,e);return ne(r)?r:void 0}var O=ta;var ea=O(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,na=Date.now;function fa(t){var e=0,r=0;return function(){var o=na(),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=fa;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=O(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,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?xt(r,i,f):W(r,i,f)}return r}var M=Ta;var ye=Math.max;function Oa(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),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),me(t,this,i)}}var be=Oa;var ja=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ja}var $=Pa;function Sa(t){return t!=null&&$(t.length)&&!dt(t)}var yt=Sa;var Aa=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var H=Ia;function _a(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=_a;var Ea="[object Arguments]";function Ca(t){return S(t)&&A(t)==Ea}var Ft=Ca;var we=Object.prototype,Fa=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Na=Ft(function(){return arguments}())?Ft:function(t){return S(t)&&Fa.call(t,"callee")&&!Ma.call(t,"callee")},q=Na;function Ra(){return!1}var Te=Ra;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===Pe,je=Ba?x.Buffer:void 0,La=je?je.isBuffer:void 0,Da=La||Te,bt=Da;var Ua="[object Arguments]",ka="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",$a="[object Map]",Ha="[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]",ni="[object Uint16Array]",fi="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[ni]=c[fi]=!0;c[Ua]=c[ka]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[$a]=c[Ha]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return S(t)&&$(t.length)&&!!c[A(t)]}var Se=pi;function li(t){return function(e){return t(e)}}var Y=li;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===Ae,Mt=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch{}}(),C=ui;var Ie=C&&C.isTypedArray,di=Ie?Y(Ie):Se,_e=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&&_e(t),n=r||o||a||s,i=n?ve(t.length,String):[],f=i.length;for(var m in t)(e||hi.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,f)))&&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(!H(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 Oi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=Oi;var ji=Object.prototype,Pi=ji.hasOwnProperty;function Si(t){if(!P(t))return Fe(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Me=Si;function Ai(t){return yt(t)?vt(t,!0):Me(t)}var Z=Ai;var Ii=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\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:_i.test(t)||!Ii.test(t)||e!=null&&t in Object(e)}var Ne=Ei;var Ci=O(Object,"create"),F=Ci;function Fi(){this.__data__=F?F(null):{},this.size=0}var Re=Fi;function Mi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Mi;var Ni="__lodash_hash_undefined__",Ri=Object.prototype,Bi=Ri.hasOwnProperty;function Li(t){var e=this.__data__;if(F){var r=e[t];return r===Ni?void 0:r}return Bi.call(e,t)?e[t]:void 0}var Le=Li;var Di=Object.prototype,Ui=Di.hasOwnProperty;function ki(t){var e=this.__data__;return F?e[t]!==void 0:Ui.call(e,t)}var De=ki;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=F&&e===void 0?zi:e,this}var Ue=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=Re;J.prototype.delete=Be;J.prototype.get=Le;J.prototype.has=De;J.prototype.set=Ue;var Nt=J;function Gi(){this.__data__=[],this.size=0}var ke=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var N=Wi;var $i=Array.prototype,Hi=$i.splice;function qi(t){var e=this.__data__,r=N(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Hi.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=N(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return N(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=N(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=ke;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var R=X;var Ji=O(x,"Map"),B=Ji;function Xi(){this.size=0,this.__data__={hash:new Nt,map:new(B||R),string:new Nt}}var $e=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var He=Qi;function ts(t,e){var r=t.__data__;return He(e)?r[typeof e=="string"?"string":"hash"]:r.map}var L=ts;function es(t){var e=L(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return L(this,t).get(t)}var Ye=rs;function os(t){return L(this,t).has(t)}var Ve=os;function as(t,e){var r=L(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=$e;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 Rt(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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Rt.Cache||lt),r}Rt.Cache=lt;var Je=Rt;var ss=500;function ns(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=ns;var fs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(fs,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:Ne(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,n=t.length;for(r||(r=or),a||(a=[]);++s<n;){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 nr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new R,this.size=0}var fr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function Os(t){return this.__data__.get(t)}var lr=Os;function js(t){return this.__data__.has(t)}var mr=js;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof R){var o=r.__data__;if(!B||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=Ss;function rt(t){var e=this.__data__=new R(t);this.size=e.size}rt.prototype.clear=fr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function As(t,e){return t&&M(e,V(e),t)}var cr=As;function Is(t,e){return t&&M(e,Z(e),t)}var hr=Is;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,_s=xr&&xr.exports===br,gr=_s?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 n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var wr=Cs;function Fs(){return[]}var Ot=Fs;var Ms=Object.prototype,Ns=Ms.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Rs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Ns.call(t,e)}))}:Ot,ot=Rs;function Bs(t,e){return M(t,ot(t),e)}var Or=Bs;var Ls=Object.getOwnPropertySymbols,Ds=Ls?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:Ot,jt=Ds;function Us(t,e){return M(t,jt(t),e)}var jr=Us;function ks(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=ks;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,jt)}var Sr=Ks;var Gs=O(x,"DataView"),St=Gs;var Ws=O(x,"Promise"),At=Ws;var $s=O(x,"Set"),It=$s;var Ar="[object Map]",Hs="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(St),Ys=E(B),Vs=E(At),Zs=E(It),Js=E(ht),k=A;(St&&k(new St(new ArrayBuffer(1)))!=Cr||B&&k(new B)!=Ar||At&&k(At.resolve())!=Ir||It&&k(new It)!=_r||ht&&k(new ht)!=Er)&&(k=function(t){var e=A(t),r=e==Hs?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Ar;case Vs:return Ir;case Zs:return _r;case Js:return Er}return e});var at=k;var Xs=Object.prototype,Qs=Xs.hasOwnProperty;function tn(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 Fr=tn;var en=x.Uint8Array,Bt=en;function rn(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var it=rn;function on(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Mr=on;var an=/\w*$/;function sn(t){var e=new t.constructor(t.source,an.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=sn;var Rr=w?w.prototype:void 0,Br=Rr?Rr.valueOf:void 0;function nn(t){return Br?Object(Br.call(t)):{}}var Lr=nn;function fn(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=fn;var pn="[object Boolean]",ln="[object Date]",mn="[object Map]",un="[object Number]",dn="[object RegExp]",cn="[object Set]",hn="[object String]",xn="[object Symbol]",gn="[object ArrayBuffer]",yn="[object DataView]",bn="[object Float32Array]",vn="[object Float64Array]",wn="[object Int8Array]",Tn="[object Int16Array]",On="[object Int32Array]",jn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",Sn="[object Uint16Array]",An="[object Uint32Array]";function In(t,e,r){var o=t.constructor;switch(e){case gn:return it(t);case pn:case ln:return new o(+t);case yn:return Mr(t,r);case bn:case vn:case wn:case Tn:case On:case jn:case Pn:case Sn:case An:return Dr(t,r);case mn:return new o;case un:case hn:return new o(t);case dn:return Nr(t);case cn:return new o;case xn:return Lr(t)}}var Ur=In;function _n(t){return typeof t.constructor=="function"&&!H(t)?le(Tt(t)):{}}var kr=_n;var En="[object Map]";function Cn(t){return S(t)&&at(t)==En}var zr=Cn;var Kr=C&&C.isMap,Fn=Kr?Y(Kr):zr,Gr=Fn;var Mn="[object Set]";function Nn(t){return S(t)&&at(t)==Mn}var Wr=Nn;var $r=C&&C.isSet,Rn=$r?Y($r):Wr,Hr=Rn;var Bn=1,Ln=2,Dn=4,qr="[object Arguments]",Un="[object Array]",kn="[object Boolean]",zn="[object Date]",Kn="[object Error]",Yr="[object Function]",Gn="[object GeneratorFunction]",Wn="[object Map]",$n="[object Number]",Vr="[object Object]",Hn="[object RegExp]",qn="[object Set]",Yn="[object String]",Vn="[object Symbol]",Zn="[object WeakMap]",Jn="[object ArrayBuffer]",Xn="[object DataView]",Qn="[object Float32Array]",tf="[object Float64Array]",ef="[object Int8Array]",rf="[object Int16Array]",of="[object Int32Array]",af="[object Uint8Array]",sf="[object Uint8ClampedArray]",nf="[object Uint16Array]",ff="[object Uint32Array]",d={};d[qr]=d[Un]=d[Jn]=d[Xn]=d[kn]=d[zn]=d[Qn]=d[tf]=d[ef]=d[rf]=d[of]=d[Wn]=d[$n]=d[Vr]=d[Hn]=d[qn]=d[Yn]=d[Vn]=d[af]=d[sf]=d[nf]=d[ff]=!0;d[Kn]=d[Yr]=d[Zn]=!1;function _t(t,e,r,o,a,s){var n,i=e&Bn,f=e&Ln,m=e&Dn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!P(t))return t;var h=v(t);if(h){if(n=Fr(t),!i)return ue(t,n)}else{var b=at(t),j=b==Yr||b==Gn;if(bt(t))return vr(t,i);if(b==Vr||b==qr||j&&!a){if(n=f||j?{}:kr(t),!i)return f?jr(t,hr(n,t)):Or(t,cr(n,t))}else{if(!d[b])return a?t:{};n=Ur(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,n),Hr(t)?t.forEach(function(y){n.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){n.set(p,_t(y,e,r,p,t,s))});var g=m?f?Sr:Pr:f?Z:V,I=h?void 0:g(t);return ge(I||t,function(y,p){I&&(p=y,y=t[p]),W(n,p,_t(y,e,r,p,t,s))}),n}var Zr=_t;var pf=1,lf=4;function mf(t){return Zr(t,pf|lf)}var Lt=mf;function uf(t,e){return t!=null&&e in Object(t)}var Jr=uf;function df(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=tt(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&$(a)&&G(n,a)&&(v(t)||q(t)))}var Xr=df;function cf(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cf;function hf(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=tt(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var h=i[f];m=o?o(h,f,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,f,m),i=i[f]}return t}var to=hf;function xf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=er(t,n);r(i,n)&&to(s,D(n,t),i)}return s}var eo=xf;function gf(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gf;var yf=nr(function(t,e){return t==null?{}:ro(t,e)}),Et=yf;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 bf="array",vf="bit",ao="bits",wf="byte",io="bytes",st="",Tf="exponent",Of="function",so="iec",jf="Invalid number",Pf="Invalid rounding method",Ut="jedec",Sf="object",no=".",Af="round",If="s",_f="si",Ef="kbit",Cf="kB",Ff=" ",Mf="string",Nf="0",kt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:n={},separator:i=st,spacer:f=Ff,symbols:m={},standard:h=st,output:b=Mf,fullform:j=!1,fullforms:T=[],exponent:g=-1,roundingMethod:I=Af,precision:y=0}={}){let p=g,u=Number(t),l=[],_=0,Ct=st;h===_f?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=j===!0,Kt=u<0,Gt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(jf);if(typeof Gt!==Of)throw new TypeError(Pf);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===Tf)return p;if(u===0)l[0]=0,Ct=l[1]=kt.symbol[h][e?ao:io][p];else{_=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(_=_*8,_>=mt&&p<8&&(_=_/mt,p++));let nt=Math.pow(10,p>0?a:0);l[0]=Gt(_*nt)/nt,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?Ef:Cf:kt.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,n):i.length>0&&(l[0]=l[0].toString().replace(no,i)),r&&Number.isInteger(l[0])===!1&&a>0){let nt=i||no,Wt=l[0].toString().split(nt),$t=Wt[1]||st,Ht=$t.length,lo=a-Ht;l[0]=`${Wt[0]}${nt}${$t.padEnd(Ht+lo,Nf)}`}return po&&(l[1]=T[p]?T[p]:kt.fullform[h][p]+(e?vf:wf)+(l[0]===1?st:If)),b===bf?l:b===Sf?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(f)}var U=class t{#t;id;name;icon;path;url;teraUrl;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),delete this.tera,this.#t=e.tera,this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this.#t.getProjectFile(this.id)}setContents(e){return this.#t.setProjectFile(this.id,e)}getRefs(){return this.#t.getProjectLibrary(this.id)}setRefs(e){return this.#t.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,verbosity:1,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","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","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(),...Lt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);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("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=qt(r,e,Yt);return this.debug("INFO",3,"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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}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("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),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("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"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:f,basePath:m,basePathForRemoves:h,diffs:b}){var j=Object.keys(i),T=j.length,g=Object.keys(f),I=g.length,y,p=i.length-f.length;if(uo(i,f)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(j[u]):j[u];l in f||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<I;u++){var l=Array.isArray(f)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:f,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.slice(p),u=0;u<I;u++)s({key:u,obj1:_,obj2:f,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:f,obj2:m,path:h,pathForRemoves:b,diffs:j}){var T=f[i],g=m[i];if(!(i in f)&&i in m){var I=g;j.add.push({op:"add",path:r(h),value:I})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?n(h,j,g):o({obj1:f[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:j}))}function n(i,f,m){f.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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)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,ft=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,ft),r=t[ft];try{t[ft]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[ft]=r:delete t[ft]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Oo(t){return To.call(t)}var Jt=Oo;var jo="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:jo:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var A=So;function Ao(t){return t!=null&&typeof t=="object"}var S=Ao;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||S(t)&&A(t)==Io}var z=_o;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 Fo=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==-Fo?"-0":e}var oe=re;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Mo;function No(t){return t}var ae=No;var Ro="[object AsyncFunction]",Bo="[object Function]",Lo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!P(t))return!1;var e=A(t);return e==Bo||e==Lo||e==Ro||e==Do}var dt=Uo;var ko=x["__core-js_shared__"],ct=ko;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 $o=/[\\^$.*+?()[\]{}|]/g,Ho=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace($o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!P(t)||se(t))return!1;var e=dt(t)?Jo:Ho;return e.test(E(t))}var ne=Xo;function Qo(t,e){return t?.[e]}var fe=Qo;function ta(t,e){var r=fe(t,e);return ne(r)?r:void 0}var O=ta;var ea=O(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,na=Date.now;function fa(t){var e=0,r=0;return function(){var o=na(),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=fa;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=O(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,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?xt(r,i,f):W(r,i,f)}return r}var M=Ta;var ye=Math.max;function Oa(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),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),me(t,this,i)}}var be=Oa;var ja=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ja}var $=Pa;function Sa(t){return t!=null&&$(t.length)&&!dt(t)}var yt=Sa;var Aa=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var H=Ia;function _a(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=_a;var Ea="[object Arguments]";function Ca(t){return S(t)&&A(t)==Ea}var Ft=Ca;var we=Object.prototype,Fa=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Na=Ft(function(){return arguments}())?Ft:function(t){return S(t)&&Fa.call(t,"callee")&&!Ma.call(t,"callee")},q=Na;function Ra(){return!1}var Te=Ra;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===Pe,je=Ba?x.Buffer:void 0,La=je?je.isBuffer:void 0,Da=La||Te,bt=Da;var Ua="[object Arguments]",ka="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",$a="[object Map]",Ha="[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]",ni="[object Uint16Array]",fi="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[ni]=c[fi]=!0;c[Ua]=c[ka]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[$a]=c[Ha]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return S(t)&&$(t.length)&&!!c[A(t)]}var Se=pi;function li(t){return function(e){return t(e)}}var Y=li;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===Ae,Mt=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch{}}(),C=ui;var Ie=C&&C.isTypedArray,di=Ie?Y(Ie):Se,_e=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&&_e(t),n=r||o||a||s,i=n?ve(t.length,String):[],f=i.length;for(var m in t)(e||hi.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,f)))&&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(!H(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 Oi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=Oi;var ji=Object.prototype,Pi=ji.hasOwnProperty;function Si(t){if(!P(t))return Fe(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Me=Si;function Ai(t){return yt(t)?vt(t,!0):Me(t)}var Z=Ai;var Ii=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\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:_i.test(t)||!Ii.test(t)||e!=null&&t in Object(e)}var Ne=Ei;var Ci=O(Object,"create"),F=Ci;function Fi(){this.__data__=F?F(null):{},this.size=0}var Re=Fi;function Mi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Mi;var Ni="__lodash_hash_undefined__",Ri=Object.prototype,Bi=Ri.hasOwnProperty;function Li(t){var e=this.__data__;if(F){var r=e[t];return r===Ni?void 0:r}return Bi.call(e,t)?e[t]:void 0}var Le=Li;var Di=Object.prototype,Ui=Di.hasOwnProperty;function ki(t){var e=this.__data__;return F?e[t]!==void 0:Ui.call(e,t)}var De=ki;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=F&&e===void 0?zi:e,this}var Ue=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=Re;J.prototype.delete=Be;J.prototype.get=Le;J.prototype.has=De;J.prototype.set=Ue;var Nt=J;function Gi(){this.__data__=[],this.size=0}var ke=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var N=Wi;var $i=Array.prototype,Hi=$i.splice;function qi(t){var e=this.__data__,r=N(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Hi.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=N(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return N(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=N(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=ke;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var R=X;var Ji=O(x,"Map"),B=Ji;function Xi(){this.size=0,this.__data__={hash:new Nt,map:new(B||R),string:new Nt}}var $e=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var He=Qi;function ts(t,e){var r=t.__data__;return He(e)?r[typeof e=="string"?"string":"hash"]:r.map}var L=ts;function es(t){var e=L(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return L(this,t).get(t)}var Ye=rs;function os(t){return L(this,t).has(t)}var Ve=os;function as(t,e){var r=L(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=$e;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 Rt(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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Rt.Cache||lt),r}Rt.Cache=lt;var Je=Rt;var ss=500;function ns(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=ns;var fs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(fs,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:Ne(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,n=t.length;for(r||(r=or),a||(a=[]);++s<n;){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 nr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new R,this.size=0}var fr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function Os(t){return this.__data__.get(t)}var lr=Os;function js(t){return this.__data__.has(t)}var mr=js;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof R){var o=r.__data__;if(!B||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=Ss;function rt(t){var e=this.__data__=new R(t);this.size=e.size}rt.prototype.clear=fr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function As(t,e){return t&&M(e,V(e),t)}var cr=As;function Is(t,e){return t&&M(e,Z(e),t)}var hr=Is;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,_s=xr&&xr.exports===br,gr=_s?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 n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var wr=Cs;function Fs(){return[]}var Ot=Fs;var Ms=Object.prototype,Ns=Ms.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Rs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Ns.call(t,e)}))}:Ot,ot=Rs;function Bs(t,e){return M(t,ot(t),e)}var Or=Bs;var Ls=Object.getOwnPropertySymbols,Ds=Ls?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:Ot,jt=Ds;function Us(t,e){return M(t,jt(t),e)}var jr=Us;function ks(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=ks;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,jt)}var Sr=Ks;var Gs=O(x,"DataView"),St=Gs;var Ws=O(x,"Promise"),At=Ws;var $s=O(x,"Set"),It=$s;var Ar="[object Map]",Hs="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(St),Ys=E(B),Vs=E(At),Zs=E(It),Js=E(ht),k=A;(St&&k(new St(new ArrayBuffer(1)))!=Cr||B&&k(new B)!=Ar||At&&k(At.resolve())!=Ir||It&&k(new It)!=_r||ht&&k(new ht)!=Er)&&(k=function(t){var e=A(t),r=e==Hs?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Ar;case Vs:return Ir;case Zs:return _r;case Js:return Er}return e});var at=k;var Xs=Object.prototype,Qs=Xs.hasOwnProperty;function tn(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 Fr=tn;var en=x.Uint8Array,Bt=en;function rn(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var it=rn;function on(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Mr=on;var an=/\w*$/;function sn(t){var e=new t.constructor(t.source,an.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=sn;var Rr=w?w.prototype:void 0,Br=Rr?Rr.valueOf:void 0;function nn(t){return Br?Object(Br.call(t)):{}}var Lr=nn;function fn(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=fn;var pn="[object Boolean]",ln="[object Date]",mn="[object Map]",un="[object Number]",dn="[object RegExp]",cn="[object Set]",hn="[object String]",xn="[object Symbol]",gn="[object ArrayBuffer]",yn="[object DataView]",bn="[object Float32Array]",vn="[object Float64Array]",wn="[object Int8Array]",Tn="[object Int16Array]",On="[object Int32Array]",jn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",Sn="[object Uint16Array]",An="[object Uint32Array]";function In(t,e,r){var o=t.constructor;switch(e){case gn:return it(t);case pn:case ln:return new o(+t);case yn:return Mr(t,r);case bn:case vn:case wn:case Tn:case On:case jn:case Pn:case Sn:case An:return Dr(t,r);case mn:return new o;case un:case hn:return new o(t);case dn:return Nr(t);case cn:return new o;case xn:return Lr(t)}}var Ur=In;function _n(t){return typeof t.constructor=="function"&&!H(t)?le(Tt(t)):{}}var kr=_n;var En="[object Map]";function Cn(t){return S(t)&&at(t)==En}var zr=Cn;var Kr=C&&C.isMap,Fn=Kr?Y(Kr):zr,Gr=Fn;var Mn="[object Set]";function Nn(t){return S(t)&&at(t)==Mn}var Wr=Nn;var $r=C&&C.isSet,Rn=$r?Y($r):Wr,Hr=Rn;var Bn=1,Ln=2,Dn=4,qr="[object Arguments]",Un="[object Array]",kn="[object Boolean]",zn="[object Date]",Kn="[object Error]",Yr="[object Function]",Gn="[object GeneratorFunction]",Wn="[object Map]",$n="[object Number]",Vr="[object Object]",Hn="[object RegExp]",qn="[object Set]",Yn="[object String]",Vn="[object Symbol]",Zn="[object WeakMap]",Jn="[object ArrayBuffer]",Xn="[object DataView]",Qn="[object Float32Array]",tf="[object Float64Array]",ef="[object Int8Array]",rf="[object Int16Array]",of="[object Int32Array]",af="[object Uint8Array]",sf="[object Uint8ClampedArray]",nf="[object Uint16Array]",ff="[object Uint32Array]",d={};d[qr]=d[Un]=d[Jn]=d[Xn]=d[kn]=d[zn]=d[Qn]=d[tf]=d[ef]=d[rf]=d[of]=d[Wn]=d[$n]=d[Vr]=d[Hn]=d[qn]=d[Yn]=d[Vn]=d[af]=d[sf]=d[nf]=d[ff]=!0;d[Kn]=d[Yr]=d[Zn]=!1;function _t(t,e,r,o,a,s){var n,i=e&Bn,f=e&Ln,m=e&Dn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!P(t))return t;var h=v(t);if(h){if(n=Fr(t),!i)return ue(t,n)}else{var b=at(t),j=b==Yr||b==Gn;if(bt(t))return vr(t,i);if(b==Vr||b==qr||j&&!a){if(n=f||j?{}:kr(t),!i)return f?jr(t,hr(n,t)):Or(t,cr(n,t))}else{if(!d[b])return a?t:{};n=Ur(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,n),Hr(t)?t.forEach(function(y){n.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){n.set(p,_t(y,e,r,p,t,s))});var g=m?f?Sr:Pr:f?Z:V,I=h?void 0:g(t);return ge(I||t,function(y,p){I&&(p=y,y=t[p]),W(n,p,_t(y,e,r,p,t,s))}),n}var Zr=_t;var pf=1,lf=4;function mf(t){return Zr(t,pf|lf)}var Lt=mf;function uf(t,e){return t!=null&&e in Object(t)}var Jr=uf;function df(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=tt(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&$(a)&&G(n,a)&&(v(t)||q(t)))}var Xr=df;function cf(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cf;function hf(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=tt(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var h=i[f];m=o?o(h,f,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,f,m),i=i[f]}return t}var to=hf;function xf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=er(t,n);r(i,n)&&to(s,D(n,t),i)}return s}var eo=xf;function gf(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gf;var yf=nr(function(t,e){return t==null?{}:ro(t,e)}),Et=yf;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 bf="array",vf="bit",ao="bits",wf="byte",io="bytes",st="",Tf="exponent",Of="function",so="iec",jf="Invalid number",Pf="Invalid rounding method",Ut="jedec",Sf="object",no=".",Af="round",If="s",_f="si",Ef="kbit",Cf="kB",Ff=" ",Mf="string",Nf="0",kt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:n={},separator:i=st,spacer:f=Ff,symbols:m={},standard:h=st,output:b=Mf,fullform:j=!1,fullforms:T=[],exponent:g=-1,roundingMethod:I=Af,precision:y=0}={}){let p=g,u=Number(t),l=[],_=0,Ct=st;h===_f?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=j===!0,Kt=u<0,Gt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(jf);if(typeof Gt!==Of)throw new TypeError(Pf);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===Tf)return p;if(u===0)l[0]=0,Ct=l[1]=kt.symbol[h][e?ao:io][p];else{_=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(_=_*8,_>=mt&&p<8&&(_=_/mt,p++));let nt=Math.pow(10,p>0?a:0);l[0]=Gt(_*nt)/nt,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?Ef:Cf:kt.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,n):i.length>0&&(l[0]=l[0].toString().replace(no,i)),r&&Number.isInteger(l[0])===!1&&a>0){let nt=i||no,Wt=l[0].toString().split(nt),$t=Wt[1]||st,Ht=$t.length,lo=a-Ht;l[0]=`${Wt[0]}${nt}${$t.padEnd(Ht+lo,Nf)}`}return po&&(l[1]=T[p]?T[p]:kt.fullform[h][p]+(e?vf:wf)+(l[0]===1?st:If)),b===bf?l:b===Sf?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(f)}var U=class t{_tera;id;name;icon;path;url;teraUrl;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);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this._tera.getProjectFile(this.id)}setContents(e){return this._tera.setProjectFile(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,verbosity:1,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","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","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(),...Lt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);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("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=qt(r,e,Yt);return this.debug("INFO",3,"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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}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("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),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("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"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){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){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("INFO",2,"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}))}createProjectFile(e){return this.rpc("createProjectFile",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
|
@@ -9,9 +9,10 @@ export default class ProjectFile {
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Parent TeraClient instance used by all helper functions
|
|
12
|
-
* @
|
|
12
|
+
* @type {TeraClient}
|
|
13
|
+
* @private
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
_tera;
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -149,8 +150,18 @@ export default class ProjectFile {
|
|
|
149
150
|
constructor(baseFile) {
|
|
150
151
|
if (!baseFile.tera) throw new Error('Basic file requires a `tera` key to access the Tera instance');
|
|
151
152
|
Object.assign(this, baseFile);
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
|
|
154
|
+
// Translate baseFile.tera -> this._tera (non-enumerable, non-configurable)
|
|
155
|
+
const tera = this.tera;
|
|
156
|
+
Object.defineProperty(this, '_tera', {
|
|
157
|
+
enumerable: false,
|
|
158
|
+
configurable: false,
|
|
159
|
+
get() {
|
|
160
|
+
// NOTE: We can't just set {value:tera} as it upsets how Vue uses proxies
|
|
161
|
+
return tera;
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
delete this.tera; // Remove original ref we merged above
|
|
154
165
|
|
|
155
166
|
// Calculate `teraUrl` from URL
|
|
156
167
|
this.teraUrl = this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/, '/project/$1');
|
|
@@ -171,7 +182,7 @@ export default class ProjectFile {
|
|
|
171
182
|
* @see getProjectFile()
|
|
172
183
|
*/
|
|
173
184
|
getContents() {
|
|
174
|
-
return this
|
|
185
|
+
return this._tera.getProjectFile(this.id);
|
|
175
186
|
}
|
|
176
187
|
|
|
177
188
|
|
|
@@ -185,7 +196,7 @@ export default class ProjectFile {
|
|
|
185
196
|
* @see setProjectFile()
|
|
186
197
|
*/
|
|
187
198
|
setContents(contents) {
|
|
188
|
-
return this
|
|
199
|
+
return this._tera.setProjectFile(this.id, contents);
|
|
189
200
|
}
|
|
190
201
|
|
|
191
202
|
|
|
@@ -197,7 +208,7 @@ export default class ProjectFile {
|
|
|
197
208
|
* @see getProjectLibrary()
|
|
198
209
|
*/
|
|
199
210
|
getRefs() {
|
|
200
|
-
return this
|
|
211
|
+
return this._tera.getProjectLibrary(this.id);
|
|
201
212
|
}
|
|
202
213
|
|
|
203
214
|
|
|
@@ -211,7 +222,7 @@ export default class ProjectFile {
|
|
|
211
222
|
* @see setProjectLibrary()
|
|
212
223
|
*/
|
|
213
224
|
setRefs(refs) {
|
|
214
|
-
return this
|
|
225
|
+
return this._tera.setProjectLibrary(this.id, refs);
|
|
215
226
|
}
|
|
216
227
|
|
|
217
228
|
|
package/lib/terafy.server.js
CHANGED
|
@@ -968,6 +968,7 @@ export default class TeraFyServer {
|
|
|
968
968
|
*
|
|
969
969
|
* @param {Object} options Options which mutate behaviour
|
|
970
970
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
971
|
+
* @param {Boolean} [options.lazy=true] If true, use the fastest method to retrieve the file list such as the cache. If false, force a refresh each time
|
|
971
972
|
* @param {Boolean} [options.meta=true] Pull meta information for each file entity
|
|
972
973
|
*
|
|
973
974
|
* @returns {Promise<Array<ProjectFile>>} A collection of project files for the given project
|
|
@@ -975,6 +976,7 @@ export default class TeraFyServer {
|
|
|
975
976
|
getProjectFiles(options) {
|
|
976
977
|
let settings = {
|
|
977
978
|
autoRequire: true,
|
|
979
|
+
lazy: true,
|
|
978
980
|
meta: true,
|
|
979
981
|
...options,
|
|
980
982
|
};
|
|
@@ -982,9 +984,14 @@ export default class TeraFyServer {
|
|
|
982
984
|
return Promise.resolve()
|
|
983
985
|
.then(()=> app.service('$projects').promise())
|
|
984
986
|
.then(()=> settings.autoRequire && this.requireProject())
|
|
985
|
-
.then(
|
|
986
|
-
|
|
987
|
-
|
|
987
|
+
.then(()=>
|
|
988
|
+
app.service('$projects').activeFiles.length == 0 // If we have no files in the cache
|
|
989
|
+
|| !settings.lazy // OR lazy/cache use is disabled
|
|
990
|
+
? app.service('$projects').refreshFiles({ // Go refresh files first
|
|
991
|
+
lazy: false,
|
|
992
|
+
})
|
|
993
|
+
: app.service('$projects').activeFiles // Otherwise use file cache
|
|
994
|
+
)
|
|
988
995
|
}
|
|
989
996
|
|
|
990
997
|
|
package/package.json
CHANGED
package/plugins/vue3.js
CHANGED
|
@@ -166,7 +166,7 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
|
|
|
166
166
|
.then(projects => $tera.projects = reactive(projects))
|
|
167
167
|
.then(()=> $tera.debug('INFO', 2, 'Loaded project list', $tera.projects)),
|
|
168
168
|
]))
|
|
169
|
-
.then(()=>
|
|
169
|
+
.then(()=> $tera.debug('INFO', 1, 'Ready'))
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
// Make this module available globally
|