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

react-hook-form

Package Overview
Dependencies
Maintainers
1
Versions
1037
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.54.2 to 7.55.0-next.0

dist/utils/omit.d.ts

2

dist/index.cjs.js

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

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

@@ -1,6 +0,7 @@

import { Control, FieldValues, FormState, InternalFieldName, ReadFormState } from '../types';
import { FieldValues, FormState, InternalFieldName, ReadFormState } from '../types';
declare const _default: <T extends FieldValues, K extends ReadFormState>(formStateData: Partial<FormState<T>> & {
name?: InternalFieldName;
}, _proxyFormState: K, updateFormState: Control<T>["_updateFormState"], isRoot?: boolean) => string | true | undefined;
values?: T;
}, _proxyFormState: K, updateFormState: (formState: Partial<FormState<T>>) => void, isRoot?: boolean) => string | true | undefined;
export default _default;
//# sourceMappingURL=shouldRenderFormState.d.ts.map

@@ -76,2 +76,3 @@ import React from 'react';

delayError: number;
control?: Omit<UseFormReturn<TFieldValues, TContext>, 'formState'>;
}>;

@@ -90,2 +91,4 @@ export type FieldNamesMarkedBoolean<TFieldValues extends FieldValues> = DeepMap<DeepPartial<TFieldValues>, boolean>;

[K in keyof FormStateProxy]: boolean | 'all';
} & {
values?: boolean;
};

@@ -283,2 +286,30 @@ export type FormState<TFieldValues extends FieldValues> = {

};
/**
* This method will allow you to subscribe to formState without component render
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/subscribe) • [Demo](https://codesandbox.io/s/subscribe)
*
* @param options - subscription options on which formState subscribe to
*
* @example
* ```tsx
const { subscribe } = useForm()
useEffect(() => {
subscribe({
formState: { isDirty: true },
callback: () => {}
})
})
* ```
*/
export type UseFromSubscribe<TFieldValues extends FieldValues> = (payload: {
name?: string;
formState?: Partial<ReadFormState>;
callback: (data: Partial<FormState<TFieldValues>> & {
values: TFieldValues;
}) => void;
exact?: boolean;
}) => () => void;
export type UseFormWatch<TFieldValues extends FieldValues> = {

@@ -556,9 +587,6 @@ /**

name?: InternalFieldName;
values?: TFieldValues;
type?: EventType;
}>;
export type Subjects<TFieldValues extends FieldValues = FieldValues> = {
values: Subject<{
name?: InternalFieldName;
type?: EventType;
values: FieldValues;
}>;
array: Subject<{

@@ -583,2 +611,11 @@ name?: InternalFieldName;

}>, shouldSetValue?: boolean, shouldUpdateFieldsAndErrors?: boolean) => void;
export type FromSubscribe<TFieldValues extends FieldValues> = (payload: {
name?: string;
formState?: Partial<ReadFormState>;
callback: (data: Partial<FormState<TFieldValues>> & {
values: TFieldValues;
}) => void;
exact?: boolean;
reRenderRoot?: boolean;
}) => () => void;
export type Control<TFieldValues extends FieldValues = FieldValues, TContext = any> = {

@@ -598,4 +635,3 @@ _subjects: Subjects<TFieldValues>;

_formState: FormState<TFieldValues>;
_updateValid: (shouldUpdateValid?: boolean) => void;
_updateFormState: (formState: Partial<FormState<TFieldValues>>) => void;
_setValid: (shouldUpdateValid?: boolean) => void;
_fields: FieldRefs;

@@ -606,6 +642,6 @@ _formValues: FieldValues;

_getWatch: WatchInternal<TFieldValues>;
_updateFieldArray: BatchFieldArrayUpdate;
_setFieldArray: BatchFieldArrayUpdate;
_getFieldArray: <TFieldArrayValues>(name: InternalFieldName) => Partial<TFieldArrayValues>[];
_setErrors: (errors: FieldErrors<TFieldValues>) => void;
_updateDisabledField: (props: {
_setDisabledField: (props: {
disabled?: boolean;

@@ -621,8 +657,9 @@ name: FieldName<any>;

})) => void;
_executeSchema: (names: InternalFieldName[]) => Promise<{
_runSchema: (names: InternalFieldName[]) => Promise<{
errors: FieldErrors;
}>;
_disableForm: (disabled?: boolean) => void;
_subscribe: FromSubscribe<TFieldValues>;
register: UseFormRegister<TFieldValues>;
handleSubmit: UseFormHandleSubmit<TFieldValues>;
_disableForm: (disabled?: boolean) => void;
unregister: UseFormUnregister<TFieldValues>;

@@ -653,2 +690,3 @@ getFieldState: UseFormGetFieldState<TFieldValues>;

setFocus: UseFormSetFocus<TFieldValues>;
subscribe: UseFromSubscribe<TFieldValues>;
};

@@ -655,0 +693,0 @@ export type UseFormStateProps<TFieldValues extends FieldValues> = Partial<{

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

@@ -75,30 +75,31 @@ "module": "dist/index.esm.mjs",

"devDependencies": {
"@eslint/compat": "^1.2.0",
"@microsoft/api-extractor": "^7.47.9",
"@eslint/compat": "^1.2.4",
"@microsoft/api-extractor": "^7.48.1",
"@rollup/plugin-commonjs": "^26.0.3",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-node-resolve": "^15.3.1",
"@rollup/plugin-terser": "^0.4.4",
"@swc/core": "^1.7.35",
"@swc/jest": "^0.2.36",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@types/jest": "^29.5.13",
"@types/react": "^19.0.0",
"@types/react-dom": "^18.3.0",
"@swc/core": "^1.10.1",
"@swc/jest": "^0.2.37",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/jest": "^29.5.14",
"@types/react": "^19.0.2",
"@types/react-dom": "^18.3.5",
"@types/testing-library__jest-dom": "^5.14.9",
"eslint": "^9.8.0",
"bundlewatch": "^0.3.3",
"cypress": "^13.15.0",
"cypress": "^13.17.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^3.5.0",
"eslint-plugin-cypress": "^3.6.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.1",
"husky": "^9.1.6",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fixed-jsdom": "^0.0.9",
"jest-preview": "^0.3.1",
"lint-staged": "^15.2.10",
"msw": "^2.4.10",
"lint-staged": "^15.2.11",
"msw": "^2.7.0",
"prettier": "3.3.2",

@@ -109,7 +110,7 @@ "react": "^19.0.0",

"rimraf": "^5.0.10",
"rollup": "^4.24.0",
"rollup": "^4.29.0",
"rollup-plugin-typescript2": "^0.36.0",
"tsd": "^0.31.2",
"typescript": "^5.7.2",
"typescript-eslint": "7.18.0",
"tsd": "^0.31.2",
"typescript": "^5.6.3",
"whatwg-fetch": "^3.6.20"

@@ -116,0 +117,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc