Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@evergis/condition

Package Overview
Dependencies
Maintainers
5
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/condition - npm Package Compare versions

Comparing version 1.2.10 to 1.2.11

14

dist/condition.cjs.development.js

@@ -26,5 +26,2 @@ 'use strict';

if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;

@@ -63,5 +60,2 @@ }

});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);

@@ -165,4 +159,2 @@ }

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -201,3 +193,3 @@

function _get() {
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {

@@ -213,3 +205,3 @@ _get = Reflect.get;

if (desc.get) {
return desc.get.call(arguments.length < 3 ? target : receiver);
return desc.get.call(receiver);
}

@@ -221,3 +213,3 @@

return _get.apply(this, arguments);
return _get(target, property, receiver || target);
}

@@ -224,0 +216,0 @@

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("date-fns");function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,n){return(a=p()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function f(e){var t=p();return function(){var n,r=u(e);if(t){var o=u(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return h(this,n)}}function y(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}function k(){return(k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=y(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}}).apply(this,arguments)}(e=exports.TokenType||(exports.TokenType={}))[e.Number=0]="Number",e[e.Identifier=1]="Identifier",e[e.DynamicIdentifier=2]="DynamicIdentifier",e[e.String=3]="String",e[e.Date=4]="Date",e[e.TimeSpan=5]="TimeSpan",e[e.Terminal=6]="Terminal",e[e.EndOfString=7]="EndOfString",e[e.Null=8]="Null",e[e.ArIn=9]="ArIn",e[e.ArEq=10]="ArEq",e[e.ArNotEq=11]="ArNotEq",e[e.ArGr=12]="ArGr",e[e.ArGre=13]="ArGre",e[e.ArLs=14]="ArLs",e[e.ArLse=15]="ArLse",e[e.BoolNot=16]="BoolNot",e[e.BoolAnd=17]="BoolAnd",e[e.BoolOr=18]="BoolOr",e[e.ArPlus=19]="ArPlus",e[e.ArMinus=20]="ArMinus",e[e.ArMul=21]="ArMul",e[e.ArDiv=22]="ArDiv",e[e.ExprOpen=23]="ExprOpen",e[e.ExprClose=24]="ExprClose",e[e.ArrayOpen=25]="ArrayOpen",e[e.ArrayClose=26]="ArrayClose",e[e.Separator=27]="Separator",e[e.Function=28]="Function",e[e.Between=29]="Between",e[e.Outside=30]="Outside";const T={start:0,end:0};let v=o((function e(t,r,o){void 0===o&&(o=T),n(this,e),this.type=t,this.value=r,this.position=o})),x=function(){function e(t,r,o){void 0===r&&(r=null),void 0===o&&(o=null),n(this,e),this.token=t,this.left=r,this.right=o}return o(e,[{key:"accept",value:function(e){return e.visit(this)}}]),e}(),d=function(e){s(r,x);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();d.TOKENS=[exports.TokenType.String,exports.TokenType.Number,exports.TokenType.DynamicIdentifier,exports.TokenType.Date];let E=function(e){s(r,x);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();E.TOKENS=[exports.TokenType.Identifier];let g=function(e){s(r,x);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();g.TOKENS=[exports.TokenType.ArEq,exports.TokenType.ArNotEq,exports.TokenType.ArGr,exports.TokenType.ArGre,exports.TokenType.ArLs,exports.TokenType.ArLse,exports.TokenType.ArPlus,exports.TokenType.ArMinus,exports.TokenType.ArDiv,exports.TokenType.ArMul,exports.TokenType.Between,exports.TokenType.Outside];let A=function(e){s(r,x);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();A.TOKENS=[exports.TokenType.BoolAnd,exports.TokenType.BoolOr];let O=function(e){s(r,x);var t=f(r);function r(e,o,i,s){var u;return void 0===i&&(i=null),void 0===s&&(s=null),n(this,r),(u=t.call(this,e,i,s)).func=o,u}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();O.TOKENS=[exports.TokenType.Function];const N=new Map;N.set(exports.TokenType.ExprOpen,0),N.set(exports.TokenType.ExprClose,0),N.set(exports.TokenType.BoolAnd,1),N.set(exports.TokenType.BoolOr,1),N.set(exports.TokenType.ArEq,2),N.set(exports.TokenType.ArNotEq,2),N.set(exports.TokenType.ArGr,2),N.set(exports.TokenType.ArGre,2),N.set(exports.TokenType.ArLs,2),N.set(exports.TokenType.ArLse,2),N.set(exports.TokenType.ArPlus,3),N.set(exports.TokenType.ArMinus,3),N.set(exports.TokenType.ArMul,4),N.set(exports.TokenType.ArDiv,4),N.set(exports.TokenType.Function,5),N.set(exports.TokenType.Between,5),N.set(exports.TokenType.Outside,5);let b=function(e){s(r,l(Error));var t=f(r);function r(e,o){var i;void 0===o&&(o=T),n(this,r),(i=t.call(this)).position=o;const{start:s,end:u}=o;return i.message=i.name+"(cимвол: "+(s+1)+", "+(u+1)+"):"+e+".",i}return o(r)}(),m=function(e){s(r,b);var t=f(r);function r(e,o){var i;return void 0===o&&(o=T),n(this,r),(i=t.call(this,e,o)).position=o,i.name="LintError",i}return o(r)}();const w=e=>e[e.length-1],S=e=>d.is(e)||E.is(e),B=e=>g.is(e)||A.is(e)||O.is(e);let C=function(e){s(r,b);var t=f(r);function r(e,o){var i;return void 0===o&&(o=T),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionAst",i}return o(r)}(),L=function(){function e(){n(this,e)}return o(e,[{key:"visit",value:function(e){return e instanceof A?this.visitBoolOpNode(e):e instanceof g?this.visitOpNode(e):e instanceof d?this.visitValueNode(e):e instanceof E?this.visitAttributeNode(e):e instanceof O?this.visitFunctionNode(e):void 0}},{key:"visitBoolOpNode",value:function(e){}},{key:"visitOpNode",value:function(e){}},{key:"visitValueNode",value:function(e){}},{key:"visitAttributeNode",value:function(e){}},{key:"visitFunctionNode",value:function(e){}}]),e}(),M=function(e){s(r,L);var t=f(r);function r(e){var o;return n(this,r),(o=t.call(this)).attributes=e,o}return o(r,[{key:"visitBoolOpNode",value:function(e){k(u(r.prototype),"visitBoolOpNode",this).call(this,e),this.checkBoolOpNode(e),this.acceptLeafs(e)}},{key:"visitOpNode",value:function(e){k(u(r.prototype),"visitOpNode",this).call(this,e),this.checkOpNode(e),this.acceptLeafs(e)}},{key:"visitValueNode",value:function(e){k(u(r.prototype),"visitValueNode",this).call(this,e),this.checkLeafNode(e)}},{key:"visitAttributeNode",value:function(e){k(u(r.prototype),"visitAttributeNode",this).call(this,e),this.checkLeafNode(e),this.checkAttributeNode(e)}},{key:"visitFunctionNode",value:function(e){k(u(r.prototype),"visitFunctionNode",this).call(this,e),this.checkLeafNode(e),this.checkFunctionNode(e)}},{key:"checkBoolOpNode",value:function(e){const t="Ожидается выражение вида 'a == 2 "+e.token.value+" b == 3'";this.isOperationNode(e.left)||this.Error(t,e.token),this.isOperationNode(e.right)||this.Error(t,e.token)}},{key:"checkOpNode",value:function(e){e.left&&e.right||this.Error("'"+e.token.value+"' ожидает выражение",e.token)}},{key:"checkLeafNode",value:function(e){if(e.left){const{token:t}=e.left;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}if(e.right){const{token:t}=e.right;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}}},{key:"checkAttributeNode",value:function(e){e.token.value&&void 0!==this.attributes[e.token.value]||this.Error("Атрибут '"+e.token.value+"' не найден в атрибутах слоя",e.token)}},{key:"checkFunctionNode",value:function(e){const t=e.func.check(this.attributes);t instanceof Error&&this.Error(t.message,e.token)}},{key:"Error",value:function(e,t){const{position:n}=t;throw new m(e,n)}},{key:"acceptLeafs",value:function(e){return{x:e.left&&e.left.accept(this),y:e.right&&e.right.accept(this)}}},{key:"isOperationNode",value:function(e){return e instanceof A||e instanceof g}}]),r}(),P=function(e){s(r,M);var t=f(r);function r(e,o){var i;return n(this,r),(i=t.call(this,e)).attributes=e,i.silent=!(!o||!o.silent),i}return o(r,[{key:"visitBoolOpNode",value:function(e){this.silent||k(u(r.prototype),"visitBoolOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);return e.token.type===exports.TokenType.BoolAnd?t&&n:t||n}},{key:"visitOpNode",value:function(e){this.silent||k(u(r.prototype),"visitOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);switch(e.token.type){case exports.TokenType.ArEq:return t===n;case exports.TokenType.ArNotEq:return t!==n;case exports.TokenType.ArGre:return t>=n;case exports.TokenType.ArLse:return t<=n;case exports.TokenType.ArGr:return t>n;case exports.TokenType.ArLs:return t<n;case exports.TokenType.ArPlus:return t+n;case exports.TokenType.ArMinus:return t-n;case exports.TokenType.ArMul:return t*n;case exports.TokenType.ArDiv:return t/n;default:return!1}}},{key:"visitValueNode",value:function(e){return this.silent||k(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return this.silent||k(u(r.prototype),"visitAttributeNode",this).call(this,e),this.attributes[e.token.value]}},{key:"visitFunctionNode",value:function(e){return this.silent||k(u(r.prototype),"visitFunctionNode",this).call(this,e),e.func.calc(this.attributes)}}]),r}(),D=function(){function e(t){n(this,e),this.args=t}return o(e,[{key:"calc",value:function(e){return 0}},{key:"evaluateArguments",value:function(e){return this.args.map(t=>{if(t instanceof g)return t.accept(new P(e));if("string"==typeof t.value){if("number"!=typeof e[t.value]){const{position:e}=t;throw new m("Аргумент функции должен быть числовым типом",e)}return e[t.value]}return t.value})}},{key:"check",value:function(e,t){return this.evaluateArguments(e).length!==t?new Error("Передано неверное количество аргументов"):null}}]),e}(),F=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sin(t).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();F.ArgsCount=1,F.Name="sin";let I=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.asin(t).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();I.ArgsCount=1,I.Name="arcsin";let _=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.cos(t).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();_.ArgsCount=1,_.Name="cos";let R=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.acos(t).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();R.ArgsCount=1,R.Name="arccos";let U=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t,n]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan2(t,n).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();U.ArgsCount=2,U.Name="arctan2";let K=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.tan(t).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();K.ArgsCount=1,K.Name="tan";let q=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan(t).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();q.ArgsCount=1,q.Name="arctan";let j=function(e){s(r,D);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=k(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sqrt(t).toFixed(3)}},{key:"check",value:function(e){return k(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();j.ArgsCount=1,j.Name="sqrt";const G={[F.Name]:F,[I.Name]:I,[_.Name]:_,[R.Name]:R,[K.Name]:K,[q.Name]:q,[U.Name]:U,[j.Name]:j},V=e=>t.isValid(e)?e:"#'"+e+"'";let W=function(){function e(t){n(this,e),this.tokens=t,this.tree=null,this.currentPosition=0}return o(e,[{key:"value",get:function(){if(this.tree)return this.tree;this.tokens=function(e){let t=[];const n=[];for(const i of e){if(S(i)&&t.push(i),B(i)){if(![exports.TokenType.Between,exports.TokenType.Outside].includes(i.type))for(;w(n)&&(r=w(n),o=i,N.get(r.type)>N.get(o.type))&&w(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());n.push(i)}if(i.type===exports.TokenType.ExprOpen&&n.push(i),i.type===exports.TokenType.ExprClose){const e=i;for(;w(n)&&w(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());if(0===n.length)throw new m("Пропущена открывающая скобка",e.position);w(n).type===exports.TokenType.ExprOpen&&n.pop()}}var r,o;if(n.length){const e=w(n);if(e.type===exports.TokenType.ExprOpen)throw new m("Пропущена закрывающая скобка",e.position);t=[...t,...n.reverse()]}return t}(this.tokens);const e=[];for(;this.currentPosition<this.tokens.length;this.nextToken()){if(d.is(this.currentToken)&&e.push(new d(this.currentToken)),E.is(this.currentToken)&&e.push(new E(this.currentToken)),O.is(this.currentToken)){const t=G[this.currentToken.value];t||this.Error("Функция '"+this.currentToken.value+"' не определена",this.currentToken);const n=[];for(let r=0;r<t.ArgsCount;r++){const t=e.pop()||null;t instanceof g?n.push(t):t&&t.token&&n.push(t.token)}const r=new t(n);e.push(new O(this.currentToken,r))}if(g.is(this.currentToken)){const r=new g(this.currentToken);if([exports.TokenType.Between,exports.TokenType.Outside].includes(this.currentToken.type)){var t,n;const o=e.pop()||null,s=e.pop()||null;r.left=e.pop()||null,r.right=new d(i({},this.currentToken,{value:V(null==s?void 0:s.token.value)+" - "+V(null==o?void 0:o.token.value),position:{start:(null==s||null==(t=s.token.position)?void 0:t.start)||0,end:(null==o||null==(n=o.token.position)?void 0:n.end)||0}}))}else e.length>1&&(r.right=e.pop()||null),r.left=e.pop()||null;e.push(r)}if(A.is(this.currentToken)){const t=new A(this.currentToken);e.length>1&&(t.right=e.pop()||null),t.left=e.pop()||null,e.push(t)}}return this.tree=e.pop()||null,this.flashStack(e),this.checkRoot(),this.tree}},{key:"nextToken",value:function(){this.currentPosition+=1}},{key:"currentToken",get:function(){return this.tokens[this.currentPosition]}},{key:"checkRoot",value:function(){}},{key:"flashStack",value:function(e){if(this.tree&&e.length)for(;e.length;){const t=e.pop();t&&this.insert(this.tree,t)}}},{key:"insert",value:function(e,t){null!==e.right?this.insert(e.right,t):e.right=t}},{key:"Error",value:function(e,t){const{position:n}=t,{start:r,end:o}=n;throw new C(e,{start:r,end:o})}}]),e}(),H=function(e){s(r,b);var t=f(r);function r(e,o){var i;return void 0===o&&(o=T),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionTokenizer",i}return o(r)}(),z=function(){function e(t,r,o){void 0===o&&(o=[]),n(this,e),this.acceptMap=new Map,this.value=t,this.tokenType=r,o.map(e=>this.acceptMap.set(e.value,e))}return o(e,[{key:"accept",value:function(e){return this.acceptMap.get(e)||null}}]),e}(),Q=function(){function e(){n(this,e)}return o(e,null,[{key:"isChar",value:function(e){return"string"==typeof e&&1===e.length}},{key:"isDigit",value:function(e){return this.isChar(e)&&/\d/.test(e)}},{key:"isLetter",value:function(e){return this.isChar(e)&&/\w/.test(e)}},{key:"isWhiteSpace",value:function(t){return this.isChar(t)&&t===e.WHITE_SPACE}},{key:"isLetterOrDigit",value:function(t){return e.isLetter(t)||e.isDigit(t)}},{key:"isUnderscore",value:function(t){return e.isChar(t)&&t===e.UNDERSCORE}},{key:"isFloating",value:function(t){return e.isChar(t)&&("f"===t||"F"===t)}},{key:"escapeSpecChars",value:function(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\t/g,"\\\\t").replace(/\v/g,"\\\\v").replace(/\0/g,"\\\\0").replace(/\f/g,"\\\\f").replace(/\n/g,"\\\\n").replace(/\r/g,"\\\\r")}},{key:"unEscapeSpecChars",value:function(e){return e.replace(/\\'/g,"'").replace(/\\"/g,'"').replace(/\\\\/g,"\\").replace(/\\\\t/g,"\t").replace(/\\\\v/g,"\v").replace(/\\\\0/g,"\0").replace(/\\\\f/g,"\f").replace(/\\\\n/g,"\n").replace(/\\\\r/g,"\r")}}]),e}();function Y(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}Q.LEFT_BRACKET="{",Q.OPEN_BRACKET="(",Q.BETWEEN="between",Q.OUTSIDE="!between",Q.SINGLE_QUOTE="'",Q.DOUBLE_QUOTE='"',Q.HASH_SYMBOL="#",Q.RIGHT_BRACKET="}",Q.CLOSE_BRACKET=")",Q.BACK_SLASH="\\",Q.WHITE_SPACE=" ",Q.UNDERSCORE="_",Q.PERCENTAGE="%",Q.POINT=".";let J=o((function e(){n(this,e)}));J.sToMs=e=>1e3*e,J.mToMs=e=>60*J.sToMs(e),J.hToMs=e=>60*J.mToMs(e),J.dToMs=e=>24*J.hToMs(e),J.mthToMs=e=>30*J.dToMs(e),J.yToMs=e=>365*J.mthToMs(e);const X=new z("",exports.TokenType.Null,[new z(Q.BETWEEN,exports.TokenType.Between),new z(Q.OUTSIDE,exports.TokenType.Outside),new z(">",exports.TokenType.ArGr,[new z("=",exports.TokenType.ArGre)]),new z("<",exports.TokenType.ArLs,[new z("=",exports.TokenType.ArLse)]),new z("!",exports.TokenType.BoolNot,[new z("=",exports.TokenType.ArNotEq)]),new z("&",exports.TokenType.Null,[new z("&",exports.TokenType.BoolAnd)]),new z("=",exports.TokenType.ArEq,[new z("=",exports.TokenType.ArEq)]),new z("|",exports.TokenType.Null,[new z("|",exports.TokenType.BoolOr)]),new z("+",exports.TokenType.ArPlus),new z("-",exports.TokenType.ArMinus),new z("*",exports.TokenType.ArMul),new z("/",exports.TokenType.ArDiv),new z("(",exports.TokenType.ExprOpen),new z(")",exports.TokenType.ExprClose),new z("[",exports.TokenType.ArrayOpen),new z("]",exports.TokenType.ArrayClose),new z(",",exports.TokenType.Separator)]);let Z=function(){function e(t){n(this,e),this.start=0,this.currentPosition=0,this.tokens=[],this.input=t||""}return o(e,[{key:"tokenize",value:function(){if(this.isEndOfString())return this.tokens;for(;;){const e=this.nextToken();if(!e)break;if(this.tokens.push(e),this.tokens.length>1e3&&this.Error("Привышен лимит запроса: 1000"),e.type===exports.TokenType.EndOfString)break}return this.tokens}},{key:"nextToken",value:function(){for(;this.currentPosition<this.input.length;this.nextSymbol()){if(Q.isWhiteSpace(this.current))continue;if(this.resetStart(),this.input.slice(this.currentPosition).startsWith(Q.OUTSIDE))return this.currentPosition+=Q.OUTSIDE.length,this.createToken(exports.TokenType.Outside,Q.OUTSIDE);if(this.input.slice(this.currentPosition).startsWith(Q.BETWEEN))return this.currentPosition+=Q.BETWEEN.length,this.createToken(exports.TokenType.Between,Q.BETWEEN);const e=X.accept(this.current);if(null!==e)return this.captureSpecial(e);if(Q.isDigit(this.current)||this.current===Q.POINT)return this.captureNumber();if(Q.isLetter(this.current)||Q.isUnderscore(this.current))return this.captureIdentifier();if(this.current===Q.LEFT_BRACKET)return this.captureDynamicIdentifier();if(this.current===Q.DOUBLE_QUOTE||this.current===Q.SINGLE_QUOTE)return this.captureString();if(this.current===Q.HASH_SYMBOL)return this.captureDate()}return this.resetStart(),this.createToken(exports.TokenType.EndOfString)}},{key:"resetStart",value:function(){this.start=this.currentPosition}},{key:"createToken",value:function(e,t){void 0===t&&(t=null);const n=this.currentPosition-(e===exports.TokenType.EndOfString?0:1);return new v(e,t,{start:this.start,end:n})}},{key:"nextSymbol",value:function(){this.currentPosition+=1}},{key:"current",get:function(){return this.input[this.currentPosition]}},{key:"captureSpecial",value:function(e){let t=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol()){const n=e.accept(this.current);if(null===n||n.tokenType===exports.TokenType.Null)break;t+=this.current,e=n}return this.current&&Q.isDigit(this.current)&&e.tokenType===exports.TokenType.ArMinus?this.createToken(exports.TokenType.Number,-(this.captureNumber().value||0)):(e.tokenType===exports.TokenType.Null&&this.Error("Неизвеcтная операция '"+e.value+"'"),this.createToken(e.tokenType,t))}},{key:"captureNumber",value:function(){let e="",t=!1;for(;this.currentPosition<this.input.length&&!Q.isWhiteSpace(this.current)&&(Q.isDigit(this.current)||Q.isFloating(this.current)||this.current===Q.POINT);this.nextSymbol())this.current===Q.POINT&&(t=!0),e+=this.current;t&&Q.isFloating(e[e.length-1])&&(e=e.slice(0,-1));const n=parseFloat(e);return Number.isNaN(n)&&this.Error("Неверный числовой формат: "+e),this.createToken(exports.TokenType.Number,n)}},{key:"captureIdentifier",value:function(){let e="";for(;this.currentPosition<this.input.length&&(Q.isLetterOrDigit(this.current)||Q.isUnderscore(this.current));this.nextSymbol())e+=this.current;if(this.current===Q.OPEN_BRACKET){const t=this.tokens.some(e=>e.type===exports.TokenType.Between),n=this.tokens.some(e=>e.type===exports.TokenType.Outside);return this.createToken(n?exports.TokenType.Outside:t?exports.TokenType.Between:exports.TokenType.Function,e)}return"true"===e||"True"===e||"TRUE"===e?this.createToken(exports.TokenType.Terminal,!0):"false"===e||"False"===e||"FALSE"===e?this.createToken(exports.TokenType.Terminal,!1):"in"===e||"IN"===e?this.createToken(exports.TokenType.ArIn):this.createToken(exports.TokenType.Identifier,e)}},{key:"captureDynamicIdentifier",value:function(){this.nextSymbol();let e="";for(;this.currentPosition<this.input.length;this.nextSymbol()){if(this.current===Q.RIGHT_BRACKET){this.nextSymbol();break}e+=this.current}return this.createToken(exports.TokenType.DynamicIdentifier,"null"===e||"Null"===e||"NULL"===e?null:e)}},{key:"captureString",value:function(){let e="",t=!1;const n=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol())if(t||this.current!==Q.BACK_SLASH){if(!t&&this.current===n)return this.nextSymbol(),this.createToken(exports.TokenType.String,e);e+=this.current,t=!1}else t=!0;this.Error("Открытая строка")}},{key:"captureDate",value:function(){if(this.nextSymbol(),![Q.SINGLE_QUOTE,Q.DOUBLE_QUOTE,Q.BACK_SLASH].includes(this.current))return this.captureTimeSpan();const e=this.captureString();return this.createToken(exports.TokenType.Date,e.value)}},{key:"captureTimeSpan",value:function(){let e="";for(;this.currentPosition<this.input.length&&Q.isDigit(this.current);this.nextSymbol())e+=this.current;const t=parseFloat(e);Number.isNaN(t)&&this.Error("Неверный формат числа для значения timespan: "+e+". Должно быть положительным целочисленным значением."),Q.isLetter(this.current)||this.Error("Для значения задана неверная единица измерения "+this.current);let n="";for(;Q.isLetter(this.current);)n+=this.current,this.nextSymbol();let r=0;switch(n){case"ms":r=t;break;case"s":r=J.sToMs(t);break;case"m":r=J.mToMs(t);break;case"h":r=J.hToMs(t);break;case"d":r=J.dToMs(t);break;case"mth":r=J.mthToMs(t);break;case"y":r=J.yToMs(t);break;default:this.Error("Неверная единица измерения для timespan: "+n)}return this.createToken(exports.TokenType.TimeSpan,r)}},{key:"isEndOfString",value:function(){return this.tokens.length>0&&this.tokens[this.tokens.length-1].type===exports.TokenType.EndOfString}},{key:"Error",value:function(e){throw new H(e,{start:this.start,end:this.start})}}]),e}(),$=function(e){s(r,L);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"visitBoolOpNode",value:function(e){k(u(r.prototype),"visitBoolOpNode",this).call(this,e);const t=e.left&&e.left.accept(this),n=e.right&&e.right.accept(this);return e.left instanceof A&&e.right instanceof A?(this.checkBoolOperations(e.token.type,[...t.boolOperations,...n.boolOperations]),{boolOperations:[...t.boolOperations,e.token.type,...n.boolOperations],expressions:[...t.expressions,...n.expressions]}):e.right instanceof A?(this.checkBoolOperations(e.token.type,n.boolOperations),{boolOperations:[e.token.type,...n.boolOperations],expressions:[t,...n.expressions]}):e.left instanceof A?(this.checkBoolOperations(e.token.type,t.boolOperations),{boolOperations:[...t.boolOperations,e.token.type],expressions:[...t.expressions,n]}):{boolOperations:[e.token.type],expressions:[t,n]}}},{key:"visitOpNode",value:function(e){var t;k(u(r.prototype),"visitOpNode",this).call(this,e),this.checkExpressionSimple(e);const n=e.left&&e.left.accept(this),o=e.right&&(null==(t=e.right)?void 0:t.accept(this));return{attribute:n,operation:e.token.type,value:o}}},{key:"visitValueNode",value:function(e){return k(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return k(u(r.prototype),"visitAttributeNode",this).call(this,e),e.token.value}},{key:"checkBoolOperations",value:function(e,t){if(t.some(t=>t!==e))throw new m("Выражение должно использовать одинаковые булевы операторы")}},{key:"checkExpressionSimple",value:function(e){if(!(e.left instanceof E&&e.right instanceof d||e.right instanceof d))throw new m("Выражение должно быть простым")}}]),r}();const ee=e=>Y(e)&&"boolOperations"in e,te=e=>Y(e)&&"attribute"in e;let ne=function(){function e(t){n(this,e),this.result=null,this.tokenizer=new Z(t)}return o(e,[{key:"value",get:function(){if(this.result)return this.result;try{const e=this.tokenizer.tokenize(),t=new W(e).value,n=t&&t.accept(new $);return this.result=ee(n)?n:te(n)?{boolOperations:[],expressions:[n]}:{boolOperations:[],expressions:[]},this.result}catch(e){return e}}}]),e}(),re=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"evaluate",value:function(e,t){try{const n=new Z(e).tokenize(),r=new W(n).value;return r&&r.accept(new P(this.attributes,t))}catch(e){return e}}}]),e}(),oe=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"lint",value:function(e){try{const t=new Z(e).tokenize(),n=new W(t).value;return n&&n.accept(new M(this.attributes)),null}catch(e){return e}}}]),e}();exports.ArcCos=R,exports.ArcSin=I,exports.ArcTan=q,exports.ArcTan2=U,exports.AttributeNode=E,exports.BoolOperationNode=A,exports.Char=Q,exports.ConditionEvaluator=re,exports.ConditionInterpreter=ne,exports.ConditionLinter=oe,exports.ConditionVisitor=$,exports.Cos=_,exports.DEFAULT_TOKEN_POSITION=T,exports.EqlFunction=D,exports.EqlFunctions=G,exports.EvaluateVisitor=P,exports.ExpressionAst=W,exports.ExpressionAstError=C,exports.ExpressionNode=x,exports.ExpressionTokenizer=Z,exports.ExpressionTokenizerError=H,exports.ExpressionVisitor=L,exports.FunctionNode=O,exports.LintError=m,exports.LintVisitor=M,exports.OperationNode=g,exports.Sin=F,exports.Sqrt=j,exports.Tan=K,exports.Time=J,exports.Token=v,exports.TokenError=b,exports.ValueNode=d,exports.isBoolResult=ee,exports.isExpression=te,exports.isObject=Y;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("date-fns");function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,n){return(a=p()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){var t=p();return function(){var n,r=u(e);if(t){var o=u(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return h(this,n)}}function y(e,t,n){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}(e=exports.TokenType||(exports.TokenType={}))[e.Number=0]="Number",e[e.Identifier=1]="Identifier",e[e.DynamicIdentifier=2]="DynamicIdentifier",e[e.String=3]="String",e[e.Date=4]="Date",e[e.TimeSpan=5]="TimeSpan",e[e.Terminal=6]="Terminal",e[e.EndOfString=7]="EndOfString",e[e.Null=8]="Null",e[e.ArIn=9]="ArIn",e[e.ArEq=10]="ArEq",e[e.ArNotEq=11]="ArNotEq",e[e.ArGr=12]="ArGr",e[e.ArGre=13]="ArGre",e[e.ArLs=14]="ArLs",e[e.ArLse=15]="ArLse",e[e.BoolNot=16]="BoolNot",e[e.BoolAnd=17]="BoolAnd",e[e.BoolOr=18]="BoolOr",e[e.ArPlus=19]="ArPlus",e[e.ArMinus=20]="ArMinus",e[e.ArMul=21]="ArMul",e[e.ArDiv=22]="ArDiv",e[e.ExprOpen=23]="ExprOpen",e[e.ExprClose=24]="ExprClose",e[e.ArrayOpen=25]="ArrayOpen",e[e.ArrayClose=26]="ArrayClose",e[e.Separator=27]="Separator",e[e.Function=28]="Function",e[e.Between=29]="Between",e[e.Outside=30]="Outside";const k={start:0,end:0};let T=o((function e(t,r,o){void 0===o&&(o=k),n(this,e),this.type=t,this.value=r,this.position=o})),v=function(){function e(t,r,o){void 0===r&&(r=null),void 0===o&&(o=null),n(this,e),this.token=t,this.left=r,this.right=o}return o(e,[{key:"accept",value:function(e){return e.visit(this)}}]),e}(),x=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();x.TOKENS=[exports.TokenType.String,exports.TokenType.Number,exports.TokenType.DynamicIdentifier,exports.TokenType.Date];let d=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();d.TOKENS=[exports.TokenType.Identifier];let E=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();E.TOKENS=[exports.TokenType.ArEq,exports.TokenType.ArNotEq,exports.TokenType.ArGr,exports.TokenType.ArGre,exports.TokenType.ArLs,exports.TokenType.ArLse,exports.TokenType.ArPlus,exports.TokenType.ArMinus,exports.TokenType.ArDiv,exports.TokenType.ArMul,exports.TokenType.Between,exports.TokenType.Outside];let A=function(e){s(r,v);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();A.TOKENS=[exports.TokenType.BoolAnd,exports.TokenType.BoolOr];let g=function(e){s(r,v);var t=f(r);function r(e,o,i,s){var u;return void 0===i&&(i=null),void 0===s&&(s=null),n(this,r),(u=t.call(this,e,i,s)).func=o,u}return o(r,null,[{key:"is",value:function(e){return r.TOKENS.includes(e.type)}}]),r}();g.TOKENS=[exports.TokenType.Function];const O=new Map;O.set(exports.TokenType.ExprOpen,0),O.set(exports.TokenType.ExprClose,0),O.set(exports.TokenType.BoolAnd,1),O.set(exports.TokenType.BoolOr,1),O.set(exports.TokenType.ArEq,2),O.set(exports.TokenType.ArNotEq,2),O.set(exports.TokenType.ArGr,2),O.set(exports.TokenType.ArGre,2),O.set(exports.TokenType.ArLs,2),O.set(exports.TokenType.ArLse,2),O.set(exports.TokenType.ArPlus,3),O.set(exports.TokenType.ArMinus,3),O.set(exports.TokenType.ArMul,4),O.set(exports.TokenType.ArDiv,4),O.set(exports.TokenType.Function,5),O.set(exports.TokenType.Between,5),O.set(exports.TokenType.Outside,5);let N=function(e){s(r,l(Error));var t=f(r);function r(e,o){var i;void 0===o&&(o=k),n(this,r),(i=t.call(this)).position=o;const{start:s,end:u}=o;return i.message=i.name+"(cимвол: "+(s+1)+", "+(u+1)+"):"+e+".",i}return o(r)}(),b=function(e){s(r,N);var t=f(r);function r(e,o){var i;return void 0===o&&(o=k),n(this,r),(i=t.call(this,e,o)).position=o,i.name="LintError",i}return o(r)}();const m=e=>e[e.length-1],S=e=>x.is(e)||d.is(e),w=e=>E.is(e)||A.is(e)||g.is(e);let B=function(e){s(r,N);var t=f(r);function r(e,o){var i;return void 0===o&&(o=k),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionAst",i}return o(r)}(),C=function(){function e(){n(this,e)}return o(e,[{key:"visit",value:function(e){return e instanceof A?this.visitBoolOpNode(e):e instanceof E?this.visitOpNode(e):e instanceof x?this.visitValueNode(e):e instanceof d?this.visitAttributeNode(e):e instanceof g?this.visitFunctionNode(e):void 0}},{key:"visitBoolOpNode",value:function(e){}},{key:"visitOpNode",value:function(e){}},{key:"visitValueNode",value:function(e){}},{key:"visitAttributeNode",value:function(e){}},{key:"visitFunctionNode",value:function(e){}}]),e}(),L=function(e){s(r,C);var t=f(r);function r(e){var o;return n(this,r),(o=t.call(this)).attributes=e,o}return o(r,[{key:"visitBoolOpNode",value:function(e){y(u(r.prototype),"visitBoolOpNode",this).call(this,e),this.checkBoolOpNode(e),this.acceptLeafs(e)}},{key:"visitOpNode",value:function(e){y(u(r.prototype),"visitOpNode",this).call(this,e),this.checkOpNode(e),this.acceptLeafs(e)}},{key:"visitValueNode",value:function(e){y(u(r.prototype),"visitValueNode",this).call(this,e),this.checkLeafNode(e)}},{key:"visitAttributeNode",value:function(e){y(u(r.prototype),"visitAttributeNode",this).call(this,e),this.checkLeafNode(e),this.checkAttributeNode(e)}},{key:"visitFunctionNode",value:function(e){y(u(r.prototype),"visitFunctionNode",this).call(this,e),this.checkLeafNode(e),this.checkFunctionNode(e)}},{key:"checkBoolOpNode",value:function(e){const t="Ожидается выражение вида 'a == 2 "+e.token.value+" b == 3'";this.isOperationNode(e.left)||this.Error(t,e.token),this.isOperationNode(e.right)||this.Error(t,e.token)}},{key:"checkOpNode",value:function(e){e.left&&e.right||this.Error("'"+e.token.value+"' ожидает выражение",e.token)}},{key:"checkLeafNode",value:function(e){if(e.left){const{token:t}=e.left;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}if(e.right){const{token:t}=e.right;this.Error("'"+t.value+"' не может использоваться вне выражения",t)}}},{key:"checkAttributeNode",value:function(e){e.token.value&&void 0!==this.attributes[e.token.value]||this.Error("Атрибут '"+e.token.value+"' не найден в атрибутах слоя",e.token)}},{key:"checkFunctionNode",value:function(e){const t=e.func.check(this.attributes);t instanceof Error&&this.Error(t.message,e.token)}},{key:"Error",value:function(e,t){const{position:n}=t;throw new b(e,n)}},{key:"acceptLeafs",value:function(e){return{x:e.left&&e.left.accept(this),y:e.right&&e.right.accept(this)}}},{key:"isOperationNode",value:function(e){return e instanceof A||e instanceof E}}]),r}(),M=function(e){s(r,L);var t=f(r);function r(e,o){var i;return n(this,r),(i=t.call(this,e)).attributes=e,i.silent=!(!o||!o.silent),i}return o(r,[{key:"visitBoolOpNode",value:function(e){this.silent||y(u(r.prototype),"visitBoolOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);return e.token.type===exports.TokenType.BoolAnd?t&&n:t||n}},{key:"visitOpNode",value:function(e){this.silent||y(u(r.prototype),"visitOpNode",this).call(this,e);const{x:t,y:n}=this.acceptLeafs(e);switch(e.token.type){case exports.TokenType.ArEq:return t===n;case exports.TokenType.ArNotEq:return t!==n;case exports.TokenType.ArGre:return t>=n;case exports.TokenType.ArLse:return t<=n;case exports.TokenType.ArGr:return t>n;case exports.TokenType.ArLs:return t<n;case exports.TokenType.ArPlus:return t+n;case exports.TokenType.ArMinus:return t-n;case exports.TokenType.ArMul:return t*n;case exports.TokenType.ArDiv:return t/n;default:return!1}}},{key:"visitValueNode",value:function(e){return this.silent||y(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return this.silent||y(u(r.prototype),"visitAttributeNode",this).call(this,e),this.attributes[e.token.value]}},{key:"visitFunctionNode",value:function(e){return this.silent||y(u(r.prototype),"visitFunctionNode",this).call(this,e),e.func.calc(this.attributes)}}]),r}(),P=function(){function e(t){n(this,e),this.args=t}return o(e,[{key:"calc",value:function(e){return 0}},{key:"evaluateArguments",value:function(e){return this.args.map(t=>{if(t instanceof E)return t.accept(new M(e));if("string"==typeof t.value){if("number"!=typeof e[t.value]){const{position:e}=t;throw new b("Аргумент функции должен быть числовым типом",e)}return e[t.value]}return t.value})}},{key:"check",value:function(e,t){return this.evaluateArguments(e).length!==t?new Error("Передано неверное количество аргументов"):null}}]),e}(),D=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sin(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();D.ArgsCount=1,D.Name="sin";let F=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.asin(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();F.ArgsCount=1,F.Name="arcsin";let I=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.cos(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();I.ArgsCount=1,I.Name="cos";let _=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.acos(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();_.ArgsCount=1,_.Name="arccos";let R=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t,n]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan2(t,n).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();R.ArgsCount=2,R.Name="arctan2";let U=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.tan(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();U.ArgsCount=1,U.Name="tan";let K=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.atan(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();K.ArgsCount=1,K.Name="arctan";let q=function(e){s(r,P);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"calc",value:function(e){const[t]=y(u(r.prototype),"evaluateArguments",this).call(this,e);return+Math.sqrt(t).toFixed(3)}},{key:"check",value:function(e){return y(u(r.prototype),"check",this).call(this,e,r.ArgsCount)}}]),r}();q.ArgsCount=1,q.Name="sqrt";const G={[D.Name]:D,[F.Name]:F,[I.Name]:I,[_.Name]:_,[U.Name]:U,[K.Name]:K,[R.Name]:R,[q.Name]:q},j=e=>t.isValid(e)?e:"#'"+e+"'";let V=function(){function e(t){n(this,e),this.tokens=t,this.tree=null,this.currentPosition=0}return o(e,[{key:"value",get:function(){if(this.tree)return this.tree;this.tokens=function(e){let t=[];const n=[];for(const i of e){if(S(i)&&t.push(i),w(i)){if(![exports.TokenType.Between,exports.TokenType.Outside].includes(i.type))for(;m(n)&&(r=m(n),o=i,O.get(r.type)>O.get(o.type))&&m(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());n.push(i)}if(i.type===exports.TokenType.ExprOpen&&n.push(i),i.type===exports.TokenType.ExprClose){const e=i;for(;m(n)&&m(n).type!==exports.TokenType.ExprOpen;)t.push(n.pop());if(0===n.length)throw new b("Пропущена открывающая скобка",e.position);m(n).type===exports.TokenType.ExprOpen&&n.pop()}}var r,o;if(n.length){const e=m(n);if(e.type===exports.TokenType.ExprOpen)throw new b("Пропущена закрывающая скобка",e.position);t=[...t,...n.reverse()]}return t}(this.tokens);const e=[];for(;this.currentPosition<this.tokens.length;this.nextToken()){if(x.is(this.currentToken)&&e.push(new x(this.currentToken)),d.is(this.currentToken)&&e.push(new d(this.currentToken)),g.is(this.currentToken)){const t=G[this.currentToken.value];t||this.Error("Функция '"+this.currentToken.value+"' не определена",this.currentToken);const n=[];for(let r=0;r<t.ArgsCount;r++){const t=e.pop()||null;t instanceof E?n.push(t):t&&t.token&&n.push(t.token)}const r=new t(n);e.push(new g(this.currentToken,r))}if(E.is(this.currentToken)){const r=new E(this.currentToken);if([exports.TokenType.Between,exports.TokenType.Outside].includes(this.currentToken.type)){var t,n;const o=e.pop()||null,s=e.pop()||null;r.left=e.pop()||null,r.right=new x(i({},this.currentToken,{value:j(null==s?void 0:s.token.value)+" - "+j(null==o?void 0:o.token.value),position:{start:(null==s||null==(t=s.token.position)?void 0:t.start)||0,end:(null==o||null==(n=o.token.position)?void 0:n.end)||0}}))}else e.length>1&&(r.right=e.pop()||null),r.left=e.pop()||null;e.push(r)}if(A.is(this.currentToken)){const t=new A(this.currentToken);e.length>1&&(t.right=e.pop()||null),t.left=e.pop()||null,e.push(t)}}return this.tree=e.pop()||null,this.flashStack(e),this.checkRoot(),this.tree}},{key:"nextToken",value:function(){this.currentPosition+=1}},{key:"currentToken",get:function(){return this.tokens[this.currentPosition]}},{key:"checkRoot",value:function(){}},{key:"flashStack",value:function(e){if(this.tree&&e.length)for(;e.length;){const t=e.pop();t&&this.insert(this.tree,t)}}},{key:"insert",value:function(e,t){null!==e.right?this.insert(e.right,t):e.right=t}},{key:"Error",value:function(e,t){const{position:n}=t,{start:r,end:o}=n;throw new B(e,{start:r,end:o})}}]),e}(),W=function(e){s(r,N);var t=f(r);function r(e,o){var i;return void 0===o&&(o=k),n(this,r),(i=t.call(this,e,o)).position=o,i.name="ExpressionTokenizer",i}return o(r)}(),H=function(){function e(t,r,o){void 0===o&&(o=[]),n(this,e),this.acceptMap=new Map,this.value=t,this.tokenType=r,o.map(e=>this.acceptMap.set(e.value,e))}return o(e,[{key:"accept",value:function(e){return this.acceptMap.get(e)||null}}]),e}(),z=function(){function e(){n(this,e)}return o(e,null,[{key:"isChar",value:function(e){return"string"==typeof e&&1===e.length}},{key:"isDigit",value:function(e){return this.isChar(e)&&/\d/.test(e)}},{key:"isLetter",value:function(e){return this.isChar(e)&&/\w/.test(e)}},{key:"isWhiteSpace",value:function(t){return this.isChar(t)&&t===e.WHITE_SPACE}},{key:"isLetterOrDigit",value:function(t){return e.isLetter(t)||e.isDigit(t)}},{key:"isUnderscore",value:function(t){return e.isChar(t)&&t===e.UNDERSCORE}},{key:"isFloating",value:function(t){return e.isChar(t)&&("f"===t||"F"===t)}},{key:"escapeSpecChars",value:function(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\t/g,"\\\\t").replace(/\v/g,"\\\\v").replace(/\0/g,"\\\\0").replace(/\f/g,"\\\\f").replace(/\n/g,"\\\\n").replace(/\r/g,"\\\\r")}},{key:"unEscapeSpecChars",value:function(e){return e.replace(/\\'/g,"'").replace(/\\"/g,'"').replace(/\\\\/g,"\\").replace(/\\\\t/g,"\t").replace(/\\\\v/g,"\v").replace(/\\\\0/g,"\0").replace(/\\\\f/g,"\f").replace(/\\\\n/g,"\n").replace(/\\\\r/g,"\r")}}]),e}();function Q(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}z.LEFT_BRACKET="{",z.OPEN_BRACKET="(",z.BETWEEN="between",z.OUTSIDE="!between",z.SINGLE_QUOTE="'",z.DOUBLE_QUOTE='"',z.HASH_SYMBOL="#",z.RIGHT_BRACKET="}",z.CLOSE_BRACKET=")",z.BACK_SLASH="\\",z.WHITE_SPACE=" ",z.UNDERSCORE="_",z.PERCENTAGE="%",z.POINT=".";let Y=o((function e(){n(this,e)}));Y.sToMs=e=>1e3*e,Y.mToMs=e=>60*Y.sToMs(e),Y.hToMs=e=>60*Y.mToMs(e),Y.dToMs=e=>24*Y.hToMs(e),Y.mthToMs=e=>30*Y.dToMs(e),Y.yToMs=e=>365*Y.mthToMs(e);const J=new H("",exports.TokenType.Null,[new H(z.BETWEEN,exports.TokenType.Between),new H(z.OUTSIDE,exports.TokenType.Outside),new H(">",exports.TokenType.ArGr,[new H("=",exports.TokenType.ArGre)]),new H("<",exports.TokenType.ArLs,[new H("=",exports.TokenType.ArLse)]),new H("!",exports.TokenType.BoolNot,[new H("=",exports.TokenType.ArNotEq)]),new H("&",exports.TokenType.Null,[new H("&",exports.TokenType.BoolAnd)]),new H("=",exports.TokenType.ArEq,[new H("=",exports.TokenType.ArEq)]),new H("|",exports.TokenType.Null,[new H("|",exports.TokenType.BoolOr)]),new H("+",exports.TokenType.ArPlus),new H("-",exports.TokenType.ArMinus),new H("*",exports.TokenType.ArMul),new H("/",exports.TokenType.ArDiv),new H("(",exports.TokenType.ExprOpen),new H(")",exports.TokenType.ExprClose),new H("[",exports.TokenType.ArrayOpen),new H("]",exports.TokenType.ArrayClose),new H(",",exports.TokenType.Separator)]);let X=function(){function e(t){n(this,e),this.start=0,this.currentPosition=0,this.tokens=[],this.input=t||""}return o(e,[{key:"tokenize",value:function(){if(this.isEndOfString())return this.tokens;for(;;){const e=this.nextToken();if(!e)break;if(this.tokens.push(e),this.tokens.length>1e3&&this.Error("Привышен лимит запроса: 1000"),e.type===exports.TokenType.EndOfString)break}return this.tokens}},{key:"nextToken",value:function(){for(;this.currentPosition<this.input.length;this.nextSymbol()){if(z.isWhiteSpace(this.current))continue;if(this.resetStart(),this.input.slice(this.currentPosition).startsWith(z.OUTSIDE))return this.currentPosition+=z.OUTSIDE.length,this.createToken(exports.TokenType.Outside,z.OUTSIDE);if(this.input.slice(this.currentPosition).startsWith(z.BETWEEN))return this.currentPosition+=z.BETWEEN.length,this.createToken(exports.TokenType.Between,z.BETWEEN);const e=J.accept(this.current);if(null!==e)return this.captureSpecial(e);if(z.isDigit(this.current)||this.current===z.POINT)return this.captureNumber();if(z.isLetter(this.current)||z.isUnderscore(this.current))return this.captureIdentifier();if(this.current===z.LEFT_BRACKET)return this.captureDynamicIdentifier();if(this.current===z.DOUBLE_QUOTE||this.current===z.SINGLE_QUOTE)return this.captureString();if(this.current===z.HASH_SYMBOL)return this.captureDate()}return this.resetStart(),this.createToken(exports.TokenType.EndOfString)}},{key:"resetStart",value:function(){this.start=this.currentPosition}},{key:"createToken",value:function(e,t){void 0===t&&(t=null);const n=this.currentPosition-(e===exports.TokenType.EndOfString?0:1);return new T(e,t,{start:this.start,end:n})}},{key:"nextSymbol",value:function(){this.currentPosition+=1}},{key:"current",get:function(){return this.input[this.currentPosition]}},{key:"captureSpecial",value:function(e){let t=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol()){const n=e.accept(this.current);if(null===n||n.tokenType===exports.TokenType.Null)break;t+=this.current,e=n}return this.current&&z.isDigit(this.current)&&e.tokenType===exports.TokenType.ArMinus?this.createToken(exports.TokenType.Number,-(this.captureNumber().value||0)):(e.tokenType===exports.TokenType.Null&&this.Error("Неизвеcтная операция '"+e.value+"'"),this.createToken(e.tokenType,t))}},{key:"captureNumber",value:function(){let e="",t=!1;for(;this.currentPosition<this.input.length&&!z.isWhiteSpace(this.current)&&(z.isDigit(this.current)||z.isFloating(this.current)||this.current===z.POINT);this.nextSymbol())this.current===z.POINT&&(t=!0),e+=this.current;t&&z.isFloating(e[e.length-1])&&(e=e.slice(0,-1));const n=parseFloat(e);return Number.isNaN(n)&&this.Error("Неверный числовой формат: "+e),this.createToken(exports.TokenType.Number,n)}},{key:"captureIdentifier",value:function(){let e="";for(;this.currentPosition<this.input.length&&(z.isLetterOrDigit(this.current)||z.isUnderscore(this.current));this.nextSymbol())e+=this.current;if(this.current===z.OPEN_BRACKET){const t=this.tokens.some(e=>e.type===exports.TokenType.Between),n=this.tokens.some(e=>e.type===exports.TokenType.Outside);return this.createToken(n?exports.TokenType.Outside:t?exports.TokenType.Between:exports.TokenType.Function,e)}return"true"===e||"True"===e||"TRUE"===e?this.createToken(exports.TokenType.Terminal,!0):"false"===e||"False"===e||"FALSE"===e?this.createToken(exports.TokenType.Terminal,!1):"in"===e||"IN"===e?this.createToken(exports.TokenType.ArIn):this.createToken(exports.TokenType.Identifier,e)}},{key:"captureDynamicIdentifier",value:function(){this.nextSymbol();let e="";for(;this.currentPosition<this.input.length;this.nextSymbol()){if(this.current===z.RIGHT_BRACKET){this.nextSymbol();break}e+=this.current}return this.createToken(exports.TokenType.DynamicIdentifier,"null"===e||"Null"===e||"NULL"===e?null:e)}},{key:"captureString",value:function(){let e="",t=!1;const n=this.current;for(this.nextSymbol();this.currentPosition<this.input.length;this.nextSymbol())if(t||this.current!==z.BACK_SLASH){if(!t&&this.current===n)return this.nextSymbol(),this.createToken(exports.TokenType.String,e);e+=this.current,t=!1}else t=!0;this.Error("Открытая строка")}},{key:"captureDate",value:function(){if(this.nextSymbol(),![z.SINGLE_QUOTE,z.DOUBLE_QUOTE,z.BACK_SLASH].includes(this.current))return this.captureTimeSpan();const e=this.captureString();return this.createToken(exports.TokenType.Date,e.value)}},{key:"captureTimeSpan",value:function(){let e="";for(;this.currentPosition<this.input.length&&z.isDigit(this.current);this.nextSymbol())e+=this.current;const t=parseFloat(e);Number.isNaN(t)&&this.Error("Неверный формат числа для значения timespan: "+e+". Должно быть положительным целочисленным значением."),z.isLetter(this.current)||this.Error("Для значения задана неверная единица измерения "+this.current);let n="";for(;z.isLetter(this.current);)n+=this.current,this.nextSymbol();let r=0;switch(n){case"ms":r=t;break;case"s":r=Y.sToMs(t);break;case"m":r=Y.mToMs(t);break;case"h":r=Y.hToMs(t);break;case"d":r=Y.dToMs(t);break;case"mth":r=Y.mthToMs(t);break;case"y":r=Y.yToMs(t);break;default:this.Error("Неверная единица измерения для timespan: "+n)}return this.createToken(exports.TokenType.TimeSpan,r)}},{key:"isEndOfString",value:function(){return this.tokens.length>0&&this.tokens[this.tokens.length-1].type===exports.TokenType.EndOfString}},{key:"Error",value:function(e){throw new W(e,{start:this.start,end:this.start})}}]),e}(),Z=function(e){s(r,C);var t=f(r);function r(){return n(this,r),t.apply(this,arguments)}return o(r,[{key:"visitBoolOpNode",value:function(e){y(u(r.prototype),"visitBoolOpNode",this).call(this,e);const t=e.left&&e.left.accept(this),n=e.right&&e.right.accept(this);return e.left instanceof A&&e.right instanceof A?(this.checkBoolOperations(e.token.type,[...t.boolOperations,...n.boolOperations]),{boolOperations:[...t.boolOperations,e.token.type,...n.boolOperations],expressions:[...t.expressions,...n.expressions]}):e.right instanceof A?(this.checkBoolOperations(e.token.type,n.boolOperations),{boolOperations:[e.token.type,...n.boolOperations],expressions:[t,...n.expressions]}):e.left instanceof A?(this.checkBoolOperations(e.token.type,t.boolOperations),{boolOperations:[...t.boolOperations,e.token.type],expressions:[...t.expressions,n]}):{boolOperations:[e.token.type],expressions:[t,n]}}},{key:"visitOpNode",value:function(e){var t;y(u(r.prototype),"visitOpNode",this).call(this,e),this.checkExpressionSimple(e);const n=e.left&&e.left.accept(this),o=e.right&&(null==(t=e.right)?void 0:t.accept(this));return{attribute:n,operation:e.token.type,value:o}}},{key:"visitValueNode",value:function(e){return y(u(r.prototype),"visitValueNode",this).call(this,e),e.token.value}},{key:"visitAttributeNode",value:function(e){return y(u(r.prototype),"visitAttributeNode",this).call(this,e),e.token.value}},{key:"checkBoolOperations",value:function(e,t){if(t.some(t=>t!==e))throw new b("Выражение должно использовать одинаковые булевы операторы")}},{key:"checkExpressionSimple",value:function(e){if(!(e.left instanceof d&&e.right instanceof x||e.right instanceof x))throw new b("Выражение должно быть простым")}}]),r}();const $=e=>Q(e)&&"boolOperations"in e,ee=e=>Q(e)&&"attribute"in e;let te=function(){function e(t){n(this,e),this.result=null,this.tokenizer=new X(t)}return o(e,[{key:"value",get:function(){if(this.result)return this.result;try{const e=this.tokenizer.tokenize(),t=new V(e).value,n=t&&t.accept(new Z);return this.result=$(n)?n:ee(n)?{boolOperations:[],expressions:[n]}:{boolOperations:[],expressions:[]},this.result}catch(e){return e}}}]),e}(),ne=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"evaluate",value:function(e,t){try{const n=new X(e).tokenize(),r=new V(n).value;return r&&r.accept(new M(this.attributes,t))}catch(e){return e}}}]),e}(),re=function(){function e(t){n(this,e),this.attributes=t}return o(e,[{key:"lint",value:function(e){try{const t=new X(e).tokenize(),n=new V(t).value;return n&&n.accept(new L(this.attributes)),null}catch(e){return e}}}]),e}();exports.ArcCos=_,exports.ArcSin=F,exports.ArcTan=K,exports.ArcTan2=R,exports.AttributeNode=d,exports.BoolOperationNode=A,exports.Char=z,exports.ConditionEvaluator=ne,exports.ConditionInterpreter=te,exports.ConditionLinter=re,exports.ConditionVisitor=Z,exports.Cos=I,exports.DEFAULT_TOKEN_POSITION=k,exports.EqlFunction=P,exports.EqlFunctions=G,exports.EvaluateVisitor=M,exports.ExpressionAst=V,exports.ExpressionAstError=B,exports.ExpressionNode=v,exports.ExpressionTokenizer=X,exports.ExpressionTokenizerError=W,exports.ExpressionVisitor=C,exports.FunctionNode=g,exports.LintError=b,exports.LintVisitor=L,exports.OperationNode=E,exports.Sin=D,exports.Sqrt=q,exports.Tan=U,exports.Time=Y,exports.Token=T,exports.TokenError=N,exports.ValueNode=x,exports.isBoolResult=$,exports.isExpression=ee,exports.isObject=Q;
//# sourceMappingURL=condition.cjs.production.min.js.map

@@ -22,5 +22,2 @@ import { isValid } from 'date-fns';

if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;

@@ -59,5 +56,2 @@ }

});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);

@@ -161,4 +155,2 @@ }

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -197,3 +189,3 @@

function _get() {
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {

@@ -209,3 +201,3 @@ _get = Reflect.get;

if (desc.get) {
return desc.get.call(arguments.length < 3 ? target : receiver);
return desc.get.call(receiver);
}

@@ -217,3 +209,3 @@

return _get.apply(this, arguments);
return _get(target, property, receiver || target);
}

@@ -220,0 +212,0 @@

{
"version": "1.2.10",
"version": "1.2.11",
"license": "MIT",

@@ -36,3 +36,3 @@ "main": "dist/index.js",

"module": "dist/condition.esm.js",
"gitHead": "d7917d6e90024987d2d78d34cbd9aa9bb20de131"
"gitHead": "e35d0a0b33e4c7a7fd687d678e5f8bded8663856"
}

@@ -0,0 +0,0 @@ # @everigs/condition

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc