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