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