Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hook-form

Package Overview
Dependencies
Maintainers
1
Versions
1031
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hook-form - npm Package Compare versions

Comparing version 7.43.5 to 7.43.6

2

dist/__tests__/form.test.d.ts
import 'whatwg-fetch';
//# sourceMappingURL=form.test.d.ts.map
//# sourceMappingURL=form.test.d.ts.map
import * as React from 'react';
import { Control, FieldValues, SubmitHandler } from './types';
export type FormProps<
TFieldValues extends FieldValues,
TTransformedValues extends FieldValues | undefined = undefined,
> = Partial<{
control: Control<TFieldValues>;
children?: React.ReactNode | React.ReactNode[];
render?: (props: {
submit: (e?: React.FormEvent) => void;
}) => React.ReactNode | React.ReactNode[];
onSubmit: TTransformedValues extends FieldValues
? SubmitHandler<TTransformedValues>
: SubmitHandler<TFieldValues>;
}> &
Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onError'> &
(
| Partial<{
onSuccess: ({ response }: { response: Response }) => void;
onError: ({
response,
error,
}:
| {
response: Response;
error?: undefined;
}
| {
response?: undefined;
error: unknown;
}) => void;
headers: Record<string, string>;
validateStatus: (status: number) => boolean;
fetcher: undefined;
}>
| Partial<{
onSuccess: undefined;
onError: undefined;
validateStatus: undefined;
headers: undefined;
fetcher: (
action: string,
payload: {
values?: TFieldValues;
method: string;
event?: React.BaseSyntheticEvent;
formData: FormData;
formDataJson: string;
},
) => Promise<void> | void;
}>
);
export type FormProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues | undefined = undefined> = Partial<{
control: Control<TFieldValues>;
children?: React.ReactNode | React.ReactNode[];
render?: (props: {
submit: (e?: React.FormEvent) => void;
}) => React.ReactNode | React.ReactNode[];
onSubmit: TTransformedValues extends FieldValues ? SubmitHandler<TTransformedValues> : SubmitHandler<TFieldValues>;
}> & Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onError'> & (Partial<{
onSuccess: ({ response }: {
response: Response;
}) => void;
onError: ({ response, error, }: {
response: Response;
error?: undefined;
} | {
response?: undefined;
error: unknown;
}) => void;
headers: Record<string, string>;
validateStatus: (status: number) => boolean;
fetcher: undefined;
}> | Partial<{
onSuccess: undefined;
onError: undefined;
validateStatus: undefined;
headers: undefined;
fetcher: (action: string, payload: {
values?: TFieldValues;
method: string;
event?: React.BaseSyntheticEvent;
formData: FormData;
formDataJson: string;
}) => Promise<void> | void;
}>);
/**

@@ -75,6 +59,3 @@ * Form component to manage submission.

*/
export declare function Form<
T extends FieldValues,
U extends FieldValues | undefined = undefined,
>(props: FormProps<T, U>): JSX.Element;
//# sourceMappingURL=form.d.ts.map
export declare function Form<T extends FieldValues, U extends FieldValues | undefined = undefined>(props: FormProps<T, U>): JSX.Element;
//# sourceMappingURL=form.d.ts.map

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),r=e=>"checkbox"===e.type,s=e=>e instanceof Date,a=e=>null==e;const n=e=>"object"==typeof e;var i=e=>!a(e)&&!Array.isArray(e)&&n(e)&&!s(e),u=e=>i(e)&&e.target?r(e.target)?e.target.checked:e.target.value:e,o=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),l="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function c(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(l&&(e instanceof Blob||e instanceof FileList)||!r&&!i(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return i(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=c(e[r]);else t=e}return t}var d=e=>Array.isArray(e)?e.filter(Boolean):[],f=e=>void 0===e,m=(e,t,r)=>{if(!t||!i(e))return r;const s=d(t.split(/[,[\].]+?/)).reduce(((e,t)=>a(e)?e:e[t]),e);return f(s)||s===e?f(e[t])?r:e[t]:s};const y="blur",p="focusout",g="change",_="onBlur",v="onChange",h="onSubmit",b="onTouched",x="all",A="max",V="min",F="maxLength",S="minLength",w="pattern",k="required",D="validate",C=t.default.createContext(null),j=()=>t.default.useContext(C);var O=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==x&&(t._proxyFormState[a]=!s||x),r&&(r[a]=!0),e[a]}});return a},E=e=>i(e)&&!Object.keys(e).length,U=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return E(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||x)))},B=e=>Array.isArray(e)?e:[e],T=(e,t,r)=>r&&t?e===t:!e||!t||e===t||B(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function L(e){const r=t.default.useRef(e);r.current=e,t.default.useEffect((()=>{const t=!e.disabled&&r.current.subject&&r.current.subject.subscribe({next:r.current.next});return()=>{t&&t.unsubscribe()}}),[e.disabled])}function M(e){const r=j(),{control:s=r.control,disabled:a,name:n,exact:i}=e||{},[u,o]=t.default.useState(s._formState),l=t.default.useRef(!0),c=t.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=t.default.useRef(n);return d.current=n,L({disabled:a,next:e=>l.current&&T(d.current,e.name,i)&&U(e,c.current,s._updateFormState)&&o({...s._formState,...e}),subject:s._subjects.state}),t.default.useEffect((()=>{l.current=!0;const e=s._proxyFormState.isDirty&&s._getDirty();return e!==s._formState.isDirty&&s._subjects.state.next({isDirty:e}),c.current.isValid&&s._updateValid(!0),()=>{l.current=!1}}),[s]),O(u,s,c.current,!1)}var N=e=>"string"==typeof e,R=(e,t,r,s,a)=>N(e)?(s&&t.watch.add(e),m(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),m(r,e)))):(s&&(t.watchAll=!0),r);function q(e){const r=j(),{control:s=r.control,name:a,defaultValue:n,disabled:i,exact:u}=e||{},o=t.default.useRef(a);o.current=a,L({disabled:i,subject:s._subjects.values,next:e=>{T(o.current,e.name,u)&&d(c(R(o.current,s._names,e.values||s._formValues,!1,n)))}});const[l,d]=t.default.useState(s._getWatch(a,n));return t.default.useEffect((()=>s._removeUnmounted())),l}var P=e=>/^\w*$/.test(e),W=e=>d(e.replace(/["|']|\]/g,"").split(/\.|\[/));function $(e,t,r){let s=-1;const a=P(t)?[t]:W(t),n=a.length,u=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==u){const r=e[t];n=i(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}e[t]=n,e=e[t]}return e}function I(e){const r=j(),{name:s,control:a=r.control,shouldUnregister:n}=e,i=o(a._names.array,s),l=q({control:a,name:s,defaultValue:m(a._formValues,s,m(a._defaultValues,s,e.defaultValue)),exact:!0}),d=M({control:a,name:s}),f=t.default.useRef(a.register(s,{...e.rules,value:l}));return t.default.useEffect((()=>{const e=a._options.shouldUnregister||n,t=(e,t)=>{const r=m(a._fields,e);r&&(r._f.mount=t)};return t(s,!0),e&&$(a._defaultValues,s,c(m(a._options.defaultValues,s))),()=>{(i?e&&!a._state.action:e)?a.unregister(s):t(s,!1)}}),[s,a,i,n]),{field:{name:s,value:l,onChange:t.default.useCallback((e=>f.current.onChange({target:{value:u(e),name:s},type:g})),[s]),onBlur:t.default.useCallback((()=>f.current.onBlur({target:{value:m(a._formValues,s),name:s},type:y})),[s,a]),ref:e=>{const t=m(a._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:d,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!m(d.errors,s)},isDirty:{enumerable:!0,get:()=>!!m(d.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!m(d.touchedFields,s)},error:{enumerable:!0,get:()=>m(d.errors,s)}})}}var H=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{};const z=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=m(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else i(s)&&z(s,t)}}};var G=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},J=(e,t,r={})=>r.shouldFocus||f(r.shouldFocus)?r.focusName||`${e}.${f(r.focusIndex)?t:r.focusIndex}.`:"",K=e=>({isOnSubmit:!e||e===h,isOnBlur:e===_,isOnChange:e===v,isOnAll:e===x,isOnTouch:e===b}),Q=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),X=(e,t,r)=>{const s=d(m(e,r));return $(s,"root",t[r]),$(e,r,s),e},Y=e=>"boolean"==typeof e,Z=e=>"file"===e.type,ee=e=>"function"==typeof e,te=e=>{if(!l)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},re=e=>N(e),se=e=>"radio"===e.type,ae=e=>e instanceof RegExp;const ne={value:!1,isValid:!1},ie={value:!0,isValid:!0};var ue=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!f(e[0].attributes.value)?f(e[0].value)||""===e[0].value?ie:{value:e[0].value,isValid:!0}:ie:ne}return ne};const oe={isValid:!1,value:null};var le=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),oe):oe;function ce(e,t,r="validate"){if(re(e)||Array.isArray(e)&&e.every(re)||Y(e)&&!e)return{type:r,message:re(e)?e:"",ref:t}}var de=e=>i(e)&&!ae(e)?e:{value:e,message:""},fe=async(e,t,s,n,u)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:y,min:p,max:g,pattern:_,validate:v,name:h,valueAsNumber:b,mount:x,disabled:C}=e._f,j=m(t,h);if(!x||C)return{};const O=l?l[0]:o,U=e=>{n&&O.reportValidity&&(O.setCustomValidity(Y(e)?"":e||""),O.reportValidity())},B={},T=se(o),L=r(o),M=T||L,R=(b||Z(o))&&f(o.value)&&f(j)||te(o)&&""===o.value||""===j||Array.isArray(j)&&!j.length,q=H.bind(null,h,s,B),P=(e,t,r,s=F,a=S)=>{const n=e?t:r;B[h]={type:e?s:a,message:n,ref:o,...q(e?s:a,n)}};if(u?!Array.isArray(j)||!j.length:c&&(!M&&(R||a(j))||Y(j)&&!j||L&&!ue(l).isValid||T&&!le(l).isValid)){const{value:e,message:t}=re(c)?{value:!!c,message:c}:de(c);if(e&&(B[h]={type:k,message:t,ref:O,...q(k,t)},!s))return U(t),B}if(!(R||a(p)&&a(g))){let e,t;const r=de(g),n=de(p);if(a(j)||isNaN(j)){const s=o.valueAsDate||new Date(j),a=e=>new Date((new Date).toDateString()+" "+e),i="time"==o.type,u="week"==o.type;N(r.value)&&j&&(e=i?a(j)>a(r.value):u?j>r.value:s>new Date(r.value)),N(n.value)&&j&&(t=i?a(j)<a(n.value):u?j<n.value:s<new Date(n.value))}else{const s=o.valueAsNumber||(j?+j:j);a(r.value)||(e=s>r.value),a(n.value)||(t=s<n.value)}if((e||t)&&(P(!!e,r.message,n.message,A,V),!s))return U(B[h].message),B}if((d||y)&&!R&&(N(j)||u&&Array.isArray(j))){const e=de(d),t=de(y),r=!a(e.value)&&j.length>e.value,n=!a(t.value)&&j.length<t.value;if((r||n)&&(P(r,e.message,t.message),!s))return U(B[h].message),B}if(_&&!R&&N(j)){const{value:e,message:t}=de(_);if(ae(e)&&!j.match(e)&&(B[h]={type:w,message:t,ref:o,...q(w,t)},!s))return U(t),B}if(v)if(ee(v)){const e=ce(await v(j,t),O);if(e&&(B[h]={...e,...q(D,e.message)},!s))return U(e.message),B}else if(i(v)){let e={};for(const r in v){if(!E(e)&&!s)break;const a=ce(await v[r](j,t),O,r);a&&(e={...a,...q(r,a.message)},U(a.message),s&&(B[h]=e))}if(!E(e)&&(B[h]={ref:O,...e},!s))return B}return U(!0),B};function me(e,t){return[...e,...B(t)]}var ye=e=>Array.isArray(e)?e.map((()=>{})):void 0;function pe(e,t,r){return[...e.slice(0,t),...B(r),...e.slice(t)]}var ge=(e,t,r)=>Array.isArray(e)?(f(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[];function _e(e,t){return[...B(t),...B(e)]}var ve=(e,t)=>f(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return d(s).length?s:[]}(e,B(t).sort(((e,t)=>e-t))),he=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function be(e,t){const r=Array.isArray(t)?t:P(t)?[t]:W(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=f(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(i(s)&&E(s)||Array.isArray(s)&&function(e){for(const t in e)if(!f(e[t]))return!1;return!0}(s))&&be(e,r.slice(0,-1)),e}var xe=(e,t,r)=>(e[t]=r,e);function Ae(){let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Ve=e=>a(e)||!n(e);function Fe(e,t){if(Ve(e)||Ve(t))return e===t;if(s(e)&&s(t))return e.getTime()===t.getTime();const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const n of r){const r=e[n];if(!a.includes(n))return!1;if("ref"!==n){const e=t[n];if(s(r)&&s(e)||i(r)&&i(e)||Array.isArray(r)&&Array.isArray(e)?!Fe(r,e):r!==e)return!1}}return!0}var Se=e=>"select-multiple"===e.type,we=e=>te(e)&&e.isConnected,ke=e=>{for(const t in e)if(ee(e[t]))return!0;return!1};function De(e,t={}){const r=Array.isArray(e);if(i(e)||r)for(const r in e)Array.isArray(e[r])||i(e[r])&&!ke(e[r])?(t[r]=Array.isArray(e[r])?[]:{},De(e[r],t[r])):a(e[r])||(t[r]=!0);return t}function Ce(e,t,r){const s=Array.isArray(e);if(i(e)||s)for(const s in e)Array.isArray(e[s])||i(e[s])&&!ke(e[s])?f(t)||Ve(r[s])?r[s]=Array.isArray(e[s])?De(e[s],[]):{...De(e[s])}:Ce(e[s],a(t)?{}:t[s],r[s]):r[s]=!Fe(e[s],t[s]);return r}var je=(e,t)=>Ce(e,t,De(t)),Oe=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>f(e)?e:t?""===e?NaN:e?+e:e:r&&N(e)?new Date(e):s?s(e):e;function Ee(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return Z(t)?t.files:se(t)?le(e.refs).value:Se(t)?[...t.selectedOptions].map((({value:e})=>e)):r(t)?ue(e.refs).value:Oe(f(t.value)?e.ref.value:t.value,e)}var Ue=e=>f(e)?e:ae(e)?e.source:i(e)?ae(e.value)?e.value.source:e.value:e;function Be(e,t,r){const s=m(e,r);if(s||P(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=m(t,s),i=m(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Te={mode:h,reValidateMode:v,shouldFocusError:!0};function Le(e={},t){let n,g={...Te,...e},_={submitCount:0,isDirty:!1,isLoading:!0,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},v={},h=(i(g.defaultValues)||i(g.values))&&c(g.defaultValues||g.values)||{},b=g.shouldUnregister?{}:c(h),A={action:!1,mount:!1,watch:!1},V={mount:new Set,unMount:new Set,array:new Set,watch:new Set},F=0;const S={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},w={values:Ae(),array:Ae(),state:Ae()},k=e.resetOptions&&e.resetOptions.keepDirtyValues,D=K(g.mode),C=K(g.reValidateMode),j=g.criteriaMode===x,O=async e=>{if(S.isValid||e){const e=g.resolver?E((await q()).errors):await P(v,!0);e!==_.isValid&&w.state.next({isValid:e})}},U=e=>S.isValidating&&w.state.next({isValidating:e}),T=(e,t,r,s)=>{const a=m(v,e);if(a){const n=m(b,e,f(r)?m(h,e):r);f(n)||s&&s.defaultChecked||t?$(b,e,t?n:Ee(a._f)):H(e,n),A.mount&&O()}},L=(e,t,r,s,a)=>{let n=!1,i=!1;const u={name:e};if(!r||s){S.isDirty&&(i=_.isDirty,_.isDirty=u.isDirty=W(),n=i!==u.isDirty);const r=Fe(m(h,e),t);i=m(_.dirtyFields,e),r?be(_.dirtyFields,e):$(_.dirtyFields,e,!0),u.dirtyFields=_.dirtyFields,n=n||S.dirtyFields&&i!==!r}if(r){const t=m(_.touchedFields,e);t||($(_.touchedFields,e,r),u.touchedFields=_.touchedFields,n=n||S.touchedFields&&t!==r)}return n&&a&&w.state.next(u),n?u:{}},M=(t,r,s,a)=>{const i=m(_.errors,t),u=S.isValid&&Y(r)&&_.isValid!==r;var o;if(e.delayError&&s?(o=()=>((e,t)=>{$(_.errors,e,t),w.state.next({errors:_.errors})})(t,s),n=e=>{clearTimeout(F),F=setTimeout(o,e)},n(e.delayError)):(clearTimeout(F),n=null,s?$(_.errors,t,s):be(_.errors,t)),(s?!Fe(i,s):i)||!E(a)||u){const e={...a,...u&&Y(r)?{isValid:r}:{},errors:_.errors,name:t};_={..._,...e},w.state.next(e)}U(!1)},q=async e=>g.resolver(b,g.context,((e,t,r,s)=>{const a={};for(const r of e){const e=m(t,r);e&&$(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||V.mount,v,g.criteriaMode,g.shouldUseNativeValidation)),P=async(e,t,r={valid:!0})=>{for(const s in e){const a=e[s];if(a){const{_f:e,...s}=a;if(e){const s=V.array.has(e.name),n=await fe(a,b,j,g.shouldUseNativeValidation,s);if(n[e.name]&&(r.valid=!1,t))break;!t&&(m(n,e.name)?s?X(_.errors,n,e.name):$(_.errors,e.name,n[e.name]):be(_.errors,e.name))}s&&await P(s,t,r)}}return r.valid},W=(e,t)=>(e&&t&&$(b,e,t),!Fe(ne(),h)),I=(e,t,r)=>R(e,V,{...A.mount?b:f(t)?h:N(e)?{[e]:t}:t},r,t),H=(e,t,s={})=>{const n=m(v,e);let i=t;if(n){const s=n._f;s&&(!s.disabled&&$(b,e,Oe(t,s)),i=te(s.ref)&&a(t)?"":t,Se(s.ref)?[...s.ref.options].forEach((e=>e.selected=i.includes(e.value))):s.refs?r(s.ref)?s.refs.length>1?s.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(i)?!!i.find((t=>t===e.value)):i===e.value))):s.refs[0]&&(s.refs[0].checked=!!i):s.refs.forEach((e=>e.checked=e.value===i)):Z(s.ref)?s.ref.value="":(s.ref.value=i,s.ref.type||w.values.next({name:e,values:{...b}})))}(s.shouldDirty||s.shouldTouch)&&L(e,i,s.shouldTouch,s.shouldDirty,!0),s.shouldValidate&&ae(e)},G=(e,t,r)=>{for(const a in t){const n=t[a],i=`${e}.${a}`,u=m(v,i);!V.array.has(e)&&Ve(n)&&(!u||u._f)||s(n)?H(i,n,r):G(i,n,r)}},J=(e,r,s={})=>{const n=m(v,e),i=V.array.has(e),u=c(r);$(b,e,u),i?(w.array.next({name:e,values:{...b}}),(S.isDirty||S.dirtyFields)&&s.shouldDirty&&w.state.next({name:e,dirtyFields:je(h,b),isDirty:W(e,u)})):!n||n._f||a(u)?H(e,u,s):G(e,u,s),Q(e,V)&&w.state.next({..._}),w.values.next({name:e,values:{...b}}),!A.mount&&t()},re=async e=>{const t=e.target;let r=t.name;const s=m(v,r);if(s){let i,o;const l=t.type?Ee(s._f):u(e),c=e.type===y||e.type===p,d=!((a=s._f).mount&&(a.required||a.min||a.max||a.maxLength||a.minLength||a.pattern||a.validate)||g.resolver||m(_.errors,r)||s._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(c,m(_.touchedFields,r),_.isSubmitted,C,D),f=Q(r,V,c);$(b,r,l),c?(s._f.onBlur&&s._f.onBlur(e),n&&n(0)):s._f.onChange&&s._f.onChange(e);const h=L(r,l,c,!1),x=!E(h)||f;if(!c&&w.values.next({name:r,type:e.type,values:{...b}}),d)return S.isValid&&O(),x&&w.state.next({name:r,...f?{}:h});if(!c&&f&&w.state.next({..._}),U(!0),g.resolver){const{errors:e}=await q([r]),t=Be(_.errors,v,r),s=Be(e,v,t.name||r);i=s.error,r=s.name,o=E(e)}else i=(await fe(s,b,j,g.shouldUseNativeValidation))[r],i?o=!1:S.isValid&&(o=await P(v,!0));s._f.deps&&ae(s._f.deps),M(r,o,i,h)}var a},ae=async(e,t={})=>{let r,s;const a=B(e);if(U(!0),g.resolver){const t=await(async e=>{const{errors:t}=await q();if(e)for(const r of e){const e=m(t,r);e?$(_.errors,r,e):be(_.errors,r)}else _.errors=t;return t})(f(e)?e:a);r=E(t),s=e?!a.some((e=>m(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=m(v,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||_.isValid)&&O()):s=r=await P(v);return w.state.next({...!N(e)||S.isValid&&r!==_.isValid?{}:{name:e},...g.resolver||!e?{isValid:r}:{},errors:_.errors,isValidating:!1}),t.shouldFocus&&!s&&z(v,(e=>e&&m(_.errors,e)),e?a:V.mount),s},ne=e=>{const t={...h,...A.mount?b:{}};return f(e)?t:N(e)?m(t,e):e.map((e=>m(t,e)))},ie=(e,t)=>({invalid:!!m((t||_).errors,e),isDirty:!!m((t||_).dirtyFields,e),isTouched:!!m((t||_).touchedFields,e),error:m((t||_).errors,e)}),ue=(e,t={})=>{for(const r of e?B(e):V.mount)V.mount.delete(r),V.array.delete(r),m(v,r)&&(t.keepValue||(be(v,r),be(b,r)),!t.keepError&&be(_.errors,r),!t.keepDirty&&be(_.dirtyFields,r),!t.keepTouched&&be(_.touchedFields,r),!g.shouldUnregister&&!t.keepDefaultValue&&be(h,r));w.values.next({values:{...b}}),w.state.next({..._,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&O()},oe=(e,t={})=>{let s=m(v,e);const a=Y(t.disabled);return $(v,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...t}}),V.mount.add(e),s?a&&$(b,e,t.disabled?void 0:m(b,e,Ee(s._f))):T(e,!0,t.value),{...a?{disabled:t.disabled}:{},...g.shouldUseNativeValidation?{required:!!t.required,min:Ue(t.min),max:Ue(t.max),minLength:Ue(t.minLength),maxLength:Ue(t.maxLength),pattern:Ue(t.pattern)}:{},name:e,onChange:re,onBlur:re,ref:a=>{if(a){oe(e,t),s=m(v,e);const n=f(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,i=(e=>se(e)||r(e))(n),u=s._f.refs||[];if(i?u.find((e=>e===n)):n===s._f.ref)return;$(v,e,{_f:{...s._f,...i?{refs:[...u.filter(we),n,...Array.isArray(m(h,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),T(e,!1,void 0,n)}else s=m(v,e,{}),s._f&&(s._f.mount=!1),(g.shouldUnregister||t.shouldUnregister)&&(!o(V.array,e)||!A.action)&&V.unMount.add(e)}}},le=()=>g.shouldFocusError&&z(v,(e=>e&&m(_.errors,e)),V.mount),ce=(r,s={})=>{const a=r||h,n=c(a),i=r&&!E(r)?n:h;if(s.keepDefaultValues||(h=a),!s.keepValues){if(s.keepDirtyValues||k)for(const e of V.mount)m(_.dirtyFields,e)?$(i,e,m(b,e)):J(e,m(i,e));else{if(l&&f(r))for(const e of V.mount){const t=m(v,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(te(e)){const t=e.closest("form");if(t){t.reset();break}}}}v={}}b=e.shouldUnregister?s.keepDefaultValues?c(h):{}:n,w.array.next({values:{...i}}),w.values.next({values:{...i}})}V={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!A.mount&&t(),A.mount=!S.isValid||!!s.keepIsValid,A.watch=!!e.shouldUnregister,w.state.next({submitCount:s.keepSubmitCount?_.submitCount:0,isDirty:s.keepDirty?_.isDirty:!(!s.keepDefaultValues||Fe(r,h)),isSubmitted:!!s.keepIsSubmitted&&_.isSubmitted,dirtyFields:s.keepDirtyValues?_.dirtyFields:s.keepDefaultValues&&r?je(h,r):{},touchedFields:s.keepTouched?_.touchedFields:{},errors:s.keepErrors?_.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(ee(e)?e(b):e,t);return ee(g.defaultValues)&&g.defaultValues().then((e=>{de(e,g.resetOptions),w.state.next({isLoading:!1})})),{control:{register:oe,unregister:ue,getFieldState:ie,_executeSchema:q,_getWatch:I,_getDirty:W,_updateValid:O,_removeUnmounted:()=>{for(const e of V.unMount){const t=m(v,e);t&&(t._f.refs?t._f.refs.every((e=>!we(e))):!we(t._f.ref))&&ue(e)}V.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(A.action=!0,n&&Array.isArray(m(v,e))){const t=r(m(v,e),s.argA,s.argB);a&&$(v,e,t)}if(n&&Array.isArray(m(_.errors,e))){const t=r(m(_.errors,e),s.argA,s.argB);a&&$(_.errors,e,t),((e,t)=>{!d(m(e,t)).length&&be(e,t)})(_.errors,e)}if(S.touchedFields&&n&&Array.isArray(m(_.touchedFields,e))){const t=r(m(_.touchedFields,e),s.argA,s.argB);a&&$(_.touchedFields,e,t)}S.dirtyFields&&(_.dirtyFields=je(h,b)),w.state.next({name:e,isDirty:W(e,t),dirtyFields:_.dirtyFields,errors:_.errors,isValid:_.isValid})}else $(b,e,t)},_getFieldArray:t=>d(m(A.mount?b:h,t,e.shouldUnregister?m(h,t,[]):[])),_reset:ce,_updateFormState:e=>{_={..._,...e}},_subjects:w,_proxyFormState:S,get _fields(){return v},get _formValues(){return b},get _state(){return A},set _state(e){A=e},get _defaultValues(){return h},get _names(){return V},set _names(e){V=e},get _formState(){return _},set _formState(e){_=e},get _options(){return g},set _options(e){g={...g,...e}}},trigger:ae,register:oe,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let s=c(b);if(w.state.next({isSubmitting:!0}),g.resolver){const{errors:e,values:t}=await q();_.errors=e,s=t}else await P(v);be(_.errors,"root"),E(_.errors)?(w.state.next({errors:{}}),await e(s,r)):(t&&await t({..._.errors},r),le(),setTimeout(le)),w.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:E(_.errors),submitCount:_.submitCount+1,errors:_.errors})},watch:(e,t)=>ee(e)?w.values.subscribe({next:r=>e(I(void 0,t),r)}):I(e,t,!0),setValue:J,getValues:ne,reset:de,resetField:(e,t={})=>{m(v,e)&&(f(t.defaultValue)?J(e,m(h,e)):(J(e,t.defaultValue),$(h,e,t.defaultValue)),t.keepTouched||be(_.touchedFields,e),t.keepDirty||(be(_.dirtyFields,e),_.isDirty=t.defaultValue?W(e,m(h,e)):W()),t.keepError||(be(_.errors,e),S.isValid&&O()),w.state.next({..._}))},clearErrors:e=>{e&&B(e).forEach((e=>be(_.errors,e))),w.state.next({errors:e?_.errors:{}})},unregister:ue,setError:(e,t,r)=>{const s=(m(v,e,{_f:{}})._f||{}).ref;$(_.errors,e,{...t,ref:s}),w.state.next({name:e,errors:_.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=m(v,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}exports.Controller=e=>e.render(I(e)),exports.FormProvider=e=>{const{children:r,...s}=e;return t.default.createElement(C.Provider,{value:s},r)},exports.appendErrors=H,exports.get=m,exports.set=$,exports.useController=I,exports.useFieldArray=function(e){const r=j(),{control:s=r.control,name:a,keyName:n="id",shouldUnregister:i}=e,[u,o]=t.default.useState(s._getFieldArray(a)),l=t.default.useRef(s._getFieldArray(a).map(G)),d=t.default.useRef(u),f=t.default.useRef(a),y=t.default.useRef(!1);f.current=a,d.current=u,s._names.array.add(a),e.rules&&s.register(a,e.rules),L({next:({values:e,name:t})=>{if(t===f.current||!t){const t=m(e,f.current);Array.isArray(t)&&(o(t),l.current=t.map(G))}},subject:s._subjects.array});const p=t.default.useCallback((e=>{y.current=!0,s._updateFieldArray(a,e)}),[s,a]);return t.default.useEffect((()=>{if(s._state.action=!1,Q(a,s._names)&&s._subjects.state.next({...s._formState}),y.current&&(!K(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._executeSchema([a]).then((e=>{const t=m(e.errors,a),r=m(s._formState.errors,a);(r?!t&&r.type:t&&t.type)&&(t?$(s._formState.errors,a,t):be(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=m(s._fields,a);e&&e._f&&fe(e,s._formValues,s._options.criteriaMode===x,s._options.shouldUseNativeValidation,!0).then((e=>!E(e)&&s._subjects.state.next({errors:X(s._formState.errors,e,a)})))}s._subjects.values.next({name:a,values:{...s._formValues}}),s._names.focus&&z(s._fields,(e=>!!e&&e.startsWith(s._names.focus||""))),s._names.focus="",s._updateValid()}),[u,a,s]),t.default.useEffect((()=>(!m(s._formValues,a)&&s._updateFieldArray(a),()=>{(s._options.shouldUnregister||i)&&s.unregister(a)})),[a,s,n,i]),{swap:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);he(r,e,t),he(l.current,e,t),p(r),o(r),s._updateFieldArray(a,r,he,{argA:e,argB:t},!1)}),[p,a,s]),move:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);ge(r,e,t),ge(l.current,e,t),p(r),o(r),s._updateFieldArray(a,r,ge,{argA:e,argB:t},!1)}),[p,a,s]),prepend:t.default.useCallback(((e,t)=>{const r=B(c(e)),n=_e(s._getFieldArray(a),r);s._names.focus=J(a,0,t),l.current=_e(l.current,r.map(G)),p(n),o(n),s._updateFieldArray(a,n,_e,{argA:ye(e)})}),[p,a,s]),append:t.default.useCallback(((e,t)=>{const r=B(c(e)),n=me(s._getFieldArray(a),r);s._names.focus=J(a,n.length-1,t),l.current=me(l.current,r.map(G)),p(n),o(n),s._updateFieldArray(a,n,me,{argA:ye(e)})}),[p,a,s]),remove:t.default.useCallback((e=>{const t=ve(s._getFieldArray(a),e);l.current=ve(l.current,e),p(t),o(t),s._updateFieldArray(a,t,ve,{argA:e})}),[p,a,s]),insert:t.default.useCallback(((e,t,r)=>{const n=B(c(t)),i=pe(s._getFieldArray(a),e,n);s._names.focus=J(a,e,r),l.current=pe(l.current,e,n.map(G)),p(i),o(i),s._updateFieldArray(a,i,pe,{argA:e,argB:ye(t)})}),[p,a,s]),update:t.default.useCallback(((e,t)=>{const r=c(t),n=xe(s._getFieldArray(a),e,r);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:G())),p(n),o([...n]),s._updateFieldArray(a,n,xe,{argA:e,argB:r},!0,!1)}),[p,a,s]),replace:t.default.useCallback((e=>{const t=B(c(e));l.current=t.map(G),p([...t]),o([...t]),s._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[p,a,s]),fields:t.default.useMemo((()=>u.map(((e,t)=>({...e,[n]:l.current[t]||G()})))),[u,n])}},exports.useForm=function(e={}){const r=t.default.useRef(),[s,a]=t.default.useState({isDirty:!1,isValidating:!1,isLoading:!0,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:ee(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...Le(e,(()=>a((e=>({...e}))))),formState:s});const n=r.current.control;return n._options=e,L({subject:n._subjects.state,next:e=>{U(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),t.default.useEffect((()=>{e.values&&!Fe(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),t.default.useEffect((()=>{n._state.mount||(n._updateValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),r.current.formState=O(s,n),r.current},exports.useFormContext=j,exports.useFormState=M,exports.useWatch=q;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),r=e=>"checkbox"===e.type,s=e=>e instanceof Date,a=e=>null==e;const n=e=>"object"==typeof e;var i=e=>!a(e)&&!Array.isArray(e)&&n(e)&&!s(e),u=e=>i(e)&&e.target?r(e.target)?e.target.checked:e.target.value:e,o=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),l="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function c(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(l&&(e instanceof Blob||e instanceof FileList)||!r&&!i(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return i(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=c(e[r]);else t=e}return t}var d=e=>Array.isArray(e)?e.filter(Boolean):[],f=e=>void 0===e,m=(e,t,r)=>{if(!t||!i(e))return r;const s=d(t.split(/[,[\].]+?/)).reduce(((e,t)=>a(e)?e:e[t]),e);return f(s)||s===e?f(e[t])?r:e[t]:s};const y="blur",p="focusout",_="change",g="onBlur",v="onChange",h="onSubmit",b="onTouched",x="all",A="max",V="min",F="maxLength",S="minLength",w="pattern",k="required",D="validate",C=t.default.createContext(null),j=()=>t.default.useContext(C);var O=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==x&&(t._proxyFormState[a]=!s||x),r&&(r[a]=!0),e[a]}});return a},E=e=>i(e)&&!Object.keys(e).length,U=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return E(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||x)))},B=e=>Array.isArray(e)?e:[e],T=(e,t,r)=>r&&t?e===t:!e||!t||e===t||B(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function L(e){const r=t.default.useRef(e);r.current=e,t.default.useEffect((()=>{const t=!e.disabled&&r.current.subject&&r.current.subject.subscribe({next:r.current.next});return()=>{t&&t.unsubscribe()}}),[e.disabled])}function M(e){const r=j(),{control:s=r.control,disabled:a,name:n,exact:i}=e||{},[u,o]=t.default.useState(s._formState),l=t.default.useRef(!0),c=t.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=t.default.useRef(n);return d.current=n,L({disabled:a,next:e=>l.current&&T(d.current,e.name,i)&&U(e,c.current,s._updateFormState)&&o({...s._formState,...e}),subject:s._subjects.state}),t.default.useEffect((()=>{l.current=!0;const e=s._proxyFormState.isDirty&&s._getDirty();return e!==s._formState.isDirty&&s._subjects.state.next({isDirty:e}),c.current.isValid&&s._updateValid(!0),()=>{l.current=!1}}),[s]),O(u,s,c.current,!1)}var N=e=>"string"==typeof e,R=(e,t,r,s,a)=>N(e)?(s&&t.watch.add(e),m(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),m(r,e)))):(s&&(t.watchAll=!0),r);function q(e){const r=j(),{control:s=r.control,name:a,defaultValue:n,disabled:i,exact:u}=e||{},o=t.default.useRef(a);o.current=a,L({disabled:i,subject:s._subjects.values,next:e=>{T(o.current,e.name,u)&&d(c(R(o.current,s._names,e.values||s._formValues,!1,n)))}});const[l,d]=t.default.useState(s._getWatch(a,n));return t.default.useEffect((()=>s._removeUnmounted())),l}var P=e=>/^\w*$/.test(e),W=e=>d(e.replace(/["|']|\]/g,"").split(/\.|\[/));function $(e,t,r){let s=-1;const a=P(t)?[t]:W(t),n=a.length,u=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==u){const r=e[t];n=i(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}e[t]=n,e=e[t]}return e}function I(e){const r=j(),{name:s,control:a=r.control,shouldUnregister:n}=e,i=o(a._names.array,s),l=q({control:a,name:s,defaultValue:m(a._formValues,s,m(a._defaultValues,s,e.defaultValue)),exact:!0}),d=M({control:a,name:s}),p=t.default.useRef(a.register(s,{...e.rules,value:l}));return t.default.useEffect((()=>{const e=a._options.shouldUnregister||n,t=(e,t)=>{const r=m(a._fields,e);r&&(r._f.mount=t)};if(t(s,!0),e){const e=c(m(a._options.defaultValues,s));$(a._defaultValues,s,e),f(m(a._formValues,s))&&$(a._formValues,s,e)}return()=>{(i?e&&!a._state.action:e)?a.unregister(s):t(s,!1)}}),[s,a,i,n]),{field:{name:s,value:l,onChange:t.default.useCallback((e=>p.current.onChange({target:{value:u(e),name:s},type:_})),[s]),onBlur:t.default.useCallback((()=>p.current.onBlur({target:{value:m(a._formValues,s),name:s},type:y})),[s,a]),ref:e=>{const t=m(a._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:d,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!m(d.errors,s)},isDirty:{enumerable:!0,get:()=>!!m(d.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!m(d.touchedFields,s)},error:{enumerable:!0,get:()=>m(d.errors,s)}})}}var H=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{};const z=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=m(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else i(s)&&z(s,t)}}};var G=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},J=(e,t,r={})=>r.shouldFocus||f(r.shouldFocus)?r.focusName||`${e}.${f(r.focusIndex)?t:r.focusIndex}.`:"",K=e=>({isOnSubmit:!e||e===h,isOnBlur:e===g,isOnChange:e===v,isOnAll:e===x,isOnTouch:e===b}),Q=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),X=(e,t,r)=>{const s=d(m(e,r));return $(s,"root",t[r]),$(e,r,s),e},Y=e=>"boolean"==typeof e,Z=e=>"file"===e.type,ee=e=>"function"==typeof e,te=e=>{if(!l)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},re=e=>N(e),se=e=>"radio"===e.type,ae=e=>e instanceof RegExp;const ne={value:!1,isValid:!1},ie={value:!0,isValid:!0};var ue=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!f(e[0].attributes.value)?f(e[0].value)||""===e[0].value?ie:{value:e[0].value,isValid:!0}:ie:ne}return ne};const oe={isValid:!1,value:null};var le=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),oe):oe;function ce(e,t,r="validate"){if(re(e)||Array.isArray(e)&&e.every(re)||Y(e)&&!e)return{type:r,message:re(e)?e:"",ref:t}}var de=e=>i(e)&&!ae(e)?e:{value:e,message:""},fe=async(e,t,s,n,u)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:y,min:p,max:_,pattern:g,validate:v,name:h,valueAsNumber:b,mount:x,disabled:C}=e._f,j=m(t,h);if(!x||C)return{};const O=l?l[0]:o,U=e=>{n&&O.reportValidity&&(O.setCustomValidity(Y(e)?"":e||""),O.reportValidity())},B={},T=se(o),L=r(o),M=T||L,R=(b||Z(o))&&f(o.value)&&f(j)||te(o)&&""===o.value||""===j||Array.isArray(j)&&!j.length,q=H.bind(null,h,s,B),P=(e,t,r,s=F,a=S)=>{const n=e?t:r;B[h]={type:e?s:a,message:n,ref:o,...q(e?s:a,n)}};if(u?!Array.isArray(j)||!j.length:c&&(!M&&(R||a(j))||Y(j)&&!j||L&&!ue(l).isValid||T&&!le(l).isValid)){const{value:e,message:t}=re(c)?{value:!!c,message:c}:de(c);if(e&&(B[h]={type:k,message:t,ref:O,...q(k,t)},!s))return U(t),B}if(!(R||a(p)&&a(_))){let e,t;const r=de(_),n=de(p);if(a(j)||isNaN(j)){const s=o.valueAsDate||new Date(j),a=e=>new Date((new Date).toDateString()+" "+e),i="time"==o.type,u="week"==o.type;N(r.value)&&j&&(e=i?a(j)>a(r.value):u?j>r.value:s>new Date(r.value)),N(n.value)&&j&&(t=i?a(j)<a(n.value):u?j<n.value:s<new Date(n.value))}else{const s=o.valueAsNumber||(j?+j:j);a(r.value)||(e=s>r.value),a(n.value)||(t=s<n.value)}if((e||t)&&(P(!!e,r.message,n.message,A,V),!s))return U(B[h].message),B}if((d||y)&&!R&&(N(j)||u&&Array.isArray(j))){const e=de(d),t=de(y),r=!a(e.value)&&j.length>e.value,n=!a(t.value)&&j.length<t.value;if((r||n)&&(P(r,e.message,t.message),!s))return U(B[h].message),B}if(g&&!R&&N(j)){const{value:e,message:t}=de(g);if(ae(e)&&!j.match(e)&&(B[h]={type:w,message:t,ref:o,...q(w,t)},!s))return U(t),B}if(v)if(ee(v)){const e=ce(await v(j,t),O);if(e&&(B[h]={...e,...q(D,e.message)},!s))return U(e.message),B}else if(i(v)){let e={};for(const r in v){if(!E(e)&&!s)break;const a=ce(await v[r](j,t),O,r);a&&(e={...a,...q(r,a.message)},U(a.message),s&&(B[h]=e))}if(!E(e)&&(B[h]={ref:O,...e},!s))return B}return U(!0),B};function me(e,t){return[...e,...B(t)]}var ye=e=>Array.isArray(e)?e.map((()=>{})):void 0;function pe(e,t,r){return[...e.slice(0,t),...B(r),...e.slice(t)]}var _e=(e,t,r)=>Array.isArray(e)?(f(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[];function ge(e,t){return[...B(t),...B(e)]}var ve=(e,t)=>f(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return d(s).length?s:[]}(e,B(t).sort(((e,t)=>e-t))),he=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function be(e,t){const r=Array.isArray(t)?t:P(t)?[t]:W(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=f(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(i(s)&&E(s)||Array.isArray(s)&&function(e){for(const t in e)if(!f(e[t]))return!1;return!0}(s))&&be(e,r.slice(0,-1)),e}var xe=(e,t,r)=>(e[t]=r,e);function Ae(){let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Ve=e=>a(e)||!n(e);function Fe(e,t){if(Ve(e)||Ve(t))return e===t;if(s(e)&&s(t))return e.getTime()===t.getTime();const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const n of r){const r=e[n];if(!a.includes(n))return!1;if("ref"!==n){const e=t[n];if(s(r)&&s(e)||i(r)&&i(e)||Array.isArray(r)&&Array.isArray(e)?!Fe(r,e):r!==e)return!1}}return!0}var Se=e=>"select-multiple"===e.type,we=e=>te(e)&&e.isConnected,ke=e=>{for(const t in e)if(ee(e[t]))return!0;return!1};function De(e,t={}){const r=Array.isArray(e);if(i(e)||r)for(const r in e)Array.isArray(e[r])||i(e[r])&&!ke(e[r])?(t[r]=Array.isArray(e[r])?[]:{},De(e[r],t[r])):a(e[r])||(t[r]=!0);return t}function Ce(e,t,r){const s=Array.isArray(e);if(i(e)||s)for(const s in e)Array.isArray(e[s])||i(e[s])&&!ke(e[s])?f(t)||Ve(r[s])?r[s]=Array.isArray(e[s])?De(e[s],[]):{...De(e[s])}:Ce(e[s],a(t)?{}:t[s],r[s]):r[s]=!Fe(e[s],t[s]);return r}var je=(e,t)=>Ce(e,t,De(t)),Oe=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>f(e)?e:t?""===e?NaN:e?+e:e:r&&N(e)?new Date(e):s?s(e):e;function Ee(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return Z(t)?t.files:se(t)?le(e.refs).value:Se(t)?[...t.selectedOptions].map((({value:e})=>e)):r(t)?ue(e.refs).value:Oe(f(t.value)?e.ref.value:t.value,e)}var Ue=e=>f(e)?e:ae(e)?e.source:i(e)?ae(e.value)?e.value.source:e.value:e;function Be(e,t,r){const s=m(e,r);if(s||P(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=m(t,s),i=m(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Te={mode:h,reValidateMode:v,shouldFocusError:!0};function Le(e={},t){let n,_={...Te,...e},g={submitCount:0,isDirty:!1,isLoading:ee(_.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},v={},h=(i(_.defaultValues)||i(_.values))&&c(_.defaultValues||_.values)||{},b=_.shouldUnregister?{}:c(h),A={action:!1,mount:!1,watch:!1},V={mount:new Set,unMount:new Set,array:new Set,watch:new Set},F=0;const S={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},w={values:Ae(),array:Ae(),state:Ae()},k=e.resetOptions&&e.resetOptions.keepDirtyValues,D=K(_.mode),C=K(_.reValidateMode),j=_.criteriaMode===x,O=async e=>{if(S.isValid||e){const e=_.resolver?E((await q()).errors):await P(v,!0);e!==g.isValid&&w.state.next({isValid:e})}},U=e=>S.isValidating&&w.state.next({isValidating:e}),T=(e,t,r,s)=>{const a=m(v,e);if(a){const n=m(b,e,f(r)?m(h,e):r);f(n)||s&&s.defaultChecked||t?$(b,e,t?n:Ee(a._f)):H(e,n),A.mount&&O()}},L=(e,t,r,s,a)=>{let n=!1,i=!1;const u={name:e};if(!r||s){S.isDirty&&(i=g.isDirty,g.isDirty=u.isDirty=W(),n=i!==u.isDirty);const r=Fe(m(h,e),t);i=m(g.dirtyFields,e),r?be(g.dirtyFields,e):$(g.dirtyFields,e,!0),u.dirtyFields=g.dirtyFields,n=n||S.dirtyFields&&i!==!r}if(r){const t=m(g.touchedFields,e);t||($(g.touchedFields,e,r),u.touchedFields=g.touchedFields,n=n||S.touchedFields&&t!==r)}return n&&a&&w.state.next(u),n?u:{}},M=(t,r,s,a)=>{const i=m(g.errors,t),u=S.isValid&&Y(r)&&g.isValid!==r;var o;if(e.delayError&&s?(o=()=>((e,t)=>{$(g.errors,e,t),w.state.next({errors:g.errors})})(t,s),n=e=>{clearTimeout(F),F=setTimeout(o,e)},n(e.delayError)):(clearTimeout(F),n=null,s?$(g.errors,t,s):be(g.errors,t)),(s?!Fe(i,s):i)||!E(a)||u){const e={...a,...u&&Y(r)?{isValid:r}:{},errors:g.errors,name:t};g={...g,...e},w.state.next(e)}U(!1)},q=async e=>_.resolver(b,_.context,((e,t,r,s)=>{const a={};for(const r of e){const e=m(t,r);e&&$(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||V.mount,v,_.criteriaMode,_.shouldUseNativeValidation)),P=async(e,t,r={valid:!0})=>{for(const s in e){const a=e[s];if(a){const{_f:e,...s}=a;if(e){const s=V.array.has(e.name),n=await fe(a,b,j,_.shouldUseNativeValidation&&!t,s);if(n[e.name]&&(r.valid=!1,t))break;!t&&(m(n,e.name)?s?X(g.errors,n,e.name):$(g.errors,e.name,n[e.name]):be(g.errors,e.name))}s&&await P(s,t,r)}}return r.valid},W=(e,t)=>(e&&t&&$(b,e,t),!Fe(ne(),h)),I=(e,t,r)=>R(e,V,{...A.mount?b:f(t)?h:N(e)?{[e]:t}:t},r,t),H=(e,t,s={})=>{const n=m(v,e);let i=t;if(n){const s=n._f;s&&(!s.disabled&&$(b,e,Oe(t,s)),i=te(s.ref)&&a(t)?"":t,Se(s.ref)?[...s.ref.options].forEach((e=>e.selected=i.includes(e.value))):s.refs?r(s.ref)?s.refs.length>1?s.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(i)?!!i.find((t=>t===e.value)):i===e.value))):s.refs[0]&&(s.refs[0].checked=!!i):s.refs.forEach((e=>e.checked=e.value===i)):Z(s.ref)?s.ref.value="":(s.ref.value=i,s.ref.type||w.values.next({name:e,values:{...b}})))}(s.shouldDirty||s.shouldTouch)&&L(e,i,s.shouldTouch,s.shouldDirty,!0),s.shouldValidate&&ae(e)},G=(e,t,r)=>{for(const a in t){const n=t[a],i=`${e}.${a}`,u=m(v,i);!V.array.has(e)&&Ve(n)&&(!u||u._f)||s(n)?H(i,n,r):G(i,n,r)}},J=(e,r,s={})=>{const n=m(v,e),i=V.array.has(e),u=c(r);$(b,e,u),i?(w.array.next({name:e,values:{...b}}),(S.isDirty||S.dirtyFields)&&s.shouldDirty&&w.state.next({name:e,dirtyFields:je(h,b),isDirty:W(e,u)})):!n||n._f||a(u)?H(e,u,s):G(e,u,s),Q(e,V)&&w.state.next({...g}),w.values.next({name:e,values:{...b}}),!A.mount&&t()},re=async e=>{const t=e.target;let r=t.name,s=!0;const a=m(v,r);if(a){let o,l;const c=t.type?Ee(a._f):u(e),d=e.type===y||e.type===p,f=!((i=a._f).mount&&(i.required||i.min||i.max||i.maxLength||i.minLength||i.pattern||i.validate)||_.resolver||m(g.errors,r)||a._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(d,m(g.touchedFields,r),g.isSubmitted,C,D),h=Q(r,V,d);$(b,r,c),d?(a._f.onBlur&&a._f.onBlur(e),n&&n(0)):a._f.onChange&&a._f.onChange(e);const x=L(r,c,d,!1),A=!E(x)||h;if(!d&&w.values.next({name:r,type:e.type,values:{...b}}),f)return S.isValid&&O(),A&&w.state.next({name:r,...h?{}:x});if(!d&&h&&w.state.next({...g}),U(!0),_.resolver){const{errors:e}=await q([r]),t=Be(g.errors,v,r),s=Be(e,v,t.name||r);o=s.error,r=s.name,l=E(e)}else o=(await fe(a,b,j,_.shouldUseNativeValidation))[r],s=c===m(b,r,c),s&&(o?l=!1:S.isValid&&(l=await P(v,!0)));s&&(a._f.deps&&ae(a._f.deps),M(r,l,o,x))}var i},ae=async(e,t={})=>{let r,s;const a=B(e);if(U(!0),_.resolver){const t=await(async e=>{const{errors:t}=await q();if(e)for(const r of e){const e=m(t,r);e?$(g.errors,r,e):be(g.errors,r)}else g.errors=t;return t})(f(e)?e:a);r=E(t),s=e?!a.some((e=>m(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=m(v,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||g.isValid)&&O()):s=r=await P(v);return w.state.next({...!N(e)||S.isValid&&r!==g.isValid?{}:{name:e},..._.resolver||!e?{isValid:r}:{},errors:g.errors,isValidating:!1}),t.shouldFocus&&!s&&z(v,(e=>e&&m(g.errors,e)),e?a:V.mount),s},ne=e=>{const t={...h,...A.mount?b:{}};return f(e)?t:N(e)?m(t,e):e.map((e=>m(t,e)))},ie=(e,t)=>({invalid:!!m((t||g).errors,e),isDirty:!!m((t||g).dirtyFields,e),isTouched:!!m((t||g).touchedFields,e),error:m((t||g).errors,e)}),ue=(e,t={})=>{for(const r of e?B(e):V.mount)V.mount.delete(r),V.array.delete(r),m(v,r)&&(t.keepValue||(be(v,r),be(b,r)),!t.keepError&&be(g.errors,r),!t.keepDirty&&be(g.dirtyFields,r),!t.keepTouched&&be(g.touchedFields,r),!_.shouldUnregister&&!t.keepDefaultValue&&be(h,r));w.values.next({values:{...b}}),w.state.next({...g,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&O()},oe=(e,t={})=>{let s=m(v,e);const a=Y(t.disabled);return $(v,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...t}}),V.mount.add(e),s?a&&$(b,e,t.disabled?void 0:m(b,e,Ee(s._f))):T(e,!0,t.value),{...a?{disabled:t.disabled}:{},..._.shouldUseNativeValidation?{required:!!t.required,min:Ue(t.min),max:Ue(t.max),minLength:Ue(t.minLength),maxLength:Ue(t.maxLength),pattern:Ue(t.pattern)}:{},name:e,onChange:re,onBlur:re,ref:a=>{if(a){oe(e,t),s=m(v,e);const n=f(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,i=(e=>se(e)||r(e))(n),u=s._f.refs||[];if(i?u.find((e=>e===n)):n===s._f.ref)return;$(v,e,{_f:{...s._f,...i?{refs:[...u.filter(we),n,...Array.isArray(m(h,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),T(e,!1,void 0,n)}else s=m(v,e,{}),s._f&&(s._f.mount=!1),(_.shouldUnregister||t.shouldUnregister)&&(!o(V.array,e)||!A.action)&&V.unMount.add(e)}}},le=()=>_.shouldFocusError&&z(v,(e=>e&&m(g.errors,e)),V.mount),ce=(r,s={})=>{const a=r||h,n=c(a),i=r&&!E(r)?n:h;if(s.keepDefaultValues||(h=a),!s.keepValues){if(s.keepDirtyValues||k)for(const e of V.mount)m(g.dirtyFields,e)?$(i,e,m(b,e)):J(e,m(i,e));else{if(l&&f(r))for(const e of V.mount){const t=m(v,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(te(e)){const t=e.closest("form");if(t){t.reset();break}}}}v={}}b=e.shouldUnregister?s.keepDefaultValues?c(h):{}:n,w.array.next({values:{...i}}),w.values.next({values:{...i}})}V={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!A.mount&&t(),A.mount=!S.isValid||!!s.keepIsValid,A.watch=!!e.shouldUnregister,w.state.next({submitCount:s.keepSubmitCount?g.submitCount:0,isDirty:s.keepDirty?g.isDirty:!(!s.keepDefaultValues||Fe(r,h)),isSubmitted:!!s.keepIsSubmitted&&g.isSubmitted,dirtyFields:s.keepDirtyValues?g.dirtyFields:s.keepDefaultValues&&r?je(h,r):{},touchedFields:s.keepTouched?g.touchedFields:{},errors:s.keepErrors?g.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(ee(e)?e(b):e,t);return ee(_.defaultValues)&&_.defaultValues().then((e=>{de(e,_.resetOptions),w.state.next({isLoading:!1})})),{control:{register:oe,unregister:ue,getFieldState:ie,_executeSchema:q,_getWatch:I,_getDirty:W,_updateValid:O,_removeUnmounted:()=>{for(const e of V.unMount){const t=m(v,e);t&&(t._f.refs?t._f.refs.every((e=>!we(e))):!we(t._f.ref))&&ue(e)}V.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(A.action=!0,n&&Array.isArray(m(v,e))){const t=r(m(v,e),s.argA,s.argB);a&&$(v,e,t)}if(n&&Array.isArray(m(g.errors,e))){const t=r(m(g.errors,e),s.argA,s.argB);a&&$(g.errors,e,t),((e,t)=>{!d(m(e,t)).length&&be(e,t)})(g.errors,e)}if(S.touchedFields&&n&&Array.isArray(m(g.touchedFields,e))){const t=r(m(g.touchedFields,e),s.argA,s.argB);a&&$(g.touchedFields,e,t)}S.dirtyFields&&(g.dirtyFields=je(h,b)),w.state.next({name:e,isDirty:W(e,t),dirtyFields:g.dirtyFields,errors:g.errors,isValid:g.isValid})}else $(b,e,t)},_getFieldArray:t=>d(m(A.mount?b:h,t,e.shouldUnregister?m(h,t,[]):[])),_reset:ce,_updateFormState:e=>{g={...g,...e}},_subjects:w,_proxyFormState:S,get _fields(){return v},get _formValues(){return b},get _state(){return A},set _state(e){A=e},get _defaultValues(){return h},get _names(){return V},set _names(e){V=e},get _formState(){return g},set _formState(e){g=e},get _options(){return _},set _options(e){_={..._,...e}}},trigger:ae,register:oe,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let s=c(b);if(w.state.next({isSubmitting:!0}),_.resolver){const{errors:e,values:t}=await q();g.errors=e,s=t}else await P(v);be(g.errors,"root"),E(g.errors)?(w.state.next({errors:{}}),await e(s,r)):(t&&await t({...g.errors},r),le(),setTimeout(le)),w.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:E(g.errors),submitCount:g.submitCount+1,errors:g.errors})},watch:(e,t)=>ee(e)?w.values.subscribe({next:r=>e(I(void 0,t),r)}):I(e,t,!0),setValue:J,getValues:ne,reset:de,resetField:(e,t={})=>{m(v,e)&&(f(t.defaultValue)?J(e,m(h,e)):(J(e,t.defaultValue),$(h,e,t.defaultValue)),t.keepTouched||be(g.touchedFields,e),t.keepDirty||(be(g.dirtyFields,e),g.isDirty=t.defaultValue?W(e,m(h,e)):W()),t.keepError||(be(g.errors,e),S.isValid&&O()),w.state.next({...g}))},clearErrors:e=>{e&&B(e).forEach((e=>be(g.errors,e))),w.state.next({errors:e?g.errors:{}})},unregister:ue,setError:(e,t,r)=>{const s=(m(v,e,{_f:{}})._f||{}).ref;$(g.errors,e,{...t,ref:s}),w.state.next({name:e,errors:g.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=m(v,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}exports.Controller=e=>e.render(I(e)),exports.FormProvider=e=>{const{children:r,...s}=e;return t.default.createElement(C.Provider,{value:s},r)},exports.appendErrors=H,exports.get=m,exports.set=$,exports.useController=I,exports.useFieldArray=function(e){const r=j(),{control:s=r.control,name:a,keyName:n="id",shouldUnregister:i}=e,[u,o]=t.default.useState(s._getFieldArray(a)),l=t.default.useRef(s._getFieldArray(a).map(G)),d=t.default.useRef(u),f=t.default.useRef(a),y=t.default.useRef(!1);f.current=a,d.current=u,s._names.array.add(a),e.rules&&s.register(a,e.rules),L({next:({values:e,name:t})=>{if(t===f.current||!t){const t=m(e,f.current);Array.isArray(t)&&(o(t),l.current=t.map(G))}},subject:s._subjects.array});const p=t.default.useCallback((e=>{y.current=!0,s._updateFieldArray(a,e)}),[s,a]);return t.default.useEffect((()=>{if(s._state.action=!1,Q(a,s._names)&&s._subjects.state.next({...s._formState}),y.current&&(!K(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._executeSchema([a]).then((e=>{const t=m(e.errors,a),r=m(s._formState.errors,a);(r?!t&&r.type:t&&t.type)&&(t?$(s._formState.errors,a,t):be(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=m(s._fields,a);e&&e._f&&fe(e,s._formValues,s._options.criteriaMode===x,s._options.shouldUseNativeValidation,!0).then((e=>!E(e)&&s._subjects.state.next({errors:X(s._formState.errors,e,a)})))}s._subjects.values.next({name:a,values:{...s._formValues}}),s._names.focus&&z(s._fields,(e=>!!e&&e.startsWith(s._names.focus||""))),s._names.focus="",s._updateValid()}),[u,a,s]),t.default.useEffect((()=>(!m(s._formValues,a)&&s._updateFieldArray(a),()=>{(s._options.shouldUnregister||i)&&s.unregister(a)})),[a,s,n,i]),{swap:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);he(r,e,t),he(l.current,e,t),p(r),o(r),s._updateFieldArray(a,r,he,{argA:e,argB:t},!1)}),[p,a,s]),move:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);_e(r,e,t),_e(l.current,e,t),p(r),o(r),s._updateFieldArray(a,r,_e,{argA:e,argB:t},!1)}),[p,a,s]),prepend:t.default.useCallback(((e,t)=>{const r=B(c(e)),n=ge(s._getFieldArray(a),r);s._names.focus=J(a,0,t),l.current=ge(l.current,r.map(G)),p(n),o(n),s._updateFieldArray(a,n,ge,{argA:ye(e)})}),[p,a,s]),append:t.default.useCallback(((e,t)=>{const r=B(c(e)),n=me(s._getFieldArray(a),r);s._names.focus=J(a,n.length-1,t),l.current=me(l.current,r.map(G)),p(n),o(n),s._updateFieldArray(a,n,me,{argA:ye(e)})}),[p,a,s]),remove:t.default.useCallback((e=>{const t=ve(s._getFieldArray(a),e);l.current=ve(l.current,e),p(t),o(t),s._updateFieldArray(a,t,ve,{argA:e})}),[p,a,s]),insert:t.default.useCallback(((e,t,r)=>{const n=B(c(t)),i=pe(s._getFieldArray(a),e,n);s._names.focus=J(a,e,r),l.current=pe(l.current,e,n.map(G)),p(i),o(i),s._updateFieldArray(a,i,pe,{argA:e,argB:ye(t)})}),[p,a,s]),update:t.default.useCallback(((e,t)=>{const r=c(t),n=xe(s._getFieldArray(a),e,r);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:G())),p(n),o([...n]),s._updateFieldArray(a,n,xe,{argA:e,argB:r},!0,!1)}),[p,a,s]),replace:t.default.useCallback((e=>{const t=B(c(e));l.current=t.map(G),p([...t]),o([...t]),s._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[p,a,s]),fields:t.default.useMemo((()=>u.map(((e,t)=>({...e,[n]:l.current[t]||G()})))),[u,n])}},exports.useForm=function(e={}){const r=t.default.useRef(),[s,a]=t.default.useState({isDirty:!1,isValidating:!1,isLoading:ee(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:ee(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...Le(e,(()=>a((e=>({...e}))))),formState:s});const n=r.current.control;return n._options=e,L({subject:n._subjects.state,next:e=>{U(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),t.default.useEffect((()=>{e.values&&!Fe(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),t.default.useEffect((()=>{n._state.mount||(n._updateValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),r.current.formState=O(s,n),r.current},exports.useFormContext=j,exports.useFormState=M,exports.useWatch=q;
//# sourceMappingURL=index.cjs.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactHookForm={},e.React)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=r(t),a=e=>"checkbox"===e.type,n=e=>e instanceof Date,i=e=>null==e;const u=e=>"object"==typeof e;var o=e=>!i(e)&&!Array.isArray(e)&&u(e)&&!n(e),l=e=>o(e)&&e.target?a(e.target)?e.target.checked:e.target.value:e,c=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),d="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function f(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(d&&(e instanceof Blob||e instanceof FileList)||!r&&!o(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return o(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=f(e[r]);else t=e}return t}var m=e=>Array.isArray(e)?e.filter(Boolean):[],y=e=>void 0===e,p=(e,t,r)=>{if(!t||!o(e))return r;const s=m(t.split(/[,[\].]+?/)).reduce(((e,t)=>i(e)?e:e[t]),e);return y(s)||s===e?y(e[t])?r:e[t]:s};const g="blur",_="focusout",h="change",v="onBlur",b="onChange",A="onSubmit",x="onTouched",V="all",F="max",S="min",w="maxLength",k="minLength",D="pattern",C="required",j="validate",O=s.default.createContext(null),E=()=>s.default.useContext(O);var T=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==V&&(t._proxyFormState[a]=!s||V),r&&(r[a]=!0),e[a]}});return a},U=e=>o(e)&&!Object.keys(e).length,B=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return U(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||V)))},L=e=>Array.isArray(e)?e:[e],M=(e,t,r)=>r&&t?e===t:!e||!t||e===t||L(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function N(e){const t=s.default.useRef(e);t.current=e,s.default.useEffect((()=>{const r=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{r&&r.unsubscribe()}}),[e.disabled])}function R(e){const t=E(),{control:r=t.control,disabled:a,name:n,exact:i}=e||{},[u,o]=s.default.useState(r._formState),l=s.default.useRef(!0),c=s.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=s.default.useRef(n);return d.current=n,N({disabled:a,next:e=>l.current&&M(d.current,e.name,i)&&B(e,c.current,r._updateFormState)&&o({...r._formState,...e}),subject:r._subjects.state}),s.default.useEffect((()=>{l.current=!0;const e=r._proxyFormState.isDirty&&r._getDirty();return e!==r._formState.isDirty&&r._subjects.state.next({isDirty:e}),c.current.isValid&&r._updateValid(!0),()=>{l.current=!1}}),[r]),T(u,r,c.current,!1)}var q=e=>"string"==typeof e,P=(e,t,r,s,a)=>q(e)?(s&&t.watch.add(e),p(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),p(r,e)))):(s&&(t.watchAll=!0),r);function W(e){const t=E(),{control:r=t.control,name:a,defaultValue:n,disabled:i,exact:u}=e||{},o=s.default.useRef(a);o.current=a,N({disabled:i,subject:r._subjects.values,next:e=>{M(o.current,e.name,u)&&c(f(P(o.current,r._names,e.values||r._formValues,!1,n)))}});const[l,c]=s.default.useState(r._getWatch(a,n));return s.default.useEffect((()=>r._removeUnmounted())),l}var $=e=>/^\w*$/.test(e),I=e=>m(e.replace(/["|']|\]/g,"").split(/\.|\[/));function H(e,t,r){let s=-1;const a=$(t)?[t]:I(t),n=a.length,i=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==i){const r=e[t];n=o(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}e[t]=n,e=e[t]}return e}function z(e){const t=E(),{name:r,control:a=t.control,shouldUnregister:n}=e,i=c(a._names.array,r),u=W({control:a,name:r,defaultValue:p(a._formValues,r,p(a._defaultValues,r,e.defaultValue)),exact:!0}),o=R({control:a,name:r}),d=s.default.useRef(a.register(r,{...e.rules,value:u}));return s.default.useEffect((()=>{const e=a._options.shouldUnregister||n,t=(e,t)=>{const r=p(a._fields,e);r&&(r._f.mount=t)};return t(r,!0),e&&H(a._defaultValues,r,f(p(a._options.defaultValues,r))),()=>{(i?e&&!a._state.action:e)?a.unregister(r):t(r,!1)}}),[r,a,i,n]),{field:{name:r,value:u,onChange:s.default.useCallback((e=>d.current.onChange({target:{value:l(e),name:r},type:h})),[r]),onBlur:s.default.useCallback((()=>d.current.onBlur({target:{value:p(a._formValues,r),name:r},type:g})),[r,a]),ref:e=>{const t=p(a._fields,r);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:o,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!p(o.errors,r)},isDirty:{enumerable:!0,get:()=>!!p(o.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!p(o.touchedFields,r)},error:{enumerable:!0,get:()=>p(o.errors,r)}})}}var G=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{};const J=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=p(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else o(s)&&J(s,t)}}};var K=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},Q=(e,t,r={})=>r.shouldFocus||y(r.shouldFocus)?r.focusName||`${e}.${y(r.focusIndex)?t:r.focusIndex}.`:"",X=e=>({isOnSubmit:!e||e===A,isOnBlur:e===v,isOnChange:e===b,isOnAll:e===V,isOnTouch:e===x}),Y=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),Z=(e,t,r)=>{const s=m(p(e,r));return H(s,"root",t[r]),H(e,r,s),e},ee=e=>"boolean"==typeof e,te=e=>"file"===e.type,re=e=>"function"==typeof e,se=e=>{if(!d)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ae=e=>q(e),ne=e=>"radio"===e.type,ie=e=>e instanceof RegExp;const ue={value:!1,isValid:!1},oe={value:!0,isValid:!0};var le=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!y(e[0].attributes.value)?y(e[0].value)||""===e[0].value?oe:{value:e[0].value,isValid:!0}:oe:ue}return ue};const ce={isValid:!1,value:null};var de=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),ce):ce;function fe(e,t,r="validate"){if(ae(e)||Array.isArray(e)&&e.every(ae)||ee(e)&&!e)return{type:r,message:ae(e)?e:"",ref:t}}var me=e=>o(e)&&!ie(e)?e:{value:e,message:""},ye=async(e,t,r,s,n)=>{const{ref:u,refs:l,required:c,maxLength:d,minLength:f,min:m,max:g,pattern:_,validate:h,name:v,valueAsNumber:b,mount:A,disabled:x}=e._f,V=p(t,v);if(!A||x)return{};const O=l?l[0]:u,E=e=>{s&&O.reportValidity&&(O.setCustomValidity(ee(e)?"":e||""),O.reportValidity())},T={},B=ne(u),L=a(u),M=B||L,N=(b||te(u))&&y(u.value)&&y(V)||se(u)&&""===u.value||""===V||Array.isArray(V)&&!V.length,R=G.bind(null,v,r,T),P=(e,t,r,s=w,a=k)=>{const n=e?t:r;T[v]={type:e?s:a,message:n,ref:u,...R(e?s:a,n)}};if(n?!Array.isArray(V)||!V.length:c&&(!M&&(N||i(V))||ee(V)&&!V||L&&!le(l).isValid||B&&!de(l).isValid)){const{value:e,message:t}=ae(c)?{value:!!c,message:c}:me(c);if(e&&(T[v]={type:C,message:t,ref:O,...R(C,t)},!r))return E(t),T}if(!(N||i(m)&&i(g))){let e,t;const s=me(g),a=me(m);if(i(V)||isNaN(V)){const r=u.valueAsDate||new Date(V),n=e=>new Date((new Date).toDateString()+" "+e),i="time"==u.type,o="week"==u.type;q(s.value)&&V&&(e=i?n(V)>n(s.value):o?V>s.value:r>new Date(s.value)),q(a.value)&&V&&(t=i?n(V)<n(a.value):o?V<a.value:r<new Date(a.value))}else{const r=u.valueAsNumber||(V?+V:V);i(s.value)||(e=r>s.value),i(a.value)||(t=r<a.value)}if((e||t)&&(P(!!e,s.message,a.message,F,S),!r))return E(T[v].message),T}if((d||f)&&!N&&(q(V)||n&&Array.isArray(V))){const e=me(d),t=me(f),s=!i(e.value)&&V.length>e.value,a=!i(t.value)&&V.length<t.value;if((s||a)&&(P(s,e.message,t.message),!r))return E(T[v].message),T}if(_&&!N&&q(V)){const{value:e,message:t}=me(_);if(ie(e)&&!V.match(e)&&(T[v]={type:D,message:t,ref:u,...R(D,t)},!r))return E(t),T}if(h)if(re(h)){const e=fe(await h(V,t),O);if(e&&(T[v]={...e,...R(j,e.message)},!r))return E(e.message),T}else if(o(h)){let e={};for(const s in h){if(!U(e)&&!r)break;const a=fe(await h[s](V,t),O,s);a&&(e={...a,...R(s,a.message)},E(a.message),r&&(T[v]=e))}if(!U(e)&&(T[v]={ref:O,...e},!r))return T}return E(!0),T};function pe(e,t){return[...e,...L(t)]}var ge=e=>Array.isArray(e)?e.map((()=>{})):void 0;function _e(e,t,r){return[...e.slice(0,t),...L(r),...e.slice(t)]}var he=(e,t,r)=>Array.isArray(e)?(y(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[];function ve(e,t){return[...L(t),...L(e)]}var be=(e,t)=>y(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return m(s).length?s:[]}(e,L(t).sort(((e,t)=>e-t))),Ae=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function xe(e,t){const r=Array.isArray(t)?t:$(t)?[t]:I(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=y(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(o(s)&&U(s)||Array.isArray(s)&&function(e){for(const t in e)if(!y(e[t]))return!1;return!0}(s))&&xe(e,r.slice(0,-1)),e}var Ve=(e,t,r)=>(e[t]=r,e);function Fe(){let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Se=e=>i(e)||!u(e);function we(e,t){if(Se(e)||Se(t))return e===t;if(n(e)&&n(t))return e.getTime()===t.getTime();const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(const a of r){const r=e[a];if(!s.includes(a))return!1;if("ref"!==a){const e=t[a];if(n(r)&&n(e)||o(r)&&o(e)||Array.isArray(r)&&Array.isArray(e)?!we(r,e):r!==e)return!1}}return!0}var ke=e=>"select-multiple"===e.type,De=e=>se(e)&&e.isConnected,Ce=e=>{for(const t in e)if(re(e[t]))return!0;return!1};function je(e,t={}){const r=Array.isArray(e);if(o(e)||r)for(const r in e)Array.isArray(e[r])||o(e[r])&&!Ce(e[r])?(t[r]=Array.isArray(e[r])?[]:{},je(e[r],t[r])):i(e[r])||(t[r]=!0);return t}function Oe(e,t,r){const s=Array.isArray(e);if(o(e)||s)for(const s in e)Array.isArray(e[s])||o(e[s])&&!Ce(e[s])?y(t)||Se(r[s])?r[s]=Array.isArray(e[s])?je(e[s],[]):{...je(e[s])}:Oe(e[s],i(t)?{}:t[s],r[s]):r[s]=!we(e[s],t[s]);return r}var Ee=(e,t)=>Oe(e,t,je(t)),Te=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>y(e)?e:t?""===e?NaN:e?+e:e:r&&q(e)?new Date(e):s?s(e):e;function Ue(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return te(t)?t.files:ne(t)?de(e.refs).value:ke(t)?[...t.selectedOptions].map((({value:e})=>e)):a(t)?le(e.refs).value:Te(y(t.value)?e.ref.value:t.value,e)}var Be=e=>y(e)?e:ie(e)?e.source:o(e)?ie(e.value)?e.value.source:e.value:e;function Le(e,t,r){const s=p(e,r);if(s||$(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=p(t,s),i=p(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Me={mode:A,reValidateMode:b,shouldFocusError:!0};function Ne(e={},t){let r,s={...Me,...e},u={submitCount:0,isDirty:!1,isLoading:!0,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},h={},v=(o(s.defaultValues)||o(s.values))&&f(s.defaultValues||s.values)||{},b=s.shouldUnregister?{}:f(v),A={action:!1,mount:!1,watch:!1},x={mount:new Set,unMount:new Set,array:new Set,watch:new Set},F=0;const S={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},w={values:Fe(),array:Fe(),state:Fe()},k=e.resetOptions&&e.resetOptions.keepDirtyValues,D=X(s.mode),C=X(s.reValidateMode),j=s.criteriaMode===V,O=async e=>{if(S.isValid||e){const e=s.resolver?U((await N()).errors):await R(h,!0);e!==u.isValid&&w.state.next({isValid:e})}},E=e=>S.isValidating&&w.state.next({isValidating:e}),T=(e,t,r,s)=>{const a=p(h,e);if(a){const n=p(b,e,y(r)?p(v,e):r);y(n)||s&&s.defaultChecked||t?H(b,e,t?n:Ue(a._f)):I(e,n),A.mount&&O()}},B=(e,t,r,s,a)=>{let n=!1,i=!1;const o={name:e};if(!r||s){S.isDirty&&(i=u.isDirty,u.isDirty=o.isDirty=W(),n=i!==o.isDirty);const r=we(p(v,e),t);i=p(u.dirtyFields,e),r?xe(u.dirtyFields,e):H(u.dirtyFields,e,!0),o.dirtyFields=u.dirtyFields,n=n||S.dirtyFields&&i!==!r}if(r){const t=p(u.touchedFields,e);t||(H(u.touchedFields,e,r),o.touchedFields=u.touchedFields,n=n||S.touchedFields&&t!==r)}return n&&a&&w.state.next(o),n?o:{}},M=(t,s,a,n)=>{const i=p(u.errors,t),o=S.isValid&&ee(s)&&u.isValid!==s;var l;if(e.delayError&&a?(l=()=>((e,t)=>{H(u.errors,e,t),w.state.next({errors:u.errors})})(t,a),r=e=>{clearTimeout(F),F=setTimeout(l,e)},r(e.delayError)):(clearTimeout(F),r=null,a?H(u.errors,t,a):xe(u.errors,t)),(a?!we(i,a):i)||!U(n)||o){const e={...n,...o&&ee(s)?{isValid:s}:{},errors:u.errors,name:t};u={...u,...e},w.state.next(e)}E(!1)},N=async e=>s.resolver(b,s.context,((e,t,r,s)=>{const a={};for(const r of e){const e=p(t,r);e&&H(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||x.mount,h,s.criteriaMode,s.shouldUseNativeValidation)),R=async(e,t,r={valid:!0})=>{for(const a in e){const n=e[a];if(n){const{_f:e,...a}=n;if(e){const a=x.array.has(e.name),i=await ye(n,b,j,s.shouldUseNativeValidation,a);if(i[e.name]&&(r.valid=!1,t))break;!t&&(p(i,e.name)?a?Z(u.errors,i,e.name):H(u.errors,e.name,i[e.name]):xe(u.errors,e.name))}a&&await R(a,t,r)}}return r.valid},W=(e,t)=>(e&&t&&H(b,e,t),!we(ae(),v)),$=(e,t,r)=>P(e,x,{...A.mount?b:y(t)?v:q(e)?{[e]:t}:t},r,t),I=(e,t,r={})=>{const s=p(h,e);let n=t;if(s){const r=s._f;r&&(!r.disabled&&H(b,e,Te(t,r)),n=se(r.ref)&&i(t)?"":t,ke(r.ref)?[...r.ref.options].forEach((e=>e.selected=n.includes(e.value))):r.refs?a(r.ref)?r.refs.length>1?r.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):r.refs[0]&&(r.refs[0].checked=!!n):r.refs.forEach((e=>e.checked=e.value===n)):te(r.ref)?r.ref.value="":(r.ref.value=n,r.ref.type||w.values.next({name:e,values:{...b}})))}(r.shouldDirty||r.shouldTouch)&&B(e,n,r.shouldTouch,r.shouldDirty,!0),r.shouldValidate&&Q(e)},z=(e,t,r)=>{for(const s in t){const a=t[s],i=`${e}.${s}`,u=p(h,i);!x.array.has(e)&&Se(a)&&(!u||u._f)||n(a)?I(i,a,r):z(i,a,r)}},G=(e,r,s={})=>{const a=p(h,e),n=x.array.has(e),o=f(r);H(b,e,o),n?(w.array.next({name:e,values:{...b}}),(S.isDirty||S.dirtyFields)&&s.shouldDirty&&w.state.next({name:e,dirtyFields:Ee(v,b),isDirty:W(e,o)})):!a||a._f||i(o)?I(e,o,s):z(e,o,s),Y(e,x)&&w.state.next({...u}),w.values.next({name:e,values:{...b}}),!A.mount&&t()},K=async e=>{const t=e.target;let a=t.name;const n=p(h,a);if(n){let o,c;const d=t.type?Ue(n._f):l(e),f=e.type===g||e.type===_,m=!((i=n._f).mount&&(i.required||i.min||i.max||i.maxLength||i.minLength||i.pattern||i.validate)||s.resolver||p(u.errors,a)||n._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(f,p(u.touchedFields,a),u.isSubmitted,C,D),y=Y(a,x,f);H(b,a,d),f?(n._f.onBlur&&n._f.onBlur(e),r&&r(0)):n._f.onChange&&n._f.onChange(e);const v=B(a,d,f,!1),A=!U(v)||y;if(!f&&w.values.next({name:a,type:e.type,values:{...b}}),m)return S.isValid&&O(),A&&w.state.next({name:a,...y?{}:v});if(!f&&y&&w.state.next({...u}),E(!0),s.resolver){const{errors:e}=await N([a]),t=Le(u.errors,h,a),r=Le(e,h,t.name||a);o=r.error,a=r.name,c=U(e)}else o=(await ye(n,b,j,s.shouldUseNativeValidation))[a],o?c=!1:S.isValid&&(c=await R(h,!0));n._f.deps&&Q(n._f.deps),M(a,c,o,v)}var i},Q=async(e,t={})=>{let r,a;const n=L(e);if(E(!0),s.resolver){const t=await(async e=>{const{errors:t}=await N();if(e)for(const r of e){const e=p(t,r);e?H(u.errors,r,e):xe(u.errors,r)}else u.errors=t;return t})(y(e)?e:n);r=U(t),a=e?!n.some((e=>p(t,e))):r}else e?(a=(await Promise.all(n.map((async e=>{const t=p(h,e);return await R(t&&t._f?{[e]:t}:t)})))).every(Boolean),(a||u.isValid)&&O()):a=r=await R(h);return w.state.next({...!q(e)||S.isValid&&r!==u.isValid?{}:{name:e},...s.resolver||!e?{isValid:r}:{},errors:u.errors,isValidating:!1}),t.shouldFocus&&!a&&J(h,(e=>e&&p(u.errors,e)),e?n:x.mount),a},ae=e=>{const t={...v,...A.mount?b:{}};return y(e)?t:q(e)?p(t,e):e.map((e=>p(t,e)))},ie=(e,t)=>({invalid:!!p((t||u).errors,e),isDirty:!!p((t||u).dirtyFields,e),isTouched:!!p((t||u).touchedFields,e),error:p((t||u).errors,e)}),ue=(e,t={})=>{for(const r of e?L(e):x.mount)x.mount.delete(r),x.array.delete(r),p(h,r)&&(t.keepValue||(xe(h,r),xe(b,r)),!t.keepError&&xe(u.errors,r),!t.keepDirty&&xe(u.dirtyFields,r),!t.keepTouched&&xe(u.touchedFields,r),!s.shouldUnregister&&!t.keepDefaultValue&&xe(v,r));w.values.next({values:{...b}}),w.state.next({...u,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&O()},oe=(e,t={})=>{let r=p(h,e);const n=ee(t.disabled);return H(h,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),x.mount.add(e),r?n&&H(b,e,t.disabled?void 0:p(b,e,Ue(r._f))):T(e,!0,t.value),{...n?{disabled:t.disabled}:{},...s.shouldUseNativeValidation?{required:!!t.required,min:Be(t.min),max:Be(t.max),minLength:Be(t.minLength),maxLength:Be(t.maxLength),pattern:Be(t.pattern)}:{},name:e,onChange:K,onBlur:K,ref:n=>{if(n){oe(e,t),r=p(h,e);const s=y(n.value)&&n.querySelectorAll&&n.querySelectorAll("input,select,textarea")[0]||n,i=(e=>ne(e)||a(e))(s),u=r._f.refs||[];if(i?u.find((e=>e===s)):s===r._f.ref)return;H(h,e,{_f:{...r._f,...i?{refs:[...u.filter(De),s,...Array.isArray(p(v,e))?[{}]:[]],ref:{type:s.type,name:e}}:{ref:s}}}),T(e,!1,void 0,s)}else r=p(h,e,{}),r._f&&(r._f.mount=!1),(s.shouldUnregister||t.shouldUnregister)&&(!c(x.array,e)||!A.action)&&x.unMount.add(e)}}},le=()=>s.shouldFocusError&&J(h,(e=>e&&p(u.errors,e)),x.mount),ce=(r,s={})=>{const a=r||v,n=f(a),i=r&&!U(r)?n:v;if(s.keepDefaultValues||(v=a),!s.keepValues){if(s.keepDirtyValues||k)for(const e of x.mount)p(u.dirtyFields,e)?H(i,e,p(b,e)):G(e,p(i,e));else{if(d&&y(r))for(const e of x.mount){const t=p(h,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(se(e)){const t=e.closest("form");if(t){t.reset();break}}}}h={}}b=e.shouldUnregister?s.keepDefaultValues?f(v):{}:n,w.array.next({values:{...i}}),w.values.next({values:{...i}})}x={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!A.mount&&t(),A.mount=!S.isValid||!!s.keepIsValid,A.watch=!!e.shouldUnregister,w.state.next({submitCount:s.keepSubmitCount?u.submitCount:0,isDirty:s.keepDirty?u.isDirty:!(!s.keepDefaultValues||we(r,v)),isSubmitted:!!s.keepIsSubmitted&&u.isSubmitted,dirtyFields:s.keepDirtyValues?u.dirtyFields:s.keepDefaultValues&&r?Ee(v,r):{},touchedFields:s.keepTouched?u.touchedFields:{},errors:s.keepErrors?u.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(re(e)?e(b):e,t);return re(s.defaultValues)&&s.defaultValues().then((e=>{de(e,s.resetOptions),w.state.next({isLoading:!1})})),{control:{register:oe,unregister:ue,getFieldState:ie,_executeSchema:N,_getWatch:$,_getDirty:W,_updateValid:O,_removeUnmounted:()=>{for(const e of x.unMount){const t=p(h,e);t&&(t._f.refs?t._f.refs.every((e=>!De(e))):!De(t._f.ref))&&ue(e)}x.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(A.action=!0,n&&Array.isArray(p(h,e))){const t=r(p(h,e),s.argA,s.argB);a&&H(h,e,t)}if(n&&Array.isArray(p(u.errors,e))){const t=r(p(u.errors,e),s.argA,s.argB);a&&H(u.errors,e,t),((e,t)=>{!m(p(e,t)).length&&xe(e,t)})(u.errors,e)}if(S.touchedFields&&n&&Array.isArray(p(u.touchedFields,e))){const t=r(p(u.touchedFields,e),s.argA,s.argB);a&&H(u.touchedFields,e,t)}S.dirtyFields&&(u.dirtyFields=Ee(v,b)),w.state.next({name:e,isDirty:W(e,t),dirtyFields:u.dirtyFields,errors:u.errors,isValid:u.isValid})}else H(b,e,t)},_getFieldArray:t=>m(p(A.mount?b:v,t,e.shouldUnregister?p(v,t,[]):[])),_reset:ce,_updateFormState:e=>{u={...u,...e}},_subjects:w,_proxyFormState:S,get _fields(){return h},get _formValues(){return b},get _state(){return A},set _state(e){A=e},get _defaultValues(){return v},get _names(){return x},set _names(e){x=e},get _formState(){return u},set _formState(e){u=e},get _options(){return s},set _options(e){s={...s,...e}}},trigger:Q,register:oe,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=f(b);if(w.state.next({isSubmitting:!0}),s.resolver){const{errors:e,values:t}=await N();u.errors=e,a=t}else await R(h);xe(u.errors,"root"),U(u.errors)?(w.state.next({errors:{}}),await e(a,r)):(t&&await t({...u.errors},r),le(),setTimeout(le)),w.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:U(u.errors),submitCount:u.submitCount+1,errors:u.errors})},watch:(e,t)=>re(e)?w.values.subscribe({next:r=>e($(void 0,t),r)}):$(e,t,!0),setValue:G,getValues:ae,reset:de,resetField:(e,t={})=>{p(h,e)&&(y(t.defaultValue)?G(e,p(v,e)):(G(e,t.defaultValue),H(v,e,t.defaultValue)),t.keepTouched||xe(u.touchedFields,e),t.keepDirty||(xe(u.dirtyFields,e),u.isDirty=t.defaultValue?W(e,p(v,e)):W()),t.keepError||(xe(u.errors,e),S.isValid&&O()),w.state.next({...u}))},clearErrors:e=>{e&&L(e).forEach((e=>xe(u.errors,e))),w.state.next({errors:e?u.errors:{}})},unregister:ue,setError:(e,t,r)=>{const s=(p(h,e,{_f:{}})._f||{}).ref;H(u.errors,e,{...t,ref:s}),w.state.next({name:e,errors:u.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=p(h,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}e.Controller=e=>e.render(z(e)),e.FormProvider=e=>{const{children:t,...r}=e;return s.default.createElement(O.Provider,{value:r},t)},e.appendErrors=G,e.get=p,e.set=H,e.useController=z,e.useFieldArray=function(e){const t=E(),{control:r=t.control,name:a,keyName:n="id",shouldUnregister:i}=e,[u,o]=s.default.useState(r._getFieldArray(a)),l=s.default.useRef(r._getFieldArray(a).map(K)),c=s.default.useRef(u),d=s.default.useRef(a),m=s.default.useRef(!1);d.current=a,c.current=u,r._names.array.add(a),e.rules&&r.register(a,e.rules),N({next:({values:e,name:t})=>{if(t===d.current||!t){const t=p(e,d.current);Array.isArray(t)&&(o(t),l.current=t.map(K))}},subject:r._subjects.array});const y=s.default.useCallback((e=>{m.current=!0,r._updateFieldArray(a,e)}),[r,a]);return s.default.useEffect((()=>{if(r._state.action=!1,Y(a,r._names)&&r._subjects.state.next({...r._formState}),m.current&&(!X(r._options.mode).isOnSubmit||r._formState.isSubmitted))if(r._options.resolver)r._executeSchema([a]).then((e=>{const t=p(e.errors,a),s=p(r._formState.errors,a);(s?!t&&s.type:t&&t.type)&&(t?H(r._formState.errors,a,t):xe(r._formState.errors,a),r._subjects.state.next({errors:r._formState.errors}))}));else{const e=p(r._fields,a);e&&e._f&&ye(e,r._formValues,r._options.criteriaMode===V,r._options.shouldUseNativeValidation,!0).then((e=>!U(e)&&r._subjects.state.next({errors:Z(r._formState.errors,e,a)})))}r._subjects.values.next({name:a,values:{...r._formValues}}),r._names.focus&&J(r._fields,(e=>!!e&&e.startsWith(r._names.focus||""))),r._names.focus="",r._updateValid()}),[u,a,r]),s.default.useEffect((()=>(!p(r._formValues,a)&&r._updateFieldArray(a),()=>{(r._options.shouldUnregister||i)&&r.unregister(a)})),[a,r,n,i]),{swap:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);Ae(s,e,t),Ae(l.current,e,t),y(s),o(s),r._updateFieldArray(a,s,Ae,{argA:e,argB:t},!1)}),[y,a,r]),move:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);he(s,e,t),he(l.current,e,t),y(s),o(s),r._updateFieldArray(a,s,he,{argA:e,argB:t},!1)}),[y,a,r]),prepend:s.default.useCallback(((e,t)=>{const s=L(f(e)),n=ve(r._getFieldArray(a),s);r._names.focus=Q(a,0,t),l.current=ve(l.current,s.map(K)),y(n),o(n),r._updateFieldArray(a,n,ve,{argA:ge(e)})}),[y,a,r]),append:s.default.useCallback(((e,t)=>{const s=L(f(e)),n=pe(r._getFieldArray(a),s);r._names.focus=Q(a,n.length-1,t),l.current=pe(l.current,s.map(K)),y(n),o(n),r._updateFieldArray(a,n,pe,{argA:ge(e)})}),[y,a,r]),remove:s.default.useCallback((e=>{const t=be(r._getFieldArray(a),e);l.current=be(l.current,e),y(t),o(t),r._updateFieldArray(a,t,be,{argA:e})}),[y,a,r]),insert:s.default.useCallback(((e,t,s)=>{const n=L(f(t)),i=_e(r._getFieldArray(a),e,n);r._names.focus=Q(a,e,s),l.current=_e(l.current,e,n.map(K)),y(i),o(i),r._updateFieldArray(a,i,_e,{argA:e,argB:ge(t)})}),[y,a,r]),update:s.default.useCallback(((e,t)=>{const s=f(t),n=Ve(r._getFieldArray(a),e,s);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:K())),y(n),o([...n]),r._updateFieldArray(a,n,Ve,{argA:e,argB:s},!0,!1)}),[y,a,r]),replace:s.default.useCallback((e=>{const t=L(f(e));l.current=t.map(K),y([...t]),o([...t]),r._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[y,a,r]),fields:s.default.useMemo((()=>u.map(((e,t)=>({...e,[n]:l.current[t]||K()})))),[u,n])}},e.useForm=function(e={}){const t=s.default.useRef(),[r,a]=s.default.useState({isDirty:!1,isValidating:!1,isLoading:!0,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:re(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ne(e,(()=>a((e=>({...e}))))),formState:r});const n=t.current.control;return n._options=e,N({subject:n._subjects.state,next:e=>{B(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),s.default.useEffect((()=>{e.values&&!we(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),s.default.useEffect((()=>{n._state.mount||(n._updateValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),t.current.formState=T(r,n),t.current},e.useFormContext=E,e.useFormState=R,e.useWatch=W,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactHookForm={},e.React)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=r(t),a=e=>"checkbox"===e.type,n=e=>e instanceof Date,i=e=>null==e;const u=e=>"object"==typeof e;var o=e=>!i(e)&&!Array.isArray(e)&&u(e)&&!n(e),l=e=>o(e)&&e.target?a(e.target)?e.target.checked:e.target.value:e,c=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),d="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function f(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(d&&(e instanceof Blob||e instanceof FileList)||!r&&!o(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return o(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=f(e[r]);else t=e}return t}var m=e=>Array.isArray(e)?e.filter(Boolean):[],y=e=>void 0===e,p=(e,t,r)=>{if(!t||!o(e))return r;const s=m(t.split(/[,[\].]+?/)).reduce(((e,t)=>i(e)?e:e[t]),e);return y(s)||s===e?y(e[t])?r:e[t]:s};const g="blur",_="focusout",h="change",v="onBlur",b="onChange",A="onSubmit",x="onTouched",V="all",F="max",S="min",w="maxLength",k="minLength",D="pattern",C="required",j="validate",O=s.default.createContext(null),E=()=>s.default.useContext(O);var T=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==V&&(t._proxyFormState[a]=!s||V),r&&(r[a]=!0),e[a]}});return a},U=e=>o(e)&&!Object.keys(e).length,B=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return U(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||V)))},L=e=>Array.isArray(e)?e:[e],M=(e,t,r)=>r&&t?e===t:!e||!t||e===t||L(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function N(e){const t=s.default.useRef(e);t.current=e,s.default.useEffect((()=>{const r=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{r&&r.unsubscribe()}}),[e.disabled])}function R(e){const t=E(),{control:r=t.control,disabled:a,name:n,exact:i}=e||{},[u,o]=s.default.useState(r._formState),l=s.default.useRef(!0),c=s.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=s.default.useRef(n);return d.current=n,N({disabled:a,next:e=>l.current&&M(d.current,e.name,i)&&B(e,c.current,r._updateFormState)&&o({...r._formState,...e}),subject:r._subjects.state}),s.default.useEffect((()=>{l.current=!0;const e=r._proxyFormState.isDirty&&r._getDirty();return e!==r._formState.isDirty&&r._subjects.state.next({isDirty:e}),c.current.isValid&&r._updateValid(!0),()=>{l.current=!1}}),[r]),T(u,r,c.current,!1)}var q=e=>"string"==typeof e,P=(e,t,r,s,a)=>q(e)?(s&&t.watch.add(e),p(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),p(r,e)))):(s&&(t.watchAll=!0),r);function W(e){const t=E(),{control:r=t.control,name:a,defaultValue:n,disabled:i,exact:u}=e||{},o=s.default.useRef(a);o.current=a,N({disabled:i,subject:r._subjects.values,next:e=>{M(o.current,e.name,u)&&c(f(P(o.current,r._names,e.values||r._formValues,!1,n)))}});const[l,c]=s.default.useState(r._getWatch(a,n));return s.default.useEffect((()=>r._removeUnmounted())),l}var $=e=>/^\w*$/.test(e),I=e=>m(e.replace(/["|']|\]/g,"").split(/\.|\[/));function H(e,t,r){let s=-1;const a=$(t)?[t]:I(t),n=a.length,i=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==i){const r=e[t];n=o(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}e[t]=n,e=e[t]}return e}function z(e){const t=E(),{name:r,control:a=t.control,shouldUnregister:n}=e,i=c(a._names.array,r),u=W({control:a,name:r,defaultValue:p(a._formValues,r,p(a._defaultValues,r,e.defaultValue)),exact:!0}),o=R({control:a,name:r}),d=s.default.useRef(a.register(r,{...e.rules,value:u}));return s.default.useEffect((()=>{const e=a._options.shouldUnregister||n,t=(e,t)=>{const r=p(a._fields,e);r&&(r._f.mount=t)};if(t(r,!0),e){const e=f(p(a._options.defaultValues,r));H(a._defaultValues,r,e),y(p(a._formValues,r))&&H(a._formValues,r,e)}return()=>{(i?e&&!a._state.action:e)?a.unregister(r):t(r,!1)}}),[r,a,i,n]),{field:{name:r,value:u,onChange:s.default.useCallback((e=>d.current.onChange({target:{value:l(e),name:r},type:h})),[r]),onBlur:s.default.useCallback((()=>d.current.onBlur({target:{value:p(a._formValues,r),name:r},type:g})),[r,a]),ref:e=>{const t=p(a._fields,r);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:o,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!p(o.errors,r)},isDirty:{enumerable:!0,get:()=>!!p(o.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!p(o.touchedFields,r)},error:{enumerable:!0,get:()=>p(o.errors,r)}})}}var G=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{};const J=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=p(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else o(s)&&J(s,t)}}};var K=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},Q=(e,t,r={})=>r.shouldFocus||y(r.shouldFocus)?r.focusName||`${e}.${y(r.focusIndex)?t:r.focusIndex}.`:"",X=e=>({isOnSubmit:!e||e===A,isOnBlur:e===v,isOnChange:e===b,isOnAll:e===V,isOnTouch:e===x}),Y=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),Z=(e,t,r)=>{const s=m(p(e,r));return H(s,"root",t[r]),H(e,r,s),e},ee=e=>"boolean"==typeof e,te=e=>"file"===e.type,re=e=>"function"==typeof e,se=e=>{if(!d)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ae=e=>q(e),ne=e=>"radio"===e.type,ie=e=>e instanceof RegExp;const ue={value:!1,isValid:!1},oe={value:!0,isValid:!0};var le=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!y(e[0].attributes.value)?y(e[0].value)||""===e[0].value?oe:{value:e[0].value,isValid:!0}:oe:ue}return ue};const ce={isValid:!1,value:null};var de=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),ce):ce;function fe(e,t,r="validate"){if(ae(e)||Array.isArray(e)&&e.every(ae)||ee(e)&&!e)return{type:r,message:ae(e)?e:"",ref:t}}var me=e=>o(e)&&!ie(e)?e:{value:e,message:""},ye=async(e,t,r,s,n)=>{const{ref:u,refs:l,required:c,maxLength:d,minLength:f,min:m,max:g,pattern:_,validate:h,name:v,valueAsNumber:b,mount:A,disabled:x}=e._f,V=p(t,v);if(!A||x)return{};const O=l?l[0]:u,E=e=>{s&&O.reportValidity&&(O.setCustomValidity(ee(e)?"":e||""),O.reportValidity())},T={},B=ne(u),L=a(u),M=B||L,N=(b||te(u))&&y(u.value)&&y(V)||se(u)&&""===u.value||""===V||Array.isArray(V)&&!V.length,R=G.bind(null,v,r,T),P=(e,t,r,s=w,a=k)=>{const n=e?t:r;T[v]={type:e?s:a,message:n,ref:u,...R(e?s:a,n)}};if(n?!Array.isArray(V)||!V.length:c&&(!M&&(N||i(V))||ee(V)&&!V||L&&!le(l).isValid||B&&!de(l).isValid)){const{value:e,message:t}=ae(c)?{value:!!c,message:c}:me(c);if(e&&(T[v]={type:C,message:t,ref:O,...R(C,t)},!r))return E(t),T}if(!(N||i(m)&&i(g))){let e,t;const s=me(g),a=me(m);if(i(V)||isNaN(V)){const r=u.valueAsDate||new Date(V),n=e=>new Date((new Date).toDateString()+" "+e),i="time"==u.type,o="week"==u.type;q(s.value)&&V&&(e=i?n(V)>n(s.value):o?V>s.value:r>new Date(s.value)),q(a.value)&&V&&(t=i?n(V)<n(a.value):o?V<a.value:r<new Date(a.value))}else{const r=u.valueAsNumber||(V?+V:V);i(s.value)||(e=r>s.value),i(a.value)||(t=r<a.value)}if((e||t)&&(P(!!e,s.message,a.message,F,S),!r))return E(T[v].message),T}if((d||f)&&!N&&(q(V)||n&&Array.isArray(V))){const e=me(d),t=me(f),s=!i(e.value)&&V.length>e.value,a=!i(t.value)&&V.length<t.value;if((s||a)&&(P(s,e.message,t.message),!r))return E(T[v].message),T}if(_&&!N&&q(V)){const{value:e,message:t}=me(_);if(ie(e)&&!V.match(e)&&(T[v]={type:D,message:t,ref:u,...R(D,t)},!r))return E(t),T}if(h)if(re(h)){const e=fe(await h(V,t),O);if(e&&(T[v]={...e,...R(j,e.message)},!r))return E(e.message),T}else if(o(h)){let e={};for(const s in h){if(!U(e)&&!r)break;const a=fe(await h[s](V,t),O,s);a&&(e={...a,...R(s,a.message)},E(a.message),r&&(T[v]=e))}if(!U(e)&&(T[v]={ref:O,...e},!r))return T}return E(!0),T};function pe(e,t){return[...e,...L(t)]}var ge=e=>Array.isArray(e)?e.map((()=>{})):void 0;function _e(e,t,r){return[...e.slice(0,t),...L(r),...e.slice(t)]}var he=(e,t,r)=>Array.isArray(e)?(y(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[];function ve(e,t){return[...L(t),...L(e)]}var be=(e,t)=>y(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return m(s).length?s:[]}(e,L(t).sort(((e,t)=>e-t))),Ae=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function xe(e,t){const r=Array.isArray(t)?t:$(t)?[t]:I(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=y(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(o(s)&&U(s)||Array.isArray(s)&&function(e){for(const t in e)if(!y(e[t]))return!1;return!0}(s))&&xe(e,r.slice(0,-1)),e}var Ve=(e,t,r)=>(e[t]=r,e);function Fe(){let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Se=e=>i(e)||!u(e);function we(e,t){if(Se(e)||Se(t))return e===t;if(n(e)&&n(t))return e.getTime()===t.getTime();const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(const a of r){const r=e[a];if(!s.includes(a))return!1;if("ref"!==a){const e=t[a];if(n(r)&&n(e)||o(r)&&o(e)||Array.isArray(r)&&Array.isArray(e)?!we(r,e):r!==e)return!1}}return!0}var ke=e=>"select-multiple"===e.type,De=e=>se(e)&&e.isConnected,Ce=e=>{for(const t in e)if(re(e[t]))return!0;return!1};function je(e,t={}){const r=Array.isArray(e);if(o(e)||r)for(const r in e)Array.isArray(e[r])||o(e[r])&&!Ce(e[r])?(t[r]=Array.isArray(e[r])?[]:{},je(e[r],t[r])):i(e[r])||(t[r]=!0);return t}function Oe(e,t,r){const s=Array.isArray(e);if(o(e)||s)for(const s in e)Array.isArray(e[s])||o(e[s])&&!Ce(e[s])?y(t)||Se(r[s])?r[s]=Array.isArray(e[s])?je(e[s],[]):{...je(e[s])}:Oe(e[s],i(t)?{}:t[s],r[s]):r[s]=!we(e[s],t[s]);return r}var Ee=(e,t)=>Oe(e,t,je(t)),Te=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>y(e)?e:t?""===e?NaN:e?+e:e:r&&q(e)?new Date(e):s?s(e):e;function Ue(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return te(t)?t.files:ne(t)?de(e.refs).value:ke(t)?[...t.selectedOptions].map((({value:e})=>e)):a(t)?le(e.refs).value:Te(y(t.value)?e.ref.value:t.value,e)}var Be=e=>y(e)?e:ie(e)?e.source:o(e)?ie(e.value)?e.value.source:e.value:e;function Le(e,t,r){const s=p(e,r);if(s||$(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=p(t,s),i=p(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Me={mode:A,reValidateMode:b,shouldFocusError:!0};function Ne(e={},t){let r,s={...Me,...e},u={submitCount:0,isDirty:!1,isLoading:re(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},h={},v=(o(s.defaultValues)||o(s.values))&&f(s.defaultValues||s.values)||{},b=s.shouldUnregister?{}:f(v),A={action:!1,mount:!1,watch:!1},x={mount:new Set,unMount:new Set,array:new Set,watch:new Set},F=0;const S={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},w={values:Fe(),array:Fe(),state:Fe()},k=e.resetOptions&&e.resetOptions.keepDirtyValues,D=X(s.mode),C=X(s.reValidateMode),j=s.criteriaMode===V,O=async e=>{if(S.isValid||e){const e=s.resolver?U((await N()).errors):await R(h,!0);e!==u.isValid&&w.state.next({isValid:e})}},E=e=>S.isValidating&&w.state.next({isValidating:e}),T=(e,t,r,s)=>{const a=p(h,e);if(a){const n=p(b,e,y(r)?p(v,e):r);y(n)||s&&s.defaultChecked||t?H(b,e,t?n:Ue(a._f)):I(e,n),A.mount&&O()}},B=(e,t,r,s,a)=>{let n=!1,i=!1;const o={name:e};if(!r||s){S.isDirty&&(i=u.isDirty,u.isDirty=o.isDirty=W(),n=i!==o.isDirty);const r=we(p(v,e),t);i=p(u.dirtyFields,e),r?xe(u.dirtyFields,e):H(u.dirtyFields,e,!0),o.dirtyFields=u.dirtyFields,n=n||S.dirtyFields&&i!==!r}if(r){const t=p(u.touchedFields,e);t||(H(u.touchedFields,e,r),o.touchedFields=u.touchedFields,n=n||S.touchedFields&&t!==r)}return n&&a&&w.state.next(o),n?o:{}},M=(t,s,a,n)=>{const i=p(u.errors,t),o=S.isValid&&ee(s)&&u.isValid!==s;var l;if(e.delayError&&a?(l=()=>((e,t)=>{H(u.errors,e,t),w.state.next({errors:u.errors})})(t,a),r=e=>{clearTimeout(F),F=setTimeout(l,e)},r(e.delayError)):(clearTimeout(F),r=null,a?H(u.errors,t,a):xe(u.errors,t)),(a?!we(i,a):i)||!U(n)||o){const e={...n,...o&&ee(s)?{isValid:s}:{},errors:u.errors,name:t};u={...u,...e},w.state.next(e)}E(!1)},N=async e=>s.resolver(b,s.context,((e,t,r,s)=>{const a={};for(const r of e){const e=p(t,r);e&&H(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||x.mount,h,s.criteriaMode,s.shouldUseNativeValidation)),R=async(e,t,r={valid:!0})=>{for(const a in e){const n=e[a];if(n){const{_f:e,...a}=n;if(e){const a=x.array.has(e.name),i=await ye(n,b,j,s.shouldUseNativeValidation&&!t,a);if(i[e.name]&&(r.valid=!1,t))break;!t&&(p(i,e.name)?a?Z(u.errors,i,e.name):H(u.errors,e.name,i[e.name]):xe(u.errors,e.name))}a&&await R(a,t,r)}}return r.valid},W=(e,t)=>(e&&t&&H(b,e,t),!we(ae(),v)),$=(e,t,r)=>P(e,x,{...A.mount?b:y(t)?v:q(e)?{[e]:t}:t},r,t),I=(e,t,r={})=>{const s=p(h,e);let n=t;if(s){const r=s._f;r&&(!r.disabled&&H(b,e,Te(t,r)),n=se(r.ref)&&i(t)?"":t,ke(r.ref)?[...r.ref.options].forEach((e=>e.selected=n.includes(e.value))):r.refs?a(r.ref)?r.refs.length>1?r.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):r.refs[0]&&(r.refs[0].checked=!!n):r.refs.forEach((e=>e.checked=e.value===n)):te(r.ref)?r.ref.value="":(r.ref.value=n,r.ref.type||w.values.next({name:e,values:{...b}})))}(r.shouldDirty||r.shouldTouch)&&B(e,n,r.shouldTouch,r.shouldDirty,!0),r.shouldValidate&&Q(e)},z=(e,t,r)=>{for(const s in t){const a=t[s],i=`${e}.${s}`,u=p(h,i);!x.array.has(e)&&Se(a)&&(!u||u._f)||n(a)?I(i,a,r):z(i,a,r)}},G=(e,r,s={})=>{const a=p(h,e),n=x.array.has(e),o=f(r);H(b,e,o),n?(w.array.next({name:e,values:{...b}}),(S.isDirty||S.dirtyFields)&&s.shouldDirty&&w.state.next({name:e,dirtyFields:Ee(v,b),isDirty:W(e,o)})):!a||a._f||i(o)?I(e,o,s):z(e,o,s),Y(e,x)&&w.state.next({...u}),w.values.next({name:e,values:{...b}}),!A.mount&&t()},K=async e=>{const t=e.target;let a=t.name,n=!0;const i=p(h,a);if(i){let c,d;const f=t.type?Ue(i._f):l(e),m=e.type===g||e.type===_,y=!((o=i._f).mount&&(o.required||o.min||o.max||o.maxLength||o.minLength||o.pattern||o.validate)||s.resolver||p(u.errors,a)||i._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(m,p(u.touchedFields,a),u.isSubmitted,C,D),v=Y(a,x,m);H(b,a,f),m?(i._f.onBlur&&i._f.onBlur(e),r&&r(0)):i._f.onChange&&i._f.onChange(e);const A=B(a,f,m,!1),V=!U(A)||v;if(!m&&w.values.next({name:a,type:e.type,values:{...b}}),y)return S.isValid&&O(),V&&w.state.next({name:a,...v?{}:A});if(!m&&v&&w.state.next({...u}),E(!0),s.resolver){const{errors:e}=await N([a]),t=Le(u.errors,h,a),r=Le(e,h,t.name||a);c=r.error,a=r.name,d=U(e)}else c=(await ye(i,b,j,s.shouldUseNativeValidation))[a],n=f===p(b,a,f),n&&(c?d=!1:S.isValid&&(d=await R(h,!0)));n&&(i._f.deps&&Q(i._f.deps),M(a,d,c,A))}var o},Q=async(e,t={})=>{let r,a;const n=L(e);if(E(!0),s.resolver){const t=await(async e=>{const{errors:t}=await N();if(e)for(const r of e){const e=p(t,r);e?H(u.errors,r,e):xe(u.errors,r)}else u.errors=t;return t})(y(e)?e:n);r=U(t),a=e?!n.some((e=>p(t,e))):r}else e?(a=(await Promise.all(n.map((async e=>{const t=p(h,e);return await R(t&&t._f?{[e]:t}:t)})))).every(Boolean),(a||u.isValid)&&O()):a=r=await R(h);return w.state.next({...!q(e)||S.isValid&&r!==u.isValid?{}:{name:e},...s.resolver||!e?{isValid:r}:{},errors:u.errors,isValidating:!1}),t.shouldFocus&&!a&&J(h,(e=>e&&p(u.errors,e)),e?n:x.mount),a},ae=e=>{const t={...v,...A.mount?b:{}};return y(e)?t:q(e)?p(t,e):e.map((e=>p(t,e)))},ie=(e,t)=>({invalid:!!p((t||u).errors,e),isDirty:!!p((t||u).dirtyFields,e),isTouched:!!p((t||u).touchedFields,e),error:p((t||u).errors,e)}),ue=(e,t={})=>{for(const r of e?L(e):x.mount)x.mount.delete(r),x.array.delete(r),p(h,r)&&(t.keepValue||(xe(h,r),xe(b,r)),!t.keepError&&xe(u.errors,r),!t.keepDirty&&xe(u.dirtyFields,r),!t.keepTouched&&xe(u.touchedFields,r),!s.shouldUnregister&&!t.keepDefaultValue&&xe(v,r));w.values.next({values:{...b}}),w.state.next({...u,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&O()},oe=(e,t={})=>{let r=p(h,e);const n=ee(t.disabled);return H(h,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),x.mount.add(e),r?n&&H(b,e,t.disabled?void 0:p(b,e,Ue(r._f))):T(e,!0,t.value),{...n?{disabled:t.disabled}:{},...s.shouldUseNativeValidation?{required:!!t.required,min:Be(t.min),max:Be(t.max),minLength:Be(t.minLength),maxLength:Be(t.maxLength),pattern:Be(t.pattern)}:{},name:e,onChange:K,onBlur:K,ref:n=>{if(n){oe(e,t),r=p(h,e);const s=y(n.value)&&n.querySelectorAll&&n.querySelectorAll("input,select,textarea")[0]||n,i=(e=>ne(e)||a(e))(s),u=r._f.refs||[];if(i?u.find((e=>e===s)):s===r._f.ref)return;H(h,e,{_f:{...r._f,...i?{refs:[...u.filter(De),s,...Array.isArray(p(v,e))?[{}]:[]],ref:{type:s.type,name:e}}:{ref:s}}}),T(e,!1,void 0,s)}else r=p(h,e,{}),r._f&&(r._f.mount=!1),(s.shouldUnregister||t.shouldUnregister)&&(!c(x.array,e)||!A.action)&&x.unMount.add(e)}}},le=()=>s.shouldFocusError&&J(h,(e=>e&&p(u.errors,e)),x.mount),ce=(r,s={})=>{const a=r||v,n=f(a),i=r&&!U(r)?n:v;if(s.keepDefaultValues||(v=a),!s.keepValues){if(s.keepDirtyValues||k)for(const e of x.mount)p(u.dirtyFields,e)?H(i,e,p(b,e)):G(e,p(i,e));else{if(d&&y(r))for(const e of x.mount){const t=p(h,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(se(e)){const t=e.closest("form");if(t){t.reset();break}}}}h={}}b=e.shouldUnregister?s.keepDefaultValues?f(v):{}:n,w.array.next({values:{...i}}),w.values.next({values:{...i}})}x={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!A.mount&&t(),A.mount=!S.isValid||!!s.keepIsValid,A.watch=!!e.shouldUnregister,w.state.next({submitCount:s.keepSubmitCount?u.submitCount:0,isDirty:s.keepDirty?u.isDirty:!(!s.keepDefaultValues||we(r,v)),isSubmitted:!!s.keepIsSubmitted&&u.isSubmitted,dirtyFields:s.keepDirtyValues?u.dirtyFields:s.keepDefaultValues&&r?Ee(v,r):{},touchedFields:s.keepTouched?u.touchedFields:{},errors:s.keepErrors?u.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(re(e)?e(b):e,t);return re(s.defaultValues)&&s.defaultValues().then((e=>{de(e,s.resetOptions),w.state.next({isLoading:!1})})),{control:{register:oe,unregister:ue,getFieldState:ie,_executeSchema:N,_getWatch:$,_getDirty:W,_updateValid:O,_removeUnmounted:()=>{for(const e of x.unMount){const t=p(h,e);t&&(t._f.refs?t._f.refs.every((e=>!De(e))):!De(t._f.ref))&&ue(e)}x.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(A.action=!0,n&&Array.isArray(p(h,e))){const t=r(p(h,e),s.argA,s.argB);a&&H(h,e,t)}if(n&&Array.isArray(p(u.errors,e))){const t=r(p(u.errors,e),s.argA,s.argB);a&&H(u.errors,e,t),((e,t)=>{!m(p(e,t)).length&&xe(e,t)})(u.errors,e)}if(S.touchedFields&&n&&Array.isArray(p(u.touchedFields,e))){const t=r(p(u.touchedFields,e),s.argA,s.argB);a&&H(u.touchedFields,e,t)}S.dirtyFields&&(u.dirtyFields=Ee(v,b)),w.state.next({name:e,isDirty:W(e,t),dirtyFields:u.dirtyFields,errors:u.errors,isValid:u.isValid})}else H(b,e,t)},_getFieldArray:t=>m(p(A.mount?b:v,t,e.shouldUnregister?p(v,t,[]):[])),_reset:ce,_updateFormState:e=>{u={...u,...e}},_subjects:w,_proxyFormState:S,get _fields(){return h},get _formValues(){return b},get _state(){return A},set _state(e){A=e},get _defaultValues(){return v},get _names(){return x},set _names(e){x=e},get _formState(){return u},set _formState(e){u=e},get _options(){return s},set _options(e){s={...s,...e}}},trigger:Q,register:oe,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=f(b);if(w.state.next({isSubmitting:!0}),s.resolver){const{errors:e,values:t}=await N();u.errors=e,a=t}else await R(h);xe(u.errors,"root"),U(u.errors)?(w.state.next({errors:{}}),await e(a,r)):(t&&await t({...u.errors},r),le(),setTimeout(le)),w.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:U(u.errors),submitCount:u.submitCount+1,errors:u.errors})},watch:(e,t)=>re(e)?w.values.subscribe({next:r=>e($(void 0,t),r)}):$(e,t,!0),setValue:G,getValues:ae,reset:de,resetField:(e,t={})=>{p(h,e)&&(y(t.defaultValue)?G(e,p(v,e)):(G(e,t.defaultValue),H(v,e,t.defaultValue)),t.keepTouched||xe(u.touchedFields,e),t.keepDirty||(xe(u.dirtyFields,e),u.isDirty=t.defaultValue?W(e,p(v,e)):W()),t.keepError||(xe(u.errors,e),S.isValid&&O()),w.state.next({...u}))},clearErrors:e=>{e&&L(e).forEach((e=>xe(u.errors,e))),w.state.next({errors:e?u.errors:{}})},unregister:ue,setError:(e,t,r)=>{const s=(p(h,e,{_f:{}})._f||{}).ref;H(u.errors,e,{...t,ref:s}),w.state.next({name:e,errors:u.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=p(h,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}e.Controller=e=>e.render(z(e)),e.FormProvider=e=>{const{children:t,...r}=e;return s.default.createElement(O.Provider,{value:r},t)},e.appendErrors=G,e.get=p,e.set=H,e.useController=z,e.useFieldArray=function(e){const t=E(),{control:r=t.control,name:a,keyName:n="id",shouldUnregister:i}=e,[u,o]=s.default.useState(r._getFieldArray(a)),l=s.default.useRef(r._getFieldArray(a).map(K)),c=s.default.useRef(u),d=s.default.useRef(a),m=s.default.useRef(!1);d.current=a,c.current=u,r._names.array.add(a),e.rules&&r.register(a,e.rules),N({next:({values:e,name:t})=>{if(t===d.current||!t){const t=p(e,d.current);Array.isArray(t)&&(o(t),l.current=t.map(K))}},subject:r._subjects.array});const y=s.default.useCallback((e=>{m.current=!0,r._updateFieldArray(a,e)}),[r,a]);return s.default.useEffect((()=>{if(r._state.action=!1,Y(a,r._names)&&r._subjects.state.next({...r._formState}),m.current&&(!X(r._options.mode).isOnSubmit||r._formState.isSubmitted))if(r._options.resolver)r._executeSchema([a]).then((e=>{const t=p(e.errors,a),s=p(r._formState.errors,a);(s?!t&&s.type:t&&t.type)&&(t?H(r._formState.errors,a,t):xe(r._formState.errors,a),r._subjects.state.next({errors:r._formState.errors}))}));else{const e=p(r._fields,a);e&&e._f&&ye(e,r._formValues,r._options.criteriaMode===V,r._options.shouldUseNativeValidation,!0).then((e=>!U(e)&&r._subjects.state.next({errors:Z(r._formState.errors,e,a)})))}r._subjects.values.next({name:a,values:{...r._formValues}}),r._names.focus&&J(r._fields,(e=>!!e&&e.startsWith(r._names.focus||""))),r._names.focus="",r._updateValid()}),[u,a,r]),s.default.useEffect((()=>(!p(r._formValues,a)&&r._updateFieldArray(a),()=>{(r._options.shouldUnregister||i)&&r.unregister(a)})),[a,r,n,i]),{swap:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);Ae(s,e,t),Ae(l.current,e,t),y(s),o(s),r._updateFieldArray(a,s,Ae,{argA:e,argB:t},!1)}),[y,a,r]),move:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);he(s,e,t),he(l.current,e,t),y(s),o(s),r._updateFieldArray(a,s,he,{argA:e,argB:t},!1)}),[y,a,r]),prepend:s.default.useCallback(((e,t)=>{const s=L(f(e)),n=ve(r._getFieldArray(a),s);r._names.focus=Q(a,0,t),l.current=ve(l.current,s.map(K)),y(n),o(n),r._updateFieldArray(a,n,ve,{argA:ge(e)})}),[y,a,r]),append:s.default.useCallback(((e,t)=>{const s=L(f(e)),n=pe(r._getFieldArray(a),s);r._names.focus=Q(a,n.length-1,t),l.current=pe(l.current,s.map(K)),y(n),o(n),r._updateFieldArray(a,n,pe,{argA:ge(e)})}),[y,a,r]),remove:s.default.useCallback((e=>{const t=be(r._getFieldArray(a),e);l.current=be(l.current,e),y(t),o(t),r._updateFieldArray(a,t,be,{argA:e})}),[y,a,r]),insert:s.default.useCallback(((e,t,s)=>{const n=L(f(t)),i=_e(r._getFieldArray(a),e,n);r._names.focus=Q(a,e,s),l.current=_e(l.current,e,n.map(K)),y(i),o(i),r._updateFieldArray(a,i,_e,{argA:e,argB:ge(t)})}),[y,a,r]),update:s.default.useCallback(((e,t)=>{const s=f(t),n=Ve(r._getFieldArray(a),e,s);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:K())),y(n),o([...n]),r._updateFieldArray(a,n,Ve,{argA:e,argB:s},!0,!1)}),[y,a,r]),replace:s.default.useCallback((e=>{const t=L(f(e));l.current=t.map(K),y([...t]),o([...t]),r._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[y,a,r]),fields:s.default.useMemo((()=>u.map(((e,t)=>({...e,[n]:l.current[t]||K()})))),[u,n])}},e.useForm=function(e={}){const t=s.default.useRef(),[r,a]=s.default.useState({isDirty:!1,isValidating:!1,isLoading:re(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:re(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ne(e,(()=>a((e=>({...e}))))),formState:r});const n=t.current.control;return n._options=e,N({subject:n._subjects.state,next:e=>{B(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),s.default.useEffect((()=>{e.values&&!we(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),s.default.useEffect((()=>{n._state.mount||(n._updateValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),t.current.formState=T(r,n),t.current},e.useFormContext=E,e.useFormState=R,e.useWatch=W,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.js.map

@@ -177,3 +177,3 @@ import { FieldValues } from './fields';

* type="button"
* onClick={() => update([{ name: "data" }, { name: "data" }])}
* onClick={() => replace([{ name: "data" }, { name: "data" }])}
* >

@@ -180,0 +180,0 @@ * Replace

@@ -20,3 +20,3 @@ import { FieldValues } from '../fields';

* Helper type for recursively constructing paths through a type.
* This obsucres the internal type param TraversedTypes from exported contract.
* This obscures the internal type param TraversedTypes from exported contract.
*

@@ -53,3 +53,3 @@ * See {@link Path}

* Helper type for recursively constructing paths through a type.
* This obsucres the internal type param TraversedTypes from exported contract.
* This obscures the internal type param TraversedTypes from exported contract.
*

@@ -56,0 +56,0 @@ * See {@link ArrayPath}

@@ -10,3 +10,3 @@ import { Message } from './errors';

};
export type ValidateResult = Message | boolean | undefined;
export type ValidateResult = Message | Message[] | boolean | undefined;
export type Validate<TFieldValue, TFormValues> = (value: TFieldValue, formValues: TFormValues) => ValidateResult | Promise<ValidateResult>;

@@ -13,0 +13,0 @@ export type RegisterOptions<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Partial<{

{
"name": "react-hook-form",
"description": "Performant, flexible and extensible forms library for React Hooks",
"version": "7.43.5",
"version": "7.43.6",
"main": "dist/index.cjs.js",

@@ -6,0 +6,0 @@ "module": "dist/index.esm.mjs",

@@ -72,2 +72,5 @@ <div align="center">

</a>
<a target="_blank" href='https://toss.im'>
<img width="94" src="https://images.opencollective.com/toss/3ed69b3/logo/256.png" />
</a>
<a target="_blank" href="https://graphcms.com">

@@ -74,0 +77,0 @@ <img width="94" src="https://avatars.githubusercontent.com/u/31031438" />

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc