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

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.7 to 7.43.8

2

dist/index.cjs.js

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

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

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