/**
  * vee-validate v4.0.0-beta.7
  * (c) 2020 Abdelrahman Awad
  * @license MIT
  */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function a(e){return"function"==typeof e}const r=e=>null!==e&&e&&"object"==typeof e&&!Array.isArray(e),n={};function i(e){return a(e)&&!!e.__locatorRef}function l(e){return["input","textarea","select"].includes(e)}function o(e){return e&&a(e.validate)}function u(e){return"checkbox"===e||"radio"===e}function s(e){return Number(e)>=0}function d(e){return/^\[.+\]$/i.test(e)}function c(e){return`v_${e}_error`}function v(e){return d(e)?e.replace(/\[|\]/gi,""):e}function f(e,t){if(e)return d(t)?e[v(t)]:t.split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{if(e&&t in e)return e[t]}),e)}function m(e,t,a){if(d(t))return void(e[v(t)]=a);const r=t.split(/\.|\[(\d+)\]/).filter(Boolean);let n=e;for(let e=0;e<r.length;e++){if(e===r.length-1)return void(n[r[e]]=a);r[e]in n||(n[r[e]]=s(r[e+1])?[]:{}),n=n[r[e]]}}function p(e,t){Array.isArray(e)&&s(t)?e.splice(Number(t),1):delete e[t]}function h(e,t){if(d(t))return void delete e[v(t)];const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let n=e;for(let e=0;e<a.length;e++){if(e===a.length-1){p(n,a[e]);break}if(!(a[e]in n))break;n=n[a[e]]}const i=a.map(((t,r)=>f(e,a.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)l=i[t],(Array.isArray(l)?0===l.length:r(l)&&0===Object.keys(l).length)&&(0!==t?p(i[t-1],a[t-1]):p(e,a[0]));var l}function y(e){if(!(t=e)||!("undefined"!=typeof Event&&a(Event)&&t instanceof Event||t&&t.srcElement))return e;var t;const r=e.target;return"checkbox"===r.type&&"_value"in r?r._value:"file"===r.type&&r.files?Array.from(r.files):r.value}function b(e){return t.isRef(e)?e.value:e}function g(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)||o(e)||r(e)&&e._$$isNormalized?e:r(e)?Object.keys(e).reduce(((t,a)=>{const n=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(r(e))return e;return[e]}(e[a]);return!1!==e[a]&&(t[a]=O(n)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const a=V(t);return a.name?(e[a.name]=O(a.params),e):e}),t):t}function O(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):Object.keys(e).reduce(((a,r)=>(a[r]=t(e[r]),a)),{})}const V=e=>{let t=[];const a=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:a,params:t}};const j=(e,t)=>e.slots.default&&e.slots.default(t)||[];let A=Object.assign({},{generateMessage:({field:e})=>e+" is not valid.",bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const S=()=>A,E=e=>{A=Object.assign(Object.assign({},A),e)};async function k(e,t,r={}){const n=null==r?void 0:r.bails,i={name:(null==r?void 0:r.name)||"{field}",rules:g(t),bails:null==n||n,formData:(null==r?void 0:r.values)||{}},l=await async function(e,t){if(o(e.rules))return async function(e,t){return{errors:await e.rules.validate(t,{abortEarly:e.bails}).then((()=>[])).catch((e=>{if("ValidationError"===e.name)return e.errors;throw e}))}}(e,t);if(a(e.rules)){const a=await e.rules(t),r="string"!=typeof a&&a,n="string"==typeof a?a:F({field:e.name,value:t,form:e.formData});return{errors:r?[]:[n]}}const r=[],n=Object.keys(e.rules),i=n.length;for(let a=0;a<i;a++){const i=n[a],l=await w(e,t,{name:i,params:e.rules[i]});if(l.error&&(r.push(l.error),e.bails))return{errors:r}}return{errors:r}}(i,e);return{errors:l.errors}}async function w(e,t,a){const r=(l=a.name,n[l]);var l;if(!r)throw new Error(`No such validator '${a.name}' exists.`);const o=function(e,t){const a=e=>i(e)?e(t):e;if(Array.isArray(e))return e.map(a);return Object.keys(e).reduce(((t,r)=>(t[r]=a(e[r]),t)),{})}(a.params,e.formData),u={field:e.name,value:t,form:e.formData,rule:a},s=await r(t,o,u);return"string"==typeof s?{error:s}:{error:s?void 0:F(u)}}function F(e){const t=S().generateMessage;return t?t(e):"Field is invalid"}const M=Symbol("vee-validate-form"),x=Symbol("vee-validate-form-errors"),B=Symbol("vee-validate-form-initial-values");function R(e,r,n){const{initialValue:l,form:o,validateOnMount:s,bails:d,disabled:v,type:p,valueProp:h,label:O,validateOnValueUpdate:V}=function(e,a){const r=t.inject(M,void 0),n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,rules:"",disabled:!1,form:r,label:e,validateOnValueUpdate:!0});if(!a)return n();return Object.assign(Object.assign({},n()),a||{})}(e,n),{meta:j,errors:A,handleBlur:S,handleInput:E,reset:w,patch:F,value:x,checked:R}=function({name:e,initValue:a,form:r,type:n,valueProp:i}){var l;const o=t.ref([]),{reset:s,meta:d}=function(){const e=()=>({untouched:!0,touched:!1,dirty:!1,pristine:!0,valid:!1,invalid:!1,validated:!1,pending:!1,changed:!1,passed:!1,failed:!1}),a=t.reactive(e());function r(){const t=e();Object.keys(a).forEach((e=>{["passed","failed"].includes(e)||(a[e]=t[e])}))}return t.watchEffect((()=>{a.passed=a.valid&&a.validated,a.failed=a.invalid&&a.validated})),{meta:a,reset:r}}(),c=null!==(l=f(b(t.inject(B,{})),e))&&void 0!==l?l:a,v=function(e,a,r){if(!r)return t.ref(e);m(r.values,a,e);return t.computed({get:()=>f(r.values,a),set(e){r.setFieldValue(a,e)}})}(c,e,r);u(n)&&c&&(v.value=c);const p=u(n)?t.computed((()=>Array.isArray(v.value)?v.value.includes(b(i)):b(i)===v.value)):void 0;(void 0===p||p.value)&&(v.value=c);const h=()=>{d.touched=!0,d.untouched=!1},g=e=>{u(n)||(v.value=y(e)),d.dirty=!0,d.pristine=!1};function O(e){return o.value=e.errors,d.changed=c!==v.value,d.valid=!e.errors.length,d.invalid=!!e.errors.length,d.validated=!0,e}const V=()=>{o.value=[],s()};return{meta:d,errors:o,patch:O,reset:V,handleBlur:h,handleInput:g,value:v,checked:p}}({name:e,initValue:b(l),form:o,type:p,valueProp:h}),_=function(e,t){if(!e)return;return e[t]}(null==o?void 0:o.schema,e),C=t.computed((()=>g(_||b(r)))),P=async()=>{var t;if(j.pending=!0,!o||!o.validateSchema){const e=await k(x.value,C.value,{name:O,values:null!==(t=null==o?void 0:o.values)&&void 0!==t?t:{},bails:d});return j.valid=!e.errors.length,j.invalid=!!e.errors.length,j.pending=!1,e}const a=await o.validateSchema();return j.pending=!1,a[e]},$=()=>P().then(F);t.onMounted((()=>{P().then((e=>{s&&F(e)}))}));const I=t.computed((()=>A.value[0])),U=function(e,a){return t.computed((()=>({"aria-invalid":a.failed?"true":"false","aria-describedBy":c(e)})))}(e,j),D={name:e,value:x,meta:j,errors:A,errorMessage:I,aria:U,reset:w,validate:$,handleChange:e=>{var t,a;if(!R||R.value!==(null===(a=null===(t=e)||void 0===t?void 0:t.target)||void 0===a?void 0:a.checked))return x.value=y(e),j.dirty=!0,j.pristine=!1,V?void 0:$()},handleBlur:S,handleInput:E,disabled:v,setValidationState:F,type:p,valueProp:h,checked:R,idx:-1};if(V&&t.watch(x,$,{deep:!0}),t.isRef(r)&&t.watch(r,$,{deep:!0}),!o)return D;o.register(D),t.onBeforeUnmount((()=>{o.unregister(D)}));const N=t.computed((()=>{const e=C.value;return!e||a(e)||a(e.validate)?[]:Object.keys(e).reduce(((e,t)=>{const a=(r=C.value[t],Array.isArray(r)?r.filter(i):Object.keys(r).filter((e=>i(r[e]))).map((e=>r[e]))).map((e=>e.__locatorRef));var r;return e.push(...a),e}),[])}));return t.watchEffect((()=>{N.value.length&&N.value.forEach((e=>{e in o.values&&j.validated&&$()}))})),D}const _=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:null},validateOnMount:{type:Boolean,default:!1},bails:{type:Boolean,default:()=>S().bails},disabled:{type:Boolean,default:!1},label:{type:String,default:void 0}},setup(e,a){const[r,n]=[t.toRef(e,"disabled"),t.toRef(e,"rules")],{errors:i,value:o,errorMessage:s,validate:d,handleChange:c,handleBlur:v,handleInput:f,reset:m,meta:p,aria:h,checked:y}=R(e.name,n,{validateOnMount:e.validateOnMount,bails:e.bails,disabled:r,type:a.attrs.type,initialValue:u(a.attrs.type)||"modelValue"in a.attrs?a.attrs.modelValue:a.attrs.value,valueProp:a.attrs.value,label:e.label||e.name,validateOnValueUpdate:!1});let b=!1;function g(){b=!0,t.nextTick((()=>{b=!1}))}const O="modelValue"in a.attrs?function(e){c(e),a.emit("update:modelValue",o.value)}:c,V="modelValue"in a.attrs?function(e){f(e),a.emit("update:modelValue",o.value)}:f,{validateOnInput:A,validateOnChange:E,validateOnBlur:k,validateOnModelUpdate:w}=S(),F=()=>{const t={name:e.name,disabled:e.disabled,onBlur:[v],onInput:[V,g],onChange:[V,g]};var r,n;return A&&t.onInput.push(O),E&&t.onChange.push(O),k&&t.onBlur.push(d),w&&(t["onUpdate:modelValue"]=[O,g]),u(a.attrs.type)&&y?t.checked=y.value:t.value=o.value,r=C(e,a),n=a.attrs.type,l(r)&&"file"===n&&delete t.value,{field:t,aria:h.value,meta:p,errors:i.value,errorMessage:s.value,validate:d,reset:m,handleChange:O}};return()=>{const r=C(e,a),n=F();"modelValue"in a.attrs&&String(a.attrs.modelValue)!==String(o.value)&&!b&&t.nextTick((()=>{c(a.attrs.modelValue)}));const i=j(a,n);return r?t.h(r,Object.assign(Object.assign(Object.assign({},a.attrs),n.field),l(r)?n.aria:{}),i):i}}});function C(e,t){let a=e.as||"";return e.as||t.slots.default||(a="input"),a}function P(e){const a=t.ref([]),r=t.ref(!1),n=t.computed((()=>a.value.reduce(((e,t)=>{if(!e[t.name])return e[t.name]=t,t.idx=-1,e;if(!Array.isArray(e[t.name])){const a=e[t.name];a.idx=0,e[t.name]=[a]}return t.idx=e[t.name].length,e[t.name].push(t),e}),{}))),i=t.computed((()=>a.value.filter((e=>!b(e.disabled)))));function l(e,t){const a=n.value[e];a&&(Array.isArray(a)?a.forEach((e=>{e.setValidationState({errors:[t]})})):a.setValidationState({errors:[t]}))}function u(e){Object.keys(e).forEach((t=>{l(t,e[t])}))}function s(e,t){var a;const r=n.value[e];if(Array.isArray(r)&&"checkbox"===(null===(a=r[0])||void 0===a?void 0:a.type)&&!Array.isArray(t)){const a=f(c,e),r=Array.isArray(a)?[...a]:[],n=r.indexOf(t);return n>=0?r.splice(n,1):r.push(t),void m(c,e,r)}let i=t;"checkbox"===(null==r?void 0:r.type)&&(i=f(c,e)===t?void 0:t),m(c,e,i)}function d(e){Object.keys(e).forEach((t=>{s(t,e[t])}))}const c=t.reactive({}),v={register(e){a.value.push(e)},unregister(e){var t,r;const n=a.value.indexOf(e);if(-1===n)return;a.value.splice(n,1);const i=e.name;if(-1===e.idx)return void h(c,i);const l=null===(r=null===(t=f(c,i))||void 0===t?void 0:t.indexOf)||void 0===r?void 0:r.call(t,b(e.valueProp));void 0!==l?-1!==l&&(Array.isArray(c[i])?h(c,`${i}.${l}`):h(c,i)):h(c,i)},fields:n,values:c,schema:null==e?void 0:e.validationSchema,validateSchema:o(null==e?void 0:e.validationSchema)?(e=!1)=>async function(e,t=!1){const a=await e.schema.validate(e.values,{abortEarly:!1}).then((()=>[])).catch((e=>{if("ValidationError"!==e.name)throw e;return e.inner||[]})),r=e.fields.value,n=a.reduce(((e,t)=>(e[t.path]=t,e)),{});return Object.keys(r).reduce(((e,a)=>{const i=r[a],l={errors:(n[a]||{errors:[]}).errors};e[a]=l;const o=Array.isArray(i),u=o?i.some((e=>e.meta.validated)):i.meta.validated;return t||u?o?(i.forEach((e=>e.setValidationState(l))),e):(i.setValidationState(l),e):e}),{})}(v,e):void 0,setFieldValue:s,setValues:d,setErrors:u,setFieldError:l},p=async()=>{if(v.validateSchema)return v.validateSchema(!0).then((e=>Object.keys(e).every((t=>!e[t].errors.length))));return(await Promise.all(i.value.map((e=>e.validate())))).every((e=>!e.errors.length))},y=t.computed((()=>i.value.reduce(((e,t)=>{if(Array.isArray(n.value[t.name])){const a=n.value[t.name];return e[t.name]=b((a.find((e=>b(e.checked)))||t).errorMessage),e}return e[t.name]=b(t.errorMessage),e}),{}))),g=t.computed((()=>i.value.reduce(((e,t)=>(m(e,t.name,b(t.value)),e)),{}))),O=e=>function(t){return t instanceof Event&&(t.preventDefault(),t.stopPropagation()),r.value=!0,p().then((a=>{if(a&&"function"==typeof e)return e(g.value,{evt:t,form:v})})).then((()=>{r.value=!1}),(e=>{throw r.value=!1,e}))},V=O(((e,{evt:t})=>{var a;t&&(null===(a=null==t?void 0:t.target)||void 0===a||a.submit())})),j=function(e){const a=Object.keys($);return t.computed((()=>a.reduce(((t,a)=>{const r=$[a];return t[a]=e.value[r]((e=>e.meta[a])),t}),{})))}(a);t.provide(M,v),t.provide(x,y);const A=t.computed((()=>{const a=(null==e?void 0:e.initialValues)||{};return t.isRef(a)?a.value:a}));return t.provide(B,A),t.watch(A,(e=>{const t=e=>e.meta.dirty;Object.keys(n.value).forEach((a=>{const r=n.value[a];if(Array.isArray(r)?r.some(t):t(r))return;const i=f(e,a);m(c,a,i)}))}),{deep:!0}),t.onMounted((()=>{(null==e?void 0:e.validateOnMount)&&p()})),{errors:y,meta:j,form:v,values:c,validate:p,isSubmitting:r,handleReset:()=>{a.value.forEach((e=>e.reset()))},handleSubmit:O,submitForm:V,setFieldError:l,setErrors:u,setFieldValue:s,setValues:d}}const $={valid:"every",invalid:"some",dirty:"some",pristine:"every",touched:"some",untouched:"every",pending:"some",validated:"every",changed:"some",passed:"every",failed:"some"};const I=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1}},setup(e,a){const r=t.toRef(e,"initialValues"),{errors:n,validate:i,handleSubmit:l,handleReset:o,values:u,meta:s,isSubmitting:d,submitForm:c,setErrors:v,setFieldError:f,setFieldValue:m,setValues:p}=P({validationSchema:e.validationSchema,initialValues:r,validateOnMount:e.validateOnMount}),h=a.attrs.onSubmit?l(a.attrs.onSubmit):c;function y(){o(),"function"==typeof a.attrs.onReset&&a.attrs.onReset()}function b(e,t){return l("function"!=typeof e||t?t:e)(e)}return function(){"setErrors"in this||(this.setFieldError=f,this.setErrors=v,this.setFieldValue=m,this.setValues=p);const r=j(a,{meta:s.value,errors:n.value,values:u,isSubmitting:d.value,validate:i,handleSubmit:b,handleReset:o,submitForm:c,setErrors:v,setFieldError:f,setFieldValue:m,setValues:p});if(!e.as)return r;const l="form"===e.as?{novalidate:!0}:{};return t.h(e.as,Object.assign(Object.assign(Object.assign({},l),a.attrs),{onSubmit:h,onReset:y}),r)}}}),U=t.defineComponent({props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,a){const r=t.inject(x,void 0),n=t.computed((()=>r.value[e.name]));return()=>{const r=j(a,{message:n.value}),i=e.as,l=Object.assign({id:c(e.name),role:"alert"},a.attrs);return!i&&r.length?r:r.length?t.h(i,l,r):t.h(i||"span",l,n.value)}}});e.ErrorMessage=U,e.Field=_,e.Form=I,e.configure=E,e.defineRule=function(e,t){!function(e,t){if(a(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),n[e]=t},e.useField=R,e.useForm=P,e.validate=k,Object.defineProperty(e,"__esModule",{value:!0})}));