@iebh/tera-fy 2.0.21 → 2.2.0

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/api.md +68 -66
  3. package/dist/lib/projectFile.d.ts +182 -0
  4. package/dist/lib/projectFile.js +157 -0
  5. package/dist/lib/projectFile.js.map +1 -0
  6. package/dist/lib/syncro/entities.d.ts +28 -0
  7. package/dist/lib/syncro/entities.js +203 -0
  8. package/dist/lib/syncro/entities.js.map +1 -0
  9. package/dist/lib/syncro/keyed.d.ts +95 -0
  10. package/dist/lib/syncro/keyed.js +286 -0
  11. package/dist/lib/syncro/keyed.js.map +1 -0
  12. package/dist/lib/syncro/syncro.d.ts +328 -0
  13. package/dist/lib/syncro/syncro.js +633 -0
  14. package/dist/lib/syncro/syncro.js.map +1 -0
  15. package/dist/lib/terafy.bootstrapper.d.ts +42 -0
  16. package/dist/lib/terafy.bootstrapper.js +130 -0
  17. package/dist/lib/terafy.bootstrapper.js.map +1 -0
  18. package/dist/lib/terafy.client.d.ts +532 -0
  19. package/dist/lib/terafy.client.js +1110 -0
  20. package/dist/lib/terafy.client.js.map +1 -0
  21. package/dist/lib/terafy.proxy.d.ts +66 -0
  22. package/dist/lib/terafy.proxy.js +123 -0
  23. package/dist/lib/terafy.proxy.js.map +1 -0
  24. package/dist/lib/terafy.server.d.ts +607 -0
  25. package/dist/lib/terafy.server.js +1774 -0
  26. package/dist/lib/terafy.server.js.map +1 -0
  27. package/dist/plugin.vue2.es2019.js +30 -13
  28. package/dist/plugins/base.d.ts +20 -0
  29. package/dist/plugins/base.js +21 -0
  30. package/dist/plugins/base.js.map +1 -0
  31. package/dist/plugins/firebase.d.ts +62 -0
  32. package/dist/plugins/firebase.js +111 -0
  33. package/dist/plugins/firebase.js.map +1 -0
  34. package/dist/plugins/vite.d.ts +12 -0
  35. package/dist/plugins/vite.js +22 -0
  36. package/dist/plugins/vite.js.map +1 -0
  37. package/dist/plugins/vue2.d.ts +68 -0
  38. package/dist/plugins/vue2.js +96 -0
  39. package/dist/plugins/vue2.js.map +1 -0
  40. package/dist/plugins/vue3.d.ts +64 -0
  41. package/dist/plugins/vue3.js +96 -0
  42. package/dist/plugins/vue3.js.map +1 -0
  43. package/dist/terafy.bootstrapper.es2019.js +2 -2
  44. package/dist/terafy.bootstrapper.js +2 -2
  45. package/dist/terafy.es2019.js +2 -2
  46. package/dist/terafy.js +1 -1
  47. package/dist/utils/mixin.d.ts +11 -0
  48. package/dist/utils/mixin.js +15 -0
  49. package/dist/utils/mixin.js.map +1 -0
  50. package/dist/utils/pDefer.d.ts +12 -0
  51. package/dist/utils/pDefer.js +14 -0
  52. package/dist/utils/pDefer.js.map +1 -0
  53. package/dist/utils/pathTools.d.ts +70 -0
  54. package/dist/utils/pathTools.js +120 -0
  55. package/dist/utils/pathTools.js.map +1 -0
  56. package/eslint.config.js +44 -8
  57. package/lib/{projectFile.js → projectFile.ts} +83 -40
  58. package/lib/syncro/entities.ts +288 -0
  59. package/lib/syncro/{keyed.js → keyed.ts} +114 -57
  60. package/lib/syncro/{syncro.js → syncro.ts} +204 -169
  61. package/lib/{terafy.bootstrapper.js → terafy.bootstrapper.ts} +49 -31
  62. package/lib/{terafy.client.js → terafy.client.ts} +94 -86
  63. package/lib/{terafy.proxy.js → terafy.proxy.ts} +43 -16
  64. package/lib/{terafy.server.js → terafy.server.ts} +364 -223
  65. package/package.json +65 -26
  66. package/plugins/{base.js → base.ts} +3 -1
  67. package/plugins/{firebase.js → firebase.ts} +34 -16
  68. package/plugins/{vite.js → vite.ts} +3 -3
  69. package/plugins/{vue2.js → vue2.ts} +17 -10
  70. package/plugins/{vue3.js → vue3.ts} +11 -9
  71. package/tsconfig.json +30 -0
  72. package/utils/{mixin.js → mixin.ts} +1 -1
  73. package/utils/{pDefer.js → pDefer.ts} +10 -3
  74. package/utils/{pathTools.js → pathTools.ts} +11 -9
  75. package/lib/syncro/entities.js +0 -232
@@ -1,7 +1,7 @@
1
- var Pe=Object.defineProperty;var Ee=(t,e,r)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Z=(t,e,r)=>Ee(t,typeof e!="symbol"?e+"":e,r);var Me=typeof global=="object"&&global&&global.Object===Object&&global,N=Me;var De=typeof self=="object"&&self&&self.Object===Object&&self,Re=N||De||Function("return this")(),d=Re;var Be=d.Symbol,_=Be;var st=Object.prototype,Le=st.hasOwnProperty,Fe=st.toString,M=_?_.toStringTag:void 0;function Ne(t){var e=Le.call(t,M),r=t[M];try{t[M]=void 0;var o=!0}catch{}var a=Fe.call(t);return o&&(e?t[M]=r:delete t[M]),a}var pt=Ne;var ze=Object.prototype,We=ze.toString;function Ue(t){return We.call(t)}var it=Ue;var Ge="[object Null]",He="[object Undefined]",nt=_?_.toStringTag:void 0;function qe(t){return t==null?t===void 0?He:Ge:nt&&nt in Object(t)?pt(t):it(t)}var h=qe;function $e(t){return t!=null&&typeof t=="object"}var x=$e;var Ke=Array.isArray,D=Ke;function Ve(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var u=Ve;function ke(t){return t}var z=ke;var Ye="[object AsyncFunction]",Je="[object Function]",Xe="[object GeneratorFunction]",Ze="[object Proxy]";function Qe(t){if(!u(t))return!1;var e=h(t);return e==Je||e==Xe||e==Ye||e==Ze}var O=Qe;var tr=d["__core-js_shared__"],W=tr;var ut=function(){var t=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function er(t){return!!ut&&ut in t}var lt=er;var rr=Function.prototype,or=rr.toString;function ar(t){if(t!=null){try{return or.call(t)}catch{}try{return t+""}catch{}}return""}var mt=ar;var fr=/[\\^$.*+?()[\]{}|]/g,sr=/^\[object .+?Constructor\]$/,pr=Function.prototype,ir=Object.prototype,nr=pr.toString,ur=ir.hasOwnProperty,lr=RegExp("^"+nr.call(ur).replace(fr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function mr(t){if(!u(t)||lt(t))return!1;var e=O(t)?lr:sr;return e.test(mt(t))}var dt=mr;function dr(t,e){return t==null?void 0:t[e]}var xt=dr;function xr(t,e){var r=xt(t,e);return dt(r)?r:void 0}var T=xr;var ct=Object.create,cr=function(){function t(){}return function(e){if(!u(e))return{};if(ct)return ct(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ht=cr;function hr(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 gt=hr;function gr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var yt=gr;var yr=800,br=16,vr=Date.now;function _r(t){var e=0,r=0;return function(){var o=vr(),a=br-(o-r);if(r=o,a>0){if(++e>=yr)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var bt=_r;function Or(t){return function(){return t}}var vt=Or;var Tr=function(){try{var t=T(Object,"defineProperty");return t({},"",{}),t}catch{}}(),j=Tr;var jr=j?function(t,e){return j(t,"toString",{configurable:!0,enumerable:!1,value:vt(e),writable:!0})}:z,_t=jr;var wr=bt(_t),Ot=wr;var Ar=9007199254740991,Ir=/^(?:0|[1-9]\d*)$/;function Sr(t,e){var r=typeof t;return e=e==null?Ar:e,!!e&&(r=="number"||r!="symbol"&&Ir.test(t))&&t>-1&&t%1==0&&t<e}var U=Sr;function Cr(t,e,r){e=="__proto__"&&j?j(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var w=Cr;function Pr(t,e){return t===e||t!==t&&e!==e}var g=Pr;var Er=Object.prototype,Mr=Er.hasOwnProperty;function Dr(t,e,r){var o=t[e];(!(Mr.call(t,e)&&g(o,r))||r===void 0&&!(e in t))&&w(t,e,r)}var Tt=Dr;function Rr(t,e,r,o){var a=!r;r||(r={});for(var s=-1,p=e.length;++s<p;){var f=e[s],n=o?o(r[f],t[f],f,r,t):void 0;n===void 0&&(n=t[f]),a?w(r,f,n):Tt(r,f,n)}return r}var jt=Rr;var wt=Math.max;function Br(t,e,r){return e=wt(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=wt(o.length-e,0),p=Array(s);++a<s;)p[a]=o[e+a];a=-1;for(var f=Array(e+1);++a<e;)f[a]=o[a];return f[e]=r(p),gt(t,this,f)}}var At=Br;function Lr(t,e){return Ot(At(t,e,z),t+"")}var It=Lr;var Fr=9007199254740991;function Nr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Fr}var G=Nr;function zr(t){return t!=null&&G(t.length)&&!O(t)}var A=zr;function Wr(t,e,r){if(!u(r))return!1;var o=typeof e;return(o=="number"?A(r)&&U(e,r.length):o=="string"&&e in r)?g(r[e],t):!1}var St=Wr;function Ur(t){return It(function(e,r){var o=-1,a=r.length,s=a>1?r[a-1]:void 0,p=a>2?r[2]:void 0;for(s=t.length>3&&typeof s=="function"?(a--,s):void 0,p&&St(r[0],r[1],p)&&(s=a<3?void 0:s,a=1),e=Object(e);++o<a;){var f=r[o];f&&t(e,f,o,s)}return e})}var Ct=Ur;var Gr=Object.prototype;function Hr(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Gr;return t===r}var H=Hr;function qr(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Pt=qr;var $r="[object Arguments]";function Kr(t){return x(t)&&h(t)==$r}var Q=Kr;var Et=Object.prototype,Vr=Et.hasOwnProperty,kr=Et.propertyIsEnumerable,Yr=Q(function(){return arguments}())?Q:function(t){return x(t)&&Vr.call(t,"callee")&&!kr.call(t,"callee")},R=Yr;function Jr(){return!1}var Mt=Jr;var Bt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dt=Bt&&typeof module=="object"&&module&&!module.nodeType&&module,Xr=Dt&&Dt.exports===Bt,Rt=Xr?d.Buffer:void 0,Zr=Rt?Rt.isBuffer:void 0,Qr=Zr||Mt,q=Qr;var to="[object Arguments]",eo="[object Array]",ro="[object Boolean]",oo="[object Date]",ao="[object Error]",fo="[object Function]",so="[object Map]",po="[object Number]",io="[object Object]",no="[object RegExp]",uo="[object Set]",lo="[object String]",mo="[object WeakMap]",xo="[object ArrayBuffer]",co="[object DataView]",ho="[object Float32Array]",go="[object Float64Array]",yo="[object Int8Array]",bo="[object Int16Array]",vo="[object Int32Array]",_o="[object Uint8Array]",Oo="[object Uint8ClampedArray]",To="[object Uint16Array]",jo="[object Uint32Array]",i={};i[ho]=i[go]=i[yo]=i[bo]=i[vo]=i[_o]=i[Oo]=i[To]=i[jo]=!0;i[to]=i[eo]=i[xo]=i[ro]=i[co]=i[oo]=i[ao]=i[fo]=i[so]=i[po]=i[io]=i[no]=i[uo]=i[lo]=i[mo]=!1;function wo(t){return x(t)&&G(t.length)&&!!i[h(t)]}var Lt=wo;function Ao(t){return function(e){return t(e)}}var Ft=Ao;var Nt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,B=Nt&&typeof module=="object"&&module&&!module.nodeType&&module,Io=B&&B.exports===Nt,tt=Io&&N.process,So=function(){try{var t=B&&B.require&&B.require("util").types;return t||tt&&tt.binding&&tt.binding("util")}catch{}}(),et=So;var zt=et&&et.isTypedArray,Co=zt?Ft(zt):Lt,$=Co;var Po=Object.prototype,Eo=Po.hasOwnProperty;function Mo(t,e){var r=D(t),o=!r&&R(t),a=!r&&!o&&q(t),s=!r&&!o&&!a&&$(t),p=r||o||a||s,f=p?Pt(t.length,String):[],n=f.length;for(var m in t)(e||Eo.call(t,m))&&!(p&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||U(m,n)))&&f.push(m);return f}var Wt=Mo;function Do(t,e){return function(r){return t(e(r))}}var Ut=Do;function Ro(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Gt=Ro;var Bo=Object.prototype,Lo=Bo.hasOwnProperty;function Fo(t){if(!u(t))return Gt(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!Lo.call(t,o))||r.push(o);return r}var Ht=Fo;function No(t){return A(t)?Wt(t,!0):Ht(t)}var K=No;var zo=T(Object,"create"),c=zo;function Wo(){this.__data__=c?c(null):{},this.size=0}var qt=Wo;function Uo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var $t=Uo;var Go="__lodash_hash_undefined__",Ho=Object.prototype,qo=Ho.hasOwnProperty;function $o(t){var e=this.__data__;if(c){var r=e[t];return r===Go?void 0:r}return qo.call(e,t)?e[t]:void 0}var Kt=$o;var Ko=Object.prototype,Vo=Ko.hasOwnProperty;function ko(t){var e=this.__data__;return c?e[t]!==void 0:Vo.call(e,t)}var Vt=ko;var Yo="__lodash_hash_undefined__";function Jo(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=c&&e===void 0?Yo:e,this}var kt=Jo;function I(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])}}I.prototype.clear=qt;I.prototype.delete=$t;I.prototype.get=Kt;I.prototype.has=Vt;I.prototype.set=kt;var rt=I;function Xo(){this.__data__=[],this.size=0}var Yt=Xo;function Zo(t,e){for(var r=t.length;r--;)if(g(t[r][0],e))return r;return-1}var y=Zo;var Qo=Array.prototype,ta=Qo.splice;function ea(t){var e=this.__data__,r=y(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():ta.call(e,r,1),--this.size,!0}var Jt=ea;function ra(t){var e=this.__data__,r=y(e,t);return r<0?void 0:e[r][1]}var Xt=ra;function oa(t){return y(this.__data__,t)>-1}var Zt=oa;function aa(t,e){var r=this.__data__,o=y(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Qt=aa;function S(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])}}S.prototype.clear=Yt;S.prototype.delete=Jt;S.prototype.get=Xt;S.prototype.has=Zt;S.prototype.set=Qt;var b=S;var fa=T(d,"Map"),V=fa;function sa(){this.size=0,this.__data__={hash:new rt,map:new(V||b),string:new rt}}var te=sa;function pa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ee=pa;function ia(t,e){var r=t.__data__;return ee(e)?r[typeof e=="string"?"string":"hash"]:r.map}var v=ia;function na(t){var e=v(this,t).delete(t);return this.size-=e?1:0,e}var re=na;function ua(t){return v(this,t).get(t)}var oe=ua;function la(t){return v(this,t).has(t)}var ae=la;function ma(t,e){var r=v(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var fe=ma;function C(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])}}C.prototype.clear=te;C.prototype.delete=re;C.prototype.get=oe;C.prototype.has=ae;C.prototype.set=fe;var se=C;var da=Ut(Object.getPrototypeOf,Object),k=da;var xa="[object Object]",ca=Function.prototype,ha=Object.prototype,pe=ca.toString,ga=ha.hasOwnProperty,ya=pe.call(Object);function ba(t){if(!x(t)||h(t)!=xa)return!1;var e=k(t);if(e===null)return!0;var r=ga.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&pe.call(r)==ya}var ie=ba;function va(){this.__data__=new b,this.size=0}var ne=va;function _a(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ue=_a;function Oa(t){return this.__data__.get(t)}var le=Oa;function Ta(t){return this.__data__.has(t)}var me=Ta;var ja=200;function wa(t,e){var r=this.__data__;if(r instanceof b){var o=r.__data__;if(!V||o.length<ja-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new se(o)}return r.set(t,e),this.size=r.size,this}var de=wa;function P(t){var e=this.__data__=new b(t);this.size=e.size}P.prototype.clear=ne;P.prototype.delete=ue;P.prototype.get=le;P.prototype.has=me;P.prototype.set=de;var xe=P;var ye=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ce=ye&&typeof module=="object"&&module&&!module.nodeType&&module,Aa=ce&&ce.exports===ye,he=Aa?d.Buffer:void 0,ge=he?he.allocUnsafe:void 0;function Ia(t,e){if(e)return t.slice();var r=t.length,o=ge?ge(r):new t.constructor(r);return t.copy(o),o}var be=Ia;var Sa=d.Uint8Array,ot=Sa;function Ca(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}var ve=Ca;function Pa(t,e){var r=e?ve(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var _e=Pa;function Ea(t){return typeof t.constructor=="function"&&!H(t)?ht(k(t)):{}}var Oe=Ea;function Ma(t){return function(e,r,o){for(var a=-1,s=Object(e),p=o(e),f=p.length;f--;){var n=p[t?f:++a];if(r(s[n],n,s)===!1)break}return e}}var Te=Ma;var Da=Te(),je=Da;function Ra(t,e,r){(r!==void 0&&!g(t[e],r)||r===void 0&&!(e in t))&&w(t,e,r)}var L=Ra;function Ba(t){return x(t)&&A(t)}var we=Ba;function La(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var F=La;function Fa(t){return jt(t,K(t))}var Ae=Fa;function Na(t,e,r,o,a,s,p){var f=F(t,r),n=F(e,r),m=p.get(n);if(m){L(t,r,m);return}var l=s?s(f,n,r+"",t,e,p):void 0,E=l===void 0;if(E){var J=D(n),X=!J&&q(n),ft=!J&&!X&&$(n);l=n,J||X||ft?D(f)?l=f:we(f)?l=yt(f):X?(E=!1,l=be(n,!0)):ft?(E=!1,l=_e(n,!0)):l=[]:ie(n)||R(n)?(l=f,R(f)?l=Ae(f):(!u(f)||O(f))&&(l=Oe(n))):E=!1}E&&(p.set(n,l),a(l,n,o,s,p),p.delete(n)),L(t,r,l)}var Ie=Na;function Se(t,e,r,o,a){t!==e&&je(e,function(s,p){if(a||(a=new xe),u(s))Ie(t,e,p,r,Se,o,a);else{var f=o?o(F(t,p),s,p+"",t,e,a):void 0;f===void 0&&(f=s),L(t,p,f)}},K)}var Ce=Se;var za=Ct(function(t,e,r){Ce(t,e,r)}),Y=za;var at=class{constructor(e){Z(this,"settings",{client:"tera-fy",clientType:"esm"});Z(this,"bootstrapperDeferredMethods",[]);e&&Y(this.settings,e),["set","setIfDev","use"].forEach(r=>{this[r]=(...o)=>(this.bootstrapperDeferredMethods.push({method:r,args:o}),this)})}init(e){let r=o=>`https://dev.tera-tools.com/api/tera-fy/${o}.js`;return Promise.resolve().then(()=>this.settings.clientType=="esm"?this.bootstrapperImport(r(this.settings.client)).then(o=>typeof o=="function"?o:Promise.reject("Tera-fy import didn't return a class")):Promise.reject(`Unsupported TERA-fy clientType "${this.settings.clientType}"`)).then(o=>{let a=new o;if(!a.mixin)throw new Error("TERA-fy client doesnt expose a mixin() method");a.mixin(this,a),Y(this.settings,a.settings,this.settings)}).then(()=>{if(console.log("IAM",this),!this.init||typeof this.init!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a init() method");if(!this.detectMode||typeof this.detectMode!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a detectMode() method")}).then(()=>this.bootstrapperDeferredMethods.reduce((o,a)=>a.method=="use"&&typeof a.args[0]=="string"?(console.log("TERA-FY DEFERRED-USE",a.args[0]),this.bootstrapperImport(r(a.args[0])).then(s=>typeof s=="function"?s:Promise.reject("Tera-fy plugin import didn't return a class")).then(s=>this.use(s,...a.args.slice(1)))):(console.log("TERA-FY DEFERRED-METHOD",a),this[a.method].apply(this,a.args))),Promise.resolve()).then(()=>delete this.bootstrapperDeferredMethods).then(()=>console.log("TYBS","Init")).then(()=>this.init.call(this,e))}bootstrapperImport(e){return new Promise((r,o)=>{let a=`installTFyBS${Math.random().toString(36).slice(2)}`,s=document.createElement("script");s.type="module",s.textContent=`
1
+ var Pe=typeof global=="object"&&global&&global.Object===Object&&global,N=Pe;var Se=typeof self=="object"&&self&&self.Object===Object&&self,Ee=N||Se||Function("return this")(),d=Ee;var Me=d.Symbol,O=Me;var ft=Object.prototype,De=ft.hasOwnProperty,Re=ft.toString,M=O?O.toStringTag:void 0;function Be(t){var e=De.call(t,M),r=t[M];try{t[M]=void 0;var o=!0}catch{}var a=Re.call(t);return o&&(e?t[M]=r:delete t[M]),a}var st=Be;var Le=Object.prototype,Fe=Le.toString;function Ne(t){return Fe.call(t)}var it=Ne;var ze="[object Null]",We="[object Undefined]",pt=O?O.toStringTag:void 0;function Ue(t){return t==null?t===void 0?We:ze:pt&&pt in Object(t)?st(t):it(t)}var g=Ue;function Ge(t){return t!=null&&typeof t=="object"}var x=Ge;var He=Array.isArray,D=He;function qe(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var l=qe;function $e(t){return t}var z=$e;var Ke="[object AsyncFunction]",Ve="[object Function]",ke="[object GeneratorFunction]",Ye="[object Proxy]";function Je(t){if(!l(t))return!1;var e=g(t);return e==Ve||e==ke||e==Ke||e==Ye}var T=Je;var Xe=d["__core-js_shared__"],W=Xe;var nt=function(){var t=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ze(t){return!!nt&&nt in t}var ut=Ze;var Qe=Function.prototype,tr=Qe.toString;function er(t){if(t!=null){try{return tr.call(t)}catch{}try{return t+""}catch{}}return""}var lt=er;var rr=/[\\^$.*+?()[\]{}|]/g,or=/^\[object .+?Constructor\]$/,ar=Function.prototype,fr=Object.prototype,sr=ar.toString,ir=fr.hasOwnProperty,pr=RegExp("^"+sr.call(ir).replace(rr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nr(t){if(!l(t)||ut(t))return!1;var e=T(t)?pr:or;return e.test(lt(t))}var mt=nr;function ur(t,e){return t==null?void 0:t[e]}var dt=ur;function lr(t,e){var r=dt(t,e);return mt(r)?r:void 0}var j=lr;var xt=Object.create,mr=function(){function t(){}return function(e){if(!l(e))return{};if(xt)return xt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ct=mr;function dr(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 ht=dr;function xr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var gt=xr;var cr=800,hr=16,gr=Date.now;function yr(t){var e=0,r=0;return function(){var o=gr(),a=hr-(o-r);if(r=o,a>0){if(++e>=cr)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var yt=yr;function br(t){return function(){return t}}var bt=br;var vr=function(){try{var t=j(Object,"defineProperty");return t({},"",{}),t}catch{}}(),w=vr;var _r=w?function(t,e){return w(t,"toString",{configurable:!0,enumerable:!1,value:bt(e),writable:!0})}:z,vt=_r;var Or=yt(vt),_t=Or;var Tr=9007199254740991,jr=/^(?:0|[1-9]\d*)$/;function wr(t,e){var r=typeof t;return e=e==null?Tr:e,!!e&&(r=="number"||r!="symbol"&&jr.test(t))&&t>-1&&t%1==0&&t<e}var U=wr;function Ar(t,e,r){e=="__proto__"&&w?w(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var A=Ar;function Cr(t,e){return t===e||t!==t&&e!==e}var y=Cr;var Ir=Object.prototype,Pr=Ir.hasOwnProperty;function Sr(t,e,r){var o=t[e];(!(Pr.call(t,e)&&y(o,r))||r===void 0&&!(e in t))&&A(t,e,r)}var Ot=Sr;function Er(t,e,r,o){var a=!r;r||(r={});for(var f=-1,i=e.length;++f<i;){var s=e[f],p=o?o(r[s],t[s],s,r,t):void 0;p===void 0&&(p=t[s]),a?A(r,s,p):Ot(r,s,p)}return r}var Tt=Er;var jt=Math.max;function Mr(t,e,r){return e=jt(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,f=jt(o.length-e,0),i=Array(f);++a<f;)i[a]=o[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=o[a];return s[e]=r(i),ht(t,this,s)}}var wt=Mr;function Dr(t,e){return _t(wt(t,e,z),t+"")}var At=Dr;var Rr=9007199254740991;function Br(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Rr}var G=Br;function Lr(t){return t!=null&&G(t.length)&&!T(t)}var C=Lr;function Fr(t,e,r){if(!l(r))return!1;var o=typeof e;return(o=="number"?C(r)&&U(e,r.length):o=="string"&&e in r)?y(r[e],t):!1}var Ct=Fr;function Nr(t){return At(function(e,r){var o=-1,a=r.length,f=a>1?r[a-1]:void 0,i=a>2?r[2]:void 0;for(f=t.length>3&&typeof f=="function"?(a--,f):void 0,i&&Ct(r[0],r[1],i)&&(f=a<3?void 0:f,a=1),e=Object(e);++o<a;){var s=r[o];s&&t(e,s,o,f)}return e})}var It=Nr;var zr=Object.prototype;function Wr(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||zr;return t===r}var H=Wr;function Ur(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Pt=Ur;var Gr="[object Arguments]";function Hr(t){return x(t)&&g(t)==Gr}var Z=Hr;var St=Object.prototype,qr=St.hasOwnProperty,$r=St.propertyIsEnumerable,Kr=Z(function(){return arguments}())?Z:function(t){return x(t)&&qr.call(t,"callee")&&!$r.call(t,"callee")},R=Kr;function Vr(){return!1}var Et=Vr;var Rt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mt=Rt&&typeof module=="object"&&module&&!module.nodeType&&module,kr=Mt&&Mt.exports===Rt,Dt=kr?d.Buffer:void 0,Yr=Dt?Dt.isBuffer:void 0,Jr=Yr||Et,q=Jr;var Xr="[object Arguments]",Zr="[object Array]",Qr="[object Boolean]",to="[object Date]",eo="[object Error]",ro="[object Function]",oo="[object Map]",ao="[object Number]",fo="[object Object]",so="[object RegExp]",io="[object Set]",po="[object String]",no="[object WeakMap]",uo="[object ArrayBuffer]",lo="[object DataView]",mo="[object Float32Array]",xo="[object Float64Array]",co="[object Int8Array]",ho="[object Int16Array]",go="[object Int32Array]",yo="[object Uint8Array]",bo="[object Uint8ClampedArray]",vo="[object Uint16Array]",_o="[object Uint32Array]",n={};n[mo]=n[xo]=n[co]=n[ho]=n[go]=n[yo]=n[bo]=n[vo]=n[_o]=!0;n[Xr]=n[Zr]=n[uo]=n[Qr]=n[lo]=n[to]=n[eo]=n[ro]=n[oo]=n[ao]=n[fo]=n[so]=n[io]=n[po]=n[no]=!1;function Oo(t){return x(t)&&G(t.length)&&!!n[g(t)]}var Bt=Oo;function To(t){return function(e){return t(e)}}var Lt=To;var Ft=typeof exports=="object"&&exports&&!exports.nodeType&&exports,B=Ft&&typeof module=="object"&&module&&!module.nodeType&&module,jo=B&&B.exports===Ft,Q=jo&&N.process,wo=function(){try{var t=B&&B.require&&B.require("util").types;return t||Q&&Q.binding&&Q.binding("util")}catch{}}(),tt=wo;var Nt=tt&&tt.isTypedArray,Ao=Nt?Lt(Nt):Bt,$=Ao;var Co=Object.prototype,Io=Co.hasOwnProperty;function Po(t,e){var r=D(t),o=!r&&R(t),a=!r&&!o&&q(t),f=!r&&!o&&!a&&$(t),i=r||o||a||f,s=i?Pt(t.length,String):[],p=s.length;for(var m in t)(e||Io.call(t,m))&&!(i&&(m=="length"||a&&(m=="offset"||m=="parent")||f&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||U(m,p)))&&s.push(m);return s}var zt=Po;function So(t,e){return function(r){return t(e(r))}}var Wt=So;function Eo(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ut=Eo;var Mo=Object.prototype,Do=Mo.hasOwnProperty;function Ro(t){if(!l(t))return Ut(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!Do.call(t,o))||r.push(o);return r}var Gt=Ro;function Bo(t){return C(t)?zt(t,!0):Gt(t)}var K=Bo;var Lo=j(Object,"create"),c=Lo;function Fo(){this.__data__=c?c(null):{},this.size=0}var Ht=Fo;function No(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var qt=No;var zo="__lodash_hash_undefined__",Wo=Object.prototype,Uo=Wo.hasOwnProperty;function Go(t){var e=this.__data__;if(c){var r=e[t];return r===zo?void 0:r}return Uo.call(e,t)?e[t]:void 0}var $t=Go;var Ho=Object.prototype,qo=Ho.hasOwnProperty;function $o(t){var e=this.__data__;return c?e[t]!==void 0:qo.call(e,t)}var Kt=$o;var Ko="__lodash_hash_undefined__";function Vo(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=c&&e===void 0?Ko:e,this}var Vt=Vo;function I(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])}}I.prototype.clear=Ht;I.prototype.delete=qt;I.prototype.get=$t;I.prototype.has=Kt;I.prototype.set=Vt;var et=I;function ko(){this.__data__=[],this.size=0}var kt=ko;function Yo(t,e){for(var r=t.length;r--;)if(y(t[r][0],e))return r;return-1}var b=Yo;var Jo=Array.prototype,Xo=Jo.splice;function Zo(t){var e=this.__data__,r=b(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Xo.call(e,r,1),--this.size,!0}var Yt=Zo;function Qo(t){var e=this.__data__,r=b(e,t);return r<0?void 0:e[r][1]}var Jt=Qo;function ta(t){return b(this.__data__,t)>-1}var Xt=ta;function ea(t,e){var r=this.__data__,o=b(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Zt=ea;function P(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])}}P.prototype.clear=kt;P.prototype.delete=Yt;P.prototype.get=Jt;P.prototype.has=Xt;P.prototype.set=Zt;var v=P;var ra=j(d,"Map"),V=ra;function oa(){this.size=0,this.__data__={hash:new et,map:new(V||v),string:new et}}var Qt=oa;function aa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var te=aa;function fa(t,e){var r=t.__data__;return te(e)?r[typeof e=="string"?"string":"hash"]:r.map}var _=fa;function sa(t){var e=_(this,t).delete(t);return this.size-=e?1:0,e}var ee=sa;function ia(t){return _(this,t).get(t)}var re=ia;function pa(t){return _(this,t).has(t)}var oe=pa;function na(t,e){var r=_(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ae=na;function S(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])}}S.prototype.clear=Qt;S.prototype.delete=ee;S.prototype.get=re;S.prototype.has=oe;S.prototype.set=ae;var fe=S;var ua=Wt(Object.getPrototypeOf,Object),k=ua;var la="[object Object]",ma=Function.prototype,da=Object.prototype,se=ma.toString,xa=da.hasOwnProperty,ca=se.call(Object);function ha(t){if(!x(t)||g(t)!=la)return!1;var e=k(t);if(e===null)return!0;var r=xa.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&se.call(r)==ca}var ie=ha;function ga(){this.__data__=new v,this.size=0}var pe=ga;function ya(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ne=ya;function ba(t){return this.__data__.get(t)}var ue=ba;function va(t){return this.__data__.has(t)}var le=va;var _a=200;function Oa(t,e){var r=this.__data__;if(r instanceof v){var o=r.__data__;if(!V||o.length<_a-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new fe(o)}return r.set(t,e),this.size=r.size,this}var me=Oa;function E(t){var e=this.__data__=new v(t);this.size=e.size}E.prototype.clear=pe;E.prototype.delete=ne;E.prototype.get=ue;E.prototype.has=le;E.prototype.set=me;var de=E;var ge=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xe=ge&&typeof module=="object"&&module&&!module.nodeType&&module,Ta=xe&&xe.exports===ge,ce=Ta?d.Buffer:void 0,he=ce?ce.allocUnsafe:void 0;function ja(t,e){if(e)return t.slice();var r=t.length,o=he?he(r):new t.constructor(r);return t.copy(o),o}var ye=ja;var wa=d.Uint8Array,rt=wa;function Aa(t){var e=new t.constructor(t.byteLength);return new rt(e).set(new rt(t)),e}var be=Aa;function Ca(t,e){var r=e?be(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var ve=Ca;function Ia(t){return typeof t.constructor=="function"&&!H(t)?ct(k(t)):{}}var _e=Ia;function Pa(t){return function(e,r,o){for(var a=-1,f=Object(e),i=o(e),s=i.length;s--;){var p=i[t?s:++a];if(r(f[p],p,f)===!1)break}return e}}var Oe=Pa;var Sa=Oe(),Te=Sa;function Ea(t,e,r){(r!==void 0&&!y(t[e],r)||r===void 0&&!(e in t))&&A(t,e,r)}var L=Ea;function Ma(t){return x(t)&&C(t)}var je=Ma;function Da(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var F=Da;function Ra(t){return Tt(t,K(t))}var we=Ra;function Ba(t,e,r,o,a,f,i){var s=F(t,r),p=F(e,r),m=i.get(p);if(m){L(t,r,m);return}var u=f?f(s,p,r+"",t,e,i):void 0,h=u===void 0;if(h){var J=D(p),X=!J&&q(p),at=!J&&!X&&$(p);u=p,J||X||at?D(s)?u=s:je(s)?u=gt(s):X?(h=!1,u=ye(p,!0)):at?(h=!1,u=ve(p,!0)):u=[]:ie(p)||R(p)?(u=s,R(s)?u=we(s):(!l(s)||T(s))&&(u=_e(p))):h=!1}h&&(i.set(p,u),a(u,p,o,f,i),i.delete(p)),L(t,r,u)}var Ae=Ba;function Ce(t,e,r,o,a){t!==e&&Te(e,function(f,i){if(a||(a=new de),l(f))Ae(t,e,i,r,Ce,o,a);else{var s=o?o(F(t,i),f,i+"",t,e,a):void 0;s===void 0&&(s=f),L(t,i,s)}},K)}var Ie=Ce;var La=It(function(t,e,r){Ie(t,e,r)}),Y=La;var ot=class{constructor(e){this.settings={client:"tera-fy",clientType:"esm"};this.bootstrapperDeferredMethods=[];e&&Y(this.settings,e),["set","setIfDev","use"].forEach(r=>{this[r]=(...o)=>(this.bootstrapperDeferredMethods.push({method:r,args:o}),this)})}init(e){let r=o=>`https://dev.tera-tools.com/api/tera-fy/${o}.js`;return Promise.resolve().then(()=>this.settings.clientType=="esm"?this.bootstrapperImport(r(this.settings.client)).then(o=>typeof o=="function"?o:Promise.reject("Tera-fy import didn't return a class")):Promise.reject(`Unsupported TERA-fy clientType "${this.settings.clientType}"`)).then(o=>{let a=new o;if(!a.mixin)throw new Error("TERA-fy client doesnt expose a mixin() method");a.mixin(this,a),Y(this.settings,a.settings,e||{})}).then(()=>{if(console.log("IAM",this),!this.init||typeof this.init!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a init() method");if(!this.detectMode||typeof this.detectMode!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a detectMode() method")}).then(()=>this.bootstrapperDeferredMethods.reduce((o,a)=>o.then(()=>a.method=="use"&&typeof a.args[0]=="string"?(console.log("TERA-FY DEFERRED-USE",a.args[0]),this.bootstrapperImport(r(a.args[0])).then(f=>typeof f=="function"?f:Promise.reject("Tera-fy plugin import didn't return a class")).then(f=>this.use(f,...a.args.slice(1)))):(console.log("TERA-FY DEFERRED-METHOD",a),Promise.resolve(this[a.method].apply(this,a.args)))),Promise.resolve(void 0))).then(()=>{delete this.bootstrapperDeferredMethods}).then(()=>console.log("TYBS","Init")).then(()=>this.init.call(this,e)).then(()=>this)}bootstrapperImport(e){return new Promise((r,o)=>{let a=`installTFyBS${Math.random().toString(36).slice(2)}`,f=document.createElement("script");f.type="module",f.textContent=`
2
2
  import mod from '${e}';
3
3
  window['installMod${a}'](mod);
4
- `;let p=()=>console.warn("CLEANUP",a);window[`installMod${a}`]=f=>{console.log("Accept module from",e,"=",f),r(f),p()},s.onerror=f=>{o(new Error(`Failed to load module from ${e} - ${f.toString()}`)),p()},document.head.appendChild(s)})}};export{at as default};
4
+ `;let i=()=>{delete window[`installMod${a}`],f.parentNode&&f.parentNode.removeChild(f)};window[`installMod${a}`]=s=>{console.log("Accept module from",e,"=",s),r(s),i()},f.onerror=(s,p,m,u,h)=>{o(new Error(`Failed to load module from ${e} - ${h?h.toString():s}`)),i()},document.head.appendChild(f)})}};export{ot as default};
5
5
  /*! Bundled license information:
6
6
 
7
7
  lodash-es/lodash.js:
@@ -1,7 +1,7 @@
1
- var Ce=typeof global=="object"&&global&&global.Object===Object&&global,N=Ce;var Pe=typeof self=="object"&&self&&self.Object===Object&&self,Ee=N||Pe||Function("return this")(),d=Ee;var Me=d.Symbol,_=Me;var ft=Object.prototype,De=ft.hasOwnProperty,Re=ft.toString,M=_?_.toStringTag:void 0;function Be(t){var e=De.call(t,M),r=t[M];try{t[M]=void 0;var o=!0}catch{}var a=Re.call(t);return o&&(e?t[M]=r:delete t[M]),a}var st=Be;var Le=Object.prototype,Fe=Le.toString;function Ne(t){return Fe.call(t)}var pt=Ne;var ze="[object Null]",We="[object Undefined]",it=_?_.toStringTag:void 0;function Ue(t){return t==null?t===void 0?We:ze:it&&it in Object(t)?st(t):pt(t)}var h=Ue;function Ge(t){return t!=null&&typeof t=="object"}var x=Ge;var He=Array.isArray,D=He;function qe(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var u=qe;function $e(t){return t}var z=$e;var Ke="[object AsyncFunction]",Ve="[object Function]",ke="[object GeneratorFunction]",Ye="[object Proxy]";function Je(t){if(!u(t))return!1;var e=h(t);return e==Ve||e==ke||e==Ke||e==Ye}var O=Je;var Xe=d["__core-js_shared__"],W=Xe;var nt=function(){var t=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ze(t){return!!nt&&nt in t}var ut=Ze;var Qe=Function.prototype,tr=Qe.toString;function er(t){if(t!=null){try{return tr.call(t)}catch{}try{return t+""}catch{}}return""}var lt=er;var rr=/[\\^$.*+?()[\]{}|]/g,or=/^\[object .+?Constructor\]$/,ar=Function.prototype,fr=Object.prototype,sr=ar.toString,pr=fr.hasOwnProperty,ir=RegExp("^"+sr.call(pr).replace(rr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nr(t){if(!u(t)||ut(t))return!1;var e=O(t)?ir:or;return e.test(lt(t))}var mt=nr;function ur(t,e){return t?.[e]}var dt=ur;function lr(t,e){var r=dt(t,e);return mt(r)?r:void 0}var T=lr;var xt=Object.create,mr=function(){function t(){}return function(e){if(!u(e))return{};if(xt)return xt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ct=mr;function dr(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 ht=dr;function xr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var gt=xr;var cr=800,hr=16,gr=Date.now;function yr(t){var e=0,r=0;return function(){var o=gr(),a=hr-(o-r);if(r=o,a>0){if(++e>=cr)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var yt=yr;function br(t){return function(){return t}}var bt=br;var vr=function(){try{var t=T(Object,"defineProperty");return t({},"",{}),t}catch{}}(),j=vr;var _r=j?function(t,e){return j(t,"toString",{configurable:!0,enumerable:!1,value:bt(e),writable:!0})}:z,vt=_r;var Or=yt(vt),_t=Or;var Tr=9007199254740991,jr=/^(?:0|[1-9]\d*)$/;function wr(t,e){var r=typeof t;return e=e??Tr,!!e&&(r=="number"||r!="symbol"&&jr.test(t))&&t>-1&&t%1==0&&t<e}var U=wr;function Ar(t,e,r){e=="__proto__"&&j?j(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var w=Ar;function Ir(t,e){return t===e||t!==t&&e!==e}var g=Ir;var Sr=Object.prototype,Cr=Sr.hasOwnProperty;function Pr(t,e,r){var o=t[e];(!(Cr.call(t,e)&&g(o,r))||r===void 0&&!(e in t))&&w(t,e,r)}var Ot=Pr;function Er(t,e,r,o){var a=!r;r||(r={});for(var s=-1,p=e.length;++s<p;){var f=e[s],n=o?o(r[f],t[f],f,r,t):void 0;n===void 0&&(n=t[f]),a?w(r,f,n):Ot(r,f,n)}return r}var Tt=Er;var jt=Math.max;function Mr(t,e,r){return e=jt(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=jt(o.length-e,0),p=Array(s);++a<s;)p[a]=o[e+a];a=-1;for(var f=Array(e+1);++a<e;)f[a]=o[a];return f[e]=r(p),ht(t,this,f)}}var wt=Mr;function Dr(t,e){return _t(wt(t,e,z),t+"")}var At=Dr;var Rr=9007199254740991;function Br(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Rr}var G=Br;function Lr(t){return t!=null&&G(t.length)&&!O(t)}var A=Lr;function Fr(t,e,r){if(!u(r))return!1;var o=typeof e;return(o=="number"?A(r)&&U(e,r.length):o=="string"&&e in r)?g(r[e],t):!1}var It=Fr;function Nr(t){return At(function(e,r){var o=-1,a=r.length,s=a>1?r[a-1]:void 0,p=a>2?r[2]:void 0;for(s=t.length>3&&typeof s=="function"?(a--,s):void 0,p&&It(r[0],r[1],p)&&(s=a<3?void 0:s,a=1),e=Object(e);++o<a;){var f=r[o];f&&t(e,f,o,s)}return e})}var St=Nr;var zr=Object.prototype;function Wr(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||zr;return t===r}var H=Wr;function Ur(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ct=Ur;var Gr="[object Arguments]";function Hr(t){return x(t)&&h(t)==Gr}var Z=Hr;var Pt=Object.prototype,qr=Pt.hasOwnProperty,$r=Pt.propertyIsEnumerable,Kr=Z(function(){return arguments}())?Z:function(t){return x(t)&&qr.call(t,"callee")&&!$r.call(t,"callee")},R=Kr;function Vr(){return!1}var Et=Vr;var Rt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mt=Rt&&typeof module=="object"&&module&&!module.nodeType&&module,kr=Mt&&Mt.exports===Rt,Dt=kr?d.Buffer:void 0,Yr=Dt?Dt.isBuffer:void 0,Jr=Yr||Et,q=Jr;var Xr="[object Arguments]",Zr="[object Array]",Qr="[object Boolean]",to="[object Date]",eo="[object Error]",ro="[object Function]",oo="[object Map]",ao="[object Number]",fo="[object Object]",so="[object RegExp]",po="[object Set]",io="[object String]",no="[object WeakMap]",uo="[object ArrayBuffer]",lo="[object DataView]",mo="[object Float32Array]",xo="[object Float64Array]",co="[object Int8Array]",ho="[object Int16Array]",go="[object Int32Array]",yo="[object Uint8Array]",bo="[object Uint8ClampedArray]",vo="[object Uint16Array]",_o="[object Uint32Array]",i={};i[mo]=i[xo]=i[co]=i[ho]=i[go]=i[yo]=i[bo]=i[vo]=i[_o]=!0;i[Xr]=i[Zr]=i[uo]=i[Qr]=i[lo]=i[to]=i[eo]=i[ro]=i[oo]=i[ao]=i[fo]=i[so]=i[po]=i[io]=i[no]=!1;function Oo(t){return x(t)&&G(t.length)&&!!i[h(t)]}var Bt=Oo;function To(t){return function(e){return t(e)}}var Lt=To;var Ft=typeof exports=="object"&&exports&&!exports.nodeType&&exports,B=Ft&&typeof module=="object"&&module&&!module.nodeType&&module,jo=B&&B.exports===Ft,Q=jo&&N.process,wo=function(){try{var t=B&&B.require&&B.require("util").types;return t||Q&&Q.binding&&Q.binding("util")}catch{}}(),tt=wo;var Nt=tt&&tt.isTypedArray,Ao=Nt?Lt(Nt):Bt,$=Ao;var Io=Object.prototype,So=Io.hasOwnProperty;function Co(t,e){var r=D(t),o=!r&&R(t),a=!r&&!o&&q(t),s=!r&&!o&&!a&&$(t),p=r||o||a||s,f=p?Ct(t.length,String):[],n=f.length;for(var m in t)(e||So.call(t,m))&&!(p&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||U(m,n)))&&f.push(m);return f}var zt=Co;function Po(t,e){return function(r){return t(e(r))}}var Wt=Po;function Eo(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ut=Eo;var Mo=Object.prototype,Do=Mo.hasOwnProperty;function Ro(t){if(!u(t))return Ut(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!Do.call(t,o))||r.push(o);return r}var Gt=Ro;function Bo(t){return A(t)?zt(t,!0):Gt(t)}var K=Bo;var Lo=T(Object,"create"),c=Lo;function Fo(){this.__data__=c?c(null):{},this.size=0}var Ht=Fo;function No(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var qt=No;var zo="__lodash_hash_undefined__",Wo=Object.prototype,Uo=Wo.hasOwnProperty;function Go(t){var e=this.__data__;if(c){var r=e[t];return r===zo?void 0:r}return Uo.call(e,t)?e[t]:void 0}var $t=Go;var Ho=Object.prototype,qo=Ho.hasOwnProperty;function $o(t){var e=this.__data__;return c?e[t]!==void 0:qo.call(e,t)}var Kt=$o;var Ko="__lodash_hash_undefined__";function Vo(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=c&&e===void 0?Ko:e,this}var Vt=Vo;function I(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])}}I.prototype.clear=Ht;I.prototype.delete=qt;I.prototype.get=$t;I.prototype.has=Kt;I.prototype.set=Vt;var et=I;function ko(){this.__data__=[],this.size=0}var kt=ko;function Yo(t,e){for(var r=t.length;r--;)if(g(t[r][0],e))return r;return-1}var y=Yo;var Jo=Array.prototype,Xo=Jo.splice;function Zo(t){var e=this.__data__,r=y(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Xo.call(e,r,1),--this.size,!0}var Yt=Zo;function Qo(t){var e=this.__data__,r=y(e,t);return r<0?void 0:e[r][1]}var Jt=Qo;function ta(t){return y(this.__data__,t)>-1}var Xt=ta;function ea(t,e){var r=this.__data__,o=y(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Zt=ea;function S(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])}}S.prototype.clear=kt;S.prototype.delete=Yt;S.prototype.get=Jt;S.prototype.has=Xt;S.prototype.set=Zt;var b=S;var ra=T(d,"Map"),V=ra;function oa(){this.size=0,this.__data__={hash:new et,map:new(V||b),string:new et}}var Qt=oa;function aa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var te=aa;function fa(t,e){var r=t.__data__;return te(e)?r[typeof e=="string"?"string":"hash"]:r.map}var v=fa;function sa(t){var e=v(this,t).delete(t);return this.size-=e?1:0,e}var ee=sa;function pa(t){return v(this,t).get(t)}var re=pa;function ia(t){return v(this,t).has(t)}var oe=ia;function na(t,e){var r=v(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ae=na;function C(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])}}C.prototype.clear=Qt;C.prototype.delete=ee;C.prototype.get=re;C.prototype.has=oe;C.prototype.set=ae;var fe=C;var ua=Wt(Object.getPrototypeOf,Object),k=ua;var la="[object Object]",ma=Function.prototype,da=Object.prototype,se=ma.toString,xa=da.hasOwnProperty,ca=se.call(Object);function ha(t){if(!x(t)||h(t)!=la)return!1;var e=k(t);if(e===null)return!0;var r=xa.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&se.call(r)==ca}var pe=ha;function ga(){this.__data__=new b,this.size=0}var ie=ga;function ya(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ne=ya;function ba(t){return this.__data__.get(t)}var ue=ba;function va(t){return this.__data__.has(t)}var le=va;var _a=200;function Oa(t,e){var r=this.__data__;if(r instanceof b){var o=r.__data__;if(!V||o.length<_a-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new fe(o)}return r.set(t,e),this.size=r.size,this}var me=Oa;function P(t){var e=this.__data__=new b(t);this.size=e.size}P.prototype.clear=ie;P.prototype.delete=ne;P.prototype.get=ue;P.prototype.has=le;P.prototype.set=me;var de=P;var ge=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xe=ge&&typeof module=="object"&&module&&!module.nodeType&&module,Ta=xe&&xe.exports===ge,ce=Ta?d.Buffer:void 0,he=ce?ce.allocUnsafe:void 0;function ja(t,e){if(e)return t.slice();var r=t.length,o=he?he(r):new t.constructor(r);return t.copy(o),o}var ye=ja;var wa=d.Uint8Array,rt=wa;function Aa(t){var e=new t.constructor(t.byteLength);return new rt(e).set(new rt(t)),e}var be=Aa;function Ia(t,e){var r=e?be(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var ve=Ia;function Sa(t){return typeof t.constructor=="function"&&!H(t)?ct(k(t)):{}}var _e=Sa;function Ca(t){return function(e,r,o){for(var a=-1,s=Object(e),p=o(e),f=p.length;f--;){var n=p[t?f:++a];if(r(s[n],n,s)===!1)break}return e}}var Oe=Ca;var Pa=Oe(),Te=Pa;function Ea(t,e,r){(r!==void 0&&!g(t[e],r)||r===void 0&&!(e in t))&&w(t,e,r)}var L=Ea;function Ma(t){return x(t)&&A(t)}var je=Ma;function Da(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var F=Da;function Ra(t){return Tt(t,K(t))}var we=Ra;function Ba(t,e,r,o,a,s,p){var f=F(t,r),n=F(e,r),m=p.get(n);if(m){L(t,r,m);return}var l=s?s(f,n,r+"",t,e,p):void 0,E=l===void 0;if(E){var J=D(n),X=!J&&q(n),at=!J&&!X&&$(n);l=n,J||X||at?D(f)?l=f:je(f)?l=gt(f):X?(E=!1,l=ye(n,!0)):at?(E=!1,l=ve(n,!0)):l=[]:pe(n)||R(n)?(l=f,R(f)?l=we(f):(!u(f)||O(f))&&(l=_e(n))):E=!1}E&&(p.set(n,l),a(l,n,o,s,p),p.delete(n)),L(t,r,l)}var Ae=Ba;function Ie(t,e,r,o,a){t!==e&&Te(e,function(s,p){if(a||(a=new de),u(s))Ae(t,e,p,r,Ie,o,a);else{var f=o?o(F(t,p),s,p+"",t,e,a):void 0;f===void 0&&(f=s),L(t,p,f)}},K)}var Se=Ie;var La=St(function(t,e,r){Se(t,e,r)}),Y=La;var ot=class{settings={client:"tera-fy",clientType:"esm"};init(e){let r=o=>`https://dev.tera-tools.com/api/tera-fy/${o}.js`;return Promise.resolve().then(()=>this.settings.clientType=="esm"?this.bootstrapperImport(r(this.settings.client)).then(o=>typeof o=="function"?o:Promise.reject("Tera-fy import didn't return a class")):Promise.reject(`Unsupported TERA-fy clientType "${this.settings.clientType}"`)).then(o=>{let a=new o;if(!a.mixin)throw new Error("TERA-fy client doesnt expose a mixin() method");a.mixin(this,a),Y(this.settings,a.settings,this.settings)}).then(()=>{if(console.log("IAM",this),!this.init||typeof this.init!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a init() method");if(!this.detectMode||typeof this.detectMode!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a detectMode() method")}).then(()=>this.bootstrapperDeferredMethods.reduce((o,a)=>a.method=="use"&&typeof a.args[0]=="string"?(console.log("TERA-FY DEFERRED-USE",a.args[0]),this.bootstrapperImport(r(a.args[0])).then(s=>typeof s=="function"?s:Promise.reject("Tera-fy plugin import didn't return a class")).then(s=>this.use(s,...a.args.slice(1)))):(console.log("TERA-FY DEFERRED-METHOD",a),this[a.method].apply(this,a.args))),Promise.resolve()).then(()=>delete this.bootstrapperDeferredMethods).then(()=>console.log("TYBS","Init")).then(()=>this.init.call(this,e))}bootstrapperDeferredMethods=[];bootstrapperImport(e){return new Promise((r,o)=>{let a=`installTFyBS${Math.random().toString(36).slice(2)}`,s=document.createElement("script");s.type="module",s.textContent=`
1
+ var Pe=typeof global=="object"&&global&&global.Object===Object&&global,N=Pe;var Se=typeof self=="object"&&self&&self.Object===Object&&self,Ee=N||Se||Function("return this")(),d=Ee;var Me=d.Symbol,O=Me;var ft=Object.prototype,De=ft.hasOwnProperty,Re=ft.toString,M=O?O.toStringTag:void 0;function Be(t){var e=De.call(t,M),r=t[M];try{t[M]=void 0;var o=!0}catch{}var a=Re.call(t);return o&&(e?t[M]=r:delete t[M]),a}var st=Be;var Le=Object.prototype,Fe=Le.toString;function Ne(t){return Fe.call(t)}var it=Ne;var ze="[object Null]",We="[object Undefined]",pt=O?O.toStringTag:void 0;function Ue(t){return t==null?t===void 0?We:ze:pt&&pt in Object(t)?st(t):it(t)}var g=Ue;function Ge(t){return t!=null&&typeof t=="object"}var x=Ge;var He=Array.isArray,D=He;function qe(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var l=qe;function $e(t){return t}var z=$e;var Ke="[object AsyncFunction]",Ve="[object Function]",ke="[object GeneratorFunction]",Ye="[object Proxy]";function Je(t){if(!l(t))return!1;var e=g(t);return e==Ve||e==ke||e==Ke||e==Ye}var T=Je;var Xe=d["__core-js_shared__"],W=Xe;var nt=function(){var t=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ze(t){return!!nt&&nt in t}var ut=Ze;var Qe=Function.prototype,tr=Qe.toString;function er(t){if(t!=null){try{return tr.call(t)}catch{}try{return t+""}catch{}}return""}var lt=er;var rr=/[\\^$.*+?()[\]{}|]/g,or=/^\[object .+?Constructor\]$/,ar=Function.prototype,fr=Object.prototype,sr=ar.toString,ir=fr.hasOwnProperty,pr=RegExp("^"+sr.call(ir).replace(rr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nr(t){if(!l(t)||ut(t))return!1;var e=T(t)?pr:or;return e.test(lt(t))}var mt=nr;function ur(t,e){return t?.[e]}var dt=ur;function lr(t,e){var r=dt(t,e);return mt(r)?r:void 0}var j=lr;var xt=Object.create,mr=function(){function t(){}return function(e){if(!l(e))return{};if(xt)return xt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ct=mr;function dr(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 ht=dr;function xr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var gt=xr;var cr=800,hr=16,gr=Date.now;function yr(t){var e=0,r=0;return function(){var o=gr(),a=hr-(o-r);if(r=o,a>0){if(++e>=cr)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var yt=yr;function br(t){return function(){return t}}var bt=br;var vr=function(){try{var t=j(Object,"defineProperty");return t({},"",{}),t}catch{}}(),w=vr;var _r=w?function(t,e){return w(t,"toString",{configurable:!0,enumerable:!1,value:bt(e),writable:!0})}:z,vt=_r;var Or=yt(vt),_t=Or;var Tr=9007199254740991,jr=/^(?:0|[1-9]\d*)$/;function wr(t,e){var r=typeof t;return e=e??Tr,!!e&&(r=="number"||r!="symbol"&&jr.test(t))&&t>-1&&t%1==0&&t<e}var U=wr;function Ar(t,e,r){e=="__proto__"&&w?w(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var A=Ar;function Cr(t,e){return t===e||t!==t&&e!==e}var y=Cr;var Ir=Object.prototype,Pr=Ir.hasOwnProperty;function Sr(t,e,r){var o=t[e];(!(Pr.call(t,e)&&y(o,r))||r===void 0&&!(e in t))&&A(t,e,r)}var Ot=Sr;function Er(t,e,r,o){var a=!r;r||(r={});for(var f=-1,i=e.length;++f<i;){var s=e[f],p=o?o(r[s],t[s],s,r,t):void 0;p===void 0&&(p=t[s]),a?A(r,s,p):Ot(r,s,p)}return r}var Tt=Er;var jt=Math.max;function Mr(t,e,r){return e=jt(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,f=jt(o.length-e,0),i=Array(f);++a<f;)i[a]=o[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=o[a];return s[e]=r(i),ht(t,this,s)}}var wt=Mr;function Dr(t,e){return _t(wt(t,e,z),t+"")}var At=Dr;var Rr=9007199254740991;function Br(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Rr}var G=Br;function Lr(t){return t!=null&&G(t.length)&&!T(t)}var C=Lr;function Fr(t,e,r){if(!l(r))return!1;var o=typeof e;return(o=="number"?C(r)&&U(e,r.length):o=="string"&&e in r)?y(r[e],t):!1}var Ct=Fr;function Nr(t){return At(function(e,r){var o=-1,a=r.length,f=a>1?r[a-1]:void 0,i=a>2?r[2]:void 0;for(f=t.length>3&&typeof f=="function"?(a--,f):void 0,i&&Ct(r[0],r[1],i)&&(f=a<3?void 0:f,a=1),e=Object(e);++o<a;){var s=r[o];s&&t(e,s,o,f)}return e})}var It=Nr;var zr=Object.prototype;function Wr(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||zr;return t===r}var H=Wr;function Ur(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Pt=Ur;var Gr="[object Arguments]";function Hr(t){return x(t)&&g(t)==Gr}var Z=Hr;var St=Object.prototype,qr=St.hasOwnProperty,$r=St.propertyIsEnumerable,Kr=Z(function(){return arguments}())?Z:function(t){return x(t)&&qr.call(t,"callee")&&!$r.call(t,"callee")},R=Kr;function Vr(){return!1}var Et=Vr;var Rt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mt=Rt&&typeof module=="object"&&module&&!module.nodeType&&module,kr=Mt&&Mt.exports===Rt,Dt=kr?d.Buffer:void 0,Yr=Dt?Dt.isBuffer:void 0,Jr=Yr||Et,q=Jr;var Xr="[object Arguments]",Zr="[object Array]",Qr="[object Boolean]",to="[object Date]",eo="[object Error]",ro="[object Function]",oo="[object Map]",ao="[object Number]",fo="[object Object]",so="[object RegExp]",io="[object Set]",po="[object String]",no="[object WeakMap]",uo="[object ArrayBuffer]",lo="[object DataView]",mo="[object Float32Array]",xo="[object Float64Array]",co="[object Int8Array]",ho="[object Int16Array]",go="[object Int32Array]",yo="[object Uint8Array]",bo="[object Uint8ClampedArray]",vo="[object Uint16Array]",_o="[object Uint32Array]",n={};n[mo]=n[xo]=n[co]=n[ho]=n[go]=n[yo]=n[bo]=n[vo]=n[_o]=!0;n[Xr]=n[Zr]=n[uo]=n[Qr]=n[lo]=n[to]=n[eo]=n[ro]=n[oo]=n[ao]=n[fo]=n[so]=n[io]=n[po]=n[no]=!1;function Oo(t){return x(t)&&G(t.length)&&!!n[g(t)]}var Bt=Oo;function To(t){return function(e){return t(e)}}var Lt=To;var Ft=typeof exports=="object"&&exports&&!exports.nodeType&&exports,B=Ft&&typeof module=="object"&&module&&!module.nodeType&&module,jo=B&&B.exports===Ft,Q=jo&&N.process,wo=function(){try{var t=B&&B.require&&B.require("util").types;return t||Q&&Q.binding&&Q.binding("util")}catch{}}(),tt=wo;var Nt=tt&&tt.isTypedArray,Ao=Nt?Lt(Nt):Bt,$=Ao;var Co=Object.prototype,Io=Co.hasOwnProperty;function Po(t,e){var r=D(t),o=!r&&R(t),a=!r&&!o&&q(t),f=!r&&!o&&!a&&$(t),i=r||o||a||f,s=i?Pt(t.length,String):[],p=s.length;for(var m in t)(e||Io.call(t,m))&&!(i&&(m=="length"||a&&(m=="offset"||m=="parent")||f&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||U(m,p)))&&s.push(m);return s}var zt=Po;function So(t,e){return function(r){return t(e(r))}}var Wt=So;function Eo(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ut=Eo;var Mo=Object.prototype,Do=Mo.hasOwnProperty;function Ro(t){if(!l(t))return Ut(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!Do.call(t,o))||r.push(o);return r}var Gt=Ro;function Bo(t){return C(t)?zt(t,!0):Gt(t)}var K=Bo;var Lo=j(Object,"create"),c=Lo;function Fo(){this.__data__=c?c(null):{},this.size=0}var Ht=Fo;function No(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var qt=No;var zo="__lodash_hash_undefined__",Wo=Object.prototype,Uo=Wo.hasOwnProperty;function Go(t){var e=this.__data__;if(c){var r=e[t];return r===zo?void 0:r}return Uo.call(e,t)?e[t]:void 0}var $t=Go;var Ho=Object.prototype,qo=Ho.hasOwnProperty;function $o(t){var e=this.__data__;return c?e[t]!==void 0:qo.call(e,t)}var Kt=$o;var Ko="__lodash_hash_undefined__";function Vo(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=c&&e===void 0?Ko:e,this}var Vt=Vo;function I(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])}}I.prototype.clear=Ht;I.prototype.delete=qt;I.prototype.get=$t;I.prototype.has=Kt;I.prototype.set=Vt;var et=I;function ko(){this.__data__=[],this.size=0}var kt=ko;function Yo(t,e){for(var r=t.length;r--;)if(y(t[r][0],e))return r;return-1}var b=Yo;var Jo=Array.prototype,Xo=Jo.splice;function Zo(t){var e=this.__data__,r=b(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Xo.call(e,r,1),--this.size,!0}var Yt=Zo;function Qo(t){var e=this.__data__,r=b(e,t);return r<0?void 0:e[r][1]}var Jt=Qo;function ta(t){return b(this.__data__,t)>-1}var Xt=ta;function ea(t,e){var r=this.__data__,o=b(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Zt=ea;function P(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])}}P.prototype.clear=kt;P.prototype.delete=Yt;P.prototype.get=Jt;P.prototype.has=Xt;P.prototype.set=Zt;var v=P;var ra=j(d,"Map"),V=ra;function oa(){this.size=0,this.__data__={hash:new et,map:new(V||v),string:new et}}var Qt=oa;function aa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var te=aa;function fa(t,e){var r=t.__data__;return te(e)?r[typeof e=="string"?"string":"hash"]:r.map}var _=fa;function sa(t){var e=_(this,t).delete(t);return this.size-=e?1:0,e}var ee=sa;function ia(t){return _(this,t).get(t)}var re=ia;function pa(t){return _(this,t).has(t)}var oe=pa;function na(t,e){var r=_(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ae=na;function S(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])}}S.prototype.clear=Qt;S.prototype.delete=ee;S.prototype.get=re;S.prototype.has=oe;S.prototype.set=ae;var fe=S;var ua=Wt(Object.getPrototypeOf,Object),k=ua;var la="[object Object]",ma=Function.prototype,da=Object.prototype,se=ma.toString,xa=da.hasOwnProperty,ca=se.call(Object);function ha(t){if(!x(t)||g(t)!=la)return!1;var e=k(t);if(e===null)return!0;var r=xa.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&se.call(r)==ca}var ie=ha;function ga(){this.__data__=new v,this.size=0}var pe=ga;function ya(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ne=ya;function ba(t){return this.__data__.get(t)}var ue=ba;function va(t){return this.__data__.has(t)}var le=va;var _a=200;function Oa(t,e){var r=this.__data__;if(r instanceof v){var o=r.__data__;if(!V||o.length<_a-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new fe(o)}return r.set(t,e),this.size=r.size,this}var me=Oa;function E(t){var e=this.__data__=new v(t);this.size=e.size}E.prototype.clear=pe;E.prototype.delete=ne;E.prototype.get=ue;E.prototype.has=le;E.prototype.set=me;var de=E;var ge=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xe=ge&&typeof module=="object"&&module&&!module.nodeType&&module,Ta=xe&&xe.exports===ge,ce=Ta?d.Buffer:void 0,he=ce?ce.allocUnsafe:void 0;function ja(t,e){if(e)return t.slice();var r=t.length,o=he?he(r):new t.constructor(r);return t.copy(o),o}var ye=ja;var wa=d.Uint8Array,rt=wa;function Aa(t){var e=new t.constructor(t.byteLength);return new rt(e).set(new rt(t)),e}var be=Aa;function Ca(t,e){var r=e?be(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var ve=Ca;function Ia(t){return typeof t.constructor=="function"&&!H(t)?ct(k(t)):{}}var _e=Ia;function Pa(t){return function(e,r,o){for(var a=-1,f=Object(e),i=o(e),s=i.length;s--;){var p=i[t?s:++a];if(r(f[p],p,f)===!1)break}return e}}var Oe=Pa;var Sa=Oe(),Te=Sa;function Ea(t,e,r){(r!==void 0&&!y(t[e],r)||r===void 0&&!(e in t))&&A(t,e,r)}var L=Ea;function Ma(t){return x(t)&&C(t)}var je=Ma;function Da(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var F=Da;function Ra(t){return Tt(t,K(t))}var we=Ra;function Ba(t,e,r,o,a,f,i){var s=F(t,r),p=F(e,r),m=i.get(p);if(m){L(t,r,m);return}var u=f?f(s,p,r+"",t,e,i):void 0,h=u===void 0;if(h){var J=D(p),X=!J&&q(p),at=!J&&!X&&$(p);u=p,J||X||at?D(s)?u=s:je(s)?u=gt(s):X?(h=!1,u=ye(p,!0)):at?(h=!1,u=ve(p,!0)):u=[]:ie(p)||R(p)?(u=s,R(s)?u=we(s):(!l(s)||T(s))&&(u=_e(p))):h=!1}h&&(i.set(p,u),a(u,p,o,f,i),i.delete(p)),L(t,r,u)}var Ae=Ba;function Ce(t,e,r,o,a){t!==e&&Te(e,function(f,i){if(a||(a=new de),l(f))Ae(t,e,i,r,Ce,o,a);else{var s=o?o(F(t,i),f,i+"",t,e,a):void 0;s===void 0&&(s=f),L(t,i,s)}},K)}var Ie=Ce;var La=It(function(t,e,r){Ie(t,e,r)}),Y=La;var ot=class{constructor(e){this.settings={client:"tera-fy",clientType:"esm"};this.bootstrapperDeferredMethods=[];e&&Y(this.settings,e),["set","setIfDev","use"].forEach(r=>{this[r]=(...o)=>(this.bootstrapperDeferredMethods.push({method:r,args:o}),this)})}init(e){let r=o=>`https://dev.tera-tools.com/api/tera-fy/${o}.js`;return Promise.resolve().then(()=>this.settings.clientType=="esm"?this.bootstrapperImport(r(this.settings.client)).then(o=>typeof o=="function"?o:Promise.reject("Tera-fy import didn't return a class")):Promise.reject(`Unsupported TERA-fy clientType "${this.settings.clientType}"`)).then(o=>{let a=new o;if(!a.mixin)throw new Error("TERA-fy client doesnt expose a mixin() method");a.mixin(this,a),Y(this.settings,a.settings,e||{})}).then(()=>{if(console.log("IAM",this),!this.init||typeof this.init!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a init() method");if(!this.detectMode||typeof this.detectMode!="function")throw new Error("Newly mixed-in TERA-fy client doesnt expose a detectMode() method")}).then(()=>this.bootstrapperDeferredMethods.reduce((o,a)=>o.then(()=>a.method=="use"&&typeof a.args[0]=="string"?(console.log("TERA-FY DEFERRED-USE",a.args[0]),this.bootstrapperImport(r(a.args[0])).then(f=>typeof f=="function"?f:Promise.reject("Tera-fy plugin import didn't return a class")).then(f=>this.use(f,...a.args.slice(1)))):(console.log("TERA-FY DEFERRED-METHOD",a),Promise.resolve(this[a.method].apply(this,a.args)))),Promise.resolve(void 0))).then(()=>{delete this.bootstrapperDeferredMethods}).then(()=>console.log("TYBS","Init")).then(()=>this.init.call(this,e)).then(()=>this)}bootstrapperImport(e){return new Promise((r,o)=>{let a=`installTFyBS${Math.random().toString(36).slice(2)}`,f=document.createElement("script");f.type="module",f.textContent=`
2
2
  import mod from '${e}';
3
3
  window['installMod${a}'](mod);
4
- `;let p=()=>console.warn("CLEANUP",a);window[`installMod${a}`]=f=>{console.log("Accept module from",e,"=",f),r(f),p()},s.onerror=f=>{o(new Error(`Failed to load module from ${e} - ${f.toString()}`)),p()},document.head.appendChild(s)})}constructor(e){e&&Y(this.settings,e),["set","setIfDev","use"].forEach(r=>{this[r]=(...o)=>(this.bootstrapperDeferredMethods.push({method:r,args:o}),this)})}};export{ot as default};
4
+ `;let i=()=>{delete window[`installMod${a}`],f.parentNode&&f.parentNode.removeChild(f)};window[`installMod${a}`]=s=>{console.log("Accept module from",e,"=",s),r(s),i()},f.onerror=(s,p,m,u,h)=>{o(new Error(`Failed to load module from ${e} - ${h?h.toString():s}`)),i()},document.head.appendChild(f)})}};export{ot as default};
5
5
  /*! Bundled license information:
6
6
 
7
7
  lodash-es/lodash.js:
@@ -1,5 +1,5 @@
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 p=(t,e,r)=>co(t,typeof e!="symbol"?e+"":e,r);var ho=typeof global=="object"&&global&&global.Object===Object&&global,dt=ho;var xo=typeof self=="object"&&self&&self.Object===Object&&self,go=dt||xo||Function("return this")(),c=go;var bo=c.Symbol,b=bo;var Yt=Object.prototype,yo=Yt.hasOwnProperty,vo=Yt.toString,st=b?b.toStringTag:void 0;function wo(t){var e=yo.call(t,st),r=t[st];try{t[st]=void 0;var o=!0}catch{}var a=vo.call(t);return o&&(e?t[st]=r:delete t[st]),a}var Zt=wo;var To=Object.prototype,Oo=To.toString;function jo(t){return Oo.call(t)}var Jt=jo;var Ao="[object Null]",Po="[object Undefined]",Xt=b?b.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:Ao:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var O=So;function Io(t){return t!=null&&typeof t=="object"}var T=Io;var _o="[object Symbol]";function Eo(t){return typeof t=="symbol"||T(t)&&O(t)==_o}var k=Eo;function Co(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=Co;var Fo=Array.isArray,g=Fo;var No=1/0,te=b?b.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(g(t))return Qt(t,re)+"";if(k(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-No?"-0":e}var oe=re;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var w=Mo;function Ro(t){return t}var ae=Ro;var Bo="[object AsyncFunction]",Lo="[object Function]",ko="[object GeneratorFunction]",Uo="[object Proxy]";function Do(t){if(!w(t))return!1;var e=O(t);return e==Lo||e==ko||e==Bo||e==Uo}var ct=Do;var zo=c["__core-js_shared__"],ht=zo;var ie=function(){var t=/[^.]+$/.exec(ht&&ht.keys&&ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Go(t){return!!ie&&ie in t}var se=Go;var Wo=Function.prototype,Ko=Wo.toString;function $o(t){if(t!=null){try{return Ko.call(t)}catch{}try{return t+""}catch{}}return""}var A=$o;var Ho=/[\\^$.*+?()[\]{}|]/g,Vo=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Zo=qo.toString,Jo=Yo.hasOwnProperty,Xo=RegExp("^"+Zo.call(Jo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qo(t){if(!w(t)||se(t))return!1;var e=ct(t)?Xo:Vo;return e.test(A(t))}var ne=Qo;function ta(t,e){return t==null?void 0:t[e]}var fe=ta;function ea(t,e){var r=fe(t,e);return ne(r)?r:void 0}var y=ea;var ra=y(c,"WeakMap"),xt=ra;var pe=Object.create,oa=function(){function t(){}return function(e){if(!w(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=oa;function aa(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=aa;function ia(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=ia;var sa=800,na=16,fa=Date.now;function pa(t){var e=0,r=0;return function(){var o=fa(),a=na-(o-r);if(r=o,a>0){if(++e>=sa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=pa;function la(t){return function(){return t}}var ce=la;var ma=function(){try{var t=y(Object,"defineProperty");return t({},"",{}),t}catch{}}(),U=ma;var ua=U?function(t,e){return U(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ua;var da=de(he),xe=da;function ca(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=ca;var ha=9007199254740991,xa=/^(?:0|[1-9]\d*)$/;function ga(t,e){var r=typeof t;return e=e==null?ha:e,!!e&&(r=="number"||r!="symbol"&&xa.test(t))&&t>-1&&t%1==0&&t<e}var D=ga;function ba(t,e,r){e=="__proto__"&&U?U(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var gt=ba;function ya(t,e){return t===e||t!==t&&e!==e}var bt=ya;var va=Object.prototype,wa=va.hasOwnProperty;function Ta(t,e,r){var o=t[e];(!(wa.call(t,e)&&bt(o,r))||r===void 0&&!(e in t))&&gt(t,e,r)}var z=Ta;function Oa(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],d=o?o(r[n],t[n],n,r,t):void 0;d===void 0&&(d=t[n]),a?gt(r,n,d):z(r,n,d)}return r}var I=Oa;var be=Math.max;function ja(t,e,r){return e=be(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=be(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),me(t,this,n)}}var ye=ja;var Aa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Aa}var G=Pa;function Sa(t){return t!=null&&G(t.length)&&!ct(t)}var yt=Sa;var Ia=Object.prototype;function _a(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ia;return t===r}var W=_a;function Ea(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=Ea;var Ca="[object Arguments]";function Fa(t){return T(t)&&O(t)==Ca}var Nt=Fa;var we=Object.prototype,Na=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Ra=Nt(function(){return arguments}())?Nt:function(t){return T(t)&&Na.call(t,"callee")&&!Ma.call(t,"callee")},K=Ra;function Ba(){return!1}var Te=Ba;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,La=Oe&&Oe.exports===Ae,je=La?c.Buffer:void 0,ka=je?je.isBuffer:void 0,Ua=ka||Te,vt=Ua;var Da="[object Arguments]",za="[object Array]",Ga="[object Boolean]",Wa="[object Date]",Ka="[object Error]",$a="[object Function]",Ha="[object Map]",Va="[object Number]",qa="[object Object]",Ya="[object RegExp]",Za="[object Set]",Ja="[object String]",Xa="[object WeakMap]",Qa="[object ArrayBuffer]",ti="[object DataView]",ei="[object Float32Array]",ri="[object Float64Array]",oi="[object Int8Array]",ai="[object Int16Array]",ii="[object Int32Array]",si="[object Uint8Array]",ni="[object Uint8ClampedArray]",fi="[object Uint16Array]",pi="[object Uint32Array]",u={};u[ei]=u[ri]=u[oi]=u[ai]=u[ii]=u[si]=u[ni]=u[fi]=u[pi]=!0;u[Da]=u[za]=u[Qa]=u[Ga]=u[ti]=u[Wa]=u[Ka]=u[$a]=u[Ha]=u[Va]=u[qa]=u[Ya]=u[Za]=u[Ja]=u[Xa]=!1;function li(t){return T(t)&&G(t.length)&&!!u[O(t)]}var Pe=li;function mi(t){return function(e){return t(e)}}var $=mi;var Se=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nt=Se&&typeof module=="object"&&module&&!module.nodeType&&module,ui=nt&&nt.exports===Se,Mt=ui&&dt.process,di=function(){try{var t=nt&&nt.require&&nt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch{}}(),P=di;var Ie=P&&P.isTypedArray,ci=Ie?$(Ie):Pe,_e=ci;var hi=Object.prototype,xi=hi.hasOwnProperty;function gi(t,e){var r=g(t),o=!r&&K(t),a=!r&&!o&&vt(t),s=!r&&!o&&!a&&_e(t),i=r||o||a||s,n=i?ve(t.length,String):[],d=n.length;for(var h in t)(e||xi.call(t,h))&&!(i&&(h=="length"||a&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||D(h,d)))&&n.push(h);return n}var wt=gi;function bi(t,e){return function(r){return t(e(r))}}var Tt=bi;var yi=Tt(Object.keys,Object),Ee=yi;var vi=Object.prototype,wi=vi.hasOwnProperty;function Ti(t){if(!W(t))return Ee(t);var e=[];for(var r in Object(t))wi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=Ti;function Oi(t){return yt(t)?wt(t):Ce(t)}var H=Oi;function ji(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=ji;var Ai=Object.prototype,Pi=Ai.hasOwnProperty;function Si(t){if(!w(t))return Fe(t);var e=W(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Ne=Si;function Ii(t){return yt(t)?wt(t,!0):Ne(t)}var V=Ii;var _i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ei=/^\w*$/;function Ci(t,e){if(g(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||k(t)?!0:Ei.test(t)||!_i.test(t)||e!=null&&t in Object(e)}var Me=Ci;var Fi=y(Object,"create"),S=Fi;function Ni(){this.__data__=S?S(null):{},this.size=0}var Re=Ni;function Mi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Mi;var Ri="__lodash_hash_undefined__",Bi=Object.prototype,Li=Bi.hasOwnProperty;function ki(t){var e=this.__data__;if(S){var r=e[t];return r===Ri?void 0:r}return Li.call(e,t)?e[t]:void 0}var Le=ki;var Ui=Object.prototype,Di=Ui.hasOwnProperty;function zi(t){var e=this.__data__;return S?e[t]!==void 0:Di.call(e,t)}var ke=zi;var Gi="__lodash_hash_undefined__";function Wi(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=S&&e===void 0?Gi:e,this}var Ue=Wi;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=Re;q.prototype.delete=Be;q.prototype.get=Le;q.prototype.has=ke;q.prototype.set=Ue;var Rt=q;function Ki(){this.__data__=[],this.size=0}var De=Ki;function $i(t,e){for(var r=t.length;r--;)if(bt(t[r][0],e))return r;return-1}var _=$i;var Hi=Array.prototype,Vi=Hi.splice;function qi(t){var e=this.__data__,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 ze=qi;function Yi(t){var e=this.__data__,r=_(e,t);return r<0?void 0:e[r][1]}var Ge=Yi;function Zi(t){return _(this.__data__,t)>-1}var We=Zi;function Ji(t,e){var r=this.__data__,o=_(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Ke=Ji;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=De;Y.prototype.delete=ze;Y.prototype.get=Ge;Y.prototype.has=We;Y.prototype.set=Ke;var E=Y;var Xi=y(c,"Map"),C=Xi;function Qi(){this.size=0,this.__data__={hash:new Rt,map:new(C||E),string:new Rt}}var $e=Qi;function ts(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var He=ts;function es(t,e){var r=t.__data__;return He(e)?r[typeof e=="string"?"string":"hash"]:r.map}var F=es;function rs(t){var e=F(this,t).delete(t);return this.size-=e?1:0,e}var Ve=rs;function os(t){return F(this,t).get(t)}var qe=os;function as(t){return F(this,t).has(t)}var Ye=as;function is(t,e){var r=F(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=is;function Z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Z.prototype.clear=$e;Z.prototype.delete=Ve;Z.prototype.get=qe;Z.prototype.has=Ye;Z.prototype.set=Ze;var ft=Z;var ss="Expected a function";function Bt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ss);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Bt.Cache||ft),r}Bt.Cache=ft;var Je=Bt;var ns=500;function fs(t){var e=Je(t,function(o){return r.size===ns&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ps=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ls=/\\(\\)?/g,ms=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ps,function(r,o,a,s){e.push(a?s.replace(ls,"$1"):o||r)}),e}),Qe=ms;function us(t){return t==null?"":oe(t)}var tr=us;function ds(t,e){return g(t)?t:Me(t,e)?[t]:Qe(tr(t))}var N=ds;var cs=1/0;function hs(t){if(typeof t=="string"||k(t))return t;var e=t+"";return e=="0"&&1/t==-cs?"-0":e}var J=hs;function xs(t,e){e=N(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[J(e[r++])];return r&&r==o?t:void 0}var er=xs;function gs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var X=gs;var rr=b?b.isConcatSpreadable:void 0;function bs(t){return g(t)||K(t)||!!(rr&&t&&t[rr])}var or=bs;function ar(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=or),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?ar(n,e-1,r,o,a):X(a,n):o||(a[a.length]=n)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function vs(t){return xe(ye(t,void 0,sr),t+"")}var nr=vs;var ws=Tt(Object.getPrototypeOf,Object),Ot=ws;function Ts(){this.__data__=new E,this.size=0}var fr=Ts;function Os(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Os;function js(t){return this.__data__.get(t)}var lr=js;function As(t){return this.__data__.has(t)}var mr=As;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!C||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ft(o)}return r.set(t,e),this.size=r.size,this}var ur=Ss;function Q(t){var e=this.__data__=new E(t);this.size=e.size}Q.prototype.clear=fr;Q.prototype.delete=pr;Q.prototype.get=lr;Q.prototype.has=mr;Q.prototype.set=ur;var dr=Q;function Is(t,e){return t&&I(e,H(e),t)}var cr=Is;function _s(t,e){return t&&I(e,V(e),t)}var hr=_s;var yr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=yr&&typeof module=="object"&&module&&!module.nodeType&&module,Es=xr&&xr.exports===yr,gr=Es?c.Buffer:void 0,br=gr?gr.allocUnsafe:void 0;function Cs(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 vr=Cs;function Fs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var wr=Fs;function Ns(){return[]}var jt=Ns;var Ms=Object.prototype,Rs=Ms.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Bs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Rs.call(t,e)}))}:jt,tt=Bs;function Ls(t,e){return I(t,tt(t),e)}var Or=Ls;var ks=Object.getOwnPropertySymbols,Us=ks?function(t){for(var e=[];t;)X(e,tt(t)),t=Ot(t);return e}:jt,At=Us;function Ds(t,e){return I(t,At(t),e)}var jr=Ds;function zs(t,e,r){var o=e(t);return g(t)?o:X(o,r(t))}var Pt=zs;function Gs(t){return Pt(t,H,tt)}var Ar=Gs;function Ws(t){return Pt(t,V,At)}var Pr=Ws;var Ks=y(c,"DataView"),St=Ks;var $s=y(c,"Promise"),It=$s;var Hs=y(c,"Set"),_t=Hs;var Sr="[object Map]",Vs="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=A(St),Ys=A(C),Zs=A(It),Js=A(_t),Xs=A(xt),B=O;(St&&B(new St(new ArrayBuffer(1)))!=Cr||C&&B(new C)!=Sr||It&&B(It.resolve())!=Ir||_t&&B(new _t)!=_r||xt&&B(new xt)!=Er)&&(B=function(t){var e=O(t),r=e==Vs?t.constructor:void 0,o=r?A(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Sr;case Zs:return Ir;case Js:return _r;case Xs:return Er}return e});var et=B;var Qs=Object.prototype,tn=Qs.hasOwnProperty;function en(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&tn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Fr=en;var rn=c.Uint8Array,Lt=rn;function on(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var rt=on;function an(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Nr=an;var sn=/\w*$/;function nn(t){var e=new t.constructor(t.source,sn.exec(t));return e.lastIndex=t.lastIndex,e}var Mr=nn;var Rr=b?b.prototype:void 0,Br=Rr?Rr.valueOf:void 0;function fn(t){return Br?Object(Br.call(t)):{}}var Lr=fn;function pn(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var kr=pn;var ln="[object Boolean]",mn="[object Date]",un="[object Map]",dn="[object Number]",cn="[object RegExp]",hn="[object Set]",xn="[object String]",gn="[object Symbol]",bn="[object ArrayBuffer]",yn="[object DataView]",vn="[object Float32Array]",wn="[object Float64Array]",Tn="[object Int8Array]",On="[object Int16Array]",jn="[object Int32Array]",An="[object Uint8Array]",Pn="[object Uint8ClampedArray]",Sn="[object Uint16Array]",In="[object Uint32Array]";function _n(t,e,r){var o=t.constructor;switch(e){case bn:return rt(t);case ln:case mn:return new o(+t);case yn:return Nr(t,r);case vn:case wn:case Tn:case On:case jn:case An:case Pn:case Sn:case In:return kr(t,r);case un:return new o;case dn:case xn:return new o(t);case cn:return Mr(t);case hn:return new o;case gn:return Lr(t)}}var Ur=_n;function En(t){return typeof t.constructor=="function"&&!W(t)?le(Ot(t)):{}}var Dr=En;var Cn="[object Map]";function Fn(t){return T(t)&&et(t)==Cn}var zr=Fn;var Gr=P&&P.isMap,Nn=Gr?$(Gr):zr,Wr=Nn;var Mn="[object Set]";function Rn(t){return T(t)&&et(t)==Mn}var Kr=Rn;var $r=P&&P.isSet,Bn=$r?$($r):Kr,Hr=Bn;var Ln=1,kn=2,Un=4,Vr="[object Arguments]",Dn="[object Array]",zn="[object Boolean]",Gn="[object Date]",Wn="[object Error]",qr="[object Function]",Kn="[object GeneratorFunction]",$n="[object Map]",Hn="[object Number]",Yr="[object Object]",Vn="[object RegExp]",qn="[object Set]",Yn="[object String]",Zn="[object Symbol]",Jn="[object WeakMap]",Xn="[object ArrayBuffer]",Qn="[object DataView]",tf="[object Float32Array]",ef="[object Float64Array]",rf="[object Int8Array]",of="[object Int16Array]",af="[object Int32Array]",sf="[object Uint8Array]",nf="[object Uint8ClampedArray]",ff="[object Uint16Array]",pf="[object Uint32Array]",m={};m[Vr]=m[Dn]=m[Xn]=m[Qn]=m[zn]=m[Gn]=m[tf]=m[ef]=m[rf]=m[of]=m[af]=m[$n]=m[Hn]=m[Yr]=m[Vn]=m[qn]=m[Yn]=m[Zn]=m[sf]=m[nf]=m[ff]=m[pf]=!0;m[Wn]=m[qr]=m[Jn]=!1;function Et(t,e,r,o,a,s){var i,n=e&Ln,d=e&kn,h=e&Un;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!w(t))return t;var x=g(t);if(x){if(i=Fr(t),!n)return ue(t,i)}else{var j=et(t),pt=j==qr||j==Kn;if(vt(t))return vr(t,n);if(j==Yr||j==Vr||pt&&!a){if(i=d||pt?{}:Dr(t),!n)return d?jr(t,hr(i,t)):Or(t,cr(i,t))}else{if(!m[j])return a?t:{};i=Ur(t,j,n)}}s||(s=new dr);var at=s.get(t);if(at)return at;s.set(t,i),Hr(t)?t.forEach(function(v){i.add(Et(v,e,r,v,t,s))}):Wr(t)&&t.forEach(function(v,f){i.set(f,Et(v,e,r,f,t,s))});var lt=h?d?Pr:Ar:d?V:H,mt=x?void 0:lt(t);return ge(mt||t,function(v,f){mt&&(f=v,v=t[f]),z(i,f,Et(v,e,r,f,t,s))}),i}var Zr=Et;var lf=1,mf=4;function uf(t){return Zr(t,lf|mf)}var kt=uf;function df(t,e){return t!=null&&e in Object(t)}var Jr=df;function cf(t,e,r){e=N(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=J(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&G(a)&&D(i,a)&&(g(t)||K(t)))}var Xr=cf;function hf(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=hf;function xf(t,e,r,o){if(!w(t))return t;e=N(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var d=J(e[a]),h=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(a!=i){var x=n[d];h=o?o(x,d,n):void 0,h===void 0&&(h=w(x)?x:D(e[a+1])?[]:{})}z(n,d,h),n=n[d]}return t}var to=xf;function gf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=er(t,i);r(n,i)&&to(s,N(i,t),n)}return s}var eo=gf;function bf(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=bf;var yf=nr(function(t,e){return t==null?{}:ro(t,e)}),Ct=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 ao="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Ut=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ao[r[t]&63];return e};var vf="array",wf="bit",io="bits",Tf="byte",so="bytes",ot="",Of="exponent",jf="function",no="iec",Af="Invalid number",Pf="Invalid rounding method",Dt="jedec",Sf="object",fo=".",If="round",_f="s",Ef="si",Cf="kbit",Ff="kB",Nf=" ",Mf="string",Rf="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=ot,localeOptions:i={},separator:n=ot,spacer:d=Nf,symbols:h={},standard:x=ot,output:j=Mf,fullform:pt=!1,fullforms:at=[],exponent:lt=-1,roundingMethod:mt=If,precision:v=0}={}){let f=lt,L=Number(t),l=[],R=0,Ft=ot;x===Ef?(o=10,x=Dt):x===no||x===Dt?o=2:o===2?x=no:(o=10,x=Dt);let ut=o===10?1e3:1024,lo=pt===!0,Wt=L<0,Kt=Math[mt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Af);if(typeof Kt!==jf)throw new TypeError(Pf);if(Wt&&(L=-L),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(L)/Math.log(ut)),f<0&&(f=0)),f>8&&(v>0&&(v+=8-f),f=8),j===Of)return f;if(L===0)l[0]=0,Ft=l[1]=zt.symbol[x][e?io:so][f];else{R=L/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(R=R*8,R>=ut&&f<8&&(R=R/ut,f++));let it=Math.pow(10,f>0?a:0);l[0]=Kt(R*it)/it,l[0]===ut&&f<8&&lt===-1&&(l[0]=1,f++),Ft=l[1]=o===10&&f===1?e?Cf:Ff:zt.symbol[x][e?io:so][f]}if(Wt&&(l[0]=-l[0]),v>0&&(l[0]=l[0].toPrecision(v)),l[1]=h[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,i):n.length>0&&(l[0]=l[0].toString().replace(fo,n)),r&&a>0){let it=l[0].toString(),$t=n||(it.match(/(\D)/g)||[]).pop()||fo,Ht=it.toString().split($t),Vt=Ht[1]||ot,qt=Vt.length,mo=a-qt;l[0]=`${Ht[0]}${$t}${Vt.padEnd(qt+mo,Rf)}`}return lo&&(l[1]=at[f]?at[f]:zt.fullform[x][f]+(e?wf:Tf)+(l[0]===1?ot:_f)),j===vf?l:j===Sf?{value:l[0],symbol:l[1],exponent:f,unit:Ft}:l.join(d)}var M=class t{constructor(e){p(this,"_tera");p(this,"id");p(this,"sbId");p(this,"name");p(this,"icon");p(this,"path");p(this,"url");p(this,"teraUrl");p(this,"parsedName");p(this,"created");p(this,"createdFormatted");p(this,"modified");p(this,"modifiedFormatted");p(this,"accessed");p(this,"accessedFormatted");p(this,"size");p(this,"sizeFormatted");p(this,"mime");p(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=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(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Ct(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Ct(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var Gt=class{constructor(e){p(this,"settings",{session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null});p(this,"events",oo());p(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});p(this,"methods",["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"]);p(this,"plugins",[]);p(this,"namespaces",{});p(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(),...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 Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):(r==null?void 0:r.action)=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):(r==null?void 0:r.action)=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r!=null&&r.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>{var o;return(o=this.settings).session||(o.session="tfy-"+this.getEntropicString(16))}).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).then(()=>r).catch(o=>(this.debug("WARN",0,"Init process fault",o),r))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),d=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(d,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o()).catch(a)};d()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
- `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(s=>Object.getOwnPropertyNames(s).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){var r;return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),(r=this.dom)!=null&&r.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new M({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new M({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new M({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new M({tera:this,...r}))}};export{Gt as default};
1
+ var mo=typeof global=="object"&&global&&global.Object===Object&&global,ut=mo;var uo=typeof self=="object"&&self&&self.Object===Object&&self,co=ut||uo||Function("return this")(),d=co;var ho=d.Symbol,g=ho;var qt=Object.prototype,xo=qt.hasOwnProperty,go=qt.toString,it=g?g.toStringTag:void 0;function yo(t){var e=xo.call(t,it),r=t[it];try{t[it]=void 0;var o=!0}catch{}var a=go.call(t);return o&&(e?t[it]=r:delete t[it]),a}var Yt=yo;var bo=Object.prototype,vo=bo.toString;function wo(t){return vo.call(t)}var Zt=wo;var To="[object Null]",Po="[object Undefined]",Jt=g?g.toStringTag:void 0;function jo(t){return t==null?t===void 0?Po:To:Jt&&Jt in Object(t)?Yt(t):Zt(t)}var T=jo;function Ao(t){return t!=null&&typeof t=="object"}var w=Ao;var Oo="[object Symbol]";function So(t){return typeof t=="symbol"||w(t)&&T(t)==Oo}var B=So;function Io(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Xt=Io;var _o=Array.isArray,x=_o;var Eo=1/0,Qt=g?g.prototype:void 0,te=Qt?Qt.toString:void 0;function ee(t){if(typeof t=="string")return t;if(x(t))return Xt(t,ee)+"";if(B(t))return te?te.call(t):"";var e=t+"";return e=="0"&&1/t==-Eo?"-0":e}var re=ee;function Fo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=Fo;function Co(t){return t}var oe=Co;var No="[object AsyncFunction]",Mo="[object Function]",Ro="[object GeneratorFunction]",Lo="[object Proxy]";function Bo(t){if(!v(t))return!1;var e=T(t);return e==Mo||e==Ro||e==No||e==Lo}var dt=Bo;var ko=d["__core-js_shared__"],ct=ko;var ae=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Uo(t){return!!ae&&ae in t}var ie=Uo;var Do=Function.prototype,zo=Do.toString;function Go(t){if(t!=null){try{return zo.call(t)}catch{}try{return t+""}catch{}}return""}var j=Go;var Wo=/[\\^$.*+?()[\]{}|]/g,Ko=/^\[object .+?Constructor\]$/,$o=Function.prototype,Ho=Object.prototype,Vo=$o.toString,qo=Ho.hasOwnProperty,Yo=RegExp("^"+Vo.call(qo).replace(Wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zo(t){if(!v(t)||ie(t))return!1;var e=dt(t)?Yo:Ko;return e.test(j(t))}var se=Zo;function Jo(t,e){return t==null?void 0:t[e]}var ne=Jo;function Xo(t,e){var r=ne(t,e);return se(r)?r:void 0}var y=Xo;var Qo=y(d,"WeakMap"),ht=Qo;var fe=Object.create,ta=function(){function t(){}return function(e){if(!v(e))return{};if(fe)return fe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),pe=ta;function ea(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var le=ea;function ra(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var me=ra;var oa=800,aa=16,ia=Date.now;function sa(t){var e=0,r=0;return function(){var o=ia(),a=aa-(o-r);if(r=o,a>0){if(++e>=oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ue=sa;function na(t){return function(){return t}}var de=na;var fa=function(){try{var t=y(Object,"defineProperty");return t({},"",{}),t}catch{}}(),k=fa;var pa=k?function(t,e){return k(t,"toString",{configurable:!0,enumerable:!1,value:de(e),writable:!0})}:oe,ce=pa;var la=ue(ce),he=la;function ma(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var xe=ma;var ua=9007199254740991,da=/^(?:0|[1-9]\d*)$/;function ca(t,e){var r=typeof t;return e=e==null?ua:e,!!e&&(r=="number"||r!="symbol"&&da.test(t))&&t>-1&&t%1==0&&t<e}var U=ca;function ha(t,e,r){e=="__proto__"&&k?k(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ha;function xa(t,e){return t===e||t!==t&&e!==e}var gt=xa;var ga=Object.prototype,ya=ga.hasOwnProperty;function ba(t,e,r){var o=t[e];(!(ya.call(t,e)&&gt(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var D=ba;function va(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],u=o?o(r[n],t[n],n,r,t):void 0;u===void 0&&(u=t[n]),a?xt(r,n,u):D(r,n,u)}return r}var S=va;var ge=Math.max;function wa(t,e,r){return e=ge(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ge(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),le(t,this,n)}}var ye=wa;var Ta=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ta}var z=Pa;function ja(t){return t!=null&&z(t.length)&&!dt(t)}var yt=ja;var Aa=Object.prototype;function Oa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var G=Oa;function Sa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var be=Sa;var Ia="[object Arguments]";function _a(t){return w(t)&&T(t)==Ia}var Ct=_a;var ve=Object.prototype,Ea=ve.hasOwnProperty,Fa=ve.propertyIsEnumerable,Ca=Ct(function(){return arguments}())?Ct:function(t){return w(t)&&Ea.call(t,"callee")&&!Fa.call(t,"callee")},W=Ca;function Na(){return!1}var we=Na;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ma=Te&&Te.exports===je,Pe=Ma?d.Buffer:void 0,Ra=Pe?Pe.isBuffer:void 0,La=Ra||we,bt=La;var Ba="[object Arguments]",ka="[object Array]",Ua="[object Boolean]",Da="[object Date]",za="[object Error]",Ga="[object Function]",Wa="[object Map]",Ka="[object Number]",$a="[object Object]",Ha="[object RegExp]",Va="[object Set]",qa="[object String]",Ya="[object WeakMap]",Za="[object ArrayBuffer]",Ja="[object DataView]",Xa="[object Float32Array]",Qa="[object Float64Array]",ti="[object Int8Array]",ei="[object Int16Array]",ri="[object Int32Array]",oi="[object Uint8Array]",ai="[object Uint8ClampedArray]",ii="[object Uint16Array]",si="[object Uint32Array]",m={};m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=m[ai]=m[ii]=m[si]=!0;m[Ba]=m[ka]=m[Za]=m[Ua]=m[Ja]=m[Da]=m[za]=m[Ga]=m[Wa]=m[Ka]=m[$a]=m[Ha]=m[Va]=m[qa]=m[Ya]=!1;function ni(t){return w(t)&&z(t.length)&&!!m[T(t)]}var Ae=ni;function fi(t){return function(e){return t(e)}}var K=fi;var Oe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Oe&&typeof module=="object"&&module&&!module.nodeType&&module,pi=st&&st.exports===Oe,Nt=pi&&ut.process,li=function(){try{var t=st&&st.require&&st.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),A=li;var Se=A&&A.isTypedArray,mi=Se?K(Se):Ae,Ie=mi;var ui=Object.prototype,di=ui.hasOwnProperty;function ci(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&Ie(t),i=r||o||a||s,n=i?be(t.length,String):[],u=n.length;for(var c in t)(e||di.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||U(c,u)))&&n.push(c);return n}var vt=ci;function hi(t,e){return function(r){return t(e(r))}}var wt=hi;var xi=wt(Object.keys,Object),_e=xi;var gi=Object.prototype,yi=gi.hasOwnProperty;function bi(t){if(!G(t))return _e(t);var e=[];for(var r in Object(t))yi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ee=bi;function vi(t){return yt(t)?vt(t):Ee(t)}var $=vi;function wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=wi;var Ti=Object.prototype,Pi=Ti.hasOwnProperty;function ji(t){if(!v(t))return Fe(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Ce=ji;function Ai(t){return yt(t)?vt(t,!0):Ce(t)}var H=Ai;var Oi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/;function Ii(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||B(t)?!0:Si.test(t)||!Oi.test(t)||e!=null&&t in Object(e)}var Ne=Ii;var _i=y(Object,"create"),O=_i;function Ei(){this.__data__=O?O(null):{},this.size=0}var Me=Ei;function Fi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re=Fi;var Ci="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Ri(t){var e=this.__data__;if(O){var r=e[t];return r===Ci?void 0:r}return Mi.call(e,t)?e[t]:void 0}var Le=Ri;var Li=Object.prototype,Bi=Li.hasOwnProperty;function ki(t){var e=this.__data__;return O?e[t]!==void 0:Bi.call(e,t)}var Be=ki;var Ui="__lodash_hash_undefined__";function Di(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=O&&e===void 0?Ui:e,this}var ke=Di;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=Me;V.prototype.delete=Re;V.prototype.get=Le;V.prototype.has=Be;V.prototype.set=ke;var Mt=V;function zi(){this.__data__=[],this.size=0}var Ue=zi;function Gi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var I=Gi;var Wi=Array.prototype,Ki=Wi.splice;function $i(t){var e=this.__data__,r=I(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ki.call(e,r,1),--this.size,!0}var De=$i;function Hi(t){var e=this.__data__,r=I(e,t);return r<0?void 0:e[r][1]}var ze=Hi;function Vi(t){return I(this.__data__,t)>-1}var Ge=Vi;function qi(t,e){var r=this.__data__,o=I(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=qi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Ue;q.prototype.delete=De;q.prototype.get=ze;q.prototype.has=Ge;q.prototype.set=We;var _=q;var Yi=y(d,"Map"),E=Yi;function Zi(){this.size=0,this.__data__={hash:new Mt,map:new(E||_),string:new Mt}}var Ke=Zi;function Ji(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Ji;function Xi(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var F=Xi;function Qi(t){var e=F(this,t).delete(t);return this.size-=e?1:0,e}var He=Qi;function ts(t){return F(this,t).get(t)}var Ve=ts;function es(t){return F(this,t).has(t)}var qe=es;function rs(t,e){var r=F(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ye=rs;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ke;Y.prototype.delete=He;Y.prototype.get=Ve;Y.prototype.has=qe;Y.prototype.set=Ye;var nt=Y;var os="Expected a function";function Rt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Rt.Cache||nt),r}Rt.Cache=nt;var Ze=Rt;var as=500;function is(t){var e=Ze(t,function(o){return r.size===as&&r.clear(),o}),r=e.cache;return e}var Je=is;var ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/\\(\\)?/g,fs=Je(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ss,function(r,o,a,s){e.push(a?s.replace(ns,"$1"):o||r)}),e}),Xe=fs;function ps(t){return t==null?"":re(t)}var Qe=ps;function ls(t,e){return x(t)?t:Ne(t,e)?[t]:Xe(Qe(t))}var C=ls;var ms=1/0;function us(t){if(typeof t=="string"||B(t))return t;var e=t+"";return e=="0"&&1/t==-ms?"-0":e}var Z=us;function ds(t,e){e=C(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[Z(e[r++])];return r&&r==o?t:void 0}var tr=ds;function cs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=cs;var er=g?g.isConcatSpreadable:void 0;function hs(t){return x(t)||W(t)||!!(er&&t&&t[er])}var rr=hs;function or(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=rr),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?or(n,e-1,r,o,a):J(a,n):o||(a[a.length]=n)}return a}var ar=or;function xs(t){var e=t==null?0:t.length;return e?ar(t,1):[]}var ir=xs;function gs(t){return he(ye(t,void 0,ir),t+"")}var sr=gs;var ys=wt(Object.getPrototypeOf,Object),Tt=ys;function bs(){this.__data__=new _,this.size=0}var nr=bs;function vs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var fr=vs;function ws(t){return this.__data__.get(t)}var pr=ws;function Ts(t){return this.__data__.has(t)}var lr=Ts;var Ps=200;function js(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!E||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new nt(o)}return r.set(t,e),this.size=r.size,this}var mr=js;function X(t){var e=this.__data__=new _(t);this.size=e.size}X.prototype.clear=nr;X.prototype.delete=fr;X.prototype.get=pr;X.prototype.has=lr;X.prototype.set=mr;var ur=X;function As(t,e){return t&&S(e,$(e),t)}var dr=As;function Os(t,e){return t&&S(e,H(e),t)}var cr=Os;var yr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hr=yr&&typeof module=="object"&&module&&!module.nodeType&&module,Ss=hr&&hr.exports===yr,xr=Ss?d.Buffer:void 0,gr=xr?xr.allocUnsafe:void 0;function Is(t,e){if(e)return t.slice();var r=t.length,o=gr?gr(r):new t.constructor(r);return t.copy(o),o}var br=Is;function _s(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var vr=_s;function Es(){return[]}var Pt=Es;var Fs=Object.prototype,Cs=Fs.propertyIsEnumerable,wr=Object.getOwnPropertySymbols,Ns=wr?function(t){return t==null?[]:(t=Object(t),vr(wr(t),function(e){return Cs.call(t,e)}))}:Pt,Q=Ns;function Ms(t,e){return S(t,Q(t),e)}var Tr=Ms;var Rs=Object.getOwnPropertySymbols,Ls=Rs?function(t){for(var e=[];t;)J(e,Q(t)),t=Tt(t);return e}:Pt,jt=Ls;function Bs(t,e){return S(t,jt(t),e)}var Pr=Bs;function ks(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var At=ks;function Us(t){return At(t,$,Q)}var jr=Us;function Ds(t){return At(t,H,jt)}var Ar=Ds;var zs=y(d,"DataView"),Ot=zs;var Gs=y(d,"Promise"),St=Gs;var Ws=y(d,"Set"),It=Ws;var Or="[object Map]",Ks="[object Object]",Sr="[object Promise]",Ir="[object Set]",_r="[object WeakMap]",Er="[object DataView]",$s=j(Ot),Hs=j(E),Vs=j(St),qs=j(It),Ys=j(ht),R=T;(Ot&&R(new Ot(new ArrayBuffer(1)))!=Er||E&&R(new E)!=Or||St&&R(St.resolve())!=Sr||It&&R(new It)!=Ir||ht&&R(new ht)!=_r)&&(R=function(t){var e=T(t),r=e==Ks?t.constructor:void 0,o=r?j(r):"";if(o)switch(o){case $s:return Er;case Hs:return Or;case Vs:return Sr;case qs:return Ir;case Ys:return _r}return e});var tt=R;var Zs=Object.prototype,Js=Zs.hasOwnProperty;function Xs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Js.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Fr=Xs;var Qs=d.Uint8Array,Lt=Qs;function tn(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var et=tn;function en(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Cr=en;var rn=/\w*$/;function on(t){var e=new t.constructor(t.source,rn.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=on;var Mr=g?g.prototype:void 0,Rr=Mr?Mr.valueOf:void 0;function an(t){return Rr?Object(Rr.call(t)):{}}var Lr=an;function sn(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Br=sn;var nn="[object Boolean]",fn="[object Date]",pn="[object Map]",ln="[object Number]",mn="[object RegExp]",un="[object Set]",dn="[object String]",cn="[object Symbol]",hn="[object ArrayBuffer]",xn="[object DataView]",gn="[object Float32Array]",yn="[object Float64Array]",bn="[object Int8Array]",vn="[object Int16Array]",wn="[object Int32Array]",Tn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",jn="[object Uint16Array]",An="[object Uint32Array]";function On(t,e,r){var o=t.constructor;switch(e){case hn:return et(t);case nn:case fn:return new o(+t);case xn:return Cr(t,r);case gn:case yn:case bn:case vn:case wn:case Tn:case Pn:case jn:case An:return Br(t,r);case pn:return new o;case ln:case dn:return new o(t);case mn:return Nr(t);case un:return new o;case cn:return Lr(t)}}var kr=On;function Sn(t){return typeof t.constructor=="function"&&!G(t)?pe(Tt(t)):{}}var Ur=Sn;var In="[object Map]";function _n(t){return w(t)&&tt(t)==In}var Dr=_n;var zr=A&&A.isMap,En=zr?K(zr):Dr,Gr=En;var Fn="[object Set]";function Cn(t){return w(t)&&tt(t)==Fn}var Wr=Cn;var Kr=A&&A.isSet,Nn=Kr?K(Kr):Wr,$r=Nn;var Mn=1,Rn=2,Ln=4,Hr="[object Arguments]",Bn="[object Array]",kn="[object Boolean]",Un="[object Date]",Dn="[object Error]",Vr="[object Function]",zn="[object GeneratorFunction]",Gn="[object Map]",Wn="[object Number]",qr="[object Object]",Kn="[object RegExp]",$n="[object Set]",Hn="[object String]",Vn="[object Symbol]",qn="[object WeakMap]",Yn="[object ArrayBuffer]",Zn="[object DataView]",Jn="[object Float32Array]",Xn="[object Float64Array]",Qn="[object Int8Array]",tf="[object Int16Array]",ef="[object Int32Array]",rf="[object Uint8Array]",of="[object Uint8ClampedArray]",af="[object Uint16Array]",sf="[object Uint32Array]",l={};l[Hr]=l[Bn]=l[Yn]=l[Zn]=l[kn]=l[Un]=l[Jn]=l[Xn]=l[Qn]=l[tf]=l[ef]=l[Gn]=l[Wn]=l[qr]=l[Kn]=l[$n]=l[Hn]=l[Vn]=l[rf]=l[of]=l[af]=l[sf]=!0;l[Dn]=l[Vr]=l[qn]=!1;function _t(t,e,r,o,a,s){var i,n=e&Mn,u=e&Rn,c=e&Ln;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!v(t))return t;var h=x(t);if(h){if(i=Fr(t),!n)return me(t,i)}else{var P=tt(t),ft=P==Vr||P==zn;if(bt(t))return br(t,n);if(P==qr||P==Hr||ft&&!a){if(i=u||ft?{}:Ur(t),!n)return u?Pr(t,cr(i,t)):Tr(t,dr(i,t))}else{if(!l[P])return a?t:{};i=kr(t,P,n)}}s||(s=new ur);var ot=s.get(t);if(ot)return ot;s.set(t,i),$r(t)?t.forEach(function(b){i.add(_t(b,e,r,b,t,s))}):Gr(t)&&t.forEach(function(b,f){i.set(f,_t(b,e,r,f,t,s))});var pt=c?u?Ar:jr:u?H:$,lt=h?void 0:pt(t);return xe(lt||t,function(b,f){lt&&(f=b,b=t[f]),D(i,f,_t(b,e,r,f,t,s))}),i}var Yr=_t;var nf=1,ff=4;function pf(t){return Yr(t,nf|ff)}var Bt=pf;function lf(t,e){return t!=null&&e in Object(t)}var Zr=lf;function mf(t,e,r){e=C(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=Z(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&z(a)&&U(i,a)&&(x(t)||W(t)))}var Jr=mf;function uf(t,e){return t!=null&&Jr(t,e,Zr)}var Xr=uf;function df(t,e,r,o){if(!v(t))return t;e=C(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var u=Z(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=n[u];c=o?o(h,u,n):void 0,c===void 0&&(c=v(h)?h:U(e[a+1])?[]:{})}D(n,u,c),n=n[u]}return t}var Qr=df;function cf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=tr(t,i);r(n,i)&&Qr(s,C(i,t),n)}return s}var to=cf;function hf(t,e){return to(t,e,function(r,o){return Xr(t,o)})}var eo=hf;var xf=sr(function(t,e){return t==null?{}:eo(t,e)}),Et=xf;function ro(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var oo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var kt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=oo[r[t]&63];return e};var gf="array",yf="bit",ao="bits",bf="byte",io="bytes",rt="",vf="exponent",wf="function",so="iec",Tf="Invalid number",Pf="Invalid rounding method",Ut="jedec",jf="object",no=".",Af="round",Of="s",Sf="si",If="kbit",_f="kB",Ef=" ",Ff="string",Cf="0",Dt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=rt,localeOptions:i={},separator:n=rt,spacer:u=Ef,symbols:c={},standard:h=rt,output:P=Ff,fullform:ft=!1,fullforms:ot=[],exponent:pt=-1,roundingMethod:lt=Af,precision:b=0}={}){let f=pt,L=Number(t),p=[],M=0,Ft=rt;h===Sf?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=ft===!0,Gt=L<0,Wt=Math[lt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Tf);if(typeof Wt!==wf)throw new TypeError(Pf);if(Gt&&(L=-L),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(L)/Math.log(mt)),f<0&&(f=0)),f>8&&(b>0&&(b+=8-f),f=8),P===vf)return f;if(L===0)p[0]=0,Ft=p[1]=Dt.symbol[h][e?ao:io][f];else{M=L/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(M=M*8,M>=mt&&f<8&&(M=M/mt,f++));let at=Math.pow(10,f>0?a:0);p[0]=Wt(M*at)/at,p[0]===mt&&f<8&&pt===-1&&(p[0]=1,f++),Ft=p[1]=o===10&&f===1?e?If:_f:Dt.symbol[h][e?ao:io][f]}if(Gt&&(p[0]=-p[0]),b>0&&(p[0]=p[0].toPrecision(b)),p[1]=c[p[1]]||p[1],s===!0?p[0]=p[0].toLocaleString():s.length>0?p[0]=p[0].toLocaleString(s,i):n.length>0&&(p[0]=p[0].toString().replace(no,n)),r&&a>0){let at=p[0].toString(),Kt=n||(at.match(/(\D)/g)||[]).pop()||no,$t=at.toString().split(Kt),Ht=$t[1]||rt,Vt=Ht.length,lo=a-Vt;p[0]=`${$t[0]}${Kt}${Ht.padEnd(Vt+lo,Cf)}`}return po&&(p[1]=ot[f]?ot[f]:Dt.fullform[h][f]+(e?yf:bf)+(p[0]===1?rt:Of)),P===gf?p:P===jf?{value:p[0],symbol:p[1],exponent:f,unit:Ft}:p.join(u)}var N=class t{constructor(e){this.meta={};if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){let r=Et(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]);return new t(r)}};var zt=class{constructor(e){this.settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};this.events=ro();this.dom={el:null,iframe:null,popup:null,stylesheet:null};this.methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];this.plugins=[];this.namespaces={};this.acceptPostboxes={};this.initPromise=null;e&&this.set(e)}send(e){let r=kt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||kt(),...Bt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):(r==null?void 0:r.action)=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):(r==null?void 0:r.action)=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r!=null&&r.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.initPromise)return this.initPromise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.initPromise=Promise.resolve().then(()=>{var o;return(o=this.settings).session||(o.session="tfy-"+this.getEntropicString(16))}).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths?this.settings.debugPaths=this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):this.settings.debugPaths=null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>(this.debug("INFO",4,"[6/6] Init complete"),r)).catch(o=>{throw this.debug("WARN",0,"Init process fault",o),o}),this.initPromise}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e(void 0)).catch(r)})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e(void 0)}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o(void 0)).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
+ `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(s=>Object.getOwnPropertyNames(s).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){var r;return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),(r=this.dom)!=null&&r.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new N({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new N({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new N({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new N({tera:this,...r}))}};export{zt 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
- var mo=typeof global=="object"&&global&&global.Object===Object&&global,ut=mo;var uo=typeof self=="object"&&self&&self.Object===Object&&self,co=ut||uo||Function("return this")(),d=co;var ho=d.Symbol,g=ho;var qt=Object.prototype,xo=qt.hasOwnProperty,go=qt.toString,it=g?g.toStringTag:void 0;function bo(t){var e=xo.call(t,it),r=t[it];try{t[it]=void 0;var o=!0}catch{}var a=go.call(t);return o&&(e?t[it]=r:delete t[it]),a}var Yt=bo;var yo=Object.prototype,vo=yo.toString;function wo(t){return vo.call(t)}var Zt=wo;var To="[object Null]",Oo="[object Undefined]",Jt=g?g.toStringTag:void 0;function jo(t){return t==null?t===void 0?Oo:To:Jt&&Jt in Object(t)?Yt(t):Zt(t)}var T=jo;function Ao(t){return t!=null&&typeof t=="object"}var w=Ao;var Po="[object Symbol]";function So(t){return typeof t=="symbol"||w(t)&&T(t)==Po}var L=So;function Io(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Xt=Io;var _o=Array.isArray,x=_o;var Eo=1/0,Qt=g?g.prototype:void 0,te=Qt?Qt.toString:void 0;function ee(t){if(typeof t=="string")return t;if(x(t))return Xt(t,ee)+"";if(L(t))return te?te.call(t):"";var e=t+"";return e=="0"&&1/t==-Eo?"-0":e}var re=ee;function Co(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=Co;function Fo(t){return t}var oe=Fo;var No="[object AsyncFunction]",Mo="[object Function]",Ro="[object GeneratorFunction]",Bo="[object Proxy]";function Lo(t){if(!v(t))return!1;var e=T(t);return e==Mo||e==Ro||e==No||e==Bo}var dt=Lo;var ko=d["__core-js_shared__"],ct=ko;var ae=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Uo(t){return!!ae&&ae in t}var ie=Uo;var Do=Function.prototype,zo=Do.toString;function Go(t){if(t!=null){try{return zo.call(t)}catch{}try{return t+""}catch{}}return""}var j=Go;var Wo=/[\\^$.*+?()[\]{}|]/g,Ko=/^\[object .+?Constructor\]$/,$o=Function.prototype,Ho=Object.prototype,Vo=$o.toString,qo=Ho.hasOwnProperty,Yo=RegExp("^"+Vo.call(qo).replace(Wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zo(t){if(!v(t)||ie(t))return!1;var e=dt(t)?Yo:Ko;return e.test(j(t))}var se=Zo;function Jo(t,e){return t?.[e]}var ne=Jo;function Xo(t,e){var r=ne(t,e);return se(r)?r:void 0}var b=Xo;var Qo=b(d,"WeakMap"),ht=Qo;var fe=Object.create,ta=function(){function t(){}return function(e){if(!v(e))return{};if(fe)return fe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),pe=ta;function ea(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var le=ea;function ra(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var me=ra;var oa=800,aa=16,ia=Date.now;function sa(t){var e=0,r=0;return function(){var o=ia(),a=aa-(o-r);if(r=o,a>0){if(++e>=oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ue=sa;function na(t){return function(){return t}}var de=na;var fa=function(){try{var t=b(Object,"defineProperty");return t({},"",{}),t}catch{}}(),k=fa;var pa=k?function(t,e){return k(t,"toString",{configurable:!0,enumerable:!1,value:de(e),writable:!0})}:oe,ce=pa;var la=ue(ce),he=la;function ma(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var xe=ma;var ua=9007199254740991,da=/^(?:0|[1-9]\d*)$/;function ca(t,e){var r=typeof t;return e=e??ua,!!e&&(r=="number"||r!="symbol"&&da.test(t))&&t>-1&&t%1==0&&t<e}var U=ca;function ha(t,e,r){e=="__proto__"&&k?k(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ha;function xa(t,e){return t===e||t!==t&&e!==e}var gt=xa;var ga=Object.prototype,ba=ga.hasOwnProperty;function ya(t,e,r){var o=t[e];(!(ba.call(t,e)&&gt(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var D=ya;function va(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],u=o?o(r[n],t[n],n,r,t):void 0;u===void 0&&(u=t[n]),a?xt(r,n,u):D(r,n,u)}return r}var S=va;var ge=Math.max;function wa(t,e,r){return e=ge(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ge(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),le(t,this,n)}}var be=wa;var Ta=9007199254740991;function Oa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ta}var z=Oa;function ja(t){return t!=null&&z(t.length)&&!dt(t)}var bt=ja;var Aa=Object.prototype;function Pa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var G=Pa;function Sa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ye=Sa;var Ia="[object Arguments]";function _a(t){return w(t)&&T(t)==Ia}var Ft=_a;var ve=Object.prototype,Ea=ve.hasOwnProperty,Ca=ve.propertyIsEnumerable,Fa=Ft(function(){return arguments}())?Ft:function(t){return w(t)&&Ea.call(t,"callee")&&!Ca.call(t,"callee")},W=Fa;function Na(){return!1}var we=Na;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ma=Te&&Te.exports===je,Oe=Ma?d.Buffer:void 0,Ra=Oe?Oe.isBuffer:void 0,Ba=Ra||we,yt=Ba;var La="[object Arguments]",ka="[object Array]",Ua="[object Boolean]",Da="[object Date]",za="[object Error]",Ga="[object Function]",Wa="[object Map]",Ka="[object Number]",$a="[object Object]",Ha="[object RegExp]",Va="[object Set]",qa="[object String]",Ya="[object WeakMap]",Za="[object ArrayBuffer]",Ja="[object DataView]",Xa="[object Float32Array]",Qa="[object Float64Array]",ti="[object Int8Array]",ei="[object Int16Array]",ri="[object Int32Array]",oi="[object Uint8Array]",ai="[object Uint8ClampedArray]",ii="[object Uint16Array]",si="[object Uint32Array]",m={};m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=m[ai]=m[ii]=m[si]=!0;m[La]=m[ka]=m[Za]=m[Ua]=m[Ja]=m[Da]=m[za]=m[Ga]=m[Wa]=m[Ka]=m[$a]=m[Ha]=m[Va]=m[qa]=m[Ya]=!1;function ni(t){return w(t)&&z(t.length)&&!!m[T(t)]}var Ae=ni;function fi(t){return function(e){return t(e)}}var K=fi;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,pi=st&&st.exports===Pe,Nt=pi&&ut.process,li=function(){try{var t=st&&st.require&&st.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),A=li;var Se=A&&A.isTypedArray,mi=Se?K(Se):Ae,Ie=mi;var ui=Object.prototype,di=ui.hasOwnProperty;function ci(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&yt(t),s=!r&&!o&&!a&&Ie(t),i=r||o||a||s,n=i?ye(t.length,String):[],u=n.length;for(var c in t)(e||di.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||U(c,u)))&&n.push(c);return n}var vt=ci;function hi(t,e){return function(r){return t(e(r))}}var wt=hi;var xi=wt(Object.keys,Object),_e=xi;var gi=Object.prototype,bi=gi.hasOwnProperty;function yi(t){if(!G(t))return _e(t);var e=[];for(var r in Object(t))bi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ee=yi;function vi(t){return bt(t)?vt(t):Ee(t)}var $=vi;function wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ce=wi;var Ti=Object.prototype,Oi=Ti.hasOwnProperty;function ji(t){if(!v(t))return Ce(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Oi.call(t,o))||r.push(o);return r}var Fe=ji;function Ai(t){return bt(t)?vt(t,!0):Fe(t)}var H=Ai;var Pi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/;function Ii(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||L(t)?!0:Si.test(t)||!Pi.test(t)||e!=null&&t in Object(e)}var Ne=Ii;var _i=b(Object,"create"),P=_i;function Ei(){this.__data__=P?P(null):{},this.size=0}var Me=Ei;function Ci(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re=Ci;var Fi="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Ri(t){var e=this.__data__;if(P){var r=e[t];return r===Fi?void 0:r}return Mi.call(e,t)?e[t]:void 0}var Be=Ri;var Bi=Object.prototype,Li=Bi.hasOwnProperty;function ki(t){var e=this.__data__;return P?e[t]!==void 0:Li.call(e,t)}var Le=ki;var Ui="__lodash_hash_undefined__";function Di(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=P&&e===void 0?Ui:e,this}var ke=Di;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=Me;V.prototype.delete=Re;V.prototype.get=Be;V.prototype.has=Le;V.prototype.set=ke;var Mt=V;function zi(){this.__data__=[],this.size=0}var Ue=zi;function Gi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var I=Gi;var Wi=Array.prototype,Ki=Wi.splice;function $i(t){var e=this.__data__,r=I(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ki.call(e,r,1),--this.size,!0}var De=$i;function Hi(t){var e=this.__data__,r=I(e,t);return r<0?void 0:e[r][1]}var ze=Hi;function Vi(t){return I(this.__data__,t)>-1}var Ge=Vi;function qi(t,e){var r=this.__data__,o=I(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=qi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Ue;q.prototype.delete=De;q.prototype.get=ze;q.prototype.has=Ge;q.prototype.set=We;var _=q;var Yi=b(d,"Map"),E=Yi;function Zi(){this.size=0,this.__data__={hash:new Mt,map:new(E||_),string:new Mt}}var Ke=Zi;function Ji(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Ji;function Xi(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var C=Xi;function Qi(t){var e=C(this,t).delete(t);return this.size-=e?1:0,e}var He=Qi;function ts(t){return C(this,t).get(t)}var Ve=ts;function es(t){return C(this,t).has(t)}var qe=es;function rs(t,e){var r=C(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ye=rs;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ke;Y.prototype.delete=He;Y.prototype.get=Ve;Y.prototype.has=qe;Y.prototype.set=Ye;var nt=Y;var os="Expected a function";function Rt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Rt.Cache||nt),r}Rt.Cache=nt;var Ze=Rt;var as=500;function is(t){var e=Ze(t,function(o){return r.size===as&&r.clear(),o}),r=e.cache;return e}var Je=is;var ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/\\(\\)?/g,fs=Je(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ss,function(r,o,a,s){e.push(a?s.replace(ns,"$1"):o||r)}),e}),Xe=fs;function ps(t){return t==null?"":re(t)}var Qe=ps;function ls(t,e){return x(t)?t:Ne(t,e)?[t]:Xe(Qe(t))}var F=ls;var ms=1/0;function us(t){if(typeof t=="string"||L(t))return t;var e=t+"";return e=="0"&&1/t==-ms?"-0":e}var Z=us;function ds(t,e){e=F(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[Z(e[r++])];return r&&r==o?t:void 0}var tr=ds;function cs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=cs;var er=g?g.isConcatSpreadable:void 0;function hs(t){return x(t)||W(t)||!!(er&&t&&t[er])}var rr=hs;function or(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=rr),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?or(n,e-1,r,o,a):J(a,n):o||(a[a.length]=n)}return a}var ar=or;function xs(t){var e=t==null?0:t.length;return e?ar(t,1):[]}var ir=xs;function gs(t){return he(be(t,void 0,ir),t+"")}var sr=gs;var bs=wt(Object.getPrototypeOf,Object),Tt=bs;function ys(){this.__data__=new _,this.size=0}var nr=ys;function vs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var fr=vs;function ws(t){return this.__data__.get(t)}var pr=ws;function Ts(t){return this.__data__.has(t)}var lr=Ts;var Os=200;function js(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!E||o.length<Os-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new nt(o)}return r.set(t,e),this.size=r.size,this}var mr=js;function X(t){var e=this.__data__=new _(t);this.size=e.size}X.prototype.clear=nr;X.prototype.delete=fr;X.prototype.get=pr;X.prototype.has=lr;X.prototype.set=mr;var ur=X;function As(t,e){return t&&S(e,$(e),t)}var dr=As;function Ps(t,e){return t&&S(e,H(e),t)}var cr=Ps;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hr=br&&typeof module=="object"&&module&&!module.nodeType&&module,Ss=hr&&hr.exports===br,xr=Ss?d.Buffer:void 0,gr=xr?xr.allocUnsafe:void 0;function Is(t,e){if(e)return t.slice();var r=t.length,o=gr?gr(r):new t.constructor(r);return t.copy(o),o}var yr=Is;function _s(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var vr=_s;function Es(){return[]}var Ot=Es;var Cs=Object.prototype,Fs=Cs.propertyIsEnumerable,wr=Object.getOwnPropertySymbols,Ns=wr?function(t){return t==null?[]:(t=Object(t),vr(wr(t),function(e){return Fs.call(t,e)}))}:Ot,Q=Ns;function Ms(t,e){return S(t,Q(t),e)}var Tr=Ms;var Rs=Object.getOwnPropertySymbols,Bs=Rs?function(t){for(var e=[];t;)J(e,Q(t)),t=Tt(t);return e}:Ot,jt=Bs;function Ls(t,e){return S(t,jt(t),e)}var Or=Ls;function ks(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var At=ks;function Us(t){return At(t,$,Q)}var jr=Us;function Ds(t){return At(t,H,jt)}var Ar=Ds;var zs=b(d,"DataView"),Pt=zs;var Gs=b(d,"Promise"),St=Gs;var Ws=b(d,"Set"),It=Ws;var Pr="[object Map]",Ks="[object Object]",Sr="[object Promise]",Ir="[object Set]",_r="[object WeakMap]",Er="[object DataView]",$s=j(Pt),Hs=j(E),Vs=j(St),qs=j(It),Ys=j(ht),R=T;(Pt&&R(new Pt(new ArrayBuffer(1)))!=Er||E&&R(new E)!=Pr||St&&R(St.resolve())!=Sr||It&&R(new It)!=Ir||ht&&R(new ht)!=_r)&&(R=function(t){var e=T(t),r=e==Ks?t.constructor:void 0,o=r?j(r):"";if(o)switch(o){case $s:return Er;case Hs:return Pr;case Vs:return Sr;case qs:return Ir;case Ys:return _r}return e});var tt=R;var Zs=Object.prototype,Js=Zs.hasOwnProperty;function Xs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Js.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Cr=Xs;var Qs=d.Uint8Array,Bt=Qs;function tn(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var et=tn;function en(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Fr=en;var rn=/\w*$/;function on(t){var e=new t.constructor(t.source,rn.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=on;var Mr=g?g.prototype:void 0,Rr=Mr?Mr.valueOf:void 0;function an(t){return Rr?Object(Rr.call(t)):{}}var Br=an;function sn(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Lr=sn;var nn="[object Boolean]",fn="[object Date]",pn="[object Map]",ln="[object Number]",mn="[object RegExp]",un="[object Set]",dn="[object String]",cn="[object Symbol]",hn="[object ArrayBuffer]",xn="[object DataView]",gn="[object Float32Array]",bn="[object Float64Array]",yn="[object Int8Array]",vn="[object Int16Array]",wn="[object Int32Array]",Tn="[object Uint8Array]",On="[object Uint8ClampedArray]",jn="[object Uint16Array]",An="[object Uint32Array]";function Pn(t,e,r){var o=t.constructor;switch(e){case hn:return et(t);case nn:case fn:return new o(+t);case xn:return Fr(t,r);case gn:case bn:case yn:case vn:case wn:case Tn:case On:case jn:case An:return Lr(t,r);case pn:return new o;case ln:case dn:return new o(t);case mn:return Nr(t);case un:return new o;case cn:return Br(t)}}var kr=Pn;function Sn(t){return typeof t.constructor=="function"&&!G(t)?pe(Tt(t)):{}}var Ur=Sn;var In="[object Map]";function _n(t){return w(t)&&tt(t)==In}var Dr=_n;var zr=A&&A.isMap,En=zr?K(zr):Dr,Gr=En;var Cn="[object Set]";function Fn(t){return w(t)&&tt(t)==Cn}var Wr=Fn;var Kr=A&&A.isSet,Nn=Kr?K(Kr):Wr,$r=Nn;var Mn=1,Rn=2,Bn=4,Hr="[object Arguments]",Ln="[object Array]",kn="[object Boolean]",Un="[object Date]",Dn="[object Error]",Vr="[object Function]",zn="[object GeneratorFunction]",Gn="[object Map]",Wn="[object Number]",qr="[object Object]",Kn="[object RegExp]",$n="[object Set]",Hn="[object String]",Vn="[object Symbol]",qn="[object WeakMap]",Yn="[object ArrayBuffer]",Zn="[object DataView]",Jn="[object Float32Array]",Xn="[object Float64Array]",Qn="[object Int8Array]",tf="[object Int16Array]",ef="[object Int32Array]",rf="[object Uint8Array]",of="[object Uint8ClampedArray]",af="[object Uint16Array]",sf="[object Uint32Array]",l={};l[Hr]=l[Ln]=l[Yn]=l[Zn]=l[kn]=l[Un]=l[Jn]=l[Xn]=l[Qn]=l[tf]=l[ef]=l[Gn]=l[Wn]=l[qr]=l[Kn]=l[$n]=l[Hn]=l[Vn]=l[rf]=l[of]=l[af]=l[sf]=!0;l[Dn]=l[Vr]=l[qn]=!1;function _t(t,e,r,o,a,s){var i,n=e&Mn,u=e&Rn,c=e&Bn;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!v(t))return t;var h=x(t);if(h){if(i=Cr(t),!n)return me(t,i)}else{var O=tt(t),ft=O==Vr||O==zn;if(yt(t))return yr(t,n);if(O==qr||O==Hr||ft&&!a){if(i=u||ft?{}:Ur(t),!n)return u?Or(t,cr(i,t)):Tr(t,dr(i,t))}else{if(!l[O])return a?t:{};i=kr(t,O,n)}}s||(s=new ur);var ot=s.get(t);if(ot)return ot;s.set(t,i),$r(t)?t.forEach(function(y){i.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,f){i.set(f,_t(y,e,r,f,t,s))});var pt=c?u?Ar:jr:u?H:$,lt=h?void 0:pt(t);return xe(lt||t,function(y,f){lt&&(f=y,y=t[f]),D(i,f,_t(y,e,r,f,t,s))}),i}var Yr=_t;var nf=1,ff=4;function pf(t){return Yr(t,nf|ff)}var Lt=pf;function lf(t,e){return t!=null&&e in Object(t)}var Zr=lf;function mf(t,e,r){e=F(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=Z(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&z(a)&&U(i,a)&&(x(t)||W(t)))}var Jr=mf;function uf(t,e){return t!=null&&Jr(t,e,Zr)}var Xr=uf;function df(t,e,r,o){if(!v(t))return t;e=F(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var u=Z(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=n[u];c=o?o(h,u,n):void 0,c===void 0&&(c=v(h)?h:U(e[a+1])?[]:{})}D(n,u,c),n=n[u]}return t}var Qr=df;function cf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=tr(t,i);r(n,i)&&Qr(s,F(i,t),n)}return s}var to=cf;function hf(t,e){return to(t,e,function(r,o){return Xr(t,o)})}var eo=hf;var xf=sr(function(t,e){return t==null?{}:eo(t,e)}),Et=xf;function ro(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var oo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var kt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=oo[r[t]&63];return e};var gf="array",bf="bit",ao="bits",yf="byte",io="bytes",rt="",vf="exponent",wf="function",so="iec",Tf="Invalid number",Of="Invalid rounding method",Ut="jedec",jf="object",no=".",Af="round",Pf="s",Sf="si",If="kbit",_f="kB",Ef=" ",Cf="string",Ff="0",Dt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=rt,localeOptions:i={},separator:n=rt,spacer:u=Ef,symbols:c={},standard:h=rt,output:O=Cf,fullform:ft=!1,fullforms:ot=[],exponent:pt=-1,roundingMethod:lt=Af,precision:y=0}={}){let f=pt,B=Number(t),p=[],M=0,Ct=rt;h===Sf?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=ft===!0,Gt=B<0,Wt=Math[lt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Tf);if(typeof Wt!==wf)throw new TypeError(Of);if(Gt&&(B=-B),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(B)/Math.log(mt)),f<0&&(f=0)),f>8&&(y>0&&(y+=8-f),f=8),O===vf)return f;if(B===0)p[0]=0,Ct=p[1]=Dt.symbol[h][e?ao:io][f];else{M=B/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(M=M*8,M>=mt&&f<8&&(M=M/mt,f++));let at=Math.pow(10,f>0?a:0);p[0]=Wt(M*at)/at,p[0]===mt&&f<8&&pt===-1&&(p[0]=1,f++),Ct=p[1]=o===10&&f===1?e?If:_f:Dt.symbol[h][e?ao:io][f]}if(Gt&&(p[0]=-p[0]),y>0&&(p[0]=p[0].toPrecision(y)),p[1]=c[p[1]]||p[1],s===!0?p[0]=p[0].toLocaleString():s.length>0?p[0]=p[0].toLocaleString(s,i):n.length>0&&(p[0]=p[0].toString().replace(no,n)),r&&a>0){let at=p[0].toString(),Kt=n||(at.match(/(\D)/g)||[]).pop()||no,$t=at.toString().split(Kt),Ht=$t[1]||rt,Vt=Ht.length,lo=a-Vt;p[0]=`${$t[0]}${Kt}${Ht.padEnd(Vt+lo,Ff)}`}return po&&(p[1]=ot[f]?ot[f]:Dt.fullform[h][f]+(e?bf:yf)+(p[0]===1?rt:Pf)),O===gf?p:O===jf?{value:p[0],symbol:p[1],exponent:f,unit:Ct}:p.join(u)}var N=class t{_tera;id;sbId;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?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};events=ro();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];plugins=[];namespaces={};send(e){let r=kt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||kt(),...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 Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):r?.action=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):r?.action=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r?.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}acceptPostboxes={};mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}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.settings.session||="tfy-"+this.getEntropicString(16)).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).then(()=>r).catch(o=>(this.debug("WARN",0,"Init process fault",o),r))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o()).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
1
+ var mo=typeof global=="object"&&global&&global.Object===Object&&global,ut=mo;var uo=typeof self=="object"&&self&&self.Object===Object&&self,co=ut||uo||Function("return this")(),d=co;var ho=d.Symbol,g=ho;var qt=Object.prototype,xo=qt.hasOwnProperty,go=qt.toString,it=g?g.toStringTag:void 0;function yo(t){var e=xo.call(t,it),r=t[it];try{t[it]=void 0;var o=!0}catch{}var a=go.call(t);return o&&(e?t[it]=r:delete t[it]),a}var Yt=yo;var bo=Object.prototype,vo=bo.toString;function wo(t){return vo.call(t)}var Zt=wo;var To="[object Null]",Po="[object Undefined]",Jt=g?g.toStringTag:void 0;function jo(t){return t==null?t===void 0?Po:To:Jt&&Jt in Object(t)?Yt(t):Zt(t)}var T=jo;function Ao(t){return t!=null&&typeof t=="object"}var w=Ao;var Oo="[object Symbol]";function So(t){return typeof t=="symbol"||w(t)&&T(t)==Oo}var B=So;function Io(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Xt=Io;var _o=Array.isArray,x=_o;var Eo=1/0,Qt=g?g.prototype:void 0,te=Qt?Qt.toString:void 0;function ee(t){if(typeof t=="string")return t;if(x(t))return Xt(t,ee)+"";if(B(t))return te?te.call(t):"";var e=t+"";return e=="0"&&1/t==-Eo?"-0":e}var re=ee;function Fo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=Fo;function Co(t){return t}var oe=Co;var No="[object AsyncFunction]",Mo="[object Function]",Ro="[object GeneratorFunction]",Lo="[object Proxy]";function Bo(t){if(!v(t))return!1;var e=T(t);return e==Mo||e==Ro||e==No||e==Lo}var dt=Bo;var ko=d["__core-js_shared__"],ct=ko;var ae=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Uo(t){return!!ae&&ae in t}var ie=Uo;var Do=Function.prototype,zo=Do.toString;function Go(t){if(t!=null){try{return zo.call(t)}catch{}try{return t+""}catch{}}return""}var j=Go;var Wo=/[\\^$.*+?()[\]{}|]/g,Ko=/^\[object .+?Constructor\]$/,$o=Function.prototype,Ho=Object.prototype,Vo=$o.toString,qo=Ho.hasOwnProperty,Yo=RegExp("^"+Vo.call(qo).replace(Wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zo(t){if(!v(t)||ie(t))return!1;var e=dt(t)?Yo:Ko;return e.test(j(t))}var se=Zo;function Jo(t,e){return t?.[e]}var ne=Jo;function Xo(t,e){var r=ne(t,e);return se(r)?r:void 0}var y=Xo;var Qo=y(d,"WeakMap"),ht=Qo;var fe=Object.create,ta=function(){function t(){}return function(e){if(!v(e))return{};if(fe)return fe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),pe=ta;function ea(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var le=ea;function ra(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var me=ra;var oa=800,aa=16,ia=Date.now;function sa(t){var e=0,r=0;return function(){var o=ia(),a=aa-(o-r);if(r=o,a>0){if(++e>=oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ue=sa;function na(t){return function(){return t}}var de=na;var fa=function(){try{var t=y(Object,"defineProperty");return t({},"",{}),t}catch{}}(),k=fa;var pa=k?function(t,e){return k(t,"toString",{configurable:!0,enumerable:!1,value:de(e),writable:!0})}:oe,ce=pa;var la=ue(ce),he=la;function ma(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var xe=ma;var ua=9007199254740991,da=/^(?:0|[1-9]\d*)$/;function ca(t,e){var r=typeof t;return e=e??ua,!!e&&(r=="number"||r!="symbol"&&da.test(t))&&t>-1&&t%1==0&&t<e}var U=ca;function ha(t,e,r){e=="__proto__"&&k?k(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ha;function xa(t,e){return t===e||t!==t&&e!==e}var gt=xa;var ga=Object.prototype,ya=ga.hasOwnProperty;function ba(t,e,r){var o=t[e];(!(ya.call(t,e)&&gt(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var D=ba;function va(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],u=o?o(r[n],t[n],n,r,t):void 0;u===void 0&&(u=t[n]),a?xt(r,n,u):D(r,n,u)}return r}var S=va;var ge=Math.max;function wa(t,e,r){return e=ge(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ge(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),le(t,this,n)}}var ye=wa;var Ta=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ta}var z=Pa;function ja(t){return t!=null&&z(t.length)&&!dt(t)}var yt=ja;var Aa=Object.prototype;function Oa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var G=Oa;function Sa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var be=Sa;var Ia="[object Arguments]";function _a(t){return w(t)&&T(t)==Ia}var Ct=_a;var ve=Object.prototype,Ea=ve.hasOwnProperty,Fa=ve.propertyIsEnumerable,Ca=Ct(function(){return arguments}())?Ct:function(t){return w(t)&&Ea.call(t,"callee")&&!Fa.call(t,"callee")},W=Ca;function Na(){return!1}var we=Na;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ma=Te&&Te.exports===je,Pe=Ma?d.Buffer:void 0,Ra=Pe?Pe.isBuffer:void 0,La=Ra||we,bt=La;var Ba="[object Arguments]",ka="[object Array]",Ua="[object Boolean]",Da="[object Date]",za="[object Error]",Ga="[object Function]",Wa="[object Map]",Ka="[object Number]",$a="[object Object]",Ha="[object RegExp]",Va="[object Set]",qa="[object String]",Ya="[object WeakMap]",Za="[object ArrayBuffer]",Ja="[object DataView]",Xa="[object Float32Array]",Qa="[object Float64Array]",ti="[object Int8Array]",ei="[object Int16Array]",ri="[object Int32Array]",oi="[object Uint8Array]",ai="[object Uint8ClampedArray]",ii="[object Uint16Array]",si="[object Uint32Array]",m={};m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=m[ai]=m[ii]=m[si]=!0;m[Ba]=m[ka]=m[Za]=m[Ua]=m[Ja]=m[Da]=m[za]=m[Ga]=m[Wa]=m[Ka]=m[$a]=m[Ha]=m[Va]=m[qa]=m[Ya]=!1;function ni(t){return w(t)&&z(t.length)&&!!m[T(t)]}var Ae=ni;function fi(t){return function(e){return t(e)}}var K=fi;var Oe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Oe&&typeof module=="object"&&module&&!module.nodeType&&module,pi=st&&st.exports===Oe,Nt=pi&&ut.process,li=function(){try{var t=st&&st.require&&st.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),A=li;var Se=A&&A.isTypedArray,mi=Se?K(Se):Ae,Ie=mi;var ui=Object.prototype,di=ui.hasOwnProperty;function ci(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&Ie(t),i=r||o||a||s,n=i?be(t.length,String):[],u=n.length;for(var c in t)(e||di.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||U(c,u)))&&n.push(c);return n}var vt=ci;function hi(t,e){return function(r){return t(e(r))}}var wt=hi;var xi=wt(Object.keys,Object),_e=xi;var gi=Object.prototype,yi=gi.hasOwnProperty;function bi(t){if(!G(t))return _e(t);var e=[];for(var r in Object(t))yi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ee=bi;function vi(t){return yt(t)?vt(t):Ee(t)}var $=vi;function wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=wi;var Ti=Object.prototype,Pi=Ti.hasOwnProperty;function ji(t){if(!v(t))return Fe(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Ce=ji;function Ai(t){return yt(t)?vt(t,!0):Ce(t)}var H=Ai;var Oi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/;function Ii(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||B(t)?!0:Si.test(t)||!Oi.test(t)||e!=null&&t in Object(e)}var Ne=Ii;var _i=y(Object,"create"),O=_i;function Ei(){this.__data__=O?O(null):{},this.size=0}var Me=Ei;function Fi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re=Fi;var Ci="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Ri(t){var e=this.__data__;if(O){var r=e[t];return r===Ci?void 0:r}return Mi.call(e,t)?e[t]:void 0}var Le=Ri;var Li=Object.prototype,Bi=Li.hasOwnProperty;function ki(t){var e=this.__data__;return O?e[t]!==void 0:Bi.call(e,t)}var Be=ki;var Ui="__lodash_hash_undefined__";function Di(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=O&&e===void 0?Ui:e,this}var ke=Di;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=Me;V.prototype.delete=Re;V.prototype.get=Le;V.prototype.has=Be;V.prototype.set=ke;var Mt=V;function zi(){this.__data__=[],this.size=0}var Ue=zi;function Gi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var I=Gi;var Wi=Array.prototype,Ki=Wi.splice;function $i(t){var e=this.__data__,r=I(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ki.call(e,r,1),--this.size,!0}var De=$i;function Hi(t){var e=this.__data__,r=I(e,t);return r<0?void 0:e[r][1]}var ze=Hi;function Vi(t){return I(this.__data__,t)>-1}var Ge=Vi;function qi(t,e){var r=this.__data__,o=I(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=qi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Ue;q.prototype.delete=De;q.prototype.get=ze;q.prototype.has=Ge;q.prototype.set=We;var _=q;var Yi=y(d,"Map"),E=Yi;function Zi(){this.size=0,this.__data__={hash:new Mt,map:new(E||_),string:new Mt}}var Ke=Zi;function Ji(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Ji;function Xi(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var F=Xi;function Qi(t){var e=F(this,t).delete(t);return this.size-=e?1:0,e}var He=Qi;function ts(t){return F(this,t).get(t)}var Ve=ts;function es(t){return F(this,t).has(t)}var qe=es;function rs(t,e){var r=F(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ye=rs;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ke;Y.prototype.delete=He;Y.prototype.get=Ve;Y.prototype.has=qe;Y.prototype.set=Ye;var nt=Y;var os="Expected a function";function Rt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Rt.Cache||nt),r}Rt.Cache=nt;var Ze=Rt;var as=500;function is(t){var e=Ze(t,function(o){return r.size===as&&r.clear(),o}),r=e.cache;return e}var Je=is;var ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/\\(\\)?/g,fs=Je(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ss,function(r,o,a,s){e.push(a?s.replace(ns,"$1"):o||r)}),e}),Xe=fs;function ps(t){return t==null?"":re(t)}var Qe=ps;function ls(t,e){return x(t)?t:Ne(t,e)?[t]:Xe(Qe(t))}var C=ls;var ms=1/0;function us(t){if(typeof t=="string"||B(t))return t;var e=t+"";return e=="0"&&1/t==-ms?"-0":e}var Z=us;function ds(t,e){e=C(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[Z(e[r++])];return r&&r==o?t:void 0}var tr=ds;function cs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=cs;var er=g?g.isConcatSpreadable:void 0;function hs(t){return x(t)||W(t)||!!(er&&t&&t[er])}var rr=hs;function or(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=rr),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?or(n,e-1,r,o,a):J(a,n):o||(a[a.length]=n)}return a}var ar=or;function xs(t){var e=t==null?0:t.length;return e?ar(t,1):[]}var ir=xs;function gs(t){return he(ye(t,void 0,ir),t+"")}var sr=gs;var ys=wt(Object.getPrototypeOf,Object),Tt=ys;function bs(){this.__data__=new _,this.size=0}var nr=bs;function vs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var fr=vs;function ws(t){return this.__data__.get(t)}var pr=ws;function Ts(t){return this.__data__.has(t)}var lr=Ts;var Ps=200;function js(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!E||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new nt(o)}return r.set(t,e),this.size=r.size,this}var mr=js;function X(t){var e=this.__data__=new _(t);this.size=e.size}X.prototype.clear=nr;X.prototype.delete=fr;X.prototype.get=pr;X.prototype.has=lr;X.prototype.set=mr;var ur=X;function As(t,e){return t&&S(e,$(e),t)}var dr=As;function Os(t,e){return t&&S(e,H(e),t)}var cr=Os;var yr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hr=yr&&typeof module=="object"&&module&&!module.nodeType&&module,Ss=hr&&hr.exports===yr,xr=Ss?d.Buffer:void 0,gr=xr?xr.allocUnsafe:void 0;function Is(t,e){if(e)return t.slice();var r=t.length,o=gr?gr(r):new t.constructor(r);return t.copy(o),o}var br=Is;function _s(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var vr=_s;function Es(){return[]}var Pt=Es;var Fs=Object.prototype,Cs=Fs.propertyIsEnumerable,wr=Object.getOwnPropertySymbols,Ns=wr?function(t){return t==null?[]:(t=Object(t),vr(wr(t),function(e){return Cs.call(t,e)}))}:Pt,Q=Ns;function Ms(t,e){return S(t,Q(t),e)}var Tr=Ms;var Rs=Object.getOwnPropertySymbols,Ls=Rs?function(t){for(var e=[];t;)J(e,Q(t)),t=Tt(t);return e}:Pt,jt=Ls;function Bs(t,e){return S(t,jt(t),e)}var Pr=Bs;function ks(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var At=ks;function Us(t){return At(t,$,Q)}var jr=Us;function Ds(t){return At(t,H,jt)}var Ar=Ds;var zs=y(d,"DataView"),Ot=zs;var Gs=y(d,"Promise"),St=Gs;var Ws=y(d,"Set"),It=Ws;var Or="[object Map]",Ks="[object Object]",Sr="[object Promise]",Ir="[object Set]",_r="[object WeakMap]",Er="[object DataView]",$s=j(Ot),Hs=j(E),Vs=j(St),qs=j(It),Ys=j(ht),R=T;(Ot&&R(new Ot(new ArrayBuffer(1)))!=Er||E&&R(new E)!=Or||St&&R(St.resolve())!=Sr||It&&R(new It)!=Ir||ht&&R(new ht)!=_r)&&(R=function(t){var e=T(t),r=e==Ks?t.constructor:void 0,o=r?j(r):"";if(o)switch(o){case $s:return Er;case Hs:return Or;case Vs:return Sr;case qs:return Ir;case Ys:return _r}return e});var tt=R;var Zs=Object.prototype,Js=Zs.hasOwnProperty;function Xs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Js.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Fr=Xs;var Qs=d.Uint8Array,Lt=Qs;function tn(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var et=tn;function en(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Cr=en;var rn=/\w*$/;function on(t){var e=new t.constructor(t.source,rn.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=on;var Mr=g?g.prototype:void 0,Rr=Mr?Mr.valueOf:void 0;function an(t){return Rr?Object(Rr.call(t)):{}}var Lr=an;function sn(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Br=sn;var nn="[object Boolean]",fn="[object Date]",pn="[object Map]",ln="[object Number]",mn="[object RegExp]",un="[object Set]",dn="[object String]",cn="[object Symbol]",hn="[object ArrayBuffer]",xn="[object DataView]",gn="[object Float32Array]",yn="[object Float64Array]",bn="[object Int8Array]",vn="[object Int16Array]",wn="[object Int32Array]",Tn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",jn="[object Uint16Array]",An="[object Uint32Array]";function On(t,e,r){var o=t.constructor;switch(e){case hn:return et(t);case nn:case fn:return new o(+t);case xn:return Cr(t,r);case gn:case yn:case bn:case vn:case wn:case Tn:case Pn:case jn:case An:return Br(t,r);case pn:return new o;case ln:case dn:return new o(t);case mn:return Nr(t);case un:return new o;case cn:return Lr(t)}}var kr=On;function Sn(t){return typeof t.constructor=="function"&&!G(t)?pe(Tt(t)):{}}var Ur=Sn;var In="[object Map]";function _n(t){return w(t)&&tt(t)==In}var Dr=_n;var zr=A&&A.isMap,En=zr?K(zr):Dr,Gr=En;var Fn="[object Set]";function Cn(t){return w(t)&&tt(t)==Fn}var Wr=Cn;var Kr=A&&A.isSet,Nn=Kr?K(Kr):Wr,$r=Nn;var Mn=1,Rn=2,Ln=4,Hr="[object Arguments]",Bn="[object Array]",kn="[object Boolean]",Un="[object Date]",Dn="[object Error]",Vr="[object Function]",zn="[object GeneratorFunction]",Gn="[object Map]",Wn="[object Number]",qr="[object Object]",Kn="[object RegExp]",$n="[object Set]",Hn="[object String]",Vn="[object Symbol]",qn="[object WeakMap]",Yn="[object ArrayBuffer]",Zn="[object DataView]",Jn="[object Float32Array]",Xn="[object Float64Array]",Qn="[object Int8Array]",tf="[object Int16Array]",ef="[object Int32Array]",rf="[object Uint8Array]",of="[object Uint8ClampedArray]",af="[object Uint16Array]",sf="[object Uint32Array]",l={};l[Hr]=l[Bn]=l[Yn]=l[Zn]=l[kn]=l[Un]=l[Jn]=l[Xn]=l[Qn]=l[tf]=l[ef]=l[Gn]=l[Wn]=l[qr]=l[Kn]=l[$n]=l[Hn]=l[Vn]=l[rf]=l[of]=l[af]=l[sf]=!0;l[Dn]=l[Vr]=l[qn]=!1;function _t(t,e,r,o,a,s){var i,n=e&Mn,u=e&Rn,c=e&Ln;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!v(t))return t;var h=x(t);if(h){if(i=Fr(t),!n)return me(t,i)}else{var P=tt(t),ft=P==Vr||P==zn;if(bt(t))return br(t,n);if(P==qr||P==Hr||ft&&!a){if(i=u||ft?{}:Ur(t),!n)return u?Pr(t,cr(i,t)):Tr(t,dr(i,t))}else{if(!l[P])return a?t:{};i=kr(t,P,n)}}s||(s=new ur);var ot=s.get(t);if(ot)return ot;s.set(t,i),$r(t)?t.forEach(function(b){i.add(_t(b,e,r,b,t,s))}):Gr(t)&&t.forEach(function(b,f){i.set(f,_t(b,e,r,f,t,s))});var pt=c?u?Ar:jr:u?H:$,lt=h?void 0:pt(t);return xe(lt||t,function(b,f){lt&&(f=b,b=t[f]),D(i,f,_t(b,e,r,f,t,s))}),i}var Yr=_t;var nf=1,ff=4;function pf(t){return Yr(t,nf|ff)}var Bt=pf;function lf(t,e){return t!=null&&e in Object(t)}var Zr=lf;function mf(t,e,r){e=C(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=Z(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&z(a)&&U(i,a)&&(x(t)||W(t)))}var Jr=mf;function uf(t,e){return t!=null&&Jr(t,e,Zr)}var Xr=uf;function df(t,e,r,o){if(!v(t))return t;e=C(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var u=Z(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=n[u];c=o?o(h,u,n):void 0,c===void 0&&(c=v(h)?h:U(e[a+1])?[]:{})}D(n,u,c),n=n[u]}return t}var Qr=df;function cf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=tr(t,i);r(n,i)&&Qr(s,C(i,t),n)}return s}var to=cf;function hf(t,e){return to(t,e,function(r,o){return Xr(t,o)})}var eo=hf;var xf=sr(function(t,e){return t==null?{}:eo(t,e)}),Et=xf;function ro(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var oo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var kt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=oo[r[t]&63];return e};var gf="array",yf="bit",ao="bits",bf="byte",io="bytes",rt="",vf="exponent",wf="function",so="iec",Tf="Invalid number",Pf="Invalid rounding method",Ut="jedec",jf="object",no=".",Af="round",Of="s",Sf="si",If="kbit",_f="kB",Ef=" ",Ff="string",Cf="0",Dt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=rt,localeOptions:i={},separator:n=rt,spacer:u=Ef,symbols:c={},standard:h=rt,output:P=Ff,fullform:ft=!1,fullforms:ot=[],exponent:pt=-1,roundingMethod:lt=Af,precision:b=0}={}){let f=pt,L=Number(t),p=[],M=0,Ft=rt;h===Sf?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=ft===!0,Gt=L<0,Wt=Math[lt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Tf);if(typeof Wt!==wf)throw new TypeError(Pf);if(Gt&&(L=-L),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(L)/Math.log(mt)),f<0&&(f=0)),f>8&&(b>0&&(b+=8-f),f=8),P===vf)return f;if(L===0)p[0]=0,Ft=p[1]=Dt.symbol[h][e?ao:io][f];else{M=L/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(M=M*8,M>=mt&&f<8&&(M=M/mt,f++));let at=Math.pow(10,f>0?a:0);p[0]=Wt(M*at)/at,p[0]===mt&&f<8&&pt===-1&&(p[0]=1,f++),Ft=p[1]=o===10&&f===1?e?If:_f:Dt.symbol[h][e?ao:io][f]}if(Gt&&(p[0]=-p[0]),b>0&&(p[0]=p[0].toPrecision(b)),p[1]=c[p[1]]||p[1],s===!0?p[0]=p[0].toLocaleString():s.length>0?p[0]=p[0].toLocaleString(s,i):n.length>0&&(p[0]=p[0].toString().replace(no,n)),r&&a>0){let at=p[0].toString(),Kt=n||(at.match(/(\D)/g)||[]).pop()||no,$t=at.toString().split(Kt),Ht=$t[1]||rt,Vt=Ht.length,lo=a-Vt;p[0]=`${$t[0]}${Kt}${Ht.padEnd(Vt+lo,Cf)}`}return po&&(p[1]=ot[f]?ot[f]:Dt.fullform[h][f]+(e?yf:bf)+(p[0]===1?rt:Of)),P===gf?p:P===jf?{value:p[0],symbol:p[1],exponent:f,unit:Ft}:p.join(u)}var N=class t{constructor(e){this.meta={};if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){let r=Et(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]);return new t(r)}};var zt=class{constructor(e){this.settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};this.events=ro();this.dom={el:null,iframe:null,popup:null,stylesheet:null};this.methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];this.plugins=[];this.namespaces={};this.acceptPostboxes={};this.initPromise=null;e&&this.set(e)}send(e){let r=kt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||kt(),...Bt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):r?.action=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):r?.action=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r?.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.initPromise)return this.initPromise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.initPromise=Promise.resolve().then(()=>this.settings.session||="tfy-"+this.getEntropicString(16)).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths?this.settings.debugPaths=this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):this.settings.debugPaths=null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>(this.debug("INFO",4,"[6/6] Init complete"),r)).catch(o=>{throw this.debug("WARN",0,"Init process fault",o),o}),this.initPromise}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e(void 0)).catch(r)})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e(void 0)}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o(void 0)).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
2
  `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(s=>Object.getOwnPropertyNames(s).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),this.dom?.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new N({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new N({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new N({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new N({tera:this,...r}))}};export{zt as default};
3
3
  /*! Bundled license information:
4
4
 
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Shallow-copy a object instance and inject new properties into the result
3
+ *
4
+ * Rather ugly shallow-copy-of instance hack from https://stackoverflow.com/a/44782052/1295040
5
+ * Keeps the original object instance and overrides the given object of assignments
6
+ *
7
+ * @param {Object} instance Original object class instance to mixin
8
+ * @param {Object} assignments Additional object properties to mix
9
+ * @returns {Object} A shallow copy of the input instance extended with the assignments
10
+ */
11
+ export default function mixin(instance: any, assignments: any): any;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shallow-copy a object instance and inject new properties into the result
3
+ *
4
+ * Rather ugly shallow-copy-of instance hack from https://stackoverflow.com/a/44782052/1295040
5
+ * Keeps the original object instance and overrides the given object of assignments
6
+ *
7
+ * @param {Object} instance Original object class instance to mixin
8
+ * @param {Object} assignments Additional object properties to mix
9
+ * @returns {Object} A shallow copy of the input instance extended with the assignments
10
+ */
11
+ export default function mixin(instance, assignments) {
12
+ let output = Object.assign(Object.create(Object.getPrototypeOf(instance)), instance, assignments);
13
+ return output;
14
+ }
15
+ //# sourceMappingURL=mixin.js.map