function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function a(e,t,n){return a=i()?Reflect.construct.bind():function(e,t,n){var i=[null];i.push.apply(i,t);var a=new(Function.bind.apply(e,i));return n&&r(a,n.prototype),a},a.apply(null,arguments)}function o(e){return Function.toString.call(e).indexOf(`[native code]`)!==-1}function s(e){var t=typeof Map==`function`?new Map:void 0;return s=function(e){if(e===null||!o(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return a(e,arguments,n(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),r(i,e)},s(e)}var c=/%[sdj%]/g,l=function(){};function u(e){if(!e||!e.length)return null;var t={};return e.forEach(function(e){var n=e.field;t[n]=t[n]||[],t[n].push(e)}),t}function d(e){var t=[...arguments].slice(1),n=0,r=t.length;return typeof e==`function`?e.apply(null,t):typeof e==`string`?e.replace(c,function(e){if(e===`%%`)return`%`;if(n>=r)return e;switch(e){case`%s`:return String(t[n++]);case`%d`:return Number(t[n++]);case`%j`:try{return JSON.stringify(t[n++])}catch{return`[Circular]`}break;default:return e}}):e}function f(e){return e===`string`||e===`url`||e===`hex`||e===`email`||e===`date`||e===`pattern`}function p(e,t){return!!(e==null||t===`array`&&Array.isArray(e)&&!e.length||f(t)&&typeof e==`string`&&!e)}function m(e,t,n){var r=[],i=0,a=e.length;function o(e){r.push.apply(r,e||[]),i++,i===a&&n(r)}e.forEach(function(e){t(e,o)})}function h(e,t,n){var r=0,i=e.length;function a(o){if(o&&o.length){n(o);return}var s=r;r+=1,s()\[\]\\.,;:\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},O={integer:function(e){return O.number(e)&&parseInt(e,10)===e},float:function(e){return O.number(e)&&!O.integer(e)},array:function(e){return Array.isArray(e)},regexp:function(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch{return!1}},date:function(e){return typeof e.getTime==`function`&&typeof e.getMonth==`function`&&typeof e.getYear==`function`&&!isNaN(e.getTime())},number:function(e){return isNaN(e)?!1:typeof e==`number`},object:function(e){return typeof e==`object`&&!O.array(e)},method:function(e){return typeof e==`function`},email:function(e){return typeof e==`string`&&e.length<=320&&!!e.match(D.email)},url:function(e){return typeof e==`string`&&e.length<=2048&&!!e.match(E())},hex:function(e){return typeof e==`string`&&!!e.match(D.hex)}},k=function(e,t,n,r,i){if(e.required&&t===void 0){C(e,t,n,r,i);return}var a=[`integer`,`float`,`array`,`regexp`,`object`,`method`,`email`,`number`,`date`,`url`,`hex`],o=e.type;a.indexOf(o)>-1?O[o](t)||r.push(d(i.messages.types[o],e.fullField,e.type)):o&&typeof t!==e.type&&r.push(d(i.messages.types[o],e.fullField,e.type))},A=function(e,t,n,r,i){var a=typeof e.len==`number`,o=typeof e.min==`number`,s=typeof e.max==`number`,c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,l=t,u=null,f=typeof t==`number`,p=typeof t==`string`,m=Array.isArray(t);if(f?u=`number`:p?u=`string`:m&&(u=`array`),!u)return!1;m&&(l=t.length),p&&(l=t.replace(c,`_`).length),a?l!==e.len&&r.push(d(i.messages[u].len,e.fullField,e.len)):o&&!s&&le.max?r.push(d(i.messages[u].max,e.fullField,e.max)):o&&s&&(le.max)&&r.push(d(i.messages[u].range,e.fullField,e.min,e.max))},j=`enum`,M={required:C,whitespace:w,type:k,range:A,enum:function(e,t,n,r,i){e[j]=Array.isArray(e[j])?e[j]:[],e[j].indexOf(t)===-1&&r.push(d(i.messages[j],e.fullField,e[j].join(`, `)))},pattern:function(e,t,n,r,i){e.pattern&&(e.pattern instanceof RegExp?(e.pattern.lastIndex=0,e.pattern.test(t)||r.push(d(i.messages.pattern.mismatch,e.fullField,t,e.pattern))):typeof e.pattern==`string`&&(new RegExp(e.pattern).test(t)||r.push(d(i.messages.pattern.mismatch,e.fullField,t,e.pattern))))}},N=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t,`string`)&&!e.required)return n();M.required(e,t,r,a,i,`string`),p(t,`string`)||(M.type(e,t,r,a,i),M.range(e,t,r,a,i),M.pattern(e,t,r,a,i),e.whitespace===!0&&M.whitespace(e,t,r,a,i))}n(a)},P=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i),t!==void 0&&M.type(e,t,r,a,i)}n(a)},F=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(t===``&&(t=void 0),p(t)&&!e.required)return n();M.required(e,t,r,a,i),t!==void 0&&(M.type(e,t,r,a,i),M.range(e,t,r,a,i))}n(a)},I=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i),t!==void 0&&M.type(e,t,r,a,i)}n(a)},L=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i),p(t)||M.type(e,t,r,a,i)}n(a)},R=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i),t!==void 0&&(M.type(e,t,r,a,i),M.range(e,t,r,a,i))}n(a)},z=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i),t!==void 0&&(M.type(e,t,r,a,i),M.range(e,t,r,a,i))}n(a)},B=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(t==null&&!e.required)return n();M.required(e,t,r,a,i,`array`),t!=null&&(M.type(e,t,r,a,i),M.range(e,t,r,a,i))}n(a)},V=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i),t!==void 0&&M.type(e,t,r,a,i)}n(a)},H=`enum`,U=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i),t!==void 0&&M[H](e,t,r,a,i)}n(a)},W=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t,`string`)&&!e.required)return n();M.required(e,t,r,a,i),p(t,`string`)||M.pattern(e,t,r,a,i)}n(a)},G=function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t,`date`)&&!e.required)return n();if(M.required(e,t,r,a,i),!p(t,`date`)){var o=t instanceof Date?t:new Date(t);M.type(e,o,r,a,i),o&&M.range(e,o.getTime(),r,a,i)}}n(a)},K=function(e,t,n,r,i){var a=[],o=Array.isArray(t)?`array`:typeof t;M.required(e,t,r,a,i,o),n(a)},q=function(e,t,n,r,i){var a=e.type,o=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t,a)&&!e.required)return n();M.required(e,t,r,o,i,a),p(t,a)||M.type(e,t,r,o,i)}n(o)},J={string:N,method:P,number:F,boolean:I,regexp:L,integer:R,float:z,array:B,object:V,enum:U,pattern:W,date:G,url:q,hex:q,email:q,required:K,any:function(e,t,n,r,i){var a=[];if(e.required||!e.required&&r.hasOwnProperty(e.field)){if(p(t)&&!e.required)return n();M.required(e,t,r,a,i)}n(a)}};function Y(){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 X=Y(),Z=function(){function t(e){this.rules=null,this._messages=X,this.define(e)}var n=t.prototype;return n.define=function(e){var t=this;if(!e)throw Error(`Cannot configure a schema with no rules`);if(typeof e!=`object`||Array.isArray(e))throw Error(`Rules must be an object`);this.rules={},Object.keys(e).forEach(function(n){var r=e[n];t.rules[n]=Array.isArray(r)?r:[r]})},n.messages=function(e){return e&&(this._messages=S(Y(),e)),this._messages},n.validate=function(n,r,i){var a=this;r===void 0&&(r={}),i===void 0&&(i=function(){});var o=n,s=r,c=i;if(typeof s==`function`&&(c=s,s={}),!this.rules||Object.keys(this.rules).length===0)return c&&c(null,o),Promise.resolve(o);function l(e){var t=[],n={};function r(e){if(Array.isArray(e)){var n;t=(n=t).concat.apply(n,e)}else t.push(e)}for(var i=0;i