/** * Minified by jsDelivr using Terser v5.15.1. * Original file: /npm/async-validator@4.2.5/dist-web/index.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var r=1;r1?r-1:0),n=1;n=a)return e;switch(e){case"%s":return String(t[i++]);case"%d":return Number(t[i++]);case"%j":try{return JSON.stringify(t[i++])}catch(e){return"[Circular]"}break;default:return e}}));return s}return e}function isNativeStringType(e){return"string"===e||"url"===e||"hex"===e||"email"===e||"date"===e||"pattern"===e}function isEmptyValue(e,r){return null==e||(!("array"!==r||!Array.isArray(e)||e.length)||!(!isNativeStringType(r)||"string"!=typeof e||e))}function asyncParallelArray(e,r,t){var n=[],i=0,a=e.length;function s(e){n.push.apply(n,e||[]),++i===a&&t(n)}e.forEach((function(e){r(e,s)}))}function asyncSerialArray(e,r,t){var n=0,i=e.length;!function a(s){if(s&&s.length)t(s);else{var u=n;n+=1,u()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},types={integer:function(e){return types.number(e)&&parseInt(e,10)===e},float:function(e){return types.number(e)&&!types.integer(e)},array:function(e){return Array.isArray(e)},regexp:function(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch(e){return!1}},date:function(e){return"function"==typeof e.getTime&&"function"==typeof e.getMonth&&"function"==typeof e.getYear&&!isNaN(e.getTime())},number:function(e){return!isNaN(e)&&"number"==typeof e},object:function(e){return"object"==typeof e&&!types.array(e)},method:function(e){return"function"==typeof e},email:function(e){return"string"==typeof e&&e.length<=320&&!!e.match(pattern$2.email)},url:function(e){return"string"==typeof e&&e.length<=2048&&!!e.match(getUrlRegex())},hex:function(e){return"string"==typeof e&&!!e.match(pattern$2.hex)}},type$1=function(e,r,t,n,i){if(e.required&&void 0===r)required$1(e,r,t,n,i);else{var a=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(a)>-1?types[a](r)||n.push(format(i.messages.types[a],e.fullField,e.type)):a&&typeof r!==e.type&&n.push(format(i.messages.types[a],e.fullField,e.type))}},range=function(e,r,t,n,i){var a="number"==typeof e.len,s="number"==typeof e.min,u="number"==typeof e.max,o=r,l=null,f="number"==typeof r,c="string"==typeof r,p=Array.isArray(r);if(f?l="number":c?l="string":p&&(l="array"),!l)return!1;p&&(o=r.length),c&&(o=r.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"_").length),a?o!==e.len&&n.push(format(i.messages[l].len,e.fullField,e.len)):s&&!u&&oe.max?n.push(format(i.messages[l].max,e.fullField,e.max)):s&&u&&(oe.max)&&n.push(format(i.messages[l].range,e.fullField,e.min,e.max))},ENUM$1="enum",enumerable$1=function(e,r,t,n,i){e[ENUM$1]=Array.isArray(e[ENUM$1])?e[ENUM$1]:[],-1===e[ENUM$1].indexOf(r)&&n.push(format(i.messages[ENUM$1],e.fullField,e[ENUM$1].join(", ")))},pattern$1=function(e,r,t,n,i){if(e.pattern)if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(r)||n.push(format(i.messages.pattern.mismatch,e.fullField,r,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(r)||n.push(format(i.messages.pattern.mismatch,e.fullField,r,e.pattern))}},rules={required:required$1,whitespace:whitespace,type:type$1,range:range,enum:enumerable$1,pattern:pattern$1},string=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r,"string")&&!e.required)return t();rules.required(e,r,n,a,i,"string"),isEmptyValue(r,"string")||(rules.type(e,r,n,a,i),rules.range(e,r,n,a,i),rules.pattern(e,r,n,a,i),!0===e.whitespace&&rules.whitespace(e,r,n,a,i))}t(a)},method=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),void 0!==r&&rules.type(e,r,n,a,i)}t(a)},number=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(""===r&&(r=void 0),isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),void 0!==r&&(rules.type(e,r,n,a,i),rules.range(e,r,n,a,i))}t(a)},_boolean=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),void 0!==r&&rules.type(e,r,n,a,i)}t(a)},regexp=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),isEmptyValue(r)||rules.type(e,r,n,a,i)}t(a)},integer=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),void 0!==r&&(rules.type(e,r,n,a,i),rules.range(e,r,n,a,i))}t(a)},floatFn=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),void 0!==r&&(rules.type(e,r,n,a,i),rules.range(e,r,n,a,i))}t(a)},array=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(null==r&&!e.required)return t();rules.required(e,r,n,a,i,"array"),null!=r&&(rules.type(e,r,n,a,i),rules.range(e,r,n,a,i))}t(a)},object=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),void 0!==r&&rules.type(e,r,n,a,i)}t(a)},ENUM="enum",enumerable=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i),void 0!==r&&rules[ENUM](e,r,n,a,i)}t(a)},pattern=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r,"string")&&!e.required)return t();rules.required(e,r,n,a,i),isEmptyValue(r,"string")||rules.pattern(e,r,n,a,i)}t(a)},date=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r,"date")&&!e.required)return t();var s;if(rules.required(e,r,n,a,i),!isEmptyValue(r,"date"))s=r instanceof Date?r:new Date(r),rules.type(e,s,n,a,i),s&&rules.range(e,s.getTime(),n,a,i)}t(a)},required=function(e,r,t,n,i){var a=[],s=Array.isArray(r)?"array":typeof r;rules.required(e,r,n,a,i,s),t(a)},type=function(e,r,t,n,i){var a=e.type,s=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r,a)&&!e.required)return t();rules.required(e,r,n,s,i,a),isEmptyValue(r,a)||rules.type(e,r,n,s,i)}t(s)},any=function(e,r,t,n,i){var a=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();rules.required(e,r,n,a,i)}t(a)},validators={string:string,method:method,number:number,boolean:_boolean,regexp:regexp,integer:integer,float:floatFn,array:array,object:object,enum:enumerable,pattern:pattern,date:date,url:type,hex:type,email:type,required:required,any:any};function newMessages(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone:function(){var e=JSON.parse(JSON.stringify(this));return e.clone=this.clone,e}}}var messages=newMessages(),Schema=function(){function e(e){this.rules=null,this._messages=messages,this.define(e)}var r=e.prototype;return r.define=function(e){var r=this;if(!e)throw new Error("Cannot configure a schema with no rules");if("object"!=typeof e||Array.isArray(e))throw new Error("Rules must be an object");this.rules={},Object.keys(e).forEach((function(t){var n=e[t];r.rules[t]=Array.isArray(n)?n:[n]}))},r.messages=function(e){return e&&(this._messages=deepMerge(newMessages(),e)),this._messages},r.validate=function(r,t,n){var i=this;void 0===t&&(t={}),void 0===n&&(n=function(){});var a=r,s=t,u=n;if("function"==typeof s&&(u=s,s={}),!this.rules||0===Object.keys(this.rules).length)return u&&u(null,a),Promise.resolve(a);if(s.messages){var o=this.messages();o===messages&&(o=newMessages()),deepMerge(o,s.messages),s.messages=o}else s.messages=this.messages();var l={};(s.keys||Object.keys(this.rules)).forEach((function(e){var t=i.rules[e],n=a[e];t.forEach((function(t){var s=t;"function"==typeof s.transform&&(a===r&&(a=_extends({},a)),n=a[e]=s.transform(n)),(s="function"==typeof s?{validator:s}:_extends({},s)).validator=i.getValidationMethod(s),s.validator&&(s.field=e,s.fullField=s.fullField||e,s.type=i.getType(s),l[e]=l[e]||[],l[e].push({rule:s,value:n,source:a,field:e}))}))}));var f={};return asyncMap(l,s,(function(r,t){var n,i=r.rule,u=!("object"!==i.type&&"array"!==i.type||"object"!=typeof i.fields&&"object"!=typeof i.defaultField);function o(e,r){return _extends({},r,{fullField:i.fullField+"."+e,fullFields:i.fullFields?[].concat(i.fullFields,[e]):[e]})}function l(n){void 0===n&&(n=[]);var l=Array.isArray(n)?n:[n];!s.suppressWarning&&l.length&&e.warning("async-validator:",l),l.length&&void 0!==i.message&&(l=[].concat(i.message));var c=l.map(complementError(i,a));if(s.first&&c.length)return f[i.field]=1,t(c);if(u){if(i.required&&!r.value)return void 0!==i.message?c=[].concat(i.message).map(complementError(i,a)):s.error&&(c=[s.error(i,format(s.messages.required,i.field))]),t(c);var p={};i.defaultField&&Object.keys(r.value).map((function(e){p[e]=i.defaultField})),p=_extends({},p,r.rule.fields);var d={};Object.keys(p).forEach((function(e){var r=p[e],t=Array.isArray(r)?r:[r];d[e]=t.map(o.bind(null,e))}));var y=new e(d);y.messages(s.messages),r.rule.options&&(r.rule.options.messages=s.messages,r.rule.options.error=s.error),y.validate(r.value,r.rule.options||s,(function(e){var r=[];c&&c.length&&r.push.apply(r,c),e&&e.length&&r.push.apply(r,e),t(r.length?r:null)}))}else t(c)}if(u=u&&(i.required||!i.required&&r.value),i.field=r.field,i.asyncValidator)n=i.asyncValidator(i,r.value,l,r.source,s);else if(i.validator){try{n=i.validator(i,r.value,l,r.source,s)}catch(e){null==console.error||console.error(e),s.suppressValidatorError||setTimeout((function(){throw e}),0),l(e.message)}!0===n?l():!1===n?l("function"==typeof i.message?i.message(i.fullField||i.field):i.message||(i.fullField||i.field)+" fails"):n instanceof Array?l(n):n instanceof Error&&l(n.message)}n&&n.then&&n.then((function(){return l()}),(function(e){return l(e)}))}),(function(e){!function(e){for(var r,t,n=[],i={},s=0;s