@adaas/a-utils 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +74 -22
- package/dist/index.d.ts +74 -22
- package/dist/index.mjs +28 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Signal/A-Signal.types.ts +21 -4
- package/src/lib/A-Signal/context/A-SignalState.context.ts +1 -4
- package/src/lib/A-Signal/entities/A-Signal.entity.ts +108 -4
- package/src/lib/A-Signal/entities/A-SignalVector.entity.ts +89 -21
- package/tests/A-Signal.test.ts +52 -14
package/dist/index.cjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
'use strict';var aConcept=require('@adaas/a-concept'),aFrame=require('@adaas/a-frame');var pt=Object.defineProperty;var Pt=Object.getOwnPropertyDescriptor;var i=(re,t)=>pt(re,"name",{value:t,configurable:true});var a=(re,t,e,r)=>{for(var o=r>1?void 0:r?Pt(t,e):t,n=re.length-1,s;n>=0;n--)(s=re[n])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&pt(t,e,o),o},l=(re,t)=>(e,r)=>t(e,r,re);exports.A_ExecutionContext=class R extends aConcept.A_Fragment{constructor(t,e){super({name:t}),this._meta=new aConcept.A_Meta;for(let r in e)this._meta.set(r,e[r]);}[Symbol.iterator](){return this._meta[Symbol.iterator]()}get meta(){return this._meta}get(t){return this._meta.get(t)}set(t,e){return this._meta.set(t,e),this}has(t){return this._meta.has(t)}drop(t){this._meta.delete(t);}clear(){return this._meta.clear(),this}toRaw(){return this._meta.toJSON()}toJSON(){return {name:this.name,...this.meta.toJSON()}}};i(exports.A_ExecutionContext,"A_ExecutionContext"),exports.A_ExecutionContext=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-ExecutionContext",description:"Execution context fragment that provides a structured way to manage metadata and serialized data for execution environments. It allows storing and retrieving key-value pairs, facilitating context-aware operations within the application. It useful in cases when it's necessary to share some runtime data across multiple steps of thee features, or components."})],exports.A_ExecutionContext);exports.A_OperationContext=class d extends exports.A_ExecutionContext{constructor(t,e){super("operation-context"),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(exports.A_OperationContext,"A_OperationContext"),exports.A_OperationContext=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-OperationContext",description:"Operation execution context that encapsulates the metadata and serialized data related to a specific operation. It provides structured access to operation parameters, results, and error handling, facilitating the management of operation lifecycles within the application."})],exports.A_OperationContext);var xe=class xe extends aConcept.A_Error{constructor(t,e){aConcept.A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof exports.A_OperationContext&&(this._context=e);}get context(){return this._context}};i(xe,"A_ChannelError"),xe.MethodNotImplemented="A-Channel Method Not Implemented";var oe=xe;var kt=(u=>(u.onTimeout="_A_Channel_onTimeout",u.onRetry="_A_Channel_onRetry",u.onCircuitBreakerOpen="_A_Channel_onCircuitBreakerOpen",u.onCache="_A_Channel_onCache",u.onConnect="_A_Channel_onConnect",u.onDisconnect="_A_Channel_onDisconnect",u.onBeforeRequest="_A_Channel_onBeforeRequest",u.onRequest="_A_Channel_onRequest",u.onAfterRequest="_A_Channel_onAfterRequest",u.onError="_A_Channel_onError",u.onSend="_A_Channel_onSend",u.onConsume="_A_Channel_onConsume",u))(kt||{}),Mt=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(Mt||{});exports.A_ChannelRequest=class H extends exports.A_OperationContext{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(exports.A_ChannelRequest,"A_ChannelRequest"),exports.A_ChannelRequest=a([aFrame.A_Frame.Fragment({name:"A-ChannelRequest",description:"Context for managing channel requests. It encapsulates the request parameters and the result including status and data."})],exports.A_ChannelRequest);exports.A_Channel=class I extends aConcept.A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("_A_Channel_onConnect");}async disconnect(){await this.call("_A_Channel_onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:request:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),o=new exports.A_ChannelRequest(e);try{return r.register(o),await this.call("_A_Channel_onBeforeRequest",r),await this.call("_A_Channel_onRequest",r),await this.call("_A_Channel_onAfterRequest",r),this._processing=!1,o}catch(n){this._processing=false;let s=new oe(n);throw o.fail(s),r.register(s),await this.call("_A_Channel_onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:send:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),o=new exports.A_OperationContext("send",e);try{r.inherit(aConcept.A_Context.scope(this)),r.register(o),await this.call("_A_Channel_onSend",r),this._processing=!1;}catch(n){this._processing=false;let s=new oe(n);r.register(s),o.fail(s),await this.call("_A_Channel_onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new aConcept.A_Scope({name:`a-channel@scope:consume:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),r=new exports.A_OperationContext("consume",{});try{return e.inherit(aConcept.A_Context.scope(this)),e.register(r),await this.call("_A_Channel_onConsume",e),this._processing=!1,r}catch(o){this._processing=false;let n=new oe(o);return r.fail(n),await this.call("_A_Channel_onError",e),r}}};i(exports.A_Channel,"A_Channel"),a([aConcept.A_Feature.Extend({name:"_A_Channel_onConnect"})],exports.A_Channel.prototype,"onConnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onDisconnect"})],exports.A_Channel.prototype,"onDisconnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onBeforeRequest"})],exports.A_Channel.prototype,"onBeforeRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onRequest"})],exports.A_Channel.prototype,"onRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onAfterRequest"})],exports.A_Channel.prototype,"onAfterRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onError"})],exports.A_Channel.prototype,"onError",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onSend"})],exports.A_Channel.prototype,"onSend",1),exports.A_Channel=a([aFrame.A_Frame.Namespace("A-Utils"),aFrame.A_Frame.Component({name:"A-Channel",description:"Component uses as abstract channel for communication patterns. Can be inherited and extended to implement custom channels."})],exports.A_Channel);var $t=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))($t||{}),Ft=(o=>(o.CREATED_TO_INITIALIZED="created_initialized",o.INITIALIZED_TO_EXECUTING="initialized_executing",o.EXECUTING_TO_COMPLETED="executing_completed",o.EXECUTING_TO_FAILED="executing_failed",o))(Ft||{}),Yt=(c=>(c.onInit="_A_Command_onInit",c.onBeforeExecute="_A_Command_onBeforeExecute",c.onExecute="_A_Command_onExecute",c.onAfterExecute="_A_Command_onAfterExecute",c.onComplete="_A_Command_onComplete",c.onFail="_A_Command_onFail",c.onError="_A_Command_onError",c))(Yt||{}),zt=(c=>(c.onInit="onInit",c.onBeforeExecute="onBeforeExecute",c.onExecute="onExecute",c.onAfterExecute="onAfterExecute",c.onComplete="onComplete",c.onFail="onFail",c.onError="onError",c))(zt||{});var ie=class ie extends aConcept.A_Error{};i(ie,"A_CommandError"),ie.CommandScopeBindingError="A-Command Scope Binding Error",ie.ExecutionError="A-Command Execution Error",ie.ResultProcessingError="A-Command Result Processing Error",ie.CommandInterruptedError="A-Command Interrupted Error";var q=ie;var ye=class ye extends aConcept.A_Error{};i(ye,"A_StateMachineError"),ye.InitializationError="A-StateMachine Initialization Error",ye.TransitionError="A-StateMachine Transition Error";var pe=ye;var Ht=(o=>(o.onError="_A_StateMachine_onError",o.onInitialize="_A_StateMachine_onInitialize",o.onBeforeTransition="_A_StateMachine_onBeforeTransition",o.onAfterTransition="_A_StateMachine_onAfterTransition",o))(Ht||{});exports.A_StateMachineTransition=class P extends exports.A_OperationContext{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(exports.A_StateMachineTransition,"A_StateMachineTransition"),exports.A_StateMachineTransition=a([aFrame.A_Frame.Fragment({name:"A-StateMachineTransition",description:"Context for managing state machine transitions."})],exports.A_StateMachineTransition);var Jt,Xt,Zt,Qt;exports.A_StateMachine=class E extends aConcept.A_Component{get ready(){return this._initialized||(this._initialized=this.call("_A_StateMachine_onInitialize")),this._initialized}async[Qt="_A_StateMachine_onInitialize"](...t){}async[Zt="_A_StateMachine_onBeforeTransition"](...t){}async[Xt="_A_StateMachine_onAfterTransition"](...t){}async[Jt="_A_StateMachine_onError"](...t){}async transition(t,e,r){await this.ready;let o=`${aConcept.A_FormatterHelper.toCamelCase(String(t))}_${aConcept.A_FormatterHelper.toCamelCase(String(e))}`,n=new exports.A_StateMachineTransition({from:String(t),to:String(e),props:r}),s=new aConcept.A_Scope({name:`A-StateMachine-Transition-Scope-${o}`,fragments:[n]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_StateMachine_onBeforeTransition",s),await this.call(o,s),await this.call("_A_StateMachine_onAfterTransition",s),s.destroy(),n.result}catch(c){let p=new pe({title:pe.TransitionError,description:`An error occurred while transitioning to "${o}"`,originalError:c});throw s.register(p),await this.call("_A_StateMachine_onError",s),s.destroy(),p}}};i(exports.A_StateMachine,"A_StateMachine"),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Qt,1),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Zt,1),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Xt,1),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Jt,1),a([aFrame.A_Frame.Method({name:"transition",description:"Executes a state transition from one state to another."})],exports.A_StateMachine.prototype,"transition",1),exports.A_StateMachine=a([aFrame.A_Frame.Namespace("A-Utils"),aFrame.A_Frame.Component({name:"A-StateMachine",description:"A powerful state machine component for managing complex state transitions."})],exports.A_StateMachine);var zn={},_e=[];var we=class we extends aConcept.A_Error{};i(we,"A_ConfigError"),we.InitializationError="A-Config Initialization Error";var B=we;exports.A_Config=class h extends exports.A_ExecutionContext{constructor(e){super("a-config");this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,..._e];this._strict=e.strict??false,this._configProperties=e.variables??[];for(let r in e.defaults)this.set(aConcept.A_FormatterHelper.toUpperSnakeCase(r),e.defaults[r]);}get strict(){return this._strict}get(e){if(this._configProperties.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this._strict)return super.get(aConcept.A_FormatterHelper.toUpperSnakeCase(e));throw new B("Property not exists or not allowed to read")}set(e,r){let o=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(n=>({property:n,value:e[n]}));for(let{property:n,value:s}of o)super.set(aConcept.A_FormatterHelper.toUpperSnakeCase(n),s);}};i(exports.A_Config,"A_Config"),exports.A_Config=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-Config",description:"Configuration management context that provides structured access to application configuration variables, supporting defaults and strict mode for enhanced reliability. Default environment variables are included for comprehensive configuration handling."})],exports.A_Config);var dt=20,ti="all",ut={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},gt=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],Z={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},me={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},x={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},de={DEFAULT_WIDTH:80,MIN_WIDTH:40,MAX_LINE_LENGTH_RATIO:.8,BROWSER_DEFAULT_WIDTH:120},Ee={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};exports.A_Logger=class C extends aConcept.A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=ut,this.STANDARD_SCOPE_LENGTH=r?.get(Ee.DEFAULT_SCOPE_LENGTH)||20;let o=r?.get(Ee.DEFAULT_SCOPE_COLOR),n=r?.get(Ee.DEFAULT_LOG_COLOR);if(o||n)this.DEFAULT_SCOPE_COLOR=o||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=n||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}this.TERMINAL_WIDTH=this.detectTerminalWidth(),this.MAX_CONTENT_WIDTH=Math.floor(this.TERMINAL_WIDTH*de.MAX_LINE_LENGTH_RATIO);}simpleHash(e){let r=0;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);r=(r<<5)-r+n,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=gt,n=this.simpleHash(e)%r.length;return r[n]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],n=this.simpleHash(e)%r.length;return r[n]}detectTerminalWidth(){try{if(aConcept.A_Context.environment==="browser")return de.BROWSER_DEFAULT_WIDTH;if(typeof process<"u"&&process.stdout&&process.stdout.columns){let e=process.stdout.columns;return Math.max(e,de.MIN_WIDTH)}return de.DEFAULT_WIDTH}catch{return de.DEFAULT_WIDTH}}wrapText(e,r,o=true){if(aConcept.A_Context.environment==="browser")return [e];let n=this.formattedScope.length+4+this.getTime().length+4,s=`${r}${x.PIPE}`,c=Math.max(this.TERMINAL_WIDTH-n-1,20),p=Math.max(this.TERMINAL_WIDTH-s.length,20);if(o&&e.length<=c)return [e];let m=[],_=e.split(" "),g="",u=o?c:p;for(let z of _){let $e=g?1:0;if(g.length+$e+z.length>u)if(g)m.push(g),g=z,u=p;else {if(z.length>u){let Fe=this.splitLongWord(z,u);m.push(...Fe.slice(0,-1)),g=Fe[Fe.length-1];}else g=z;u=p;}else g+=(g?" ":"")+z;}return g&&m.push(g),m.length?m:[e]}splitLongWord(e,r){let o=[];for(let n=0;n<e.length;n+=r)o.push(e.slice(n,n+r));return o}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let o=r-e.length,n=Math.floor(o/2),s=o-n;return " ".repeat(n)+e+" ".repeat(s)}compile(e,...r){let o=this.getTime(),n=" ".repeat(this.STANDARD_SCOPE_LENGTH+3),s=r.length>1;return [`${Z.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${Z.SUFFIX}${x.SCOPE_OPEN}${this.formattedScope}${x.SCOPE_CLOSE}${Z.RESET} ${Z.PREFIX}${this.COLORS[e]}${Z.SUFFIX}${x.TIME_OPEN}${o}${x.TIME_CLOSE}`,s?`
|
|
2
|
-
${
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
`).map(_=>{let
|
|
1
|
+
'use strict';var aConcept=require('@adaas/a-concept'),aFrame=require('@adaas/a-frame');var pt=Object.defineProperty;var Pt=Object.getOwnPropertyDescriptor;var i=(re,t)=>pt(re,"name",{value:t,configurable:true});var a=(re,t,e,r)=>{for(var n=r>1?void 0:r?Pt(t,e):t,o=re.length-1,s;o>=0;o--)(s=re[o])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&pt(t,e,n),n},l=(re,t)=>(e,r)=>t(e,r,re);exports.A_ExecutionContext=class R extends aConcept.A_Fragment{constructor(t,e){super({name:t}),this._meta=new aConcept.A_Meta;for(let r in e)this._meta.set(r,e[r]);}[Symbol.iterator](){return this._meta[Symbol.iterator]()}get meta(){return this._meta}get(t){return this._meta.get(t)}set(t,e){return this._meta.set(t,e),this}has(t){return this._meta.has(t)}drop(t){this._meta.delete(t);}clear(){return this._meta.clear(),this}toRaw(){return this._meta.toJSON()}toJSON(){return {name:this.name,...this.meta.toJSON()}}};i(exports.A_ExecutionContext,"A_ExecutionContext"),exports.A_ExecutionContext=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-ExecutionContext",description:"Execution context fragment that provides a structured way to manage metadata and serialized data for execution environments. It allows storing and retrieving key-value pairs, facilitating context-aware operations within the application. It useful in cases when it's necessary to share some runtime data across multiple steps of thee features, or components."})],exports.A_ExecutionContext);exports.A_OperationContext=class m extends exports.A_ExecutionContext{constructor(t,e){super("operation-context"),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(exports.A_OperationContext,"A_OperationContext"),exports.A_OperationContext=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-OperationContext",description:"Operation execution context that encapsulates the metadata and serialized data related to a specific operation. It provides structured access to operation parameters, results, and error handling, facilitating the management of operation lifecycles within the application."})],exports.A_OperationContext);var xe=class xe extends aConcept.A_Error{constructor(t,e){aConcept.A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof exports.A_OperationContext&&(this._context=e);}get context(){return this._context}};i(xe,"A_ChannelError"),xe.MethodNotImplemented="A-Channel Method Not Implemented";var ne=xe;var kt=(g=>(g.onTimeout="_A_Channel_onTimeout",g.onRetry="_A_Channel_onRetry",g.onCircuitBreakerOpen="_A_Channel_onCircuitBreakerOpen",g.onCache="_A_Channel_onCache",g.onConnect="_A_Channel_onConnect",g.onDisconnect="_A_Channel_onDisconnect",g.onBeforeRequest="_A_Channel_onBeforeRequest",g.onRequest="_A_Channel_onRequest",g.onAfterRequest="_A_Channel_onAfterRequest",g.onError="_A_Channel_onError",g.onSend="_A_Channel_onSend",g.onConsume="_A_Channel_onConsume",g))(kt||{}),Mt=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(Mt||{});exports.A_ChannelRequest=class H extends exports.A_OperationContext{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(exports.A_ChannelRequest,"A_ChannelRequest"),exports.A_ChannelRequest=a([aFrame.A_Frame.Fragment({name:"A-ChannelRequest",description:"Context for managing channel requests. It encapsulates the request parameters and the result including status and data."})],exports.A_ChannelRequest);exports.A_Channel=class L extends aConcept.A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("_A_Channel_onConnect");}async disconnect(){await this.call("_A_Channel_onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:request:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),n=new exports.A_ChannelRequest(e);try{return r.register(n),await this.call("_A_Channel_onBeforeRequest",r),await this.call("_A_Channel_onRequest",r),await this.call("_A_Channel_onAfterRequest",r),this._processing=!1,n}catch(o){this._processing=false;let s=new ne(o);throw n.fail(s),r.register(s),await this.call("_A_Channel_onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:send:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),n=new exports.A_OperationContext("send",e);try{r.inherit(aConcept.A_Context.scope(this)),r.register(n),await this.call("_A_Channel_onSend",r),this._processing=!1;}catch(o){this._processing=false;let s=new ne(o);r.register(s),n.fail(s),await this.call("_A_Channel_onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new aConcept.A_Scope({name:`a-channel@scope:consume:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),r=new exports.A_OperationContext("consume",{});try{return e.inherit(aConcept.A_Context.scope(this)),e.register(r),await this.call("_A_Channel_onConsume",e),this._processing=!1,r}catch(n){this._processing=false;let o=new ne(n);return r.fail(o),await this.call("_A_Channel_onError",e),r}}};i(exports.A_Channel,"A_Channel"),a([aConcept.A_Feature.Extend({name:"_A_Channel_onConnect"})],exports.A_Channel.prototype,"onConnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onDisconnect"})],exports.A_Channel.prototype,"onDisconnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onBeforeRequest"})],exports.A_Channel.prototype,"onBeforeRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onRequest"})],exports.A_Channel.prototype,"onRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onAfterRequest"})],exports.A_Channel.prototype,"onAfterRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onError"})],exports.A_Channel.prototype,"onError",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onSend"})],exports.A_Channel.prototype,"onSend",1),exports.A_Channel=a([aFrame.A_Frame.Namespace("A-Utils"),aFrame.A_Frame.Component({name:"A-Channel",description:"Component uses as abstract channel for communication patterns. Can be inherited and extended to implement custom channels."})],exports.A_Channel);var $t=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))($t||{}),Ft=(n=>(n.CREATED_TO_INITIALIZED="created_initialized",n.INITIALIZED_TO_EXECUTING="initialized_executing",n.EXECUTING_TO_COMPLETED="executing_completed",n.EXECUTING_TO_FAILED="executing_failed",n))(Ft||{}),zt=(c=>(c.onInit="_A_Command_onInit",c.onBeforeExecute="_A_Command_onBeforeExecute",c.onExecute="_A_Command_onExecute",c.onAfterExecute="_A_Command_onAfterExecute",c.onComplete="_A_Command_onComplete",c.onFail="_A_Command_onFail",c.onError="_A_Command_onError",c))(zt||{}),Yt=(c=>(c.onInit="onInit",c.onBeforeExecute="onBeforeExecute",c.onExecute="onExecute",c.onAfterExecute="onAfterExecute",c.onComplete="onComplete",c.onFail="onFail",c.onError="onError",c))(Yt||{});var ie=class ie extends aConcept.A_Error{};i(ie,"A_CommandError"),ie.CommandScopeBindingError="A-Command Scope Binding Error",ie.ExecutionError="A-Command Execution Error",ie.ResultProcessingError="A-Command Result Processing Error",ie.CommandInterruptedError="A-Command Interrupted Error";var q=ie;var ye=class ye extends aConcept.A_Error{};i(ye,"A_StateMachineError"),ye.InitializationError="A-StateMachine Initialization Error",ye.TransitionError="A-StateMachine Transition Error";var pe=ye;var Ht=(n=>(n.onError="_A_StateMachine_onError",n.onInitialize="_A_StateMachine_onInitialize",n.onBeforeTransition="_A_StateMachine_onBeforeTransition",n.onAfterTransition="_A_StateMachine_onAfterTransition",n))(Ht||{});exports.A_StateMachineTransition=class P extends exports.A_OperationContext{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(exports.A_StateMachineTransition,"A_StateMachineTransition"),exports.A_StateMachineTransition=a([aFrame.A_Frame.Fragment({name:"A-StateMachineTransition",description:"Context for managing state machine transitions."})],exports.A_StateMachineTransition);var Kt,Xt,Zt,Qt;exports.A_StateMachine=class E extends aConcept.A_Component{get ready(){return this._initialized||(this._initialized=this.call("_A_StateMachine_onInitialize")),this._initialized}async[Qt="_A_StateMachine_onInitialize"](...t){}async[Zt="_A_StateMachine_onBeforeTransition"](...t){}async[Xt="_A_StateMachine_onAfterTransition"](...t){}async[Kt="_A_StateMachine_onError"](...t){}async transition(t,e,r){await this.ready;let n=`${aConcept.A_FormatterHelper.toCamelCase(String(t))}_${aConcept.A_FormatterHelper.toCamelCase(String(e))}`,o=new exports.A_StateMachineTransition({from:String(t),to:String(e),props:r}),s=new aConcept.A_Scope({name:`A-StateMachine-Transition-Scope-${n}`,fragments:[o]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_StateMachine_onBeforeTransition",s),await this.call(n,s),await this.call("_A_StateMachine_onAfterTransition",s),s.destroy(),o.result}catch(c){let p=new pe({title:pe.TransitionError,description:`An error occurred while transitioning to "${n}"`,originalError:c});throw s.register(p),await this.call("_A_StateMachine_onError",s),s.destroy(),p}}};i(exports.A_StateMachine,"A_StateMachine"),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Qt,1),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Zt,1),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Xt,1),a([aConcept.A_Feature.Extend()],exports.A_StateMachine.prototype,Kt,1),a([aFrame.A_Frame.Method({name:"transition",description:"Executes a state transition from one state to another."})],exports.A_StateMachine.prototype,"transition",1),exports.A_StateMachine=a([aFrame.A_Frame.Namespace("A-Utils"),aFrame.A_Frame.Component({name:"A-StateMachine",description:"A powerful state machine component for managing complex state transitions."})],exports.A_StateMachine);var Yo={},_e=[];var we=class we extends aConcept.A_Error{};i(we,"A_ConfigError"),we.InitializationError="A-Config Initialization Error";var B=we;exports.A_Config=class h extends exports.A_ExecutionContext{constructor(e){super("a-config");this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,..._e];this._strict=e.strict??false,this._configProperties=e.variables??[];for(let r in e.defaults)this.set(aConcept.A_FormatterHelper.toUpperSnakeCase(r),e.defaults[r]);}get strict(){return this._strict}get(e){if(this._configProperties.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this._strict)return super.get(aConcept.A_FormatterHelper.toUpperSnakeCase(e));throw new B("Property not exists or not allowed to read")}set(e,r){let n=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(o=>({property:o,value:e[o]}));for(let{property:o,value:s}of n)super.set(aConcept.A_FormatterHelper.toUpperSnakeCase(o),s);}};i(exports.A_Config,"A_Config"),exports.A_Config=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-Config",description:"Configuration management context that provides structured access to application configuration variables, supporting defaults and strict mode for enhanced reliability. Default environment variables are included for comprehensive configuration handling."})],exports.A_Config);var mt=20,ti="all",gt={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},ut=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],Z={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},de={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},x={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},me={DEFAULT_WIDTH:80,MIN_WIDTH:40,MAX_LINE_LENGTH_RATIO:.8,BROWSER_DEFAULT_WIDTH:120},Ee={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};exports.A_Logger=class C extends aConcept.A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=gt,this.STANDARD_SCOPE_LENGTH=r?.get(Ee.DEFAULT_SCOPE_LENGTH)||20;let n=r?.get(Ee.DEFAULT_SCOPE_COLOR),o=r?.get(Ee.DEFAULT_LOG_COLOR);if(n||o)this.DEFAULT_SCOPE_COLOR=n||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=o||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}this.TERMINAL_WIDTH=this.detectTerminalWidth(),this.MAX_CONTENT_WIDTH=Math.floor(this.TERMINAL_WIDTH*me.MAX_LINE_LENGTH_RATIO);}simpleHash(e){let r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);r=(r<<5)-r+o,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=ut,o=this.simpleHash(e)%r.length;return r[o]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],o=this.simpleHash(e)%r.length;return r[o]}detectTerminalWidth(){try{if(aConcept.A_Context.environment==="browser")return me.BROWSER_DEFAULT_WIDTH;if(typeof process<"u"&&process.stdout&&process.stdout.columns){let e=process.stdout.columns;return Math.max(e,me.MIN_WIDTH)}return me.DEFAULT_WIDTH}catch{return me.DEFAULT_WIDTH}}wrapText(e,r,n=true){if(aConcept.A_Context.environment==="browser")return [e];let o=this.formattedScope.length+4+this.getTime().length+4,s=`${r}${x.PIPE}`,c=Math.max(this.TERMINAL_WIDTH-o-1,20),p=Math.max(this.TERMINAL_WIDTH-s.length,20);if(n&&e.length<=c)return [e];let d=[],_=e.split(" "),u="",g=n?c:p;for(let Y of _){let $e=u?1:0;if(u.length+$e+Y.length>g)if(u)d.push(u),u=Y,g=p;else {if(Y.length>g){let Fe=this.splitLongWord(Y,g);d.push(...Fe.slice(0,-1)),u=Fe[Fe.length-1];}else u=Y;g=p;}else u+=(u?" ":"")+Y;}return u&&d.push(u),d.length?d:[e]}splitLongWord(e,r){let n=[];for(let o=0;o<e.length;o+=r)n.push(e.slice(o,o+r));return n}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let n=r-e.length,o=Math.floor(n/2),s=n-o;return " ".repeat(o)+e+" ".repeat(s)}compile(e,...r){let n=this.getTime(),o=" ".repeat(this.STANDARD_SCOPE_LENGTH+3),s=r.length>1;return [`${Z.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${Z.SUFFIX}${x.SCOPE_OPEN}${this.formattedScope}${x.SCOPE_CLOSE}${Z.RESET} ${Z.PREFIX}${this.COLORS[e]}${Z.SUFFIX}${x.TIME_OPEN}${n}${x.TIME_CLOSE}`,s?`
|
|
2
|
+
${o}${x.TIME_OPEN}${x.SEPARATOR}`:"",...r.map((c,p)=>{let d=p>0||s;switch(true){case c instanceof aConcept.A_Error:return this.compile_A_Error(c);case c instanceof Error:return this.compile_Error(c);case(typeof c=="object"&&c!==null):return this.formatObject(c,d,o);default:return this.formatString(String(c),d,o)}}),s?`
|
|
3
|
+
${o}${x.TIME_OPEN}${x.SEPARATOR}${Z.RESET}`:Z.RESET]}formatObject(e,r,n){if(aConcept.A_Context.environment==="browser")return e;if(e===null)return r?`
|
|
4
|
+
${n}${x.PIPE}null`:"null";if(e===void 0)return r?`
|
|
5
|
+
${n}${x.PIPE}undefined`:"undefined";let o;try{o=JSON.stringify(e,null,2);}catch{try{let u=new WeakSet;o=JSON.stringify(e,(g,G)=>{if(typeof G=="object"&&G!==null){if(u.has(G))return "[Circular Reference]";u.add(G);}return G},2);}catch{o=String(e);}}let s=`${n}${x.PIPE}`,c=this.TERMINAL_WIDTH-s.length-4,d=o.split(`
|
|
6
|
+
`).map(_=>{let u=_.match(/^(\s*"[^"]+":\s*")([^"]+)(".*)?$/);if(u&&u[2].length>c-u[1].length-(u[3]||"").length){let[,g,G,Y=""]=u;if(G.length>c-g.length-Y.length){let $e=this.wrapJsonStringValue(G,c-g.length-Y.length);return g+$e+Y}}return _}).join(`
|
|
7
7
|
`+s);return r?`
|
|
8
|
-
`+s+
|
|
8
|
+
`+s+d:d}wrapJsonStringValue(e,r){return e.length<=r?e:r>6?e.substring(0,r-3)+"...":e.substring(0,Math.max(1,r))}formatString(e,r,n){if(aConcept.A_Context.environment==="browser")return ((r?`
|
|
9
9
|
`:"")+e).replace(/\n/g,`
|
|
10
|
-
${
|
|
10
|
+
${n}${x.PIPE}`);let o=this.wrapText(e,n,!r),s=`${n}${x.PIPE}`,c=o.map((p,d)=>d===0&&!r?p:`${s}${p}`);return r?`
|
|
11
11
|
`+c.join(`
|
|
12
12
|
`):c.join(`
|
|
13
|
-
`)}shouldLog(e){switch(this.config?.get(Ee.LOG_LEVEL)||"info"){case "debug":return true;case "info":return e==="info"||e==="warning"||e==="error";case "warn":return e==="warning"||e==="error";case "error":return e==="error";case "all":return true;default:return false}}debug(e,...r){this.shouldLog("debug")&&(typeof e=="string"&&this.COLORS[e]?console.log(...this.compile(e,...r)):console.log(...this.compile(this.DEFAULT_LOG_COLOR,e,...r)));}info(e,...r){this.shouldLog("info")&&(typeof e=="string"&&this.COLORS[e]?console.log(...this.compile(e,...r)):console.log(...this.compile(this.DEFAULT_LOG_COLOR,e,...r)));}log(e,...r){this.info(e,...r);}warning(...e){this.shouldLog("warning")&&console.log(...this.compile("yellow",...e));}error(...e){this.shouldLog("error")&&console.log(...this.compile("red",...e));}log_A_Error(e){let r=this.getTime(),
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
${
|
|
18
|
-
`).map((
|
|
13
|
+
`)}shouldLog(e){switch(this.config?.get(Ee.LOG_LEVEL)||"info"){case "debug":return true;case "info":return e==="info"||e==="warning"||e==="error";case "warn":return e==="warning"||e==="error";case "error":return e==="error";case "all":return true;default:return false}}debug(e,...r){this.shouldLog("debug")&&(typeof e=="string"&&this.COLORS[e]?console.log(...this.compile(e,...r)):console.log(...this.compile(this.DEFAULT_LOG_COLOR,e,...r)));}info(e,...r){this.shouldLog("info")&&(typeof e=="string"&&this.COLORS[e]?console.log(...this.compile(e,...r)):console.log(...this.compile(this.DEFAULT_LOG_COLOR,e,...r)));}log(e,...r){this.info(e,...r);}warning(...e){this.shouldLog("warning")&&console.log(...this.compile("yellow",...e));}error(...e){this.shouldLog("error")&&console.log(...this.compile("red",...e));}log_A_Error(e){let r=this.getTime(),n=" ".repeat(this.STANDARD_SCOPE_LENGTH+3);console.log(`\x1B[31m[${this.formattedScope}] |${r}| ERROR ${e.code}
|
|
14
|
+
${n}| ${e.message}
|
|
15
|
+
${n}| ${e.description}
|
|
16
|
+
${n}|-------------------------------
|
|
17
|
+
${n}| ${e.stack?.split(`
|
|
18
|
+
`).map((o,s)=>s===0?o:`${n}| ${o}`).join(`
|
|
19
19
|
`)||"No stack trace"}
|
|
20
|
-
${
|
|
21
|
-
\x1B[0m`+(e.originalError?`\x1B[31m${
|
|
22
|
-
${
|
|
23
|
-
${
|
|
24
|
-
`).map((
|
|
20
|
+
${n}|-------------------------------
|
|
21
|
+
\x1B[0m`+(e.originalError?`\x1B[31m${n}| Wrapped From ${e.originalError.message}
|
|
22
|
+
${n}|-------------------------------
|
|
23
|
+
${n}| ${e.originalError.stack?.split(`
|
|
24
|
+
`).map((o,s)=>s===0?o:`${n}| ${o}`).join(`
|
|
25
25
|
`)||"No stack trace"}
|
|
26
|
-
${
|
|
27
|
-
\x1B[0m`:"")+(e.link?`\x1B[31m${
|
|
28
|
-
${
|
|
29
|
-
\x1B[0m`:""));}compile_A_Error(e){let r=`${" ".repeat(this.STANDARD_SCOPE_LENGTH+3)}${x.PIPE}`,
|
|
30
|
-
`)}formatStackTrace(e,r){let
|
|
31
|
-
`),
|
|
32
|
-
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(me.MINUTES_PAD,"0"),o=String(e.getSeconds()).padStart(me.SECONDS_PAD,"0"),n=String(e.getMilliseconds()).padStart(me.MILLISECONDS_PAD,"0");return `${r}${me.SEPARATOR}${o}${me.SEPARATOR}${n}`}};i(exports.A_Logger,"A_Logger"),exports.A_Logger=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A_Logger",description:"Advanced Logging Component with Scope-based Output Formatting that provides color-coded console output, multi-type support, and configurable log levels for enhanced debugging and monitoring."}),l(0,aConcept.A_Inject(aConcept.A_Scope)),l(1,aConcept.A_Inject(exports.A_Config))],exports.A_Logger);var lr,pr,_r,mr,dr,ur,gr,hr,fr,yr,Er;exports.A_Command=class A extends aConcept.A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get context(){return this.scope.resolve(exports.A_ExecutionContext)}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[Er="_A_StateMachine_onBeforeTransition"](e,r,...o){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[yr="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[fr="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[hr="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[gr="executing_failed"](e,r,...o){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[ur="_A_Command_onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[dr="_A_Command_onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[mr="_A_Command_onExecute"](...e){}async[_r="_A_Command_onAfterExecute"](...e){}async[pr="_A_Command_onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[lr="_A_Command_onFail"](e,r,...o){await e.transition("EXECUTING","FAILED");}async init(){await this.call("_A_Command_onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new exports.A_ExecutionContext("execute-command");this.scope.register(e),await new Promise(async(r,o)=>{try{let n=new aConcept.A_Feature({name:"_A_Command_onBeforeExecute",component:this,scope:this.scope}),s=new aConcept.A_Feature({name:"_A_Command_onExecute",component:this,scope:this.scope}),c=new aConcept.A_Feature({name:"_A_Command_onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{n.interrupt(),s.interrupt(),c.interrupt(),r();}),this.on("onFail",()=>{n.interrupt(),s.interrupt(),c.interrupt(),o(this.error);}),await n.process(this.scope),await s.process(this.scope),await c.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(n){o(n);}});}catch(e){let r=e instanceof aConcept.A_Error?e:new q({title:q.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("_A_Command_onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("_A_Command_onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[exports.A_StateMachine]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[exports.A_StateMachine]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new q(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=aConcept.A_Context.scope(this);}catch(r){throw new q({title:q.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(aConcept.A_Context.scope(this))||this.scope.inherit(aConcept.A_Context.scope(this));}};i(exports.A_Command,"A_Command"),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition)),l(1,aConcept.A_Inject(exports.A_Logger))],exports.A_Command.prototype,Er,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition))],exports.A_Command.prototype,yr,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition))],exports.A_Command.prototype,fr,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition))],exports.A_Command.prototype,hr,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition)),l(1,aConcept.A_Inject(aConcept.A_Error))],exports.A_Command.prototype,gr,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachine))],exports.A_Command.prototype,ur,1),a([aConcept.A_Feature.Extend({after:/.*/}),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_StateMachine))],exports.A_Command.prototype,dr,1),a([aConcept.A_Feature.Extend()],exports.A_Command.prototype,mr,1),a([aConcept.A_Feature.Extend()],exports.A_Command.prototype,_r,1),a([aConcept.A_Feature.Extend({after:/.*/}),l(0,aConcept.A_Inject(exports.A_StateMachine))],exports.A_Command.prototype,pr,1),a([aConcept.A_Feature.Extend({after:/.*/}),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_StateMachine)),l(1,aConcept.A_Inject(exports.A_ExecutionContext))],exports.A_Command.prototype,lr,1),exports.A_Command=a([aFrame.A_Frame.Entity({namespace:"A-Utils",name:"A-Command",description:"Advanced Command Pattern Implementation with full lifecycle management, event handling, and state persistence. This entity allows to execute commands in distributed environment across multiple services."})],exports.A_Command);var qe=class qe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(qe,"A_FSPolyfillClass");var Re=qe;var je=class je{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(o,n)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),c=this._fsPolyfill.createReadStream(e);c.on("data",p=>s.update(p)),c.on("end",()=>o(`${r}-${s.digest("base64")}`)),c.on("error",p=>n(p));}catch(s){n(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,o)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),c=await crypto.subtle.digest(e,s),p=Array.from(new Uint8Array(c)),m=btoa(String.fromCharCode(...p));r(`${e}-${m}`);}catch(n){o(n);}}),"createTextHash")};}};i(je,"A_CryptoPolyfillClass");var Pe=je;var Ke=class Ke{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Ke,"A_HttpPolyfillClass");var Le=Ke;var We=class We{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(We,"A_HttpsPolyfillClass");var Ie=We;var Je=class Je{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),o=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:o}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(Je,"A_PathPolyfillClass");var Oe=Je;var Xe=class Xe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(Xe,"A_UrlPolyfillClass");var be=Xe;var Ze=class Ze{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,c)=>s+c.length,0),o=new Uint8Array(r),n=0;for(let s of t)o.set(s,n),n+=s.length;return o},"concat")};}};i(Ze,"A_BufferPolyfillClass");var Ne=Ze;var Qe=class Qe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{aConcept.A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(Qe,"A_ProcessPolyfillClass");var De=Qe;exports.A_Polyfill=class T extends aConcept.A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){aConcept.A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new Re(this.logger),this._cryptoPolyfill=new Pe(this.logger),this._httpPolyfill=new Le(this.logger),this._httpsPolyfill=new Ie(this.logger),this._pathPolyfill=new Oe(this.logger),this._urlPolyfill=new be(this.logger),this._bufferPolyfill=new Ne(this.logger),this._processPolyfill=new De(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(exports.A_Polyfill,"A_Polyfill"),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"load",1),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"attachToWindow",1),exports.A_Polyfill=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-Polyfill",description:"Polyfill component that provides cross-environment compatibility for Node.js core modules such as fs, crypto, http, https, path, url, buffer, and process. It dynamically loads appropriate polyfills based on the execution environment (Node.js or browser), enabling seamless usage of these modules in different contexts."}),l(0,aConcept.A_Inject(exports.A_Logger))],exports.A_Polyfill);exports.ConfigReader=class b extends aConcept.A_Component{constructor(e){super();this.polyfill=e;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,..._e];}async attachContext(e,r,o){o||(o=new exports.A_Config({defaults:{}}),e.scope.register(o));let n=await this.getProjectRoot();o.set("A_CONCEPT_ROOT_FOLDER",n);}async initialize(e){let r=await this.read();for(let o in r)e.set(o,r[o]);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return (await this.polyfill.process()).cwd()}};i(exports.ConfigReader,"ConfigReader"),a([aConcept.A_Concept.Load(),l(0,aConcept.A_Inject(aConcept.A_Container)),l(1,aConcept.A_Inject(aConcept.A_Scope)),l(2,aConcept.A_Inject(exports.A_Config))],exports.ConfigReader.prototype,"attachContext",1),a([aConcept.A_Concept.Load(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_Config))],exports.ConfigReader.prototype,"initialize",1),exports.ConfigReader=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"ConfigReader",description:"Abstract component for reading configuration data from various sources such as files, environment variables, or remote services. This component can be extended to implement specific configuration reading strategies."}),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_Polyfill))],exports.ConfigReader);exports.FileConfigReader=class j extends exports.ConfigReader{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return aConcept.A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let o=r.readFileSync(`${aConcept.A_Context.concept}.conf.json`,"utf8"),n=JSON.parse(o);return this.FileData=new Map(Object.entries(n)),n}catch{return {}}}};i(exports.FileConfigReader,"FileConfigReader"),exports.FileConfigReader=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"FileConfigReader",description:"Configuration reader that loads configuration data from a JSON file located in the application root directory. It reads the file named after the current concept with a .conf.json extension and parses its contents into the configuration context."})],exports.FileConfigReader);exports.ENVConfigReader=class G extends exports.ConfigReader{async readEnvFile(t,e,r){let o=await e.fs();o.existsSync(".env")&&o.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
33
|
-
`).forEach(n=>{let[s,c]=n.split("=");s&&c&&(process.env[s.trim()]=c.trim());});}getConfigurationProperty_ENV_Alias(t){return aConcept.A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(o=>{r[o]=this.resolve(o);}),r}};i(exports.ENVConfigReader,"ENVConfigReader"),a([aConcept.A_Concept.Load({before:["ENVConfigReader.initialize"]}),l(0,aConcept.A_Inject(exports.A_Config)),l(1,aConcept.A_Inject(exports.A_Polyfill)),l(2,aConcept.A_Inject(aConcept.A_Feature))],exports.ENVConfigReader.prototype,"readEnvFile",1),exports.ENVConfigReader=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"ENVConfigReader",description:"Configuration reader that sources configuration data from environment variables. It supports loading variables from a .env file and maps them to the configuration context, making it suitable for applications running in diverse environments such as local development, staging, and production."})],exports.ENVConfigReader);exports.A_ConfigLoader=class Q extends aConcept.A_Container{async prepare(t){if(!this.scope.has(exports.A_Config)){let r=new exports.A_Config({variables:[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,..._e],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(aConcept.A_Context.environment==="server"&&!!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(exports.FileConfigReader);break;case(aConcept.A_Context.environment==="server"&&!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(exports.ENVConfigReader);break;case aConcept.A_Context.environment==="browser":this.reader=this.scope.resolve(exports.ENVConfigReader);break;default:throw new B(B.InitializationError,`Environment ${aConcept.A_Context.environment} is not supported`)}}catch(r){if(r instanceof aConcept.A_ScopeError)throw new B({title:B.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${aConcept.A_Context.environment}`,originalError:r})}}};i(exports.A_ConfigLoader,"A_ConfigLoader"),a([aConcept.A_Concept.Load({before:/.*/}),l(0,aConcept.A_Inject(exports.A_Polyfill))],exports.A_ConfigLoader.prototype,"prepare",1),exports.A_ConfigLoader=a([aFrame.A_Frame.Container({namespace:"A-Utils",name:"A-ConfigLoader",description:"Container responsible for loading and initializing the A_Config component based on the environment and available configuration sources. It can be useful for application that need a separated configuration management and sharable across multiple containers."})],exports.A_ConfigLoader);var Jr=(re=>re)(Jr||{});var ke={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},Us=[ke.A_LOGGER_LEVEL,ke.A_LOGGER_DEFAULT_SCOPE_LENGTH,ke.A_LOGGER_DEFAULT_SCOPE_COLOR,ke.A_LOGGER_DEFAULT_LOG_COLOR];var Me=class Me extends aConcept.A_Error{};i(Me,"A_ManifestError"),Me.ManifestInitializationError="A-Manifest Initialization Error";var ee=Me;var tt=class tt{constructor(t,e,r,o=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=o;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(tt,"A_ManifestChecker");var ue=tt;exports.A_Manifest=class ae extends aConcept.A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!aConcept.A_TypeGuards.isArray(e))throw new ee(ee.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!aConcept.A_TypeGuards.isComponentConstructor(e.component))throw new ee(ee.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let o=/.*/;this.rules.push({componentRegex:r,methodRegex:o,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let o of e.methods){let n=this.methodToRegex(o.method);this.rules.push({componentRegex:r,methodRegex:n,applyRegex:o.apply?this.allowedComponentsToRegex(o.apply):void 0,excludeRegex:o.exclude?this.allowedComponentsToRegex(o.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(o=>this.escapeRegex(o.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let o=typeof e=="function"?e:e.constructor;return new ue(this,o,r)}internal_checkAccess(e){let r=e.component.name,o=e.method,n=e.target.name,s=this.rules.filter(c=>c.componentRegex.test(r)&&c.methodRegex.test(o)).sort((c,p)=>{let m=c.methodRegex.source===".*",_=p.methodRegex.source===".*";return m&&!_?1:!m&&_?-1:0});if(s.length===0)return true;for(let c of s){if(c.excludeRegex&&c.excludeRegex.test(n))return false;if(c.applyRegex)return c.applyRegex.test(n)}return true}isExcluded(e,r){let o=typeof e=="function"?e:e.constructor;return new ue(this,o,r,true)}};i(exports.A_Manifest,"A_Manifest"),exports.A_Manifest=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-Manifest",description:"A-Manifest is a configuration fragment that allows to include or exclude component application for particular methods. It provides fine-grained control over which components are applied to which targets and methods within the application, enabling flexible and dynamic behavior based on defined rules."})],exports.A_Manifest);var eo=(_=>(_.onInit="_A_Memory_onInit",_.onDestroy="_A_Memory_onDestroy",_.onExpire="_A_Memory_onExpire",_.onError="_A_Memory_onError",_.onSerialize="_A_Memory_onSerialize",_.onSet="_A_Memory_onSet",_.onGet="_A_Memory_onGet",_.onDrop="_A_Memory_onDrop",_.onClear="_A_Memory_onClear",_.onHas="_A_Memory_onHas",_))(eo||{});exports.A_MemoryContext=class w extends aConcept.A_Fragment{constructor(){super(...arguments);this._storage=new Map;}set(e,r){this._storage.set(e,r);}get(e){return this._storage.get(e)}delete(e){this._storage.delete(e);}has(e){return this._storage.has(e)}clear(){this._storage.clear();}};i(exports.A_MemoryContext,"A_MemoryContext"),exports.A_MemoryContext=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-MemoryContext",description:"In-memory context fragment that provides a simple key-value store for temporary data storage during application runtime. It allows setting, getting, deleting, and checking the existence of key-value pairs, facilitating quick access to transient data without persistent storage. This context is useful for scenarios where data needs to be shared across different components or operations within the same execution context."})],exports.A_MemoryContext);var $=class $ extends aConcept.A_Error{};i($,"A_MemoryError"),$.MemoryInitializationError="Memory initialization error",$.MemoryDestructionError="Memory destruction error",$.MemoryGetError="Memory GET operation failed",$.MemorySetError="Memory SET operation failed",$.MemoryDropError="Memory DROP operation failed",$.MemoryClearError="Memory CLEAR operation failed",$.MemoryHasError="Memory HAS operation failed",$.MemorySerializeError="Memory toJSON operation failed";var f=$;var so,ao,co,lo,po,_o,mo,uo,go;exports.A_Memory=class v extends aConcept.A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[go="_A_Memory_onError"](...t){}async[uo="_A_Memory_onExpire"](...t){}async[mo="_A_Memory_onInit"](t,...e){t||(t=new exports.A_MemoryContext,aConcept.A_Context.scope(this).register(t));}async[_o="_A_Memory_onDestroy"](t,...e){t.clear();}async[po="_A_Memory_onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[lo="_A_Memory_onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[co="_A_Memory_onSet"](t,e,r,...o){e.set(t.params.key,t.params.value);}async[ao="_A_Memory_onDrop"](t,e,...r){e.delete(t.params.key);}async[so="_A_Memory_onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new aConcept.A_Scope({name:"A-Memory-Init-Scope"}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onInit",t);}catch(e){let r=new f({title:f.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async destroy(){let t=new aConcept.A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(aConcept.A_Context.scope(this));try{this._ready=void 0,await this.call("_A_Memory_onDestroy",t);}catch(e){let r=new f({title:f.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async get(t){let e=new exports.A_OperationContext("get",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onGet",r),r.destroy(),e.result}catch(o){let n=new f({title:f.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async has(t){let e=new exports.A_OperationContext("has",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onHas",r),r.destroy(),e.result}catch(o){let n=new f({title:f.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async set(t,e){let r=new exports.A_OperationContext("set",{key:t,value:e}),o=new aConcept.A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onSet",o);}catch(n){let s=new f({title:f.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:n});throw o.register(s),await this.call("_A_Memory_onError",o),o.destroy(),s}}async drop(t){let e=new exports.A_OperationContext("drop",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onDrop",r);}catch(o){let n=new f({title:f.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async clear(){let t=new exports.A_OperationContext("clear"),e=new aConcept.A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onClear",e);}catch(r){let o=new f({title:f.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}async toJSON(){let t=new exports.A_OperationContext("serialize"),e=new aConcept.A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onSerialize",e),t.result}catch(r){let o=new f({title:f.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}};i(exports.A_Memory,"A_Memory"),a([aConcept.A_Feature.Extend()],exports.A_Memory.prototype,go,1),a([aConcept.A_Feature.Extend()],exports.A_Memory.prototype,uo,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,mo,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,_o,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,po,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,lo,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext)),l(2,aConcept.A_Inject(aConcept.A_Scope))],exports.A_Memory.prototype,co,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,ao,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,so,1),exports.A_Memory=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-Memory",description:"In-memory data storage component that provides a simple key-value store with asynchronous operations. It supports basic memory operations such as get, set, has, drop, and clear, along with lifecycle management and error handling features. This components features can be extended with other components to provide ability store data across multiple storage, or extract data from multiple external sources. Good example is to store some runtime data that needs to be shared across multiple containers or concepts."})],exports.A_Memory);var ho=(_=>(_.onBeforeLoad="_A_Service_onBeforeLoad",_.onLoad="_A_Service_onLoad",_.onAfterLoad="_A_Service_onAfterLoad",_.onBeforeStart="_A_Service_onBeforeStart",_.onStart="_A_Service_onStart",_.onAfterStart="_A_Service_onAfterStart",_.onBeforeStop="_A_Service_onBeforeStop",_.onStop="_A_Service_onStop",_.onAfterStop="_A_Service_onAfterStop",_.onError="_A_Service_onError",_))(ho||{});var ge=class ge extends aConcept.A_Error{};i(ge,"A_Service_Error"),ge.ServiceLoadError="Service load error",ge.ServiceStartError="Service start error",ge.ServiceStopError="Service stop error";var L=ge;var To,Ao,So,xo,Co,wo,vo,Ro,Po,Lo;exports.A_Service=class y extends aConcept.A_Container{async load(){try{await this.call("_A_Service_onBeforeLoad"),await this.call("_A_Service_onLoad"),await this.call("_A_Service_onAfterLoad");}catch(t){let e;switch(true){case t instanceof L:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof L):e=t.originalError;break;default:e=new L({title:L.ServiceLoadError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async start(){try{await this.call("_A_Service_onBeforeStart"),await this.call("_A_Service_onStart"),await this.call("_A_Service_onAfterStart");}catch(t){let e;switch(true){case t instanceof L:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof L):e=t.originalError;break;default:e=new L({title:L.ServiceStartError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async stop(){try{await this.call("_A_Service_onBeforeStop"),await this.call("_A_Service_onStop"),await this.call("_A_Service_onAfterStop");}catch(t){let e;switch(true){case t instanceof L:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof L):e=t.originalError;break;default:e=new L({title:L.ServiceStopError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async[Lo="_A_Service_onBeforeLoad"](t,...e){t||(this.scope.register(exports.A_Polyfill),t=this.scope.resolve(exports.A_Polyfill));}async[Po="_A_Service_onLoad"](...t){}async[Ro="_A_Service_onAfterLoad"](...t){}async[vo="_A_Service_onBeforeStart"](...t){}async[wo="_A_Service_onStart"](...t){}async[Co="_A_Service_onAfterStart"](...t){}async[xo="_A_Service_onBeforeStop"](...t){}async[So="_A_Service_onStop"](...t){}async[Ao="_A_Service_onAfterStop"](...t){}async[To="_A_Service_onError"](t,e,...r){e?.error(t);}};i(exports.A_Service,"A_Service"),a([aConcept.A_Concept.Load()],exports.A_Service.prototype,"load",1),a([aConcept.A_Concept.Start()],exports.A_Service.prototype,"start",1),a([aConcept.A_Concept.Stop()],exports.A_Service.prototype,"stop",1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_Polyfill))],exports.A_Service.prototype,Lo,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Po,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Ro,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,vo,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,wo,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Co,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,xo,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,So,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Ao,1),a([aConcept.A_Feature.Extend({before:/.*/}),l(0,aConcept.A_Inject(aConcept.A_Error)),l(1,aConcept.A_Inject(exports.A_Logger))],exports.A_Service.prototype,To,1),exports.A_Service=a([aFrame.A_Frame.Container({namespace:"A-Utils",name:"A-Service",description:"Service container that manages the lifecycle of various types of services, such as HTTP servers and workers or UI loader. It dynamically loads necessary components based on the provided configuration and orchestrates the start and stop processes, ensuring proper error handling and extensibility through feature hooks."})],exports.A_Service);exports.A_Route=class ce extends aConcept.A_Fragment{constructor(t){super(),this.url=t instanceof RegExp?t.source:t;}get path(){let t=this.url.split("?")[0].split("#")[0];if(t.includes("://")){let e=t.indexOf("/",t.indexOf("://")+3);if(e===-1)return "/";{let r=t.slice(e);return r.endsWith("/")?r.slice(0,-1):r}}return t.endsWith("/")?t.slice(0,-1):t}get params(){return this.path.match(/:([^\/]+)/g)?.map(t=>t.slice(1))||[]}get protocol(){switch(true){case this.url.startsWith("http://"):return "http";case this.url.startsWith("https://"):return "https";case this.url.startsWith("ws://"):return "ws";case this.url.startsWith("wss://"):return "wss";default:return this.url.includes("://")?this.url.split("://")[0]:"http"}}extractParams(t){let r=t.split("?")[0].split("/").filter(Boolean),o=this.path.split("/").filter(Boolean),n={};for(let s=0;s<o.length;s++){let c=o[s],p=r[s];if(c.startsWith(":")){let m=c.slice(1);n[m]=p;}else if(c!==p)return {}}return n}extractQuery(t){let e={},r=t.split("?")[1];if(!r)return e;let o=r.split("#")[0];for(let n of o.split("&")){if(!n)continue;let[s,c=""]=n.split("=");e[decodeURIComponent(s)]=decodeURIComponent(c);}return e}toString(){return `${this.path}`}toRegExp(){return new RegExp(`^${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}toAFeatureExtension(t=[]){return new RegExp(`^${t.length?`(${t.join("|")})`:".*"}\\.${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}};i(exports.A_Route,"A_Route"),exports.A_Route=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-Route",description:"Route fragment that defines URL patterns for routing purposes. It supports dynamic parameters and query extraction, allowing for flexible route definitions. This fragment can be used in routing systems to match incoming URLs against defined routes and extract relevant parameters and query strings."})],exports.A_Route);exports.A_Signal=class S extends aConcept.A_Entity{static async default(){}fromJSON(t){super.fromJSON(t),this.data=t.data;}fromNew(t){this.aseid=this.generateASEID({entity:t.name}),this.data=t.data;}toJSON(){return {...super.toJSON(),data:this.data}}};i(exports.A_Signal,"A_Signal"),exports.A_Signal=a([aFrame.A_Frame.Entity({namespace:"A-Utils",name:"A-Signal",description:"A Signal Entity represents an individual signal instance that carries data, used for managing state within an application context. Signals are designed to reflect the current state rather than individual events, making them suitable for scenarios where state monitoring and real-time updates are essential."})],exports.A_Signal);exports.A_SignalVector=class X extends aConcept.A_Entity{fromNew(t){super.fromNew(t),this._structure=t.structure,this._signals=t.values;}get structure(){return this._structure||this._signals.map(t=>t.constructor)}get length(){return this.structure.length}[Symbol.iterator](){let t=0,e=this.structure.map(r=>{let o=this._signals.findIndex(n=>n.constructor===r);return o!==-1?this._signals[o]:void 0});return {next(){return t<e.length?{done:false,value:e[t++]}:{done:true,value:void 0}}}}has(t){let e;return t instanceof aConcept.A_Entity?e=t.constructor:e=t,this.structure.includes(e)}get(t){let e;t instanceof aConcept.A_Entity?e=t.constructor:e=t;let r=this._signals.findIndex(o=>o.constructor===e);if(r!==-1)return this._signals[r]}async toVector(t){return (t||this.structure).map(r=>{let o=this._signals.findIndex(n=>n.constructor===r);return o!==-1?this._signals[o]:void 0})}async toDataVector(t){let e=t||this.structure,r=[];for(let o of e){let n=this._signals.findIndex(c=>c.constructor===o),s;n===-1?s=await o.default():s=this._signals[n],r.push(s?.toJSON().data);}return r}async toObject(t){let e=t||this.structure,r={};return e.forEach(o=>{let n=o.name,s=this._signals.findIndex(c=>c.constructor===o);if(s!==-1){let c=this._signals[s];r[n]=c.toJSON().data;}else r[n]=void 0;}),r}toJSON(){return {...super.toJSON(),structure:this.structure.map(t=>t.name),values:this._signals.map(t=>t.toJSON())}}};i(exports.A_SignalVector,"A_SignalVector"),exports.A_SignalVector=a([aFrame.A_Frame.Entity({namespace:"A-Utils",name:"A-SignalVector",description:"A Signal Vector Entity represents a collection of signals structured in a specific way, allowing for batch processing and transmission of related signals as a unified state representation."})],exports.A_SignalVector);exports.A_SignalState=class F extends aConcept.A_Fragment{constructor(e){super({name:"A_SignalState"});this._state=new Map;this._prevState=new Map;this._structure=e;}get structure(){return this._structure||[]}set(e,r){let o=e instanceof exports.A_Signal?e.constructor:e,n=e instanceof exports.A_Signal?e:r;this._prevState.set(o,this._state.get(o)),this._state.set(o,n);}get(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this._state.get(r)}getPrev(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this._prevState.get(r)}has(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this.structure.includes(r)}delete(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this._state.delete(r)}toVector(){let e=[];return this._state.forEach((r,o)=>{e.push(r);}),new exports.A_SignalVector({structure:this.structure,values:e})}toObject(){let e={};return this.structure.forEach(r=>{let o=this._state.get(r);if(o===void 0)throw new Error(`Signal ${r.name} has no value in state`);e[r.name]=o;}),e}};i(exports.A_SignalState,"A_SignalState"),exports.A_SignalState=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-SignalState",description:"Manages the latest state of all signals within a given scope, maintaining a mapping between signal constructors and their most recently emitted values."})],exports.A_SignalState);exports.A_SignalConfig=class Y extends aConcept.A_Fragment{get structure(){if(this._structure)return this._structure;let t=aConcept.A_Context.scope(this);return [...t.allowedEntities].filter(r=>aConcept.A_CommonHelper.isInheritedFrom(r,exports.A_Signal)).sort((r,o)=>r.constructor.name.localeCompare(o.name)).map(r=>t.resolveConstructor(r.name)).filter(r=>r)}get ready(){return this._ready}constructor(t){super({name:"A_SignalConfig"}),this._config=t;}async initialize(){return this._ready||(this._ready=this._initialize()),this._ready}async _initialize(){if(this._config.structure)this._structure=this._config.structure;else if(this._config.stringStructure){let t=this._config.stringStructure.split(",").map(e=>e.trim());this._structure=t.map(e=>aConcept.A_Context.scope(this).resolveConstructor(e)).filter(e=>e);}}};i(exports.A_SignalConfig,"A_SignalConfig"),exports.A_SignalConfig=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-SignalConfig",description:"Signal configuration fragment that defines the structure and types of signals within a given scope. It allows specifying the expected signal constructors and their order, facilitating consistent signal management and processing across components that emit or listen to signals."})],exports.A_SignalConfig);var Fo=(r=>(r.onBeforeNext="_A_SignalBusFeatures_onBeforeNext",r.onNext="_A_SignalBusFeatures_onNext",r.onError="_A_SignalBusFeatures_onError",r))(Fo||{});var Ge=class Ge extends aConcept.A_Error{};i(Ge,"A_SignalBusError"),Ge.SignalProcessingError="Signal processing error";var te=Ge;var Bo,Vo,Ho;exports.A_SignalBus=class k extends aConcept.A_Component{async next(...t){let e=new aConcept.A_Scope({name:"A_SignalBus-Next-Scope",entities:t}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_SignalBusFeatures_onBeforeNext",e),await this.call("_A_SignalBusFeatures_onNext",e),e.destroy();}catch(r){let o;switch(true){case r instanceof te:o=r;break;case(r instanceof aConcept.A_Error&&r.originalError instanceof te):o=r.originalError;break;default:o=new te({title:te.SignalProcessingError,description:"An error occurred while processing the signal.",originalError:r});break}e.register(o),await this.call("_A_SignalBusFeatures_onError"),e.destroy();}}async[Ho="_A_SignalBusFeatures_onError"](t,e,...r){e?.error(t);}async[Vo="_A_SignalBusFeatures_onBeforeNext"](t,e,r,o,n){let s=aConcept.A_Context.scope(this);n||(n=new exports.A_SignalConfig({stringStructure:e?.get("A_SIGNAL_VECTOR_STRUCTURE")||void 0}),s.register(n)),n.ready||await n.initialize(),r||(r=new exports.A_SignalState(n.structure),s.register(r));}async[Bo="_A_SignalBusFeatures_onNext"](t,e,r,o,n,s){for(let p of t){if(!r.has(p))return;n?.debug(`A_SignalBus: Updating state for signal '${p.constructor.name}' with data:`,p.data),r.set(p);}let c=r.toVector();e.register(c);}};i(exports.A_SignalBus,"A_SignalBus"),a([aFrame.A_Frame.Method({description:"Emit multiple signals through the signal bus."})],exports.A_SignalBus.prototype,"next",1),a([aConcept.A_Feature.Extend({before:/.*/}),l(0,aConcept.A_Inject(aConcept.A_Error)),l(1,aConcept.A_Inject(exports.A_Logger))],exports.A_SignalBus.prototype,Ho,1),a([aConcept.A_Feature.Extend({scope:[exports.A_SignalBus],before:/.*/}),l(0,aConcept.A_Inject(aConcept.A_Scope)),l(1,aConcept.A_Inject(exports.A_Config)),l(2,aConcept.A_Inject(exports.A_SignalState)),l(3,aConcept.A_Inject(exports.A_Logger)),l(4,aConcept.A_Inject(exports.A_SignalConfig))],exports.A_SignalBus.prototype,Vo,1),a([aConcept.A_Feature.Extend({scope:[exports.A_SignalBus],before:/.*/}),l(0,aConcept.A_Dependency.Flat()),l(0,aConcept.A_Dependency.All()),l(0,aConcept.A_Inject(exports.A_Signal)),l(1,aConcept.A_Inject(aConcept.A_Scope)),l(2,aConcept.A_Dependency.Required()),l(2,aConcept.A_Inject(exports.A_SignalState)),l(3,aConcept.A_Inject(exports.A_Config)),l(4,aConcept.A_Inject(exports.A_Logger)),l(5,aConcept.A_Inject(exports.A_SignalConfig))],exports.A_SignalBus.prototype,Bo,1),exports.A_SignalBus=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-SignalBus",description:"Signal bus component that manages the emission and state of signals within a given scope. It listens for emitted signals, updates their state, and forwards them to registered watchers. The bus ensures a consistent signal vector structure based on the defined configuration, facilitating signal management across multiple components."})],exports.A_SignalBus);var ct=class ct{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(ct,"A_Deferred");var Se=ct;var lt=class lt{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new Se,this.timeout=setTimeout(()=>e().then((...o)=>this.deferred.resolve(...o)).catch((...o)=>this.deferred.reject(...o)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new aConcept.A_Error("Timeout Cleared")));}};i(lt,"A_ScheduleObject");var he=lt;exports.A_Schedule=class le extends aConcept.A_Component{async schedule(t,e,r){let o=aConcept.A_TypeGuards.isString(t)?new Date(t).getTime():t;return new he(o-Date.now(),e,r)}async delay(t,e,r){return new he(t,e,r)}};i(exports.A_Schedule,"A_Schedule"),exports.A_Schedule=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-Schedule",description:"Scheduling component that allows scheduling of callbacks to be executed at specific times or after certain delays. It provides methods to schedule callbacks based on Unix timestamps or ISO date strings, as well as a method to execute callbacks after a specified delay in milliseconds. This component is useful for managing timed operations within an application."})],exports.A_Schedule);
|
|
34
|
-
exports.A_CONSTANTS__CONFIG_ENV_VARIABLES=
|
|
26
|
+
${n}|-------------------------------
|
|
27
|
+
\x1B[0m`:"")+(e.link?`\x1B[31m${n}| Read in docs: ${e.link}
|
|
28
|
+
${n}|-------------------------------
|
|
29
|
+
\x1B[0m`:""));}compile_A_Error(e){let r=`${" ".repeat(this.STANDARD_SCOPE_LENGTH+3)}${x.PIPE}`,n=`${r}-------------------------------`,o=[];o.push(""),o.push(n),o.push(`${r}A_ERROR: ${e.code}`),o.push(n);let s=this.wrapText(`Message: ${e.message}`,r,false),c=this.wrapText(`Description: ${e.description}`,r,false);if(o.push(...s.map(p=>`${r}${p}`)),o.push(...c.map(p=>`${r}${p}`)),e.originalError){o.push(n),o.push(`${r}ORIGINAL ERROR:`),o.push(n);let p=this.wrapText(`${e.originalError.name}: ${e.originalError.message}`,r,false);if(o.push(...p.map(d=>`${r}${d}`)),e.originalError.stack){o.push(`${r}Stack trace:`);let d=this.formatStackTrace(e.originalError.stack,r);o.push(...d);}}if(e.stack){o.push(n),o.push(`${r}A_ERROR STACK:`),o.push(n);let p=this.formatStackTrace(e.stack,r);o.push(...p);}if(e.link){o.push(n);let p=this.wrapText(`Documentation: ${e.link}`,r,false);o.push(...p.map(d=>`${r}${d}`));}return o.push(n),o.join(`
|
|
30
|
+
`)}formatStackTrace(e,r){let n=e.split(`
|
|
31
|
+
`),o=[];return n.forEach((s,c)=>{if(s.trim()){let p=c===0?r:`${r} `,d=this.wrapText(s.trim(),p,false);o.push(...d.map(_=>c===0&&_===d[0]?`${r}${_}`:`${r} ${_}`));}}),o}compile_Error(e){let r=`${" ".repeat(this.STANDARD_SCOPE_LENGTH+3)}${x.PIPE}`,n=`${r}-------------------------------`,o=[];o.push(""),o.push(n),o.push(`${r}ERROR: ${e.name}`),o.push(n);let s=this.wrapText(`Message: ${e.message}`,r,false);if(o.push(...s.map(c=>`${r}${c}`)),e.stack){o.push(n),o.push(`${r}STACK TRACE:`),o.push(n);let c=this.formatStackTrace(e.stack,r);o.push(...c);}return o.push(n),o.join(`
|
|
32
|
+
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(de.MINUTES_PAD,"0"),n=String(e.getSeconds()).padStart(de.SECONDS_PAD,"0"),o=String(e.getMilliseconds()).padStart(de.MILLISECONDS_PAD,"0");return `${r}${de.SEPARATOR}${n}${de.SEPARATOR}${o}`}};i(exports.A_Logger,"A_Logger"),exports.A_Logger=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A_Logger",description:"Advanced Logging Component with Scope-based Output Formatting that provides color-coded console output, multi-type support, and configurable log levels for enhanced debugging and monitoring."}),l(0,aConcept.A_Inject(aConcept.A_Scope)),l(1,aConcept.A_Inject(exports.A_Config))],exports.A_Logger);var lr,pr,_r,dr,mr,gr,ur,hr,fr,yr,Er;exports.A_Command=class A extends aConcept.A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get context(){return this.scope.resolve(exports.A_ExecutionContext)}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[Er="_A_StateMachine_onBeforeTransition"](e,r,...n){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[yr="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[fr="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[hr="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[ur="executing_failed"](e,r,...n){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[gr="_A_Command_onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[mr="_A_Command_onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[dr="_A_Command_onExecute"](...e){}async[_r="_A_Command_onAfterExecute"](...e){}async[pr="_A_Command_onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[lr="_A_Command_onFail"](e,r,...n){await e.transition("EXECUTING","FAILED");}async init(){await this.call("_A_Command_onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new exports.A_ExecutionContext("execute-command");this.scope.register(e),await new Promise(async(r,n)=>{try{let o=new aConcept.A_Feature({name:"_A_Command_onBeforeExecute",component:this,scope:this.scope}),s=new aConcept.A_Feature({name:"_A_Command_onExecute",component:this,scope:this.scope}),c=new aConcept.A_Feature({name:"_A_Command_onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{o.interrupt(),s.interrupt(),c.interrupt(),r();}),this.on("onFail",()=>{o.interrupt(),s.interrupt(),c.interrupt(),n(this.error);}),await o.process(this.scope),await s.process(this.scope),await c.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(o){n(o);}});}catch(e){let r=e instanceof aConcept.A_Error?e:new q({title:q.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("_A_Command_onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("_A_Command_onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[exports.A_StateMachine]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[exports.A_StateMachine]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new q(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=aConcept.A_Context.scope(this);}catch(r){throw new q({title:q.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(aConcept.A_Context.scope(this))||this.scope.inherit(aConcept.A_Context.scope(this));}};i(exports.A_Command,"A_Command"),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition)),l(1,aConcept.A_Inject(exports.A_Logger))],exports.A_Command.prototype,Er,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition))],exports.A_Command.prototype,yr,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition))],exports.A_Command.prototype,fr,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition))],exports.A_Command.prototype,hr,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachineTransition)),l(1,aConcept.A_Inject(aConcept.A_Error))],exports.A_Command.prototype,ur,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_StateMachine))],exports.A_Command.prototype,gr,1),a([aConcept.A_Feature.Extend({after:/.*/}),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_StateMachine))],exports.A_Command.prototype,mr,1),a([aConcept.A_Feature.Extend()],exports.A_Command.prototype,dr,1),a([aConcept.A_Feature.Extend()],exports.A_Command.prototype,_r,1),a([aConcept.A_Feature.Extend({after:/.*/}),l(0,aConcept.A_Inject(exports.A_StateMachine))],exports.A_Command.prototype,pr,1),a([aConcept.A_Feature.Extend({after:/.*/}),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_StateMachine)),l(1,aConcept.A_Inject(exports.A_ExecutionContext))],exports.A_Command.prototype,lr,1),exports.A_Command=a([aFrame.A_Frame.Entity({namespace:"A-Utils",name:"A-Command",description:"Advanced Command Pattern Implementation with full lifecycle management, event handling, and state persistence. This entity allows to execute commands in distributed environment across multiple services."})],exports.A_Command);var qe=class qe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(qe,"A_FSPolyfillClass");var Re=qe;var je=class je{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(n,o)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),c=this._fsPolyfill.createReadStream(e);c.on("data",p=>s.update(p)),c.on("end",()=>n(`${r}-${s.digest("base64")}`)),c.on("error",p=>o(p));}catch(s){o(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,n)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),c=await crypto.subtle.digest(e,s),p=Array.from(new Uint8Array(c)),d=btoa(String.fromCharCode(...p));r(`${e}-${d}`);}catch(o){n(o);}}),"createTextHash")};}};i(je,"A_CryptoPolyfillClass");var Pe=je;var We=class We{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let o={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(o),0);}},"end"),write:i(o=>{},"write"),on:i((o,s)=>{},"on")}}};i(We,"A_HttpPolyfillClass");var Ie=We;var Je=class Je{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let o={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(o),0);}},"end"),write:i(o=>{},"write"),on:i((o,s)=>{},"on")}}};i(Je,"A_HttpsPolyfillClass");var Le=Je;var Ke=class Ke{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),n=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:n}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(Ke,"A_PathPolyfillClass");var Oe=Ke;var Xe=class Xe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(Xe,"A_UrlPolyfillClass");var be=Xe;var Ze=class Ze{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,c)=>s+c.length,0),n=new Uint8Array(r),o=0;for(let s of t)n.set(s,o),o+=s.length;return n},"concat")};}};i(Ze,"A_BufferPolyfillClass");var Ne=Ze;var Qe=class Qe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{aConcept.A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(Qe,"A_ProcessPolyfillClass");var De=Qe;exports.A_Polyfill=class T extends aConcept.A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){aConcept.A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new Re(this.logger),this._cryptoPolyfill=new Pe(this.logger),this._httpPolyfill=new Ie(this.logger),this._httpsPolyfill=new Le(this.logger),this._pathPolyfill=new Oe(this.logger),this._urlPolyfill=new be(this.logger),this._bufferPolyfill=new Ne(this.logger),this._processPolyfill=new De(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(exports.A_Polyfill,"A_Polyfill"),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"load",1),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"attachToWindow",1),exports.A_Polyfill=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-Polyfill",description:"Polyfill component that provides cross-environment compatibility for Node.js core modules such as fs, crypto, http, https, path, url, buffer, and process. It dynamically loads appropriate polyfills based on the execution environment (Node.js or browser), enabling seamless usage of these modules in different contexts."}),l(0,aConcept.A_Inject(exports.A_Logger))],exports.A_Polyfill);exports.ConfigReader=class b extends aConcept.A_Component{constructor(e){super();this.polyfill=e;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,..._e];}async attachContext(e,r,n){n||(n=new exports.A_Config({defaults:{}}),e.scope.register(n));let o=await this.getProjectRoot();n.set("A_CONCEPT_ROOT_FOLDER",o);}async initialize(e){let r=await this.read();for(let n in r)e.set(n,r[n]);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return (await this.polyfill.process()).cwd()}};i(exports.ConfigReader,"ConfigReader"),a([aConcept.A_Concept.Load(),l(0,aConcept.A_Inject(aConcept.A_Container)),l(1,aConcept.A_Inject(aConcept.A_Scope)),l(2,aConcept.A_Inject(exports.A_Config))],exports.ConfigReader.prototype,"attachContext",1),a([aConcept.A_Concept.Load(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_Config))],exports.ConfigReader.prototype,"initialize",1),exports.ConfigReader=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"ConfigReader",description:"Abstract component for reading configuration data from various sources such as files, environment variables, or remote services. This component can be extended to implement specific configuration reading strategies."}),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_Polyfill))],exports.ConfigReader);exports.FileConfigReader=class j extends exports.ConfigReader{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return aConcept.A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let n=r.readFileSync(`${aConcept.A_Context.concept}.conf.json`,"utf8"),o=JSON.parse(n);return this.FileData=new Map(Object.entries(o)),o}catch{return {}}}};i(exports.FileConfigReader,"FileConfigReader"),exports.FileConfigReader=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"FileConfigReader",description:"Configuration reader that loads configuration data from a JSON file located in the application root directory. It reads the file named after the current concept with a .conf.json extension and parses its contents into the configuration context."})],exports.FileConfigReader);exports.ENVConfigReader=class U extends exports.ConfigReader{async readEnvFile(t,e,r){let n=await e.fs();n.existsSync(".env")&&n.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
33
|
+
`).forEach(o=>{let[s,c]=o.split("=");s&&c&&(process.env[s.trim()]=c.trim());});}getConfigurationProperty_ENV_Alias(t){return aConcept.A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(n=>{r[n]=this.resolve(n);}),r}};i(exports.ENVConfigReader,"ENVConfigReader"),a([aConcept.A_Concept.Load({before:["ENVConfigReader.initialize"]}),l(0,aConcept.A_Inject(exports.A_Config)),l(1,aConcept.A_Inject(exports.A_Polyfill)),l(2,aConcept.A_Inject(aConcept.A_Feature))],exports.ENVConfigReader.prototype,"readEnvFile",1),exports.ENVConfigReader=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"ENVConfigReader",description:"Configuration reader that sources configuration data from environment variables. It supports loading variables from a .env file and maps them to the configuration context, making it suitable for applications running in diverse environments such as local development, staging, and production."})],exports.ENVConfigReader);exports.A_ConfigLoader=class Q extends aConcept.A_Container{async prepare(t){if(!this.scope.has(exports.A_Config)){let r=new exports.A_Config({variables:[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,..._e],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(aConcept.A_Context.environment==="server"&&!!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(exports.FileConfigReader);break;case(aConcept.A_Context.environment==="server"&&!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(exports.ENVConfigReader);break;case aConcept.A_Context.environment==="browser":this.reader=this.scope.resolve(exports.ENVConfigReader);break;default:throw new B(B.InitializationError,`Environment ${aConcept.A_Context.environment} is not supported`)}}catch(r){if(r instanceof aConcept.A_ScopeError)throw new B({title:B.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${aConcept.A_Context.environment}`,originalError:r})}}};i(exports.A_ConfigLoader,"A_ConfigLoader"),a([aConcept.A_Concept.Load({before:/.*/}),l(0,aConcept.A_Inject(exports.A_Polyfill))],exports.A_ConfigLoader.prototype,"prepare",1),exports.A_ConfigLoader=a([aFrame.A_Frame.Container({namespace:"A-Utils",name:"A-ConfigLoader",description:"Container responsible for loading and initializing the A_Config component based on the environment and available configuration sources. It can be useful for application that need a separated configuration management and sharable across multiple containers."})],exports.A_ConfigLoader);var Kr=(re=>re)(Kr||{});var ke={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},Gs=[ke.A_LOGGER_LEVEL,ke.A_LOGGER_DEFAULT_SCOPE_LENGTH,ke.A_LOGGER_DEFAULT_SCOPE_COLOR,ke.A_LOGGER_DEFAULT_LOG_COLOR];var Me=class Me extends aConcept.A_Error{};i(Me,"A_ManifestError"),Me.ManifestInitializationError="A-Manifest Initialization Error";var ee=Me;var tt=class tt{constructor(t,e,r,n=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=n;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(tt,"A_ManifestChecker");var ge=tt;exports.A_Manifest=class ae extends aConcept.A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!aConcept.A_TypeGuards.isArray(e))throw new ee(ee.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!aConcept.A_TypeGuards.isComponentConstructor(e.component))throw new ee(ee.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let n=/.*/;this.rules.push({componentRegex:r,methodRegex:n,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let n of e.methods){let o=this.methodToRegex(n.method);this.rules.push({componentRegex:r,methodRegex:o,applyRegex:n.apply?this.allowedComponentsToRegex(n.apply):void 0,excludeRegex:n.exclude?this.allowedComponentsToRegex(n.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(n=>this.escapeRegex(n.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let n=typeof e=="function"?e:e.constructor;return new ge(this,n,r)}internal_checkAccess(e){let r=e.component.name,n=e.method,o=e.target.name,s=this.rules.filter(c=>c.componentRegex.test(r)&&c.methodRegex.test(n)).sort((c,p)=>{let d=c.methodRegex.source===".*",_=p.methodRegex.source===".*";return d&&!_?1:!d&&_?-1:0});if(s.length===0)return true;for(let c of s){if(c.excludeRegex&&c.excludeRegex.test(o))return false;if(c.applyRegex)return c.applyRegex.test(o)}return true}isExcluded(e,r){let n=typeof e=="function"?e:e.constructor;return new ge(this,n,r,true)}};i(exports.A_Manifest,"A_Manifest"),exports.A_Manifest=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-Manifest",description:"A-Manifest is a configuration fragment that allows to include or exclude component application for particular methods. It provides fine-grained control over which components are applied to which targets and methods within the application, enabling flexible and dynamic behavior based on defined rules."})],exports.A_Manifest);var en=(_=>(_.onInit="_A_Memory_onInit",_.onDestroy="_A_Memory_onDestroy",_.onExpire="_A_Memory_onExpire",_.onError="_A_Memory_onError",_.onSerialize="_A_Memory_onSerialize",_.onSet="_A_Memory_onSet",_.onGet="_A_Memory_onGet",_.onDrop="_A_Memory_onDrop",_.onClear="_A_Memory_onClear",_.onHas="_A_Memory_onHas",_))(en||{});exports.A_MemoryContext=class w extends aConcept.A_Fragment{constructor(){super(...arguments);this._storage=new Map;}set(e,r){this._storage.set(e,r);}get(e){return this._storage.get(e)}delete(e){this._storage.delete(e);}has(e){return this._storage.has(e)}clear(){this._storage.clear();}};i(exports.A_MemoryContext,"A_MemoryContext"),exports.A_MemoryContext=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-MemoryContext",description:"In-memory context fragment that provides a simple key-value store for temporary data storage during application runtime. It allows setting, getting, deleting, and checking the existence of key-value pairs, facilitating quick access to transient data without persistent storage. This context is useful for scenarios where data needs to be shared across different components or operations within the same execution context."})],exports.A_MemoryContext);var $=class $ extends aConcept.A_Error{};i($,"A_MemoryError"),$.MemoryInitializationError="Memory initialization error",$.MemoryDestructionError="Memory destruction error",$.MemoryGetError="Memory GET operation failed",$.MemorySetError="Memory SET operation failed",$.MemoryDropError="Memory DROP operation failed",$.MemoryClearError="Memory CLEAR operation failed",$.MemoryHasError="Memory HAS operation failed",$.MemorySerializeError="Memory toJSON operation failed";var f=$;var an,cn,ln,pn,_n,dn,mn,gn,un;exports.A_Memory=class v extends aConcept.A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[un="_A_Memory_onError"](...t){}async[gn="_A_Memory_onExpire"](...t){}async[mn="_A_Memory_onInit"](t,...e){t||(t=new exports.A_MemoryContext,aConcept.A_Context.scope(this).register(t));}async[dn="_A_Memory_onDestroy"](t,...e){t.clear();}async[_n="_A_Memory_onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[pn="_A_Memory_onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[ln="_A_Memory_onSet"](t,e,r,...n){e.set(t.params.key,t.params.value);}async[cn="_A_Memory_onDrop"](t,e,...r){e.delete(t.params.key);}async[an="_A_Memory_onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new aConcept.A_Scope({name:"A-Memory-Init-Scope"}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onInit",t);}catch(e){let r=new f({title:f.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async destroy(){let t=new aConcept.A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(aConcept.A_Context.scope(this));try{this._ready=void 0,await this.call("_A_Memory_onDestroy",t);}catch(e){let r=new f({title:f.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async get(t){let e=new exports.A_OperationContext("get",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onGet",r),r.destroy(),e.result}catch(n){let o=new f({title:f.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:n});throw r.register(o),await this.call("_A_Memory_onError",r),r.destroy(),o}}async has(t){let e=new exports.A_OperationContext("has",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onHas",r),r.destroy(),e.result}catch(n){let o=new f({title:f.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:n});throw r.register(o),await this.call("_A_Memory_onError",r),r.destroy(),o}}async set(t,e){let r=new exports.A_OperationContext("set",{key:t,value:e}),n=new aConcept.A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onSet",n);}catch(o){let s=new f({title:f.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:o});throw n.register(s),await this.call("_A_Memory_onError",n),n.destroy(),s}}async drop(t){let e=new exports.A_OperationContext("drop",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onDrop",r);}catch(n){let o=new f({title:f.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:n});throw r.register(o),await this.call("_A_Memory_onError",r),r.destroy(),o}}async clear(){let t=new exports.A_OperationContext("clear"),e=new aConcept.A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onClear",e);}catch(r){let n=new f({title:f.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(n),await this.call("_A_Memory_onError",e),e.destroy(),n}}async toJSON(){let t=new exports.A_OperationContext("serialize"),e=new aConcept.A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onSerialize",e),t.result}catch(r){let n=new f({title:f.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(n),await this.call("_A_Memory_onError",e),e.destroy(),n}}};i(exports.A_Memory,"A_Memory"),a([aConcept.A_Feature.Extend()],exports.A_Memory.prototype,un,1),a([aConcept.A_Feature.Extend()],exports.A_Memory.prototype,gn,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,mn,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,dn,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,_n,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,pn,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext)),l(2,aConcept.A_Inject(aConcept.A_Scope))],exports.A_Memory.prototype,ln,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,cn,1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Dependency.Required()),l(0,aConcept.A_Inject(exports.A_OperationContext)),l(1,aConcept.A_Inject(exports.A_MemoryContext))],exports.A_Memory.prototype,an,1),exports.A_Memory=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-Memory",description:"In-memory data storage component that provides a simple key-value store with asynchronous operations. It supports basic memory operations such as get, set, has, drop, and clear, along with lifecycle management and error handling features. This components features can be extended with other components to provide ability store data across multiple storage, or extract data from multiple external sources. Good example is to store some runtime data that needs to be shared across multiple containers or concepts."})],exports.A_Memory);var hn=(_=>(_.onBeforeLoad="_A_Service_onBeforeLoad",_.onLoad="_A_Service_onLoad",_.onAfterLoad="_A_Service_onAfterLoad",_.onBeforeStart="_A_Service_onBeforeStart",_.onStart="_A_Service_onStart",_.onAfterStart="_A_Service_onAfterStart",_.onBeforeStop="_A_Service_onBeforeStop",_.onStop="_A_Service_onStop",_.onAfterStop="_A_Service_onAfterStop",_.onError="_A_Service_onError",_))(hn||{});var ue=class ue extends aConcept.A_Error{};i(ue,"A_Service_Error"),ue.ServiceLoadError="Service load error",ue.ServiceStartError="Service start error",ue.ServiceStopError="Service stop error";var I=ue;var Tn,An,Sn,xn,Cn,wn,vn,Rn,Pn,In;exports.A_Service=class y extends aConcept.A_Container{async load(){try{await this.call("_A_Service_onBeforeLoad"),await this.call("_A_Service_onLoad"),await this.call("_A_Service_onAfterLoad");}catch(t){let e;switch(true){case t instanceof I:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof I):e=t.originalError;break;default:e=new I({title:I.ServiceLoadError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async start(){try{await this.call("_A_Service_onBeforeStart"),await this.call("_A_Service_onStart"),await this.call("_A_Service_onAfterStart");}catch(t){let e;switch(true){case t instanceof I:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof I):e=t.originalError;break;default:e=new I({title:I.ServiceStartError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async stop(){try{await this.call("_A_Service_onBeforeStop"),await this.call("_A_Service_onStop"),await this.call("_A_Service_onAfterStop");}catch(t){let e;switch(true){case t instanceof I:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof I):e=t.originalError;break;default:e=new I({title:I.ServiceStopError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async[In="_A_Service_onBeforeLoad"](t,...e){t||(this.scope.register(exports.A_Polyfill),t=this.scope.resolve(exports.A_Polyfill));}async[Pn="_A_Service_onLoad"](...t){}async[Rn="_A_Service_onAfterLoad"](...t){}async[vn="_A_Service_onBeforeStart"](...t){}async[wn="_A_Service_onStart"](...t){}async[Cn="_A_Service_onAfterStart"](...t){}async[xn="_A_Service_onBeforeStop"](...t){}async[Sn="_A_Service_onStop"](...t){}async[An="_A_Service_onAfterStop"](...t){}async[Tn="_A_Service_onError"](t,e,...r){e?.error(t);}};i(exports.A_Service,"A_Service"),a([aConcept.A_Concept.Load()],exports.A_Service.prototype,"load",1),a([aConcept.A_Concept.Start()],exports.A_Service.prototype,"start",1),a([aConcept.A_Concept.Stop()],exports.A_Service.prototype,"stop",1),a([aConcept.A_Feature.Extend(),l(0,aConcept.A_Inject(exports.A_Polyfill))],exports.A_Service.prototype,In,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Pn,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Rn,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,vn,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,wn,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Cn,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,xn,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,Sn,1),a([aConcept.A_Feature.Extend()],exports.A_Service.prototype,An,1),a([aConcept.A_Feature.Extend({before:/.*/}),l(0,aConcept.A_Inject(aConcept.A_Error)),l(1,aConcept.A_Inject(exports.A_Logger))],exports.A_Service.prototype,Tn,1),exports.A_Service=a([aFrame.A_Frame.Container({namespace:"A-Utils",name:"A-Service",description:"Service container that manages the lifecycle of various types of services, such as HTTP servers and workers or UI loader. It dynamically loads necessary components based on the provided configuration and orchestrates the start and stop processes, ensuring proper error handling and extensibility through feature hooks."})],exports.A_Service);exports.A_Route=class ce extends aConcept.A_Fragment{constructor(t){super(),this.url=t instanceof RegExp?t.source:t;}get path(){let t=this.url.split("?")[0].split("#")[0];if(t.includes("://")){let e=t.indexOf("/",t.indexOf("://")+3);if(e===-1)return "/";{let r=t.slice(e);return r.endsWith("/")?r.slice(0,-1):r}}return t.endsWith("/")?t.slice(0,-1):t}get params(){return this.path.match(/:([^\/]+)/g)?.map(t=>t.slice(1))||[]}get protocol(){switch(true){case this.url.startsWith("http://"):return "http";case this.url.startsWith("https://"):return "https";case this.url.startsWith("ws://"):return "ws";case this.url.startsWith("wss://"):return "wss";default:return this.url.includes("://")?this.url.split("://")[0]:"http"}}extractParams(t){let r=t.split("?")[0].split("/").filter(Boolean),n=this.path.split("/").filter(Boolean),o={};for(let s=0;s<n.length;s++){let c=n[s],p=r[s];if(c.startsWith(":")){let d=c.slice(1);o[d]=p;}else if(c!==p)return {}}return o}extractQuery(t){let e={},r=t.split("?")[1];if(!r)return e;let n=r.split("#")[0];for(let o of n.split("&")){if(!o)continue;let[s,c=""]=o.split("=");e[decodeURIComponent(s)]=decodeURIComponent(c);}return e}toString(){return `${this.path}`}toRegExp(){return new RegExp(`^${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}toAFeatureExtension(t=[]){return new RegExp(`^${t.length?`(${t.join("|")})`:".*"}\\.${this.path.replace(/\/:([^\/]+)/g,"/([^/]+)")}$`)}};i(exports.A_Route,"A_Route"),exports.A_Route=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-Route",description:"Route fragment that defines URL patterns for routing purposes. It supports dynamic parameters and query extraction, allowing for flexible route definitions. This fragment can be used in routing systems to match incoming URLs against defined routes and extract relevant parameters and query strings."})],exports.A_Route);exports.A_Signal=class S extends aConcept.A_Entity{static async default(){}createHash(t){let e;if(t instanceof Map)e=JSON.stringify(Array.from(t.entries()));else if(t instanceof Set)e=JSON.stringify(Array.from(t.values()));else switch(typeof t){case "string":e=t;break;case "undefined":e="undefined";break;case "object":"toJSON"in t?e=JSON.stringify(t.toJSON()):e=JSON.stringify(t);break;case "number":e=t.toString();break;case "boolean":e=t?"true":"false";break;case "function":e=t.toString();break;default:e=String(t);}let r=0,n,o;for(n=0;n<e.length;n++)o=e.charCodeAt(n),r=(r<<5)-r+o,r|=0;return r.toString()}compare(t){return this.aseid.id===t.aseid.id}fromJSON(t){super.fromJSON(t),this.data=t.data;}fromNew(t){this.data=t.data;let e=t.id||{name:t.name,data:this.data},r=this.createHash(e);this.aseid=this.generateASEID({entity:t.name,id:r});}toJSON(){return {...super.toJSON(),data:this.data}}};i(exports.A_Signal,"A_Signal"),exports.A_Signal=a([aFrame.A_Frame.Entity({namespace:"A-Utils",name:"A-Signal",description:"A Signal Entity represents an individual signal instance that carries data, used for managing state within an application context. Signals are designed to reflect the current state rather than individual events, making them suitable for scenarios where state monitoring and real-time updates are essential."})],exports.A_Signal);exports.A_SignalVector=class X extends aConcept.A_Entity{constructor(t,e){"aseid"in t?super(t):super({structure:e||t.map(r=>r.constructor),values:t});}fromNew(t){super.fromNew(t),this._structure=t.structure,this._signals=t.values;}get structure(){return this._structure||this._signals.map(t=>t.constructor)}get length(){return this.structure.length}[Symbol.iterator](){let t=0,e=this.structure.map(r=>{let n=this._signals.findIndex(o=>o.constructor===r);return n!==-1?this._signals[n]:void 0});return {next(){return t<e.length?{done:false,value:e[t++]}:{done:true,value:void 0}}}}match(t){if(this.length!==t.length)return false;for(let e=0;e<this.length;e++){let r=this.structure[e],n=t.structure[e];if(r!==n)return false;let o=this._signals.findIndex(d=>d.constructor===r),s=t._signals.findIndex(d=>d.constructor===n),c=o!==-1?this._signals[o]:void 0,p=s!==-1?t._signals[s]:void 0;if(c&&p){if(!c.compare(p))return false}else if(c||p)return false}return true}contains(t){for(let e of t.structure)if(this._signals.findIndex(n=>n.constructor===e)===-1)return false;return true}has(t){let e;return t instanceof aConcept.A_Entity?e=t.constructor:e=t,this.structure.includes(e)}get(t){let e;t instanceof aConcept.A_Entity?e=t.constructor:e=t;let r=this._signals.findIndex(n=>n.constructor===e);if(r!==-1)return this._signals[r]}async toVector(t){return (t||this.structure).map(r=>{let n=this._signals.findIndex(o=>o.constructor===r);return n!==-1?this._signals[n]:void 0})}async toDataVector(t){let e=t||this.structure,r=[];for(let n of e){let o=this._signals.findIndex(c=>c.constructor===n),s;o===-1?s=await n.default():s=this._signals[o],r.push(s?.toJSON().data);}return r}async toObject(t){let e=t||this.structure,r={};return e.forEach(n=>{let o=n.name,s=this._signals.findIndex(c=>c.constructor===n);if(s!==-1){let c=this._signals[s];r[o]=c.toJSON().data;}else r[o]=void 0;}),r}toJSON(){return {...super.toJSON(),structure:this.structure.map(t=>t.name),values:this._signals.map(t=>t.toJSON())}}};i(exports.A_SignalVector,"A_SignalVector"),exports.A_SignalVector=a([aFrame.A_Frame.Entity({namespace:"A-Utils",name:"A-SignalVector",description:"A Signal Vector Entity represents a collection of signals structured in a specific way, allowing for batch processing and transmission of related signals as a unified state representation."})],exports.A_SignalVector);exports.A_SignalState=class F extends aConcept.A_Fragment{constructor(e){super({name:"A_SignalState"});this._state=new Map;this._prevState=new Map;this._structure=e;}get structure(){return this._structure||[]}set(e,r){let n=e instanceof exports.A_Signal?e.constructor:e,o=e instanceof exports.A_Signal?e:r;this._prevState.set(n,this._state.get(n)),this._state.set(n,o);}get(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this._state.get(r)}getPrev(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this._prevState.get(r)}has(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this.structure.includes(r)}delete(e){let r=e instanceof exports.A_Signal?e.constructor:e;return this._state.delete(r)}toVector(){let e=[];return this._state.forEach((r,n)=>{e.push(r);}),new exports.A_SignalVector(e,this.structure)}toObject(){let e={};return this.structure.forEach(r=>{let n=this._state.get(r);if(n===void 0)throw new Error(`Signal ${r.name} has no value in state`);e[r.name]=n;}),e}};i(exports.A_SignalState,"A_SignalState"),exports.A_SignalState=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-SignalState",description:"Manages the latest state of all signals within a given scope, maintaining a mapping between signal constructors and their most recently emitted values."})],exports.A_SignalState);exports.A_SignalConfig=class z extends aConcept.A_Fragment{get structure(){if(this._structure)return this._structure;let t=aConcept.A_Context.scope(this);return [...t.allowedEntities].filter(r=>aConcept.A_CommonHelper.isInheritedFrom(r,exports.A_Signal)).sort((r,n)=>r.constructor.name.localeCompare(n.name)).map(r=>t.resolveConstructor(r.name)).filter(r=>r)}get ready(){return this._ready}constructor(t){super({name:"A_SignalConfig"}),this._config=t;}async initialize(){return this._ready||(this._ready=this._initialize()),this._ready}async _initialize(){if(this._config.structure)this._structure=this._config.structure;else if(this._config.stringStructure){let t=this._config.stringStructure.split(",").map(e=>e.trim());this._structure=t.map(e=>aConcept.A_Context.scope(this).resolveConstructor(e)).filter(e=>e);}}};i(exports.A_SignalConfig,"A_SignalConfig"),exports.A_SignalConfig=a([aFrame.A_Frame.Fragment({namespace:"A-Utils",name:"A-SignalConfig",description:"Signal configuration fragment that defines the structure and types of signals within a given scope. It allows specifying the expected signal constructors and their order, facilitating consistent signal management and processing across components that emit or listen to signals."})],exports.A_SignalConfig);var Fn=(r=>(r.onBeforeNext="_A_SignalBusFeatures_onBeforeNext",r.onNext="_A_SignalBusFeatures_onNext",r.onError="_A_SignalBusFeatures_onError",r))(Fn||{});var Ue=class Ue extends aConcept.A_Error{};i(Ue,"A_SignalBusError"),Ue.SignalProcessingError="Signal processing error";var te=Ue;var Bn,Vn,Hn;exports.A_SignalBus=class k extends aConcept.A_Component{async next(...t){let e=new aConcept.A_Scope({name:"A_SignalBus-Next-Scope",entities:t}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_SignalBusFeatures_onBeforeNext",e),await this.call("_A_SignalBusFeatures_onNext",e),e.destroy();}catch(r){let n;switch(true){case r instanceof te:n=r;break;case(r instanceof aConcept.A_Error&&r.originalError instanceof te):n=r.originalError;break;default:n=new te({title:te.SignalProcessingError,description:"An error occurred while processing the signal.",originalError:r});break}e.register(n),await this.call("_A_SignalBusFeatures_onError"),e.destroy();}}async[Hn="_A_SignalBusFeatures_onError"](t,e,...r){e?.error(t);}async[Vn="_A_SignalBusFeatures_onBeforeNext"](t,e,r,n,o){let s=aConcept.A_Context.scope(this);o||(o=new exports.A_SignalConfig({stringStructure:e?.get("A_SIGNAL_VECTOR_STRUCTURE")||void 0}),s.register(o)),o.ready||await o.initialize(),r||(r=new exports.A_SignalState(o.structure),s.register(r));}async[Bn="_A_SignalBusFeatures_onNext"](t,e,r,n,o,s){for(let p of t){if(!r.has(p))return;o?.debug(`A_SignalBus: Updating state for signal '${p.constructor.name}' with data:`,p.data),r.set(p);}let c=r.toVector();e.register(c);}};i(exports.A_SignalBus,"A_SignalBus"),a([aFrame.A_Frame.Method({description:"Emit multiple signals through the signal bus."})],exports.A_SignalBus.prototype,"next",1),a([aConcept.A_Feature.Extend({before:/.*/}),l(0,aConcept.A_Inject(aConcept.A_Error)),l(1,aConcept.A_Inject(exports.A_Logger))],exports.A_SignalBus.prototype,Hn,1),a([aConcept.A_Feature.Extend({scope:[exports.A_SignalBus],before:/.*/}),l(0,aConcept.A_Inject(aConcept.A_Scope)),l(1,aConcept.A_Inject(exports.A_Config)),l(2,aConcept.A_Inject(exports.A_SignalState)),l(3,aConcept.A_Inject(exports.A_Logger)),l(4,aConcept.A_Inject(exports.A_SignalConfig))],exports.A_SignalBus.prototype,Vn,1),a([aConcept.A_Feature.Extend({scope:[exports.A_SignalBus],before:/.*/}),l(0,aConcept.A_Dependency.Flat()),l(0,aConcept.A_Dependency.All()),l(0,aConcept.A_Inject(exports.A_Signal)),l(1,aConcept.A_Inject(aConcept.A_Scope)),l(2,aConcept.A_Dependency.Required()),l(2,aConcept.A_Inject(exports.A_SignalState)),l(3,aConcept.A_Inject(exports.A_Config)),l(4,aConcept.A_Inject(exports.A_Logger)),l(5,aConcept.A_Inject(exports.A_SignalConfig))],exports.A_SignalBus.prototype,Bn,1),exports.A_SignalBus=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-SignalBus",description:"Signal bus component that manages the emission and state of signals within a given scope. It listens for emitted signals, updates their state, and forwards them to registered watchers. The bus ensures a consistent signal vector structure based on the defined configuration, facilitating signal management across multiple components."})],exports.A_SignalBus);var ct=class ct{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(ct,"A_Deferred");var Se=ct;var lt=class lt{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new Se,this.timeout=setTimeout(()=>e().then((...n)=>this.deferred.resolve(...n)).catch((...n)=>this.deferred.reject(...n)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new aConcept.A_Error("Timeout Cleared")));}};i(lt,"A_ScheduleObject");var he=lt;exports.A_Schedule=class le extends aConcept.A_Component{async schedule(t,e,r){let n=aConcept.A_TypeGuards.isString(t)?new Date(t).getTime():t;return new he(n-Date.now(),e,r)}async delay(t,e,r){return new he(t,e,r)}};i(exports.A_Schedule,"A_Schedule"),exports.A_Schedule=a([aFrame.A_Frame.Component({namespace:"A-Utils",name:"A-Schedule",description:"Scheduling component that allows scheduling of callbacks to be executed at specific times or after certain delays. It provides methods to schedule callbacks based on Unix timestamps or ISO date strings, as well as a method to execute callbacks after a specified delay in milliseconds. This component is useful for managing timed operations within an application."})],exports.A_Schedule);
|
|
34
|
+
exports.A_CONSTANTS__CONFIG_ENV_VARIABLES=Yo;exports.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY=_e;exports.A_ChannelError=ne;exports.A_ChannelFeatures=kt;exports.A_ChannelRequestStatuses=Mt;exports.A_CommandError=q;exports.A_CommandEvent=Yt;exports.A_CommandFeatures=zt;exports.A_CommandTransitions=Ft;exports.A_Command_Status=$t;exports.A_ConfigError=B;exports.A_Deferred=Se;exports.A_LOGGER_ANSI=Z;exports.A_LOGGER_COLORS=gt;exports.A_LOGGER_DEFAULT_LEVEL=ti;exports.A_LOGGER_DEFAULT_SCOPE_LENGTH=mt;exports.A_LOGGER_ENV_KEYS=Ee;exports.A_LOGGER_FORMAT=x;exports.A_LOGGER_SAFE_RANDOM_COLORS=ut;exports.A_LOGGER_TERMINAL=me;exports.A_LOGGER_TIME_FORMAT=de;exports.A_LoggerEnvVariables=ke;exports.A_LoggerEnvVariablesArray=Gs;exports.A_ManifestChecker=ge;exports.A_ManifestError=ee;exports.A_MemoryError=f;exports.A_MemoryFeatures=en;exports.A_ScheduleObject=he;exports.A_ServiceFeatures=hn;exports.A_SignalBusError=te;exports.A_SignalBusFeatures=Fn;exports.A_StateMachineError=pe;exports.A_StateMachineFeatures=Ht;exports.A_TYPES__ConfigFeature=Kr;//# sourceMappingURL=index.cjs.map
|
|
35
35
|
//# sourceMappingURL=index.cjs.map
|