@sisukas/boel
Version:
Form Data validation library
1 lines • 46 kB
JavaScript
var boel=function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},n.apply(this,arguments)},r="INUMBER",i="IOP1",s="IOP2",a="IOP3",o="IVAR",u="IVARNAME",h="IFUNCALL",p="IFUNDEF",l="IEXPR",c="IEXPREVAL",f="IMEMBER",d="IENDSTATEMENT",v="IARRAY";function y(t,e){this.type=t,this.value=null!=e?e:0}function m(t){return new y(i,t)}function g(t){return new y(s,t)}function x(t){return new y(a,t)}function w(t,e,n,h,p){for(var c,d,m,g,x=[],b=[],F=0;F<t.length;F++){var E=t[F],_=E.type;if(_===r||_===u)Array.isArray(E.value)?x.push.apply(x,w(E.value.map((function(t){return new y(r,t)})).concat(new y(v,E.value.length)),e,n,h,p)):x.push(E);else if(_===o&&p.hasOwnProperty(E.value))E=new y(r,p[E.value]),x.push(E);else if(_===s&&x.length>1)d=x.pop(),c=x.pop(),g=n[E.value],E=new y(r,g(c.value,d.value)),x.push(E);else if(_===a&&x.length>2)m=x.pop(),d=x.pop(),c=x.pop(),"?"===E.value?x.push(c.value?d.value:m.value):(g=h[E.value],E=new y(r,g(c.value,d.value,m.value)),x.push(E));else if(_===i&&x.length>0)c=x.pop(),g=e[E.value],E=new y(r,g(c.value)),x.push(E);else if(_===l){for(;x.length>0;)b.push(x.shift());b.push(new y(l,w(E.value,e,n,h,p)))}else if(_===f&&x.length>0)c=x.pop(),x.push(new y(r,c.value[E.value]));else{for(;x.length>0;)b.push(x.shift());b.push(E)}}for(;x.length>0;)b.push(x.shift());return b}function b(t,e,n){for(var r=[],u=0;u<t.length;u++){var h=t[u],p=h.type;if(p===o&&h.value===e)for(var c=0;c<n.tokens.length;c++){var f,d=n.tokens[c];f=d.type===i?m(d.value):d.type===s?g(d.value):d.type===a?x(d.value):new y(d.type,d.value),r.push(f)}else p===l?r.push(new y(l,b(h.value,e,n))):r.push(h)}return r}function F(t,e,n){var y,m,g,x,w,b,A=[];if(_(t))return T(t,n);for(var M=t.length,k=0;k<M;k++){var O=t[k],S=O.type;if(S===r||S===u)A.push(O.value);else if(S===s)m=A.pop(),y=A.pop(),"and"===O.value?A.push(!!y&&!!F(m,e,n)):"or"===O.value?A.push(!!y||!!F(m,e,n)):"="===O.value?(x=e.binaryOps[O.value],A.push(x(y,F(m,e,n),n))):(x=e.binaryOps[O.value],A.push(x(T(y,n),T(m,n))));else if(S===a)g=A.pop(),m=A.pop(),y=A.pop(),"?"===O.value?A.push(F(y?m:g,e,n)):(x=e.ternaryOps[O.value],A.push(x(T(y,n),T(m,n),T(g,n))));else if(S===o)if(O.value in e.functions)A.push(e.functions[O.value]);else if(O.value in e.unaryOps&&e.parser.isOperatorEnabled(O.value))A.push(e.unaryOps[O.value]);else{var C=n[O.value];if(void 0===C)throw new Error("undefined variable: "+O.value);A.push(C)}else if(S===i)y=A.pop(),x=e.unaryOps[O.value],A.push(x(T(y,n)));else if(S===h){for(b=O.value,w=[];b-- >0;)w.unshift(T(A.pop(),n));if(!(x=A.pop()).apply||!x.call)throw new Error(x+" is not a function");A.push(x.apply(void 0,w))}else if(S===p)A.push(function(){for(var t=A.pop(),r=[],i=O.value;i-- >0;)r.unshift(A.pop());var s=A.pop(),a=function(){for(var i=Object.assign({},n),s=0,a=r.length;s<a;s++)i[r[s]]=arguments[s];return F(t,e,i)};return Object.defineProperty(a,"name",{value:s,writable:!1}),n[s]=a,a}());else if(S===l)A.push(E(O,e));else if(S===c)A.push(O);else if(S===f)y=A.pop(),A.push(y[O.value]);else if(S===d)A.pop();else{if(S!==v)throw new Error("invalid Expression");for(b=O.value,w=[];b-- >0;)w.unshift(A.pop());A.push(w)}}if(A.length>1)throw new Error("invalid Expression (parity)");return 0===A[0]?0:T(A[0],n)}function E(t,e,n){return _(t)?t:{type:c,value:function(n){return F(t.value,e,n)}}}function _(t){return t&&t.type===c}function T(t,e){return _(t)?t.value(e):t}function A(t,e){for(var n,c,y,m,g,x,w=[],b=0;b<t.length;b++){var F=t[b],E=F.type;if(E===r)"number"==typeof F.value&&F.value<0?w.push("("+F.value+")"):Array.isArray(F.value)?w.push("["+F.value.map(M).join(", ")+"]"):w.push(M(F.value));else if(E===s)c=w.pop(),n=w.pop(),m=F.value,e?"^"===m?w.push("Math.pow("+n+", "+c+")"):"and"===m?w.push("(!!"+n+" && !!"+c+")"):"or"===m?w.push("(!!"+n+" || !!"+c+")"):"||"===m?w.push("(function(a,b){ return Array.isArray(a) && Array.isArray(b) ? a.concat(b) : String(a) + String(b); }(("+n+"),("+c+")))"):"=="===m?w.push("("+n+" === "+c+")"):"!="===m?w.push("("+n+" !== "+c+")"):"["===m?w.push(n+"[("+c+") | 0]"):w.push("("+n+" "+m+" "+c+")"):"["===m?w.push(n+"["+c+"]"):w.push("("+n+" "+m+" "+c+")");else if(E===a){if(y=w.pop(),c=w.pop(),n=w.pop(),"?"!==(m=F.value))throw new Error("invalid Expression");w.push("("+n+" ? "+c+" : "+y+")")}else if(E===o||E===u)w.push(F.value);else if(E===i)n=w.pop(),"-"===(m=F.value)||"+"===m?w.push("("+m+n+")"):e?"not"===m?w.push("(!"+n+")"):"!"===m?w.push("fac("+n+")"):w.push(m+"("+n+")"):"!"===m?w.push("("+n+"!)"):w.push("("+m+" "+n+")");else if(E===h){for(x=F.value,g=[];x-- >0;)g.unshift(w.pop());m=w.pop(),w.push(m+"("+g.join(", ")+")")}else if(E===p){for(c=w.pop(),x=F.value,g=[];x-- >0;)g.unshift(w.pop());n=w.pop(),e?w.push("("+n+" = function("+g.join(", ")+") { return "+c+" })"):w.push("("+n+"("+g.join(", ")+") = "+c+")")}else if(E===f)n=w.pop(),w.push(n+"."+F.value);else if(E===v){for(x=F.value,g=[];x-- >0;)g.unshift(w.pop());w.push("["+g.join(", ")+"]")}else if(E===l)w.push("("+A(F.value,e)+")");else if(E!==d)throw new Error("invalid Expression")}return w.length>1&&(w=e?[w.join(",")]:[w.join(";")]),String(w[0])}function M(t){return"string"==typeof t?JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):t}function k(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return!0;return!1}function O(t,e,n){for(var r=!!(n=n||{}).withMembers,i=null,s=0;s<t.length;s++){var a=t[s];a.type===o||a.type===u?r||k(e,a.value)?null!==i?(k(e,i)||e.push(i),i=a.value):i=a.value:e.push(a.value):a.type===f&&r&&null!==i?i+="."+a.value:a.type===l?O(a.value,e,n):null!==i&&(k(e,i)||e.push(i),i=null)}null===i||k(e,i)||e.push(i)}function S(t,e){this.tokens=t,this.parser=e,this.unaryOps=e.unaryOps,this.binaryOps=e.binaryOps,this.ternaryOps=e.ternaryOps,this.functions=e.functions}y.prototype.toString=function(){switch(this.type){case r:case i:case s:case a:case o:case u:case d:return this.value;case h:return"CALL "+this.value;case p:return"DEF "+this.value;case v:return"ARRAY "+this.value;case f:return"."+this.value;default:return"Invalid Instruction"}},S.prototype.simplify=function(t){return t=t||{},new S(w(this.tokens,this.unaryOps,this.binaryOps,this.ternaryOps,t),this.parser)},S.prototype.substitute=function(t,e){return e instanceof S||(e=this.parser.parse(String(e))),new S(b(this.tokens,t,e),this.parser)},S.prototype.evaluate=function(t){return t=t||{},F(this.tokens,this,t)},S.prototype.toString=function(){return A(this.tokens,!1)},S.prototype.symbols=function(t){t=t||{};var e=[];return O(this.tokens,e,t),e},S.prototype.variables=function(t){t=t||{};var e=[];O(this.tokens,e,t);var n=this.functions;return e.filter((function(t){return!(t in n)}))},S.prototype.toJSFunction=function(t,e){var n=this,r=new Function(t,"with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return "+A(this.simplify(e).tokens,!0)+"; }");return function(){return r.apply(n,arguments)}};var C="TEOF",V="TOP",D="TNUMBER",N="TSTRING",q="TPAREN",P="TBRACKET",R="TCOMMA",L="TNAME",I="TSEMICOLON";function j(t,e,n){this.type=t,this.value=e,this.index=n}function z(t,e){this.pos=0,this.current=null,this.unaryOps=t.unaryOps,this.binaryOps=t.binaryOps,this.ternaryOps=t.ternaryOps,this.consts=t.consts,this.expression=e,this.savedPosition=0,this.savedCurrent=null,this.options=t.options,this.parser=t}j.prototype.toString=function(){return this.type+": "+this.value},z.prototype.newToken=function(t,e,n){return new j(t,e,null!=n?n:this.pos)},z.prototype.save=function(){this.savedPosition=this.pos,this.savedCurrent=this.current},z.prototype.restore=function(){this.pos=this.savedPosition,this.current=this.savedCurrent},z.prototype.next=function(){return this.pos>=this.expression.length?this.newToken(C,"EOF"):this.isWhitespace()||this.isComment()?this.next():this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isBracket()||this.isComma()||this.isSemicolon()||this.isNamedOp()||this.isConst()||this.isName()?this.current:void this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')},z.prototype.isString=function(){var t=!1,e=this.pos,n=this.expression.charAt(e);if("'"===n||'"'===n)for(var r=this.expression.indexOf(n,e+1);r>=0&&this.pos<this.expression.length;){if(this.pos=r+1,"\\"!==this.expression.charAt(r-1)){var i=this.expression.substring(e+1,r);this.current=this.newToken(N,this.unescape(i),e),t=!0;break}r=this.expression.indexOf(n,r+1)}return t},z.prototype.isParen=function(){var t=this.expression.charAt(this.pos);return("("===t||")"===t)&&(this.current=this.newToken(q,t),this.pos++,!0)},z.prototype.isBracket=function(){var t=this.expression.charAt(this.pos);return!("["!==t&&"]"!==t||!this.isOperatorEnabled("["))&&(this.current=this.newToken(P,t),this.pos++,!0)},z.prototype.isComma=function(){return","===this.expression.charAt(this.pos)&&(this.current=this.newToken(R,","),this.pos++,!0)},z.prototype.isSemicolon=function(){return";"===this.expression.charAt(this.pos)&&(this.current=this.newToken(I,";"),this.pos++,!0)},z.prototype.isConst=function(){for(var t=this.pos,e=t;e<this.expression.length;e++){var n=this.expression.charAt(e);if(n.toUpperCase()===n.toLowerCase()&&(e===this.pos||"_"!==n&&"."!==n&&(n<"0"||n>"9")))break}if(e>t){var r=this.expression.substring(t,e);if(r in this.consts)return this.current=this.newToken(D,this.consts[r]),this.pos+=r.length,!0}return!1},z.prototype.isNamedOp=function(){for(var t=this.pos,e=t;e<this.expression.length;e++){var n=this.expression.charAt(e);if(n.toUpperCase()===n.toLowerCase()&&(e===this.pos||"_"!==n&&(n<"0"||n>"9")))break}if(e>t){var r=this.expression.substring(t,e);if(this.isOperatorEnabled(r)&&(r in this.binaryOps||r in this.unaryOps||r in this.ternaryOps))return this.current=this.newToken(V,r),this.pos+=r.length,!0}return!1},z.prototype.isName=function(){for(var t=this.pos,e=t,n=!1;e<this.expression.length;e++){var r=this.expression.charAt(e);if(r.toUpperCase()===r.toLowerCase()){if(e===this.pos&&("$"===r||"_"===r)){"_"===r&&(n=!0);continue}if(e===this.pos||!n||"_"!==r&&(r<"0"||r>"9"))break}else n=!0}if(n){var i=this.expression.substring(t,e);return this.current=this.newToken(L,i),this.pos+=i.length,!0}return!1},z.prototype.isWhitespace=function(){for(var t=!1,e=this.expression.charAt(this.pos);!(" "!==e&&"\t"!==e&&"\n"!==e&&"\r"!==e||(t=!0,this.pos++,this.pos>=this.expression.length));)e=this.expression.charAt(this.pos);return t};var $=/^[0-9a-f]{4}$/i;function U(t,e,n){this.parser=t,this.tokens=e,this.current=null,this.nextToken=null,this.next(),this.savedCurrent=null,this.savedNextToken=null,this.allowMemberAccess=!1!==n.allowMemberAccess}z.prototype.unescape=function(t){var e=t.indexOf("\\");if(e<0)return t;for(var n=t.substring(0,e);e>=0;){var r=t.charAt(++e);switch(r){case"'":n+="'";break;case'"':n+='"';break;case"\\":n+="\\";break;case"/":n+="/";break;case"b":n+="\b";break;case"f":n+="\f";break;case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+="\t";break;case"u":var i=t.substring(e+1,e+5);$.test(i)||this.parseError("Illegal escape sequence: \\u"+i),n+=String.fromCharCode(parseInt(i,16)),e+=4;break;default:throw this.parseError('Illegal escape sequence: "\\'+r+'"')}++e;var s=t.indexOf("\\",e);n+=t.substring(e,s<0?t.length:s),e=s}return n},z.prototype.isComment=function(){return"/"===this.expression.charAt(this.pos)&&"*"===this.expression.charAt(this.pos+1)&&(this.pos=this.expression.indexOf("*/",this.pos)+2,1===this.pos&&(this.pos=this.expression.length),!0)},z.prototype.isRadixInteger=function(){var t,e,n=this.pos;if(n>=this.expression.length-2||"0"!==this.expression.charAt(n))return!1;if(++n,"x"===this.expression.charAt(n))t=16,e=/^[0-9a-f]$/i,++n;else{if("b"!==this.expression.charAt(n))return!1;t=2,e=/^[01]$/i,++n}for(var r=!1,i=n;n<this.expression.length;){var s=this.expression.charAt(n);if(!e.test(s))break;n++,r=!0}return r&&(this.current=this.newToken(D,parseInt(this.expression.substring(i,n),t)),this.pos=n),r},z.prototype.isNumber=function(){for(var t,e=!1,n=this.pos,r=n,i=n,s=!1,a=!1;n<this.expression.length&&((t=this.expression.charAt(n))>="0"&&t<="9"||!s&&"."===t);)"."===t?s=!0:a=!0,n++,e=a;if(e&&(i=n),"e"===t||"E"===t){n++;for(var o=!0,u=!1;n<this.expression.length;){if(t=this.expression.charAt(n),!o||"+"!==t&&"-"!==t){if(!(t>="0"&&t<="9"))break;u=!0,o=!1}else o=!1;n++}u||(n=i)}return e?(this.current=this.newToken(D,parseFloat(this.expression.substring(r,n))),this.pos=n):this.pos=i,e},z.prototype.isOperator=function(){var t=this.pos,e=this.expression.charAt(this.pos);if("+"===e||"-"===e||"*"===e||"/"===e||"%"===e||"^"===e||"?"===e||":"===e||"."===e)this.current=this.newToken(V,e);else if("∙"===e||"•"===e)this.current=this.newToken(V,"*");else if(">"===e)"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(V,">="),this.pos++):this.current=this.newToken(V,">");else if("<"===e)"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(V,"<="),this.pos++):this.current=this.newToken(V,"<");else if("|"===e){if("|"!==this.expression.charAt(this.pos+1))return!1;this.current=this.newToken(V,"||"),this.pos++}else if("="===e)"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(V,"=="),this.pos++):this.current=this.newToken(V,e);else{if("!"!==e)return!1;"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(V,"!="),this.pos++):this.current=this.newToken(V,e)}return this.pos++,!!this.isOperatorEnabled(this.current.value)||(this.pos=t,!1)},z.prototype.isOperatorEnabled=function(t){return this.parser.isOperatorEnabled(t)},z.prototype.getCoordinates=function(){var t,e=0,n=-1;do{e++,t=this.pos-n,n=this.expression.indexOf("\n",n+1)}while(n>=0&&n<this.pos);return{line:e,column:t}},z.prototype.parseError=function(t){var e=this.getCoordinates();throw new Error("parse error ["+e.line+":"+e.column+"]: "+t)},U.prototype.next=function(){return this.current=this.nextToken,this.nextToken=this.tokens.next()},U.prototype.tokenMatches=function(t,e){return void 0===e||(Array.isArray(e)?k(e,t.value):"function"==typeof e?e(t):t.value===e)},U.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()},U.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken},U.prototype.accept=function(t,e){return!(this.nextToken.type!==t||!this.tokenMatches(this.nextToken,e))&&(this.next(),!0)},U.prototype.expect=function(t,e){if(!this.accept(t,e)){var n=this.tokens.getCoordinates();throw new Error("parse error ["+n.line+":"+n.column+"]: Expected "+(e||t))}},U.prototype.parseAtom=function(t){var e=this.tokens.unaryOps;if(this.accept(L)||this.accept(V,(function(t){return t.value in e})))t.push(new y(o,this.current.value));else if(this.accept(D))t.push(new y(r,this.current.value));else if(this.accept(N))t.push(new y(r,this.current.value));else if(this.accept(q,"("))this.parseExpression(t),this.expect(q,")");else{if(!this.accept(P,"["))throw new Error("unexpected "+this.nextToken);if(this.accept(P,"]"))t.push(new y(v,0));else{var n=this.parseArrayList(t);t.push(new y(v,n))}}},U.prototype.parseExpression=function(t){var e=[];this.parseUntilEndStatement(t,e)||(this.parseVariableAssignmentExpression(e),this.parseUntilEndStatement(t,e)||this.pushExpression(t,e))},U.prototype.pushExpression=function(t,e){for(var n=0,r=e.length;n<r;n++)t.push(e[n])},U.prototype.parseUntilEndStatement=function(t,e){return!!this.accept(I)&&(!this.nextToken||this.nextToken.type===C||this.nextToken.type===q&&")"===this.nextToken.value||e.push(new y(d)),this.nextToken.type!==C&&this.parseExpression(e),t.push(new y(l,e)),!0)},U.prototype.parseArrayList=function(t){for(var e=0;!this.accept(P,"]");)for(this.parseExpression(t),++e;this.accept(R);)this.parseExpression(t),++e;return e},U.prototype.parseVariableAssignmentExpression=function(t){for(this.parseConditionalExpression(t);this.accept(V,"=");){var e=t.pop(),n=[],r=t.length-1;if(e.type!==h){if(e.type!==o&&e.type!==f)throw new Error("expected variable for assignment");this.parseVariableAssignmentExpression(n),t.push(new y(u,e.value)),t.push(new y(l,n)),t.push(g("="))}else{if(!this.tokens.isOperatorEnabled("()="))throw new Error("function definition is not permitted");for(var i=0,s=e.value+1;i<s;i++){var a=r-i;t[a].type===o&&(t[a]=new y(u,t[a].value))}this.parseVariableAssignmentExpression(n),t.push(new y(l,n)),t.push(new y(p,e.value))}}},U.prototype.parseConditionalExpression=function(t){for(this.parseOrExpression(t);this.accept(V,"?");){var e=[],n=[];this.parseConditionalExpression(e),this.expect(V,":"),this.parseConditionalExpression(n),t.push(new y(l,e)),t.push(new y(l,n)),t.push(x("?"))}},U.prototype.parseOrExpression=function(t){for(this.parseAndExpression(t);this.accept(V,"or");){var e=[];this.parseAndExpression(e),t.push(new y(l,e)),t.push(g("or"))}},U.prototype.parseAndExpression=function(t){for(this.parseComparison(t);this.accept(V,"and");){var e=[];this.parseComparison(e),t.push(new y(l,e)),t.push(g("and"))}};var B=["==","!=","<","<=",">=",">","in"];U.prototype.parseComparison=function(t){for(this.parseAddSub(t);this.accept(V,B);){var e=this.current;this.parseAddSub(t),t.push(g(e.value))}};var G=["+","-","||"];U.prototype.parseAddSub=function(t){for(this.parseTerm(t);this.accept(V,G);){var e=this.current;this.parseTerm(t),t.push(g(e.value))}};var Z=["*","/","%"];function W(t,e){return Number(t)+Number(e)}function Y(t,e){return t-e}function J(t,e){return t*e}function X(t,e){return t/e}function K(t,e){return t%e}function H(t,e){return Array.isArray(t)&&Array.isArray(e)?t.concat(e):""+t+e}function Q(t,e){return t===e}function tt(t,e){return t!==e}function et(t,e){return t>e}function nt(t,e){return t<e}function rt(t,e){return t>=e}function it(t,e){return t<=e}function st(t,e){return Boolean(t&&e)}function at(t,e){return Boolean(t||e)}function ot(t,e){return k(e,t)}function ut(t){return(Math.exp(t)-Math.exp(-t))/2}function ht(t){return(Math.exp(t)+Math.exp(-t))/2}function pt(t){return t===1/0?1:t===-1/0?-1:(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))}function lt(t){return t===-1/0?t:Math.log(t+Math.sqrt(t*t+1))}function ct(t){return Math.log(t+Math.sqrt(t*t-1))}function ft(t){return Math.log((1+t)/(1-t))/2}function dt(t){return Math.log(t)*Math.LOG10E}function vt(t){return-t}function yt(t){return!t}function mt(t){return t<0?Math.ceil(t):Math.floor(t)}function gt(t){return Math.random()*(t||1)}function xt(t){return bt(t+1)}U.prototype.parseTerm=function(t){for(this.parseFactor(t);this.accept(V,Z);){var e=this.current;this.parseFactor(t),t.push(g(e.value))}},U.prototype.parseFactor=function(t){var e=this.tokens.unaryOps;if(this.save(),this.accept(V,(function(t){return t.value in e}))){if("-"!==this.current.value&&"+"!==this.current.value){if(this.nextToken.type===q&&"("===this.nextToken.value)return this.restore(),void this.parseExponential(t);if(this.nextToken.type===I||this.nextToken.type===R||this.nextToken.type===C||this.nextToken.type===q&&")"===this.nextToken.value)return this.restore(),void this.parseAtom(t)}var n=this.current;this.parseFactor(t),t.push(m(n.value))}else this.parseExponential(t)},U.prototype.parseExponential=function(t){for(this.parsePostfixExpression(t);this.accept(V,"^");)this.parseFactor(t),t.push(g("^"))},U.prototype.parsePostfixExpression=function(t){for(this.parseFunctionCall(t);this.accept(V,"!");)t.push(m("!"))},U.prototype.parseFunctionCall=function(t){var e=this.tokens.unaryOps;if(this.accept(V,(function(t){return t.value in e}))){var n=this.current;this.parseAtom(t),t.push(m(n.value))}else for(this.parseMemberExpression(t);this.accept(q,"(");)if(this.accept(q,")"))t.push(new y(h,0));else{var r=this.parseArgumentList(t);t.push(new y(h,r))}},U.prototype.parseArgumentList=function(t){for(var e=0;!this.accept(q,")");)for(this.parseExpression(t),++e;this.accept(R);)this.parseExpression(t),++e;return e},U.prototype.parseMemberExpression=function(t){for(this.parseAtom(t);this.accept(V,".")||this.accept(P,"[");){var e=this.current;if("."===e.value){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect(L),t.push(new y(f,this.current.value))}else{if("["!==e.value)throw new Error("unexpected symbol: "+e.value);if(!this.tokens.isOperatorEnabled("["))throw new Error('unexpected "[]", arrays are disabled');this.parseExpression(t),this.expect(P,"]"),t.push(g("["))}}};var wt=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function bt(t){var e,n;if(function(t){return isFinite(t)&&t===Math.round(t)}(t)){if(t<=0)return isFinite(t)?1/0:NaN;if(t>171)return 1/0;for(var r=t-2,i=t-1;r>1;)i*=r,r--;return 0===i&&(i=1),i}if(t<.5)return Math.PI/(Math.sin(Math.PI*t)*bt(1-t));if(t>=171.35)return 1/0;if(t>85){var s=t*t,a=s*t,o=a*t,u=o*t;return Math.sqrt(2*Math.PI/t)*Math.pow(t/Math.E,t)*(1+1/(12*t)+1/(288*s)-139/(51840*a)-571/(2488320*o)+163879/(209018880*u)+5246819/(75246796800*u*t))}--t,n=wt[0];for(var h=1;h<wt.length;++h)n+=wt[h]/(t+h);return e=t+4.7421875+.5,Math.sqrt(2*Math.PI)*Math.pow(e,t+.5)*Math.exp(-e)*n}function Ft(t){return Array.isArray(t)?t.length:String(t).length}function Et(){for(var t=0,e=0,n=0;n<arguments.length;n++){var r,i=Math.abs(arguments[n]);e<i?(t=t*(r=e/i)*r+1,e=i):t+=i>0?(r=i/e)*r:i}return e===1/0?1/0:e*Math.sqrt(t)}function _t(t,e,n){return t?e:n}function Tt(t,e){return void 0===e||0==+e?Math.round(t):(t=+t,e=-+e,isNaN(t)||"number"!=typeof e||e%1!=0?NaN:(t=t.toString().split("e"),+((t=(t=Math.round(+(t[0]+"e"+(t[1]?+t[1]-e:-e)))).toString().split("e"))[0]+"e"+(t[1]?+t[1]+e:e))))}function At(t,e,n){return n&&(n[t]=e),e}function Mt(t,e){return t[0|e]}function kt(t){return 1===arguments.length&&Array.isArray(t)?Math.max.apply(Math,t):Math.max.apply(Math,arguments)}function Ot(t){return 1===arguments.length&&Array.isArray(t)?Math.min.apply(Math,t):Math.min.apply(Math,arguments)}function St(t,e){if("function"!=typeof t)throw new Error("First argument to map is not a function");if(!Array.isArray(e))throw new Error("Second argument to map is not an array");return e.map((function(e,n){return t(e,n)}))}function Ct(t,e,n){if("function"!=typeof t)throw new Error("First argument to fold is not a function");if(!Array.isArray(n))throw new Error("Second argument to fold is not an array");return n.reduce((function(e,n,r){return t(e,n,r)}),e)}function Vt(t,e){if("function"!=typeof t)throw new Error("First argument to filter is not a function");if(!Array.isArray(e))throw new Error("Second argument to filter is not an array");return e.filter((function(e,n){return t(e,n)}))}function Dt(t,e){if(!Array.isArray(e)&&"string"!=typeof e)throw new Error("Second argument to indexOf is not a string or array");return e.indexOf(t)}function Nt(t,e){if(!Array.isArray(e))throw new Error("Second argument to join is not an array");return e.join(t)}function qt(t){return(t>0)-(t<0)||+t}var Pt=1/3;function Rt(t){return t<0?-Math.pow(-t,Pt):Math.pow(t,Pt)}function Lt(t){return Math.exp(t)-1}function It(t){return Math.log(1+t)}function jt(t){return Math.log(t)/Math.LN2}function zt(t){this.options=t||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||ut,cosh:Math.cosh||ht,tanh:Math.tanh||pt,asinh:Math.asinh||lt,acosh:Math.acosh||ct,atanh:Math.atanh||ft,sqrt:Math.sqrt,cbrt:Math.cbrt||Rt,log:Math.log,log2:Math.log2||jt,ln:Math.log,lg:Math.log10||dt,log10:Math.log10||dt,expm1:Math.expm1||Lt,log1p:Math.log1p||It,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||mt,"-":vt,"+":Number,exp:Math.exp,not:yt,length:Ft,"!":xt,sign:Math.sign||qt},this.binaryOps={"+":W,"-":Y,"*":J,"/":X,"%":K,"^":Math.pow,"||":H,"==":Q,"!=":tt,">":et,"<":nt,">=":rt,"<=":it,and:st,or:at,in:ot,"=":At,"[":Mt},this.ternaryOps={"?":_t},this.functions={random:gt,fac:xt,min:Ot,max:kt,hypot:Math.hypot||Et,pyt:Math.hypot||Et,pow:Math.pow,atan2:Math.atan2,if:_t,gamma:bt,roundTo:Tt,map:St,fold:Ct,filter:Vt,indexOf:Dt,join:Nt},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}zt.prototype.parse=function(t){var e=[],n=new U(this,new z(this,t),{allowMemberAccess:this.options.allowMemberAccess});return n.parseExpression(e),n.expect(C,"EOF"),new S(e,this)},zt.prototype.evaluate=function(t,e){return this.parse(t).evaluate(e)};var $t=new zt;zt.parse=function(t){return $t.parse(t)},zt.evaluate=function(t,e){return $t.parse(t).evaluate(e)};var Ut={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional","=":"assignment","[":"array","()=":"fndef"};function Bt(t){return t.name?t.name:t.constructor.name}zt.prototype.isOperatorEnabled=function(t){var e=function(t){return Ut.hasOwnProperty(t)?Ut[t]:t}(t),n=this.options.operators||{};return!(e in n)||!!n[e]};var Gt,Zt=function(){function t(t){this.message="",this.condition_expr=null,this.validator=t}return Object.defineProperty(t.prototype,"condition",{set:function(t){if(t){var e=new zt;this.condition_expr=e.parse(t)}else this.condition_expr=null},enumerable:!1,configurable:!0}),t}(),Wt=function(){function t(t,e){this.fields=t,this.validator_info=e,this.validations=[]}return t.prototype.addValidation=function(t){this.validations.push(new Zt(t))},t.prototype.addMessage=function(t){this.validations.length>0&&(this.validations[this.validations.length-1].message=t)},t.prototype.addCondition=function(t){this.validations.length>0&&(this.validations[this.validations.length-1].condition=t)},t.prototype.validate=function(t){for(var e={},n=0,r=this.validations;n<r.length;n++){var i=r[n];if(null!==i.condition_expr)if(!i.condition_expr.evaluate(t))continue;for(var s=0,a=this.fields;s<a.length;s++){var o=a[s];i.validator.validate(o,t)||e[o]||(e[o]={validation:Bt(i.validator),message:this.getMessage(i,o)})}}return e},t.prototype.getMessage=function(t,r){return function(t,n){if("string"==typeof t&&"object"===e(n))for(var r in n)t=t.replace(new RegExp("{{\\s*"+r+"\\s*}}","g"),String(n[r]));return t}(t.message?t.message:this.validator_info.getMessageTemplate(t.validator),n({field:r},t.validator))},t.prototype.hasValidations=function(){return this.validations.length>0},t}(),Yt=function(){function t(t){this.field_v=t}return t.prototype.addValidation=function(t){this.field_v.addValidation(t)},t.prototype.validate=function(t){return this.field_v.validate(t)},t.prototype.message=function(t){return this.field_v.addMessage(t),this},t.prototype.onlyWhen=function(t){return this.field_v.addCondition(t),this},t}(),Jt=function(){function t(){this.message="{{field}} is required"}return t.prototype.validate=function(t,e){if(e[t]){if(String(e[t]).length>0)return!0}else if(0===e[t]||!1===e[t])return!0;return!1},t}(),Xt=function(){function t(t){this.max_length=t,this.message="{{field}} exceeded max length {{max_length}}"}return t.prototype.validate=function(t,e){return void 0===e[t]||!(String(e[t]).length>this.max_length)},t}(),Kt=function(){function t(t){this.min_length=t,this.message="{{field}} input length should be at least {{min_length}}"}return t.prototype.validate=function(t,e){return void 0===e[t]||!(String(e[t]).length<this.min_length)},t}(),Ht={"<":{name:"LessThan",message:"{{field}} should be less than {{test_value}}",fn:function(t,e){return t<e}},"<=":{name:"LessThanOrEqualTo",message:"{{field}} should be less than or equal to {{test_value}}",fn:function(t,e){return t<=e}},">":{name:"GreaterThan",message:"{{field}} should be greater than {{test_value}}",fn:function(t,e){return t>e}},">=":{name:"GreaterThanOrEqualTo",message:"{{field}} should be greater than or equal to {{test_value}}",fn:function(t,e){return t>=e}},"=":{name:"EqualTo",message:"{{field}} should be equal to {{test_value}}",fn:function(t,e){return t===e}},"!=":{name:"NotEqualTo",message:"{{field}} should not be equal to {{test_value}}",fn:function(t,e){return t!==e}}};!function(t){t[t.Value=0]="Value",t[t.Field=1]="Field"}(Gt||(Gt={}));var Qt=function(){function t(t,e){if(this.comparison=t,this.options=e,this.message="",this.test_value=0,this.test_against=Gt.Value,this.name="",!Object.keys(Ht).includes(t))throw Error("unsupported comparison operator "+t);if(this.name=Ht[t].name,this.message=Ht[t].message,void 0!==e.test_value)this.test_against=Gt.Value,this.test_value=e.test_value;else{if(void 0===e.test_field)throw Error("Provide one of test_value or test_field in the options");this.test_against=Gt.Field,this.test_value=e.test_field}}return t.prototype.validate=function(t,e){if(void 0===e[t])return!0;var n,r=this.getOtherValue(e);if("string"==typeof r)n=String(e[t]);else if("number"==typeof r)n=Number(e[t]);else{if(!(r instanceof Date))throw Error("Couldn't identify value type");n=new Date(e[t])}return this.doComparison(n,r)},t.prototype.getOtherValue=function(t){if(this.test_against==Gt.Field){if(void 0===this.options.test_field)throw Error("The test_field is not provided");if("string"==typeof t[this.options.test_field])return String(t[this.options.test_field]);if("number"==typeof t[this.options.test_field])return Number(t[this.options.test_field]);throw Error("Wrong type for test_field (neither string nor number)")}if(void 0===this.options.test_value)throw Error("The test_value is not provided");return this.options.test_value},t.prototype.doComparison=function(t,e){return Ht[this.comparison].fn(t,e)},t}();var te,ee,ne,re=(te=function(t,e){!function(){var t={d:function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};function r(t,e){return void 0===e&&(e="-"),new RegExp("^(?!0{4}"+e+"0{2}"+e+"0{2})((?=[0-9]{4}"+e+"(((0[^2])|1[0-2])|02(?="+e+"(([0-1][0-9])|2[0-8])))"+e+"[0-9]{2})|(?=((([13579][26])|([2468][048])|(0[48]))0{2})|([0-9]{2}((((0|[2468])[48])|[2468][048])|([13579][26])))"+e+"02"+e+"29))([0-9]{4})"+e+"(?!((0[469])|11)"+e+"31)((0[1,3-9]|1[0-2])|(02(?!"+e+"3)))"+e+"([0-2][0-9]|3[0-1])$").test(t)}function i(t){var e=/\D/.exec(t);return e?e[0]:""}function s(t,e,n){void 0===e&&(e=":"),void 0===n&&(n=!1);var r=new RegExp("^([0-1]|2(?=([0-3])|4"+e+"00))[0-9]"+e+"[0-5][0-9]("+e+"([0-5]|6(?=0))[0-9])?(.[0-9]{1,9})?$");if(!n||!/[Z+\-]/.test(t))return r.test(t);if(/Z$/.test(t))return r.test(t.replace("Z",""));var s=t.includes("+"),a=t.split(/[+-]/),o=a[0],u=a[1];return r.test(o)&&function(t,e,n){return void 0===n&&(n=":"),new RegExp(e?"^(0(?!(2"+n+"4)|0"+n+"3)|1(?=([0-1]|2(?="+n+"[04])|[34](?="+n+"0))))([03469](?="+n+"[03])|[17](?="+n+"0)|2(?="+n+"[04])|5(?="+n+"[034])|8(?="+n+"[04]))"+n+"([03](?=0)|4(?=5))[05]$":"^(0(?=[^0])|1(?=[0-2]))([39](?="+n+"[03])|[0-24-8](?="+n+"00))"+n+"[03]0$").test(t)}(u,s,i(u))}function a(t){var e,n=t.split("T"),a=n[0],o=n[1],u=r(a,i(a));return!!o&&u&&s(o,(e=o.match(/[^Z+\-\d]/),Array.isArray(e)?e[0]:""),!0)}function o(t,e){return void 0===e&&(e="-"),new RegExp("^[0-9]{4}"+e+"(0(?=[^0])|1(?=[0-2]))[0-9]$").test(t)}t.r(n),t.d(n,{isValidDate:function(){return r},isValidISODateString:function(){return a},isValidTime:function(){return s},isValidYearMonth:function(){return o}});var u=e;for(var h in n)u[h]=n[h];n.__esModule&&Object.defineProperty(u,"__esModule",{value:!0})}()},te(ne={path:ee,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&ne.path)}},ne.exports),ne.exports),ie="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͅͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈְ-ׇֽֿׁׂׅׄא-תׯ-ײؐ-ؚؠ-ٗٙ-ٟٮ-ۓە-ۜۡ-ۭۨ-ۯۺ-ۼۿܐ-ܿݍ-ޱߊ-ߪߴߵߺࠀ-ࠗࠚ-ࠬࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉࣔ-ࣣࣟ-ࣰࣩ-ऻऽ-ौॎ-ॐॕ-ॣॱ-ঃঅ-ঌএঐও-নপ-রলশ-হঽ-ৄেৈোৌৎৗড়ঢ়য়-ৣৰৱৼਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਾ-ੂੇੈੋੌੑਖ਼-ੜਫ਼ੰ-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽ-ૅે-ૉોૌૐૠ-ૣૹ-ૼଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽ-ୄେୈୋୌୖୗଡ଼ଢ଼ୟ-ୣୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-ௌௐௗఀ-ఃఅ-ఌఎ-ఐఒ-నప-హఽ-ౄె-ైొ-ౌౕౖౘ-ౚౝౠ-ౣಀ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೄೆ-ೈೊ-ೌೕೖೝೞೠ-ೣೱೲഀ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൌൎൔ-ൗൟ-ൣൺ-ൿඁ-ඃඅ-ඖක-නඳ-රලව-ෆා-ුූෘ-ෟෲෳก-ฺเ-ๆํກຂຄຆ-ຊຌ-ຣລວ-ູົ-ຽເ-ໄໆໍໜ-ໟༀཀ-ཇཉ-ཬཱ-ཱྀྈ-ྗྙ-ྼက-ံးျ-ဿၐ-ႏႚ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜓᜟ-ᜳᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-ឳា-ៈៗៜᠠ-ᡸᢀ-ᢪᢰ-ᣵᤀ-ᤞᤠ-ᤫᤰ-ᤸᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨛᨠ-ᩞᩡ-ᩴᪧᪿᫀᫌ-ᫎᬀ-ᬳᬵ-ᭃᭅ-ᭌᮀ-ᮩᮬ-ᮯᮺ-ᯥᯧ-ᯱᰀ-ᰶᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿᷧ-ᷴḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⒶ-ⓩⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙴ-ꙻꙿ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠅꠇ-ꠧꡀ-ꡳꢀ-ꣃꣅꣲ-ꣷꣻꣽ-ꣿꤊ-ꤪꤰ-ꥒꥠ-ꥼꦀ-ꦲꦴ-ꦿꧏꧠ-ꧯꧺ-ꧾꨀ-ꨶꩀ-ꩍꩠ-ꩶꩺ-ꪾꫀꫂꫛ-ꫝꫠ-ꫯꫲ-ꫵꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯪ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",se={alpha:{name:"Alphabetic",message:"{{field}} can contain only alphabetic characters",fn:function(t){return RegExp("^["+ie+"]+$").test(t)}},alpha_s:{name:"Alphabetic",message:"{{field}} can contain only alphabetic characters",fn:function(t){return RegExp("^["+ie+"\\s]+$").test(t)}},alnum:{name:"AlphaNumeric",message:"{{field}} can contain only alpha-numeric characters",fn:function(t){return RegExp("^["+ie+"0-9]+$").test(t)}},alnum_s:{name:"AlphaNumeric",message:"{{field}} can contain only alpha-numeric characters",fn:function(t){return RegExp("^["+ie+"\\s0-9]+$").test(t)}},email:{name:"Email",message:"Please provide a valid email address",fn:function(t){return/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(t)}},number:{name:"Number",message:"Please provide a valid number",fn:function(t){return/^[\-\+]?\d+([\.,]\d+)?$/.test(t)}},phone:{name:"Phone",message:"Please provide a valid phone number",fn:function(t){var e=t.replace(/[^\d]/g,"");return e.length>6&&e.length<=14}},color:{name:"Color",message:"Please provide a valid color code",fn:function(t){return/^#[0-9a-fA-F]{6}$/i.test(t)}},date:{name:"Date",message:"Please enter a valid date",fn:function(t){return re.isValidDate(t)}},datetime:{name:"DateTime",message:"Please enter a valid date",fn:function(t){return re.isValidISODateString(t)}},url:{name:"URL",message:"Please enter a valid URL",fn:function(t){return/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(t)}}},ae=function(){function t(t){if(this.type=t,this.message="",this.name="",!Object.keys(se).includes(t))throw Error("unsupported content type "+t);this.name=se[t].name,this.message=se[t].message}return t.prototype.validate=function(t,e){return void 0===e[t]||""==e[t]||se[this.type].fn(e[t])},t}(),oe=function(){function t(t){this.max_count=t,this.message="{{field}} selections exceeds max limit {{max_count}}"}return t.prototype.validate=function(t,e){return void 0===e[t]||(!Array.isArray(e[t])||!(e[t].length>this.max_count))},t}(),ue=function(){function t(t){this.min_count=t,this.message="For {{field}}, select at least {{min_count}} options"}return t.prototype.validate=function(t,e){return void 0===e[t]||(!Array.isArray(e[t])||!(e[t].length<this.min_count))},t}(),he=function(){function t(){this.message="{{field}} should be selected"}return t.prototype.validate=function(t,e){return!!e[t]},t}(),pe=function(){function t(t){this.regex=t,this.message="{{field}} does not match the pattern"}return t.prototype.validate=function(t,e){if(void 0===e[t])return!0;var n=e[t];return new RegExp(this.regex).test(n)},t}(),le=function(){function t(t){this.extensions_str=t,this.message="Valid file extensions are: {{extensions_str}}",this.valid_extensions=[],this.valid_extensions=this.extensions_str.split(",").map((function(t){return t.trim()}))}return t.prototype.validate=function(t,e){if(void 0!==e[t]){if("string"==typeof e[t])return this.checkExtension(String(e[t]));if(e[t].file_name&&"string"==typeof e[t].file_name)return this.checkExtension(String(e[t].file_name))}return!0},t.prototype.checkExtension=function(t){if(""==t)return!0;var e=t.split(".").pop();return void 0!==e&&!!this.valid_extensions.includes(e)},t}();function ce(t,e){var n=new Wt([t.name],e);for(var r in t.validations){var i=t.validations[r],s=fe(r,i);s&&(n.addValidation(s),n.addMessage(i.message||""),n.addCondition(i.condition||""))}return n}function fe(t,e){var n=null;switch(t){case"required":!0===e.enabled&&(n=new Jt);break;case"maxlength":e.size&&(n=new Xt(+e.size));break;case"minlength":e.size&&(n=new Kt(+e.size));break;case"min":void 0!==e.num&&(n=new Qt(">=",{test_value:+e.num}));break;case"max":void 0!==e.num&&(n=new Qt("<=",{test_value:+e.num}));break;case"confirm":e.other&&(n=new Qt("=",{test_field:String(e.other)}));break;case"max_date":void 0!==e.date&&""!==e.other&&(n=new Qt("<=",{test_value:new Date(String(e.date))}));break;case"min_date":void 0!==e.date&&""!==e.other&&(n=new Qt(">=",{test_value:new Date(String(e.date))}));break;case"content_type":var r=String(e.type);r&&(n=new ae(r));break;case"max_count":e.num&&(n=new oe(Number(e.num)));break;case"min_count":e.num&&(n=new ue(Number(e.num)));break;case"must_check":e.enabled&&(n=new he);break;case"should_select":e.item&&(n=new Qt("=",{test_value:String(e.item)}));break;case"should_not_select":e.item&&(n=new Qt("!=",{test_value:String(e.item)}));break;case"pattern":e.regexp&&(n=new pe(String(e.regexp)));break;case"file_extension":e.valid_extensions&&(n=new le(String(e.valid_extensions)))}return n}var de=function(){function t(){this.validator_makers={},this.all_validators={}}return t.prototype.addValidator=function(t,e){if("string"==typeof t)this.validator_makers[t]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=e.apply(void 0,t);return null!=r&&this.addValidation(r),this};else for(var n=0,r=t;n<r.length;n++){var i=r[n];this.addValidator(i,e)}return this},t.prototype.updateMessages=function(t){for(var e in t)this.all_validators[e]?this.all_validators[e].message=t[e]:this.all_validators[e]={message:t[e]}},t.prototype.field=function(t){var e=new Yt(new Wt([t],this));return Object.assign(e,this.validator_makers),e},t.prototype.fields=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new Yt(new Wt(t,this));return Object.assign(n,this.validator_makers),n},t.prototype.validate=function(t,e){return this.validateByRules(t,e)},t.prototype.validateByRules=function(t,e){for(var r={},i=0,s=t;i<s.length;i++){var a=s[i].validate(e);r=n(n({},r),a)}return{has_errors:Object.keys(r).length>0,error_map:r}},t.prototype.validateFields=function(t,e){var n=function(t,e){for(var n=[],r=0,i=t;r<i.length;r++){var s=ce(i[r],e);s.hasValidations()&&n.push(s)}return n}(t,this);return n.length<=0?{has_errors:!1}:this.validateByRules(n,e)},t.prototype.getMessageTemplate=function(t){var e="Error! ",n=Bt(t);return this.all_validators[n]&&this.all_validators[n].message?e=this.all_validators[n].message:t.message&&(e=t.message),e},t}();return t.makeBoel=function(){return function(t){return t.addValidator(["isRequired","areRequired","required"],(function(){return new Jt})).addValidator(["maxLength","checkMaxLength"],(function(t){return"number"==typeof t?new Xt(t):null})).addValidator(["minLength","checkMinLength"],(function(t){return"number"==typeof t?new Kt(t):null})).addValidator(["isAlphabetic","areAlphabetic"],(function(t){return void 0===t&&(t=!0),new ae(t?"alpha_s":"alpha")})).addValidator(["isAlphaNumeric","areAlphaNumeric"],(function(t){return void 0===t&&(t=!0),new ae(t?"alnum_s":"alnum")})).addValidator(["isEmail","areEmails"],(function(){return new ae("email")})).addValidator(["isPhone","isPhoneNumber","arePhoneNumbers"],(function(){return new ae("phone")})).addValidator(["isNumber","areNumbers"],(function(){return new ae("number")})).addValidator(["isColorCode","areColorCodes"],(function(){return new ae("color")})).addValidator(["isDate","areDates"],(function(){return new ae("date")})).addValidator(["isDateTime","areDateTime"],(function(){return new ae("datetime")})).addValidator(["isURL","areURLs"],(function(){return new ae("url")})).addValidator(["lessThan","isLessThan","areLessThan"],(function(t){return"number"==typeof t?new Qt("<",{test_value:t}):null})).addValidator(["lessThanOrEqualTo","isLessThanOrEqualTo","areLessThanOrEqualTo","max","isMax","areMax"],(function(t){return"number"==typeof t?new Qt("<=",{test_value:t}):null})).addValidator(["greaterThan","isGreaterThan","areGreaterThan"],(function(t){return"number"==typeof t?new Qt(">",{test_value:t}):null})).addValidator(["greaterThanOrEqualTo","isGreaterThanOrEqualTo","areGreaterThanOrEqualTo"],(function(t){return"number"==typeof t?new Qt(">=",{test_value:t}):null})).addValidator(["equalsTo","isEqualTo","areEqualTo"],(function(t){return"number"==typeof t||"string"==typeof t?new Qt("=",{test_value:t}):null})).addValidator(["notEqualTo","isNotEqualTo","areNotEqualTo"],(function(t){return"number"==typeof t||"string"==typeof t?new Qt("!=",{test_value:t}):null})).addValidator(["maxDate","onOrBefore"],(function(t){return"string"==typeof t?new Qt("<=",{test_value:new Date(t)}):null})).addValidator(["minDate","onOrAfter"],(function(t){return"string"==typeof t?new Qt(">=",{test_value:new Date(t)}):null})).addValidator(["lessThanField","isLessThanField","areLessThanField"],(function(t){return"string"==typeof t?new Qt("<",{test_field:t}):null})).addValidator(["lessThanOrEqualToField","isLessThanOrEqualToField","areLessThanOrEqualToField"],(function(t){return"string"==typeof t?new Qt("<=",{test_field:t}):null})).addValidator(["greaterThanField","isGreaterThanField","areGreaterThanField"],(function(t){return"string"==typeof t?new Qt(">",{test_field:t}):null})).addValidator(["greaterThanOrEqualToField","isGreaterThanOrEqualToField","areGreaterThanOrEqualToField"],(function(t){return"string"==typeof t?new Qt(">=",{test_field:t}):null})).addValidator(["equalsToField","isEqualToField","areEqualToField"],(function(t){return"string"==typeof t?new Qt("=",{test_field:t}):null})).addValidator(["notEqualsToField","isNotEqualToField","areNotEqualToField"],(function(t){return"string"==typeof t?new Qt("!=",{test_field:t}):null})).addValidator(["maxSelections","hasMaxSelections","maxCount"],(function(t){return"number"==typeof t?new oe(t):null})).addValidator(["minSelections","hasMinSelections","minCount"],(function(t){return"number"==typeof t?new ue(t):null})).addValidator(["isSelected","selected"],(function(){return new he})).addValidator(["shouldSelect"],(function(t){return new Qt("=",{test_value:String(t)})})).addValidator(["shouldNotSelect"],(function(t){return new Qt("!=",{test_value:String(t)})})).addValidator(["matchesPattern","pattern"],(function(t){return new pe(String(t))})).addValidator(["hasExtension","hasFileExtension"],(function(t){return"string"==typeof t?new le(t):null})),t}(new de)},Object.defineProperty(t,"__esModule",{value:!0}),t}({});