@zenflux/core
Advanced tools
Comparing version 0.0.0-alpha.4 to 0.0.0-alpha.5
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@zenflux/core"]={})}(this,(function(t){"use strict";function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;arguments.length>n;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){l(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new N(r||[]);return o(i,"_invoke",{value:O(t,n,a)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function p(){}function v(){}function y(){}var g={};s(g,a,(function(){return this}));var d=Object.getPrototypeOf,m=d&&d(d(_([])));m&&m!==e&&n.call(m,a)&&(g=m);var b=y.prototype=p.prototype=Object.create(g);function k(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return x()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=j(a,n);if(c){if(c===h)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function j(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function _(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return v.prototype=y,o(b,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=s(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,u,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},k(w.prototype),s(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new w(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(b),s(b,u,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=_,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),E(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;E(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:_(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function i(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function a(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function c(t){i(a,r,o,c,u,"next",t)}function u(t){i(a,r,o,c,u,"throw",t)}c(void 0)}))}}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,C(r.key),r)}}function s(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e,n){return(e=C(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function v(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function y(t,e,n){return y=v()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&p(o,n.prototype),o},y.apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return y(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)},g(t)}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return d(t)}function b(t){var e=v();return function(){var n,r=h(t);if(e){var o=h(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return m(this,n)}}function k(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}function w(){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=k(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(3>arguments.length?t:n):o.value}},w.apply(this,arguments)}function O(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return j(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r}function C(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var E="0.0.0-alpha.3",N=function(){var t=new WeakSet;return function(e,n){if("object"===o(n)&&null!==n){if(t.has(n))return;t.add(n)}return n}},_=function(t,e){t=t.replace("#",""),e=e.replace("#","");var n=parseInt(t.substring(0,2),16),r=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),i=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),c=parseInt(e.substring(4,6),16),u=255-Math.abs(n-i),s=255-Math.abs(r-a),l=255-Math.abs(o-c);return((u/=255)+(s/=255)+(l/=255))/3},x=Object.freeze({__proto__:null,getCircularReplacer:N,hexColorDelta:_}),A=function(){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,t),l(this,"args",{}),l(this,"state",!1),"off"!==(null===(n=globalThis.process)||void 0===n?void 0:n.env.flow_modules_logger)&&(this.state=r,this.args=o,this.name="",this.name="string"==typeof e?e:e.constructor.name,r&&this.initialize())}return s(t,[{key:"initialize",value:function(){this.args.sameColor?(t.sharedData[this.name]||(t.sharedData[this.name]=this.getRandomColor()),this.color=t.sharedData[this.name]):(this.color=this.getRandomColor(),t.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: ".concat(this.color),"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}},{key:"setOutputHandler",value:function(t){this.outputHandler=t}},{key:"useWrapper",value:function(e){var r=this,i=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!e||"object"!==o(e)||Array.isArray(e))return e;t.wrapperDepth++;var a=n({},e);return Object.values(t.wrappers).forEach((function(t){var n=O(t,1)[0];e instanceof n.classType&&(a=n.callback(e)||a)})),4>t.wrapperDepth?(i&&a&&Object.entries(a).forEach((function(t){var e=O(t,2);a[e[0]]=r.useWrapper(e[1],!0)})),t.wrapperDepth--,a):(t.wrapperDepth--,a)}},{key:"startEmpty",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.state&&this.printFunctionNotify("se",t.getCallerName(),e)}},{key:"startWith",value:function(e){if(this.state){e=Object.assign({},e);var n="se",r=t.getCallerName();if("string"==typeof e)this.printInLineString(n,r,e);else if(1===Object.keys(e).length){var i=Object.keys(e)[0],a=Object.values(e)[0];"object"===o(a)?this.printNextLineObject(n,r,i,a||{}):"function"==typeof a?this.printInLineFunction(n,r,i,a):this.printInLineElement(n,r,i,a)}else this.printMultiLineObject(n,r,e)}}},{key:"object",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(this.state){var r=t.getCallerName();for(var i in e=Object.create(e))"object"===o(e[i])&&(e[i]=JSON.stringify(this.useWrapper(e[i]),N())),this.out.apply(this,["%c(ob)-> %c%c".concat(this.name,"%c::%c").concat(r,"%c() [").concat(n,"] ->> ").concat(i,": '").concat(e[i],"'%c")].concat(this.defaultStyle))}}},{key:"debug",value:function(e){this.state&&this.printFunctionNotify("db",t.getCallerName(),e)}},{key:"drop",value:function(e,n){if(this.state){var r=t.getCallerName();for(var o in e)this.out.apply(this,["%c(dr)-> %c%c".concat(this.name,"%c::%c").concat(r,"%c() ->> corresponding ").concat(o,": '").concat(e[o],"' RESULT: %c↓")].concat(this.defaultStyle));this.out(n)}}},{key:"throw",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"null",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};throw this.printFunctionNotify("tw",t.getCallerName(),e),r&&this.printNextLineObject("tw",t.getCallerName(),n,r),Error().stack}},{key:"clone",value:function(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}},{key:"printFunctionNotify",value:function(t,e,n){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ").concat(n,"%c")].concat(this.defaultStyle))}},{key:"printInLineElement",value:function(t,e,n,r){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(n,": '").concat(r,"'%c")].concat(this.defaultStyle))}},{key:"printInLineFunction",value:function(e,n,r,o){o=t.getFunctionView(o),this.printInLineElement(e,n,r,o)}},{key:"printInLineString",value:function(t,e,n){this.printInLineElement(t,e,"(string)",n)}},{key:"printNextLineObject",value:function(t,e,n,r){r=this.useWrapper(r),this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(n," %c↓")].concat(this.defaultStyle)),this.out(r)}},{key:"printMultiLineObject",value:function(e,n,r){for(var i in this.out.apply(this,["%c(".concat(e,")-> %c%c").concat(this.name,"%c::%c").concat(n,"%c(").concat(Object.keys(r).join(", "),") %c↓")].concat(this.defaultStyle)),r){var a=r[i];"object"===o(a)?a=JSON.stringify(this.useWrapper(a),N()):"function"==typeof r[i]&&(a=t.getFunctionView(a)),this.out.call(this,"%c"+i+": `"+this.useWrapper(a)+"`","color: #a3a3a3")}}},{key:"getRandomColor",value:function(){for(var e="#",n=0;6>n;n++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return t.colorsInUse.some((function(t){return _(e,t)>=.8}))?this.getRandomColor():e}},{key:"out",value:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.outputHandler.apply(this,e)}}],[{key:"getName",value:function(){return"Core/Modules/Logger"}},{key:"reset",value:function(){t.wrappers={},t.wrapperDepth=0,t.colorsInUse=[],t.sharedData={}}},{key:"createCustomWrapper",value:function(e,n){t.wrappers[e]||(t.wrappers[e.name]=[]),t.wrappers[e.name].push({classType:e,callback:n})}},{key:"getCallerName",value:function(){var t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}},{key:"getFunctionView",value:function(t){var e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}}]),t}();l(A,"wrappers",{}),l(A,"wrapperDepth",0),l(A,"sharedData",{}),l(A,"colorsInUse",[]);var I=Object.freeze({__proto__:null,Logger:A}),L=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Command: '".concat(t.getName(),"' is already registered"))}return s(n)}(g(Error)),P=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Command: '".concat(t,"' is not found"))}return s(n)}(g(Error)),T=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Controller: '".concat(t.getName(),"' is already registered"))}return s(n)}(g(Error)),H=function(t){f(n,t);var e=b(n);function n(t,r){return c(this,n),e.call(this,"ForeMethod implementation: at '".concat(t,"' method: '").concat(r,"'"))}return s(n)}(g(Error)),S=function(t){f(n,t);var e=b(n);function n(t,r){return c(this,n),e.call(this,"ForeMethod implementation: at '".concat(t.getName(),"' method: '").concat(r,"'"))}return s(n)}(g(Error)),B=Object.freeze({__proto__:null,CommandAlreadyRegistered:L,CommandNotFound:P,ControllerAlreadyRegistered:T,ForceMethod:S}),M=0,D=function(){function t(){c(this,t),l(this,"virtualId",0),this.virtualId=M,M++}return s(t,[{key:"getName",value:function(){return this.constructor.getName()}}],[{key:"getName",value:function(){throw new H("ObjectBase","getName")}}]),t}();var R=function(t){f(p,t);var e,o,i,u,h=b(p);function p(){var t;return c(this,p),l(d(t=h.call(this)),"current",{}),l(d(t),"currentArgs",{}),l(d(t),"trace",[]),l(d(t),"commands",{}),l(d(t),"onBeforeHooks",{}),l(d(t),"onBeforeUIHooks",{}),l(d(t),"onAfterHooks",{}),l(d(t),"onAfterOnceHooks",{}),l(d(t),"onAfterUIHooks",{}),l(d(t),"onAfterAffectHooks",{}),t.logger=new A(t.getName(),!0),t.logger.startEmpty(),t}return s(p,[{key:"run",value:(u=a(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:{},o=a.length>2&&void 0!==a[2]?a[2]:{},"string"==typeof e&&(e=this.getCommandInstance(e,n,o)),this.attachCurrent(e,n),t.next=6,this.runInstance(e,n,o);case 6:return i=t.sent,this.detachCurrent(e),t.abrupt("return",i);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"register",value:function(t,e){var n=this,r={};return Object.values(t).forEach((function(t){var e=t.getName();if(n.commands[e])throw new L(t);n.commands[e]=t,r[e]=t})),r}},{key:"getAll",value:function(){return this.commands}},{key:"getByName",value:function(t){return this.commands[t]}},{key:"getLogger",value:function(){return this.logger}},{key:"getCommandInstance",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.commands[t];if(!r)throw new P(t);return new r(e,n)}},{key:"onBefore",value:function(t,e){p.hookCommand(this.onBeforeHooks,t,e)}},{key:"onBeforeUI",value:function(t,e){p.hookCommand(this.onBeforeUIHooks,t,e)}},{key:"onAfter",value:function(t,e){p.hookCommand(this.onAfterHooks,t,e)}},{key:"onAfterUI",value:function(t,e){p.hookCommand(this.onAfterUIHooks,t,e)}},{key:"onAfterOnce",value:function(t,e){p.hookCommand(this.onAfterOnceHooks,t,e)}},{key:"onAfterAffect",value:function(t,e){p.hookCommand(this.onAfterAffectHooks,t,e)}},{key:"onBeforeRun",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.onBeforeHooks[t.getName()]){var r=this.onBeforeHooks[t.getName()];r.forEach((function(t){return t(e,n)}))}if(this.onBeforeUIHooks[t.getName()]){var o=this.onBeforeUIHooks[t.getName()];o.forEach((function(t){return t(e,n)}))}}},{key:"runInstance",value:(i=a(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=a.length>2&&void 0!==a[2]?a[2]:{},i=null,Object.keys(n=a.length>1&&void 0!==a[1]?a[1]:{}).length?(this.logger.startWith({command:e.getName(),options:o,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(n)):this.logger.startWith({command:e.getName(),options:o,args:n}),this.onBeforeRun(e,n,o),t.next=7,e.run();case 7:return i=t.sent,t.next=10,this.onAfterRun(e,n,o,i);case 10:return t.abrupt("return",i);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"onAfterRun",value:(o=a(r().mark((function t(e,o,i,a){var c=this;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=Object.assign({},i),!this.onAfterAffectHooks[e.getName()]){t.next=6;break}return this.onAfterAffectHooks[e.getName()].forEach((function(t){o.result=a,a=c.run(""+t,o,i)})),t.next=5,a;case 5:a=t.sent;case 6:if(!this.onAfterHooks){t.next=10;break}return o.result=a,t.next=10,p.runCallbacks(Object.assign([],this.onAfterHooks[e.getName()]),o,i);case 10:if(!this.onAfterOnceHooks){t.next=13;break}return t.next=13,p.runCallbacks(this.onAfterOnceHooks[e.getName()],o,n(n({},i),{},{pop:!0}));case 13:return this.onAfterUIHooks&&p.runCallbacks(Object.assign([],this.onAfterUIHooks[e.getName()]),o,i),t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return o.apply(this,arguments)})},{key:"attachCurrent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),p.trace.push(t.getName())}},{key:"detachCurrent",value:function(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],p.trace.pop(),this.trace.pop()}}],[{key:"getName",value:function(){return"Core/Managers/Commands"}},{key:"runCallbacks",value:(e=a(r().mark((function t(e){var n,o,i,a,c,u=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2&&void 0!==u[2]?u[2]:{},i=(null==e?void 0:e.length)||0,a=0;case 4:if(a>=i){t.next=13;break}if(c=!0===o.pop?e.pop():e[a]){t.next=8;break}throw Error("Callback is not defined.");case 8:return t.next=10,c(n,o);case 10:++a,t.next=4;break;case 13:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})},{key:"hookCommand",value:function(t,e,n){t[e]||(t[e]=[]),t[e].push(n)}}]),p}(D);l(R,"trace",[]);var U,F=function(t){f(n,t);var e=b(n);function n(){var t;c(this,n);for(var r=arguments.length,o=Array(r),i=0;r>i;i++)o[i]=arguments[i];return l(d(t=e.call.apply(e,[this].concat(o))),"controllers",{}),t}return s(n,[{key:"get",value:function(t){return this.controllers[t]}},{key:"getAll",value:function(){return this.controllers}},{key:"register",value:function(t){if(this.controllers[t.getName()])throw new T(t);return this.controllers[t.getName()]=t,t}}],[{key:"getName",value:function(){return"Core/Managers/Controllers"}}]),n}(D);!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(U||(U={}));var z=function(t){f(o,t);var e,n=b(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"http://localhost";return c(this,o),(t=n.call(this)).logger=new A(o.getName(),!0),t.logger.startWith({apiBaseUrl:e}),t.apiBaseUrl=e+"/",t}return s(o,[{key:"fetch",value:(e=a(r().mark((function t(e,n){var o,i,a,c,u,s,l,f,h=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.logger.startWith({path:e,method:n,body:c=h.length>2&&void 0!==h[2]?h[2]:null}),u={credentials:"include"},s={},[U.POST,U.PUT,U.PATCH].includes(n)?(Object.assign(s,{"Content-Type":"application/json"}),Object.assign(u,{method:n,headers:s,body:JSON.stringify(c)})):Object.assign(u,{headers:s}),t.next=6,globalThis.fetch(this.apiBaseUrl+e,u);case 6:return l=t.sent,f=void 0,t.prev=8,t.next=11,l.json();case 11:f=t.sent,t.next=18;break;case 14:return t.prev=14,t.t0=t.catch(8),console.error(t.t0),t.abrupt("return",!1);case 18:if(!(null!==(o=f)&&void 0!==o&&o.error&&null!==(i=f)&&void 0!==i&&i.global&&null!==(a=f)&&void 0!==a&&a.message)){t.next=20;break}throw Error(f.message);case 20:return this.logger.drop({path:e},f),t.abrupt("return",f);case 22:case"end":return t.stop()}}),t,this,[[8,14]])}))),function(t,n){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Clients/Http"}}]),o}(D),W=function(t){f(o,t);var e,n=b(o);function o(t){var e;return c(this,o),e=n.call(this),o.client=new z(t.baseURL),e}return s(o,[{key:"getClient",value:function(){return o.client}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.GET,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.PATCH,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.DELETE,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"create",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.POST,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"runInstance",value:(e=a(r().mark((function t(e){var n,i,a,c=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=c.length>1&&void 0!==c[1]?c[1]:{},i=c.length>2&&void 0!==c[2]?c[2]:{},this.currentHttpMethod){t.next=4;break}throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');case 4:return a={type:this.currentHttpMethod,args:{query:{},data:{}}},U.GET===this.currentHttpMethod?a.args.query=n:a.args.data=n,t.next=8,w(h(o.prototype),"runInstance",this).call(this,e,a,i);case 8:return n.result=t.sent,this.currentHttpMethod=U.__EMPTY__,t.abrupt("return",n.result);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Managers/Data"}}]),o}(R),G=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/Managers/Internal"}}]),n}(R),Y=[];function J(t){Z=new R,q=new F,K=new W(t),$=new G}function V(){Z={},q={},K={},$={}}var Z={},q={},K={},$={},Q=Object.freeze({__proto__:null,afterInitializeCallbacks:Y,get commands(){return Z},get controllers(){return q},get data(){return K},destroy:V,initialize:J,get internal(){return $}}),X=function(t){f(o,t);var e,n=b(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c(this,o),l(d(t=n.call(this)),"args",{}),l(d(t),"options",{});var i=t.constructor.getName();return t.logger=new A(i,!0,{sameColor:!0}),t.logger.startWith({args:e,options:r}),t.initialize(e,r),t}return s(o,[{key:"initialize",value:function(t,e){this.args=t,this.options=e}},{key:"apply",value:function(){throw new S(this,"apply")}},{key:"run",value:(e=a(r().mark((function t(){var e;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.onBeforeApply&&this.onBeforeApply(),t.next=3,this.apply(this.args,this.options);case 3:return e=t.sent,this.onAfterApply&&this.onAfterApply(),t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"getArgs",value:function(){return this.args}},{key:"getOptions",value:function(){return this.options}}]),o}(D),tt=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandPublic"}}]),n}(X),et=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,[{key:"getEndpoint",value:function(){throw new S(this,"getEndpoint")}},{key:"apply",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.args,e=this.applyEndpointFormat(this.getEndpoint(),t);return K.getClient().fetch(e,K.currentHttpMethod,t||null)}},{key:"applyEndpointFormat",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.includes("{")&&(t=t.split("/").map((function(t){var n=t.match("\\{(.*?)\\}");return null!=n&&n.length&&void 0!==e[n[1]]?e[n[1]]:t})).join("/")),t}}],[{key:"getName",value:function(){return"Core/CommandBases/CommandData"}}]),n}(X),nt=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandInternal"}}]),n}(X),rt=Object.freeze({__proto__:null,CommandBase:X,CommandData:et,CommandInternal:nt,CommandPublic:tt}),ot=Object.freeze({__proto__:null,Controller:function(t){f(n,t);var e=b(n);function n(){var t;return c(this,n),(t=e.call(this)).initialize(),t}return s(n,[{key:"initialize",value:function(){this.register(),this.setupHooks&&this.setupHooks()}},{key:"register",value:function(){this.commands=Z.register(this.getCommands(),this),this.data=K.register(this.getData(),this),this.internal=$.register(this.getInternal(),this)}},{key:"getCommands",value:function(){return{}}},{key:"getData",value:function(){return{}}},{key:"getInternal",value:function(){return{}}}],[{key:"getName",value:function(){return"Core/Core/Controller"}}]),n}(D),ObjectBase:D}),it=Object.freeze({__proto__:null,Commands:R,Controllers:F,Data:W,Internal:G}),at=Object.freeze({__proto__:null,commandBases:rt,core:ot,errors:B,managerBases:it,managers:Q,modules:I,utils:x}),ct=!1;function ut(){if(ct)throw Error("ZenCore is already initialized.")}ut();var st={version:E},lt=n({initialize:function(t){ut(),J(st=t||st),ct=!0},destroy:function(){V(),ct=!1},onAfterInitialize:function(t){Y.push(t)},config:st},at);null!==globalThis&&void 0!==globalThis&&globalThis.ZenCore||(globalThis.ZenCore=lt),t.commandBases=rt,t.core=ot,t.default=lt,t.errors=B,t.managerBases=it,t.managers=Q,t.modules=I,t.utils=x,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@zenflux/core"]={})}(this,(function(t){"use strict";function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;arguments.length>n;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){l(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new N(r||[]);return o(i,"_invoke",{value:O(t,n,a)}),i}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function p(){}function v(){}function y(){}var g={};s(g,a,(function(){return this}));var d=Object.getPrototypeOf,m=d&&d(d(_([])));m&&m!==e&&n.call(m,a)&&(g=m);var b=y.prototype=p.prototype=Object.create(g);function k(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return x()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=j(a,n);if(c){if(c===h)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function j(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var o=f(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function _(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return v.prototype=y,o(b,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=s(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,u,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},k(w.prototype),s(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new w(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(b),s(b,u,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=_,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),E(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;E(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:_(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function i(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function a(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function c(t){i(a,r,o,c,u,"next",t)}function u(t){i(a,r,o,c,u,"throw",t)}c(void 0)}))}}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,C(r.key),r)}}function s(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e,n){return(e=C(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function v(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function y(t,e,n){return y=v()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&p(o,n.prototype),o},y.apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return y(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)},g(t)}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return d(t)}function b(t){var e=v();return function(){var n,r=h(t);if(e){var o=h(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return m(this,n)}}function k(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}function w(){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=k(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(3>arguments.length?t:n):o.value}},w.apply(this,arguments)}function O(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return j(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r}function C(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var E="0.0.0-alpha.5",N=function(){var t=new WeakSet;return function(e,n){if("object"===o(n)&&null!==n){if(t.has(n))return;t.add(n)}return n}},_=function(t,e){t=t.replace("#",""),e=e.replace("#","");var n=parseInt(t.substring(0,2),16),r=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),i=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),c=parseInt(e.substring(4,6),16),u=255-Math.abs(n-i),s=255-Math.abs(r-a),l=255-Math.abs(o-c);return((u/=255)+(s/=255)+(l/=255))/3},x=Object.freeze({__proto__:null,getCircularReplacer:N,hexColorDelta:_}),A=function(){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,t),l(this,"args",{}),l(this,"state",!1),"off"!==(null===(n=globalThis.process)||void 0===n?void 0:n.env.flow_modules_logger)&&(this.state=r,this.args=o,this.name="",this.name="string"==typeof e?e:e.constructor.name,r&&this.initialize())}return s(t,[{key:"initialize",value:function(){this.args.sameColor?(t.sharedData[this.name]||(t.sharedData[this.name]=this.getRandomColor()),this.color=t.sharedData[this.name]):(this.color=this.getRandomColor(),t.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: ".concat(this.color),"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}},{key:"setOutputHandler",value:function(t){this.outputHandler=t}},{key:"useWrapper",value:function(e){var r=this,i=1>=arguments.length||void 0===arguments[1]||arguments[1];if(!e||"object"!==o(e)||Array.isArray(e))return e;t.wrapperDepth++;var a=n({},e);return Object.values(t.wrappers).forEach((function(t){var n=O(t,1)[0];e instanceof n.classType&&(a=n.callback(e)||a)})),4>t.wrapperDepth?(i&&a&&Object.entries(a).forEach((function(t){var e=O(t,2);a[e[0]]=r.useWrapper(e[1],!0)})),t.wrapperDepth--,a):(t.wrapperDepth--,a)}},{key:"startEmpty",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.state&&this.printFunctionNotify("se",t.getCallerName(),e)}},{key:"startWith",value:function(e){if(this.state){e=Object.assign({},e);var n="se",r=t.getCallerName();if("string"==typeof e)this.printInLineString(n,r,e);else if(1===Object.keys(e).length){var i=Object.keys(e)[0],a=Object.values(e)[0];"object"===o(a)?this.printNextLineObject(n,r,i,a||{}):"function"==typeof a?this.printInLineFunction(n,r,i,a):this.printInLineElement(n,r,i,a)}else this.printMultiLineObject(n,r,e)}}},{key:"object",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(this.state){var r=t.getCallerName();for(var i in e=Object.create(e))"object"===o(e[i])&&(e[i]=JSON.stringify(this.useWrapper(e[i]),N())),this.out.apply(this,["%c(ob)-> %c%c".concat(this.name,"%c::%c").concat(r,"%c() [").concat(n,"] ->> ").concat(i,": '").concat(e[i],"'%c")].concat(this.defaultStyle))}}},{key:"debug",value:function(e){this.state&&this.printFunctionNotify("db",t.getCallerName(),e)}},{key:"drop",value:function(e,n){if(this.state){var r=t.getCallerName();for(var o in e)this.out.apply(this,["%c(dr)-> %c%c".concat(this.name,"%c::%c").concat(r,"%c() ->> corresponding ").concat(o,": '").concat(e[o],"' RESULT: %c↓")].concat(this.defaultStyle));this.out(n)}}},{key:"throw",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"null",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};throw this.printFunctionNotify("tw",t.getCallerName(),e),r&&this.printNextLineObject("tw",t.getCallerName(),n,r),Error().stack}},{key:"clone",value:function(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}},{key:"printFunctionNotify",value:function(t,e,n){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ").concat(n,"%c")].concat(this.defaultStyle))}},{key:"printInLineElement",value:function(t,e,n,r){this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(n,": '").concat(r,"'%c")].concat(this.defaultStyle))}},{key:"printInLineFunction",value:function(e,n,r,o){o=t.getFunctionView(o),this.printInLineElement(e,n,r,o)}},{key:"printInLineString",value:function(t,e,n){this.printInLineElement(t,e,"(string)",n)}},{key:"printNextLineObject",value:function(t,e,n,r){r=this.useWrapper(r),this.out.apply(this,["%c(".concat(t,")-> %c%c").concat(this.name,"%c::%c").concat(e,"%c() ->> ").concat(n," %c↓")].concat(this.defaultStyle)),this.out(r)}},{key:"printMultiLineObject",value:function(e,n,r){for(var i in this.out.apply(this,["%c(".concat(e,")-> %c%c").concat(this.name,"%c::%c").concat(n,"%c(").concat(Object.keys(r).join(", "),") %c↓")].concat(this.defaultStyle)),r){var a=r[i];"object"===o(a)?a=JSON.stringify(this.useWrapper(a),N()):"function"==typeof r[i]&&(a=t.getFunctionView(a)),this.out.call(this,"%c"+i+": `"+this.useWrapper(a)+"`","color: #a3a3a3")}}},{key:"getRandomColor",value:function(){for(var e="#",n=0;6>n;n++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return t.colorsInUse.some((function(t){return _(e,t)>=.8}))?this.getRandomColor():e}},{key:"out",value:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.outputHandler.apply(this,e)}}],[{key:"getName",value:function(){return"Core/Modules/Logger"}},{key:"reset",value:function(){t.wrappers={},t.wrapperDepth=0,t.colorsInUse=[],t.sharedData={}}},{key:"createCustomWrapper",value:function(e,n){t.wrappers[e]||(t.wrappers[e.name]=[]),t.wrappers[e.name].push({classType:e,callback:n})}},{key:"getCallerName",value:function(){var t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}},{key:"getFunctionView",value:function(t){var e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}}]),t}();l(A,"wrappers",{}),l(A,"wrapperDepth",0),l(A,"sharedData",{}),l(A,"colorsInUse",[]);var I=Object.freeze({__proto__:null,Logger:A}),L=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Command: '".concat(t.getName(),"' is already registered"))}return s(n)}(g(Error)),P=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Command: '".concat(t,"' is not found"))}return s(n)}(g(Error)),T=function(t){f(n,t);var e=b(n);function n(t){return c(this,n),e.call(this,"Controller: '".concat(t.getName(),"' is already registered"))}return s(n)}(g(Error)),H=function(t){f(n,t);var e=b(n);function n(t,r){return c(this,n),e.call(this,"ForeMethod implementation: at '".concat(t,"' method: '").concat(r,"'"))}return s(n)}(g(Error)),S=function(t){f(n,t);var e=b(n);function n(t,r){return c(this,n),e.call(this,"ForeMethod implementation: at '".concat(t.getName(),"' method: '").concat(r,"'"))}return s(n)}(g(Error)),B=Object.freeze({__proto__:null,CommandAlreadyRegistered:L,CommandNotFound:P,ControllerAlreadyRegistered:T,ForceMethod:S}),M=0,D=function(){function t(){c(this,t),l(this,"virtualId",0),this.virtualId=M,M++}return s(t,[{key:"getName",value:function(){return this.constructor.getName()}}],[{key:"getName",value:function(){throw new H("ObjectBase","getName")}}]),t}();var R=function(t){f(p,t);var e,o,i,u,h=b(p);function p(){var t;return c(this,p),l(d(t=h.call(this)),"current",{}),l(d(t),"currentArgs",{}),l(d(t),"trace",[]),l(d(t),"commands",{}),l(d(t),"onBeforeHooks",{}),l(d(t),"onBeforeUIHooks",{}),l(d(t),"onAfterHooks",{}),l(d(t),"onAfterOnceHooks",{}),l(d(t),"onAfterUIHooks",{}),l(d(t),"onAfterAffectHooks",{}),t.logger=new A(t.getName(),!0),t.logger.startEmpty(),t}return s(p,[{key:"run",value:(u=a(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:{},o=a.length>2&&void 0!==a[2]?a[2]:{},"string"==typeof e&&(e=this.getCommandInstance(e,n,o)),this.attachCurrent(e,n),t.next=6,this.runInstance(e,n,o);case 6:return i=t.sent,this.detachCurrent(e),t.abrupt("return",i);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"register",value:function(t,e){var n=this,r={};return Object.values(t).forEach((function(t){var e=t.getName();if(n.commands[e])throw new L(t);n.commands[e]=t,r[e]=t})),r}},{key:"getAll",value:function(){return this.commands}},{key:"getByName",value:function(t){return this.commands[t]}},{key:"getLogger",value:function(){return this.logger}},{key:"getCommandInstance",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.commands[t];if(!r)throw new P(t);return new r(e,n)}},{key:"onBefore",value:function(t,e){p.hookCommand(this.onBeforeHooks,t,e)}},{key:"onBeforeUI",value:function(t,e){p.hookCommand(this.onBeforeUIHooks,t,e)}},{key:"onAfter",value:function(t,e){p.hookCommand(this.onAfterHooks,t,e)}},{key:"onAfterUI",value:function(t,e){p.hookCommand(this.onAfterUIHooks,t,e)}},{key:"onAfterOnce",value:function(t,e){p.hookCommand(this.onAfterOnceHooks,t,e)}},{key:"onAfterAffect",value:function(t,e){p.hookCommand(this.onAfterAffectHooks,t,e)}},{key:"onBeforeRun",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.onBeforeHooks[t.getName()]){var r=this.onBeforeHooks[t.getName()];r.forEach((function(t){return t(e,n)}))}if(this.onBeforeUIHooks[t.getName()]){var o=this.onBeforeUIHooks[t.getName()];o.forEach((function(t){return t(e,n)}))}}},{key:"runInstance",value:(i=a(r().mark((function t(e){var n,o,i,a=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=a.length>2&&void 0!==a[2]?a[2]:{},i=null,Object.keys(n=a.length>1&&void 0!==a[1]?a[1]:{}).length?(this.logger.startWith({command:e.getName(),options:o,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(n)):this.logger.startWith({command:e.getName(),options:o,args:n}),this.onBeforeRun(e,n,o),t.next=7,e.run();case 7:return i=t.sent,t.next=10,this.onAfterRun(e,n,o,i);case 10:return t.abrupt("return",i);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"onAfterRun",value:(o=a(r().mark((function t(e,o,i,a){var c=this;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=Object.assign({},i),!this.onAfterAffectHooks[e.getName()]){t.next=6;break}return this.onAfterAffectHooks[e.getName()].forEach((function(t){o.result=a,a=c.run(""+t,o,i)})),t.next=5,a;case 5:a=t.sent;case 6:if(!this.onAfterHooks){t.next=10;break}return o.result=a,t.next=10,p.runCallbacks(Object.assign([],this.onAfterHooks[e.getName()]),o,i);case 10:if(!this.onAfterOnceHooks){t.next=13;break}return t.next=13,p.runCallbacks(this.onAfterOnceHooks[e.getName()],o,n(n({},i),{},{pop:!0}));case 13:return this.onAfterUIHooks&&p.runCallbacks(Object.assign([],this.onAfterUIHooks[e.getName()]),o,i),t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return o.apply(this,arguments)})},{key:"attachCurrent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),p.trace.push(t.getName())}},{key:"detachCurrent",value:function(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],p.trace.pop(),this.trace.pop()}}],[{key:"getName",value:function(){return"Core/Managers/Commands"}},{key:"runCallbacks",value:(e=a(r().mark((function t(e){var n,o,i,a,c,u=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2&&void 0!==u[2]?u[2]:{},i=(null==e?void 0:e.length)||0,a=0;case 4:if(a>=i){t.next=13;break}if(c=!0===o.pop?e.pop():e[a]){t.next=8;break}throw Error("Callback is not defined.");case 8:return t.next=10,c(n,o);case 10:++a,t.next=4;break;case 13:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})},{key:"hookCommand",value:function(t,e,n){t[e]||(t[e]=[]),t[e].push(n)}}]),p}(D);l(R,"trace",[]);var U,F=function(t){f(n,t);var e=b(n);function n(){var t;c(this,n);for(var r=arguments.length,o=Array(r),i=0;r>i;i++)o[i]=arguments[i];return l(d(t=e.call.apply(e,[this].concat(o))),"controllers",{}),t}return s(n,[{key:"get",value:function(t){return this.controllers[t]}},{key:"getAll",value:function(){return this.controllers}},{key:"register",value:function(t){if(this.controllers[t.getName()])throw new T(t);return this.controllers[t.getName()]=t,t}}],[{key:"getName",value:function(){return"Core/Managers/Controllers"}}]),n}(D);!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(U||(U={}));var z=function(t){f(o,t);var e,n=b(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"http://localhost";return c(this,o),(t=n.call(this)).logger=new A(o.getName(),!0),t.logger.startWith({apiBaseUrl:e}),t.apiBaseUrl=e+"/",t}return s(o,[{key:"fetch",value:(e=a(r().mark((function t(e,n){var o,i,a,c,u,s,l,f,h=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.logger.startWith({path:e,method:n,body:c=h.length>2&&void 0!==h[2]?h[2]:null}),u={credentials:"include"},s={},[U.POST,U.PUT,U.PATCH].includes(n)?(Object.assign(s,{"Content-Type":"application/json"}),Object.assign(u,{method:n,headers:s,body:JSON.stringify(c)})):Object.assign(u,{headers:s}),t.next=6,globalThis.fetch(this.apiBaseUrl+e,u);case 6:return l=t.sent,f=void 0,t.prev=8,t.next=11,l.json();case 11:f=t.sent,t.next=18;break;case 14:return t.prev=14,t.t0=t.catch(8),console.error(t.t0),t.abrupt("return",!1);case 18:if(!(null!==(o=f)&&void 0!==o&&o.error&&null!==(i=f)&&void 0!==i&&i.global&&null!==(a=f)&&void 0!==a&&a.message)){t.next=20;break}throw Error(f.message);case 20:return this.logger.drop({path:e},f),t.abrupt("return",f);case 22:case"end":return t.stop()}}),t,this,[[8,14]])}))),function(t,n){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Clients/Http"}}]),o}(D),W=function(t){f(o,t);var e,n=b(o);function o(t){var e;return c(this,o),e=n.call(this),o.client=new z(t.baseURL),e}return s(o,[{key:"getClient",value:function(){return o.client}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.GET,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.PATCH,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.DELETE,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"create",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.currentHttpMethod=U.POST,w(h(o.prototype),"run",this).call(this,t,e,n)}},{key:"runInstance",value:(e=a(r().mark((function t(e){var n,i,a,c=arguments;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=c.length>1&&void 0!==c[1]?c[1]:{},i=c.length>2&&void 0!==c[2]?c[2]:{},this.currentHttpMethod){t.next=4;break}throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');case 4:return a={type:this.currentHttpMethod,args:{query:{},data:{}}},U.GET===this.currentHttpMethod?a.args.query=n:a.args.data=n,t.next=8,w(h(o.prototype),"runInstance",this).call(this,e,a,i);case 8:return n.result=t.sent,this.currentHttpMethod=U.__EMPTY__,t.abrupt("return",n.result);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}],[{key:"getName",value:function(){return"Core/Managers/Data"}}]),o}(R),G=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/Managers/Internal"}}]),n}(R),Y=[];function J(t){Z=new R,q=new F,K=new W(t),$=new G}function V(){Z={},q={},K={},$={}}var Z={},q={},K={},$={},Q=Object.freeze({__proto__:null,afterInitializeCallbacks:Y,get commands(){return Z},get controllers(){return q},get data(){return K},destroy:V,initialize:J,get internal(){return $}}),X=function(t){f(o,t);var e,n=b(o);function o(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c(this,o),l(d(t=n.call(this)),"args",{}),l(d(t),"options",{});var i=t.constructor.getName();return t.logger=new A(i,!0,{sameColor:!0}),t.logger.startWith({args:e,options:r}),t.initialize(e,r),t}return s(o,[{key:"initialize",value:function(t,e){this.args=t,this.options=e}},{key:"apply",value:function(){throw new S(this,"apply")}},{key:"run",value:(e=a(r().mark((function t(){var e;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.onBeforeApply&&this.onBeforeApply(),t.next=3,this.apply(this.args,this.options);case 3:return e=t.sent,this.onAfterApply&&this.onAfterApply(),t.abrupt("return",e);case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"getArgs",value:function(){return this.args}},{key:"getOptions",value:function(){return this.options}}]),o}(D),tt=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandPublic"}}]),n}(X),et=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,[{key:"getEndpoint",value:function(){throw new S(this,"getEndpoint")}},{key:"apply",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.args,e=this.applyEndpointFormat(this.getEndpoint(),t);return K.getClient().fetch(e,K.currentHttpMethod,t||null)}},{key:"applyEndpointFormat",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.includes("{")&&(t=t.split("/").map((function(t){var n=t.match("\\{(.*?)\\}");return null!=n&&n.length&&void 0!==e[n[1]]?e[n[1]]:t})).join("/")),t}}],[{key:"getName",value:function(){return"Core/CommandBases/CommandData"}}]),n}(X),nt=function(t){f(n,t);var e=b(n);function n(){return c(this,n),e.apply(this,arguments)}return s(n,null,[{key:"getName",value:function(){return"Core/CommandBases/CommandInternal"}}]),n}(X),rt=Object.freeze({__proto__:null,CommandBase:X,CommandData:et,CommandInternal:nt,CommandPublic:tt}),ot=Object.freeze({__proto__:null,Controller:function(t){f(n,t);var e=b(n);function n(){var t;return c(this,n),(t=e.call(this)).initialize(),t}return s(n,[{key:"initialize",value:function(){this.register(),this.setupHooks&&this.setupHooks()}},{key:"register",value:function(){this.commands=Z.register(this.getCommands(),this),this.data=K.register(this.getData(),this),this.internal=$.register(this.getInternal(),this)}},{key:"getCommands",value:function(){return{}}},{key:"getData",value:function(){return{}}},{key:"getInternal",value:function(){return{}}}],[{key:"getName",value:function(){return"Core/Core/Controller"}}]),n}(D),ObjectBase:D}),it=Object.freeze({__proto__:null,Commands:R,Controllers:F,Data:W,Internal:G}),at=Object.freeze({__proto__:null,commandBases:rt,core:ot,errors:B,managerBases:it,managers:Q,modules:I,utils:x}),ct=!1;function ut(){if(ct)throw Error("ZenCore is already initialized.")}ut();var st={version:E},lt=n({initialize:function(t){ut(),J(st=t||st),ct=!0},destroy:function(){V(),ct=!1},onAfterInitialize:function(t){Y.push(t)},config:st},at);null!==globalThis&&void 0!==globalThis&&globalThis.ZenCore||(globalThis.ZenCore=lt),t.commandBases=rt,t.core=ot,t.default=lt,t.errors=B,t.managerBases=it,t.managers=Q,t.modules=I,t.utils=x,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@zenflux/core", | ||
"version": "0.0.0-alpha.4", | ||
"version": "0.0.0-alpha.5", | ||
"description": "ZenFlux core", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package