!(function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=r||self).jsonLogic=n()})(this,(function(){"use strict";var l=Array.isArray;function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}function u(r){return (function(r){if(Array.isArray(r)){for(var n=0,t=new Array(r.length);n<r.length;n++)t[n]=r[n];return t}})(r)||(function(r){if(Symbol.iterator in Object(r)||"[object Arguments]"===Object.prototype.toString.call(r))return Array.from(r)})(r)||(function(){throw new TypeError("Invalid attempt to spread non-iterable instance")})()}function p(r){return"object"===n(r)&&null!==r&&!l(r)&&1===Object.keys(r).length}function s(r){return Object.keys(r)[0]}function r(r,n){var t=void 0===n?null:n,e=this;if(void 0===r||""===r||null===r)return e;for(var o=String(r).split("."),u=0;u<o.length;u++){if(null===e)return t;if(void 0===(e=e[o[u]]))return t}return e}function t(r){for(var n=[],t=arguments.length,e=new Array(1<t?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];for(var u=l(e[0])?e[0]:e,i=0;i<u.length;i++){var f=u[i],a=r({var:f},this);null!==a&&""!==a||n.push(f)}return n}function e(r,n,t){var e=r({missing:t},this);return t.length-e.length>=n?[]:e}function o(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];return n.reduce((function(r,n){return parseFloat(r,10)+parseFloat(n,10)}),0)}function i(r,n){return r/n}function f(r,n){return r%n}function a(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];return n.reduce((function(r,n){return parseFloat(r,10)*parseFloat(n,10)}),1)}function c(r,n){return void 0===n?-r:r-n}function d(r){return(!l(r)||0!==r.length)&&!!r}function h(r,n,t){var e=r(t[0],n),o=t[1];if(!e.length)return!1;for(var u=0;u<e.length;u+=1)if(!d(r(o,e[u])))return!1;return!0}function v(n,r,t){var e=n(t[0],r),o=t[1];return l(e)?e.filter((function(r){return d(n(o,r))})):[]}function g(n,r,t){var e=n(t[0],r),o=t[1];return l(e)?e.map((function(r){return n(o,r)})):[]}function y(r,n,t){return 0===r({filter:t},n).length}function m(t,r,n){var e=t(n[0],r),o=n[1],u=void 0!==n[2]?n[2]:null;return l(e)?e.reduce((function(r,n){return t(o,{current:n,accumulator:r})}),u):u}function b(r,n,t){return 0<r({filter:t},n).length}function w(r,n,t){for(var e,o=0;o<t.length;o++)if(!d(e=r(t[o],n)))return e;return e}function A(r,n,t){var e;for(e=0;e<t.length-1;e+=2)if(d(r(t[e],n)))return r(t[e+1],n);return t.length===e+1?r(t[e],n):null}function F(r,n){return r==n}function j(r){return!d(r)}function E(r,n){return r!=n}function _(r,n,t){for(var e,o=0;o<t.length;o++)if(d(e=r(t[o],n)))return e;return e}function O(r,n){return r===n}function S(r,n){return r!==n}function x(r,n){return!(!n||void 0===n.indexOf)&&-1!==n.indexOf(r)}function q(r,n){return n<r}function k(r,n){return n<=r}function M(r,n,t){return void 0===t?r<n:r<n&&n<t}function z(r,n,t){return void 0===t?r<=n:r<=n&&n<=t}function U(r){return r[s(r)]}r.op="var",e.withApply=t.withApply=!0,o.op="+",i.op="/",f.op="%",a.op="*",w.deepFirst=b.deepFirst=m.deepFirst=y.deepFirst=g.deepFirst=v.deepFirst=h.deepFirst=!(c.op="-"),A.op=["if","?:"],A.deepFirst=!1,F.op="==",j.op="!",E.op="!=",_.deepFirst=!(d.op="!!"),O.op="===",S.op="!==",x.op="in",q.op=">",k.op=">=",M.op="<",z.op="<=";var I,L,N=(L={},(I=Object.freeze({__proto__:null,variable:r,missing:t,missing_some:e,add:o,divide:i,modulo:f,multiply:a,subtract:c,all:h,filter:v,map:g,merge:function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];return n.reduce((function(r,n){return r.concat(n)}),[])},none:y,reduce:m,some:b,and:w,condition:A,equal:F,not:j,notEqual:E,notnot:d,or:_,strictEqual:O,strictNotEqual:S,indexOf:x,log:function(r){return console.log(r),r},method:function(r,n,t){return r[n].apply(r,t)},greater:q,greaterEqual:k,less:M,lessEqual:z,max:function(){return Math.max.apply(Math,arguments)},min:function(){return Math.min.apply(Math,arguments)},cat:function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];return n.join("")},substr:function(r,n,t){if(t<0){var e=String(r).substr(n);return e.substr(0,e.length+t)}return String(r).substr(n,t)}}))&&Object.keys(I).forEach((function(r){var n=I[r];T(n.op||r,n)})),{apply:function n(r){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(l(r))return r.map((function(r){return n(r,t)}));if(!p(r))return r;var e,o=s(r),u=r[o];l(u)||(u=[u]);var i=L[o];if("function"==typeof i){var f=i.deepFirst;if(void 0!==f&&!f)return i(n,t,u)}if(u=u.map((function(r){return n(r,t)})),"function"==typeof i)return i.withApply&&u.unshift(n),i.apply(t,u);if(0<o.indexOf(".")){var a=String(o).split("."),c=L;for(e=0;e<a.length;e++)if(void 0===(c=c[a[e]]))throw new Error("Unrecognized operation ".concat(o," (failed at ").concat(a.slice(0,e+1).join("."),")"));return c.apply(t,u)}throw new Error("Unrecognized operation ".concat(o))},add_operation:T,rm_operation:function n(r){l(r)?r.forEach((function(r){return n(r)})):delete L[r]}});function T(r,n){l(r)?r.forEach((function(r){return T(r,n)})):L[r]=n}return N.is_logic=p,N.truthy=d,N.get_operator=s,N.get_values=U,N.uses_data=function n(r){var t=[];if(p(r)){var e=s(r),o=r[e];l(o)||(o=[o]),"var"===e?t.push(o[0]):o.forEach((function(r){t.push.apply(t,u(n(r)))}))}return (function(r){for(var n=[],t=0,e=r.length;t<e;t++)-1===n.indexOf(r[t])&&n.push(r[t]);return n})(t)},N.rule_like=function r(n,t){if(t===n)return!0;if("@"===t)return!0;if("number"===t)return"number"==typeof n;if("string"===t)return"string"==typeof n;if("array"===t)return l(n)&&!p(n);if(p(t)){if(p(n)){var e=s(t),o=s(n);if("@"===e||e===o)return r(U(n),U(t))}return!1}if(l(t)){if(l(n)){if(t.length!==n.length)return!1;for(var u=0;u<t.length;u+=1)if(!r(n[u],t[u]))return!1;return!0}return!1}return!1},N}));
//# sourceMappingURL=jsonLogic.min.js.map
