@fincity/kirun-js 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -1,2 +1,2 @@
1
- function e(e,t,r,s){Object.defineProperty(e,t,{get:r,set:s,enumerable:!0,configurable:!0})}function t(e,t){return Object.keys(t).forEach((function(r){"default"===r||"__esModule"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e}e({},"KIRunSchemaRepository",(()=>O));var r={};e(r,"AdditionalPropertiesType",(()=>c)),e(r,"Schema",(()=>m));e({},"Namespaces",(()=>s));class s{static SYSTEM="System";static SYSTEM_CTX="System.Context";static SYSTEM_LOOP="System.Loop";static SYSTEM_ARRAY="System.Array";static MATH="System.Math";static STRING="System.String";constructor(){}}e({},"ArraySchemaType",(()=>a));function n(e){return null==e}e({},"isNullValue",(()=>n));class a{constructor(e){e&&(this.singleSchema=e.singleSchema?new m(e.singleSchema):void 0,this.tupleSchema=e.tupleSchema?e.tupleSchema.map((e=>new m(e))):void 0)}setSingleSchema(e){return this.singleSchema=e,this}setTupleSchema(e){return this.tupleSchema=e,this}getSingleSchema(){return this.singleSchema}getTupleSchema(){return this.tupleSchema}isSingleType(){return!n(this.singleSchema)}static of(...e){return 1==e.length?(new a).setSingleSchema(e[0]):(new a).setTupleSchema(e)}static from(e){if(!e)return;Array.isArray(e)&&a.of(...m.fromListOfSchemas(e));let t=m.from(e);return t?a.of(t):void 0}}let i;var o;e({},"SchemaType",(()=>i)),(o=i||(i={})).INTEGER="Integer",o.LONG="Long",o.FLOAT="Float",o.DOUBLE="Double",o.STRING="String",o.OBJECT="Object",o.ARRAY="Array",o.BOOLEAN="Boolean",o.NULL="Null";e({},"TypeUtil",(()=>l));e({},"MultipleType",(()=>p));e({},"Type",(()=>u));class u{}class p extends u{constructor(e){super(),this.type=e instanceof p?new Set(Array.from(e.type)):new Set(Array.from(e))}getType(){return this.type}setType(e){return this.type=e,this}getAllowedSchemaTypes(){return this.type}contains(e){return this.type?.has(e)}}e({},"SingleType",(()=>h));class h extends u{constructor(e){super(),this.type=e instanceof h?e.type:e}getType(){return this.type}getAllowedSchemaTypes(){return new Set([this.type])}contains(e){return this.type==e}}class l{static of(...e){return 1==e.length?new h(e[0]):new p(new Set(e))}static from(e){return"string"==typeof e?new h(e):Array.isArray(e)?new p(new Set(e.map((e=>e)).map((e=>e)))):void 0}}class c{constructor(e){e&&(this.booleanValue=e.booleanValue,e.schemaValue&&(this.schemaValue=new m(e.schemaValue)))}getBooleanValue(){return this.booleanValue}getSchemaValue(){return this.schemaValue}setBooleanValue(e){return this.booleanValue=e,this}setSchemaValue(e){return this.schemaValue=e,this}static from(e){if(!e)return;const t=new c;return t.booleanValue=e.booleanValue,t.schemaValue=e.schemaValue,t}}class m{static NULL=(new m).setNamespace(s.SYSTEM).setName("Null").setType(l.of(i.NULL)).setConstant(void 0);static TYPE_SCHEMA=(new m).setType(l.of(i.STRING)).setEnums(["INTEGER","LONG","FLOAT","DOUBLE","STRING","OBJECT","ARRAY","BOOLEAN","NULL"]);static SCHEMA=(new m).setNamespace(s.SYSTEM).setName("Schema").setType(l.of(i.OBJECT)).setProperties(new Map([["namespace",m.of("namespace",i.STRING).setDefaultValue("_")],["name",m.ofString("name")],["version",m.of("version",i.INTEGER).setDefaultValue(1)],["ref",m.ofString("ref")],["type",(new m).setAnyOf([m.TYPE_SCHEMA,m.ofArray("type",m.TYPE_SCHEMA)])],["anyOf",m.ofArray("anyOf",m.ofRef("#/"))],["allOf",m.ofArray("allOf",m.ofRef("#/"))],["oneOf",m.ofArray("oneOf",m.ofRef("#/"))],["not",m.ofRef("#/")],["title",m.ofString("title")],["description",m.ofString("description")],["id",m.ofString("id")],["examples",m.ofAny("examples")],["defaultValue",m.ofAny("defaultValue")],["comment",m.ofString("comment")],["enums",m.ofArray("enums",m.ofString("enums"))],["constant",m.ofAny("constant")],["pattern",m.ofString("pattern")],["format",m.of("format",i.STRING).setEnums(["DATETIME","TIME","DATE","EMAIL","REGEX"])],["minLength",m.ofInteger("minLength")],["maxLength",m.ofInteger("maxLength")],["multipleOf",m.ofLong("multipleOf")],["minimum",m.ofNumber("minimum")],["maximum",m.ofNumber("maximum")],["exclusiveMinimum",m.ofNumber("exclusiveMinimum")],["exclusiveMaximum",m.ofNumber("exclusiveMaximum")],["properties",m.of("properties",i.OBJECT).setAdditionalProperties((new c).setSchemaValue(m.ofRef("#/")))],["additionalProperties",(new m).setName("additionalProperty").setNamespace(s.SYSTEM).setAnyOf([m.ofBoolean("additionalProperty"),m.ofObject("additionalProperty").setRef("#/")]).setDefaultValue(!0)],["required",m.ofArray("required",m.ofString("required")).setDefaultValue([])],["propertyNames",m.ofRef("#/")],["minProperties",m.ofInteger("minProperties")],["maxProperties",m.ofInteger("maxProperties")],["patternProperties",m.of("patternProperties",i.OBJECT).setAdditionalProperties((new c).setSchemaValue(m.ofRef("#/")))],["items",(new m).setName("items").setAnyOf([m.ofRef("#/").setName("item"),m.ofArray("tuple",m.ofRef("#/"))])],["contains",m.ofRef("#/")],["minItems",m.ofInteger("minItems")],["maxItems",m.ofInteger("maxItems")],["uniqueItems",m.ofBoolean("uniqueItems")],["$defs",m.of("$defs",i.OBJECT).setAdditionalProperties((new c).setSchemaValue(m.ofRef("#/")))],["permission",m.ofString("permission")]])).setRequired([]);static ofString(e){return(new m).setType(l.of(i.STRING)).setName(e)}static ofInteger(e){return(new m).setType(l.of(i.INTEGER)).setName(e)}static ofFloat(e){return(new m).setType(l.of(i.FLOAT)).setName(e)}static ofLong(e){return(new m).setType(l.of(i.LONG)).setName(e)}static ofDouble(e){return(new m).setType(l.of(i.DOUBLE)).setName(e)}static ofAny(e){return(new m).setType(l.of(i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE,i.STRING,i.BOOLEAN,i.ARRAY,i.NULL,i.OBJECT)).setName(e)}static ofAnyNotNull(e){return(new m).setType(l.of(i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE,i.STRING,i.BOOLEAN,i.ARRAY,i.OBJECT)).setName(e)}static ofNumber(e){return(new m).setType(l.of(i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE)).setName(e)}static ofBoolean(e){return(new m).setType(l.of(i.BOOLEAN)).setName(e)}static of(e,...t){return(new m).setType(l.of(...t)).setName(e)}static ofObject(e){return(new m).setType(l.of(i.OBJECT)).setName(e)}static ofRef(e){return(new m).setRef(e)}static ofArray(e,...t){return(new m).setType(l.of(i.ARRAY)).setName(e).setItems(a.of(...t))}static fromListOfSchemas(e){if(n(e)&&!Array.isArray(e))return[];let t=[];for(let r of Array.from(e)){let e=m.from(r);e&&t.push(e)}return t}static fromMapOfSchemas(e){if(n(e))return;const t=new Map;return Object.entries(e).forEach((([e,r])=>{let s=m.from(r);s&&t.set(e,s)})),t}static from(e,t=!1){if(n(e))return;let r=new m;return r.namespace=e.namespace??"_",r.name=e.name,r.version=e.version??1,r.ref=e.ref,r.type=t?new h(i.STRING):l.from(e.type),r.anyOf=m.fromListOfSchemas(e.anyOf),r.allOf=m.fromListOfSchemas(e.allOf),r.oneOf=m.fromListOfSchemas(e.oneOf),r.not=m.from(e.not),r.description=e.description,r.examples=e.examples?[...e.examples]:void 0,r.defaultValue=e.defaultValue,r.comment=e.comment,r.enums=e.enums?[...e.enums]:void 0,r.constant=e.constant,r.pattern=e.pattern,r.format=e.format,r.minLength=e.minLength,r.maxLength=e.maxLength,r.multipleOf=e.multipleOf,r.minimum=e.minimum,r.maximum=e.maximum,r.exclusiveMinimum=e.exclusiveMinimum,r.exclusiveMaximum=e.exclusiveMaximum,r.properties=m.fromMapOfSchemas(e.properties),r.additionalProperties=c.from(e.additionalProperties),r.required=e.required,r.propertyNames=m.from(e.propertyNames,!0),r.minProperties=e.minProperties,r.maxProperties=e.maxProperties,r.patternProperties=m.fromMapOfSchemas(e.patternProperties),r.items=a.from(e.items),r.contains=m.from(e.contains),r.minItems=e.minItems,r.maxItems=e.maxItems,r.uniqueItems=e.uniqueItems,r.$defs=m.fromMapOfSchemas(e.$defs),r.permission=e.permission,r}namespace="_";version=1;constructor(e){e&&(this.namespace=e.namespace,this.name=e.name,this.version=e.version,this.ref=e.ref,this.type=e.type instanceof h?new h(e.type):new p(e.type),this.anyOf=e.anyOf?.map((e=>new m(e))),this.allOf=e.allOf?.map((e=>new m(e))),this.oneOf=e.oneOf?.map((e=>new m(e))),this.not=this.not?new m(this.not):void 0,this.description=e.description,this.examples=e.examples?JSON.parse(JSON.stringify(e.examples)):void 0,this.defaultValue=e.defaultValue?JSON.parse(JSON.stringify(e.defaultValue)):void 0,this.comment=e.comment,this.enums=e.enums?[...e.enums]:void 0,this.constant=e.constant?JSON.parse(JSON.stringify(e.constant)):void 0,this.pattern=e.pattern,this.format=e.format,this.minLength=e.minLength,this.maxLength=e.maxLength,this.multipleOf=e.multipleOf,this.minimum=e.minimum,this.maximum=e.maximum,this.exclusiveMinimum=e.exclusiveMinimum,this.exclusiveMaximum=e.exclusiveMaximum,this.properties=e.properties?new Map(Array.from(e.properties.entries()).map((e=>[e[0],new m(e[1])]))):void 0,this.additionalProperties=e.additionalProperties?new c(e.additionalProperties):void 0,this.required=e.required?[...e.required]:void 0,this.propertyNames=e.propertyNames?new m(e.propertyNames):void 0,this.minProperties=e.minProperties,this.maxProperties=e.maxProperties,this.patternProperties=e.patternProperties?new Map(Array.from(e.patternProperties.entries()).map((e=>[e[0],new m(e[1])]))):void 0,this.items=e.items?new a(e.items):void 0,this.contains=e.contains?new m(this.contains):void 0,this.minItems=e.minItems,this.maxItems=e.maxItems,this.uniqueItems=e.uniqueItems,this.$defs=e.$defs?new Map(Array.from(e.$defs.entries()).map((e=>[e[0],new m(e[1])]))):void 0,this.permission=e.permission)}getTitle(){return this.getFullName()}getFullName(){return this.namespace&&"_"!=this.namespace?this.namespace+"."+this.name:this.name}get$defs(){return this.$defs}set$defs(e){return this.$defs=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getVersion(){return this.version}setVersion(e){return this.version=e,this}getRef(){return this.ref}setRef(e){return this.ref=e,this}getType(){return this.type}setType(e){return this.type=e,this}getAnyOf(){return this.anyOf}setAnyOf(e){return this.anyOf=e,this}getAllOf(){return this.allOf}setAllOf(e){return this.allOf=e,this}getOneOf(){return this.oneOf}setOneOf(e){return this.oneOf=e,this}getNot(){return this.not}setNot(e){return this.not=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getExamples(){return this.examples}setExamples(e){return this.examples=e,this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}getComment(){return this.comment}setComment(e){return this.comment=e,this}getEnums(){return this.enums}setEnums(e){return this.enums=e,this}getConstant(){return this.constant}setConstant(e){return this.constant=e,this}getPattern(){return this.pattern}setPattern(e){return this.pattern=e,this}getFormat(){return this.format}setFormat(e){return this.format=e,this}getMinLength(){return this.minLength}setMinLength(e){return this.minLength=e,this}getMaxLength(){return this.maxLength}setMaxLength(e){return this.maxLength=e,this}getMultipleOf(){return this.multipleOf}setMultipleOf(e){return this.multipleOf=e,this}getMinimum(){return this.minimum}setMinimum(e){return this.minimum=e,this}getMaximum(){return this.maximum}setMaximum(e){return this.maximum=e,this}getExclusiveMinimum(){return this.exclusiveMinimum}setExclusiveMinimum(e){return this.exclusiveMinimum=e,this}getExclusiveMaximum(){return this.exclusiveMaximum}setExclusiveMaximum(e){return this.exclusiveMaximum=e,this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}getAdditionalProperties(){return this.additionalProperties}setAdditionalProperties(e){return this.additionalProperties=e,this}getRequired(){return this.required}setRequired(e){return this.required=e,this}getPropertyNames(){return this.propertyNames}setPropertyNames(e){return this.propertyNames=e,this.propertyNames.type=new h(i.STRING),this}getMinProperties(){return this.minProperties}setMinProperties(e){return this.minProperties=e,this}getMaxProperties(){return this.maxProperties}setMaxProperties(e){return this.maxProperties=e,this}getPatternProperties(){return this.patternProperties}setPatternProperties(e){return this.patternProperties=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}getContains(){return this.contains}setContains(e){return this.contains=e,this}getMinItems(){return this.minItems}setMinItems(e){return this.minItems=e,this}getMaxItems(){return this.maxItems}setMaxItems(e){return this.maxItems=e,this}getUniqueItems(){return this.uniqueItems}setUniqueItems(e){return this.uniqueItems=e,this}getPermission(){return this.permission}setPermission(e){return this.permission=e,this}}e({},"Parameter",(()=>T));e({},"SchemaReferenceException",(()=>g));class g extends Error{constructor(e,t,r){super(e.trim()?e+"-"+t:t),this.schemaPath=e,this.cause=r}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}let f;var E;e({},"ParameterType",(()=>f)),(E=f||(f={})).CONSTANT="CONSTANT",E.EXPRESSION="EXPRESSION";class T{static SCHEMA_NAME="Parameter";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(T.SCHEMA_NAME).setProperties(new Map([["schema",m.SCHEMA],["parameterName",m.ofString("parameterName")],["variableArgument",m.of("variableArgument",i.BOOLEAN).setDefaultValue(!1)],["type",m.ofString("type").setEnums(["EXPRESSION","CONSTANT"])]]));static EXPRESSION=(new m).setNamespace(s.SYSTEM).setName("ParameterExpression").setType(l.of(i.OBJECT)).setProperties(new Map([["isExpression",m.ofBoolean("isExpression").setDefaultValue(!0)],["value",m.ofAny("value")]]));variableArgument=!1;type=f.EXPRESSION;constructor(e,t){if(e instanceof T)this.schema=new m(e.schema),this.parameterName=e.parameterName,this.variableArgument=e.variableArgument,this.type=e.type;else{if(!t)throw new Error("Unknown constructor signature");this.schema=t,this.parameterName=e}}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getParameterName(){return this.parameterName}setParameterName(e){return this.parameterName=e,this}isVariableArgument(){return this.variableArgument}setVariableArgument(e){return this.variableArgument=e,this}getType(){return this.type}setType(e){return this.type=e,this}static ofEntry(e,t,r=!1,s=f.EXPRESSION){return[e,new T(e,t).setType(s).setVariableArgument(r)]}static of(e,t,r=!1,s=f.EXPRESSION){return new T(e,t).setType(s).setVariableArgument(r)}static from(e){const t=m.from(e.schema);if(!t)throw new g("","Parameter requires Schema");return new T(e.parameterName,t).setVariableArgument(!!e.variableArguments).setType(e.type??f.EXPRESSION)}}const A=new Map([["any",m.ofAny("any").setNamespace(s.SYSTEM)],["boolean",m.ofBoolean("boolean").setNamespace(s.SYSTEM)],["double",m.ofDouble("double").setNamespace(s.SYSTEM)],["float",m.ofFloat("float").setNamespace(s.SYSTEM)],["integer",m.ofInteger("integer").setNamespace(s.SYSTEM)],["long",m.ofLong("long").setNamespace(s.SYSTEM)],["number",m.ofNumber("number").setNamespace(s.SYSTEM)],["string",m.ofString("string").setNamespace(s.SYSTEM)],[T.EXPRESSION.getName(),T.EXPRESSION]]);class O{find(e,t){if(s.SYSTEM==e)return A.get(t)}}e({},"KIRunFunctionRepository",(()=>Ut));e({},"KIRuntimeException",(()=>w));class w extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}let S;var d;e({},"StringFormat",(()=>S)),(d=S||(S={})).DATETIME="DATETIME",d.TIME="TIME",d.DATE="DATE",d.EMAIL="EMAIL",d.REGEX="REGEX";e({},"Event",(()=>N));class N{static OUTPUT="output";static ERROR="error";static ITERATION="iteration";static TRUE="true";static FALSE="false";static SCHEMA_NAME="Event";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(N.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["name",m.ofString("name")],["parameters",m.ofObject("parameter").setAdditionalProperties((new c).setSchemaValue(m.SCHEMA))]]));constructor(e,t){if(e instanceof N)this.name=e.name,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new m(e[1])])));else{if(this.name=e,!t)throw new Error("Unknown constructor format");this.parameters=t}}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}static outputEventMapEntry(e){return N.eventMapEntry(N.OUTPUT,e)}static eventMapEntry(e,t){return[e,new N(e,t)]}static from(e){return new N(e.name,new Map(Object.entries(e.parameters??{}).map((e=>{const t=m.from(e[1]);if(!t)throw new g("","Event expects a schema");return[e[0],t]}))))}}e({},"EventResult",(()=>y));class y{constructor(e,t){this.name=e,this.result=t}getName(){return this.name}setName(e){return this.name=e,this}getResult(){return this.result}setResult(e){return this.result=e,this}static outputOf(e){return y.of(N.OUTPUT,e)}static of(e,t){return new y(e,t)}}e({},"FunctionOutput",(()=>R));class R{index=0;constructor(e){if(n(e))throw new w("Function output is generating null");Array.isArray(e)&&e.length&&e[0]instanceof y?this.fo=e:(this.fo=[],this.generator=e)}next(){if(!this.generator)return this.index<this.fo.length?this.fo[this.index++]:void 0;const e=this.generator.next();return e&&this.fo.push(e),e}allResults(){return this.fo}}e({},"FunctionSignature",(()=>I));class I{static SCHEMA_NAME="FunctionSignature";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(I.SCHEMA_NAME).setProperties(new Map([["name",m.ofString("name")],["namespace",m.ofString("namespace")],["parameters",m.ofObject("parameters").setAdditionalProperties((new c).setSchemaValue(T.SCHEMA))],["events",m.ofObject("events").setAdditionalProperties((new c).setSchemaValue(N.SCHEMA))]]));namespace="_";parameters=new Map;events=new Map;constructor(e){e instanceof I?(this.name=e.name,this.namespace=e.namespace,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new T(e[1])]))),this.events=new Map(Array.from(e.events.entries()).map((e=>[e[0],new N(e[1])])))):this.name=e}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}getEvents(){return this.events}setEvents(e){return this.events=e,this}}e({},"ContextElement",(()=>x));class x{static NULL=new x(m.NULL,void 0);constructor(e,t){this.schema=e,this.element=t}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getElement(){return this.element}setElement(e){return this.element=e,this}}e({},"StringFormatter",(()=>M));class M{static format(e,...t){if(!t||0==t.length)return e;let r="",s=0,n="",a=n,i=e.length;for(let o=0;o<i;o++)n=e.charAt(o),"$"==n&&"\\"==a?r=r.substring(0,o-1)+n:"$"==n&&s<t.length?r+=t[s++]:r+=n,a=n;return r.toString()}constructor(){}}e({},"AbstractFunction",(()=>W));e({},"SchemaValidator",(()=>$));e({},"StringUtil",(()=>v));class v{constructor(){}static nthIndex(e,t,r=0,s){if(!e)throw new w("String cannot be null");if(r<0||r>=e.length)throw new w(M.format("Cannot search from index : $",r));if(s<=0||s>e.length)throw new w(M.format("Cannot search for occurance : $",s));for(;r<e.length;){if(e.charAt(r)==t&&0==--s)return r;++r}return-1}static splitAtFirstOccurance(e,t){if(!e)return[void 0,void 0];let r=e.indexOf(t);return-1==r?[e,void 0]:[e.substring(0,r),e.substring(r+1)]}static isNullOrBlank(e){return!e||""==e.trim()}}e({},"SchemaUtil",(()=>U));var P={};e(P,"Tuple2",(()=>_)),e(P,"Tuple3",(()=>L)),e(P,"Tuple4",(()=>C));class _{constructor(e,t){this.f=e,this.s=t}getT1(){return this.f}getT2(){return this.s}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}}class L extends _{constructor(e,t,r){super(e,t),this.t=r}getT3(){return this.t}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}}class C extends L{constructor(e,t,r,s){super(e,t,r),this.fr=s}getT4(){return this.fr}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}setT4(e){return this.fr=e,this}}e({},"SchemaValidationException",(()=>b));class b extends Error{constructor(e,t,r=[],s){super(t+(r?r.map((e=>e.message)).reduce(((e,t)=>e+"\n"+t),""):"")),this.schemaPath=e,this.cause=s}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}class U{static UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH="Unable to retrive schema from referenced path";static CYCLIC_REFERENCE_LIMIT_COUNTER=20;static getDefaultValue(e,t){if(e)return e.getConstant()?e.getConstant():e.getDefaultValue()?e.getDefaultValue():U.getDefaultValue(U.getSchemaFromRef(e,t,e.getRef()),t)}static getSchemaFromRef(e,t,r,s=0){if(++s==U.CYCLIC_REFERENCE_LIMIT_COUNTER)throw new b(r??"","Schema has a cyclic reference");if(!e||!r||v.isNullOrBlank(r))return;if(!r.startsWith("#")){var n=U.resolveExternalSchema(e,t,r);n&&(e=n.getT1(),r=n.getT2())}let a=r.split("/");return 1===a.length?e:U.resolveInternalSchema(e,t,r,s,a,1)}static resolveInternalSchema(e,t,r,s,n,a){let o=e;if(a!==n.length){for(;a<n.length;){if("$defs"===n[a]){if(++a>=n.length||!o.get$defs())throw new g(r,U.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);o=o.get$defs()?.get(n[a])}else{if(o&&(!o.getType()?.contains(i.OBJECT)||!o.getProperties()))throw new g(r,"Cannot retrievie schema from non Object type schemas");o=o.getProperties()?.get(n[a])}if(a++,!o)throw new g(r,U.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);if(!v.isNullOrBlank(o.getRef())&&(o=U.getSchemaFromRef(o,t,o.getRef(),s),!o))throw new g(r,U.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH)}return o}}static resolveExternalSchema(e,t,r){if(!t)return;let s=v.splitAtFirstOccurance(r??"","/");if(!s[0])return;let n=v.splitAtFirstOccurance(s[0],".");if(!n[0]||!n[1])return;let a=t.find(n[0],n[1]);if(a){if(!s[1]||""===s[1])return new _(a,r);if(r="#/"+s[1],!a)throw new g(r,U.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);return new _(a,r)}}constructor(){}}e({},"AnyOfAllOfOneOfValidator",(()=>V));class V{static validate(e,t,r,s){let n=[];return t.getOneOf()&&!t.getOneOf()?V.oneOf(e,t,r,s,n):t.getAllOf()&&!t.getAllOf()?V.allOf(e,t,r,s,n):t.getAnyOf()&&!t.getAnyOf()&&V.anyOf(e,t,r,s,n),s}static anyOf(e,t,r,s,n){let a=!1;for(let i of t.getAnyOf()??[])try{V.validate(e,i,r,s),a=!0;break}catch(e){a=!1,n.push(e)}if(!a)throw new b($.path(e),"The value don't satisfy any of the schemas.",n)}static allOf(e,t,r,s,n){let a=0;for(let i of t.getAllOf()??[])try{V.validate(e,i,r,s),a++}catch(e){n.push(e)}if(a!==t.getAllOf()?.length)throw new b($.path(e),"The value doesn't satisfy some of the schemas.",n)}static oneOf(e,t,r,s,n){let a=0;for(let i of t.getOneOf()??[])try{V.validate(e,i,r,s),a++}catch(e){n.push(e)}if(1!=a)throw new b($.path(e),0==a?"The value does not satisfy any schema":"The value satisfy more than one schema",n)}constructor(){}}e({},"TypeValidator",(()=>Y));e({},"ArrayValidator",(()=>B));class B{static validate(e,t,r,s){if(n(s))throw new b($.path(e),"Expected an array but found null");if(!Array.isArray(s))throw new b($.path(e),s.toString()+" is not an Array");let a=s;return B.checkMinMaxItems(e,t,a),B.checkItems(e,t,r,a),B.checkUniqueItems(e,t,a),B.checkContains(e,t,r,a),s}static checkContains(e,t,r,s){if(!t.getContains())return;let n=!1;for(let a=0;a<s.length;a++){let i=e?[...e]:[];try{$.validate(i,t.getContains(),r,s[a]),n=!0;break}catch(e){n=!1}}if(!n)throw new b($.path(e),"None of the items are of type contains schema")}static checkUniqueItems(e,t,r){if(t.getUniqueItems()&&t.getUniqueItems()){if(new Set(r).size!==r.length)throw new b($.path(e),"Items on the array are not unique")}}static checkMinMaxItems(e,t,r){if(t.getMinItems()&&t.getMinItems()>r.length)throw new b($.path(e),"Array should have minimum of "+t.getMinItems()+" elements");if(t.getMaxItems()&&t.getMaxItems()<r.length)throw new b($.path(e),"Array can have maximum of "+t.getMaxItems()+" elements")}static checkItems(e,t,r,s){if(!t.getItems())return;let n=t.getItems();if(n.getSingleSchema())for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=$.validate(a,n.getSingleSchema(),r,s[t]);s[t]=i}if(n.getTupleSchema()){if(n.getTupleSchema().length!==s.length)throw new b($.path(e),"Expected an array with only "+n.getTupleSchema().length+" but found "+s.length);for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=$.validate(a,n.getTupleSchema()[t],r,s[t]);s[t]=i}}}constructor(){}}e({},"BooleanValidator",(()=>D));class D{static validate(e,t,r){if(n(r))throw new b($.path(e),"Expected a boolean but found null");if("boolean"!=typeof r)throw new b($.path(e),r.toString()+" is not a boolean");return r}constructor(){}}e({},"NullValidator",(()=>k));class k{static validate(e,t,r){if(r)throw new b($.path(e),"Expected a null but found "+r);return r}constructor(){}}e({},"NumberValidator",(()=>G));class G{static validate(e,t,r,s){if(n(s))throw new b($.path(t),"Expected a number but found null");if("number"!=typeof s)throw new b($.path(t),s.toString()+" is not a "+e);let a=G.extractNumber(e,t,r,s);return G.checkRange(t,r,s,a),G.checkMultipleOf(t,r,s,a),s}static extractNumber(e,t,r,s){let a=s;try{e!=i.LONG&&e!=i.INTEGER||(a=Math.round(a))}catch(r){throw new b($.path(t),s+" is not a number of type "+e,r)}if(n(a)||(e==i.LONG||e==i.INTEGER)&&a!=s)throw new b($.path(t),s.toString()+" is not a number of type "+e);return a}static checkMultipleOf(e,t,r,s){if(t.getMultipleOf()){if(s%t.getMultipleOf()!=0)throw new b($.path(e),r.toString()+" is not multiple of "+t.getMultipleOf())}}static checkRange(e,t,r,s){if(t.getMinimum()&&G.numberCompare(s,t.getMinimum())<0)throw new b($.path(e),r.toString()+" should be greater than or equal to "+t.getMinimum());if(t.getMaximum()&&G.numberCompare(s,t.getMaximum())>0)throw new b($.path(e),r.toString()+" should be less than or equal to "+t.getMaximum());if(t.getExclusiveMinimum()&&G.numberCompare(s,t.getExclusiveMinimum())<=0)throw new b($.path(e),r.toString()+" should be greater than "+t.getExclusiveMinimum());if(t.getExclusiveMaximum()&&G.numberCompare(s,t.getExclusiveMaximum())>0)throw new b($.path(e),r.toString()+" should be less than "+t.getExclusiveMaximum())}static numberCompare(e,t){return e-t}constructor(){}}e({},"ObjectValidator",(()=>F));class F{static validate(e,t,r,s){if(n(s))throw new b($.path(e),"Expected an object but found null");if("object"!=typeof s||Array.isArray(s))throw new b($.path(e),s.toString()+" is not an Object");let a=s,i=new Set(Object.keys(a));F.checkMinMaxProperties(e,t,i),t.getPropertyNames()&&F.checkPropertyNameSchema(e,t,r,i),t.getRequired()&&F.checkRequired(e,t,a),t.getProperties()&&F.checkProperties(e,t,r,a,i),t.getPatternProperties()&&F.checkPatternProperties(e,t,r,a,i),t.getAdditionalProperties()&&F.checkAddtionalProperties(e,t,r,a,i)}static checkPropertyNameSchema(e,t,r,s){for(let n of Array.from(s.values()))try{$.validate(e,t.getPropertyNames(),r,n)}catch(t){throw new b($.path(e),"Property name '"+n+"' does not fit the property schema")}}static checkRequired(e,t,r){for(const s of t.getRequired()??[])if(n(r[s]))throw new b($.path(e),s+" is mandatory")}static checkAddtionalProperties(e,t,r,s,n){let a=t.getAdditionalProperties();if(a.getSchemaValue())for(let t of Array.from(n.values())){let n=e?[...e]:[],i=$.validate(n,a.getSchemaValue(),r,s[t]);s[t]=i}else if(!1===a.getBooleanValue()&&n.size)throw new b($.path(e),n.toString()+" are additional properties which are not allowed.")}static checkPatternProperties(e,t,r,s,n){const a=new Map;for(const e of Array.from(t.getPatternProperties().keys()))a.set(e,new RegExp(e));for(const i of Array.from(n.values())){const o=e?[...e]:[];for(const e of Array.from(a.entries()))if(e[1].test(i)){const a=$.validate(o,t.getPatternProperties().get(e[0]),r,s[i]);s[i]=a,n.delete(i);break}}}static checkProperties(e,t,r,s,a){for(const i of Array.from(t.getProperties())){let t=s[i[0]];if(n(t))continue;let o=e?[...e]:[],u=$.validate(o,i[1],r,t);s[i[0]]=u,a.delete(i[0])}}static checkMinMaxProperties(e,t,r){if(t.getMinProperties()&&r.size<t.getMinProperties())throw new b($.path(e),"Object should have minimum of "+t.getMinProperties()+" properties");if(t.getMaxProperties()&&r.size>t.getMaxProperties())throw new b($.path(e),"Object can have maximum of "+t.getMaxProperties()+" properties")}constructor(){}}e({},"StringValidator",(()=>H));class H{static TIME=/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static DATE=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])$/;static DATETIME=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])T([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static validate(e,t,r){if(n(r))throw new b($.path(e),"Expected a string but found "+r);if("string"!=typeof r)throw new b($.path(e),r.toString()+" is not String");t.getFormat()==S.TIME?H.patternMatcher(e,t,r,H.TIME,"time pattern"):t.getFormat()==S.DATE?H.patternMatcher(e,t,r,H.DATE,"date pattern"):t.getFormat()==S.DATETIME?H.patternMatcher(e,t,r,H.DATETIME,"date time pattern"):t.getPattern()&&H.patternMatcher(e,t,r,new RegExp(t.getPattern()),"pattern "+t.getPattern());let s=r.length;if(t.getMinLength()&&s<t.getMinLength())throw new b($.path(e),"Expected a minimum of "+t.getMinLength()+" characters");if(t.getMaxLength()&&s>t.getMinLength())throw new b($.path(e),"Expected a maximum of "+t.getMaxLength()+" characters");return r}static patternMatcher(e,t,r,s,n){if(!s.test(r))throw new b($.path(e),r.toString()+" is not matched with the "+n)}constructor(){}}class Y{static validate(e,t,r,s,n){if(t==i.STRING)H.validate(e,r,n);else if(t==i.LONG||t==i.INTEGER||t==i.DOUBLE||t==i.FLOAT)G.validate(t,e,r,n);else if(t==i.BOOLEAN)D.validate(e,r,n);else if(t==i.OBJECT)F.validate(e,r,s,n);else if(t==i.ARRAY)B.validate(e,r,s,n);else{if(t!=i.NULL)throw new b($.path(e),t+" is not a valid type.");k.validate(e,r,n)}return n}constructor(){}}class ${static path(e){return e?e.map((e=>e.getTitle()??"")).filter((e=>!!e)).reduce(((e,t,r)=>e+(0===r?"":".")+t),""):""}static validate(e,t,r,s){if(!t)throw new b($.path(e),"No schema found to validate");if(e||(e=new Array),e.push(t),n(s)&&!n(t.getDefaultValue()))return JSON.parse(JSON.stringify(t.getDefaultValue()));if(t.getConstant())return $.constantValidation(e,t,s);if(t.getEnums()&&!t.getEnums()?.length)return $.enumCheck(e,t,s);if(t.getType()&&$.typeValidation(e,t,r,s),!v.isNullOrBlank(t.getRef()))return $.validate(e,U.getSchemaFromRef(e[0],r,t.getRef()),r,s);if((t.getOneOf()||t.getAllOf()||t.getAnyOf())&&V.validate(e,t,r,s),t.getNot()){let n=!1;try{$.validate(e,t.getNot(),r,s),n=!0}catch(e){n=!1}if(n)throw new b($.path(e),"Schema validated value in not condition.")}return s}static constantValidation(e,t,r){if(!t.getConstant().equals(r))throw new b($.path(e),"Expecting a constant value : "+r);return r}static enumCheck(e,t,r){let s=!1;for(let e of t.getEnums()??[])if(e===r){s=!0;break}if(s)return r;throw new b($.path(e),"Value is not one of "+t.getEnums())}static typeValidation(e,t,r,s){let n=!1,a=[];for(const i of Array.from(t.getType()?.getAllowedSchemaTypes()?.values()??[]))try{Y.validate(e,i,t,r,s),n=!0;break}catch(e){n=!1,a.push(e)}if(!n)throw new b($.path(e),"Value "+JSON.stringify(s)+" is not of valid type(s)",a)}constructor(){}}class W{validateArguments(e,t,r){return Array.from(this.getSignature().getParameters().entries()).map((s=>{let n=s[1];try{return this.validateArgument(e,t,s,n)}catch(e){const t=this.getSignature();throw new w(`Error while executing the function ${t.getNamespace()}.${t.getName()}'s parameter ${n.getParameterName()} with step name '${r?.getStatement().getStatementName()??"Unknown Step"}' with error : ${e?.message}`)}})).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}validateArgument(e,t,r,s){let a,i=r[0],o=e.get(r[0]);if(n(o)&&!s.isVariableArgument())return new _(i,$.validate(void 0,s.getSchema(),t,void 0));if(!s?.isVariableArgument())return new _(i,$.validate(void 0,s.getSchema(),t,o));Array.isArray(o)?a=o:(a=[],n(o)?n(s.getSchema().getDefaultValue())||a.push(s.getSchema().getDefaultValue()):a.push(o));for(let e=0;e<a.length;e++)a[e]=$.validate(void 0,s.getSchema(),t,a[e]);return new _(i,a)}async execute(e){e.setArguments(this.validateArguments(e.getArguments()??new Map,e.getSchemaRepository(),e.getStatementExecution()));try{return this.internalExecute(e)}catch(t){const r=this.getSignature();throw new w(`Error while executing the function ${r.getNamespace()}.${r.getName()} with step name '${e.getStatementExecution()?.getStatement().getStatementName()??"Unknown Step"}' with error : ${t?.message}`)}}getProbableEventSignature(e){return this.getSignature().getEvents()}}const j=new I("Create").setNamespace(s.SYSTEM_CTX).setParameters(new Map([T.ofEntry("name",(new m).setName("name").setType(l.of(i.STRING)).setMinLength(1).setFormat(S.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,f.CONSTANT),T.ofEntry("schema",m.SCHEMA,!1,f.CONSTANT)])).setEvents(new Map([N.outputEventMapEntry(new Map)]));const q=new I("Get").setNamespace(s.SYSTEM_CTX).setParameters(new Map([T.ofEntry("name",(new m).setName("name").setType(l.of(i.STRING)).setMinLength(1).setFormat(S.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,f.CONSTANT)])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofAny("value")]]))]));e({},"ExecutionException",(()=>X));class X extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}e({},"Expression",(()=>re));e({},"LinkedList",(()=>J));class J{head=void 0;tail=void 0;length=0;constructor(e){if(e?.length){for(const t of e)if(this.head){const e=new Q(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new Q(t);this.length=e.length}}push(e){const t=new Q(e,void 0,this.head);this.head?(this.head.previous=t,this.head=t):this.tail=this.head=t,this.length++}pop(){if(!this.head)throw Error("List is empty and cannot pop further.");const e=this.head.value;if(this.length--,this.head==this.tail)return this.head=this.tail=void 0,e;const t=this.head;return this.head=t.next,t.next=void 0,t.previous=void 0,this.head.previous=void 0,e}isEmpty(){return!this.length}size(){return this.length}get(e){if(e<0||e>=this.length)throw new Error(`${e} is out of bounds [0,${this.length}]`);let t=this.head;for(;e>0;)t=this.head.next,--e;return t.value}set(e,t){if(e<0||e>=this.length)throw new w(M.format("Index $ out of bound to set the value in linked list.",e));let r=this.head;for(;e>0;)r=this.head.next,--e;return r.value=t,this}toString(){let e=this.head,t="";for(;e;)t+=e.value,e=e.next,e&&(t+=", ");return`[${t}]`}toArray(){let e=[],t=this.head;for(;t;)e.push(t.value),t=t.next;return e}peek(){if(!this.head)throw new Error("List is empty so cannot peak");return this.head.value}peekLast(){if(!this.tail)throw new Error("List is empty so cannot peak");return this.tail.value}getFirst(){if(!this.head)throw new Error("List is empty so cannot get first");return this.head.value}removeFirst(){return this.pop()}removeLast(){if(!this.tail)throw new Error("List is empty so cannot remove");--this.length;const e=this.tail.value;if(0==this.length)this.head=this.tail=void 0;else{const e=this.tail.previous;e.next=void 0,this.tail.previous=void 0,this.tail=e}return e}addAll(e){return e&&e.length?(e.forEach(this.add.bind(this)),this):this}add(e){return++this.length,this.tail||this.head?this.head===this.tail?(this.tail=new Q(e,this.head),this.head.next=this.tail):(this.tail=new Q(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new Q(e),this}map(e,t){let r=new J,s=this.head,n=0;for(;s;)r.add(e(s.value,n)),s=s.next,++n;return r}forEach(e,t){let r=this.head,s=0;for(;r;)e(r.value,s),r=r.next,++s}}class Q{constructor(e,t,r){this.value=e,this.next=r,this.previous=t}toString(){return""+this.value}}e({},"StringBuilder",(()=>K));class K{constructor(e){this.str=e??""}append(e){return this.str+=e,this}toString(){return""+this.str}trim(){return this.str=this.str.trim(),this}setLength(e){return this.str=this.str.substring(0,e),this}length(){return this.str.length}charAt(e){return this.str.charAt(e)}deleteCharAt(e){return this.checkIndex(e),this.str=this.str.substring(0,e)+this.str.substring(e+1),this}insert(e,t){return this.str=this.str.substring(0,e)+t+this.str.substring(e),this}checkIndex(e){if(e>=this.str.length)throw new w(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}e({},"ExpressionEvaluationException",(()=>z));class z extends Error{constructor(e,t,r){super(M.format("$ : $",e,t)),this.cause=r}getCause(){return this.cause}}e({},"ExpressionToken",(()=>Z));class Z{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}e({},"ExpressionTokenValue",(()=>ee));class ee extends Z{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return M.format("$: $",this.expression,this.element)}}e({},"Operation",(()=>te));class te{static MULTIPLICATION=new te("*");static DIVISION=new te("/");static INTEGER_DIVISION=new te("//");static MOD=new te("%");static ADDITION=new te("+");static SUBTRACTION=new te("-");static NOT=new te("not",void 0,!0);static AND=new te("and",void 0,!0);static OR=new te("or",void 0,!0);static LESS_THAN=new te("<");static LESS_THAN_EQUAL=new te("<=");static GREATER_THAN=new te(">");static GREATER_THAN_EQUAL=new te(">=");static EQUAL=new te("=");static NOT_EQUAL=new te("!=");static BITWISE_AND=new te("&");static BITWISE_OR=new te("|");static BITWISE_XOR=new te("^");static BITWISE_COMPLEMENT=new te("~");static BITWISE_LEFT_SHIFT=new te("<<");static BITWISE_RIGHT_SHIFT=new te(">>");static BITWISE_UNSIGNED_RIGHT_SHIFT=new te(">>>");static UNARY_PLUS=new te("UN: +","+");static UNARY_MINUS=new te("UN: -","-");static UNARY_LOGICAL_NOT=new te("UN: not","not");static UNARY_BITWISE_COMPLEMENT=new te("UN: ~","~");static ARRAY_OPERATOR=new te("[");static OBJECT_OPERATOR=new te(".");static NULLISH_COALESCING_OPERATOR=new te("??");static CONDITIONAL_TERNARY_OPERATOR=new te("?");static VALUE_OF=new Map([["MULTIPLICATION",te.MULTIPLICATION],["DIVISION",te.DIVISION],["INTEGER_DIVISON",te.INTEGER_DIVISION],["MOD",te.MOD],["ADDITION",te.ADDITION],["SUBTRACTION",te.SUBTRACTION],["NOT",te.NOT],["AND",te.AND],["OR",te.OR],["LESS_THAN",te.LESS_THAN],["LESS_THAN_EQUAL",te.LESS_THAN_EQUAL],["GREATER_THAN",te.GREATER_THAN],["GREATER_THAN_EQUAL",te.GREATER_THAN_EQUAL],["EQUAL",te.EQUAL],["NOT_EQUAL",te.NOT_EQUAL],["BITWISE_AND",te.BITWISE_AND],["BITWISE_OR",te.BITWISE_OR],["BITWISE_XOR",te.BITWISE_XOR],["BITWISE_COMPLEMENT",te.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",te.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",te.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",te.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",te.UNARY_PLUS],["UNARY_MINUS",te.UNARY_MINUS],["UNARY_LOGICAL_NOT",te.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",te.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",te.ARRAY_OPERATOR],["OBJECT_OPERATOR",te.OBJECT_OPERATOR],["NULLISH_COALESCING_OPERATOR",te.NULLISH_COALESCING_OPERATOR],["CONDITIONAL_TERNARY_OPERATOR",te.CONDITIONAL_TERNARY_OPERATOR]]);static UNARY_OPERATORS=new Set([te.ADDITION,te.SUBTRACTION,te.NOT,te.BITWISE_COMPLEMENT,te.UNARY_PLUS,te.UNARY_MINUS,te.UNARY_LOGICAL_NOT,te.UNARY_BITWISE_COMPLEMENT]);static ARITHMETIC_OPERATORS=new Set([te.MULTIPLICATION,te.DIVISION,te.INTEGER_DIVISION,te.MOD,te.ADDITION,te.SUBTRACTION]);static LOGICAL_OPERATORS=new Set([te.NOT,te.AND,te.OR,te.LESS_THAN,te.LESS_THAN_EQUAL,te.GREATER_THAN,te.GREATER_THAN_EQUAL,te.EQUAL,te.NOT_EQUAL,te.NULLISH_COALESCING_OPERATOR]);static BITWISE_OPERATORS=new Set([te.BITWISE_AND,te.BITWISE_COMPLEMENT,te.BITWISE_LEFT_SHIFT,te.BITWISE_OR,te.BITWISE_RIGHT_SHIFT,te.BITWISE_UNSIGNED_RIGHT_SHIFT,te.BITWISE_XOR]);static CONDITIONAL_OPERATORS=new Set([te.CONDITIONAL_TERNARY_OPERATOR]);static OPERATOR_PRIORITY=new Map([[te.UNARY_PLUS,1],[te.UNARY_MINUS,1],[te.UNARY_LOGICAL_NOT,1],[te.UNARY_BITWISE_COMPLEMENT,1],[te.ARRAY_OPERATOR,1],[te.OBJECT_OPERATOR,1],[te.MULTIPLICATION,2],[te.DIVISION,2],[te.INTEGER_DIVISION,2],[te.MOD,2],[te.ADDITION,3],[te.SUBTRACTION,3],[te.BITWISE_LEFT_SHIFT,4],[te.BITWISE_RIGHT_SHIFT,4],[te.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[te.LESS_THAN,5],[te.LESS_THAN_EQUAL,5],[te.GREATER_THAN,5],[te.GREATER_THAN_EQUAL,5],[te.EQUAL,6],[te.NOT_EQUAL,6],[te.BITWISE_AND,7],[te.BITWISE_XOR,8],[te.BITWISE_OR,9],[te.AND,10],[te.OR,11],[te.NULLISH_COALESCING_OPERATOR,11],[te.CONDITIONAL_TERNARY_OPERATOR,12]]);static OPERATORS=new Set([...Array.from(te.ARITHMETIC_OPERATORS),...Array.from(te.LOGICAL_OPERATORS),...Array.from(te.BITWISE_OPERATORS),te.ARRAY_OPERATOR,te.OBJECT_OPERATOR,...Array.from(te.CONDITIONAL_OPERATORS)].map((e=>e.getOperator())));static OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(te.ARITHMETIC_OPERATORS),...Array.from(te.LOGICAL_OPERATORS),...Array.from(te.BITWISE_OPERATORS),te.ARRAY_OPERATOR,te.OBJECT_OPERATOR,...Array.from(te.CONDITIONAL_OPERATORS)].filter((e=>!e.shouldBeWrappedInSpace())).map((e=>e.getOperator())));static OPERATION_VALUE_OF=new Map(Array.from(te.VALUE_OF.entries()).map((([e,t])=>[t.getOperator(),t])));static UNARY_MAP=new Map([[te.ADDITION,te.UNARY_PLUS],[te.SUBTRACTION,te.UNARY_MINUS],[te.NOT,te.UNARY_LOGICAL_NOT],[te.BITWISE_COMPLEMENT,te.UNARY_BITWISE_COMPLEMENT],[te.UNARY_PLUS,te.UNARY_PLUS],[te.UNARY_MINUS,te.UNARY_MINUS],[te.UNARY_LOGICAL_NOT,te.UNARY_LOGICAL_NOT],[te.UNARY_BITWISE_COMPLEMENT,te.UNARY_BITWISE_COMPLEMENT]]);static BIGGEST_OPERATOR_SIZE=Array.from(te.VALUE_OF.values()).map((e=>e.getOperator())).filter((e=>!e.startsWith("UN: "))).map((e=>e.length)).reduce(((e,t)=>e>t?e:t),0);constructor(e,t,r=!1){this.operator=e,this.operatorName=t??e,this._shouldBeWrappedInSpace=r}getOperator(){return this.operator}getOperatorName(){return this.operatorName}shouldBeWrappedInSpace(){return this._shouldBeWrappedInSpace}valueOf(e){return te.VALUE_OF.get(e)}toString(){return this.operator}}class re extends Z{tokens=new J;ops=new J;constructor(e,t,r,s){super(e||""),t&&this.tokens.push(t),r&&this.tokens.push(r),s&&this.ops.push(s),this.evaluate()}getTokens(){return this.tokens}getOperations(){return this.ops}evaluate(){const e=this.expression.length;let t,r="",s=new K(""),n=0,a=!1;for(;n<e;){switch(r=this.expression[n],t=s.toString(),r){case" ":a=this.processTokenSepearator(s,t,a);break;case"(":n=this.processSubExpression(e,s,t,n,a),a=!1;break;case")":throw new z(this.expression,"Extra closing parenthesis found");case"]":throw new z(this.expression,"Extra closing square bracket found");case"'":case'"':{let t=this.processStringLiteral(e,r,n);n=t.getT1(),a=t.getT2();break}case"?":if(n+1<e&&"?"!=this.expression.charAt(n+1)&&0!=n&&"?"!=this.expression.charAt(n-1))n=this.processTernaryOperator(e,s,t,n,a);else{let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==te.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}break;default:let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==te.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}++n}if(t=s.toString(),!v.isNullOrBlank(t)){if(te.OPERATORS.has(t))throw new z(this.expression,"Expression is ending with an operator");this.tokens.push(new Z(t))}}processStringLiteral(e,t,r){let s="",n=r+1;for(;n<e;n++){let e=this.expression.charAt(n);if(e==t&&"\\"!=this.expression.charAt(n-1))break;s+=e}if(n==e&&this.expression.charAt(n-1)!=t)throw new z(this.expression,"Missing string ending marker "+t);let a=new _(n,!1);return this.tokens.push(new ee(s,s)),a}process(e,t,r){let s=1;for(++r;r<e&&0!=s;){let e=this.expression.charAt(r);"]"==e?--s:"["==e&&++s,0!=s&&(t.append(e),r++)}return this.tokens.push(new re(t.toString())),t.setLength(0),new _(r,!1)}processOthers(e,t,r,s,n,a){let i=t-n;i=i<te.BIGGEST_OPERATOR_SIZE?i:te.BIGGEST_OPERATOR_SIZE;for(let e=i;e>0;e--){let t=this.expression.substring(n,n+e);if(te.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return v.isNullOrBlank(s)||(this.tokens.push(new Z(s)),a=!1),this.checkUnaryOperator(this.tokens,this.ops,te.OPERATION_VALUE_OF.get(t),a),a=!0,r.setLength(0),new _(n+e-1,a)}return r.append(e),new _(n,!1)}processTernaryOperator(e,t,r,s,n){if(n)throw new z(this.expression,"Ternary operator is followed by an operator");""!=r.trim()&&(this.tokens.push(new re(r)),t.setLength(0));let a=1,i="";const o=++s;for(;s<e&&a>0;)i=this.expression.charAt(s),"?"==i?++a:":"==i&&--a,++s;if(":"!=i)throw new z(this.expression,"':' operater is missing");if(s>=e)throw new z(this.expression,"Third part of the ternary expression is missing");for(;!this.ops.isEmpty()&&this.hasPrecedence(te.CONDITIONAL_TERNARY_OPERATOR,this.ops.peek());){let e=this.ops.pop();if(te.UNARY_OPERATORS.has(e)){const t=this.tokens.pop();this.tokens.push(new re("",t,void 0,e))}else{let t=this.tokens.pop(),r=this.tokens.pop();this.tokens.push(new re("",r,t,e))}}this.ops.push(te.CONDITIONAL_TERNARY_OPERATOR),this.tokens.push(new re(this.expression.substring(o,s-1)));const u=this.expression.substring(s);if(""===u.trim())throw new z(this.expression,"Third part of the ternary expression is missing");return this.tokens.push(new re(u)),e-1}processSubExpression(e,t,r,s,n){if(te.OPERATORS.has(r))this.checkUnaryOperator(this.tokens,this.ops,te.OPERATION_VALUE_OF.get(r),n),t.setLength(0);else if(!v.isNullOrBlank(r))throw new z(this.expression,M.format("Unkown token : $ found.",r));let a=1;const i=new K;let o=this.expression.charAt(s);for(s++;s<e&&a>0;)o=this.expression.charAt(s),"("==o?a++:")"==o&&a--,0!=a&&(i.append(o),s++);if(")"!=o)throw new z(this.expression,"Missing a closed parenthesis");for(;i.length()>2&&"("==i.charAt(0)&&")"==i.charAt(i.length()-1);)i.deleteCharAt(0),i.setLength(i.length()-1);return this.tokens.push(new re(i.toString().trim())),s}processTokenSepearator(e,t,r){return v.isNullOrBlank(t)||(te.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,te.OPERATION_VALUE_OF.get(t),r),r=!0):(this.tokens.push(new Z(t)),r=!1)),e.setLength(0),r}checkUnaryOperator(e,t,r,s){if(r)if(s||e.isEmpty()){if(!te.UNARY_OPERATORS.has(r))throw new z(this.expression,M.format("Extra operator $ found.",r));{const e=te.UNARY_MAP.get(r);e&&t.push(e)}}else{for(;!t.isEmpty()&&this.hasPrecedence(r,t.peek());){let r=t.pop();if(te.UNARY_OPERATORS.has(r)){let t=e.pop();e.push(new re("",t,void 0,r))}else{let t=e.pop(),s=e.pop();e.push(new re("",s,t,r))}}t.push(r)}}hasPrecedence(e,t){let r=te.OPERATOR_PRIORITY.get(e),s=te.OPERATOR_PRIORITY.get(t);if(!r||!s)throw new Error("Unknown operators provided");return s<r}toString(){if(this.ops.isEmpty())return 1==this.tokens.size()?this.tokens.get(0).toString():"Error: No tokens";let e=new K,t=0;const r=this.ops.toArray(),s=this.tokens.toArray();for(let n=0;n<r.length;n++)if(r[n].getOperator().startsWith("UN: "))e.append("(").append(r[n].getOperator().substring(4)).append(s[t]instanceof re?s[t].toString():s[t]).append(")"),t++;else if(this.ops.get(n)==te.CONDITIONAL_TERNARY_OPERATOR){let r=s[t++];e.insert(0,r.toString()),e.insert(0,":"),r=s[t++],e.insert(0,r.toString()),e.insert(0,"?"),r=s[t++],e.insert(0,r.toString()).append(")"),e.insert(0,"(")}else{if(0==t){const r=s[t++];e.insert(0,r.toString())}const a=s[t++];e.insert(0,r[n].getOperator()).insert(0,a.toString()).insert(0,"(").append(")")}return e.toString()}equals(e){return this.expression==e.expression}}e({},"ExpressionEvaluator",(()=>gt));var se={};e(se,"LogicalNullishCoalescingOperator",(()=>ie));var ne={};e(ne,"BinaryOperator",(()=>ae));class ae{nullCheck(e,t,r){if(n(e)||n(t))throw new X(M.format("$ cannot be applied to a null value",r.getOperatorName()))}}class ie extends ae{apply(e,t){return n(e)?t:e}}var oe={};e(oe,"ArithmeticAdditionOperator",(()=>ue));class ue extends ae{apply(e,t){return this.nullCheck(e,t,te.ADDITION),e+t}}var pe={};e(pe,"ArithmeticDivisionOperator",(()=>he));class he extends ae{apply(e,t){return this.nullCheck(e,t,te.DIVISION),e/t}}var le={};e(le,"ArithmeticIntegerDivisionOperator",(()=>ce));class ce extends ae{apply(e,t){return this.nullCheck(e,t,te.DIVISION),Math.floor(e/t)}}var me={};e(me,"ArithmeticModulusOperator",(()=>ge));class ge extends ae{apply(e,t){return this.nullCheck(e,t,te.MOD),e%t}}var fe={};e(fe,"ArithmeticMultiplicationOperator",(()=>Ee));class Ee extends ae{apply(e,t){this.nullCheck(e,t,te.MULTIPLICATION);const r="string"==typeof e;if(r||"string"===typeof t){let s=r?e:t,n=r?t:e,a="",i=n<0;n=Math.abs(n);let o=Math.floor(n);for(;o-- >0;)a+=s;let u=Math.floor(s.length*(n-Math.floor(n)));if(u<0&&(u=-u),0!=u&&(a+=s.substring(0,u)),i){let e="";for(let t=a.length-1;t>=0;t--)e+=a[t];return e}return a}return e*t}}var Te={};e(Te,"ArithmeticSubtractionOperator",(()=>Ae));class Ae extends ae{apply(e,t){return this.nullCheck(e,t,te.SUBTRACTION),e-t}}var Oe={};e(Oe,"ArrayOperator",(()=>we));class we extends ae{apply(e,t){if(!e)throw new X("Cannot apply array operator on a null value");if(!t)throw new X("Cannot retrive null index value");if(!Array.isArray(e)&&"string"!=typeof e)throw new X(M.format("Cannot retrieve value from a primitive value $",e));if(t>=e.length)throw new X(M.format("Cannot retrieve index $ from the array of length $",t,e.length));return e[t]}}var Se={};e(Se,"BitwiseAndOperator",(()=>de));class de extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_AND),e&t}}var Ne={};e(Ne,"BitwiseLeftShiftOperator",(()=>ye));class ye extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_LEFT_SHIFT),e<<t}}var Re={};e(Re,"BitwiseOrOperator",(()=>Ie));class Ie extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_OR),e|t}}var xe={};e(xe,"BitwiseRightShiftOperator",(()=>Me));class Me extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_RIGHT_SHIFT),e>>t}}var ve={};e(ve,"BitwiseUnsignedRightShiftOperator",(()=>Pe));class Pe extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_UNSIGNED_RIGHT_SHIFT),e>>>t}}var _e={};e(_e,"BitwiseXorOperator",(()=>Le));class Le extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_XOR),e^t}}var Ce={};e(Ce,"LogicalAndOperator",(()=>Ue));e({},"PrimitiveUtil",(()=>be));class be{static findPrimitiveNullAsBoolean(e){if(!e)return new _(i.BOOLEAN,!1);let t=typeof e;if("object"===t)throw new X(M.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new _(i.BOOLEAN,r):"string"===t?new _(i.STRING,r):be.findPrimitiveNumberType(r)}static findPrimitive(e){if(n(e))return new _(i.NULL,void 0);let t=typeof e;if("object"===t)throw new X(M.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new _(i.BOOLEAN,r):"string"===t?new _(i.STRING,r):be.findPrimitiveNumberType(r)}static findPrimitiveNumberType(e){if(n(e)||Array.isArray(e)||"object"==typeof e)throw new X(M.format("Unable to convert $ to a number.",e));let t=e;try{let e=t;return Number.isInteger(e)?new _(i.LONG,e):new _(i.DOUBLE,e)}catch(e){throw new X(M.format("Unable to convert $ to a number.",t),e)}}static compare(e,t){if(e==t)return 0;if(n(e)||n(t))return n(e)?-1:1;if(Array.isArray(e)||Array.isArray(t)){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!=t.length)return e.length-t.length;for(let r=0;r<e.length;r++){let s=this.compare(e[r],t[r]);if(0!=s)return s}return 0}return Array.isArray(e)?-1:1}const r=typeof e,s=typeof t;return"object"===r||"object"===s?("object"===r&&"object"===s&&Object.keys(e).forEach((r=>{let s=this.compare(e[r],t[r]);if(0!=s)return s})),"object"===r?-1:1):this.comparePrimitive(e,t)}static comparePrimitive(e,t){return n(e)||n(t)?n(e)&&n(t)?0:n(e)?-1:1:e==t?0:"boolean"==typeof e||"boolean"==typeof t?e?-1:1:"string"==typeof e||"string"==typeof t?e+""<t+""?-1:1:"number"==typeof e||"number"==typeof t?e-t:0}static baseNumberType(e){return Number.isInteger(e)?i.LONG:i.DOUBLE}static toPrimitiveType(e){return e}constructor(){}}class Ue extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",s.getT2()));return r.getT2()&&s.getT2()}}var Ve={};e(Ve,"LogicalEqualOperator",(()=>De));function Be(e,t){let r=new J;r.push(e);let s=new J;for(s.push(t);!r.isEmpty()&&!s.isEmpty();){const e=r.pop(),t=s.pop();if(e===t)continue;const n=typeof e,a=typeof t;if("undefined"===n||"undefined"===a){if(!e&&!t)continue;return!1}if(n!==a)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!=t.length)return!1;for(let n=0;n<e.length;n++)r.push(e[n]),s.push(t[n])}else{if("object"!==n)return!1;{const n=Object.entries(e),a=Object.entries(t);if(n.length!==a.length)return!1;for(const[e,a]of n)r.push(a),s.push(t[e])}}}return!0}e({},"deepEqual",(()=>Be));class De extends ae{apply(e,t){return Be(e,t)}}var ke={};e(ke,"LogicalGreaterThanEqualOperator",(()=>Ge));class Ge extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare >= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>=s.getT2()}}var Fe={};e(Fe,"LogicalGreaterThanOperator",(()=>He));class He extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare > with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>s.getT2()}}var Ye={};e(Ye,"LogicalLessThanEqualOperator",(()=>$e));class $e extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare <= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<=s.getT2()}}var We={};e(We,"LogicalLessThanOperator",(()=>je));class je extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare < with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<s.getT2()}}var qe={};e(qe,"LogicalNotEqualOperator",(()=>Xe));class Xe extends ae{apply(e,t){return!Be(e,t)}}var Je={};e(Je,"LogicalOrOperator",(()=>Qe));class Qe extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",s.getT2()));return r.getT2()||s.getT2()}}var Ke={};e(Ke,"ObjectOperator",(()=>ze));class ze extends ae{apply(e,t){if(!e)throw new X("Cannot apply array operator on a null value");if(!t)throw new X("Cannot retrive null property value");const r=typeof e;if(!Array.isArray(e)&&"string"!=r&&"object"!=r)throw new X(M.format("Cannot retrieve value from a primitive value $",e));return e[t]}}var Ze={};e(Ze,"ArithmeticUnaryMinusOperator",(()=>rt));var et={};e(et,"UnaryOperator",(()=>tt));class tt{nullCheck(e,t){if(n(e))throw new X(M.format("$ cannot be applied to a null value",t.getOperatorName()))}}class rt extends tt{apply(e){return this.nullCheck(e,te.UNARY_MINUS),be.findPrimitiveNumberType(e),-e}}var st={};e(st,"ArithmeticUnaryPlusOperator",(()=>nt));class nt extends tt{apply(e){return this.nullCheck(e,te.UNARY_PLUS),be.findPrimitiveNumberType(e),e}}var at={};e(at,"BitwiseComplementOperator",(()=>it));class it extends tt{apply(e){this.nullCheck(e,te.UNARY_BITWISE_COMPLEMENT);let t=be.findPrimitiveNumberType(e);if(t.getT1()!=i.INTEGER&&t.getT1()!=i.LONG)throw new X(M.format("Unable to apply bitwise operator on $",e));return~e}}var ot={};e(ot,"LogicalNotOperator",(()=>ut));class ut extends tt{apply(e){if(this.nullCheck(e,te.UNARY_LOGICAL_NOT),be.findPrimitiveNumberType(e).getT1()!=i.BOOLEAN)throw new X(M.format("Unable to apply bitwise operator on $",e));return!e}}e({},"LiteralTokenValueExtractor",(()=>lt));e({},"TokenValueExtractor",(()=>pt));class pt{static REGEX_SQUARE_BRACKETS=/[\[\]]/;static REGEX_DOT=/\./;getValue(e){let t=this.getPrefix();if(!e.startsWith(t))throw new w(M.format("Token $ doesn't start with $",e,t));return this.getValueInternal(e)}retrieveElementFrom(e,t,r,s){if(n(s))return;if(t.length==r)return s;let a=t[r].split(pt.REGEX_SQUARE_BRACKETS).map((e=>e.trim())).filter((e=>!v.isNullOrBlank(e))).reduce(((s,n,a)=>this.resolveForEachPartOfTokenWithBrackets(e,t,r,n,s,a)),s);return this.retrieveElementFrom(e,t,r+1,a)}resolveForEachPartOfTokenWithBrackets(e,t,r,s,a,i){if(!n(a)){if(0===i){if(Array.isArray(a)){if("length"===s)return a.length;try{let e=parseInt(s);if(isNaN(e))throw new Error(M.format("$ is not a number",e));if(e>=a.length)return;return a[e]}catch(t){throw new z(e,M.format("$ couldn't be parsed into integer in $",s,e),t)}}return this.checkIfObject(e,t,r,a),a[s]}if(s?.startsWith('"')){if(!s.endsWith('"')||1==s.length||2==s.length)throw new z(e,M.format("$ is missing a double quote or empty key found",e));return this.checkIfObject(e,t,r,a),a[s.substring(1,s.length-1)]}try{let t=parseInt(s);if(isNaN(t))throw new Error(M.format("$ is not a number",t));if(!Array.isArray(a))throw new z(e,M.format("Expecting an array with index $ while processing the expression",t,e));if(t>=a.length)return;return a[t]}catch(t){throw new z(e,M.format("$ couldn't be parsed into integer in $",s,e),t)}}}checkIfObject(e,t,r,s){if("object"!=typeof s||Array.isArray(s))throw new z(e,M.format("Unable to retrive $ from $ in the path $",t[r],s.toString(),e))}}const ht=new Map([["true",!0],["false",!1],["null",void 0]]);class lt extends pt{static INSTANCE=new lt;getValueInternal(e){if(!v.isNullOrBlank(e))return e=e.trim(),ht.has(e)?ht.get(e):e.startsWith('"')?this.processString(e):this.processNumbers(e)}processNumbers(e){try{let t;if(t=-1==e.indexOf(".")?parseInt(e):parseFloat(e),isNaN(t))throw new Error("Parse number error");return t}catch(t){throw new z(e,M.format("Unable to parse the literal or expression $",e),t)}}processString(e){if(!e.endsWith('"'))throw new z(e,M.format("String literal $ is not closed properly",e));return e.substring(1,e.length-1)}getPrefix(){return""}}var ct={};e(ct,"ConditionalTernaryOperator",(()=>mt));class mt extends class{nullCheck(e,t,r,s){if(n(e)||n(t)||n(r))throw new X(M.format("$ cannot be applied to a null value",s.getOperatorName()))}}{apply(e,t,r){return e?t:r}}t({},ct);class gt{static UNARY_OPERATORS_MAP=new Map([[te.UNARY_BITWISE_COMPLEMENT,new it],[te.UNARY_LOGICAL_NOT,new ut],[te.UNARY_MINUS,new rt],[te.UNARY_PLUS,new nt]]);static TERNARY_OPERATORS_MAP=new Map([[te.CONDITIONAL_TERNARY_OPERATOR,new mt]]);static BINARY_OPERATORS_MAP=new Map([[te.ADDITION,new ue],[te.DIVISION,new he],[te.INTEGER_DIVISION,new ce],[te.MOD,new ge],[te.MULTIPLICATION,new Ee],[te.SUBTRACTION,new Ae],[te.BITWISE_AND,new de],[te.BITWISE_LEFT_SHIFT,new ye],[te.BITWISE_OR,new Ie],[te.BITWISE_RIGHT_SHIFT,new Me],[te.BITWISE_UNSIGNED_RIGHT_SHIFT,new Pe],[te.BITWISE_XOR,new Le],[te.AND,new Ue],[te.EQUAL,new De],[te.GREATER_THAN,new He],[te.GREATER_THAN_EQUAL,new Ge],[te.LESS_THAN,new je],[te.LESS_THAN_EQUAL,new $e],[te.OR,new Qe],[te.NOT_EQUAL,new Xe],[te.NULLISH_COALESCING_OPERATOR,new ie],[te.ARRAY_OPERATOR,new we],[te.OBJECT_OPERATOR,new ze]]);static UNARY_OPERATORS_MAP_KEY_SET=new Set(gt.UNARY_OPERATORS_MAP.keys());constructor(e){e instanceof re?(this.exp=e,this.expression=this.exp.getExpression()):this.expression=e}evaluate(e){const t=this.processNestingExpression(this.expression,e);return this.expression=t.getT1(),this.exp=t.getT2(),this.evaluateExpression(this.exp,e)}processNestingExpression(e,t){let r=0,s=0;const n=new J;for(;s<e.length-1;){if("{"==e.charAt(s)&&"{"==e.charAt(s+1))0==r&&n.push(new _(s+2,-1)),r++,s++;else if("}"==e.charAt(s)&&"}"==e.charAt(s+1)){if(r--,r<0)throw new z(e,"Expecting {{ nesting path operator to be started before closing");0==r&&n.push(n.pop().setT2(s)),s++}s++}let a=this.replaceNestingExpression(e,t,n);return new _(a,new re(a))}replaceNestingExpression(e,t,r){let s=e;for(var n of r.toArray()){if(-1==n.getT2())throw new z(e,"Expecting }} nesting path operator to be closed");let r=new gt(s.substring(n.getT1(),n.getT2())).evaluate(t);s=s.substring(0,n.getT1()-2)+r+s.substring(n.getT2()+2)}return s}getExpression(){return this.exp||(this.exp=new re(this.expression)),this.exp}getExpressionString(){return this.expression}evaluateExpression(e,t){let r=e.getOperations(),s=e.getTokens();for(;!r.isEmpty();){let e=r.pop(),o=s.pop();if(gt.UNARY_OPERATORS_MAP_KEY_SET.has(e))s.push(this.applyUnaryOperation(e,this.getValueFromToken(t,o)));else if(e==te.OBJECT_OPERATOR||e==te.ARRAY_OPERATOR)this.processObjectOrArrayOperator(t,r,s,e,o);else if(e==te.CONDITIONAL_TERNARY_OPERATOR){const r=s.pop(),u=s.pop();var n=this.getValueFromToken(t,u),a=this.getValueFromToken(t,r),i=this.getValueFromToken(t,o);s.push(this.applyTernaryOperation(e,n,a,i))}else{const r=s.pop();n=this.getValueFromToken(t,r),a=this.getValueFromToken(t,o);s.push(this.applyBinaryOperation(e,n,a))}}if(s.isEmpty())throw new X(M.format("Expression : $ evaluated to null",e));if(1!=s.size())throw new X(M.format("Expression : $ evaluated multiple values $",e,s));const o=s.get(0);if(o instanceof ee)return o.getElement();if(!(o instanceof re))return this.getValueFromToken(t,o);throw new X(M.format("Expression : $ evaluated to $",e,s.get(0)))}processObjectOrArrayOperator(e,t,r,s,n){const a=new J,i=new J;if(!s||!n)return;do{i.push(s),n instanceof re?a.push(new ee(n.toString(),this.evaluateExpression(n,e))):n&&a.push(n),n=r.isEmpty()?void 0:r.pop(),s=t.isEmpty()?void 0:t.pop()}while(s==te.OBJECT_OPERATOR||s==te.ARRAY_OPERATOR);n&&(n instanceof re?a.push(new ee(n.toString(),this.evaluateExpression(n,e))):a.push(n)),s&&t.push(s);let o=a.pop(),u=new K(o instanceof ee?o.getTokenValue():o.toString());for(;!a.isEmpty();)o=a.pop(),s=i.pop(),u.append(s.getOperator()).append(o instanceof ee?o.getTokenValue():o.toString()),s==te.ARRAY_OPERATOR&&u.append("]");let p=u.toString(),h=p.substring(0,p.indexOf(".")+1);if(h.length>2&&e.has(h))r.push(new ee(p,this.getValue(p,e)));else{let e;try{e=lt.INSTANCE.getValue(p)}catch(t){e=p}r.push(new ee(p,e))}}applyTernaryOperation(e,t,r,s){let n=gt.TERNARY_OPERATORS_MAP.get(e);if(!n)throw new z(this.expression,M.format("No operator found to evaluate $",this.getExpression()));return new ee(e.toString(),n.apply(t,r,s))}applyBinaryOperation(e,t,r){let s=typeof t,n=typeof r,a=gt.BINARY_OPERATORS_MAP.get(e);if(("object"===s||"object"===n)&&e!==te.EQUAL&&e!==te.NOT_EQUAL)throw new z(this.expression,M.format("Cannot evaluate expression $ $ $",t,e.getOperator(),r));if(!a)throw new z(this.expression,M.format("No operator found to evaluate $ $ $",t,e.getOperator(),r));return new ee(e.toString(),a.apply(t,r))}applyUnaryOperation(e,t){if("object"===typeof t||Array.isArray(t))throw new z(this.expression,M.format("The operator $ cannot be applied to $",e.getOperator(),t));let r=gt.UNARY_OPERATORS_MAP.get(e);if(!r)throw new z(this.expression,M.format("No Unary operator $ is found to apply on $",e.getOperator(),t));return new ee(e.toString(),r.apply(t))}getValueFromToken(e,t){return t instanceof re?this.evaluateExpression(t,e):t instanceof ee?t.getElement():this.getValue(t.getExpression(),e)}getValue(e,t){if(e.length<=5)return lt.INSTANCE.getValue(e);const r=e.substring(0,e.indexOf(".")+1);return(t.get(r)??lt.INSTANCE).getValue(e)}}const ft=new I("Set").setNamespace(s.SYSTEM_CTX).setParameters(new Map([T.ofEntry("name",(new m).setName("name").setType(l.of(i.STRING)).setMinLength(1),!1,f.CONSTANT),T.ofEntry("value",m.ofAny("value"))])).setEvents(new Map([N.outputEventMapEntry(new Map)]));const Et=new I("GenerateEvent").setNamespace(s.SYSTEM).setParameters(new Map([T.ofEntry("eventName",m.ofString("eventName").setDefaultValue("output")),T.ofEntry("results",m.ofObject("results").setProperties(new Map([["name",m.ofString("name")],["value",T.EXPRESSION]])),!0)])).setEvents(new Map([N.outputEventMapEntry(new Map)]));class Tt extends W{static CONDITION="condition";static SIGNATURE=new I("If").setNamespace(s.SYSTEM).setParameters(new Map([T.ofEntry(Tt.CONDITION,m.of(Tt.CONDITION,i.BOOLEAN))])).setEvents(new Map([N.eventMapEntry(N.TRUE,new Map),N.eventMapEntry(N.FALSE,new Map),N.outputEventMapEntry(new Map)]));getSignature(){return Tt.SIGNATURE}async internalExecute(e){var t=e.getArguments()?.get(Tt.CONDITION);return new R([y.of(t?N.TRUE:N.FALSE,new Map),y.outputOf(new Map)])}}const At=new I("CountLoop").setNamespace(s.SYSTEM_LOOP).setParameters(new Map([T.ofEntry("count",m.of("count",i.INTEGER).setDefaultValue(1))])).setEvents(new Map([N.eventMapEntry(N.ITERATION,new Map([["index",m.of("index",i.INTEGER)]])),N.outputEventMapEntry(new Map([["value",m.of("value",i.INTEGER)]]))]));const Ot=new I("RangeLoop").setNamespace(s.SYSTEM_LOOP).setParameters(new Map([T.ofEntry("from",m.of("from",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE).setDefaultValue(0)),T.ofEntry("to",m.of("to",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE).setDefaultValue(1)),T.ofEntry("step",m.of("step",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE).setDefaultValue(1).setNot((new m).setConstant(0)))])).setEvents(new Map([N.eventMapEntry(N.ITERATION,new Map([["index",m.of("index",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE)]])),N.outputEventMapEntry(new Map([["value",m.of("value",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE)]]))]));const wt=new I("Add").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofNumber("value")]]))]));const St=[()=>new Map([["value",new T("value",m.ofNumber("value"))]]),()=>new Map([["value1",new T("value1",m.ofNumber("value1"))],["value2",new T("value2",m.ofNumber("value2"))]])];class dt extends W{constructor(e,t,r=1,...n){super(),n&&n.length||(n=[i.DOUBLE]),this.parametersNumber=r,this.mathFunction=t,this.signature=new I(e).setNamespace(s.MATH).setParameters(St[r-1]()).setEvents(new Map([N.outputEventMapEntry(new Map([["value",(new m).setType(l.of(...n)).setName("value")]]))]))}getSignature(){return this.signature}async internalExecute(e){let t,r=be.findPrimitiveNumberType(e.getArguments()?.get(1==this.parametersNumber?"value":"value1")).getT2();return 2==this.parametersNumber&&(t=be.findPrimitiveNumberType(e.getArguments()?.get("value2")).getT2()),new R([y.outputOf(new Map([["value",this.mathFunction.call(this,r,t)]]))])}}class Nt extends W{static SIGNATURE=new I("Hypotenuse").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",(new m).setType(l.of(i.DOUBLE)).setName("value")]]))]));constructor(){super()}getSignature(){return Nt.SIGNATURE}async internalExecute(e){let t=e.getArguments()?.get("value");return new R([y.outputOf(new Map([["value",Math.sqrt(t.reduce(((e,t)=>e+t*t),0))]]))])}}const yt=new I("Maximum").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofNumber("value")]]))]));const Rt=new I("Minimum").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofNumber("value")]]))]));var It={};e(It,"MapUtil",(()=>xt)),e(It,"MapEntry",(()=>Mt));class xt{static of(e,t,r,s,a,i,o,u,p,h,l,c,m,g,f,E,T,A,O,w){const S=new Map;return n(e)||n(t)||S.set(e,t),n(r)||n(s)||S.set(r,s),n(a)||n(i)||S.set(a,i),n(o)||n(u)||S.set(o,u),n(p)||n(h)||S.set(p,h),n(l)||n(c)||S.set(l,c),n(m)||n(g)||S.set(m,g),n(f)||n(E)||S.set(f,E),n(T)||n(A)||S.set(T,A),n(O)||n(w)||S.set(O,w),S}static ofArrayEntries(...e){const t=new Map;for(const[r,s]of e)t.set(r,s);return t}static entry(e,t){return new Mt(e,t)}static ofEntries(...e){const t=new Map;for(const r of e)t.set(r.k,r.v);return t}static ofEntriesArray(...e){const t=new Map;for(let r=0;r<e.length;r++)t.set(e[r][0],e[r][1]);return t}constructor(){}}class Mt{constructor(e,t){this.k=e,this.v=t}}class vt extends W{static SIGNATURE=new I("Random").setNamespace(s.MATH).setEvents(new Map([N.outputEventMapEntry(xt.of("value",m.ofDouble("value")))]));getSignature(){return vt.SIGNATURE}async internalExecute(e){return new R([y.outputOf(new Map([["value",Math.random()]]))])}}const Pt={Absolute:new dt("Absolute",(e=>Math.abs(e)),1,i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE),ACosine:new dt("ArcCosine",(e=>Math.acos(e))),ASine:new dt("ArcSine",(e=>Math.asin(e))),ATangent:new dt("ArcTangent",(e=>Math.atan(e))),Ceiling:new dt("Ceiling",(e=>Math.ceil(e))),Cosine:new dt("Cosine",(e=>Math.cos(e))),CosineH:new dt("HyperbolicCosine",(e=>Math.cosh(e))),CubeRoot:new dt("CubeRoot",(e=>Math.cbrt(e))),Exponential:new dt("Exponential",(e=>Math.exp(e))),Expm1:new dt("ExponentialMinus1",(e=>Math.expm1(e))),Floor:new dt("Floor",(e=>Math.floor(e))),Log:new dt("LogNatural",(e=>Math.log(e))),Log10:new dt("Log10",(e=>Math.log10(e))),Round:new dt("Round",(e=>Math.round(e)),1,i.INTEGER,i.LONG),Sine:new dt("Sine",(e=>Math.sin(e))),SineH:new dt("HyperbolicSine",(e=>Math.sinh(e))),Tangent:new dt("Tangent",(e=>Math.tan(e))),TangentH:new dt("HyperbolicTangent",(e=>Math.tanh(e))),ToDegrees:new dt("ToDegrees",(e=>e*(Math.PI/180))),ToRadians:new dt("ToRadians",(e=>e*(180/Math.PI))),SquareRoot:new dt("SquareRoot",(e=>Math.sqrt(e))),ArcTangent:new dt("ArcTangent2",((e,t)=>Math.atan2(e,t)),2),Power:new dt("Power",((e,t)=>Math.pow(e,t)),2),Add:new class extends W{getSignature(){return wt}async internalExecute(e){let t=e.getArguments()?.get("value");return new R([y.outputOf(new Map([["value",t.reduce(((e,t)=>e+t),0)]]))])}},Hypotenuse:new Nt,Maximum:new class extends W{getSignature(){return yt}async internalExecute(e){let t=e.getArguments()?.get("value");return new R([y.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t>e?t:e))]]))])}},Minimum:new class extends W{getSignature(){return Rt}async internalExecute(e){let t=e.getArguments()?.get("value");return new R([y.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t<e?t:e))]]))])}},Random:new vt};class _t{find(e,t){if(e==s.MATH)return Pt[t]}}e({},"HybridRepository",(()=>Lt));class Lt{constructor(...e){this.repos=e}find(e,t){for(let r of this.repos){let s=r.find(e,t);if(s)return s}}}function Ct(e){return[e.getSignature().getName(),e]}const bt=new Map([[s.SYSTEM_CTX,new Map([Ct(new class extends W{getSignature(){return j}async internalExecute(e){const t=e?.getArguments()?.get("name");if(e?.getContext()?.has(t))throw new w(M.format("Context already has an element for '$' ",t));let r=m.from(e?.getArguments()?.get("schema"));if(!r)throw new w("Schema is not supplied.");return e.getContext().set(t,new x(r,n(r.getDefaultValue())?void 0:r.getDefaultValue())),new R([y.outputOf(new Map)])}}),Ct(new class extends W{getSignature(){return q}async internalExecute(e){const t=e?.getArguments()?.get("name");if(!e.getContext()?.has(t))throw new w(M.format("Context don't have an element for '$' ",t));return new R([y.outputOf(new Map(["value",e.getContext()?.get(t)?.getElement()]))])}}),Ct(new class extends W{getSignature(){return ft}async internalExecute(e){let t=e?.getArguments()?.get("name");if(v.isNullOrBlank(t))throw new w("Empty string is not a valid name for the context element");let r=e?.getArguments()?.get("value");const s=new re(t),n=s.getTokens().peekLast();if(!n.getExpression().startsWith("Context")||n instanceof re||n instanceof ee&&!n.getElement().toString().startsWith("Context"))throw new X(M.format("The context path $ is not a valid path in context",t));for(const e of s.getOperations().toArray())if(e!=te.ARRAY_OPERATOR&&e!=te.OBJECT_OPERATOR)throw new X(M.format("Expected a reference to the context location, but found an expression $",t));for(let r=0;r<s.getTokens().size();r++){let n=s.getTokens().get(r);n instanceof re&&s.getTokens().set(r,new ee(t,new gt(n).evaluate(e.getValuesMap())))}return this.modifyContext(e,t,r,s)}modifyContext(e,t,r,s){const a=s.getTokens();a.removeLast();const i=s.getOperations();i.removeLast();let o=e.getContext()?.get(a.removeLast().getExpression());if(n(o))throw new w(M.format("Context doesn't have any element with name '$' ",t));if(i.isEmpty())return o.setElement(r),new R([y.outputOf(new Map)]);let u=o.getElement(),p=i.removeLast(),h=a.removeLast(),l=h instanceof ee?h.getElement():h.getExpression();for(n(u)&&(u=p==te.OBJECT_OPERATOR?{}:[],o.setElement(u));!i.isEmpty();)u=p==te.OBJECT_OPERATOR?this.getDataFromObject(u,l,i.peekLast()):this.getDataFromArray(u,l,i.peekLast()),p=i.removeLast(),h=a.removeLast(),l=h instanceof ee?h.getElement():h.getExpression();return p==te.OBJECT_OPERATOR?this.putDataInObject(u,l,r):this.putDataInArray(u,l,r),new R([y.outputOf(new Map)])}getDataFromArray(e,t,r){if(!Array.isArray(e))throw new w(M.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new w(M.format("Expected an array index but found $",t));if(s<0)throw new w(M.format("Array index is out of bound - $",t));let a=e[s];return n(a)&&(a=r==te.OBJECT_OPERATOR?{}:[],e[s]=a),a}getDataFromObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new w(M.format("Expected an object but found $",e));let s=e[t];return n(s)&&(s=r==te.OBJECT_OPERATOR?{}:[],e[t]=s),s}putDataInArray(e,t,r){if(!Array.isArray(e))throw new w(M.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new w(M.format("Expected an array index but found $",t));if(s<0)throw new w(M.format("Array index is out of bound - $",t));e[s]=r}putDataInObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new w(M.format("Expected an object but found $",e));e[t]=r}})])],[s.SYSTEM_LOOP,new Map([Ct(new class extends W{getSignature(){return Ot}async internalExecute(e){let t=e.getArguments()?.get("from"),r=e.getArguments()?.get("to"),s=e.getArguments()?.get("step");const n=s>0;let a=t,i=!1;return new R({next(){if(i)return;if(n&&a>=r||!n&&a<=r)return i=!0,y.outputOf(new Map([["value",a]]));const e=y.of(N.ITERATION,new Map([["index",a]]));return a+=s,e}})}}),Ct(new class extends W{getSignature(){return At}async internalExecute(e){let t=e.getArguments()?.get("count"),r=0;return new R({next(){if(r>=t)return y.outputOf(new Map([["value",r]]));const e=y.of(N.ITERATION,new Map([["index",r]]));return++r,e}})}})])],[s.SYSTEM,new Map([Ct(new Tt),Ct(new class extends W{getSignature(){return Et}async internalExecute(e){const t=e.getEvents(),r=e.getArguments()?.get("eventName"),s=e?.getArguments()?.get("results").map((t=>{let r=t.value;if(n(r))throw new w("Expect a value object");let s=r.value;return r.isExpression&&(s=new gt(s).evaluate(e.getValuesMap())),[t.name,s]})).reduce(((e,t)=>(e.set(t[0],t[1]),e)),new Map);return t?.has(r)||t?.set(r,[]),t?.get(r)?.push(s),new R([y.outputOf(new Map)])}})])]]);class Ut extends Lt{constructor(){super({find:(e,t)=>bt.get(e)?.get(t)},new _t)}}e({},"ArrayUtil",(()=>Vt));class Vt{static removeAListFrom(e,t){if(!(t&&e&&e.length&&t.length))return;const r=new Set(t);for(let t=0;t<e.length;t++)r.has(e[t])&&(e.splice(t,1),t--)}static of(...e){const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r];return t}constructor(){}}e({},"StatementExecution",(()=>Dt));e({},"StatementMessage",(()=>Bt));class Bt{constructor(e,t){this.message=t,this.messageType=e}getMessageType(){return this.messageType}setMessageType(e){return this.messageType=e,this}getMessage(){return this.message}setMessage(e){return this.message=e,this}toString(){return`${this.messageType} : ${this.message}`}}class Dt{messages=new Array;dependencies=new Set;constructor(e){this.statement=e}getStatement(){return this.statement}setStatement(e){return this.statement=e,this}getMessages(){return this.messages}setMessages(e){return this.messages=e,this}getDependencies(){return this.dependencies}setDependencies(e){return this.dependencies=e,this}getUniqueKey(){return this.statement.getStatementName()}addMessage(e,t){this.messages.push(new Bt(e,t))}addDependency(e){this.dependencies.add(e)}getDepenedencies(){return this.dependencies}equals(e){if(!(e instanceof Dt))return!1;return e.statement.equals(this.statement)}}e({},"ContextTokenValueExtractor",(()=>kt));class kt extends pt{static PREFIX="Context.";constructor(e){super(),this.context=e}getValueInternal(e){let t=e.split(pt.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.context.get(r)?.getElement())}getPrefix(){return kt.PREFIX}}e({},"OutputMapTokenValueExtractor",(()=>Gt));class Gt extends pt{static PREFIX="Steps.";constructor(e){super(),this.output=e}getValueInternal(e){let t=e.split(pt.REGEX_DOT),r=1,s=this.output.get(t[r++]);if(!s||r>=t.length)return;let n=s.get(t[r++]);if(!n||r>=t.length)return;let a=n.get(t[r++]);return this.retrieveElementFrom(e,t,r,a)}getPrefix(){return Gt.PREFIX}}e({},"ArgumentsTokenValueExtractor",(()=>Ft));class Ft extends pt{static PREFIX="Arguments.";constructor(e){super(),this.args=e}getValueInternal(e){let t=e.split(pt.REGEX_DOT);return this.retrieveElementFrom(e,t,2,this.args.get(t[1]))}getPrefix(){return Ft.PREFIX}}e({},"GraphVertex",(()=>Yt));e({},"ExecutionGraph",(()=>Ht));class Ht{nodeMap=new Map;constructor(e=!1){this.isSubGrph=e}getVerticesData(){return Array.from(this.nodeMap.values()).map((e=>e.getData()))}addVertex(e){if(!this.nodeMap.has(e.getUniqueKey())){let t=new Yt(this,e);this.nodeMap.set(e.getUniqueKey(),t)}return this.nodeMap.get(e.getUniqueKey())}getVertex(e){return this.nodeMap.get(e)}getVertexData(e){if(this.nodeMap.has(e))return this.nodeMap.get(e).getData()}getVerticesWithNoIncomingEdges(){return Array.from(this.nodeMap.values()).filter((e=>!e.hasIncomingEdges()))}isCyclic(){let e,t=new J(this.getVerticesWithNoIncomingEdges()),r=new Set;for(;!t.isEmpty();){if(r.has(t.getFirst().getKey()))return!0;e=t.removeFirst(),r.add(e.getKey()),e.hasOutgoingEdges()&&t.addAll(Array.from(e.getOutVertices().values()).flatMap((e=>Array.from(e))))}return!1}addVertices(e){for(const t of e)this.addVertex(t)}getNodeMap(){return this.nodeMap}isSubGraph(){return this.isSubGrph}toString(){return"Execution Graph : \n"+Array.from(this.nodeMap.values()).map((e=>e.toString())).join("\n")}}class Yt{outVertices=new Map;inVertices=new Set;constructor(e,t){this.data=t,this.graph=e}getData(){return this.data}setData(e){return this.data=e,this}getOutVertices(){return this.outVertices}setOutVertices(e){return this.outVertices=e,this}getInVertices(){return this.inVertices}setInVertices(e){return this.inVertices=e,this}getGraph(){return this.graph}setGraph(e){return this.graph=e,this}getKey(){return this.data.getUniqueKey()}addOutEdgeTo(e,t){return this.outVertices.has(e)||this.outVertices.set(e,new Set),this.outVertices.get(e).add(t),t.inVertices.add(new _(this,e)),t}addInEdgeTo(e,t){return this.inVertices.add(new _(e,t)),e.outVertices.has(t)||e.outVertices.set(t,new Set),e.outVertices.get(t).add(this),e}hasIncomingEdges(){return!!this.inVertices.size}hasOutgoingEdges(){return!!this.outVertices.size}getSubGraphOfType(e){let t=new Ht(!0);var r=new J(Array.from(this.outVertices.get(e)??[]));for(r.map((e=>e.getData())).forEach((e=>t.addVertex(e)));!r.isEmpty();){var s=r.pop();Array.from(s.outVertices.values()).flatMap((e=>Array.from(e))).forEach((e=>{t.addVertex(e.getData()),r.add(e)}))}return t}toString(){var e=Array.from(this.getInVertices()).map((e=>e.getT1().getKey()+"("+e.getT2()+")")).join(", "),t=Array.from(this.outVertices.entries()).map((([e,t])=>e+": "+Array.from(t).map((e=>e.getKey())).join(","))).join("\n\t\t");return this.getKey()+":\n\tIn: "+e+"\n\tOut: \n\t\t"+t}}e({},"KIRuntime",(()=>Kt));e({},"JsonExpression",(()=>$t));class $t{constructor(e){this.expression=e}getExpression(){return this.expression}}let Wt;var jt;e({},"ParameterReferenceType",(()=>Wt)),(jt=Wt||(Wt={})).VALUE="VALUE",jt.EXPRESSION="EXPRESSION";function qt(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))}e({},"FunctionExecutionParameters",(()=>Xt));class Xt{count=0;valueExtractors=new Map;constructor(e,t,r){this.functionRepository=e,this.schemaRepository=t,this.executionId=r??qt()}getExecutionId(){return this.executionId}getContext(){return this.context}setContext(e){this.context=e;let t=new kt(e);return this.valueExtractors.set(t.getPrefix(),t),this}getArguments(){return this.args}setArguments(e){this.args=e;let t=new Ft(e);return this.valueExtractors.set(t.getPrefix(),t),this}getEvents(){return this.events}setEvents(e){return this.events=e,this}getStatementExecution(){return this.statementExecution}setStatementExecution(e){return this.statementExecution=e,this}getSteps(){return this.steps}setSteps(e){this.steps=e;let t=new Gt(e);return this.valueExtractors.set(t.getPrefix(),t),this}getCount(){return this.count}setCount(e){return this.count=e,this}getValuesMap(){return this.valueExtractors}getFunctionRepository(){return this.functionRepository}setFunctionRepository(e){return this.functionRepository=e,this}getSchemaRepository(){return this.schemaRepository}setSchemaRepository(e){return this.schemaRepository=e,this}addTokenValueExtractor(...e){for(const t of e)this.valueExtractors.set(t.getPrefix(),t);return this}setValuesMap(e){for(const[t,r]of e.entries())this.valueExtractors.set(t,r);return this}}let Jt;var Qt;e({},"StatementMessageType",(()=>Jt)),(Qt=Jt||(Jt={})).ERROR="ERROR",Qt.WARNING="WARNING",Qt.MESSAGE="MESSAGE";class Kt extends W{static PARAMETER_NEEDS_A_VALUE='Parameter "$" needs a value';static STEP_REGEX_PATTERN=new RegExp("Steps\\.([a-zA-Z0-9\\\\-]{1,})\\.([a-zA-Z0-9\\\\-]{1,})","g");static VERSION=1;static MAX_EXECUTION_ITERATIONS=1e7;constructor(e){if(super(),this.fd=e,this.fd.getVersion()>Kt.VERSION)throw new w("Runtime is at a lower version "+Kt.VERSION+" and trying to run code from version "+this.fd.getVersion()+".")}getSignature(){return this.fd}async getExecutionPlan(e){let t=new Ht;for(let r of Array.from(this.fd.getSteps().values()))t.addVertex(this.prepareStatementExecution(r,e.getFunctionRepository(),e.getSchemaRepository()));return new _(this.makeEdges(t),t)}async internalExecute(e){e.getContext()||e.setContext(new Map),e.getEvents()||e.setEvents(new Map),e.getSteps()||e.setSteps(new Map);let t=await this.getExecutionPlan(e),r=t.getT1();if(r.length)throw new w(M.format("Found these unresolved dependencies : $ ",r.map((e=>M.format("Steps.$.$",e.getT1(),e.getT2())))));let s=t.getT2().getVerticesData().filter((e=>e.getMessages().length)).map((e=>e.getStatement().getStatementName()+": \n"+e.getMessages().join(",")));if(s?.length)throw new w("Please fix the errors in the function definition before execution : \n"+s.join(",\n"));return await this.executeGraph(t.getT2(),e)}async executeGraph(e,t){let r=new J;r.addAll(e.getVerticesWithNoIncomingEdges());let s=new J;for(;!(r.isEmpty()&&s.isEmpty()||t.getEvents()?.has(N.OUTPUT));)if(await this.processBranchQue(t,r,s),await this.processExecutionQue(t,r,s),t.setCount(t.getCount()+1),t.getCount()==Kt.MAX_EXECUTION_ITERATIONS)throw new w("Execution locked in an infinite loop");if(!e.isSubGraph()&&!t.getEvents()?.size)throw new w("No events raised");return new R(Array.from(t.getEvents()?.entries()??[]).flatMap((e=>e[1].map((t=>y.of(e[0],t))))))}async processExecutionQue(e,t,r){if(!t.isEmpty()){let s=t.pop();await this.allDependenciesResolvedVertex(s,e.getSteps())?await this.executeVertex(s,e,r,t,e.getFunctionRepository()):t.add(s)}}async processBranchQue(e,t,r){if(r.length){let s=r.pop();await this.allDependenciesResolvedTuples(s.getT2(),e.getSteps())?await this.executeBranch(e,t,s):r.add(s)}}async executeBranch(e,t,r){let s,n=r.getT4();do{await this.executeGraph(r.getT1(),e),s=r.getT3().next(),s&&(e.getSteps()?.has(n.getData().getStatement().getStatementName())||e.getSteps()?.set(n.getData().getStatement().getStatementName(),new Map),e.getSteps()?.get(n.getData().getStatement().getStatementName())?.set(s.getName(),await this.resolveInternalExpressions(s.getResult(),e)))}while(s&&s.getName()!=N.OUTPUT);s?.getName()==N.OUTPUT&&n.getOutVertices().has(N.OUTPUT)&&(n?.getOutVertices()?.get(N.OUTPUT)??[]).forEach((e=>t.add(e)))}async executeVertex(e,t,r,s,n){let a=e.getData().getStatement(),i=n.find(a.getNamespace(),a.getName());if(!i)throw new w(M.format("$.$ function is not found.",a.getNamespace(),a.getName()));let o=i?.getSignature().getParameters(),u=this.getArgumentsFromParametersMap(t,a,o??new Map),p=t.getContext(),h=await i.execute(new Xt(t.getFunctionRepository(),t.getSchemaRepository(),t.getExecutionId()).setValuesMap(t.getValuesMap()).setContext(p).setArguments(u).setEvents(t.getEvents()).setSteps(t.getSteps()).setStatementExecution(e.getData()).setCount(t.getCount())),l=h.next();if(!l)throw new w(M.format("Executing $ returned no events",a.getStatementName()));let c=l.getName()==N.OUTPUT;if(t.getSteps()?.has(a.getStatementName())||t.getSteps().set(a.getStatementName(),new Map),t.getSteps().get(a.getStatementName()).set(l.getName(),this.resolveInternalExpressions(l.getResult(),t)),c){let t=e.getOutVertices().get(N.OUTPUT);t&&t.forEach((e=>s.add(e)))}else{let t=e.getSubGraphOfType(l.getName()),s=this.makeEdges(t);r.push(new C(t,s,h,e))}}resolveInternalExpressions(e,t){return e?Array.from(e.entries()).map((e=>new _(e[0],this.resolveInternalExpression(e[1],t)))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map):e}resolveInternalExpression(e,t){if(n(e)||"object"!=typeof e)return e;if(e instanceof $t){return new gt(e.getExpression()).evaluate(t.getValuesMap())}if(Array.isArray(e)){let r=[];for(let s of e)r.push(this.resolveInternalExpression(s,t));return r}if("object"==typeof e){let r={};for(let s of Object.entries(e))r[s[0]]=this.resolveInternalExpression(s[1],t);return r}}allDependenciesResolvedTuples(e,t){for(let r of e){if(!t.has(r.getT1()))return!1;if(!t.get(r.getT1())?.get(r.getT2()))return!1}return!0}allDependenciesResolvedVertex(e,t){return!e.getInVertices().size||0==Array.from(e.getInVertices()).filter((e=>{let r=e.getT1().getData().getStatement().getStatementName(),s=e.getT2();return!(t.has(r)&&t.get(r)?.has(s))})).length}getArgumentsFromParametersMap(e,t,r){return Array.from(t.getParameterMap().entries()).map((t=>{let s,n=Array.from(t[1]?.values()??[]);if(!n?.length)return new _(t[0],s);let a=r.get(t[0]);return a?(s=a.isVariableArgument()?n.map((t=>this.parameterReferenceEvaluation(e,t))).flatMap((e=>Array.isArray(e)?e:[e])):this.parameterReferenceEvaluation(e,n[0]),new _(t[0],s)):new _(t[0],void 0)})).filter((e=>!n(e.getT2()))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}parameterReferenceEvaluation(e,t){let r;if(t.getType()==Wt.VALUE)r=this.resolveInternalExpression(t.getValue(),e);else if(t.getType()==Wt.EXPRESSION&&!v.isNullOrBlank(t.getExpression())){r=new gt(t.getExpression()??"").evaluate(e.getValuesMap())}return r}prepareStatementExecution(e,t,r){let s=new Dt(e),a=t.find(e.getNamespace(),e.getName());if(!a)throw new w(M.format("$.$ was not available",e.getNamespace(),e.getName()));let i=new Map(a.getSignature().getParameters());for(let t of Array.from(e.getParameterMap().entries())){let e=i.get(t[0]);if(!e)continue;let a=Array.from(t[1]?.values()??[]);if(a.length||e.isVariableArgument()){if(e.isVariableArgument())for(let t of a)this.parameterReferenceValidation(s,e,t,r);else if(a.length){let t=a[0];this.parameterReferenceValidation(s,e,t,r)}i.delete(e.getParameterName())}else n(U.getDefaultValue(e.getSchema(),r))&&s.addMessage(Jt.ERROR,M.format(Kt.PARAMETER_NEEDS_A_VALUE,e.getParameterName())),i.delete(e.getParameterName())}if(!n(s.getStatement().getDependentStatements()))for(let e of s.getStatement().getDependentStatements().entries())e[1]&&s.addDependency(e[0]);if(i.size)for(let e of Array.from(i.values()))e.isVariableArgument()||n(U.getDefaultValue(e.getSchema(),r))&&s.addMessage(Jt.ERROR,M.format(Kt.PARAMETER_NEEDS_A_VALUE,e.getParameterName()));return s}parameterReferenceValidation(e,t,r,s){if(r){if(r.getType()==Wt.VALUE){n(r.getValue())&&n(U.getDefaultValue(t.getSchema(),s))&&e.addMessage(Jt.ERROR,M.format(Kt.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));let a=new J;for(a.push(new _(t.getSchema(),r.getValue()));!a.isEmpty();){let t=a.pop();if(t.getT2()instanceof $t)this.addDependencies(e,t.getT2().getExpression());else{if(n(t.getT1())||n(t.getT1().getType()))continue;if(t.getT1().getType()?.contains(i.ARRAY)&&Array.isArray(t.getT2())){let e=t.getT1().getItems();if(!e)continue;if(e.isSingleType())for(let r of t.getT2())a.push(new _(e.getSingleSchema(),r));else{let r=t.getT2();for(let t=0;t<r.length;t++)a.push(new _(e.getTupleSchema()[t],r[t]))}}else if(t.getT1().getType()?.contains(i.OBJECT)&&"object"==typeof t.getT2()){let r=t.getT1();if(r.getName()===T.EXPRESSION.getName()&&r.getNamespace()===T.EXPRESSION.getNamespace()){let r=t.getT2();r.isExpression&&this.addDependencies(e,r.value)}else if(r.getProperties())for(let e of Object.entries(t.getT2()))r.getProperties().has(e[0])&&a.push(new _(r.getProperties().get(e[0]),e[1]))}}}}else if(r.getType()==Wt.EXPRESSION)if(v.isNullOrBlank(r.getExpression()))n(U.getDefaultValue(t.getSchema(),s))&&e.addMessage(Jt.ERROR,M.format(Kt.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));else try{this.addDependencies(e,r.getExpression())}catch(t){e.addMessage(Jt.ERROR,M.format("Error evaluating $ : $",r.getExpression(),t))}}else n(U.getDefaultValue(t.getSchema(),s))&&e.addMessage(Jt.ERROR,M.format(Kt.PARAMETER_NEEDS_A_VALUE,t.getParameterName()))}addDependencies(e,t){t&&Array.from(t.match(Kt.STEP_REGEX_PATTERN)??[]).forEach((t=>e.addDependency(t)))}makeEdges(e){let t=e.getNodeMap().values(),r=[];for(let s of Array.from(t))for(let t of s.getData().getDependencies()){let n=t.indexOf(".",6),a=t.substring(6,n),i=t.indexOf(".",n+1),o=-1==i?t.substring(n+1):t.substring(n+1,i);e.getNodeMap().has(a)||r.push(new _(a,o));let u=e.getNodeMap().get(a);u&&s.addInEdgeTo(u,o)}return r}}e({},"KIRunConstants",(()=>zt));class zt{static NAMESPACE="namespace";static NAME="name";static ID="id";constructor(){}}e({},"Position",(()=>Zt));class Zt{static SCHEMA_NAME="Position";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(Zt.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["left",m.ofFloat("left")],["top",m.ofFloat("top")]]));constructor(e,t){this.left=e,this.top=t}getLeft(){return this.left}setLeft(e){return this.left=e,this}getTop(){return this.top}setTop(e){return this.top=e,this}static from(e){return e?new Zt(e.left,e.top):new Zt(-1,-1)}}e({},"FunctionDefinition",(()=>ar));e({},"Statement",(()=>rr));e({},"AbstractStatement",(()=>er));class er{override=!1;constructor(e){e&&(this.comment=e.comment,this.description=e.description,this.position=e.position?new Zt(e.position.getLeft(),e.position.getTop()):void 0,this.override=e.override)}getComment(){return this.comment}setComment(e){return this.comment=e,this}isOverride(){return this.override}setOverride(e){return this.override=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getPosition(){return this.position}setPosition(e){return this.position=e,this}}e({},"ParameterReference",(()=>tr));class tr{static SCHEMA_NAME="ParameterReference";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(tr.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["key",m.ofString("key")],["value",m.ofAny("value")],["expression",m.ofString("expression")],["type",m.ofString("type").setEnums(["EXPRESSION","VALUE"])]]));constructor(e){if(e instanceof tr){let t=e;this.key=t.key,this.type=t.type,this.value=n(t.value)?void 0:JSON.parse(JSON.stringify(t.value)),this.expression=t.expression}else this.type=e,this.key=qt()}getType(){return this.type}setType(e){return this.type=e,this}getKey(){return this.key}setKey(e){return this.key=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}getExpression(){return this.expression}setExpression(e){return this.expression=e,this}static ofExpression(e){const t=new tr(Wt.EXPRESSION).setExpression(e);return[t.getKey(),t]}static ofValue(e){const t=new tr(Wt.VALUE).setValue(e);return[t.getKey(),t]}static from(e){return new tr(e.type).setValue(e.value).setExpression(e.expression).setKey(e.key)}}class rr extends er{static SCHEMA_NAME="Statement";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(rr.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["statementName",m.ofString("statementName")],["comment",m.ofString("comment")],["description",m.ofString("description")],["namespace",m.ofString("namespace")],["name",m.ofString("name")],["dependentStatements",m.ofObject("dependentstatement").setAdditionalProperties((new c).setSchemaValue(m.ofBoolean("exists")))],["parameterMap",(new m).setName("parameterMap").setAdditionalProperties((new c).setSchemaValue(m.ofObject("parameterReference").setAdditionalProperties((new c).setSchemaValue(tr.SCHEMA))))],["position",Zt.SCHEMA]]));constructor(e,t,r){if(super(e instanceof rr?e:void 0),e instanceof rr){let t=e;this.statementName=t.statementName,this.name=t.name,this.namespace=t.namespace,t.parameterMap&&(this.parameterMap=new Map(Array.from(t.parameterMap.entries()).map((e=>[e[0],new Map(Array.from(e[1].entries()).map((e=>[e[0],new tr(e[1])])))])))),t.dependentStatements&&(this.dependentStatements=new Map(Array.from(t.dependentStatements.entries())))}else{if(this.statementName=e,!r||!t)throw new Error("Unknown constructor");this.namespace=t,this.name=r}}getStatementName(){return this.statementName}setStatementName(e){return this.statementName=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameterMap(){return this.parameterMap||(this.parameterMap=new Map),this.parameterMap}setParameterMap(e){return this.parameterMap=e,this}getDependentStatements(){return this.dependentStatements??new Map}setDependentStatements(e){return this.dependentStatements=e,this}equals(e){if(!(e instanceof rr))return!1;return e.statementName==this.statementName}static ofEntry(e){return[e.statementName,e]}static from(e){return new rr(e.statementName,e.namespace,e.name).setParameterMap(new Map(Object.entries(e.parameterMap??{}).map((([e,t])=>[e,new Map(Object.entries(t??{}).map((([e,t])=>tr.from(t))).map((e=>[e.getKey(),e])))])))).setDependentStatements(new Map(Object.entries(e.dependentStatements??{}))).setPosition(Zt.from(e.position)).setComment(e.comment).setDescription(e.description)}}e({},"StatementGroup",(()=>sr));class sr extends er{static SCHEMA_NAME="StatementGroup";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(sr.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["statementGroupName",m.ofString("statementGroupName")],["comment",m.ofString("comment")],["description",m.ofString("description")],["position",Zt.SCHEMA]]));constructor(e,t=new Map){super(),this.statementGroupName=e,this.statements=t}getStatementGroupName(){return this.statementGroupName}setStatementGroupName(e){return this.statementGroupName=e,this}getStatements(){return this.statements}setStatements(e){return this.statements=e,this}static from(e){return new sr(e.statementGroupName,new Map(Object.entries(e.statements||{}).map((([e,t])=>[e,"true"==(""+t)?.toLowerCase()])))).setPosition(Zt.from(e.position)).setComment(e.comment).setDescription(e.description)}}const nr=(new m).setNamespace(s.SYSTEM).setName("FunctionDefinition").setProperties(new Map([["name",m.ofString("name")],["namespace",m.ofString("namespace")],["parameters",m.ofArray("parameters",T.SCHEMA)],["events",m.ofObject("events").setAdditionalProperties((new c).setSchemaValue(N.SCHEMA))],["steps",m.ofObject("steps").setAdditionalProperties((new c).setSchemaValue(rr.SCHEMA))]]));nr.getProperties()?.set("parts",m.ofArray("parts",nr));class ar extends I{static SCHEMA=nr;version=1;constructor(e){super(e)}getVersion(){return this.version}setVersion(e){return this.version=e,this}getSteps(){return this.steps??new Map}setSteps(e){return this.steps=e,this}getStepGroups(){return this.stepGroups}setStepGroups(e){return this.stepGroups=e,this}getParts(){return this.parts}setParts(e){return this.parts=e,this}static from(e){return e?new ar(e.name).setSteps(new Map(Object.values(e.steps??{}).filter((e=>!!e)).map((e=>[e.statementName,rr.from(e)])))).setStepGroups(new Map(Object.values(e.stepGroups??{}).filter((e=>!!e)).map((e=>[e.statementGroupName,sr.from(e)])))).setParts(Array.from(e.parts??[]).filter((e=>!!e)).map((e=>ar.from(e)))).setVersion(e.version??1).setEvents(new Map(Object.values(e.events??{}).filter((e=>!!e)).map((e=>[e.name,N.from(e)])))).setParameters(new Map(Object.values(e.parameters??{}).filter((e=>!!e)).map((e=>[e.parameterName,T.from(e)])))):new ar("unknown")}}e({},"Argument",(()=>ir));class ir{argumentIndex=0;constructor(e,t,r){this.argumentIndex=e,this.name=t,this.value=r}getArgumentIndex(){return this.argumentIndex}setArgumentIndex(e){return this.argumentIndex=e,this}getName(){return this.name}setName(e){return this.name=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}static of(e,t){return new ir(0,e,t)}}var or={};t(or,Ze),t(or,st),t(or,at),t(or,ot),t(or,et);var ur={};t(ur,oe),t(ur,pe),t(ur,le),t(ur,me),t(ur,fe),t(ur,Te),t(ur,Oe),t(ur,ne),t(ur,Se),t(ur,Ne),t(ur,Re),t(ur,xe),t(ur,ve),t(ur,_e),t(ur,Ce),t(ur,Ve),t(ur,ke),t(ur,Fe),t(ur,Ye),t(ur,qe),t(ur,We),t(ur,Je),t(ur,Ke),t(ur,se);export{O as KIRunSchemaRepository,Ut as KIRunFunctionRepository,be as PrimitiveUtil,xt as MapUtil,Mt as MapEntry,n as isNullValue,J as LinkedList,K as StringBuilder,M as StringFormatter,v as StringUtil,_ as Tuple2,L as Tuple3,C as Tuple4,Vt as ArrayUtil,Be as deepEqual,Dt as StatementExecution,Bt as StatementMessage,x as ContextElement,kt as ContextTokenValueExtractor,Gt as OutputMapTokenValueExtractor,Ft as ArgumentsTokenValueExtractor,Yt as GraphVertex,Ht as ExecutionGraph,Kt as KIRuntime,Jt as StatementMessageType,Xt as FunctionExecutionParameters,re as Expression,pt as TokenValueExtractor,lt as LiteralTokenValueExtractor,gt as ExpressionEvaluator,te as Operation,Z as ExpressionToken,z as ExpressionEvaluationException,ee as ExpressionTokenValue,W as AbstractFunction,s as Namespaces,$t as JsonExpression,c as AdditionalPropertiesType,m as Schema,G as NumberValidator,D as BooleanValidator,k as NullValidator,B as ArrayValidator,V as AnyOfAllOfOneOfValidator,H as StringValidator,F as ObjectValidator,$ as SchemaValidator,b as SchemaValidationException,g as SchemaReferenceException,Y as TypeValidator,a as ArraySchemaType,h as SingleType,l as TypeUtil,p as MultipleType,u as Type,i as SchemaType,U as SchemaUtil,S as StringFormat,Lt as HybridRepository,zt as KIRunConstants,T as Parameter,R as FunctionOutput,Zt as Position,ar as FunctionDefinition,Wt as ParameterReferenceType,y as EventResult,er as AbstractStatement,rr as Statement,sr as StatementGroup,I as FunctionSignature,N as Event,f as ParameterType,ir as Argument,tr as ParameterReference,X as ExecutionException,w as KIRuntimeException,rt as ArithmeticUnaryMinusOperator,nt as ArithmeticUnaryPlusOperator,it as BitwiseComplementOperator,ut as LogicalNotOperator,tt as UnaryOperator,ue as ArithmeticAdditionOperator,he as ArithmeticDivisionOperator,ce as ArithmeticIntegerDivisionOperator,ge as ArithmeticModulusOperator,Ee as ArithmeticMultiplicationOperator,Ae as ArithmeticSubtractionOperator,we as ArrayOperator,ae as BinaryOperator,de as BitwiseAndOperator,ye as BitwiseLeftShiftOperator,Ie as BitwiseOrOperator,Me as BitwiseRightShiftOperator,Pe as BitwiseUnsignedRightShiftOperator,Le as BitwiseXorOperator,Ue as LogicalAndOperator,De as LogicalEqualOperator,Ge as LogicalGreaterThanEqualOperator,He as LogicalGreaterThanOperator,$e as LogicalLessThanEqualOperator,Xe as LogicalNotEqualOperator,je as LogicalLessThanOperator,Qe as LogicalOrOperator,ze as ObjectOperator,ie as LogicalNullishCoalescingOperator,mt as ConditionalTernaryOperator};
1
+ function e(e,t,r,s){Object.defineProperty(e,t,{get:r,set:s,enumerable:!0,configurable:!0})}function t(e,t){return Object.keys(t).forEach((function(r){"default"===r||"__esModule"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e}e({},"KIRunSchemaRepository",(()=>O));var r={};e(r,"AdditionalPropertiesType",(()=>c)),e(r,"Schema",(()=>m));e({},"Namespaces",(()=>s));class s{static SYSTEM="System";static SYSTEM_CTX="System.Context";static SYSTEM_LOOP="System.Loop";static SYSTEM_ARRAY="System.Array";static MATH="System.Math";static STRING="System.String";constructor(){}}e({},"ArraySchemaType",(()=>a));function n(e){return null==e}e({},"isNullValue",(()=>n));class a{constructor(e){e&&(this.singleSchema=e.singleSchema?new m(e.singleSchema):void 0,this.tupleSchema=e.tupleSchema?e.tupleSchema.map((e=>new m(e))):void 0)}setSingleSchema(e){return this.singleSchema=e,this}setTupleSchema(e){return this.tupleSchema=e,this}getSingleSchema(){return this.singleSchema}getTupleSchema(){return this.tupleSchema}isSingleType(){return!n(this.singleSchema)}static of(...e){return 1==e.length?(new a).setSingleSchema(e[0]):(new a).setTupleSchema(e)}static from(e){if(!e)return;Array.isArray(e)&&a.of(...m.fromListOfSchemas(e));let t=m.from(e);return t?a.of(t):void 0}}let i;var o;e({},"SchemaType",(()=>i)),(o=i||(i={})).INTEGER="Integer",o.LONG="Long",o.FLOAT="Float",o.DOUBLE="Double",o.STRING="String",o.OBJECT="Object",o.ARRAY="Array",o.BOOLEAN="Boolean",o.NULL="Null";e({},"TypeUtil",(()=>l));e({},"MultipleType",(()=>p));e({},"Type",(()=>u));class u{}class p extends u{constructor(e){super(),this.type=e instanceof p?new Set(Array.from(e.type)):new Set(Array.from(e))}getType(){return this.type}setType(e){return this.type=e,this}getAllowedSchemaTypes(){return this.type}contains(e){return this.type?.has(e)}}e({},"SingleType",(()=>h));class h extends u{constructor(e){super(),this.type=e instanceof h?e.type:e}getType(){return this.type}getAllowedSchemaTypes(){return new Set([this.type])}contains(e){return this.type==e}}class l{static of(...e){return 1==e.length?new h(e[0]):new p(new Set(e))}static from(e){return"string"==typeof e?new h(i[e]):Array.isArray(e)?new p(new Set(e.map((e=>e)).map((e=>i[e])))):void 0}}class c{constructor(e){e&&(this.booleanValue=e.booleanValue,e.schemaValue&&(this.schemaValue=new m(e.schemaValue)))}getBooleanValue(){return this.booleanValue}getSchemaValue(){return this.schemaValue}setBooleanValue(e){return this.booleanValue=e,this}setSchemaValue(e){return this.schemaValue=e,this}static from(e){if(!e)return;const t=new c;return t.booleanValue=e.booleanValue,t.schemaValue=e.schemaValue,t}}class m{static NULL=(new m).setNamespace(s.SYSTEM).setName("Null").setType(l.of(i.NULL)).setConstant(void 0);static TYPE_SCHEMA=(new m).setType(l.of(i.STRING)).setEnums(["INTEGER","LONG","FLOAT","DOUBLE","STRING","OBJECT","ARRAY","BOOLEAN","NULL"]);static SCHEMA=(new m).setNamespace(s.SYSTEM).setName("Schema").setType(l.of(i.OBJECT)).setProperties(new Map([["namespace",m.of("namespace",i.STRING).setDefaultValue("_")],["name",m.ofString("name")],["version",m.of("version",i.INTEGER).setDefaultValue(1)],["ref",m.ofString("ref")],["type",(new m).setAnyOf([m.TYPE_SCHEMA,m.ofArray("type",m.TYPE_SCHEMA)])],["anyOf",m.ofArray("anyOf",m.ofRef("#/"))],["allOf",m.ofArray("allOf",m.ofRef("#/"))],["oneOf",m.ofArray("oneOf",m.ofRef("#/"))],["not",m.ofRef("#/")],["title",m.ofString("title")],["description",m.ofString("description")],["id",m.ofString("id")],["examples",m.ofAny("examples")],["defaultValue",m.ofAny("defaultValue")],["comment",m.ofString("comment")],["enums",m.ofArray("enums",m.ofString("enums"))],["constant",m.ofAny("constant")],["pattern",m.ofString("pattern")],["format",m.of("format",i.STRING).setEnums(["DATETIME","TIME","DATE","EMAIL","REGEX"])],["minLength",m.ofInteger("minLength")],["maxLength",m.ofInteger("maxLength")],["multipleOf",m.ofLong("multipleOf")],["minimum",m.ofNumber("minimum")],["maximum",m.ofNumber("maximum")],["exclusiveMinimum",m.ofNumber("exclusiveMinimum")],["exclusiveMaximum",m.ofNumber("exclusiveMaximum")],["properties",m.of("properties",i.OBJECT).setAdditionalProperties((new c).setSchemaValue(m.ofRef("#/")))],["additionalProperties",(new m).setName("additionalProperty").setNamespace(s.SYSTEM).setAnyOf([m.ofBoolean("additionalProperty"),m.ofObject("additionalProperty").setRef("#/")]).setDefaultValue(!0)],["required",m.ofArray("required",m.ofString("required")).setDefaultValue([])],["propertyNames",m.ofRef("#/")],["minProperties",m.ofInteger("minProperties")],["maxProperties",m.ofInteger("maxProperties")],["patternProperties",m.of("patternProperties",i.OBJECT).setAdditionalProperties((new c).setSchemaValue(m.ofRef("#/")))],["items",(new m).setName("items").setAnyOf([m.ofRef("#/").setName("item"),m.ofArray("tuple",m.ofRef("#/"))])],["contains",m.ofRef("#/")],["minItems",m.ofInteger("minItems")],["maxItems",m.ofInteger("maxItems")],["uniqueItems",m.ofBoolean("uniqueItems")],["$defs",m.of("$defs",i.OBJECT).setAdditionalProperties((new c).setSchemaValue(m.ofRef("#/")))],["permission",m.ofString("permission")]])).setRequired([]);static ofString(e){return(new m).setType(l.of(i.STRING)).setName(e)}static ofInteger(e){return(new m).setType(l.of(i.INTEGER)).setName(e)}static ofFloat(e){return(new m).setType(l.of(i.FLOAT)).setName(e)}static ofLong(e){return(new m).setType(l.of(i.LONG)).setName(e)}static ofDouble(e){return(new m).setType(l.of(i.DOUBLE)).setName(e)}static ofAny(e){return(new m).setType(l.of(i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE,i.STRING,i.BOOLEAN,i.ARRAY,i.NULL,i.OBJECT)).setName(e)}static ofAnyNotNull(e){return(new m).setType(l.of(i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE,i.STRING,i.BOOLEAN,i.ARRAY,i.OBJECT)).setName(e)}static ofNumber(e){return(new m).setType(l.of(i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE)).setName(e)}static ofBoolean(e){return(new m).setType(l.of(i.BOOLEAN)).setName(e)}static of(e,...t){return(new m).setType(l.of(...t)).setName(e)}static ofObject(e){return(new m).setType(l.of(i.OBJECT)).setName(e)}static ofRef(e){return(new m).setRef(e)}static ofArray(e,...t){return(new m).setType(l.of(i.ARRAY)).setName(e).setItems(a.of(...t))}static fromListOfSchemas(e){if(n(e)&&!Array.isArray(e))return[];let t=[];for(let r of Array.from(e)){let e=m.from(r);e&&t.push(e)}return t}static fromMapOfSchemas(e){if(n(e))return;const t=new Map;return Object.entries(e).forEach((([e,r])=>{let s=m.from(r);s&&t.set(e,s)})),t}static from(e,t=!1){if(n(e))return;let r=new m;return r.namespace=e.namespace??"_",r.name=e.name,r.version=e.version??1,r.ref=e.ref,r.type=t?new h(i.STRING):l.from(e.type),r.anyOf=m.fromListOfSchemas(e.anyOf),r.allOf=m.fromListOfSchemas(e.allOf),r.oneOf=m.fromListOfSchemas(e.oneOf),r.not=m.from(e.not),r.description=e.description,r.examples=e.examples?[...e.examples]:void 0,r.defaultValue=e.defaultValue,r.comment=e.comment,r.enums=e.enums?[...e.enums]:void 0,r.constant=e.constant,r.pattern=e.pattern,r.format=e.format,r.minLength=e.minLength,r.maxLength=e.maxLength,r.multipleOf=e.multipleOf,r.minimum=e.minimum,r.maximum=e.maximum,r.exclusiveMinimum=e.exclusiveMinimum,r.exclusiveMaximum=e.exclusiveMaximum,r.properties=m.fromMapOfSchemas(e.properties),r.additionalProperties=c.from(e.additionalProperties),r.required=e.required,r.propertyNames=m.from(e.propertyNames,!0),r.minProperties=e.minProperties,r.maxProperties=e.maxProperties,r.patternProperties=m.fromMapOfSchemas(e.patternProperties),r.items=a.from(e.items),r.contains=m.from(e.contains),r.minItems=e.minItems,r.maxItems=e.maxItems,r.uniqueItems=e.uniqueItems,r.$defs=m.fromMapOfSchemas(e.$defs),r.permission=e.permission,r}namespace="_";version=1;constructor(e){e&&(this.namespace=e.namespace,this.name=e.name,this.version=e.version,this.ref=e.ref,this.type=e.type instanceof h?new h(e.type):new p(e.type),this.anyOf=e.anyOf?.map((e=>new m(e))),this.allOf=e.allOf?.map((e=>new m(e))),this.oneOf=e.oneOf?.map((e=>new m(e))),this.not=this.not?new m(this.not):void 0,this.description=e.description,this.examples=e.examples?JSON.parse(JSON.stringify(e.examples)):void 0,this.defaultValue=e.defaultValue?JSON.parse(JSON.stringify(e.defaultValue)):void 0,this.comment=e.comment,this.enums=e.enums?[...e.enums]:void 0,this.constant=e.constant?JSON.parse(JSON.stringify(e.constant)):void 0,this.pattern=e.pattern,this.format=e.format,this.minLength=e.minLength,this.maxLength=e.maxLength,this.multipleOf=e.multipleOf,this.minimum=e.minimum,this.maximum=e.maximum,this.exclusiveMinimum=e.exclusiveMinimum,this.exclusiveMaximum=e.exclusiveMaximum,this.properties=e.properties?new Map(Array.from(e.properties.entries()).map((e=>[e[0],new m(e[1])]))):void 0,this.additionalProperties=e.additionalProperties?new c(e.additionalProperties):void 0,this.required=e.required?[...e.required]:void 0,this.propertyNames=e.propertyNames?new m(e.propertyNames):void 0,this.minProperties=e.minProperties,this.maxProperties=e.maxProperties,this.patternProperties=e.patternProperties?new Map(Array.from(e.patternProperties.entries()).map((e=>[e[0],new m(e[1])]))):void 0,this.items=e.items?new a(e.items):void 0,this.contains=e.contains?new m(this.contains):void 0,this.minItems=e.minItems,this.maxItems=e.maxItems,this.uniqueItems=e.uniqueItems,this.$defs=e.$defs?new Map(Array.from(e.$defs.entries()).map((e=>[e[0],new m(e[1])]))):void 0,this.permission=e.permission)}getTitle(){return this.getFullName()}getFullName(){return this.namespace&&"_"!=this.namespace?this.namespace+"."+this.name:this.name}get$defs(){return this.$defs}set$defs(e){return this.$defs=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getVersion(){return this.version}setVersion(e){return this.version=e,this}getRef(){return this.ref}setRef(e){return this.ref=e,this}getType(){return this.type}setType(e){return this.type=e,this}getAnyOf(){return this.anyOf}setAnyOf(e){return this.anyOf=e,this}getAllOf(){return this.allOf}setAllOf(e){return this.allOf=e,this}getOneOf(){return this.oneOf}setOneOf(e){return this.oneOf=e,this}getNot(){return this.not}setNot(e){return this.not=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getExamples(){return this.examples}setExamples(e){return this.examples=e,this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}getComment(){return this.comment}setComment(e){return this.comment=e,this}getEnums(){return this.enums}setEnums(e){return this.enums=e,this}getConstant(){return this.constant}setConstant(e){return this.constant=e,this}getPattern(){return this.pattern}setPattern(e){return this.pattern=e,this}getFormat(){return this.format}setFormat(e){return this.format=e,this}getMinLength(){return this.minLength}setMinLength(e){return this.minLength=e,this}getMaxLength(){return this.maxLength}setMaxLength(e){return this.maxLength=e,this}getMultipleOf(){return this.multipleOf}setMultipleOf(e){return this.multipleOf=e,this}getMinimum(){return this.minimum}setMinimum(e){return this.minimum=e,this}getMaximum(){return this.maximum}setMaximum(e){return this.maximum=e,this}getExclusiveMinimum(){return this.exclusiveMinimum}setExclusiveMinimum(e){return this.exclusiveMinimum=e,this}getExclusiveMaximum(){return this.exclusiveMaximum}setExclusiveMaximum(e){return this.exclusiveMaximum=e,this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}getAdditionalProperties(){return this.additionalProperties}setAdditionalProperties(e){return this.additionalProperties=e,this}getRequired(){return this.required}setRequired(e){return this.required=e,this}getPropertyNames(){return this.propertyNames}setPropertyNames(e){return this.propertyNames=e,this.propertyNames.type=new h(i.STRING),this}getMinProperties(){return this.minProperties}setMinProperties(e){return this.minProperties=e,this}getMaxProperties(){return this.maxProperties}setMaxProperties(e){return this.maxProperties=e,this}getPatternProperties(){return this.patternProperties}setPatternProperties(e){return this.patternProperties=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}getContains(){return this.contains}setContains(e){return this.contains=e,this}getMinItems(){return this.minItems}setMinItems(e){return this.minItems=e,this}getMaxItems(){return this.maxItems}setMaxItems(e){return this.maxItems=e,this}getUniqueItems(){return this.uniqueItems}setUniqueItems(e){return this.uniqueItems=e,this}getPermission(){return this.permission}setPermission(e){return this.permission=e,this}}e({},"Parameter",(()=>T));e({},"SchemaReferenceException",(()=>g));class g extends Error{constructor(e,t,r){super(e.trim()?e+"-"+t:t),this.schemaPath=e,this.cause=r}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}let f;var E;e({},"ParameterType",(()=>f)),(E=f||(f={})).CONSTANT="CONSTANT",E.EXPRESSION="EXPRESSION";class T{static SCHEMA_NAME="Parameter";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(T.SCHEMA_NAME).setProperties(new Map([["schema",m.SCHEMA],["parameterName",m.ofString("parameterName")],["variableArgument",m.of("variableArgument",i.BOOLEAN).setDefaultValue(!1)],["type",m.ofString("type").setEnums(["EXPRESSION","CONSTANT"])]]));static EXPRESSION=(new m).setNamespace(s.SYSTEM).setName("ParameterExpression").setType(l.of(i.OBJECT)).setProperties(new Map([["isExpression",m.ofBoolean("isExpression").setDefaultValue(!0)],["value",m.ofAny("value")]]));variableArgument=!1;type=f.EXPRESSION;constructor(e,t){if(e instanceof T)this.schema=new m(e.schema),this.parameterName=e.parameterName,this.variableArgument=e.variableArgument,this.type=e.type;else{if(!t)throw new Error("Unknown constructor signature");this.schema=t,this.parameterName=e}}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getParameterName(){return this.parameterName}setParameterName(e){return this.parameterName=e,this}isVariableArgument(){return this.variableArgument}setVariableArgument(e){return this.variableArgument=e,this}getType(){return this.type}setType(e){return this.type=e,this}static ofEntry(e,t,r=!1,s=f.EXPRESSION){return[e,new T(e,t).setType(s).setVariableArgument(r)]}static of(e,t,r=!1,s=f.EXPRESSION){return new T(e,t).setType(s).setVariableArgument(r)}static from(e){const t=m.from(e.schema);if(!t)throw new g("","Parameter requires Schema");return new T(e.parameterName,t).setVariableArgument(!!e.variableArguments).setType(e.type??f.EXPRESSION)}}const A=new Map([["any",m.ofAny("any").setNamespace(s.SYSTEM)],["boolean",m.ofBoolean("boolean").setNamespace(s.SYSTEM)],["double",m.ofDouble("double").setNamespace(s.SYSTEM)],["float",m.ofFloat("float").setNamespace(s.SYSTEM)],["integer",m.ofInteger("integer").setNamespace(s.SYSTEM)],["long",m.ofLong("long").setNamespace(s.SYSTEM)],["number",m.ofNumber("number").setNamespace(s.SYSTEM)],["string",m.ofString("string").setNamespace(s.SYSTEM)],[T.EXPRESSION.getName(),T.EXPRESSION]]);class O{find(e,t){if(s.SYSTEM==e)return A.get(t)}}e({},"KIRunFunctionRepository",(()=>Ut));e({},"KIRuntimeException",(()=>w));class w extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}let S;var d;e({},"StringFormat",(()=>S)),(d=S||(S={})).DATETIME="DATETIME",d.TIME="TIME",d.DATE="DATE",d.EMAIL="EMAIL",d.REGEX="REGEX";e({},"Event",(()=>N));class N{static OUTPUT="output";static ERROR="error";static ITERATION="iteration";static TRUE="true";static FALSE="false";static SCHEMA_NAME="Event";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(N.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["name",m.ofString("name")],["parameters",m.ofObject("parameter").setAdditionalProperties((new c).setSchemaValue(m.SCHEMA))]]));constructor(e,t){if(e instanceof N)this.name=e.name,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new m(e[1])])));else{if(this.name=e,!t)throw new Error("Unknown constructor format");this.parameters=t}}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}static outputEventMapEntry(e){return N.eventMapEntry(N.OUTPUT,e)}static eventMapEntry(e,t){return[e,new N(e,t)]}static from(e){return new N(e.name,new Map(Object.entries(e.parameters??{}).map((e=>{const t=m.from(e[1]);if(!t)throw new g("","Event expects a schema");return[e[0],t]}))))}}e({},"EventResult",(()=>R));class R{constructor(e,t){this.name=e,this.result=t}getName(){return this.name}setName(e){return this.name=e,this}getResult(){return this.result}setResult(e){return this.result=e,this}static outputOf(e){return R.of(N.OUTPUT,e)}static of(e,t){return new R(e,t)}}e({},"FunctionOutput",(()=>y));class y{index=0;constructor(e){if(n(e))throw new w("Function output is generating null");Array.isArray(e)&&e.length&&e[0]instanceof R?this.fo=e:(this.fo=[],this.generator=e)}next(){if(!this.generator)return this.index<this.fo.length?this.fo[this.index++]:void 0;const e=this.generator.next();return e&&this.fo.push(e),e}allResults(){return this.fo}}e({},"FunctionSignature",(()=>I));class I{static SCHEMA_NAME="FunctionSignature";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(I.SCHEMA_NAME).setProperties(new Map([["name",m.ofString("name")],["namespace",m.ofString("namespace")],["parameters",m.ofObject("parameters").setAdditionalProperties((new c).setSchemaValue(T.SCHEMA))],["events",m.ofObject("events").setAdditionalProperties((new c).setSchemaValue(N.SCHEMA))]]));namespace="_";parameters=new Map;events=new Map;constructor(e){e instanceof I?(this.name=e.name,this.namespace=e.namespace,this.parameters=new Map(Array.from(e.parameters.entries()).map((e=>[e[0],new T(e[1])]))),this.events=new Map(Array.from(e.events.entries()).map((e=>[e[0],new N(e[1])])))):this.name=e}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameters(){return this.parameters}setParameters(e){return this.parameters=e,this}getEvents(){return this.events}setEvents(e){return this.events=e,this}}e({},"ContextElement",(()=>x));class x{static NULL=new x(m.NULL,void 0);constructor(e,t){this.schema=e,this.element=t}getSchema(){return this.schema}setSchema(e){return this.schema=e,this}getElement(){return this.element}setElement(e){return this.element=e,this}}e({},"StringFormatter",(()=>M));class M{static format(e,...t){if(!t||0==t.length)return e;let r="",s=0,n="",a=n,i=e.length;for(let o=0;o<i;o++)n=e.charAt(o),"$"==n&&"\\"==a?r=r.substring(0,o-1)+n:"$"==n&&s<t.length?r+=t[s++]:r+=n,a=n;return r.toString()}constructor(){}}e({},"AbstractFunction",(()=>W));e({},"SchemaValidator",(()=>$));e({},"StringUtil",(()=>v));class v{constructor(){}static nthIndex(e,t,r=0,s){if(!e)throw new w("String cannot be null");if(r<0||r>=e.length)throw new w(M.format("Cannot search from index : $",r));if(s<=0||s>e.length)throw new w(M.format("Cannot search for occurance : $",s));for(;r<e.length;){if(e.charAt(r)==t&&0==--s)return r;++r}return-1}static splitAtFirstOccurance(e,t){if(!e)return[void 0,void 0];let r=e.indexOf(t);return-1==r?[e,void 0]:[e.substring(0,r),e.substring(r+1)]}static isNullOrBlank(e){return!e||""==e.trim()}}e({},"SchemaUtil",(()=>V));var P={};e(P,"Tuple2",(()=>_)),e(P,"Tuple3",(()=>L)),e(P,"Tuple4",(()=>C));class _{constructor(e,t){this.f=e,this.s=t}getT1(){return this.f}getT2(){return this.s}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}}class L extends _{constructor(e,t,r){super(e,t),this.t=r}getT3(){return this.t}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}}class C extends L{constructor(e,t,r,s){super(e,t,r),this.fr=s}getT4(){return this.fr}setT1(e){return this.f=e,this}setT2(e){return this.s=e,this}setT3(e){return this.t=e,this}setT4(e){return this.fr=e,this}}e({},"SchemaValidationException",(()=>b));class b extends Error{constructor(e,t,r=[],s){super(t+(r?r.map((e=>e.message)).reduce(((e,t)=>e+"\n"+t),""):"")),this.schemaPath=e,this.cause=s}getSchemaPath(){return this.schemaPath}getCause(){return this.cause}}class V{static UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH="Unable to retrive schema from referenced path";static CYCLIC_REFERENCE_LIMIT_COUNTER=20;static getDefaultValue(e,t){if(e)return e.getConstant()?e.getConstant():e.getDefaultValue()?e.getDefaultValue():V.getDefaultValue(V.getSchemaFromRef(e,t,e.getRef()),t)}static getSchemaFromRef(e,t,r,s=0){if(++s==V.CYCLIC_REFERENCE_LIMIT_COUNTER)throw new b(r??"","Schema has a cyclic reference");if(!e||!r||v.isNullOrBlank(r))return;if(!r.startsWith("#")){var n=V.resolveExternalSchema(e,t,r);n&&(e=n.getT1(),r=n.getT2())}let a=r.split("/");return 1===a.length?e:V.resolveInternalSchema(e,t,r,s,a,1)}static resolveInternalSchema(e,t,r,s,n,a){let o=e;if(a!==n.length){for(;a<n.length;){if("$defs"===n[a]){if(++a>=n.length||!o.get$defs())throw new g(r,V.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);o=o.get$defs()?.get(n[a])}else{if(o&&(!o.getType()?.contains(i.OBJECT)||!o.getProperties()))throw new g(r,"Cannot retrievie schema from non Object type schemas");o=o.getProperties()?.get(n[a])}if(a++,!o)throw new g(r,V.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);if(!v.isNullOrBlank(o.getRef())&&(o=V.getSchemaFromRef(o,t,o.getRef(),s),!o))throw new g(r,V.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH)}return o}}static resolveExternalSchema(e,t,r){if(!t)return;let s=v.splitAtFirstOccurance(r??"","/");if(!s[0])return;let n=v.splitAtFirstOccurance(s[0],".");if(!n[0]||!n[1])return;let a=t.find(n[0],n[1]);if(a){if(!s[1]||""===s[1])return new _(a,r);if(r="#/"+s[1],!a)throw new g(r,V.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH);return new _(a,r)}}constructor(){}}e({},"AnyOfAllOfOneOfValidator",(()=>U));class U{static validate(e,t,r,s){let n=[];return t.getOneOf()&&!t.getOneOf()?U.oneOf(e,t,r,s,n):t.getAllOf()&&!t.getAllOf()?U.allOf(e,t,r,s,n):t.getAnyOf()&&!t.getAnyOf()&&U.anyOf(e,t,r,s,n),s}static anyOf(e,t,r,s,n){let a=!1;for(let i of t.getAnyOf()??[])try{U.validate(e,i,r,s),a=!0;break}catch(e){a=!1,n.push(e)}if(!a)throw new b($.path(e),"The value don't satisfy any of the schemas.",n)}static allOf(e,t,r,s,n){let a=0;for(let i of t.getAllOf()??[])try{U.validate(e,i,r,s),a++}catch(e){n.push(e)}if(a!==t.getAllOf()?.length)throw new b($.path(e),"The value doesn't satisfy some of the schemas.",n)}static oneOf(e,t,r,s,n){let a=0;for(let i of t.getOneOf()??[])try{U.validate(e,i,r,s),a++}catch(e){n.push(e)}if(1!=a)throw new b($.path(e),0==a?"The value does not satisfy any schema":"The value satisfy more than one schema",n)}constructor(){}}e({},"TypeValidator",(()=>Y));e({},"ArrayValidator",(()=>B));class B{static validate(e,t,r,s){if(n(s))throw new b($.path(e),"Expected an array but found null");if(!Array.isArray(s))throw new b($.path(e),s.toString()+" is not an Array");let a=s;return B.checkMinMaxItems(e,t,a),B.checkItems(e,t,r,a),B.checkUniqueItems(e,t,a),B.checkContains(e,t,r,a),s}static checkContains(e,t,r,s){if(!t.getContains())return;let n=!1;for(let a=0;a<s.length;a++){let i=e?[...e]:[];try{$.validate(i,t.getContains(),r,s[a]),n=!0;break}catch(e){n=!1}}if(!n)throw new b($.path(e),"None of the items are of type contains schema")}static checkUniqueItems(e,t,r){if(t.getUniqueItems()&&t.getUniqueItems()){if(new Set(r).size!==r.length)throw new b($.path(e),"Items on the array are not unique")}}static checkMinMaxItems(e,t,r){if(t.getMinItems()&&t.getMinItems()>r.length)throw new b($.path(e),"Array should have minimum of "+t.getMinItems()+" elements");if(t.getMaxItems()&&t.getMaxItems()<r.length)throw new b($.path(e),"Array can have maximum of "+t.getMaxItems()+" elements")}static checkItems(e,t,r,s){if(!t.getItems())return;let n=t.getItems();if(n.getSingleSchema())for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=$.validate(a,n.getSingleSchema(),r,s[t]);s[t]=i}if(n.getTupleSchema()){if(n.getTupleSchema().length!==s.length)throw new b($.path(e),"Expected an array with only "+n.getTupleSchema().length+" but found "+s.length);for(let t=0;t<s.length;t++){let a=e?[...e]:[],i=$.validate(a,n.getTupleSchema()[t],r,s[t]);s[t]=i}}}constructor(){}}e({},"BooleanValidator",(()=>D));class D{static validate(e,t,r){if(n(r))throw new b($.path(e),"Expected a boolean but found null");if("boolean"!=typeof r)throw new b($.path(e),r.toString()+" is not a boolean");return r}constructor(){}}e({},"NullValidator",(()=>k));class k{static validate(e,t,r){if(r)throw new b($.path(e),"Expected a null but found "+r);return r}constructor(){}}e({},"NumberValidator",(()=>G));class G{static validate(e,t,r,s){if(n(s))throw new b($.path(t),"Expected a number but found null");if("number"!=typeof s)throw new b($.path(t),s.toString()+" is not a "+e);let a=G.extractNumber(e,t,r,s);return G.checkRange(t,r,s,a),G.checkMultipleOf(t,r,s,a),s}static extractNumber(e,t,r,s){let a=s;try{e!=i.LONG&&e!=i.INTEGER||(a=Math.round(a))}catch(r){throw new b($.path(t),s+" is not a number of type "+e,r)}if(n(a)||(e==i.LONG||e==i.INTEGER)&&a!=s)throw new b($.path(t),s.toString()+" is not a number of type "+e);return a}static checkMultipleOf(e,t,r,s){if(t.getMultipleOf()){if(s%t.getMultipleOf()!=0)throw new b($.path(e),r.toString()+" is not multiple of "+t.getMultipleOf())}}static checkRange(e,t,r,s){if(t.getMinimum()&&G.numberCompare(s,t.getMinimum())<0)throw new b($.path(e),r.toString()+" should be greater than or equal to "+t.getMinimum());if(t.getMaximum()&&G.numberCompare(s,t.getMaximum())>0)throw new b($.path(e),r.toString()+" should be less than or equal to "+t.getMaximum());if(t.getExclusiveMinimum()&&G.numberCompare(s,t.getExclusiveMinimum())<=0)throw new b($.path(e),r.toString()+" should be greater than "+t.getExclusiveMinimum());if(t.getExclusiveMaximum()&&G.numberCompare(s,t.getExclusiveMaximum())>0)throw new b($.path(e),r.toString()+" should be less than "+t.getExclusiveMaximum())}static numberCompare(e,t){return e-t}constructor(){}}e({},"ObjectValidator",(()=>F));class F{static validate(e,t,r,s){if(n(s))throw new b($.path(e),"Expected an object but found null");if("object"!=typeof s||Array.isArray(s))throw new b($.path(e),s.toString()+" is not an Object");let a=s,i=new Set(Object.keys(a));F.checkMinMaxProperties(e,t,i),t.getPropertyNames()&&F.checkPropertyNameSchema(e,t,r,i),t.getRequired()&&F.checkRequired(e,t,a),t.getProperties()&&F.checkProperties(e,t,r,a,i),t.getPatternProperties()&&F.checkPatternProperties(e,t,r,a,i),t.getAdditionalProperties()&&F.checkAddtionalProperties(e,t,r,a,i)}static checkPropertyNameSchema(e,t,r,s){for(let n of Array.from(s.values()))try{$.validate(e,t.getPropertyNames(),r,n)}catch(t){throw new b($.path(e),"Property name '"+n+"' does not fit the property schema")}}static checkRequired(e,t,r){for(const s of t.getRequired()??[])if(n(r[s]))throw new b($.path(e),s+" is mandatory")}static checkAddtionalProperties(e,t,r,s,n){let a=t.getAdditionalProperties();if(a.getSchemaValue())for(let t of Array.from(n.values())){let n=e?[...e]:[],i=$.validate(n,a.getSchemaValue(),r,s[t]);s[t]=i}else if(!1===a.getBooleanValue()&&n.size)throw new b($.path(e),n.toString()+" are additional properties which are not allowed.")}static checkPatternProperties(e,t,r,s,n){const a=new Map;for(const e of Array.from(t.getPatternProperties().keys()))a.set(e,new RegExp(e));for(const i of Array.from(n.values())){const o=e?[...e]:[];for(const e of Array.from(a.entries()))if(e[1].test(i)){const a=$.validate(o,t.getPatternProperties().get(e[0]),r,s[i]);s[i]=a,n.delete(i);break}}}static checkProperties(e,t,r,s,a){for(const i of Array.from(t.getProperties())){let t=s[i[0]];if(n(t))continue;let o=e?[...e]:[],u=$.validate(o,i[1],r,t);s[i[0]]=u,a.delete(i[0])}}static checkMinMaxProperties(e,t,r){if(t.getMinProperties()&&r.size<t.getMinProperties())throw new b($.path(e),"Object should have minimum of "+t.getMinProperties()+" properties");if(t.getMaxProperties()&&r.size>t.getMaxProperties())throw new b($.path(e),"Object can have maximum of "+t.getMaxProperties()+" properties")}constructor(){}}e({},"StringValidator",(()=>H));class H{static TIME=/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static DATE=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])$/;static DATETIME=/^[0-9]{4,4}-([0][0-9]|[1][0-2])-(0[1-9]|[1-2][1-9]|3[01])T([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?([+-][01][0-9]:[0-5][0-9])?$/;static validate(e,t,r){if(n(r))throw new b($.path(e),"Expected a string but found "+r);if("string"!=typeof r)throw new b($.path(e),r.toString()+" is not String");t.getFormat()==S.TIME?H.patternMatcher(e,t,r,H.TIME,"time pattern"):t.getFormat()==S.DATE?H.patternMatcher(e,t,r,H.DATE,"date pattern"):t.getFormat()==S.DATETIME?H.patternMatcher(e,t,r,H.DATETIME,"date time pattern"):t.getPattern()&&H.patternMatcher(e,t,r,new RegExp(t.getPattern()),"pattern "+t.getPattern());let s=r.length;if(t.getMinLength()&&s<t.getMinLength())throw new b($.path(e),"Expected a minimum of "+t.getMinLength()+" characters");if(t.getMaxLength()&&s>t.getMinLength())throw new b($.path(e),"Expected a maximum of "+t.getMaxLength()+" characters");return r}static patternMatcher(e,t,r,s,n){if(!s.test(r))throw new b($.path(e),r.toString()+" is not matched with the "+n)}constructor(){}}class Y{static validate(e,t,r,s,n){if(t==i.STRING)H.validate(e,r,n);else if(t==i.LONG||t==i.INTEGER||t==i.DOUBLE||t==i.FLOAT)G.validate(t,e,r,n);else if(t==i.BOOLEAN)D.validate(e,r,n);else if(t==i.OBJECT)F.validate(e,r,s,n);else if(t==i.ARRAY)B.validate(e,r,s,n);else{if(t!=i.NULL)throw new b($.path(e),t+" is not a valid type.");k.validate(e,r,n)}return n}constructor(){}}class ${static path(e){return e?e.map((e=>e.getTitle()??"")).filter((e=>!!e)).reduce(((e,t,r)=>e+(0===r?"":".")+t),""):""}static validate(e,t,r,s){if(!t)throw new b($.path(e),"No schema found to validate");if(e||(e=new Array),e.push(t),n(s)&&!n(t.getDefaultValue()))return JSON.parse(JSON.stringify(t.getDefaultValue()));if(t.getConstant())return $.constantValidation(e,t,s);if(t.getEnums()&&!t.getEnums()?.length)return $.enumCheck(e,t,s);if(t.getType()&&$.typeValidation(e,t,r,s),!v.isNullOrBlank(t.getRef()))return $.validate(e,V.getSchemaFromRef(e[0],r,t.getRef()),r,s);if((t.getOneOf()||t.getAllOf()||t.getAnyOf())&&U.validate(e,t,r,s),t.getNot()){let n=!1;try{$.validate(e,t.getNot(),r,s),n=!0}catch(e){n=!1}if(n)throw new b($.path(e),"Schema validated value in not condition.")}return s}static constantValidation(e,t,r){if(!t.getConstant().equals(r))throw new b($.path(e),"Expecting a constant value : "+r);return r}static enumCheck(e,t,r){let s=!1;for(let e of t.getEnums()??[])if(e===r){s=!0;break}if(s)return r;throw new b($.path(e),"Value is not one of "+t.getEnums())}static typeValidation(e,t,r,s){let n=!1,a=[];for(const i of Array.from(t.getType()?.getAllowedSchemaTypes()?.values()??[]))try{Y.validate(e,i,t,r,s),n=!0;break}catch(e){n=!1,a.push(e)}if(!n)throw new b($.path(e),"Value "+JSON.stringify(s)+" is not of valid type(s)",a)}constructor(){}}class W{validateArguments(e,t,r){return Array.from(this.getSignature().getParameters().entries()).map((s=>{let n=s[1];try{return this.validateArgument(e,t,s,n)}catch(e){const t=this.getSignature();throw new w(`Error while executing the function ${t.getNamespace()}.${t.getName()}'s parameter ${n.getParameterName()} with step name '${r?.getStatement().getStatementName()??"Unknown Step"}' with error : ${e?.message}`)}})).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}validateArgument(e,t,r,s){let a,i=r[0],o=e.get(r[0]);if(n(o)&&!s.isVariableArgument())return new _(i,$.validate(void 0,s.getSchema(),t,void 0));if(!s?.isVariableArgument())return new _(i,$.validate(void 0,s.getSchema(),t,o));Array.isArray(o)?a=o:(a=[],n(o)?n(s.getSchema().getDefaultValue())||a.push(s.getSchema().getDefaultValue()):a.push(o));for(let e=0;e<a.length;e++)a[e]=$.validate(void 0,s.getSchema(),t,a[e]);return new _(i,a)}async execute(e){e.setArguments(this.validateArguments(e.getArguments()??new Map,e.getSchemaRepository(),e.getStatementExecution()));try{return this.internalExecute(e)}catch(t){const r=this.getSignature();throw new w(`Error while executing the function ${r.getNamespace()}.${r.getName()} with step name '${e.getStatementExecution()?.getStatement().getStatementName()??"Unknown Step"}' with error : ${t?.message}`)}}getProbableEventSignature(e){return this.getSignature().getEvents()}}const j=new I("Create").setNamespace(s.SYSTEM_CTX).setParameters(new Map([T.ofEntry("name",(new m).setName("name").setType(l.of(i.STRING)).setMinLength(1).setFormat(S.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,f.CONSTANT),T.ofEntry("schema",m.SCHEMA,!1,f.CONSTANT)])).setEvents(new Map([N.outputEventMapEntry(new Map)]));const q=new I("Get").setNamespace(s.SYSTEM_CTX).setParameters(new Map([T.ofEntry("name",(new m).setName("name").setType(l.of(i.STRING)).setMinLength(1).setFormat(S.REGEX).setPattern("^[a-zA-Z_$][a-zA-Z_$0-9]*$"),!1,f.CONSTANT)])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofAny("value")]]))]));e({},"ExecutionException",(()=>X));class X extends Error{constructor(e,t){super(e),this.cause=t}getCause(){return this.cause}}e({},"Expression",(()=>re));e({},"LinkedList",(()=>J));class J{head=void 0;tail=void 0;length=0;constructor(e){if(e?.length){for(const t of e)if(this.head){const e=new Q(t,this.tail);this.tail.next=e,this.tail=e}else this.tail=this.head=new Q(t);this.length=e.length}}push(e){const t=new Q(e,void 0,this.head);this.head?(this.head.previous=t,this.head=t):this.tail=this.head=t,this.length++}pop(){if(!this.head)throw Error("List is empty and cannot pop further.");const e=this.head.value;if(this.length--,this.head==this.tail)return this.head=this.tail=void 0,e;const t=this.head;return this.head=t.next,t.next=void 0,t.previous=void 0,this.head.previous=void 0,e}isEmpty(){return!this.length}size(){return this.length}get(e){if(e<0||e>=this.length)throw new Error(`${e} is out of bounds [0,${this.length}]`);let t=this.head;for(;e>0;)t=this.head.next,--e;return t.value}set(e,t){if(e<0||e>=this.length)throw new w(M.format("Index $ out of bound to set the value in linked list.",e));let r=this.head;for(;e>0;)r=this.head.next,--e;return r.value=t,this}toString(){let e=this.head,t="";for(;e;)t+=e.value,e=e.next,e&&(t+=", ");return`[${t}]`}toArray(){let e=[],t=this.head;for(;t;)e.push(t.value),t=t.next;return e}peek(){if(!this.head)throw new Error("List is empty so cannot peak");return this.head.value}peekLast(){if(!this.tail)throw new Error("List is empty so cannot peak");return this.tail.value}getFirst(){if(!this.head)throw new Error("List is empty so cannot get first");return this.head.value}removeFirst(){return this.pop()}removeLast(){if(!this.tail)throw new Error("List is empty so cannot remove");--this.length;const e=this.tail.value;if(0==this.length)this.head=this.tail=void 0;else{const e=this.tail.previous;e.next=void 0,this.tail.previous=void 0,this.tail=e}return e}addAll(e){return e&&e.length?(e.forEach(this.add.bind(this)),this):this}add(e){return++this.length,this.tail||this.head?this.head===this.tail?(this.tail=new Q(e,this.head),this.head.next=this.tail):(this.tail=new Q(e,this.tail),this.tail.previous.next=this.tail):this.head=this.tail=new Q(e),this}map(e,t){let r=new J,s=this.head,n=0;for(;s;)r.add(e(s.value,n)),s=s.next,++n;return r}forEach(e,t){let r=this.head,s=0;for(;r;)e(r.value,s),r=r.next,++s}}class Q{constructor(e,t,r){this.value=e,this.next=r,this.previous=t}toString(){return""+this.value}}e({},"StringBuilder",(()=>K));class K{constructor(e){this.str=e??""}append(e){return this.str+=e,this}toString(){return""+this.str}trim(){return this.str=this.str.trim(),this}setLength(e){return this.str=this.str.substring(0,e),this}length(){return this.str.length}charAt(e){return this.str.charAt(e)}deleteCharAt(e){return this.checkIndex(e),this.str=this.str.substring(0,e)+this.str.substring(e+1),this}insert(e,t){return this.str=this.str.substring(0,e)+t+this.str.substring(e),this}checkIndex(e){if(e>=this.str.length)throw new w(`Index ${e} is greater than or equal to ${this.str.length}`)}substring(e,t){return this.str.substring(e,t)}}e({},"ExpressionEvaluationException",(()=>z));class z extends Error{constructor(e,t,r){super(M.format("$ : $",e,t)),this.cause=r}getCause(){return this.cause}}e({},"ExpressionToken",(()=>Z));class Z{constructor(e){this.expression=e}getExpression(){return this.expression}toString(){return this.expression}}e({},"ExpressionTokenValue",(()=>ee));class ee extends Z{constructor(e,t){super(e),this.element=t}getTokenValue(){return this.element}getElement(){return this.element}toString(){return M.format("$: $",this.expression,this.element)}}e({},"Operation",(()=>te));class te{static MULTIPLICATION=new te("*");static DIVISION=new te("/");static INTEGER_DIVISION=new te("//");static MOD=new te("%");static ADDITION=new te("+");static SUBTRACTION=new te("-");static NOT=new te("not",void 0,!0);static AND=new te("and",void 0,!0);static OR=new te("or",void 0,!0);static LESS_THAN=new te("<");static LESS_THAN_EQUAL=new te("<=");static GREATER_THAN=new te(">");static GREATER_THAN_EQUAL=new te(">=");static EQUAL=new te("=");static NOT_EQUAL=new te("!=");static BITWISE_AND=new te("&");static BITWISE_OR=new te("|");static BITWISE_XOR=new te("^");static BITWISE_COMPLEMENT=new te("~");static BITWISE_LEFT_SHIFT=new te("<<");static BITWISE_RIGHT_SHIFT=new te(">>");static BITWISE_UNSIGNED_RIGHT_SHIFT=new te(">>>");static UNARY_PLUS=new te("UN: +","+");static UNARY_MINUS=new te("UN: -","-");static UNARY_LOGICAL_NOT=new te("UN: not","not");static UNARY_BITWISE_COMPLEMENT=new te("UN: ~","~");static ARRAY_OPERATOR=new te("[");static OBJECT_OPERATOR=new te(".");static NULLISH_COALESCING_OPERATOR=new te("??");static CONDITIONAL_TERNARY_OPERATOR=new te("?");static VALUE_OF=new Map([["MULTIPLICATION",te.MULTIPLICATION],["DIVISION",te.DIVISION],["INTEGER_DIVISON",te.INTEGER_DIVISION],["MOD",te.MOD],["ADDITION",te.ADDITION],["SUBTRACTION",te.SUBTRACTION],["NOT",te.NOT],["AND",te.AND],["OR",te.OR],["LESS_THAN",te.LESS_THAN],["LESS_THAN_EQUAL",te.LESS_THAN_EQUAL],["GREATER_THAN",te.GREATER_THAN],["GREATER_THAN_EQUAL",te.GREATER_THAN_EQUAL],["EQUAL",te.EQUAL],["NOT_EQUAL",te.NOT_EQUAL],["BITWISE_AND",te.BITWISE_AND],["BITWISE_OR",te.BITWISE_OR],["BITWISE_XOR",te.BITWISE_XOR],["BITWISE_COMPLEMENT",te.BITWISE_COMPLEMENT],["BITWISE_LEFT_SHIFT",te.BITWISE_LEFT_SHIFT],["BITWISE_RIGHT_SHIFT",te.BITWISE_RIGHT_SHIFT],["BITWISE_UNSIGNED_RIGHT_SHIFT",te.BITWISE_UNSIGNED_RIGHT_SHIFT],["UNARY_PLUS",te.UNARY_PLUS],["UNARY_MINUS",te.UNARY_MINUS],["UNARY_LOGICAL_NOT",te.UNARY_LOGICAL_NOT],["UNARY_BITWISE_COMPLEMENT",te.UNARY_BITWISE_COMPLEMENT],["ARRAY_OPERATOR",te.ARRAY_OPERATOR],["OBJECT_OPERATOR",te.OBJECT_OPERATOR],["NULLISH_COALESCING_OPERATOR",te.NULLISH_COALESCING_OPERATOR],["CONDITIONAL_TERNARY_OPERATOR",te.CONDITIONAL_TERNARY_OPERATOR]]);static UNARY_OPERATORS=new Set([te.ADDITION,te.SUBTRACTION,te.NOT,te.BITWISE_COMPLEMENT,te.UNARY_PLUS,te.UNARY_MINUS,te.UNARY_LOGICAL_NOT,te.UNARY_BITWISE_COMPLEMENT]);static ARITHMETIC_OPERATORS=new Set([te.MULTIPLICATION,te.DIVISION,te.INTEGER_DIVISION,te.MOD,te.ADDITION,te.SUBTRACTION]);static LOGICAL_OPERATORS=new Set([te.NOT,te.AND,te.OR,te.LESS_THAN,te.LESS_THAN_EQUAL,te.GREATER_THAN,te.GREATER_THAN_EQUAL,te.EQUAL,te.NOT_EQUAL,te.NULLISH_COALESCING_OPERATOR]);static BITWISE_OPERATORS=new Set([te.BITWISE_AND,te.BITWISE_COMPLEMENT,te.BITWISE_LEFT_SHIFT,te.BITWISE_OR,te.BITWISE_RIGHT_SHIFT,te.BITWISE_UNSIGNED_RIGHT_SHIFT,te.BITWISE_XOR]);static CONDITIONAL_OPERATORS=new Set([te.CONDITIONAL_TERNARY_OPERATOR]);static OPERATOR_PRIORITY=new Map([[te.UNARY_PLUS,1],[te.UNARY_MINUS,1],[te.UNARY_LOGICAL_NOT,1],[te.UNARY_BITWISE_COMPLEMENT,1],[te.ARRAY_OPERATOR,1],[te.OBJECT_OPERATOR,1],[te.MULTIPLICATION,2],[te.DIVISION,2],[te.INTEGER_DIVISION,2],[te.MOD,2],[te.ADDITION,3],[te.SUBTRACTION,3],[te.BITWISE_LEFT_SHIFT,4],[te.BITWISE_RIGHT_SHIFT,4],[te.BITWISE_UNSIGNED_RIGHT_SHIFT,4],[te.LESS_THAN,5],[te.LESS_THAN_EQUAL,5],[te.GREATER_THAN,5],[te.GREATER_THAN_EQUAL,5],[te.EQUAL,6],[te.NOT_EQUAL,6],[te.BITWISE_AND,7],[te.BITWISE_XOR,8],[te.BITWISE_OR,9],[te.AND,10],[te.OR,11],[te.NULLISH_COALESCING_OPERATOR,11],[te.CONDITIONAL_TERNARY_OPERATOR,12]]);static OPERATORS=new Set([...Array.from(te.ARITHMETIC_OPERATORS),...Array.from(te.LOGICAL_OPERATORS),...Array.from(te.BITWISE_OPERATORS),te.ARRAY_OPERATOR,te.OBJECT_OPERATOR,...Array.from(te.CONDITIONAL_OPERATORS)].map((e=>e.getOperator())));static OPERATORS_WITHOUT_SPACE_WRAP=new Set([...Array.from(te.ARITHMETIC_OPERATORS),...Array.from(te.LOGICAL_OPERATORS),...Array.from(te.BITWISE_OPERATORS),te.ARRAY_OPERATOR,te.OBJECT_OPERATOR,...Array.from(te.CONDITIONAL_OPERATORS)].filter((e=>!e.shouldBeWrappedInSpace())).map((e=>e.getOperator())));static OPERATION_VALUE_OF=new Map(Array.from(te.VALUE_OF.entries()).map((([e,t])=>[t.getOperator(),t])));static UNARY_MAP=new Map([[te.ADDITION,te.UNARY_PLUS],[te.SUBTRACTION,te.UNARY_MINUS],[te.NOT,te.UNARY_LOGICAL_NOT],[te.BITWISE_COMPLEMENT,te.UNARY_BITWISE_COMPLEMENT],[te.UNARY_PLUS,te.UNARY_PLUS],[te.UNARY_MINUS,te.UNARY_MINUS],[te.UNARY_LOGICAL_NOT,te.UNARY_LOGICAL_NOT],[te.UNARY_BITWISE_COMPLEMENT,te.UNARY_BITWISE_COMPLEMENT]]);static BIGGEST_OPERATOR_SIZE=Array.from(te.VALUE_OF.values()).map((e=>e.getOperator())).filter((e=>!e.startsWith("UN: "))).map((e=>e.length)).reduce(((e,t)=>e>t?e:t),0);constructor(e,t,r=!1){this.operator=e,this.operatorName=t??e,this._shouldBeWrappedInSpace=r}getOperator(){return this.operator}getOperatorName(){return this.operatorName}shouldBeWrappedInSpace(){return this._shouldBeWrappedInSpace}valueOf(e){return te.VALUE_OF.get(e)}toString(){return this.operator}}class re extends Z{tokens=new J;ops=new J;constructor(e,t,r,s){super(e||""),t&&this.tokens.push(t),r&&this.tokens.push(r),s&&this.ops.push(s),this.evaluate()}getTokens(){return this.tokens}getOperations(){return this.ops}evaluate(){const e=this.expression.length;let t,r="",s=new K(""),n=0,a=!1;for(;n<e;){switch(r=this.expression[n],t=s.toString(),r){case" ":a=this.processTokenSepearator(s,t,a);break;case"(":n=this.processSubExpression(e,s,t,n,a),a=!1;break;case")":throw new z(this.expression,"Extra closing parenthesis found");case"]":throw new z(this.expression,"Extra closing square bracket found");case"'":case'"':{let t=this.processStringLiteral(e,r,n);n=t.getT1(),a=t.getT2();break}case"?":if(n+1<e&&"?"!=this.expression.charAt(n+1)&&0!=n&&"?"!=this.expression.charAt(n-1))n=this.processTernaryOperator(e,s,t,n,a);else{let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==te.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}break;default:let i=this.processOthers(r,e,s,t,n,a);n=i.getT1(),a=i.getT2(),a&&this.ops.peek()==te.ARRAY_OPERATOR&&(i=this.process(e,s,n),n=i.getT1(),a=i.getT2())}++n}if(t=s.toString(),!v.isNullOrBlank(t)){if(te.OPERATORS.has(t))throw new z(this.expression,"Expression is ending with an operator");this.tokens.push(new Z(t))}}processStringLiteral(e,t,r){let s="",n=r+1;for(;n<e;n++){let e=this.expression.charAt(n);if(e==t&&"\\"!=this.expression.charAt(n-1))break;s+=e}if(n==e&&this.expression.charAt(n-1)!=t)throw new z(this.expression,"Missing string ending marker "+t);let a=new _(n,!1);return this.tokens.push(new ee(s,s)),a}process(e,t,r){let s=1;for(++r;r<e&&0!=s;){let e=this.expression.charAt(r);"]"==e?--s:"["==e&&++s,0!=s&&(t.append(e),r++)}return this.tokens.push(new re(t.toString())),t.setLength(0),new _(r,!1)}processOthers(e,t,r,s,n,a){let i=t-n;i=i<te.BIGGEST_OPERATOR_SIZE?i:te.BIGGEST_OPERATOR_SIZE;for(let e=i;e>0;e--){let t=this.expression.substring(n,n+e);if(te.OPERATORS_WITHOUT_SPACE_WRAP.has(t))return v.isNullOrBlank(s)||(this.tokens.push(new Z(s)),a=!1),this.checkUnaryOperator(this.tokens,this.ops,te.OPERATION_VALUE_OF.get(t),a),a=!0,r.setLength(0),new _(n+e-1,a)}return r.append(e),new _(n,!1)}processTernaryOperator(e,t,r,s,n){if(n)throw new z(this.expression,"Ternary operator is followed by an operator");""!=r.trim()&&(this.tokens.push(new re(r)),t.setLength(0));let a=1,i="";const o=++s;for(;s<e&&a>0;)i=this.expression.charAt(s),"?"==i?++a:":"==i&&--a,++s;if(":"!=i)throw new z(this.expression,"':' operater is missing");if(s>=e)throw new z(this.expression,"Third part of the ternary expression is missing");for(;!this.ops.isEmpty()&&this.hasPrecedence(te.CONDITIONAL_TERNARY_OPERATOR,this.ops.peek());){let e=this.ops.pop();if(te.UNARY_OPERATORS.has(e)){const t=this.tokens.pop();this.tokens.push(new re("",t,void 0,e))}else{let t=this.tokens.pop(),r=this.tokens.pop();this.tokens.push(new re("",r,t,e))}}this.ops.push(te.CONDITIONAL_TERNARY_OPERATOR),this.tokens.push(new re(this.expression.substring(o,s-1)));const u=this.expression.substring(s);if(""===u.trim())throw new z(this.expression,"Third part of the ternary expression is missing");return this.tokens.push(new re(u)),e-1}processSubExpression(e,t,r,s,n){if(te.OPERATORS.has(r))this.checkUnaryOperator(this.tokens,this.ops,te.OPERATION_VALUE_OF.get(r),n),t.setLength(0);else if(!v.isNullOrBlank(r))throw new z(this.expression,M.format("Unkown token : $ found.",r));let a=1;const i=new K;let o=this.expression.charAt(s);for(s++;s<e&&a>0;)o=this.expression.charAt(s),"("==o?a++:")"==o&&a--,0!=a&&(i.append(o),s++);if(")"!=o)throw new z(this.expression,"Missing a closed parenthesis");for(;i.length()>2&&"("==i.charAt(0)&&")"==i.charAt(i.length()-1);)i.deleteCharAt(0),i.setLength(i.length()-1);return this.tokens.push(new re(i.toString().trim())),s}processTokenSepearator(e,t,r){return v.isNullOrBlank(t)||(te.OPERATORS.has(t)?(this.checkUnaryOperator(this.tokens,this.ops,te.OPERATION_VALUE_OF.get(t),r),r=!0):(this.tokens.push(new Z(t)),r=!1)),e.setLength(0),r}checkUnaryOperator(e,t,r,s){if(r)if(s||e.isEmpty()){if(!te.UNARY_OPERATORS.has(r))throw new z(this.expression,M.format("Extra operator $ found.",r));{const e=te.UNARY_MAP.get(r);e&&t.push(e)}}else{for(;!t.isEmpty()&&this.hasPrecedence(r,t.peek());){let r=t.pop();if(te.UNARY_OPERATORS.has(r)){let t=e.pop();e.push(new re("",t,void 0,r))}else{let t=e.pop(),s=e.pop();e.push(new re("",s,t,r))}}t.push(r)}}hasPrecedence(e,t){let r=te.OPERATOR_PRIORITY.get(e),s=te.OPERATOR_PRIORITY.get(t);if(!r||!s)throw new Error("Unknown operators provided");return s<r}toString(){if(this.ops.isEmpty())return 1==this.tokens.size()?this.tokens.get(0).toString():"Error: No tokens";let e=new K,t=0;const r=this.ops.toArray(),s=this.tokens.toArray();for(let n=0;n<r.length;n++)if(r[n].getOperator().startsWith("UN: "))e.append("(").append(r[n].getOperator().substring(4)).append(s[t]instanceof re?s[t].toString():s[t]).append(")"),t++;else if(r[n]==te.CONDITIONAL_TERNARY_OPERATOR){let r=s[t++];e.insert(0,r.toString()),e.insert(0,":"),r=s[t++],e.insert(0,r.toString()),e.insert(0,"?"),r=s[t++],e.insert(0,r.toString()).append(")"),e.insert(0,"(")}else{if(0==t){const r=s[t++];e.insert(0,r.toString())}const a=s[t++];e.insert(0,r[n].getOperator()).insert(0,a.toString()).insert(0,"(").append(")")}return e.toString()}equals(e){return this.expression==e.expression}}e({},"ExpressionEvaluator",(()=>ft));var se={};e(se,"LogicalNullishCoalescingOperator",(()=>ie));var ne={};e(ne,"BinaryOperator",(()=>ae));class ae{nullCheck(e,t,r){if(n(e)||n(t))throw new X(M.format("$ cannot be applied to a null value",r.getOperatorName()))}}class ie extends ae{apply(e,t){return n(e)?t:e}}var oe={};e(oe,"ArithmeticAdditionOperator",(()=>ue));class ue extends ae{apply(e,t){return this.nullCheck(e,t,te.ADDITION),e+t}}var pe={};e(pe,"ArithmeticDivisionOperator",(()=>he));class he extends ae{apply(e,t){return this.nullCheck(e,t,te.DIVISION),e/t}}var le={};e(le,"ArithmeticIntegerDivisionOperator",(()=>ce));class ce extends ae{apply(e,t){return this.nullCheck(e,t,te.DIVISION),Math.floor(e/t)}}var me={};e(me,"ArithmeticModulusOperator",(()=>ge));class ge extends ae{apply(e,t){return this.nullCheck(e,t,te.MOD),e%t}}var fe={};e(fe,"ArithmeticMultiplicationOperator",(()=>Ee));class Ee extends ae{apply(e,t){this.nullCheck(e,t,te.MULTIPLICATION);const r="string"==typeof e;if(r||"string"===typeof t){let s=r?e:t,n=r?t:e,a="",i=n<0;n=Math.abs(n);let o=Math.floor(n);for(;o-- >0;)a+=s;let u=Math.floor(s.length*(n-Math.floor(n)));if(u<0&&(u=-u),0!=u&&(a+=s.substring(0,u)),i){let e="";for(let t=a.length-1;t>=0;t--)e+=a[t];return e}return a}return e*t}}var Te={};e(Te,"ArithmeticSubtractionOperator",(()=>Ae));class Ae extends ae{apply(e,t){return this.nullCheck(e,t,te.SUBTRACTION),e-t}}var Oe={};e(Oe,"ArrayOperator",(()=>we));class we extends ae{apply(e,t){if(!e)throw new X("Cannot apply array operator on a null value");if(!t)throw new X("Cannot retrive null index value");if(!Array.isArray(e)&&"string"!=typeof e)throw new X(M.format("Cannot retrieve value from a primitive value $",e));if(t>=e.length)throw new X(M.format("Cannot retrieve index $ from the array of length $",t,e.length));return e[t]}}var Se={};e(Se,"BitwiseAndOperator",(()=>de));class de extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_AND),e&t}}var Ne={};e(Ne,"BitwiseLeftShiftOperator",(()=>Re));class Re extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_LEFT_SHIFT),e<<t}}var ye={};e(ye,"BitwiseOrOperator",(()=>Ie));class Ie extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_OR),e|t}}var xe={};e(xe,"BitwiseRightShiftOperator",(()=>Me));class Me extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_RIGHT_SHIFT),e>>t}}var ve={};e(ve,"BitwiseUnsignedRightShiftOperator",(()=>Pe));class Pe extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_UNSIGNED_RIGHT_SHIFT),e>>>t}}var _e={};e(_e,"BitwiseXorOperator",(()=>Le));class Le extends ae{apply(e,t){return this.nullCheck(e,t,te.BITWISE_XOR),e^t}}var Ce={};e(Ce,"LogicalAndOperator",(()=>Ve));e({},"PrimitiveUtil",(()=>be));class be{static findPrimitiveNullAsBoolean(e){if(!e)return new _(i.BOOLEAN,!1);let t=typeof e;if("object"===t)throw new X(M.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new _(i.BOOLEAN,r):"string"===t?new _(i.STRING,r):be.findPrimitiveNumberType(r)}static findPrimitive(e){if(n(e))return new _(i.NULL,void 0);let t=typeof e;if("object"===t)throw new X(M.format("$ is not a primitive type",e));let r=e;return"boolean"===t?new _(i.BOOLEAN,r):"string"===t?new _(i.STRING,r):be.findPrimitiveNumberType(r)}static findPrimitiveNumberType(e){if(n(e)||Array.isArray(e)||"object"==typeof e)throw new X(M.format("Unable to convert $ to a number.",e));let t=e;try{let e=t;return Number.isInteger(e)?new _(i.LONG,e):new _(i.DOUBLE,e)}catch(e){throw new X(M.format("Unable to convert $ to a number.",t),e)}}static compare(e,t){if(e==t)return 0;if(n(e)||n(t))return n(e)?-1:1;if(Array.isArray(e)||Array.isArray(t)){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!=t.length)return e.length-t.length;for(let r=0;r<e.length;r++){let s=this.compare(e[r],t[r]);if(0!=s)return s}return 0}return Array.isArray(e)?-1:1}const r=typeof e,s=typeof t;return"object"===r||"object"===s?("object"===r&&"object"===s&&Object.keys(e).forEach((r=>{let s=this.compare(e[r],t[r]);if(0!=s)return s})),"object"===r?-1:1):this.comparePrimitive(e,t)}static comparePrimitive(e,t){return n(e)||n(t)?n(e)&&n(t)?0:n(e)?-1:1:e==t?0:"boolean"==typeof e||"boolean"==typeof t?e?-1:1:"string"==typeof e||"string"==typeof t?e+""<t+""?-1:1:"number"==typeof e||"number"==typeof t?e-t:0}static baseNumberType(e){return Number.isInteger(e)?i.LONG:i.DOUBLE}static toPrimitiveType(e){return e}constructor(){}}class Ve extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",s.getT2()));return r.getT2()&&s.getT2()}}var Ue={};e(Ue,"LogicalEqualOperator",(()=>De));function Be(e,t){let r=new J;r.push(e);let s=new J;for(s.push(t);!r.isEmpty()&&!s.isEmpty();){const e=r.pop(),t=s.pop();if(e===t)continue;const n=typeof e,a=typeof t;if("undefined"===n||"undefined"===a){if(!e&&!t)continue;return!1}if(n!==a)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!=t.length)return!1;for(let n=0;n<e.length;n++)r.push(e[n]),s.push(t[n])}else{if("object"!==n)return!1;{const n=Object.entries(e),a=Object.entries(t);if(n.length!==a.length)return!1;for(const[e,a]of n)r.push(a),s.push(t[e])}}}return!0}e({},"deepEqual",(()=>Be));class De extends ae{apply(e,t){return Be(e,t)}}var ke={};e(ke,"LogicalGreaterThanEqualOperator",(()=>Ge));class Ge extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare >= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>=s.getT2()}}var Fe={};e(Fe,"LogicalGreaterThanOperator",(()=>He));class He extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare > with the values $ and $",r.getT2(),s.getT2()));return r.getT2()>s.getT2()}}var Ye={};e(Ye,"LogicalLessThanEqualOperator",(()=>$e));class $e extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare <= with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<=s.getT2()}}var We={};e(We,"LogicalLessThanOperator",(()=>je));class je extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()==i.BOOLEAN||s.getT1()==i.BOOLEAN)throw new X(M.format("Cannot compare < with the values $ and $",r.getT2(),s.getT2()));return r.getT2()<s.getT2()}}var qe={};e(qe,"LogicalNotEqualOperator",(()=>Xe));class Xe extends ae{apply(e,t){return!Be(e,t)}}var Je={};e(Je,"LogicalOrOperator",(()=>Qe));class Qe extends ae{apply(e,t){const r=be.findPrimitiveNullAsBoolean(e),s=be.findPrimitiveNullAsBoolean(t);if(r.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",r.getT2()));if(s.getT1()!=i.BOOLEAN)throw new X(M.format("Boolean value expected but found $",s.getT2()));return r.getT2()||s.getT2()}}var Ke={};e(Ke,"ObjectOperator",(()=>ze));class ze extends ae{apply(e,t){if(!e)throw new X("Cannot apply array operator on a null value");if(!t)throw new X("Cannot retrive null property value");const r=typeof e;if(!Array.isArray(e)&&"string"!=r&&"object"!=r)throw new X(M.format("Cannot retrieve value from a primitive value $",e));return e[t]}}var Ze={};e(Ze,"ArithmeticUnaryMinusOperator",(()=>rt));var et={};e(et,"UnaryOperator",(()=>tt));class tt{nullCheck(e,t){if(n(e))throw new X(M.format("$ cannot be applied to a null value",t.getOperatorName()))}}class rt extends tt{apply(e){return this.nullCheck(e,te.UNARY_MINUS),be.findPrimitiveNumberType(e),-e}}var st={};e(st,"ArithmeticUnaryPlusOperator",(()=>nt));class nt extends tt{apply(e){return this.nullCheck(e,te.UNARY_PLUS),be.findPrimitiveNumberType(e),e}}var at={};e(at,"BitwiseComplementOperator",(()=>it));class it extends tt{apply(e){this.nullCheck(e,te.UNARY_BITWISE_COMPLEMENT);let t=be.findPrimitiveNumberType(e);if(t.getT1()!=i.INTEGER&&t.getT1()!=i.LONG)throw new X(M.format("Unable to apply bitwise operator on $",e));return~e}}var ot={};e(ot,"LogicalNotOperator",(()=>ut));class ut extends tt{apply(e){if(this.nullCheck(e,te.UNARY_LOGICAL_NOT),be.findPrimitiveNumberType(e).getT1()!=i.BOOLEAN)throw new X(M.format("Unable to apply bitwise operator on $",e));return!e}}e({},"LiteralTokenValueExtractor",(()=>lt));e({},"TokenValueExtractor",(()=>pt));class pt{static REGEX_SQUARE_BRACKETS=/[\[\]]/;static REGEX_DOT=/\./;getValue(e){let t=this.getPrefix();if(!e.startsWith(t))throw new w(M.format("Token $ doesn't start with $",e,t));return this.getValueInternal(e)}retrieveElementFrom(e,t,r,s){if(n(s))return;if(t.length==r)return s;let a=t[r].split(pt.REGEX_SQUARE_BRACKETS).map((e=>e.trim())).filter((e=>!v.isNullOrBlank(e))).reduce(((s,n,a)=>this.resolveForEachPartOfTokenWithBrackets(e,t,r,n,s,a)),s);return this.retrieveElementFrom(e,t,r+1,a)}resolveForEachPartOfTokenWithBrackets(e,t,r,s,a,i){if(!n(a)){if(0===i){if(Array.isArray(a)){if("length"===s)return a.length;try{let e=parseInt(s);if(isNaN(e))throw new Error(M.format("$ is not a number",e));if(e>=a.length)return;return a[e]}catch(t){throw new z(e,M.format("$ couldn't be parsed into integer in $",s,e),t)}}return this.checkIfObject(e,t,r,a),a[s]}if(s?.startsWith('"')){if(!s.endsWith('"')||1==s.length||2==s.length)throw new z(e,M.format("$ is missing a double quote or empty key found",e));return this.checkIfObject(e,t,r,a),a[s.substring(1,s.length-1)]}try{let t=parseInt(s);if(isNaN(t))throw new Error(M.format("$ is not a number",t));if(!Array.isArray(a))throw new z(e,M.format("Expecting an array with index $ while processing the expression",t,e));if(t>=a.length)return;return a[t]}catch(t){throw new z(e,M.format("$ couldn't be parsed into integer in $",s,e),t)}}}checkIfObject(e,t,r,s){if("object"!=typeof s||Array.isArray(s))throw new z(e,M.format("Unable to retrive $ from $ in the path $",t[r],s.toString(),e))}}const ht=new Map([["true",!0],["false",!1],["null",void 0]]);class lt extends pt{static INSTANCE=new lt;getValueInternal(e){if(!v.isNullOrBlank(e))return e=e.trim(),ht.has(e)?ht.get(e):e.startsWith('"')?this.processString(e):this.processNumbers(e)}processNumbers(e){try{let t=Number(e);if(isNaN(t))throw new Error("Parse number error");return t}catch(t){throw new z(e,M.format("Unable to parse the literal or expression $",e),t)}}processString(e){if(!e.endsWith('"'))throw new z(e,M.format("String literal $ is not closed properly",e));return e.substring(1,e.length-1)}getPrefix(){return""}}var ct={};e(ct,"ConditionalTernaryOperator",(()=>mt));class mt extends class{nullCheck(e,t,r,s){if(n(e)||n(t)||n(r))throw new X(M.format("$ cannot be applied to a null value",s.getOperatorName()))}}{apply(e,t,r){return e?t:r}}t({},ct);class gt extends pt{static PREFIX="_internal.";values=new Map;addValue(e,t){this.values.set(e,t)}getValueInternal(e){let t=e.split(pt.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.values.get(r))}getPrefix(){return gt.PREFIX}}class ft{static UNARY_OPERATORS_MAP=new Map([[te.UNARY_BITWISE_COMPLEMENT,new it],[te.UNARY_LOGICAL_NOT,new ut],[te.UNARY_MINUS,new rt],[te.UNARY_PLUS,new nt]]);static TERNARY_OPERATORS_MAP=new Map([[te.CONDITIONAL_TERNARY_OPERATOR,new mt]]);static BINARY_OPERATORS_MAP=new Map([[te.ADDITION,new ue],[te.DIVISION,new he],[te.INTEGER_DIVISION,new ce],[te.MOD,new ge],[te.MULTIPLICATION,new Ee],[te.SUBTRACTION,new Ae],[te.BITWISE_AND,new de],[te.BITWISE_LEFT_SHIFT,new Re],[te.BITWISE_OR,new Ie],[te.BITWISE_RIGHT_SHIFT,new Me],[te.BITWISE_UNSIGNED_RIGHT_SHIFT,new Pe],[te.BITWISE_XOR,new Le],[te.AND,new Ve],[te.EQUAL,new De],[te.GREATER_THAN,new He],[te.GREATER_THAN_EQUAL,new Ge],[te.LESS_THAN,new je],[te.LESS_THAN_EQUAL,new $e],[te.OR,new Qe],[te.NOT_EQUAL,new Xe],[te.NULLISH_COALESCING_OPERATOR,new ie],[te.ARRAY_OPERATOR,new we],[te.OBJECT_OPERATOR,new ze]]);static UNARY_OPERATORS_MAP_KEY_SET=new Set(ft.UNARY_OPERATORS_MAP.keys());internalTokenValueExtractor=new gt;constructor(e){e instanceof re?(this.exp=e,this.expression=this.exp.getExpression()):this.expression=e}evaluate(e){const t=this.processNestingExpression(this.expression,e);return this.expression=t.getT1(),this.exp=t.getT2(),(e=new Map(e.entries())).set(this.internalTokenValueExtractor.getPrefix(),this.internalTokenValueExtractor),this.evaluateExpression(this.exp,e)}processNestingExpression(e,t){let r=0,s=0;const n=new J;for(;s<e.length-1;){if("{"==e.charAt(s)&&"{"==e.charAt(s+1))0==r&&n.push(new _(s+2,-1)),r++,s++;else if("}"==e.charAt(s)&&"}"==e.charAt(s+1)){if(r--,r<0)throw new z(e,"Expecting {{ nesting path operator to be started before closing");0==r&&n.push(n.pop().setT2(s)),s++}s++}let a=this.replaceNestingExpression(e,t,n);return new _(a,new re(a))}replaceNestingExpression(e,t,r){let s=e;for(var n of r.toArray()){if(-1==n.getT2())throw new z(e,"Expecting }} nesting path operator to be closed");let r=new ft(s.substring(n.getT1(),n.getT2())).evaluate(t);s=s.substring(0,n.getT1()-2)+r+s.substring(n.getT2()+2)}return s}getExpression(){return this.exp||(this.exp=new re(this.expression)),this.exp}getExpressionString(){return this.expression}evaluateExpression(e,t){let r=e.getOperations(),s=e.getTokens();for(;!r.isEmpty();){let e=r.pop(),o=s.pop();if(ft.UNARY_OPERATORS_MAP_KEY_SET.has(e))s.push(this.applyUnaryOperation(e,this.getValueFromToken(t,o)));else if(e==te.OBJECT_OPERATOR||e==te.ARRAY_OPERATOR)this.processObjectOrArrayOperator(t,r,s,e,o);else if(e==te.CONDITIONAL_TERNARY_OPERATOR){const r=s.pop(),u=s.pop();var n=this.getValueFromToken(t,u),a=this.getValueFromToken(t,r),i=this.getValueFromToken(t,o);s.push(this.applyTernaryOperation(e,n,a,i))}else{const r=s.pop();n=this.getValueFromToken(t,r),a=this.getValueFromToken(t,o);s.push(this.applyBinaryOperation(e,n,a))}}if(s.isEmpty())throw new X(M.format("Expression : $ evaluated to null",e));if(1!=s.size())throw new X(M.format("Expression : $ evaluated multiple values $",e,s));const o=s.get(0);if(o instanceof ee)return o.getElement();if(!(o instanceof re))return this.getValueFromToken(t,o);throw new X(M.format("Expression : $ evaluated to $",e,s.get(0)))}processObjectOrArrayOperator(e,t,r,s,n){const a=new J,i=new J;if(!s||!n)return;do{i.push(s),n instanceof re?a.push(new ee(n.toString(),this.evaluateExpression(n,e))):n&&a.push(n),n=r.isEmpty()?void 0:r.pop(),s=t.isEmpty()?void 0:t.pop()}while(s==te.OBJECT_OPERATOR||s==te.ARRAY_OPERATOR);n&&(n instanceof re?a.push(new ee(n.toString(),this.evaluateExpression(n,e))):a.push(n)),s&&t.push(s);let o=a.pop();if(o instanceof ee&&"object"==typeof o.getTokenValue()){const e=(new Date).getTime()+""+Math.round(1e3*Math.random());this.internalTokenValueExtractor.addValue(e,o.getTokenValue()),o=new Z(gt.PREFIX+e)}let u=new K(o instanceof ee?o.getTokenValue():o.toString());for(;!a.isEmpty();)o=a.pop(),s=i.pop(),u.append(s.getOperator()).append(o instanceof ee?o.getTokenValue():o.toString()),s==te.ARRAY_OPERATOR&&u.append("]");let p=u.toString(),h=p.substring(0,p.indexOf(".")+1);if(h.length>2&&e.has(h))r.push(new ee(p,this.getValue(p,e)));else{let e;try{e=lt.INSTANCE.getValue(p)}catch(t){e=p}r.push(new ee(p,e))}}applyTernaryOperation(e,t,r,s){let n=ft.TERNARY_OPERATORS_MAP.get(e);if(!n)throw new z(this.expression,M.format("No operator found to evaluate $",this.getExpression()));return new ee(e.toString(),n.apply(t,r,s))}applyBinaryOperation(e,t,r){let s=typeof t,n=typeof r,a=ft.BINARY_OPERATORS_MAP.get(e);if(("object"===s||"object"===n)&&e!==te.EQUAL&&e!==te.NOT_EQUAL&&e!==te.NULLISH_COALESCING_OPERATOR)throw new z(this.expression,M.format("Cannot evaluate expression $ $ $",t,e.getOperator(),r));if(!a)throw new z(this.expression,M.format("No operator found to evaluate $ $ $",t,e.getOperator(),r));return new ee(e.toString(),a.apply(t,r))}applyUnaryOperation(e,t){if("object"===typeof t||Array.isArray(t))throw new z(this.expression,M.format("The operator $ cannot be applied to $",e.getOperator(),t));let r=ft.UNARY_OPERATORS_MAP.get(e);if(!r)throw new z(this.expression,M.format("No Unary operator $ is found to apply on $",e.getOperator(),t));return new ee(e.toString(),r.apply(t))}getValueFromToken(e,t){return t instanceof re?this.evaluateExpression(t,e):t instanceof ee?t.getElement():this.getValue(t.getExpression(),e)}getValue(e,t){if(e.length<=5)return lt.INSTANCE.getValue(e);const r=e.substring(0,e.indexOf(".")+1);return(t.get(r)??lt.INSTANCE).getValue(e)}}const Et=new I("Set").setNamespace(s.SYSTEM_CTX).setParameters(new Map([T.ofEntry("name",(new m).setName("name").setType(l.of(i.STRING)).setMinLength(1),!1,f.CONSTANT),T.ofEntry("value",m.ofAny("value"))])).setEvents(new Map([N.outputEventMapEntry(new Map)]));const Tt=new I("GenerateEvent").setNamespace(s.SYSTEM).setParameters(new Map([T.ofEntry("eventName",m.ofString("eventName").setDefaultValue("output")),T.ofEntry("results",m.ofObject("results").setProperties(new Map([["name",m.ofString("name")],["value",T.EXPRESSION]])),!0)])).setEvents(new Map([N.outputEventMapEntry(new Map)]));class At extends W{static CONDITION="condition";static SIGNATURE=new I("If").setNamespace(s.SYSTEM).setParameters(new Map([T.ofEntry(At.CONDITION,m.of(At.CONDITION,i.BOOLEAN))])).setEvents(new Map([N.eventMapEntry(N.TRUE,new Map),N.eventMapEntry(N.FALSE,new Map),N.outputEventMapEntry(new Map)]));getSignature(){return At.SIGNATURE}async internalExecute(e){var t=e.getArguments()?.get(At.CONDITION);return new y([R.of(t?N.TRUE:N.FALSE,new Map),R.outputOf(new Map)])}}const Ot=new I("CountLoop").setNamespace(s.SYSTEM_LOOP).setParameters(new Map([T.ofEntry("count",m.of("count",i.INTEGER).setDefaultValue(1))])).setEvents(new Map([N.eventMapEntry(N.ITERATION,new Map([["index",m.of("index",i.INTEGER)]])),N.outputEventMapEntry(new Map([["value",m.of("value",i.INTEGER)]]))]));const wt=new I("RangeLoop").setNamespace(s.SYSTEM_LOOP).setParameters(new Map([T.ofEntry("from",m.of("from",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE).setDefaultValue(0)),T.ofEntry("to",m.of("to",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE).setDefaultValue(1)),T.ofEntry("step",m.of("step",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE).setDefaultValue(1).setNot((new m).setConstant(0)))])).setEvents(new Map([N.eventMapEntry(N.ITERATION,new Map([["index",m.of("index",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE)]])),N.outputEventMapEntry(new Map([["value",m.of("value",i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE)]]))]));const St=new I("Add").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofNumber("value")]]))]));const dt=[()=>new Map([["value",new T("value",m.ofNumber("value"))]]),()=>new Map([["value1",new T("value1",m.ofNumber("value1"))],["value2",new T("value2",m.ofNumber("value2"))]])];class Nt extends W{constructor(e,t,r=1,...n){super(),n&&n.length||(n=[i.DOUBLE]),this.parametersNumber=r,this.mathFunction=t,this.signature=new I(e).setNamespace(s.MATH).setParameters(dt[r-1]()).setEvents(new Map([N.outputEventMapEntry(new Map([["value",(new m).setType(l.of(...n)).setName("value")]]))]))}getSignature(){return this.signature}async internalExecute(e){let t,r=be.findPrimitiveNumberType(e.getArguments()?.get(1==this.parametersNumber?"value":"value1")).getT2();return 2==this.parametersNumber&&(t=be.findPrimitiveNumberType(e.getArguments()?.get("value2")).getT2()),new y([R.outputOf(new Map([["value",this.mathFunction.call(this,r,t)]]))])}}class Rt extends W{static SIGNATURE=new I("Hypotenuse").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",(new m).setType(l.of(i.DOUBLE)).setName("value")]]))]));constructor(){super()}getSignature(){return Rt.SIGNATURE}async internalExecute(e){let t=e.getArguments()?.get("value");return new y([R.outputOf(new Map([["value",Math.sqrt(t.reduce(((e,t)=>e+t*t),0))]]))])}}const yt=new I("Maximum").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofNumber("value")]]))]));const It=new I("Minimum").setNamespace(s.MATH).setParameters(new Map([["value",new T("value",m.ofNumber("value")).setVariableArgument(!0)]])).setEvents(new Map([N.outputEventMapEntry(new Map([["value",m.ofNumber("value")]]))]));var xt={};e(xt,"MapUtil",(()=>Mt)),e(xt,"MapEntry",(()=>vt));class Mt{static of(e,t,r,s,a,i,o,u,p,h,l,c,m,g,f,E,T,A,O,w){const S=new Map;return n(e)||n(t)||S.set(e,t),n(r)||n(s)||S.set(r,s),n(a)||n(i)||S.set(a,i),n(o)||n(u)||S.set(o,u),n(p)||n(h)||S.set(p,h),n(l)||n(c)||S.set(l,c),n(m)||n(g)||S.set(m,g),n(f)||n(E)||S.set(f,E),n(T)||n(A)||S.set(T,A),n(O)||n(w)||S.set(O,w),S}static ofArrayEntries(...e){const t=new Map;for(const[r,s]of e)t.set(r,s);return t}static entry(e,t){return new vt(e,t)}static ofEntries(...e){const t=new Map;for(const r of e)t.set(r.k,r.v);return t}static ofEntriesArray(...e){const t=new Map;for(let r=0;r<e.length;r++)t.set(e[r][0],e[r][1]);return t}constructor(){}}class vt{constructor(e,t){this.k=e,this.v=t}}class Pt extends W{static SIGNATURE=new I("Random").setNamespace(s.MATH).setEvents(new Map([N.outputEventMapEntry(Mt.of("value",m.ofDouble("value")))]));getSignature(){return Pt.SIGNATURE}async internalExecute(e){return new y([R.outputOf(new Map([["value",Math.random()]]))])}}const _t={Absolute:new Nt("Absolute",(e=>Math.abs(e)),1,i.INTEGER,i.LONG,i.FLOAT,i.DOUBLE),ACosine:new Nt("ArcCosine",(e=>Math.acos(e))),ASine:new Nt("ArcSine",(e=>Math.asin(e))),ATangent:new Nt("ArcTangent",(e=>Math.atan(e))),Ceiling:new Nt("Ceiling",(e=>Math.ceil(e))),Cosine:new Nt("Cosine",(e=>Math.cos(e))),CosineH:new Nt("HyperbolicCosine",(e=>Math.cosh(e))),CubeRoot:new Nt("CubeRoot",(e=>Math.cbrt(e))),Exponential:new Nt("Exponential",(e=>Math.exp(e))),Expm1:new Nt("ExponentialMinus1",(e=>Math.expm1(e))),Floor:new Nt("Floor",(e=>Math.floor(e))),Log:new Nt("LogNatural",(e=>Math.log(e))),Log10:new Nt("Log10",(e=>Math.log10(e))),Round:new Nt("Round",(e=>Math.round(e)),1,i.INTEGER,i.LONG),Sine:new Nt("Sine",(e=>Math.sin(e))),SineH:new Nt("HyperbolicSine",(e=>Math.sinh(e))),Tangent:new Nt("Tangent",(e=>Math.tan(e))),TangentH:new Nt("HyperbolicTangent",(e=>Math.tanh(e))),ToDegrees:new Nt("ToDegrees",(e=>e*(Math.PI/180))),ToRadians:new Nt("ToRadians",(e=>e*(180/Math.PI))),SquareRoot:new Nt("SquareRoot",(e=>Math.sqrt(e))),ArcTangent:new Nt("ArcTangent2",((e,t)=>Math.atan2(e,t)),2),Power:new Nt("Power",((e,t)=>Math.pow(e,t)),2),Add:new class extends W{getSignature(){return St}async internalExecute(e){let t=e.getArguments()?.get("value");return new y([R.outputOf(new Map([["value",t.reduce(((e,t)=>e+t),0)]]))])}},Hypotenuse:new Rt,Maximum:new class extends W{getSignature(){return yt}async internalExecute(e){let t=e.getArguments()?.get("value");return new y([R.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t>e?t:e))]]))])}},Minimum:new class extends W{getSignature(){return It}async internalExecute(e){let t=e.getArguments()?.get("value");return new y([R.outputOf(new Map([["value",t.reduce(((e,t)=>!e&&0!==e||t<e?t:e))]]))])}},Random:new Pt};class Lt{find(e,t){if(e==s.MATH)return _t[t]}}e({},"HybridRepository",(()=>Ct));class Ct{constructor(...e){this.repos=e}find(e,t){for(let r of this.repos){let s=r.find(e,t);if(s)return s}}}function bt(e){return[e.getSignature().getName(),e]}const Vt=new Map([[s.SYSTEM_CTX,new Map([bt(new class extends W{getSignature(){return j}async internalExecute(e){const t=e?.getArguments()?.get("name");if(e?.getContext()?.has(t))throw new w(M.format("Context already has an element for '$' ",t));let r=m.from(e?.getArguments()?.get("schema"));if(!r)throw new w("Schema is not supplied.");return e.getContext().set(t,new x(r,n(r.getDefaultValue())?void 0:r.getDefaultValue())),new y([R.outputOf(new Map)])}}),bt(new class extends W{getSignature(){return q}async internalExecute(e){const t=e?.getArguments()?.get("name");if(!e.getContext()?.has(t))throw new w(M.format("Context don't have an element for '$' ",t));return new y([R.outputOf(new Map(["value",e.getContext()?.get(t)?.getElement()]))])}}),bt(new class extends W{getSignature(){return Et}async internalExecute(e){let t=e?.getArguments()?.get("name");if(v.isNullOrBlank(t))throw new w("Empty string is not a valid name for the context element");let r=e?.getArguments()?.get("value");const s=new re(t),n=s.getTokens().peekLast();if(!n.getExpression().startsWith("Context")||n instanceof re||n instanceof ee&&!n.getElement().toString().startsWith("Context"))throw new X(M.format("The context path $ is not a valid path in context",t));for(const e of s.getOperations().toArray())if(e!=te.ARRAY_OPERATOR&&e!=te.OBJECT_OPERATOR)throw new X(M.format("Expected a reference to the context location, but found an expression $",t));for(let r=0;r<s.getTokens().size();r++){let n=s.getTokens().get(r);n instanceof re&&s.getTokens().set(r,new ee(t,new ft(n).evaluate(e.getValuesMap())))}return this.modifyContext(e,t,r,s)}modifyContext(e,t,r,s){const a=s.getTokens();a.removeLast();const i=s.getOperations();i.removeLast();let o=e.getContext()?.get(a.removeLast().getExpression());if(n(o))throw new w(M.format("Context doesn't have any element with name '$' ",t));if(i.isEmpty())return o.setElement(r),new y([R.outputOf(new Map)]);let u=o.getElement(),p=i.removeLast(),h=a.removeLast(),l=h instanceof ee?h.getElement():h.getExpression();for(n(u)&&(u=p==te.OBJECT_OPERATOR?{}:[],o.setElement(u));!i.isEmpty();)u=p==te.OBJECT_OPERATOR?this.getDataFromObject(u,l,i.peekLast()):this.getDataFromArray(u,l,i.peekLast()),p=i.removeLast(),h=a.removeLast(),l=h instanceof ee?h.getElement():h.getExpression();return p==te.OBJECT_OPERATOR?this.putDataInObject(u,l,r):this.putDataInArray(u,l,r),new y([R.outputOf(new Map)])}getDataFromArray(e,t,r){if(!Array.isArray(e))throw new w(M.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new w(M.format("Expected an array index but found $",t));if(s<0)throw new w(M.format("Array index is out of bound - $",t));let a=e[s];return n(a)&&(a=r==te.OBJECT_OPERATOR?{}:[],e[s]=a),a}getDataFromObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new w(M.format("Expected an object but found $",e));let s=e[t];return n(s)&&(s=r==te.OBJECT_OPERATOR?{}:[],e[t]=s),s}putDataInArray(e,t,r){if(!Array.isArray(e))throw new w(M.format("Expected an array but found $",e));const s=parseInt(t);if(isNaN(s))throw new w(M.format("Expected an array index but found $",t));if(s<0)throw new w(M.format("Array index is out of bound - $",t));e[s]=r}putDataInObject(e,t,r){if(Array.isArray(e)||"object"!=typeof e)throw new w(M.format("Expected an object but found $",e));e[t]=r}})])],[s.SYSTEM_LOOP,new Map([bt(new class extends W{getSignature(){return wt}async internalExecute(e){let t=e.getArguments()?.get("from"),r=e.getArguments()?.get("to"),s=e.getArguments()?.get("step");const n=s>0;let a=t,i=!1;return new y({next(){if(i)return;if(n&&a>=r||!n&&a<=r)return i=!0,R.outputOf(new Map([["value",a]]));const e=R.of(N.ITERATION,new Map([["index",a]]));return a+=s,e}})}}),bt(new class extends W{getSignature(){return Ot}async internalExecute(e){let t=e.getArguments()?.get("count"),r=0;return new y({next(){if(r>=t)return R.outputOf(new Map([["value",r]]));const e=R.of(N.ITERATION,new Map([["index",r]]));return++r,e}})}})])],[s.SYSTEM,new Map([bt(new At),bt(new class extends W{getSignature(){return Tt}async internalExecute(e){const t=e.getEvents(),r=e.getArguments()?.get("eventName"),s=e?.getArguments()?.get("results").map((t=>{let r=t.value;if(n(r))throw new w("Expect a value object");let s=r.value;return r.isExpression&&(s=new ft(s).evaluate(e.getValuesMap())),[t.name,s]})).reduce(((e,t)=>(e.set(t[0],t[1]),e)),new Map);return t?.has(r)||t?.set(r,[]),t?.get(r)?.push(s),new y([R.outputOf(new Map)])}})])]]);class Ut extends Ct{constructor(){super({find:(e,t)=>Vt.get(e)?.get(t)},new Lt)}}e({},"ArrayUtil",(()=>Bt));class Bt{static removeAListFrom(e,t){if(!(t&&e&&e.length&&t.length))return;const r=new Set(t);for(let t=0;t<e.length;t++)r.has(e[t])&&(e.splice(t,1),t--)}static of(...e){const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r];return t}constructor(){}}e({},"StatementExecution",(()=>kt));e({},"StatementMessage",(()=>Dt));class Dt{constructor(e,t){this.message=t,this.messageType=e}getMessageType(){return this.messageType}setMessageType(e){return this.messageType=e,this}getMessage(){return this.message}setMessage(e){return this.message=e,this}toString(){return`${this.messageType} : ${this.message}`}}class kt{messages=new Array;dependencies=new Set;constructor(e){this.statement=e}getStatement(){return this.statement}setStatement(e){return this.statement=e,this}getMessages(){return this.messages}setMessages(e){return this.messages=e,this}getDependencies(){return this.dependencies}setDependencies(e){return this.dependencies=e,this}getUniqueKey(){return this.statement.getStatementName()}addMessage(e,t){this.messages.push(new Dt(e,t))}addDependency(e){this.dependencies.add(e)}getDepenedencies(){return this.dependencies}equals(e){if(!(e instanceof kt))return!1;return e.statement.equals(this.statement)}}e({},"ContextTokenValueExtractor",(()=>Gt));class Gt extends pt{static PREFIX="Context.";constructor(e){super(),this.context=e}getValueInternal(e){let t=e.split(pt.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.context.get(r)?.getElement())}getPrefix(){return Gt.PREFIX}}e({},"OutputMapTokenValueExtractor",(()=>Ft));class Ft extends pt{static PREFIX="Steps.";constructor(e){super(),this.output=e}getValueInternal(e){let t=e.split(pt.REGEX_DOT),r=1,s=this.output.get(t[r++]);if(!s||r>=t.length)return;let n=s.get(t[r++]);if(!n||r>=t.length)return;let a=n.get(t[r++]);return this.retrieveElementFrom(e,t,r,a)}getPrefix(){return Ft.PREFIX}}e({},"ArgumentsTokenValueExtractor",(()=>Ht));class Ht extends pt{static PREFIX="Arguments.";constructor(e){super(),this.args=e}getValueInternal(e){let t=e.split(pt.REGEX_DOT),r=t[1],s=r.indexOf("["),n=2;return-1!=s&&(r=t[1].substring(0,s),t[1]=t[1].substring(s),n=1),this.retrieveElementFrom(e,t,n,this.args.get(r))}getPrefix(){return Ht.PREFIX}}e({},"GraphVertex",(()=>$t));e({},"ExecutionGraph",(()=>Yt));class Yt{nodeMap=new Map;constructor(e=!1){this.isSubGrph=e}getVerticesData(){return Array.from(this.nodeMap.values()).map((e=>e.getData()))}addVertex(e){if(!this.nodeMap.has(e.getUniqueKey())){let t=new $t(this,e);this.nodeMap.set(e.getUniqueKey(),t)}return this.nodeMap.get(e.getUniqueKey())}getVertex(e){return this.nodeMap.get(e)}getVertexData(e){if(this.nodeMap.has(e))return this.nodeMap.get(e).getData()}getVerticesWithNoIncomingEdges(){return Array.from(this.nodeMap.values()).filter((e=>!e.hasIncomingEdges()))}isCyclic(){let e,t=new J(this.getVerticesWithNoIncomingEdges()),r=new Set;for(;!t.isEmpty();){if(r.has(t.getFirst().getKey()))return!0;e=t.removeFirst(),r.add(e.getKey()),e.hasOutgoingEdges()&&t.addAll(Array.from(e.getOutVertices().values()).flatMap((e=>Array.from(e))))}return!1}addVertices(e){for(const t of e)this.addVertex(t)}getNodeMap(){return this.nodeMap}isSubGraph(){return this.isSubGrph}toString(){return"Execution Graph : \n"+Array.from(this.nodeMap.values()).map((e=>e.toString())).join("\n")}}class $t{outVertices=new Map;inVertices=new Set;constructor(e,t){this.data=t,this.graph=e}getData(){return this.data}setData(e){return this.data=e,this}getOutVertices(){return this.outVertices}setOutVertices(e){return this.outVertices=e,this}getInVertices(){return this.inVertices}setInVertices(e){return this.inVertices=e,this}getGraph(){return this.graph}setGraph(e){return this.graph=e,this}getKey(){return this.data.getUniqueKey()}addOutEdgeTo(e,t){return this.outVertices.has(e)||this.outVertices.set(e,new Set),this.outVertices.get(e).add(t),t.inVertices.add(new _(this,e)),t}addInEdgeTo(e,t){return this.inVertices.add(new _(e,t)),e.outVertices.has(t)||e.outVertices.set(t,new Set),e.outVertices.get(t).add(this),e}hasIncomingEdges(){return!!this.inVertices.size}hasOutgoingEdges(){return!!this.outVertices.size}getSubGraphOfType(e){let t=new Yt(!0);var r=new J(Array.from(this.outVertices.get(e)??[]));for(r.map((e=>e.getData())).forEach((e=>t.addVertex(e)));!r.isEmpty();){var s=r.pop();Array.from(s.outVertices.values()).flatMap((e=>Array.from(e))).forEach((e=>{t.addVertex(e.getData()),r.add(e)}))}return t}toString(){var e=Array.from(this.getInVertices()).map((e=>e.getT1().getKey()+"("+e.getT2()+")")).join(", "),t=Array.from(this.outVertices.entries()).map((([e,t])=>e+": "+Array.from(t).map((e=>e.getKey())).join(","))).join("\n\t\t");return this.getKey()+":\n\tIn: "+e+"\n\tOut: \n\t\t"+t}}e({},"KIRuntime",(()=>zt));e({},"JsonExpression",(()=>Wt));class Wt{constructor(e){this.expression=e}getExpression(){return this.expression}}let jt;var qt;e({},"ParameterReferenceType",(()=>jt)),(qt=jt||(jt={})).VALUE="VALUE",qt.EXPRESSION="EXPRESSION";function Xt(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))}e({},"FunctionExecutionParameters",(()=>Jt));class Jt{count=0;valueExtractors=new Map;constructor(e,t,r){this.functionRepository=e,this.schemaRepository=t,this.executionId=r??Xt()}getExecutionId(){return this.executionId}getContext(){return this.context}setContext(e){this.context=e;let t=new Gt(e);return this.valueExtractors.set(t.getPrefix(),t),this}getArguments(){return this.args}setArguments(e){this.args=e;let t=new Ht(e);return this.valueExtractors.set(t.getPrefix(),t),this}getEvents(){return this.events}setEvents(e){return this.events=e,this}getStatementExecution(){return this.statementExecution}setStatementExecution(e){return this.statementExecution=e,this}getSteps(){return this.steps}setSteps(e){this.steps=e;let t=new Ft(e);return this.valueExtractors.set(t.getPrefix(),t),this}getCount(){return this.count}setCount(e){return this.count=e,this}getValuesMap(){return this.valueExtractors}getFunctionRepository(){return this.functionRepository}setFunctionRepository(e){return this.functionRepository=e,this}getSchemaRepository(){return this.schemaRepository}setSchemaRepository(e){return this.schemaRepository=e,this}addTokenValueExtractor(...e){for(const t of e)this.valueExtractors.set(t.getPrefix(),t);return this}setValuesMap(e){for(const[t,r]of e.entries())this.valueExtractors.set(t,r);return this}}let Qt;var Kt;e({},"StatementMessageType",(()=>Qt)),(Kt=Qt||(Qt={})).ERROR="ERROR",Kt.WARNING="WARNING",Kt.MESSAGE="MESSAGE";class zt extends W{static PARAMETER_NEEDS_A_VALUE='Parameter "$" needs a value';static STEP_REGEX_PATTERN=new RegExp("Steps\\.([a-zA-Z0-9\\\\-]{1,})\\.([a-zA-Z0-9\\\\-]{1,})","g");static VERSION=1;static MAX_EXECUTION_ITERATIONS=1e7;constructor(e){if(super(),this.fd=e,this.fd.getVersion()>zt.VERSION)throw new w("Runtime is at a lower version "+zt.VERSION+" and trying to run code from version "+this.fd.getVersion()+".")}getSignature(){return this.fd}async getExecutionPlan(e){let t=new Yt;for(let r of Array.from(this.fd.getSteps().values()))t.addVertex(this.prepareStatementExecution(r,e.getFunctionRepository(),e.getSchemaRepository()));return new _(this.makeEdges(t),t)}async internalExecute(e){e.getContext()||e.setContext(new Map),e.getEvents()||e.setEvents(new Map),e.getSteps()||e.setSteps(new Map);let t=await this.getExecutionPlan(e),r=t.getT1();if(r.length)throw new w(M.format("Found these unresolved dependencies : $ ",r.map((e=>M.format("Steps.$.$",e.getT1(),e.getT2())))));let s=t.getT2().getVerticesData().filter((e=>e.getMessages().length)).map((e=>e.getStatement().getStatementName()+": \n"+e.getMessages().join(",")));if(s?.length)throw new w("Please fix the errors in the function definition before execution : \n"+s.join(",\n"));return await this.executeGraph(t.getT2(),e)}async executeGraph(e,t){let r=new J;r.addAll(e.getVerticesWithNoIncomingEdges());let s=new J;for(;!(r.isEmpty()&&s.isEmpty()||t.getEvents()?.has(N.OUTPUT));)if(await this.processBranchQue(t,r,s),await this.processExecutionQue(t,r,s),t.setCount(t.getCount()+1),t.getCount()==zt.MAX_EXECUTION_ITERATIONS)throw new w("Execution locked in an infinite loop");if(!e.isSubGraph()&&!t.getEvents()?.size)throw new w("No events raised");return new y(Array.from(t.getEvents()?.entries()??[]).flatMap((e=>e[1].map((t=>R.of(e[0],t))))))}async processExecutionQue(e,t,r){if(!t.isEmpty()){let s=t.pop();await this.allDependenciesResolvedVertex(s,e.getSteps())?await this.executeVertex(s,e,r,t,e.getFunctionRepository()):t.add(s)}}async processBranchQue(e,t,r){if(r.length){let s=r.pop();await this.allDependenciesResolvedTuples(s.getT2(),e.getSteps())?await this.executeBranch(e,t,s):r.add(s)}}async executeBranch(e,t,r){let s,n=r.getT4();do{await this.executeGraph(r.getT1(),e),s=r.getT3().next(),s&&(e.getSteps()?.has(n.getData().getStatement().getStatementName())||e.getSteps()?.set(n.getData().getStatement().getStatementName(),new Map),e.getSteps()?.get(n.getData().getStatement().getStatementName())?.set(s.getName(),await this.resolveInternalExpressions(s.getResult(),e)))}while(s&&s.getName()!=N.OUTPUT);s?.getName()==N.OUTPUT&&n.getOutVertices().has(N.OUTPUT)&&(n?.getOutVertices()?.get(N.OUTPUT)??[]).forEach((e=>t.add(e)))}async executeVertex(e,t,r,s,n){let a=e.getData().getStatement(),i=n.find(a.getNamespace(),a.getName());if(!i)throw new w(M.format("$.$ function is not found.",a.getNamespace(),a.getName()));let o=i?.getSignature().getParameters(),u=this.getArgumentsFromParametersMap(t,a,o??new Map),p=t.getContext(),h=await i.execute(new Jt(t.getFunctionRepository(),t.getSchemaRepository(),t.getExecutionId()).setValuesMap(t.getValuesMap()).setContext(p).setArguments(u).setEvents(t.getEvents()).setSteps(t.getSteps()).setStatementExecution(e.getData()).setCount(t.getCount())),l=h.next();if(!l)throw new w(M.format("Executing $ returned no events",a.getStatementName()));let c=l.getName()==N.OUTPUT;if(t.getSteps()?.has(a.getStatementName())||t.getSteps().set(a.getStatementName(),new Map),t.getSteps().get(a.getStatementName()).set(l.getName(),this.resolveInternalExpressions(l.getResult(),t)),c){let t=e.getOutVertices().get(N.OUTPUT);t&&t.forEach((e=>s.add(e)))}else{let t=e.getSubGraphOfType(l.getName()),s=this.makeEdges(t);r.push(new C(t,s,h,e))}}resolveInternalExpressions(e,t){return e?Array.from(e.entries()).map((e=>new _(e[0],this.resolveInternalExpression(e[1],t)))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map):e}resolveInternalExpression(e,t){if(n(e)||"object"!=typeof e)return e;if(e instanceof Wt){return new ft(e.getExpression()).evaluate(t.getValuesMap())}if(Array.isArray(e)){let r=[];for(let s of e)r.push(this.resolveInternalExpression(s,t));return r}if("object"==typeof e){let r={};for(let s of Object.entries(e))r[s[0]]=this.resolveInternalExpression(s[1],t);return r}}allDependenciesResolvedTuples(e,t){for(let r of e){if(!t.has(r.getT1()))return!1;if(!t.get(r.getT1())?.get(r.getT2()))return!1}return!0}allDependenciesResolvedVertex(e,t){return!e.getInVertices().size||0==Array.from(e.getInVertices()).filter((e=>{let r=e.getT1().getData().getStatement().getStatementName(),s=e.getT2();return!(t.has(r)&&t.get(r)?.has(s))})).length}getArgumentsFromParametersMap(e,t,r){return Array.from(t.getParameterMap().entries()).map((t=>{let s,n=Array.from(t[1]?.values()??[]);if(!n?.length)return new _(t[0],s);let a=r.get(t[0]);return a?(s=a.isVariableArgument()?n.map((t=>this.parameterReferenceEvaluation(e,t))).flatMap((e=>Array.isArray(e)?e:[e])):this.parameterReferenceEvaluation(e,n[0]),new _(t[0],s)):new _(t[0],void 0)})).filter((e=>!n(e.getT2()))).reduce(((e,t)=>(e.set(t.getT1(),t.getT2()),e)),new Map)}parameterReferenceEvaluation(e,t){let r;if(t.getType()==jt.VALUE)r=this.resolveInternalExpression(t.getValue(),e);else if(t.getType()==jt.EXPRESSION&&!v.isNullOrBlank(t.getExpression())){r=new ft(t.getExpression()??"").evaluate(e.getValuesMap())}return r}prepareStatementExecution(e,t,r){let s=new kt(e),a=t.find(e.getNamespace(),e.getName());if(!a)throw new w(M.format("$.$ was not available",e.getNamespace(),e.getName()));let i=new Map(a.getSignature().getParameters());for(let t of Array.from(e.getParameterMap().entries())){let e=i.get(t[0]);if(!e)continue;let a=Array.from(t[1]?.values()??[]);if(a.length||e.isVariableArgument()){if(e.isVariableArgument())for(let t of a)this.parameterReferenceValidation(s,e,t,r);else if(a.length){let t=a[0];this.parameterReferenceValidation(s,e,t,r)}i.delete(e.getParameterName())}else n(V.getDefaultValue(e.getSchema(),r))&&s.addMessage(Qt.ERROR,M.format(zt.PARAMETER_NEEDS_A_VALUE,e.getParameterName())),i.delete(e.getParameterName())}if(!n(s.getStatement().getDependentStatements()))for(let e of s.getStatement().getDependentStatements().entries())e[1]&&s.addDependency(e[0]);if(i.size)for(let e of Array.from(i.values()))e.isVariableArgument()||n(V.getDefaultValue(e.getSchema(),r))&&s.addMessage(Qt.ERROR,M.format(zt.PARAMETER_NEEDS_A_VALUE,e.getParameterName()));return s}parameterReferenceValidation(e,t,r,s){if(r){if(r.getType()==jt.VALUE){n(r.getValue())&&n(V.getDefaultValue(t.getSchema(),s))&&e.addMessage(Qt.ERROR,M.format(zt.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));let a=new J;for(a.push(new _(t.getSchema(),r.getValue()));!a.isEmpty();){let t=a.pop();if(t.getT2()instanceof Wt)this.addDependencies(e,t.getT2().getExpression());else{if(n(t.getT1())||n(t.getT1().getType()))continue;if(t.getT1().getType()?.contains(i.ARRAY)&&Array.isArray(t.getT2())){let e=t.getT1().getItems();if(!e)continue;if(e.isSingleType())for(let r of t.getT2())a.push(new _(e.getSingleSchema(),r));else{let r=t.getT2();for(let t=0;t<r.length;t++)a.push(new _(e.getTupleSchema()[t],r[t]))}}else if(t.getT1().getType()?.contains(i.OBJECT)&&"object"==typeof t.getT2()){let r=t.getT1();if(r.getName()===T.EXPRESSION.getName()&&r.getNamespace()===T.EXPRESSION.getNamespace()){let r=t.getT2();r.isExpression&&this.addDependencies(e,r.value)}else if(r.getProperties())for(let e of Object.entries(t.getT2()))r.getProperties().has(e[0])&&a.push(new _(r.getProperties().get(e[0]),e[1]))}}}}else if(r.getType()==jt.EXPRESSION)if(v.isNullOrBlank(r.getExpression()))n(V.getDefaultValue(t.getSchema(),s))&&e.addMessage(Qt.ERROR,M.format(zt.PARAMETER_NEEDS_A_VALUE,t.getParameterName()));else try{this.addDependencies(e,r.getExpression())}catch(t){e.addMessage(Qt.ERROR,M.format("Error evaluating $ : $",r.getExpression(),t))}}else n(V.getDefaultValue(t.getSchema(),s))&&e.addMessage(Qt.ERROR,M.format(zt.PARAMETER_NEEDS_A_VALUE,t.getParameterName()))}addDependencies(e,t){t&&Array.from(t.match(zt.STEP_REGEX_PATTERN)??[]).forEach((t=>e.addDependency(t)))}makeEdges(e){let t=e.getNodeMap().values(),r=[];for(let s of Array.from(t))for(let t of s.getData().getDependencies()){let n=t.indexOf(".",6),a=t.substring(6,n),i=t.indexOf(".",n+1),o=-1==i?t.substring(n+1):t.substring(n+1,i);e.getNodeMap().has(a)||r.push(new _(a,o));let u=e.getNodeMap().get(a);u&&s.addInEdgeTo(u,o)}return r}}e({},"KIRunConstants",(()=>Zt));class Zt{static NAMESPACE="namespace";static NAME="name";static ID="id";constructor(){}}e({},"Position",(()=>er));class er{static SCHEMA_NAME="Position";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(er.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["left",m.ofFloat("left")],["top",m.ofFloat("top")]]));constructor(e,t){this.left=e,this.top=t}getLeft(){return this.left}setLeft(e){return this.left=e,this}getTop(){return this.top}setTop(e){return this.top=e,this}static from(e){return e?new er(e.left,e.top):new er(-1,-1)}}e({},"FunctionDefinition",(()=>ir));e({},"Statement",(()=>sr));e({},"AbstractStatement",(()=>tr));class tr{override=!1;constructor(e){e&&(this.comment=e.comment,this.description=e.description,this.position=e.position?new er(e.position.getLeft(),e.position.getTop()):void 0,this.override=e.override)}getComment(){return this.comment}setComment(e){return this.comment=e,this}isOverride(){return this.override}setOverride(e){return this.override=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getPosition(){return this.position}setPosition(e){return this.position=e,this}}e({},"ParameterReference",(()=>rr));class rr{static SCHEMA_NAME="ParameterReference";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(rr.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["key",m.ofString("key")],["value",m.ofAny("value")],["expression",m.ofString("expression")],["type",m.ofString("type").setEnums(["EXPRESSION","VALUE"])]]));constructor(e){if(e instanceof rr){let t=e;this.key=t.key,this.type=t.type,this.value=n(t.value)?void 0:JSON.parse(JSON.stringify(t.value)),this.expression=t.expression}else this.type=e,this.key=Xt()}getType(){return this.type}setType(e){return this.type=e,this}getKey(){return this.key}setKey(e){return this.key=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}getExpression(){return this.expression}setExpression(e){return this.expression=e,this}static ofExpression(e){const t=new rr(jt.EXPRESSION).setExpression(e);return[t.getKey(),t]}static ofValue(e){const t=new rr(jt.VALUE).setValue(e);return[t.getKey(),t]}static from(e){return new rr(e.type).setValue(e.value).setExpression(e.expression).setKey(e.key)}}class sr extends tr{static SCHEMA_NAME="Statement";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(sr.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["statementName",m.ofString("statementName")],["comment",m.ofString("comment")],["description",m.ofString("description")],["namespace",m.ofString("namespace")],["name",m.ofString("name")],["dependentStatements",m.ofObject("dependentstatement").setAdditionalProperties((new c).setSchemaValue(m.ofBoolean("exists")))],["parameterMap",(new m).setName("parameterMap").setAdditionalProperties((new c).setSchemaValue(m.ofObject("parameterReference").setAdditionalProperties((new c).setSchemaValue(rr.SCHEMA))))],["position",er.SCHEMA]]));constructor(e,t,r){if(super(e instanceof sr?e:void 0),e instanceof sr){let t=e;this.statementName=t.statementName,this.name=t.name,this.namespace=t.namespace,t.parameterMap&&(this.parameterMap=new Map(Array.from(t.parameterMap.entries()).map((e=>[e[0],new Map(Array.from(e[1].entries()).map((e=>[e[0],new rr(e[1])])))])))),t.dependentStatements&&(this.dependentStatements=new Map(Array.from(t.dependentStatements.entries())))}else{if(this.statementName=e,!r||!t)throw new Error("Unknown constructor");this.namespace=t,this.name=r}}getStatementName(){return this.statementName}setStatementName(e){return this.statementName=e,this}getNamespace(){return this.namespace}setNamespace(e){return this.namespace=e,this}getName(){return this.name}setName(e){return this.name=e,this}getParameterMap(){return this.parameterMap||(this.parameterMap=new Map),this.parameterMap}setParameterMap(e){return this.parameterMap=e,this}getDependentStatements(){return this.dependentStatements??new Map}setDependentStatements(e){return this.dependentStatements=e,this}equals(e){if(!(e instanceof sr))return!1;return e.statementName==this.statementName}static ofEntry(e){return[e.statementName,e]}static from(e){return new sr(e.statementName,e.namespace,e.name).setParameterMap(new Map(Object.entries(e.parameterMap??{}).map((([e,t])=>[e,new Map(Object.entries(t??{}).map((([e,t])=>rr.from(t))).map((e=>[e.getKey(),e])))])))).setDependentStatements(new Map(Object.entries(e.dependentStatements??{}))).setPosition(er.from(e.position)).setComment(e.comment).setDescription(e.description)}}e({},"StatementGroup",(()=>nr));class nr extends tr{static SCHEMA_NAME="StatementGroup";static SCHEMA=(new m).setNamespace(s.SYSTEM).setName(nr.SCHEMA_NAME).setType(l.of(i.OBJECT)).setProperties(new Map([["statementGroupName",m.ofString("statementGroupName")],["comment",m.ofString("comment")],["description",m.ofString("description")],["position",er.SCHEMA]]));constructor(e,t=new Map){super(),this.statementGroupName=e,this.statements=t}getStatementGroupName(){return this.statementGroupName}setStatementGroupName(e){return this.statementGroupName=e,this}getStatements(){return this.statements}setStatements(e){return this.statements=e,this}static from(e){return new nr(e.statementGroupName,new Map(Object.entries(e.statements||{}).map((([e,t])=>[e,"true"==(""+t)?.toLowerCase()])))).setPosition(er.from(e.position)).setComment(e.comment).setDescription(e.description)}}const ar=(new m).setNamespace(s.SYSTEM).setName("FunctionDefinition").setProperties(new Map([["name",m.ofString("name")],["namespace",m.ofString("namespace")],["parameters",m.ofArray("parameters",T.SCHEMA)],["events",m.ofObject("events").setAdditionalProperties((new c).setSchemaValue(N.SCHEMA))],["steps",m.ofObject("steps").setAdditionalProperties((new c).setSchemaValue(sr.SCHEMA))]]));ar.getProperties()?.set("parts",m.ofArray("parts",ar));class ir extends I{static SCHEMA=ar;version=1;constructor(e){super(e)}getVersion(){return this.version}setVersion(e){return this.version=e,this}getSteps(){return this.steps??new Map}setSteps(e){return this.steps=e,this}getStepGroups(){return this.stepGroups}setStepGroups(e){return this.stepGroups=e,this}getParts(){return this.parts}setParts(e){return this.parts=e,this}static from(e){return e?new ir(e.name).setSteps(new Map(Object.values(e.steps??{}).filter((e=>!!e)).map((e=>[e.statementName,sr.from(e)])))).setStepGroups(new Map(Object.values(e.stepGroups??{}).filter((e=>!!e)).map((e=>[e.statementGroupName,nr.from(e)])))).setParts(Array.from(e.parts??[]).filter((e=>!!e)).map((e=>ir.from(e)))).setVersion(e.version??1).setEvents(new Map(Object.values(e.events??{}).filter((e=>!!e)).map((e=>[e.name,N.from(e)])))).setParameters(new Map(Object.values(e.parameters??{}).filter((e=>!!e)).map((e=>[e.parameterName,T.from(e)])))):new ir("unknown")}}e({},"Argument",(()=>or));class or{argumentIndex=0;constructor(e,t,r){this.argumentIndex=e,this.name=t,this.value=r}getArgumentIndex(){return this.argumentIndex}setArgumentIndex(e){return this.argumentIndex=e,this}getName(){return this.name}setName(e){return this.name=e,this}getValue(){return this.value}setValue(e){return this.value=e,this}static of(e,t){return new or(0,e,t)}}var ur={};t(ur,Ze),t(ur,st),t(ur,at),t(ur,ot),t(ur,et);var pr={};t(pr,oe),t(pr,pe),t(pr,le),t(pr,me),t(pr,fe),t(pr,Te),t(pr,Oe),t(pr,ne),t(pr,Se),t(pr,Ne),t(pr,ye),t(pr,xe),t(pr,ve),t(pr,_e),t(pr,Ce),t(pr,Ue),t(pr,ke),t(pr,Fe),t(pr,Ye),t(pr,qe),t(pr,We),t(pr,Je),t(pr,Ke),t(pr,se);export{O as KIRunSchemaRepository,Ut as KIRunFunctionRepository,be as PrimitiveUtil,Mt as MapUtil,vt as MapEntry,n as isNullValue,J as LinkedList,K as StringBuilder,M as StringFormatter,v as StringUtil,_ as Tuple2,L as Tuple3,C as Tuple4,Bt as ArrayUtil,Be as deepEqual,kt as StatementExecution,Dt as StatementMessage,x as ContextElement,Gt as ContextTokenValueExtractor,Ft as OutputMapTokenValueExtractor,Ht as ArgumentsTokenValueExtractor,$t as GraphVertex,Yt as ExecutionGraph,zt as KIRuntime,Qt as StatementMessageType,Jt as FunctionExecutionParameters,re as Expression,pt as TokenValueExtractor,lt as LiteralTokenValueExtractor,ft as ExpressionEvaluator,te as Operation,Z as ExpressionToken,z as ExpressionEvaluationException,ee as ExpressionTokenValue,W as AbstractFunction,s as Namespaces,Wt as JsonExpression,c as AdditionalPropertiesType,m as Schema,G as NumberValidator,D as BooleanValidator,k as NullValidator,B as ArrayValidator,U as AnyOfAllOfOneOfValidator,H as StringValidator,F as ObjectValidator,$ as SchemaValidator,b as SchemaValidationException,g as SchemaReferenceException,Y as TypeValidator,a as ArraySchemaType,h as SingleType,l as TypeUtil,p as MultipleType,u as Type,i as SchemaType,V as SchemaUtil,S as StringFormat,Ct as HybridRepository,Zt as KIRunConstants,T as Parameter,y as FunctionOutput,er as Position,ir as FunctionDefinition,jt as ParameterReferenceType,R as EventResult,tr as AbstractStatement,sr as Statement,nr as StatementGroup,I as FunctionSignature,N as Event,f as ParameterType,or as Argument,rr as ParameterReference,X as ExecutionException,w as KIRuntimeException,rt as ArithmeticUnaryMinusOperator,nt as ArithmeticUnaryPlusOperator,it as BitwiseComplementOperator,ut as LogicalNotOperator,tt as UnaryOperator,ue as ArithmeticAdditionOperator,he as ArithmeticDivisionOperator,ce as ArithmeticIntegerDivisionOperator,ge as ArithmeticModulusOperator,Ee as ArithmeticMultiplicationOperator,Ae as ArithmeticSubtractionOperator,we as ArrayOperator,ae as BinaryOperator,de as BitwiseAndOperator,Re as BitwiseLeftShiftOperator,Ie as BitwiseOrOperator,Me as BitwiseRightShiftOperator,Pe as BitwiseUnsignedRightShiftOperator,Le as BitwiseXorOperator,Ve as LogicalAndOperator,De as LogicalEqualOperator,Ge as LogicalGreaterThanEqualOperator,He as LogicalGreaterThanOperator,$e as LogicalLessThanEqualOperator,Xe as LogicalNotEqualOperator,je as LogicalLessThanOperator,Qe as LogicalOrOperator,ze as ObjectOperator,ie as LogicalNullishCoalescingOperator,mt as ConditionalTernaryOperator};
2
2
  //# sourceMappingURL=module.js.map