!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define("$validator",["vue"],t):"object"===typeof exports?exports.$validator=t(require("vue")):e.$validator=t(e.Vue)}("undefined"!==typeof self?self:this,(function(e){return function(){"use strict";var t={154:function(t){t.exports=e}},i={};function s(e){var a=i[e];if(void 0!==a)return a.exports;var n=i[e]={exports:{}};return t[e](n,n.exports,s),n.exports}s.d=function(e,t){for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){s.r(a),s.d(a,{default:function(){return u},install:function(){return d},useValidator:function(){return c}});var e=s(154);const t=/(?:^\[object\s(.*?)\]$)/;var i=e=>Object.prototype.toString.call(e).replace(t,"$1").toLowerCase();const n={required:{validate(e){return e&&e.length>0},message:"%s is required"}};let o={};function r(e,t){console.warn("[$validator]",`The '${e}' has been deprecated. Use the '${t}' instead`)}class l{constructor(){const t=(0,e.getCurrentInstance)();this.instance=t,this.validations=[],this.customValidations=[]}validate(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s={valid:!0,validFields:[],invalidFields:[],messages:[],message:"",validMsg:{}},a=[];if(this.instance){const{setupState:e,data:t}=this.instance;a=e.validations||t.validations||[]}if(this.validations=this.customValidations.length?this.customValidations:a,!Array.isArray(this.validations))throw new Error("[$validator]: validations must be an array in 10.7.0");for(let n=0,r=this.validations.length;n<r;n++){const a=this.validations[n],{key:r,label:l,validator:d}=a,c=r;if(!t.length||t.includes(c)){const t=l||c,n=d.split(",").map((e=>e.trim()));let r=!0;for(let l=0,d=n.length;l<d;l++){let d=n[l],u=a[d],v="object"===i(u)?u:o[d];if(v&&"function"===i(v.validate)){let a=[e[c],e];if(!v.validate(...a)){r=!1;let e="";switch(i(v.message)){case"string":e=v.message.replace("%s",t);break;case"function":e=v.message(...a);break;default:console.warn("[$validator]",`'${c}.message' must be a string or function`)}e&&s.messages.push(e);break}}else console.warn("[$validator]",`The field '${c}' is missing a validation rule: '${d}'`)}r?s.validFields.push(c):s.invalidFields.push(c)}}return s.messages.length&&(s.valid=!1,s.message=s.messages[0],s.invalidFields.forEach(((e,t)=>{s.validMsg[e]=s.messages[t]}))),s.validFields.forEach((e=>{s.validMsg[e]=""})),s}resetValidations(){r("resetValidations","clear")}setValidations(){r("setValidations","set")}clear(){this.customValidations=[]}get(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e?this.customValidations.find((t=>{let{key:i}=t;return i===e})):this.customValidations}set(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Array.isArray(e))this.customValidations=e;else{const i=this.customValidations.findIndex((t=>{let{key:i}=t;return i===e}));~i?this.customValidations[i]=Object.assign({},t):this.customValidations=[Object.assign({key:e},t)]}}}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o=Object.assign({},n,t);const i=new l;e.config.globalProperties.$validator=i,e.provide("validator",i)}const c=()=>new l;var u={install:d}}(),a}()}));