react-hook-form
Advanced tools
Comparing version 7.43.2 to 7.43.3
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),r=e=>"checkbox"===e.type,s=e=>e instanceof Date,a=e=>null==e;const n=e=>"object"==typeof e;var i=e=>!a(e)&&!Array.isArray(e)&&n(e)&&!s(e),o=e=>i(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=e=>Array.isArray(e)?e.filter(Boolean):[],c=e=>void 0===e,d=(e,t,r)=>{if(!t||!i(e))return r;const s=l(t.split(/[,[\].]+?/)).reduce(((e,t)=>a(e)?e:e[t]),e);return c(s)||s===e?c(e[t])?r:e[t]:s};const f="blur",m="focusout",y="change",p="onBlur",g="onChange",h="onSubmit",_="onTouched",v="all",b="max",x="min",A="maxLength",V="minLength",F="pattern",S="required",w="validate",k=t.default.createContext(null),D=()=>t.default.useContext(k);var C=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==v&&(t._proxyFormState[a]=!s||v),r&&(r[a]=!0),e[a]}});return a},j=e=>i(e)&&!Object.keys(e).length,O=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return j(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||v)))},E=e=>Array.isArray(e)?e:[e],U=(e,t,r)=>r&&t?e===t:!e||!t||e===t||E(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function B(e){const r=t.default.useRef(e);r.current=e,t.default.useEffect((()=>{const t=!e.disabled&&r.current.subject.subscribe({next:r.current.next});return()=>{t&&t.unsubscribe()}}),[e.disabled])}function T(e){const r=D(),{control:s=r.control,disabled:a,name:n,exact:i}=e||{},[o,u]=t.default.useState(s._formState),l=t.default.useRef(!0),c=t.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=t.default.useRef(n);return d.current=n,B({disabled:a,next:e=>l.current&&U(d.current,e.name,i)&&O(e,c.current,s._updateFormState)&&u({...s._formState,...e}),subject:s._subjects.state}),t.default.useEffect((()=>{l.current=!0;const e=s._proxyFormState.isDirty&&s._getDirty();return e!==s._formState.isDirty&&s._subjects.state.next({isDirty:e}),c.current.isValid&&s._updateValid(!0),()=>{l.current=!1}}),[s]),C(o,s,c.current,!1)}var L=e=>"string"==typeof e,M=(e,t,r,s,a)=>L(e)?(s&&t.watch.add(e),d(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),d(r,e)))):(s&&(t.watchAll=!0),r),N="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function R(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(N&&(e instanceof Blob||e instanceof FileList)||!r&&!i(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return i(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=R(e[r]);else t=e}return t}function q(e){const r=D(),{control:s=r.control,name:a,defaultValue:n,disabled:i,exact:o}=e||{},u=t.default.useRef(a);u.current=a,B({disabled:i,subject:s._subjects.watch,next:e=>{U(u.current,e.name,o)&&c(R(M(u.current,s._names,e.values||s._formValues,!1,n)))}});const[l,c]=t.default.useState(s._getWatch(a,n));return t.default.useEffect((()=>s._removeUnmounted())),l}function P(e){const r=D(),{name:s,control:a=r.control,shouldUnregister:n}=e,i=u(a._names.array,s),l=q({control:a,name:s,defaultValue:d(a._formValues,s,d(a._defaultValues,s,e.defaultValue)),exact:!0}),c=T({control:a,name:s}),m=t.default.useRef(a.register(s,{...e.rules,value:l}));return t.default.useEffect((()=>{const e=(e,t)=>{const r=d(a._fields,e);r&&(r._f.mount=t)};return e(s,!0),()=>{const t=a._options.shouldUnregister||n;(i?t&&!a._stateFlags.action:t)?a.unregister(s):e(s,!1)}}),[s,a,i,n]),{field:{name:s,value:l,onChange:t.default.useCallback((e=>m.current.onChange({target:{value:o(e),name:s},type:y})),[s]),onBlur:t.default.useCallback((()=>m.current.onBlur({target:{value:d(a._formValues,s),name:s},type:f})),[s,a]),ref:e=>{const t=d(a._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:c,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!d(c.errors,s)},isDirty:{enumerable:!0,get:()=>!!d(c.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!d(c.touchedFields,s)},error:{enumerable:!0,get:()=>d(c.errors,s)}})}}var W=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},$=e=>/^\w*$/.test(e),I=e=>l(e.replace(/["|']|\]/g,"").split(/\.|\[/));function H(e,t,r){let s=-1;const a=$(t)?[t]:I(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])?{}:[]}e[t]=n,e=e[t]}return e}const z=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=d(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else i(s)&&z(s,t)}}};var G=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},J=(e,t,r={})=>r.shouldFocus||c(r.shouldFocus)?r.focusName||`${e}.${c(r.focusIndex)?t:r.focusIndex}.`:"",K=e=>({isOnSubmit:!e||e===h,isOnBlur:e===p,isOnChange:e===g,isOnAll:e===v,isOnTouch:e===_}),Q=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),X=(e,t,r)=>{const s=l(d(e,r));return H(s,"root",t[r]),H(e,r,s),e},Y=e=>"boolean"==typeof e,Z=e=>"file"===e.type,ee=e=>"function"==typeof e,te=e=>{if(!N)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},re=e=>L(e),se=e=>"radio"===e.type,ae=e=>e instanceof RegExp;const ne={value:!1,isValid:!1},ie={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?ie:{value:e[0].value,isValid:!0}:ie:ne}return ne};const ue={isValid:!1,value:null};var le=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),ue):ue;function ce(e,t,r="validate"){if(re(e)||Array.isArray(e)&&e.every(re)||Y(e)&&!e)return{type:r,message:re(e)?e:"",ref:t}}var de=e=>i(e)&&!ae(e)?e:{value:e,message:""},fe=async(e,t,s,n,o)=>{const{ref:u,refs:l,required:f,maxLength:m,minLength:y,min:p,max:g,pattern:h,validate:_,name:v,valueAsNumber:k,mount:D,disabled:C}=e._f,O=d(t,v);if(!D||C)return{};const E=l?l[0]:u,U=e=>{n&&E.reportValidity&&(E.setCustomValidity(Y(e)?"":e||""),E.reportValidity())},B={},T=se(u),M=r(u),N=T||M,R=(k||Z(u))&&c(u.value)&&c(O)||te(u)&&""===u.value||""===O||Array.isArray(O)&&!O.length,q=W.bind(null,v,s,B),P=(e,t,r,s=A,a=V)=>{const n=e?t:r;B[v]={type:e?s:a,message:n,ref:u,...q(e?s:a,n)}};if(o?!Array.isArray(O)||!O.length:f&&(!N&&(R||a(O))||Y(O)&&!O||M&&!oe(l).isValid||T&&!le(l).isValid)){const{value:e,message:t}=re(f)?{value:!!f,message:f}:de(f);if(e&&(B[v]={type:S,message:t,ref:E,...q(S,t)},!s))return U(t),B}if(!(R||a(p)&&a(g))){let e,t;const r=de(g),n=de(p);if(a(O)||isNaN(O)){const s=u.valueAsDate||new Date(O),a=e=>new Date((new Date).toDateString()+" "+e),i="time"==u.type,o="week"==u.type;L(r.value)&&O&&(e=i?a(O)>a(r.value):o?O>r.value:s>new Date(r.value)),L(n.value)&&O&&(t=i?a(O)<a(n.value):o?O<n.value:s<new Date(n.value))}else{const s=u.valueAsNumber||(O?+O:O);a(r.value)||(e=s>r.value),a(n.value)||(t=s<n.value)}if((e||t)&&(P(!!e,r.message,n.message,b,x),!s))return U(B[v].message),B}if((m||y)&&!R&&(L(O)||o&&Array.isArray(O))){const e=de(m),t=de(y),r=!a(e.value)&&O.length>e.value,n=!a(t.value)&&O.length<t.value;if((r||n)&&(P(r,e.message,t.message),!s))return U(B[v].message),B}if(h&&!R&&L(O)){const{value:e,message:t}=de(h);if(ae(e)&&!O.match(e)&&(B[v]={type:F,message:t,ref:u,...q(F,t)},!s))return U(t),B}if(_)if(ee(_)){const e=ce(await _(O,t),E);if(e&&(B[v]={...e,...q(w,e.message)},!s))return U(e.message),B}else if(i(_)){let e={};for(const r in _){if(!j(e)&&!s)break;const a=ce(await _[r](O,t),E,r);a&&(e={...a,...q(r,a.message)},U(a.message),s&&(B[v]=e))}if(!j(e)&&(B[v]={ref:E,...e},!s))return B}return U(!0),B};function me(e,t){return[...e,...E(t)]}var ye=e=>Array.isArray(e)?e.map((()=>{})):void 0;function pe(e,t,r){return[...e.slice(0,t),...E(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):[];function he(e,t){return[...E(t),...E(e)]}var _e=(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 l(s).length?s:[]}(e,E(t).sort(((e,t)=>e-t))),ve=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function be(e,t){const r=Array.isArray(t)?t:$(t)?[t]:I(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=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)&&j(s)||Array.isArray(s)&&function(e){for(const t in e)if(!c(e[t]))return!1;return!0}(s))&&be(e,r.slice(0,-1)),e}var xe=(e,t,r)=>(e[t]=r,e);function Ae(){let e=[];return{get observers(){return e},next:t=>{let r=0;const s=e.length;for(;r<s;)e[r].next(t),++r},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Ve=e=>a(e)||!n(e);function Fe(e,t){if(Ve(e)||Ve(t))return e===t;if(s(e)&&s(t))return e.getTime()===t.getTime();const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const n of r){const r=e[n];if(!a.includes(n))return!1;if("ref"!==n){const e=t[n];if(s(r)&&s(e)||i(r)&&i(e)||Array.isArray(r)&&Array.isArray(e)?!Fe(r,e):r!==e)return!1}}return!0}var Se=e=>"select-multiple"===e.type,we=e=>te(e)&&e.isConnected,ke=e=>{for(const t in e)if(ee(e[t]))return!0;return!1};function De(e,t={}){const r=Array.isArray(e);if(i(e)||r)for(const r in e)Array.isArray(e[r])||i(e[r])&&!ke(e[r])?(t[r]=Array.isArray(e[r])?[]:{},De(e[r],t[r])):a(e[r])||(t[r]=!0);return t}function Ce(e,t,r){const s=Array.isArray(e);if(i(e)||s)for(const s in e)Array.isArray(e[s])||i(e[s])&&!ke(e[s])?c(t)||Ve(r[s])?r[s]=Array.isArray(e[s])?De(e[s],[]):{...De(e[s])}:Ce(e[s],a(t)?{}:t[s],r[s]):Fe(e[s],t[s])?delete r[s]:r[s]=!0;return r}var je=(e,t)=>Ce(e,t,De(t)),Oe=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>c(e)?e:t?""===e?NaN:e?+e:e:r&&L(e)?new Date(e):s?s(e):e;function Ee(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return Z(t)?t.files:se(t)?le(e.refs).value:Se(t)?[...t.selectedOptions].map((({value:e})=>e)):r(t)?oe(e.refs).value:Oe(c(t.value)?e.ref.value:t.value,e)}var Ue=e=>c(e)?e:ae(e)?e.source:i(e)?ae(e.value)?e.value.source:e.value:e;function Be(e,t,r){const s=d(e,r);if(s||$(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=d(t,s),i=d(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Te={mode:h,reValidateMode:g,shouldFocusError:!0};function Le(e={},t){let n,y={...Te,...e},p={submitCount:0,isDirty:!1,isLoading:!0,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},g={},h=(i(y.defaultValues)||i(y.values))&&R(y.defaultValues||y.values)||{},_=y.shouldUnregister?{}:R(h),b={action:!1,mount:!1,watch:!1},x={mount:new Set,unMount:new Set,array:new Set,watch:new Set},A=0;const V=e.resetOptions&&e.resetOptions.keepDirtyValues,F={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},S={watch:Ae(),array:Ae(),state:Ae()},w=K(y.mode),k=K(y.reValidateMode),D=y.criteriaMode===v,C=async e=>{if(F.isValid||e){const e=y.resolver?j((await q()).errors):await P(g,!0);e!==p.isValid&&S.state.next({isValid:e})}},O=e=>F.isValidating&&S.state.next({isValidating:e}),U=(e,t,r,s)=>{const a=d(g,e);if(a){const n=d(_,e,c(r)?d(h,e):r);c(n)||s&&s.defaultChecked||t?H(_,e,t?n:Ee(a._f)):I(e,n),b.mount&&C()}},B=(e,t,r,s,a)=>{let n=!1,i=!1;const o={name:e};if(!r||s){F.isDirty&&(i=p.isDirty,p.isDirty=o.isDirty=W(),n=i!==o.isDirty);const r=Fe(d(h,e),t);i=d(p.dirtyFields,e),r?be(p.dirtyFields,e):H(p.dirtyFields,e,!0),o.dirtyFields=p.dirtyFields,n=n||F.dirtyFields&&i!==!r}if(r){const t=d(p.touchedFields,e);t||(H(p.touchedFields,e,r),o.touchedFields=p.touchedFields,n=n||F.touchedFields&&t!==r)}return n&&a&&S.state.next(o),n?o:{}},T=(t,r,s,a)=>{const i=d(p.errors,t),o=F.isValid&&Y(r)&&p.isValid!==r;var u;if(e.delayError&&s?(u=()=>((e,t)=>{H(p.errors,e,t),S.state.next({errors:p.errors})})(t,s),n=e=>{clearTimeout(A),A=setTimeout(u,e)},n(e.delayError)):(clearTimeout(A),n=null,s?H(p.errors,t,s):be(p.errors,t)),(s?!Fe(i,s):i)||!j(a)||o){const e={...a,...o&&Y(r)?{isValid:r}:{},errors:p.errors,name:t};p={...p,...e},S.state.next(e)}O(!1)},q=async e=>await y.resolver(_,y.context,((e,t,r,s)=>{const a={};for(const r of e){const e=d(t,r);e&&H(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||x.mount,g,y.criteriaMode,y.shouldUseNativeValidation)),P=async(e,t,r={valid:!0})=>{for(const s in e){const a=e[s];if(a){const{_f:e,...s}=a;if(e){const s=x.array.has(e.name),n=await fe(a,_,D,y.shouldUseNativeValidation,s);if(n[e.name]&&(r.valid=!1,t))break;!t&&(d(n,e.name)?s?X(p.errors,n,e.name):H(p.errors,e.name,n[e.name]):be(p.errors,e.name))}s&&await P(s,t,r)}}return r.valid},W=(e,t)=>(e&&t&&H(_,e,t),!Fe(ne(),h)),$=(e,t,r)=>M(e,x,{...b.mount?_:c(t)?h:L(e)?{[e]:t}:t},r,t),I=(e,t,s={})=>{const n=d(g,e);let i=t;if(n){const s=n._f;s&&(!s.disabled&&H(_,e,Oe(t,s)),i=te(s.ref)&&a(t)?"":t,Se(s.ref)?[...s.ref.options].forEach((e=>e.selected=i.includes(e.value))):s.refs?r(s.ref)?s.refs.length>1?s.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(i)?!!i.find((t=>t===e.value)):i===e.value))):s.refs[0]&&(s.refs[0].checked=!!i):s.refs.forEach((e=>e.checked=e.value===i)):Z(s.ref)?s.ref.value="":(s.ref.value=i,s.ref.type||S.watch.next({name:e})))}(s.shouldDirty||s.shouldTouch)&&B(e,i,s.shouldTouch,s.shouldDirty,!0),s.shouldValidate&&ae(e)},G=(e,t,r)=>{for(const a in t){const n=t[a],i=`${e}.${a}`,o=d(g,i);!x.array.has(e)&&Ve(n)&&(!o||o._f)||s(n)?I(i,n,r):G(i,n,r)}},J=(e,r,s={})=>{const n=d(g,e),i=x.array.has(e),o=R(r);H(_,e,o),i?(S.array.next({name:e,values:_}),(F.isDirty||F.dirtyFields)&&s.shouldDirty&&S.state.next({name:e,dirtyFields:je(h,_),isDirty:W(e,o)})):!n||n._f||a(o)?I(e,o,s):G(e,o,s),Q(e,x)&&S.state.next({}),S.watch.next({name:e}),!b.mount&&t()},re=async e=>{const t=e.target;let r=t.name;const s=d(g,r);if(s){let i,u;const l=t.type?Ee(s._f):o(e),c=e.type===f||e.type===m,h=!((a=s._f).mount&&(a.required||a.min||a.max||a.maxLength||a.minLength||a.pattern||a.validate)||y.resolver||d(p.errors,r)||s._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(c,d(p.touchedFields,r),p.isSubmitted,k,w),v=Q(r,x,c);H(_,r,l),c?(s._f.onBlur&&s._f.onBlur(e),n&&n(0)):s._f.onChange&&s._f.onChange(e);const b=B(r,l,c,!1),A=!j(b)||v;if(!c&&S.watch.next({name:r,type:e.type}),h)return F.isValid&&C(),A&&S.state.next({name:r,...v?{}:b});if(!c&&v&&S.state.next({}),O(!0),y.resolver){const{errors:e}=await q([r]),t=Be(p.errors,g,r),s=Be(e,g,t.name||r);i=s.error,r=s.name,u=j(e)}else i=(await fe(s,_,D,y.shouldUseNativeValidation))[r],i?u=!1:F.isValid&&(u=await P(g,!0));s._f.deps&&ae(s._f.deps),T(r,u,i,b)}var a},ae=async(e,t={})=>{let r,s;const a=E(e);if(O(!0),y.resolver){const t=await(async e=>{const{errors:t}=await q();if(e)for(const r of e){const e=d(t,r);e?H(p.errors,r,e):be(p.errors,r)}else p.errors=t;return t})(c(e)?e:a);r=j(t),s=e?!a.some((e=>d(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=d(g,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||p.isValid)&&C()):s=r=await P(g);return S.state.next({...!L(e)||F.isValid&&r!==p.isValid?{}:{name:e},...y.resolver||!e?{isValid:r}:{},errors:p.errors,isValidating:!1}),t.shouldFocus&&!s&&z(g,(e=>e&&d(p.errors,e)),e?a:x.mount),s},ne=e=>{const t={...h,...b.mount?_:{}};return c(e)?t:L(e)?d(t,e):e.map((e=>d(t,e)))},ie=(e,t)=>({invalid:!!d((t||p).errors,e),isDirty:!!d((t||p).dirtyFields,e),isTouched:!!d((t||p).touchedFields,e),error:d((t||p).errors,e)}),oe=(e,t={})=>{for(const r of e?E(e):x.mount)x.mount.delete(r),x.array.delete(r),d(g,r)&&(t.keepValue||(be(g,r),be(_,r)),!t.keepError&&be(p.errors,r),!t.keepDirty&&be(p.dirtyFields,r),!t.keepTouched&&be(p.touchedFields,r),!y.shouldUnregister&&!t.keepDefaultValue&&be(h,r));S.watch.next({}),S.state.next({...p,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&C()},ue=(e,t={})=>{let s=d(g,e);const a=Y(t.disabled);return H(g,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...t}}),x.mount.add(e),s?a&&H(_,e,t.disabled?void 0:d(_,e,Ee(s._f))):U(e,!0,t.value),{...a?{disabled:t.disabled}:{},...y.shouldUseNativeValidation?{required:!!t.required,min:Ue(t.min),max:Ue(t.max),minLength:Ue(t.minLength),maxLength:Ue(t.maxLength),pattern:Ue(t.pattern)}:{},name:e,onChange:re,onBlur:re,ref:a=>{if(a){ue(e,t),s=d(g,e);const n=c(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,i=(e=>se(e)||r(e))(n),o=s._f.refs||[];if(i?o.find((e=>e===n)):n===s._f.ref)return;H(g,e,{_f:{...s._f,...i?{refs:[...o.filter(we),n,...Array.isArray(d(h,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),U(e,!1,void 0,n)}else s=d(g,e,{}),s._f&&(s._f.mount=!1),(y.shouldUnregister||t.shouldUnregister)&&(!u(x.array,e)||!b.action)&&x.unMount.add(e)}}},le=()=>y.shouldFocusError&&z(g,(e=>e&&d(p.errors,e)),x.mount),ce=(r,s={})=>{const a=r||h,n=R(a),i=r&&!j(r)?n:h;if(s.keepDefaultValues||(h=a),!s.keepValues){if(s.keepDirtyValues||V)for(const e of x.mount)d(p.dirtyFields,e)?H(i,e,d(_,e)):J(e,d(i,e));else{if(N&&c(r))for(const e of x.mount){const t=d(g,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(te(e)){const t=e.closest("form");if(t){t.reset();break}}}}g={}}_=e.shouldUnregister?s.keepDefaultValues?R(h):{}:n,S.array.next({values:i}),S.watch.next({values:i})}x={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!b.mount&&t(),b.mount=!F.isValid||!!s.keepIsValid,b.watch=!!e.shouldUnregister,S.state.next({submitCount:s.keepSubmitCount?p.submitCount:0,isDirty:s.keepDirty?p.isDirty:!(!s.keepDefaultValues||Fe(r,h)),isSubmitted:!!s.keepIsSubmitted&&p.isSubmitted,dirtyFields:s.keepDirtyValues?p.dirtyFields:s.keepDefaultValues&&r?je(h,r):{},touchedFields:s.keepTouched?p.touchedFields:{},errors:s.keepErrors?p.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(ee(e)?e(_):e,t);return ee(y.defaultValues)&&y.defaultValues().then((e=>{de(e,y.resetOptions),S.state.next({isLoading:!1})})),{control:{register:ue,unregister:oe,getFieldState:ie,_executeSchema:q,_getWatch:$,_getDirty:W,_updateValid:C,_removeUnmounted:()=>{for(const e of x.unMount){const t=d(g,e);t&&(t._f.refs?t._f.refs.every((e=>!we(e))):!we(t._f.ref))&&oe(e)}x.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(b.action=!0,n&&Array.isArray(d(g,e))){const t=r(d(g,e),s.argA,s.argB);a&&H(g,e,t)}if(n&&Array.isArray(d(p.errors,e))){const t=r(d(p.errors,e),s.argA,s.argB);a&&H(p.errors,e,t),((e,t)=>{!l(d(e,t)).length&&be(e,t)})(p.errors,e)}if(F.touchedFields&&n&&Array.isArray(d(p.touchedFields,e))){const t=r(d(p.touchedFields,e),s.argA,s.argB);a&&H(p.touchedFields,e,t)}F.dirtyFields&&(p.dirtyFields=je(h,_)),S.state.next({name:e,isDirty:W(e,t),dirtyFields:p.dirtyFields,errors:p.errors,isValid:p.isValid})}else H(_,e,t)},_getFieldArray:t=>l(d(b.mount?_:h,t,e.shouldUnregister?d(h,t,[]):[])),_reset:ce,_updateFormState:e=>{p={...p,...e}},_subjects:S,_proxyFormState:F,get _fields(){return g},get _formValues(){return _},get _stateFlags(){return b},set _stateFlags(e){b=e},get _defaultValues(){return h},get _names(){return x},set _names(e){x=e},get _formState(){return p},set _formState(e){p=e},get _options(){return y},set _options(e){y={...y,...e}}},trigger:ae,register:ue,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let s=R(_);if(S.state.next({isSubmitting:!0}),y.resolver){const{errors:e,values:t}=await q();p.errors=e,s=t}else await P(g);be(p.errors,"root"),j(p.errors)?(S.state.next({errors:{}}),await e(s,r)):(t&&await t({...p.errors},r),le(),setTimeout(le)),S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:j(p.errors),submitCount:p.submitCount+1,errors:p.errors})},watch:(e,t)=>ee(e)?S.watch.subscribe({next:r=>e($(void 0,t),r)}):$(e,t,!0),setValue:J,getValues:ne,reset:de,resetField:(e,t={})=>{d(g,e)&&(c(t.defaultValue)?J(e,d(h,e)):(J(e,t.defaultValue),H(h,e,t.defaultValue)),t.keepTouched||be(p.touchedFields,e),t.keepDirty||(be(p.dirtyFields,e),p.isDirty=t.defaultValue?W(e,d(h,e)):W()),t.keepError||(be(p.errors,e),F.isValid&&C()),S.state.next({...p}))},clearErrors:e=>{e&&E(e).forEach((e=>be(p.errors,e))),S.state.next({errors:e?p.errors:{}})},unregister:oe,setError:(e,t,r)=>{const s=(d(g,e,{_f:{}})._f||{}).ref;H(p.errors,e,{...t,ref:s}),S.state.next({name:e,errors:p.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=d(g,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}exports.Controller=e=>e.render(P(e)),exports.FormProvider=e=>{const{children:r,...s}=e;return t.default.createElement(k.Provider,{value:s},r)},exports.appendErrors=W,exports.get=d,exports.set=H,exports.useController=P,exports.useFieldArray=function(e){const r=D(),{control:s=r.control,name:a,keyName:n="id",shouldUnregister:i}=e,[o,u]=t.default.useState(s._getFieldArray(a)),l=t.default.useRef(s._getFieldArray(a).map(G)),c=t.default.useRef(o),f=t.default.useRef(a),m=t.default.useRef(!1);f.current=a,c.current=o,s._names.array.add(a),e.rules&&s.register(a,e.rules),B({next:({values:e,name:t})=>{if(t===f.current||!t){const t=d(e,f.current);Array.isArray(t)&&(u(t),l.current=t.map(G))}},subject:s._subjects.array});const y=t.default.useCallback((e=>{m.current=!0,s._updateFieldArray(a,e)}),[s,a]);return t.default.useEffect((()=>{if(s._stateFlags.action=!1,Q(a,s._names)&&s._subjects.state.next({}),m.current&&(!K(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._executeSchema([a]).then((e=>{const t=d(e.errors,a),r=d(s._formState.errors,a);(r?!t&&r.type:t&&t.type)&&(t?H(s._formState.errors,a,t):be(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=d(s._fields,a);e&&e._f&&fe(e,s._formValues,s._options.criteriaMode===v,s._options.shouldUseNativeValidation,!0).then((e=>!j(e)&&s._subjects.state.next({errors:X(s._formState.errors,e,a)})))}s._subjects.watch.next({name:a,values:s._formValues}),s._names.focus&&z(s._fields,(e=>!!e&&e.startsWith(s._names.focus||""))),s._names.focus="",s._updateValid()}),[o,a,s]),t.default.useEffect((()=>(!d(s._formValues,a)&&s._updateFieldArray(a),()=>{(s._options.shouldUnregister||i)&&s.unregister(a)})),[a,s,n,i]),{swap:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);ve(r,e,t),ve(l.current,e,t),y(r),u(r),s._updateFieldArray(a,r,ve,{argA:e,argB:t},!1)}),[y,a,s]),move:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);ge(r,e,t),ge(l.current,e,t),y(r),u(r),s._updateFieldArray(a,r,ge,{argA:e,argB:t},!1)}),[y,a,s]),prepend:t.default.useCallback(((e,t)=>{const r=E(R(e)),n=he(s._getFieldArray(a),r);s._names.focus=J(a,0,t),l.current=he(l.current,r.map(G)),y(n),u(n),s._updateFieldArray(a,n,he,{argA:ye(e)})}),[y,a,s]),append:t.default.useCallback(((e,t)=>{const r=E(R(e)),n=me(s._getFieldArray(a),r);s._names.focus=J(a,n.length-1,t),l.current=me(l.current,r.map(G)),y(n),u(n),s._updateFieldArray(a,n,me,{argA:ye(e)})}),[y,a,s]),remove:t.default.useCallback((e=>{const t=_e(s._getFieldArray(a),e);l.current=_e(l.current,e),y(t),u(t),s._updateFieldArray(a,t,_e,{argA:e})}),[y,a,s]),insert:t.default.useCallback(((e,t,r)=>{const n=E(R(t)),i=pe(s._getFieldArray(a),e,n);s._names.focus=J(a,e,r),l.current=pe(l.current,e,n.map(G)),y(i),u(i),s._updateFieldArray(a,i,pe,{argA:e,argB:ye(t)})}),[y,a,s]),update:t.default.useCallback(((e,t)=>{const r=R(t),n=xe(s._getFieldArray(a),e,r);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:G())),y(n),u([...n]),s._updateFieldArray(a,n,xe,{argA:e,argB:r},!0,!1)}),[y,a,s]),replace:t.default.useCallback((e=>{const t=E(R(e));l.current=t.map(G),y([...t]),u([...t]),s._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[y,a,s]),fields:t.default.useMemo((()=>o.map(((e,t)=>({...e,[n]:l.current[t]||G()})))),[o,n])}},exports.useForm=function(e={}){const r=t.default.useRef(),[s,a]=t.default.useState({isDirty:!1,isValidating:!1,isLoading:!0,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:ee(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...Le(e,(()=>a((e=>({...e}))))),formState:s});const n=r.current.control;return n._options=e,B({subject:n._subjects.state,next:e=>{O(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),t.default.useEffect((()=>{n._stateFlags.mount||(n._updateValid(),n._stateFlags.mount=!0),n._stateFlags.watch&&(n._stateFlags.watch=!1,n._subjects.state.next({})),n._removeUnmounted()})),t.default.useEffect((()=>{e.values&&!Fe(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),r.current.formState=C(s,n),r.current},exports.useFormContext=D,exports.useFormState=T,exports.useWatch=q; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),r=e=>"checkbox"===e.type,s=e=>e instanceof Date,a=e=>null==e;const n=e=>"object"==typeof e;var i=e=>!a(e)&&!Array.isArray(e)&&n(e)&&!s(e),u=e=>i(e)&&e.target?r(e.target)?e.target.checked:e.target.value:e,o=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),l=e=>Array.isArray(e)?e.filter(Boolean):[],c=e=>void 0===e,d=(e,t,r)=>{if(!t||!i(e))return r;const s=l(t.split(/[,[\].]+?/)).reduce(((e,t)=>a(e)?e:e[t]),e);return c(s)||s===e?c(e[t])?r:e[t]:s};const f="blur",m="focusout",y="change",p="onBlur",g="onChange",_="onSubmit",h="onTouched",v="all",b="max",x="min",A="maxLength",V="minLength",F="pattern",S="required",w="validate",k=t.default.createContext(null),D=()=>t.default.useContext(k);var C=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==v&&(t._proxyFormState[a]=!s||v),r&&(r[a]=!0),e[a]}});return a},j=e=>i(e)&&!Object.keys(e).length,O=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return j(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||v)))},E=e=>Array.isArray(e)?e:[e],U=(e,t,r)=>r&&t?e===t:!e||!t||e===t||E(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function B(e){const r=t.default.useRef(e);r.current=e,t.default.useEffect((()=>{const t=!e.disabled&&r.current.subject.subscribe({next:r.current.next});return()=>{t&&t.unsubscribe()}}),[e.disabled])}function T(e){const r=D(),{control:s=r.control,disabled:a,name:n,exact:i}=e||{},[u,o]=t.default.useState(s._formState),l=t.default.useRef(!0),c=t.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=t.default.useRef(n);return d.current=n,B({disabled:a,next:e=>l.current&&U(d.current,e.name,i)&&O(e,c.current,s._updateFormState)&&o({...s._formState,...e}),subject:s._subjects.state}),t.default.useEffect((()=>{l.current=!0;const e=s._proxyFormState.isDirty&&s._getDirty();return e!==s._formState.isDirty&&s._subjects.state.next({isDirty:e}),c.current.isValid&&s._updateValid(!0),()=>{l.current=!1}}),[s]),C(u,s,c.current,!1)}var L=e=>"string"==typeof e,M=(e,t,r,s,a)=>L(e)?(s&&t.watch.add(e),d(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),d(r,e)))):(s&&(t.watchAll=!0),r),N="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function R(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(N&&(e instanceof Blob||e instanceof FileList)||!r&&!i(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return i(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=R(e[r]);else t=e}return t}function q(e){const r=D(),{control:s=r.control,name:a,defaultValue:n,disabled:i,exact:u}=e||{},o=t.default.useRef(a);o.current=a,B({disabled:i,subject:s._subjects.values,next:e=>{U(o.current,e.name,u)&&c(R(M(o.current,s._names,e.values||s._formValues,!1,n)))}});const[l,c]=t.default.useState(s._getWatch(a,n));return t.default.useEffect((()=>s._removeUnmounted())),l}function P(e){const r=D(),{name:s,control:a=r.control,shouldUnregister:n}=e,i=o(a._names.array,s),l=q({control:a,name:s,defaultValue:d(a._formValues,s,d(a._defaultValues,s,e.defaultValue)),exact:!0}),c=T({control:a,name:s}),m=t.default.useRef(a.register(s,{...e.rules,value:l}));return t.default.useEffect((()=>{const e=(e,t)=>{const r=d(a._fields,e);r&&(r._f.mount=t)};return e(s,!0),()=>{const t=a._options.shouldUnregister||n;(i?t&&!a._stateFlags.action:t)?a.unregister(s):e(s,!1)}}),[s,a,i,n]),{field:{name:s,value:l,onChange:t.default.useCallback((e=>m.current.onChange({target:{value:u(e),name:s},type:y})),[s]),onBlur:t.default.useCallback((()=>m.current.onBlur({target:{value:d(a._formValues,s),name:s},type:f})),[s,a]),ref:e=>{const t=d(a._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:c,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!d(c.errors,s)},isDirty:{enumerable:!0,get:()=>!!d(c.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!d(c.touchedFields,s)},error:{enumerable:!0,get:()=>d(c.errors,s)}})}}var W=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},$=e=>/^\w*$/.test(e),I=e=>l(e.replace(/["|']|\]/g,"").split(/\.|\[/));function H(e,t,r){let s=-1;const a=$(t)?[t]:I(t),n=a.length,u=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==u){const r=e[t];n=i(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}e[t]=n,e=e[t]}return e}const z=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=d(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else i(s)&&z(s,t)}}};var G=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},J=(e,t,r={})=>r.shouldFocus||c(r.shouldFocus)?r.focusName||`${e}.${c(r.focusIndex)?t:r.focusIndex}.`:"",K=e=>({isOnSubmit:!e||e===_,isOnBlur:e===p,isOnChange:e===g,isOnAll:e===v,isOnTouch:e===h}),Q=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),X=(e,t,r)=>{const s=l(d(e,r));return H(s,"root",t[r]),H(e,r,s),e},Y=e=>"boolean"==typeof e,Z=e=>"file"===e.type,ee=e=>"function"==typeof e,te=e=>{if(!N)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},re=e=>L(e),se=e=>"radio"===e.type,ae=e=>e instanceof RegExp;const ne={value:!1,isValid:!1},ie={value:!0,isValid:!0};var ue=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!c(e[0].attributes.value)?c(e[0].value)||""===e[0].value?ie:{value:e[0].value,isValid:!0}:ie:ne}return ne};const oe={isValid:!1,value:null};var le=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),oe):oe;function ce(e,t,r="validate"){if(re(e)||Array.isArray(e)&&e.every(re)||Y(e)&&!e)return{type:r,message:re(e)?e:"",ref:t}}var de=e=>i(e)&&!ae(e)?e:{value:e,message:""},fe=async(e,t,s,n,u)=>{const{ref:o,refs:l,required:f,maxLength:m,minLength:y,min:p,max:g,pattern:_,validate:h,name:v,valueAsNumber:k,mount:D,disabled:C}=e._f,O=d(t,v);if(!D||C)return{};const E=l?l[0]:o,U=e=>{n&&E.reportValidity&&(E.setCustomValidity(Y(e)?"":e||""),E.reportValidity())},B={},T=se(o),M=r(o),N=T||M,R=(k||Z(o))&&c(o.value)&&c(O)||te(o)&&""===o.value||""===O||Array.isArray(O)&&!O.length,q=W.bind(null,v,s,B),P=(e,t,r,s=A,a=V)=>{const n=e?t:r;B[v]={type:e?s:a,message:n,ref:o,...q(e?s:a,n)}};if(u?!Array.isArray(O)||!O.length:f&&(!N&&(R||a(O))||Y(O)&&!O||M&&!ue(l).isValid||T&&!le(l).isValid)){const{value:e,message:t}=re(f)?{value:!!f,message:f}:de(f);if(e&&(B[v]={type:S,message:t,ref:E,...q(S,t)},!s))return U(t),B}if(!(R||a(p)&&a(g))){let e,t;const r=de(g),n=de(p);if(a(O)||isNaN(O)){const s=o.valueAsDate||new Date(O),a=e=>new Date((new Date).toDateString()+" "+e),i="time"==o.type,u="week"==o.type;L(r.value)&&O&&(e=i?a(O)>a(r.value):u?O>r.value:s>new Date(r.value)),L(n.value)&&O&&(t=i?a(O)<a(n.value):u?O<n.value:s<new Date(n.value))}else{const s=o.valueAsNumber||(O?+O:O);a(r.value)||(e=s>r.value),a(n.value)||(t=s<n.value)}if((e||t)&&(P(!!e,r.message,n.message,b,x),!s))return U(B[v].message),B}if((m||y)&&!R&&(L(O)||u&&Array.isArray(O))){const e=de(m),t=de(y),r=!a(e.value)&&O.length>e.value,n=!a(t.value)&&O.length<t.value;if((r||n)&&(P(r,e.message,t.message),!s))return U(B[v].message),B}if(_&&!R&&L(O)){const{value:e,message:t}=de(_);if(ae(e)&&!O.match(e)&&(B[v]={type:F,message:t,ref:o,...q(F,t)},!s))return U(t),B}if(h)if(ee(h)){const e=ce(await h(O,t),E);if(e&&(B[v]={...e,...q(w,e.message)},!s))return U(e.message),B}else if(i(h)){let e={};for(const r in h){if(!j(e)&&!s)break;const a=ce(await h[r](O,t),E,r);a&&(e={...a,...q(r,a.message)},U(a.message),s&&(B[v]=e))}if(!j(e)&&(B[v]={ref:E,...e},!s))return B}return U(!0),B};function me(e,t){return[...e,...E(t)]}var ye=e=>Array.isArray(e)?e.map((()=>{})):void 0;function pe(e,t,r){return[...e.slice(0,t),...E(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):[];function _e(e,t){return[...E(t),...E(e)]}var he=(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 l(s).length?s:[]}(e,E(t).sort(((e,t)=>e-t))),ve=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function be(e,t){const r=Array.isArray(t)?t:$(t)?[t]:I(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=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)&&j(s)||Array.isArray(s)&&function(e){for(const t in e)if(!c(e[t]))return!1;return!0}(s))&&be(e,r.slice(0,-1)),e}var xe=(e,t,r)=>(e[t]=r,e);function Ae(){let e=[];return{get observers(){return e},next:t=>{let r=0;const s=e.length;for(;r<s;)e[r].next(t),++r},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Ve=e=>a(e)||!n(e);function Fe(e,t){if(Ve(e)||Ve(t))return e===t;if(s(e)&&s(t))return e.getTime()===t.getTime();const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const n of r){const r=e[n];if(!a.includes(n))return!1;if("ref"!==n){const e=t[n];if(s(r)&&s(e)||i(r)&&i(e)||Array.isArray(r)&&Array.isArray(e)?!Fe(r,e):r!==e)return!1}}return!0}var Se=e=>"select-multiple"===e.type,we=e=>te(e)&&e.isConnected,ke=e=>{for(const t in e)if(ee(e[t]))return!0;return!1};function De(e,t={}){const r=Array.isArray(e);if(i(e)||r)for(const r in e)Array.isArray(e[r])||i(e[r])&&!ke(e[r])?(t[r]=Array.isArray(e[r])?[]:{},De(e[r],t[r])):a(e[r])||(t[r]=!0);return t}function Ce(e,t,r){const s=Array.isArray(e);if(i(e)||s)for(const s in e)Array.isArray(e[s])||i(e[s])&&!ke(e[s])?c(t)||Ve(r[s])?r[s]=Array.isArray(e[s])?De(e[s],[]):{...De(e[s])}:Ce(e[s],a(t)?{}:t[s],r[s]):r[s]=!Fe(e[s],t[s]);return r}var je=(e,t)=>Ce(e,t,De(t)),Oe=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>c(e)?e:t?""===e?NaN:e?+e:e:r&&L(e)?new Date(e):s?s(e):e;function Ee(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return Z(t)?t.files:se(t)?le(e.refs).value:Se(t)?[...t.selectedOptions].map((({value:e})=>e)):r(t)?ue(e.refs).value:Oe(c(t.value)?e.ref.value:t.value,e)}var Ue=e=>c(e)?e:ae(e)?e.source:i(e)?ae(e.value)?e.value.source:e.value:e;function Be(e,t,r){const s=d(e,r);if(s||$(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=d(t,s),i=d(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Te={mode:_,reValidateMode:g,shouldFocusError:!0};function Le(e={},t){let n,y={...Te,...e},p={submitCount:0,isDirty:!1,isLoading:!0,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},g={},_=(i(y.defaultValues)||i(y.values))&&R(y.defaultValues||y.values)||{},h=y.shouldUnregister?{}:R(_),b={action:!1,mount:!1,watch:!1},x={mount:new Set,unMount:new Set,array:new Set,watch:new Set},A=0;const V=e.resetOptions&&e.resetOptions.keepDirtyValues,F={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},S={values:Ae(),array:Ae(),state:Ae()},w=K(y.mode),k=K(y.reValidateMode),D=y.criteriaMode===v,C=async e=>{if(F.isValid||e){const e=y.resolver?j((await q()).errors):await P(g,!0);e!==p.isValid&&S.state.next({isValid:e})}},O=e=>F.isValidating&&S.state.next({isValidating:e}),U=(e,t,r,s)=>{const a=d(g,e);if(a){const n=d(h,e,c(r)?d(_,e):r);c(n)||s&&s.defaultChecked||t?H(h,e,t?n:Ee(a._f)):I(e,n),b.mount&&C()}},B=(e,t,r,s,a)=>{let n=!1,i=!1;const u={name:e};if(!r||s){F.isDirty&&(i=p.isDirty,p.isDirty=u.isDirty=W(),n=i!==u.isDirty);const r=Fe(d(_,e),t);i=d(p.dirtyFields,e),r?be(p.dirtyFields,e):H(p.dirtyFields,e,!0),u.dirtyFields=p.dirtyFields,n=n||F.dirtyFields&&i!==!r}if(r){const t=d(p.touchedFields,e);t||(H(p.touchedFields,e,r),u.touchedFields=p.touchedFields,n=n||F.touchedFields&&t!==r)}return n&&a&&S.state.next(u),n?u:{}},T=(t,r,s,a)=>{const i=d(p.errors,t),u=F.isValid&&Y(r)&&p.isValid!==r;var o;if(e.delayError&&s?(o=()=>((e,t)=>{H(p.errors,e,t),S.state.next({errors:p.errors})})(t,s),n=e=>{clearTimeout(A),A=setTimeout(o,e)},n(e.delayError)):(clearTimeout(A),n=null,s?H(p.errors,t,s):be(p.errors,t)),(s?!Fe(i,s):i)||!j(a)||u){const e={...a,...u&&Y(r)?{isValid:r}:{},errors:p.errors,name:t};p={...p,...e},S.state.next(e)}O(!1)},q=async e=>await y.resolver(h,y.context,((e,t,r,s)=>{const a={};for(const r of e){const e=d(t,r);e&&H(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||x.mount,g,y.criteriaMode,y.shouldUseNativeValidation)),P=async(e,t,r={valid:!0})=>{for(const s in e){const a=e[s];if(a){const{_f:e,...s}=a;if(e){const s=x.array.has(e.name),n=await fe(a,h,D,y.shouldUseNativeValidation,s);if(n[e.name]&&(r.valid=!1,t))break;!t&&(d(n,e.name)?s?X(p.errors,n,e.name):H(p.errors,e.name,n[e.name]):be(p.errors,e.name))}s&&await P(s,t,r)}}return r.valid},W=(e,t)=>(e&&t&&H(h,e,t),!Fe(ne(),_)),$=(e,t,r)=>M(e,x,{...b.mount?h:c(t)?_:L(e)?{[e]:t}:t},r,t),I=(e,t,s={})=>{const n=d(g,e);let i=t;if(n){const s=n._f;s&&(!s.disabled&&H(h,e,Oe(t,s)),i=te(s.ref)&&a(t)?"":t,Se(s.ref)?[...s.ref.options].forEach((e=>e.selected=i.includes(e.value))):s.refs?r(s.ref)?s.refs.length>1?s.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(i)?!!i.find((t=>t===e.value)):i===e.value))):s.refs[0]&&(s.refs[0].checked=!!i):s.refs.forEach((e=>e.checked=e.value===i)):Z(s.ref)?s.ref.value="":(s.ref.value=i,s.ref.type||S.values.next({name:e,values:{...h}})))}(s.shouldDirty||s.shouldTouch)&&B(e,i,s.shouldTouch,s.shouldDirty,!0),s.shouldValidate&&ae(e)},G=(e,t,r)=>{for(const a in t){const n=t[a],i=`${e}.${a}`,u=d(g,i);!x.array.has(e)&&Ve(n)&&(!u||u._f)||s(n)?I(i,n,r):G(i,n,r)}},J=(e,r,s={})=>{const n=d(g,e),i=x.array.has(e),u=R(r);H(h,e,u),i?(S.array.next({name:e,values:{...h}}),(F.isDirty||F.dirtyFields)&&s.shouldDirty&&S.state.next({name:e,dirtyFields:je(_,h),isDirty:W(e,u)})):!n||n._f||a(u)?I(e,u,s):G(e,u,s),Q(e,x)&&S.state.next({...p}),S.values.next({name:e,values:{...h}}),!b.mount&&t()},re=async e=>{const t=e.target;let r=t.name;const s=d(g,r);if(s){let i,o;const l=t.type?Ee(s._f):u(e),c=e.type===f||e.type===m,_=!((a=s._f).mount&&(a.required||a.min||a.max||a.maxLength||a.minLength||a.pattern||a.validate)||y.resolver||d(p.errors,r)||s._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(c,d(p.touchedFields,r),p.isSubmitted,k,w),v=Q(r,x,c);H(h,r,l),c?(s._f.onBlur&&s._f.onBlur(e),n&&n(0)):s._f.onChange&&s._f.onChange(e);const b=B(r,l,c,!1),A=!j(b)||v;if(!c&&S.values.next({name:r,type:e.type,values:{...h}}),_)return F.isValid&&C(),A&&S.state.next({name:r,...v?{}:b});if(!c&&v&&S.state.next({...p}),O(!0),y.resolver){const{errors:e}=await q([r]),t=Be(p.errors,g,r),s=Be(e,g,t.name||r);i=s.error,r=s.name,o=j(e)}else i=(await fe(s,h,D,y.shouldUseNativeValidation))[r],i?o=!1:F.isValid&&(o=await P(g,!0));s._f.deps&&ae(s._f.deps),T(r,o,i,b)}var a},ae=async(e,t={})=>{let r,s;const a=E(e);if(O(!0),y.resolver){const t=await(async e=>{const{errors:t}=await q();if(e)for(const r of e){const e=d(t,r);e?H(p.errors,r,e):be(p.errors,r)}else p.errors=t;return t})(c(e)?e:a);r=j(t),s=e?!a.some((e=>d(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=d(g,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||p.isValid)&&C()):s=r=await P(g);return S.state.next({...!L(e)||F.isValid&&r!==p.isValid?{}:{name:e},...y.resolver||!e?{isValid:r}:{},errors:p.errors,isValidating:!1}),t.shouldFocus&&!s&&z(g,(e=>e&&d(p.errors,e)),e?a:x.mount),s},ne=e=>{const t={..._,...b.mount?h:{}};return c(e)?t:L(e)?d(t,e):e.map((e=>d(t,e)))},ie=(e,t)=>({invalid:!!d((t||p).errors,e),isDirty:!!d((t||p).dirtyFields,e),isTouched:!!d((t||p).touchedFields,e),error:d((t||p).errors,e)}),ue=(e,t={})=>{for(const r of e?E(e):x.mount)x.mount.delete(r),x.array.delete(r),d(g,r)&&(t.keepValue||(be(g,r),be(h,r)),!t.keepError&&be(p.errors,r),!t.keepDirty&&be(p.dirtyFields,r),!t.keepTouched&&be(p.touchedFields,r),!y.shouldUnregister&&!t.keepDefaultValue&&be(_,r));S.values.next({values:{...h}}),S.state.next({...p,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&C()},oe=(e,t={})=>{let s=d(g,e);const a=Y(t.disabled);return H(g,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...t}}),x.mount.add(e),s?a&&H(h,e,t.disabled?void 0:d(h,e,Ee(s._f))):U(e,!0,t.value),{...a?{disabled:t.disabled}:{},...y.shouldUseNativeValidation?{required:!!t.required,min:Ue(t.min),max:Ue(t.max),minLength:Ue(t.minLength),maxLength:Ue(t.maxLength),pattern:Ue(t.pattern)}:{},name:e,onChange:re,onBlur:re,ref:a=>{if(a){oe(e,t),s=d(g,e);const n=c(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,i=(e=>se(e)||r(e))(n),u=s._f.refs||[];if(i?u.find((e=>e===n)):n===s._f.ref)return;H(g,e,{_f:{...s._f,...i?{refs:[...u.filter(we),n,...Array.isArray(d(_,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),U(e,!1,void 0,n)}else s=d(g,e,{}),s._f&&(s._f.mount=!1),(y.shouldUnregister||t.shouldUnregister)&&(!o(x.array,e)||!b.action)&&x.unMount.add(e)}}},le=()=>y.shouldFocusError&&z(g,(e=>e&&d(p.errors,e)),x.mount),ce=(r,s={})=>{const a=r||_,n=R(a),i=r&&!j(r)?n:_;if(s.keepDefaultValues||(_=a),!s.keepValues){if(s.keepDirtyValues||V)for(const e of x.mount)d(p.dirtyFields,e)?H(i,e,d(h,e)):J(e,d(i,e));else{if(N&&c(r))for(const e of x.mount){const t=d(g,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(te(e)){const t=e.closest("form");if(t){t.reset();break}}}}g={}}h=e.shouldUnregister?s.keepDefaultValues?R(_):{}:n,S.array.next({values:i}),S.values.next({values:i})}x={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!b.mount&&t(),b.mount=!F.isValid||!!s.keepIsValid,b.watch=!!e.shouldUnregister,S.state.next({submitCount:s.keepSubmitCount?p.submitCount:0,isDirty:s.keepDirty?p.isDirty:!(!s.keepDefaultValues||Fe(r,_)),isSubmitted:!!s.keepIsSubmitted&&p.isSubmitted,dirtyFields:s.keepDirtyValues?p.dirtyFields:s.keepDefaultValues&&r?je(_,r):{},touchedFields:s.keepTouched?p.touchedFields:{},errors:s.keepErrors?p.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(ee(e)?e(h):e,t);return ee(y.defaultValues)&&y.defaultValues().then((e=>{de(e,y.resetOptions),S.state.next({isLoading:!1})})),{control:{register:oe,unregister:ue,getFieldState:ie,_executeSchema:q,_getWatch:$,_getDirty:W,_updateValid:C,_removeUnmounted:()=>{for(const e of x.unMount){const t=d(g,e);t&&(t._f.refs?t._f.refs.every((e=>!we(e))):!we(t._f.ref))&&ue(e)}x.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(b.action=!0,n&&Array.isArray(d(g,e))){const t=r(d(g,e),s.argA,s.argB);a&&H(g,e,t)}if(n&&Array.isArray(d(p.errors,e))){const t=r(d(p.errors,e),s.argA,s.argB);a&&H(p.errors,e,t),((e,t)=>{!l(d(e,t)).length&&be(e,t)})(p.errors,e)}if(F.touchedFields&&n&&Array.isArray(d(p.touchedFields,e))){const t=r(d(p.touchedFields,e),s.argA,s.argB);a&&H(p.touchedFields,e,t)}F.dirtyFields&&(p.dirtyFields=je(_,h)),S.state.next({name:e,isDirty:W(e,t),dirtyFields:p.dirtyFields,errors:p.errors,isValid:p.isValid})}else H(h,e,t)},_getFieldArray:t=>l(d(b.mount?h:_,t,e.shouldUnregister?d(_,t,[]):[])),_reset:ce,_updateFormState:e=>{p={...p,...e}},_subjects:S,_proxyFormState:F,get _fields(){return g},get _formValues(){return h},get _stateFlags(){return b},set _stateFlags(e){b=e},get _defaultValues(){return _},get _names(){return x},set _names(e){x=e},get _formState(){return p},set _formState(e){p=e},get _options(){return y},set _options(e){y={...y,...e}}},trigger:ae,register:oe,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let s=R(h);if(S.state.next({isSubmitting:!0}),y.resolver){const{errors:e,values:t}=await q();p.errors=e,s=t}else await P(g);be(p.errors,"root"),j(p.errors)?(S.state.next({errors:{}}),await e(s,r)):(t&&await t({...p.errors},r),le(),setTimeout(le)),S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:j(p.errors),submitCount:p.submitCount+1,errors:p.errors})},watch:(e,t)=>ee(e)?S.values.subscribe({next:r=>e($(void 0,t),r)}):$(e,t,!0),setValue:J,getValues:ne,reset:de,resetField:(e,t={})=>{d(g,e)&&(c(t.defaultValue)?J(e,d(_,e)):(J(e,t.defaultValue),H(_,e,t.defaultValue)),t.keepTouched||be(p.touchedFields,e),t.keepDirty||(be(p.dirtyFields,e),p.isDirty=t.defaultValue?W(e,d(_,e)):W()),t.keepError||(be(p.errors,e),F.isValid&&C()),S.state.next({...p}))},clearErrors:e=>{e&&E(e).forEach((e=>be(p.errors,e))),S.state.next({errors:e?p.errors:{}})},unregister:ue,setError:(e,t,r)=>{const s=(d(g,e,{_f:{}})._f||{}).ref;H(p.errors,e,{...t,ref:s}),S.state.next({name:e,errors:p.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=d(g,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}exports.Controller=e=>e.render(P(e)),exports.FormProvider=e=>{const{children:r,...s}=e;return t.default.createElement(k.Provider,{value:s},r)},exports.appendErrors=W,exports.get=d,exports.set=H,exports.useController=P,exports.useFieldArray=function(e){const r=D(),{control:s=r.control,name:a,keyName:n="id",shouldUnregister:i}=e,[u,o]=t.default.useState(s._getFieldArray(a)),l=t.default.useRef(s._getFieldArray(a).map(G)),c=t.default.useRef(u),f=t.default.useRef(a),m=t.default.useRef(!1);f.current=a,c.current=u,s._names.array.add(a),e.rules&&s.register(a,e.rules),B({next:({values:e,name:t})=>{if(t===f.current||!t){const t=d(e,f.current);Array.isArray(t)&&(o(t),l.current=t.map(G))}},subject:s._subjects.array});const y=t.default.useCallback((e=>{m.current=!0,s._updateFieldArray(a,e)}),[s,a]);return t.default.useEffect((()=>{if(s._stateFlags.action=!1,Q(a,s._names)&&s._subjects.state.next({...s._formState}),m.current&&(!K(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._executeSchema([a]).then((e=>{const t=d(e.errors,a),r=d(s._formState.errors,a);(r?!t&&r.type:t&&t.type)&&(t?H(s._formState.errors,a,t):be(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=d(s._fields,a);e&&e._f&&fe(e,s._formValues,s._options.criteriaMode===v,s._options.shouldUseNativeValidation,!0).then((e=>!j(e)&&s._subjects.state.next({errors:X(s._formState.errors,e,a)})))}s._subjects.values.next({name:a,values:s._formValues}),s._names.focus&&z(s._fields,(e=>!!e&&e.startsWith(s._names.focus||""))),s._names.focus="",s._updateValid()}),[u,a,s]),t.default.useEffect((()=>(!d(s._formValues,a)&&s._updateFieldArray(a),()=>{(s._options.shouldUnregister||i)&&s.unregister(a)})),[a,s,n,i]),{swap:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);ve(r,e,t),ve(l.current,e,t),y(r),o(r),s._updateFieldArray(a,r,ve,{argA:e,argB:t},!1)}),[y,a,s]),move:t.default.useCallback(((e,t)=>{const r=s._getFieldArray(a);ge(r,e,t),ge(l.current,e,t),y(r),o(r),s._updateFieldArray(a,r,ge,{argA:e,argB:t},!1)}),[y,a,s]),prepend:t.default.useCallback(((e,t)=>{const r=E(R(e)),n=_e(s._getFieldArray(a),r);s._names.focus=J(a,0,t),l.current=_e(l.current,r.map(G)),y(n),o(n),s._updateFieldArray(a,n,_e,{argA:ye(e)})}),[y,a,s]),append:t.default.useCallback(((e,t)=>{const r=E(R(e)),n=me(s._getFieldArray(a),r);s._names.focus=J(a,n.length-1,t),l.current=me(l.current,r.map(G)),y(n),o(n),s._updateFieldArray(a,n,me,{argA:ye(e)})}),[y,a,s]),remove:t.default.useCallback((e=>{const t=he(s._getFieldArray(a),e);l.current=he(l.current,e),y(t),o(t),s._updateFieldArray(a,t,he,{argA:e})}),[y,a,s]),insert:t.default.useCallback(((e,t,r)=>{const n=E(R(t)),i=pe(s._getFieldArray(a),e,n);s._names.focus=J(a,e,r),l.current=pe(l.current,e,n.map(G)),y(i),o(i),s._updateFieldArray(a,i,pe,{argA:e,argB:ye(t)})}),[y,a,s]),update:t.default.useCallback(((e,t)=>{const r=R(t),n=xe(s._getFieldArray(a),e,r);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:G())),y(n),o([...n]),s._updateFieldArray(a,n,xe,{argA:e,argB:r},!0,!1)}),[y,a,s]),replace:t.default.useCallback((e=>{const t=E(R(e));l.current=t.map(G),y([...t]),o([...t]),s._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[y,a,s]),fields:t.default.useMemo((()=>u.map(((e,t)=>({...e,[n]:l.current[t]||G()})))),[u,n])}},exports.useForm=function(e={}){const r=t.default.useRef(),[s,a]=t.default.useState({isDirty:!1,isValidating:!1,isLoading:!0,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:ee(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...Le(e,(()=>a((e=>({...e}))))),formState:s});const n=r.current.control;return n._options=e,B({subject:n._subjects.state,next:e=>{O(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),t.default.useEffect((()=>{e.values&&!Fe(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),t.default.useEffect((()=>{n._stateFlags.mount||(n._updateValid(),n._stateFlags.mount=!0),n._stateFlags.watch&&(n._stateFlags.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),r.current.formState=C(s,n),r.current},exports.useFormContext=D,exports.useFormState=T,exports.useWatch=q; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactHookForm={},e.React)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=r(t),a=e=>"checkbox"===e.type,n=e=>e instanceof Date,i=e=>null==e;const o=e=>"object"==typeof e;var u=e=>!i(e)&&!Array.isArray(e)&&o(e)&&!n(e),l=e=>u(e)&&e.target?a(e.target)?e.target.checked:e.target.value:e,c=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),d=e=>Array.isArray(e)?e.filter(Boolean):[],f=e=>void 0===e,m=(e,t,r)=>{if(!t||!u(e))return r;const s=d(t.split(/[,[\].]+?/)).reduce(((e,t)=>i(e)?e:e[t]),e);return f(s)||s===e?f(e[t])?r:e[t]:s};const y="blur",g="focusout",h="change",p="onBlur",_="onChange",v="onSubmit",b="onTouched",A="all",x="max",V="min",F="maxLength",S="minLength",w="pattern",k="required",D="validate",C=s.default.createContext(null),j=()=>s.default.useContext(C);var O=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==A&&(t._proxyFormState[a]=!s||A),r&&(r[a]=!0),e[a]}});return a},E=e=>u(e)&&!Object.keys(e).length,T=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return E(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||A)))},U=e=>Array.isArray(e)?e:[e],B=(e,t,r)=>r&&t?e===t:!e||!t||e===t||U(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function L(e){const t=s.default.useRef(e);t.current=e,s.default.useEffect((()=>{const r=!e.disabled&&t.current.subject.subscribe({next:t.current.next});return()=>{r&&r.unsubscribe()}}),[e.disabled])}function M(e){const t=j(),{control:r=t.control,disabled:a,name:n,exact:i}=e||{},[o,u]=s.default.useState(r._formState),l=s.default.useRef(!0),c=s.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=s.default.useRef(n);return d.current=n,L({disabled:a,next:e=>l.current&&B(d.current,e.name,i)&&T(e,c.current,r._updateFormState)&&u({...r._formState,...e}),subject:r._subjects.state}),s.default.useEffect((()=>{l.current=!0;const e=r._proxyFormState.isDirty&&r._getDirty();return e!==r._formState.isDirty&&r._subjects.state.next({isDirty:e}),c.current.isValid&&r._updateValid(!0),()=>{l.current=!1}}),[r]),O(o,r,c.current,!1)}var N=e=>"string"==typeof e,R=(e,t,r,s,a)=>N(e)?(s&&t.watch.add(e),m(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),m(r,e)))):(s&&(t.watchAll=!0),r),q="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function P(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(q&&(e instanceof Blob||e instanceof FileList)||!r&&!u(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return u(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=P(e[r]);else t=e}return t}function W(e){const t=j(),{control:r=t.control,name:a,defaultValue:n,disabled:i,exact:o}=e||{},u=s.default.useRef(a);u.current=a,L({disabled:i,subject:r._subjects.watch,next:e=>{B(u.current,e.name,o)&&c(P(R(u.current,r._names,e.values||r._formValues,!1,n)))}});const[l,c]=s.default.useState(r._getWatch(a,n));return s.default.useEffect((()=>r._removeUnmounted())),l}function $(e){const t=j(),{name:r,control:a=t.control,shouldUnregister:n}=e,i=c(a._names.array,r),o=W({control:a,name:r,defaultValue:m(a._formValues,r,m(a._defaultValues,r,e.defaultValue)),exact:!0}),u=M({control:a,name:r}),d=s.default.useRef(a.register(r,{...e.rules,value:o}));return s.default.useEffect((()=>{const e=(e,t)=>{const r=m(a._fields,e);r&&(r._f.mount=t)};return e(r,!0),()=>{const t=a._options.shouldUnregister||n;(i?t&&!a._stateFlags.action:t)?a.unregister(r):e(r,!1)}}),[r,a,i,n]),{field:{name:r,value:o,onChange:s.default.useCallback((e=>d.current.onChange({target:{value:l(e),name:r},type:h})),[r]),onBlur:s.default.useCallback((()=>d.current.onBlur({target:{value:m(a._formValues,r),name:r},type:y})),[r,a]),ref:e=>{const t=m(a._fields,r);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:u,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!m(u.errors,r)},isDirty:{enumerable:!0,get:()=>!!m(u.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!m(u.touchedFields,r)},error:{enumerable:!0,get:()=>m(u.errors,r)}})}}var I=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},H=e=>/^\w*$/.test(e),z=e=>d(e.replace(/["|']|\]/g,"").split(/\.|\[/));function G(e,t,r){let s=-1;const a=H(t)?[t]:z(t),n=a.length,i=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==i){const r=e[t];n=u(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}e[t]=n,e=e[t]}return e}const J=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=m(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else u(s)&&J(s,t)}}};var K=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},Q=(e,t,r={})=>r.shouldFocus||f(r.shouldFocus)?r.focusName||`${e}.${f(r.focusIndex)?t:r.focusIndex}.`:"",X=e=>({isOnSubmit:!e||e===v,isOnBlur:e===p,isOnChange:e===_,isOnAll:e===A,isOnTouch:e===b}),Y=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),Z=(e,t,r)=>{const s=d(m(e,r));return G(s,"root",t[r]),G(e,r,s),e},ee=e=>"boolean"==typeof e,te=e=>"file"===e.type,re=e=>"function"==typeof e,se=e=>{if(!q)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ae=e=>N(e),ne=e=>"radio"===e.type,ie=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 ce={isValid:!1,value:null};var de=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),ce):ce;function fe(e,t,r="validate"){if(ae(e)||Array.isArray(e)&&e.every(ae)||ee(e)&&!e)return{type:r,message:ae(e)?e:"",ref:t}}var me=e=>u(e)&&!ie(e)?e:{value:e,message:""},ye=async(e,t,r,s,n)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:y,min:g,max:h,pattern:p,validate:_,name:v,valueAsNumber:b,mount:A,disabled:C}=e._f,j=m(t,v);if(!A||C)return{};const O=l?l[0]:o,T=e=>{s&&O.reportValidity&&(O.setCustomValidity(ee(e)?"":e||""),O.reportValidity())},U={},B=ne(o),L=a(o),M=B||L,R=(b||te(o))&&f(o.value)&&f(j)||se(o)&&""===o.value||""===j||Array.isArray(j)&&!j.length,q=I.bind(null,v,r,U),P=(e,t,r,s=F,a=S)=>{const n=e?t:r;U[v]={type:e?s:a,message:n,ref:o,...q(e?s:a,n)}};if(n?!Array.isArray(j)||!j.length:c&&(!M&&(R||i(j))||ee(j)&&!j||L&&!le(l).isValid||B&&!de(l).isValid)){const{value:e,message:t}=ae(c)?{value:!!c,message:c}:me(c);if(e&&(U[v]={type:k,message:t,ref:O,...q(k,t)},!r))return T(t),U}if(!(R||i(g)&&i(h))){let e,t;const s=me(h),a=me(g);if(i(j)||isNaN(j)){const r=o.valueAsDate||new Date(j),n=e=>new Date((new Date).toDateString()+" "+e),i="time"==o.type,u="week"==o.type;N(s.value)&&j&&(e=i?n(j)>n(s.value):u?j>s.value:r>new Date(s.value)),N(a.value)&&j&&(t=i?n(j)<n(a.value):u?j<a.value:r<new Date(a.value))}else{const r=o.valueAsNumber||(j?+j:j);i(s.value)||(e=r>s.value),i(a.value)||(t=r<a.value)}if((e||t)&&(P(!!e,s.message,a.message,x,V),!r))return T(U[v].message),U}if((d||y)&&!R&&(N(j)||n&&Array.isArray(j))){const e=me(d),t=me(y),s=!i(e.value)&&j.length>e.value,a=!i(t.value)&&j.length<t.value;if((s||a)&&(P(s,e.message,t.message),!r))return T(U[v].message),U}if(p&&!R&&N(j)){const{value:e,message:t}=me(p);if(ie(e)&&!j.match(e)&&(U[v]={type:w,message:t,ref:o,...q(w,t)},!r))return T(t),U}if(_)if(re(_)){const e=fe(await _(j,t),O);if(e&&(U[v]={...e,...q(D,e.message)},!r))return T(e.message),U}else if(u(_)){let e={};for(const s in _){if(!E(e)&&!r)break;const a=fe(await _[s](j,t),O,s);a&&(e={...a,...q(s,a.message)},T(a.message),r&&(U[v]=e))}if(!E(e)&&(U[v]={ref:O,...e},!r))return U}return T(!0),U};function ge(e,t){return[...e,...U(t)]}var he=e=>Array.isArray(e)?e.map((()=>{})):void 0;function pe(e,t,r){return[...e.slice(0,t),...U(r),...e.slice(t)]}var _e=(e,t,r)=>Array.isArray(e)?(f(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[];function ve(e,t){return[...U(t),...U(e)]}var be=(e,t)=>f(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return d(s).length?s:[]}(e,U(t).sort(((e,t)=>e-t))),Ae=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function xe(e,t){const r=Array.isArray(t)?t:H(t)?[t]:z(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=f(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(u(s)&&E(s)||Array.isArray(s)&&function(e){for(const t in e)if(!f(e[t]))return!1;return!0}(s))&&xe(e,r.slice(0,-1)),e}var Ve=(e,t,r)=>(e[t]=r,e);function Fe(){let e=[];return{get observers(){return e},next:t=>{let r=0;const s=e.length;for(;r<s;)e[r].next(t),++r},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Se=e=>i(e)||!o(e);function we(e,t){if(Se(e)||Se(t))return e===t;if(n(e)&&n(t))return e.getTime()===t.getTime();const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(const a of r){const r=e[a];if(!s.includes(a))return!1;if("ref"!==a){const e=t[a];if(n(r)&&n(e)||u(r)&&u(e)||Array.isArray(r)&&Array.isArray(e)?!we(r,e):r!==e)return!1}}return!0}var ke=e=>"select-multiple"===e.type,De=e=>se(e)&&e.isConnected,Ce=e=>{for(const t in e)if(re(e[t]))return!0;return!1};function je(e,t={}){const r=Array.isArray(e);if(u(e)||r)for(const r in e)Array.isArray(e[r])||u(e[r])&&!Ce(e[r])?(t[r]=Array.isArray(e[r])?[]:{},je(e[r],t[r])):i(e[r])||(t[r]=!0);return t}function Oe(e,t,r){const s=Array.isArray(e);if(u(e)||s)for(const s in e)Array.isArray(e[s])||u(e[s])&&!Ce(e[s])?f(t)||Se(r[s])?r[s]=Array.isArray(e[s])?je(e[s],[]):{...je(e[s])}:Oe(e[s],i(t)?{}:t[s],r[s]):we(e[s],t[s])?delete r[s]:r[s]=!0;return r}var Ee=(e,t)=>Oe(e,t,je(t)),Te=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>f(e)?e:t?""===e?NaN:e?+e:e:r&&N(e)?new Date(e):s?s(e):e;function Ue(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return te(t)?t.files:ne(t)?de(e.refs).value:ke(t)?[...t.selectedOptions].map((({value:e})=>e)):a(t)?le(e.refs).value:Te(f(t.value)?e.ref.value:t.value,e)}var Be=e=>f(e)?e:ie(e)?e.source:u(e)?ie(e.value)?e.value.source:e.value:e;function Le(e,t,r){const s=m(e,r);if(s||H(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=m(t,s),i=m(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Me={mode:v,reValidateMode:_,shouldFocusError:!0};function Ne(e={},t){let r,s={...Me,...e},o={submitCount:0,isDirty:!1,isLoading:!0,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},h={},p=(u(s.defaultValues)||u(s.values))&&P(s.defaultValues||s.values)||{},_=s.shouldUnregister?{}:P(p),v={action:!1,mount:!1,watch:!1},b={mount:new Set,unMount:new Set,array:new Set,watch:new Set},x=0;const V=e.resetOptions&&e.resetOptions.keepDirtyValues,F={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},S={watch:Fe(),array:Fe(),state:Fe()},w=X(s.mode),k=X(s.reValidateMode),D=s.criteriaMode===A,C=async e=>{if(F.isValid||e){const e=s.resolver?E((await L()).errors):await M(h,!0);e!==o.isValid&&S.state.next({isValid:e})}},j=e=>F.isValidating&&S.state.next({isValidating:e}),O=(e,t,r,s)=>{const a=m(h,e);if(a){const n=m(_,e,f(r)?m(p,e):r);f(n)||s&&s.defaultChecked||t?G(_,e,t?n:Ue(a._f)):I(e,n),v.mount&&C()}},T=(e,t,r,s,a)=>{let n=!1,i=!1;const u={name:e};if(!r||s){F.isDirty&&(i=o.isDirty,o.isDirty=u.isDirty=W(),n=i!==u.isDirty);const r=we(m(p,e),t);i=m(o.dirtyFields,e),r?xe(o.dirtyFields,e):G(o.dirtyFields,e,!0),u.dirtyFields=o.dirtyFields,n=n||F.dirtyFields&&i!==!r}if(r){const t=m(o.touchedFields,e);t||(G(o.touchedFields,e,r),u.touchedFields=o.touchedFields,n=n||F.touchedFields&&t!==r)}return n&&a&&S.state.next(u),n?u:{}},B=(t,s,a,n)=>{const i=m(o.errors,t),u=F.isValid&&ee(s)&&o.isValid!==s;var l;if(e.delayError&&a?(l=()=>((e,t)=>{G(o.errors,e,t),S.state.next({errors:o.errors})})(t,a),r=e=>{clearTimeout(x),x=setTimeout(l,e)},r(e.delayError)):(clearTimeout(x),r=null,a?G(o.errors,t,a):xe(o.errors,t)),(a?!we(i,a):i)||!E(n)||u){const e={...n,...u&&ee(s)?{isValid:s}:{},errors:o.errors,name:t};o={...o,...e},S.state.next(e)}j(!1)},L=async e=>await s.resolver(_,s.context,((e,t,r,s)=>{const a={};for(const r of e){const e=m(t,r);e&&G(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||b.mount,h,s.criteriaMode,s.shouldUseNativeValidation)),M=async(e,t,r={valid:!0})=>{for(const a in e){const n=e[a];if(n){const{_f:e,...a}=n;if(e){const a=b.array.has(e.name),i=await ye(n,_,D,s.shouldUseNativeValidation,a);if(i[e.name]&&(r.valid=!1,t))break;!t&&(m(i,e.name)?a?Z(o.errors,i,e.name):G(o.errors,e.name,i[e.name]):xe(o.errors,e.name))}a&&await M(a,t,r)}}return r.valid},W=(e,t)=>(e&&t&&G(_,e,t),!we(ae(),p)),$=(e,t,r)=>R(e,b,{...v.mount?_:f(t)?p:N(e)?{[e]:t}:t},r,t),I=(e,t,r={})=>{const s=m(h,e);let n=t;if(s){const r=s._f;r&&(!r.disabled&&G(_,e,Te(t,r)),n=se(r.ref)&&i(t)?"":t,ke(r.ref)?[...r.ref.options].forEach((e=>e.selected=n.includes(e.value))):r.refs?a(r.ref)?r.refs.length>1?r.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):r.refs[0]&&(r.refs[0].checked=!!n):r.refs.forEach((e=>e.checked=e.value===n)):te(r.ref)?r.ref.value="":(r.ref.value=n,r.ref.type||S.watch.next({name:e})))}(r.shouldDirty||r.shouldTouch)&&T(e,n,r.shouldTouch,r.shouldDirty,!0),r.shouldValidate&&Q(e)},H=(e,t,r)=>{for(const s in t){const a=t[s],i=`${e}.${s}`,o=m(h,i);!b.array.has(e)&&Se(a)&&(!o||o._f)||n(a)?I(i,a,r):H(i,a,r)}},z=(e,r,s={})=>{const a=m(h,e),n=b.array.has(e),o=P(r);G(_,e,o),n?(S.array.next({name:e,values:_}),(F.isDirty||F.dirtyFields)&&s.shouldDirty&&S.state.next({name:e,dirtyFields:Ee(p,_),isDirty:W(e,o)})):!a||a._f||i(o)?I(e,o,s):H(e,o,s),Y(e,b)&&S.state.next({}),S.watch.next({name:e}),!v.mount&&t()},K=async e=>{const t=e.target;let a=t.name;const n=m(h,a);if(n){let u,c;const d=t.type?Ue(n._f):l(e),f=e.type===y||e.type===g,p=!((i=n._f).mount&&(i.required||i.min||i.max||i.maxLength||i.minLength||i.pattern||i.validate)||s.resolver||m(o.errors,a)||n._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(f,m(o.touchedFields,a),o.isSubmitted,k,w),v=Y(a,b,f);G(_,a,d),f?(n._f.onBlur&&n._f.onBlur(e),r&&r(0)):n._f.onChange&&n._f.onChange(e);const A=T(a,d,f,!1),x=!E(A)||v;if(!f&&S.watch.next({name:a,type:e.type}),p)return F.isValid&&C(),x&&S.state.next({name:a,...v?{}:A});if(!f&&v&&S.state.next({}),j(!0),s.resolver){const{errors:e}=await L([a]),t=Le(o.errors,h,a),r=Le(e,h,t.name||a);u=r.error,a=r.name,c=E(e)}else u=(await ye(n,_,D,s.shouldUseNativeValidation))[a],u?c=!1:F.isValid&&(c=await M(h,!0));n._f.deps&&Q(n._f.deps),B(a,c,u,A)}var i},Q=async(e,t={})=>{let r,a;const n=U(e);if(j(!0),s.resolver){const t=await(async e=>{const{errors:t}=await L();if(e)for(const r of e){const e=m(t,r);e?G(o.errors,r,e):xe(o.errors,r)}else o.errors=t;return t})(f(e)?e:n);r=E(t),a=e?!n.some((e=>m(t,e))):r}else e?(a=(await Promise.all(n.map((async e=>{const t=m(h,e);return await M(t&&t._f?{[e]:t}:t)})))).every(Boolean),(a||o.isValid)&&C()):a=r=await M(h);return S.state.next({...!N(e)||F.isValid&&r!==o.isValid?{}:{name:e},...s.resolver||!e?{isValid:r}:{},errors:o.errors,isValidating:!1}),t.shouldFocus&&!a&&J(h,(e=>e&&m(o.errors,e)),e?n:b.mount),a},ae=e=>{const t={...p,...v.mount?_:{}};return f(e)?t:N(e)?m(t,e):e.map((e=>m(t,e)))},ie=(e,t)=>({invalid:!!m((t||o).errors,e),isDirty:!!m((t||o).dirtyFields,e),isTouched:!!m((t||o).touchedFields,e),error:m((t||o).errors,e)}),oe=(e,t={})=>{for(const r of e?U(e):b.mount)b.mount.delete(r),b.array.delete(r),m(h,r)&&(t.keepValue||(xe(h,r),xe(_,r)),!t.keepError&&xe(o.errors,r),!t.keepDirty&&xe(o.dirtyFields,r),!t.keepTouched&&xe(o.touchedFields,r),!s.shouldUnregister&&!t.keepDefaultValue&&xe(p,r));S.watch.next({}),S.state.next({...o,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&C()},ue=(e,t={})=>{let r=m(h,e);const n=ee(t.disabled);return G(h,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),b.mount.add(e),r?n&&G(_,e,t.disabled?void 0:m(_,e,Ue(r._f))):O(e,!0,t.value),{...n?{disabled:t.disabled}:{},...s.shouldUseNativeValidation?{required:!!t.required,min:Be(t.min),max:Be(t.max),minLength:Be(t.minLength),maxLength:Be(t.maxLength),pattern:Be(t.pattern)}:{},name:e,onChange:K,onBlur:K,ref:n=>{if(n){ue(e,t),r=m(h,e);const s=f(n.value)&&n.querySelectorAll&&n.querySelectorAll("input,select,textarea")[0]||n,i=(e=>ne(e)||a(e))(s),o=r._f.refs||[];if(i?o.find((e=>e===s)):s===r._f.ref)return;G(h,e,{_f:{...r._f,...i?{refs:[...o.filter(De),s,...Array.isArray(m(p,e))?[{}]:[]],ref:{type:s.type,name:e}}:{ref:s}}}),O(e,!1,void 0,s)}else r=m(h,e,{}),r._f&&(r._f.mount=!1),(s.shouldUnregister||t.shouldUnregister)&&(!c(b.array,e)||!v.action)&&b.unMount.add(e)}}},le=()=>s.shouldFocusError&&J(h,(e=>e&&m(o.errors,e)),b.mount),ce=(r,s={})=>{const a=r||p,n=P(a),i=r&&!E(r)?n:p;if(s.keepDefaultValues||(p=a),!s.keepValues){if(s.keepDirtyValues||V)for(const e of b.mount)m(o.dirtyFields,e)?G(i,e,m(_,e)):z(e,m(i,e));else{if(q&&f(r))for(const e of b.mount){const t=m(h,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(se(e)){const t=e.closest("form");if(t){t.reset();break}}}}h={}}_=e.shouldUnregister?s.keepDefaultValues?P(p):{}:n,S.array.next({values:i}),S.watch.next({values:i})}b={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!v.mount&&t(),v.mount=!F.isValid||!!s.keepIsValid,v.watch=!!e.shouldUnregister,S.state.next({submitCount:s.keepSubmitCount?o.submitCount:0,isDirty:s.keepDirty?o.isDirty:!(!s.keepDefaultValues||we(r,p)),isSubmitted:!!s.keepIsSubmitted&&o.isSubmitted,dirtyFields:s.keepDirtyValues?o.dirtyFields:s.keepDefaultValues&&r?Ee(p,r):{},touchedFields:s.keepTouched?o.touchedFields:{},errors:s.keepErrors?o.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(re(e)?e(_):e,t);return re(s.defaultValues)&&s.defaultValues().then((e=>{de(e,s.resetOptions),S.state.next({isLoading:!1})})),{control:{register:ue,unregister:oe,getFieldState:ie,_executeSchema:L,_getWatch:$,_getDirty:W,_updateValid:C,_removeUnmounted:()=>{for(const e of b.unMount){const t=m(h,e);t&&(t._f.refs?t._f.refs.every((e=>!De(e))):!De(t._f.ref))&&oe(e)}b.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(v.action=!0,n&&Array.isArray(m(h,e))){const t=r(m(h,e),s.argA,s.argB);a&&G(h,e,t)}if(n&&Array.isArray(m(o.errors,e))){const t=r(m(o.errors,e),s.argA,s.argB);a&&G(o.errors,e,t),((e,t)=>{!d(m(e,t)).length&&xe(e,t)})(o.errors,e)}if(F.touchedFields&&n&&Array.isArray(m(o.touchedFields,e))){const t=r(m(o.touchedFields,e),s.argA,s.argB);a&&G(o.touchedFields,e,t)}F.dirtyFields&&(o.dirtyFields=Ee(p,_)),S.state.next({name:e,isDirty:W(e,t),dirtyFields:o.dirtyFields,errors:o.errors,isValid:o.isValid})}else G(_,e,t)},_getFieldArray:t=>d(m(v.mount?_:p,t,e.shouldUnregister?m(p,t,[]):[])),_reset:ce,_updateFormState:e=>{o={...o,...e}},_subjects:S,_proxyFormState:F,get _fields(){return h},get _formValues(){return _},get _stateFlags(){return v},set _stateFlags(e){v=e},get _defaultValues(){return p},get _names(){return b},set _names(e){b=e},get _formState(){return o},set _formState(e){o=e},get _options(){return s},set _options(e){s={...s,...e}}},trigger:Q,register:ue,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=P(_);if(S.state.next({isSubmitting:!0}),s.resolver){const{errors:e,values:t}=await L();o.errors=e,a=t}else await M(h);xe(o.errors,"root"),E(o.errors)?(S.state.next({errors:{}}),await e(a,r)):(t&&await t({...o.errors},r),le(),setTimeout(le)),S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:E(o.errors),submitCount:o.submitCount+1,errors:o.errors})},watch:(e,t)=>re(e)?S.watch.subscribe({next:r=>e($(void 0,t),r)}):$(e,t,!0),setValue:z,getValues:ae,reset:de,resetField:(e,t={})=>{m(h,e)&&(f(t.defaultValue)?z(e,m(p,e)):(z(e,t.defaultValue),G(p,e,t.defaultValue)),t.keepTouched||xe(o.touchedFields,e),t.keepDirty||(xe(o.dirtyFields,e),o.isDirty=t.defaultValue?W(e,m(p,e)):W()),t.keepError||(xe(o.errors,e),F.isValid&&C()),S.state.next({...o}))},clearErrors:e=>{e&&U(e).forEach((e=>xe(o.errors,e))),S.state.next({errors:e?o.errors:{}})},unregister:oe,setError:(e,t,r)=>{const s=(m(h,e,{_f:{}})._f||{}).ref;G(o.errors,e,{...t,ref:s}),S.state.next({name:e,errors:o.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=m(h,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}e.Controller=e=>e.render($(e)),e.FormProvider=e=>{const{children:t,...r}=e;return s.default.createElement(C.Provider,{value:r},t)},e.appendErrors=I,e.get=m,e.set=G,e.useController=$,e.useFieldArray=function(e){const t=j(),{control:r=t.control,name:a,keyName:n="id",shouldUnregister:i}=e,[o,u]=s.default.useState(r._getFieldArray(a)),l=s.default.useRef(r._getFieldArray(a).map(K)),c=s.default.useRef(o),d=s.default.useRef(a),f=s.default.useRef(!1);d.current=a,c.current=o,r._names.array.add(a),e.rules&&r.register(a,e.rules),L({next:({values:e,name:t})=>{if(t===d.current||!t){const t=m(e,d.current);Array.isArray(t)&&(u(t),l.current=t.map(K))}},subject:r._subjects.array});const y=s.default.useCallback((e=>{f.current=!0,r._updateFieldArray(a,e)}),[r,a]);return s.default.useEffect((()=>{if(r._stateFlags.action=!1,Y(a,r._names)&&r._subjects.state.next({}),f.current&&(!X(r._options.mode).isOnSubmit||r._formState.isSubmitted))if(r._options.resolver)r._executeSchema([a]).then((e=>{const t=m(e.errors,a),s=m(r._formState.errors,a);(s?!t&&s.type:t&&t.type)&&(t?G(r._formState.errors,a,t):xe(r._formState.errors,a),r._subjects.state.next({errors:r._formState.errors}))}));else{const e=m(r._fields,a);e&&e._f&&ye(e,r._formValues,r._options.criteriaMode===A,r._options.shouldUseNativeValidation,!0).then((e=>!E(e)&&r._subjects.state.next({errors:Z(r._formState.errors,e,a)})))}r._subjects.watch.next({name:a,values:r._formValues}),r._names.focus&&J(r._fields,(e=>!!e&&e.startsWith(r._names.focus||""))),r._names.focus="",r._updateValid()}),[o,a,r]),s.default.useEffect((()=>(!m(r._formValues,a)&&r._updateFieldArray(a),()=>{(r._options.shouldUnregister||i)&&r.unregister(a)})),[a,r,n,i]),{swap:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);Ae(s,e,t),Ae(l.current,e,t),y(s),u(s),r._updateFieldArray(a,s,Ae,{argA:e,argB:t},!1)}),[y,a,r]),move:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);_e(s,e,t),_e(l.current,e,t),y(s),u(s),r._updateFieldArray(a,s,_e,{argA:e,argB:t},!1)}),[y,a,r]),prepend:s.default.useCallback(((e,t)=>{const s=U(P(e)),n=ve(r._getFieldArray(a),s);r._names.focus=Q(a,0,t),l.current=ve(l.current,s.map(K)),y(n),u(n),r._updateFieldArray(a,n,ve,{argA:he(e)})}),[y,a,r]),append:s.default.useCallback(((e,t)=>{const s=U(P(e)),n=ge(r._getFieldArray(a),s);r._names.focus=Q(a,n.length-1,t),l.current=ge(l.current,s.map(K)),y(n),u(n),r._updateFieldArray(a,n,ge,{argA:he(e)})}),[y,a,r]),remove:s.default.useCallback((e=>{const t=be(r._getFieldArray(a),e);l.current=be(l.current,e),y(t),u(t),r._updateFieldArray(a,t,be,{argA:e})}),[y,a,r]),insert:s.default.useCallback(((e,t,s)=>{const n=U(P(t)),i=pe(r._getFieldArray(a),e,n);r._names.focus=Q(a,e,s),l.current=pe(l.current,e,n.map(K)),y(i),u(i),r._updateFieldArray(a,i,pe,{argA:e,argB:he(t)})}),[y,a,r]),update:s.default.useCallback(((e,t)=>{const s=P(t),n=Ve(r._getFieldArray(a),e,s);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:K())),y(n),u([...n]),r._updateFieldArray(a,n,Ve,{argA:e,argB:s},!0,!1)}),[y,a,r]),replace:s.default.useCallback((e=>{const t=U(P(e));l.current=t.map(K),y([...t]),u([...t]),r._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[y,a,r]),fields:s.default.useMemo((()=>o.map(((e,t)=>({...e,[n]:l.current[t]||K()})))),[o,n])}},e.useForm=function(e={}){const t=s.default.useRef(),[r,a]=s.default.useState({isDirty:!1,isValidating:!1,isLoading:!0,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:re(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ne(e,(()=>a((e=>({...e}))))),formState:r});const n=t.current.control;return n._options=e,L({subject:n._subjects.state,next:e=>{T(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),s.default.useEffect((()=>{n._stateFlags.mount||(n._updateValid(),n._stateFlags.mount=!0),n._stateFlags.watch&&(n._stateFlags.watch=!1,n._subjects.state.next({})),n._removeUnmounted()})),s.default.useEffect((()=>{e.values&&!we(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),t.current.formState=O(r,n),t.current},e.useFormContext=j,e.useFormState=M,e.useWatch=W,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactHookForm={},e.React)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=r(t),a=e=>"checkbox"===e.type,n=e=>e instanceof Date,i=e=>null==e;const u=e=>"object"==typeof e;var o=e=>!i(e)&&!Array.isArray(e)&&u(e)&&!n(e),l=e=>o(e)&&e.target?a(e.target)?e.target.checked:e.target.value:e,c=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),d=e=>Array.isArray(e)?e.filter(Boolean):[],f=e=>void 0===e,m=(e,t,r)=>{if(!t||!o(e))return r;const s=d(t.split(/[,[\].]+?/)).reduce(((e,t)=>i(e)?e:e[t]),e);return f(s)||s===e?f(e[t])?r:e[t]:s};const y="blur",g="focusout",p="change",_="onBlur",h="onChange",v="onSubmit",b="onTouched",A="all",x="max",V="min",F="maxLength",S="minLength",w="pattern",k="required",D="validate",C=s.default.createContext(null),j=()=>s.default.useContext(C);var O=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const n in e)Object.defineProperty(a,n,{get:()=>{const a=n;return t._proxyFormState[a]!==A&&(t._proxyFormState[a]=!s||A),r&&(r[a]=!0),e[a]}});return a},E=e=>o(e)&&!Object.keys(e).length,T=(e,t,r,s)=>{r(e);const{name:a,...n}=e;return E(n)||Object.keys(n).length>=Object.keys(t).length||Object.keys(n).find((e=>t[e]===(!s||A)))},U=e=>Array.isArray(e)?e:[e],B=(e,t,r)=>r&&t?e===t:!e||!t||e===t||U(e).some((e=>e&&(e.startsWith(t)||t.startsWith(e))));function L(e){const t=s.default.useRef(e);t.current=e,s.default.useEffect((()=>{const r=!e.disabled&&t.current.subject.subscribe({next:t.current.next});return()=>{r&&r.unsubscribe()}}),[e.disabled])}function M(e){const t=j(),{control:r=t.control,disabled:a,name:n,exact:i}=e||{},[u,o]=s.default.useState(r._formState),l=s.default.useRef(!0),c=s.default.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=s.default.useRef(n);return d.current=n,L({disabled:a,next:e=>l.current&&B(d.current,e.name,i)&&T(e,c.current,r._updateFormState)&&o({...r._formState,...e}),subject:r._subjects.state}),s.default.useEffect((()=>{l.current=!0;const e=r._proxyFormState.isDirty&&r._getDirty();return e!==r._formState.isDirty&&r._subjects.state.next({isDirty:e}),c.current.isValid&&r._updateValid(!0),()=>{l.current=!1}}),[r]),O(u,r,c.current,!1)}var N=e=>"string"==typeof e,R=(e,t,r,s,a)=>N(e)?(s&&t.watch.add(e),m(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),m(r,e)))):(s&&(t.watchAll=!0),r),q="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function P(e){let t;const r=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(q&&(e instanceof Blob||e instanceof FileList)||!r&&!o(e))return e;if(t=r?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return o(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)t[r]=P(e[r]);else t=e}return t}function W(e){const t=j(),{control:r=t.control,name:a,defaultValue:n,disabled:i,exact:u}=e||{},o=s.default.useRef(a);o.current=a,L({disabled:i,subject:r._subjects.values,next:e=>{B(o.current,e.name,u)&&c(P(R(o.current,r._names,e.values||r._formValues,!1,n)))}});const[l,c]=s.default.useState(r._getWatch(a,n));return s.default.useEffect((()=>r._removeUnmounted())),l}function $(e){const t=j(),{name:r,control:a=t.control,shouldUnregister:n}=e,i=c(a._names.array,r),u=W({control:a,name:r,defaultValue:m(a._formValues,r,m(a._defaultValues,r,e.defaultValue)),exact:!0}),o=M({control:a,name:r}),d=s.default.useRef(a.register(r,{...e.rules,value:u}));return s.default.useEffect((()=>{const e=(e,t)=>{const r=m(a._fields,e);r&&(r._f.mount=t)};return e(r,!0),()=>{const t=a._options.shouldUnregister||n;(i?t&&!a._stateFlags.action:t)?a.unregister(r):e(r,!1)}}),[r,a,i,n]),{field:{name:r,value:u,onChange:s.default.useCallback((e=>d.current.onChange({target:{value:l(e),name:r},type:p})),[r]),onBlur:s.default.useCallback((()=>d.current.onBlur({target:{value:m(a._formValues,r),name:r},type:y})),[r,a]),ref:e=>{const t=m(a._fields,r);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}},formState:o,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!m(o.errors,r)},isDirty:{enumerable:!0,get:()=>!!m(o.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!m(o.touchedFields,r)},error:{enumerable:!0,get:()=>m(o.errors,r)}})}}var I=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},H=e=>/^\w*$/.test(e),z=e=>d(e.replace(/["|']|\]/g,"").split(/\.|\[/));function G(e,t,r){let s=-1;const a=H(t)?[t]:z(t),n=a.length,i=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==i){const r=e[t];n=o(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}e[t]=n,e=e[t]}return e}const J=(e,t,r)=>{for(const s of r||Object.keys(e)){const r=m(e,s);if(r){const{_f:e,...s}=r;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else o(s)&&J(s,t)}}};var K=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},Q=(e,t,r={})=>r.shouldFocus||f(r.shouldFocus)?r.focusName||`${e}.${f(r.focusIndex)?t:r.focusIndex}.`:"",X=e=>({isOnSubmit:!e||e===v,isOnBlur:e===_,isOnChange:e===h,isOnAll:e===A,isOnTouch:e===b}),Y=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),Z=(e,t,r)=>{const s=d(m(e,r));return G(s,"root",t[r]),G(e,r,s),e},ee=e=>"boolean"==typeof e,te=e=>"file"===e.type,re=e=>"function"==typeof e,se=e=>{if(!q)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ae=e=>N(e),ne=e=>"radio"===e.type,ie=e=>e instanceof RegExp;const ue={value:!1,isValid:!1},oe={value:!0,isValid:!0};var le=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!f(e[0].attributes.value)?f(e[0].value)||""===e[0].value?oe:{value:e[0].value,isValid:!0}:oe:ue}return ue};const ce={isValid:!1,value:null};var de=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),ce):ce;function fe(e,t,r="validate"){if(ae(e)||Array.isArray(e)&&e.every(ae)||ee(e)&&!e)return{type:r,message:ae(e)?e:"",ref:t}}var me=e=>o(e)&&!ie(e)?e:{value:e,message:""},ye=async(e,t,r,s,n)=>{const{ref:u,refs:l,required:c,maxLength:d,minLength:y,min:g,max:p,pattern:_,validate:h,name:v,valueAsNumber:b,mount:A,disabled:C}=e._f,j=m(t,v);if(!A||C)return{};const O=l?l[0]:u,T=e=>{s&&O.reportValidity&&(O.setCustomValidity(ee(e)?"":e||""),O.reportValidity())},U={},B=ne(u),L=a(u),M=B||L,R=(b||te(u))&&f(u.value)&&f(j)||se(u)&&""===u.value||""===j||Array.isArray(j)&&!j.length,q=I.bind(null,v,r,U),P=(e,t,r,s=F,a=S)=>{const n=e?t:r;U[v]={type:e?s:a,message:n,ref:u,...q(e?s:a,n)}};if(n?!Array.isArray(j)||!j.length:c&&(!M&&(R||i(j))||ee(j)&&!j||L&&!le(l).isValid||B&&!de(l).isValid)){const{value:e,message:t}=ae(c)?{value:!!c,message:c}:me(c);if(e&&(U[v]={type:k,message:t,ref:O,...q(k,t)},!r))return T(t),U}if(!(R||i(g)&&i(p))){let e,t;const s=me(p),a=me(g);if(i(j)||isNaN(j)){const r=u.valueAsDate||new Date(j),n=e=>new Date((new Date).toDateString()+" "+e),i="time"==u.type,o="week"==u.type;N(s.value)&&j&&(e=i?n(j)>n(s.value):o?j>s.value:r>new Date(s.value)),N(a.value)&&j&&(t=i?n(j)<n(a.value):o?j<a.value:r<new Date(a.value))}else{const r=u.valueAsNumber||(j?+j:j);i(s.value)||(e=r>s.value),i(a.value)||(t=r<a.value)}if((e||t)&&(P(!!e,s.message,a.message,x,V),!r))return T(U[v].message),U}if((d||y)&&!R&&(N(j)||n&&Array.isArray(j))){const e=me(d),t=me(y),s=!i(e.value)&&j.length>e.value,a=!i(t.value)&&j.length<t.value;if((s||a)&&(P(s,e.message,t.message),!r))return T(U[v].message),U}if(_&&!R&&N(j)){const{value:e,message:t}=me(_);if(ie(e)&&!j.match(e)&&(U[v]={type:w,message:t,ref:u,...q(w,t)},!r))return T(t),U}if(h)if(re(h)){const e=fe(await h(j,t),O);if(e&&(U[v]={...e,...q(D,e.message)},!r))return T(e.message),U}else if(o(h)){let e={};for(const s in h){if(!E(e)&&!r)break;const a=fe(await h[s](j,t),O,s);a&&(e={...a,...q(s,a.message)},T(a.message),r&&(U[v]=e))}if(!E(e)&&(U[v]={ref:O,...e},!r))return U}return T(!0),U};function ge(e,t){return[...e,...U(t)]}var pe=e=>Array.isArray(e)?e.map((()=>{})):void 0;function _e(e,t,r){return[...e.slice(0,t),...U(r),...e.slice(t)]}var he=(e,t,r)=>Array.isArray(e)?(f(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[];function ve(e,t){return[...U(t),...U(e)]}var be=(e,t)=>f(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return d(s).length?s:[]}(e,U(t).sort(((e,t)=>e-t))),Ae=(e,t,r)=>{e[t]=[e[r],e[r]=e[t]][0]};function xe(e,t){const r=Array.isArray(t)?t:H(t)?[t]:z(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=f(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(o(s)&&E(s)||Array.isArray(s)&&function(e){for(const t in e)if(!f(e[t]))return!1;return!0}(s))&&xe(e,r.slice(0,-1)),e}var Ve=(e,t,r)=>(e[t]=r,e);function Fe(){let e=[];return{get observers(){return e},next:t=>{let r=0;const s=e.length;for(;r<s;)e[r].next(t),++r},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var Se=e=>i(e)||!u(e);function we(e,t){if(Se(e)||Se(t))return e===t;if(n(e)&&n(t))return e.getTime()===t.getTime();const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(const a of r){const r=e[a];if(!s.includes(a))return!1;if("ref"!==a){const e=t[a];if(n(r)&&n(e)||o(r)&&o(e)||Array.isArray(r)&&Array.isArray(e)?!we(r,e):r!==e)return!1}}return!0}var ke=e=>"select-multiple"===e.type,De=e=>se(e)&&e.isConnected,Ce=e=>{for(const t in e)if(re(e[t]))return!0;return!1};function je(e,t={}){const r=Array.isArray(e);if(o(e)||r)for(const r in e)Array.isArray(e[r])||o(e[r])&&!Ce(e[r])?(t[r]=Array.isArray(e[r])?[]:{},je(e[r],t[r])):i(e[r])||(t[r]=!0);return t}function Oe(e,t,r){const s=Array.isArray(e);if(o(e)||s)for(const s in e)Array.isArray(e[s])||o(e[s])&&!Ce(e[s])?f(t)||Se(r[s])?r[s]=Array.isArray(e[s])?je(e[s],[]):{...je(e[s])}:Oe(e[s],i(t)?{}:t[s],r[s]):r[s]=!we(e[s],t[s]);return r}var Ee=(e,t)=>Oe(e,t,je(t)),Te=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>f(e)?e:t?""===e?NaN:e?+e:e:r&&N(e)?new Date(e):s?s(e):e;function Ue(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return te(t)?t.files:ne(t)?de(e.refs).value:ke(t)?[...t.selectedOptions].map((({value:e})=>e)):a(t)?le(e.refs).value:Te(f(t.value)?e.ref.value:t.value,e)}var Be=e=>f(e)?e:ie(e)?e.source:o(e)?ie(e.value)?e.value.source:e.value:e;function Le(e,t,r){const s=m(e,r);if(s||H(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),n=m(t,s),i=m(e,s);if(n&&!Array.isArray(n)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};a.pop()}return{name:r}}const Me={mode:v,reValidateMode:h,shouldFocusError:!0};function Ne(e={},t){let r,s={...Me,...e},u={submitCount:0,isDirty:!1,isLoading:!0,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},p={},_=(o(s.defaultValues)||o(s.values))&&P(s.defaultValues||s.values)||{},h=s.shouldUnregister?{}:P(_),v={action:!1,mount:!1,watch:!1},b={mount:new Set,unMount:new Set,array:new Set,watch:new Set},x=0;const V=e.resetOptions&&e.resetOptions.keepDirtyValues,F={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},S={values:Fe(),array:Fe(),state:Fe()},w=X(s.mode),k=X(s.reValidateMode),D=s.criteriaMode===A,C=async e=>{if(F.isValid||e){const e=s.resolver?E((await L()).errors):await M(p,!0);e!==u.isValid&&S.state.next({isValid:e})}},j=e=>F.isValidating&&S.state.next({isValidating:e}),O=(e,t,r,s)=>{const a=m(p,e);if(a){const n=m(h,e,f(r)?m(_,e):r);f(n)||s&&s.defaultChecked||t?G(h,e,t?n:Ue(a._f)):I(e,n),v.mount&&C()}},T=(e,t,r,s,a)=>{let n=!1,i=!1;const o={name:e};if(!r||s){F.isDirty&&(i=u.isDirty,u.isDirty=o.isDirty=W(),n=i!==o.isDirty);const r=we(m(_,e),t);i=m(u.dirtyFields,e),r?xe(u.dirtyFields,e):G(u.dirtyFields,e,!0),o.dirtyFields=u.dirtyFields,n=n||F.dirtyFields&&i!==!r}if(r){const t=m(u.touchedFields,e);t||(G(u.touchedFields,e,r),o.touchedFields=u.touchedFields,n=n||F.touchedFields&&t!==r)}return n&&a&&S.state.next(o),n?o:{}},B=(t,s,a,n)=>{const i=m(u.errors,t),o=F.isValid&&ee(s)&&u.isValid!==s;var l;if(e.delayError&&a?(l=()=>((e,t)=>{G(u.errors,e,t),S.state.next({errors:u.errors})})(t,a),r=e=>{clearTimeout(x),x=setTimeout(l,e)},r(e.delayError)):(clearTimeout(x),r=null,a?G(u.errors,t,a):xe(u.errors,t)),(a?!we(i,a):i)||!E(n)||o){const e={...n,...o&&ee(s)?{isValid:s}:{},errors:u.errors,name:t};u={...u,...e},S.state.next(e)}j(!1)},L=async e=>await s.resolver(h,s.context,((e,t,r,s)=>{const a={};for(const r of e){const e=m(t,r);e&&G(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||b.mount,p,s.criteriaMode,s.shouldUseNativeValidation)),M=async(e,t,r={valid:!0})=>{for(const a in e){const n=e[a];if(n){const{_f:e,...a}=n;if(e){const a=b.array.has(e.name),i=await ye(n,h,D,s.shouldUseNativeValidation,a);if(i[e.name]&&(r.valid=!1,t))break;!t&&(m(i,e.name)?a?Z(u.errors,i,e.name):G(u.errors,e.name,i[e.name]):xe(u.errors,e.name))}a&&await M(a,t,r)}}return r.valid},W=(e,t)=>(e&&t&&G(h,e,t),!we(ae(),_)),$=(e,t,r)=>R(e,b,{...v.mount?h:f(t)?_:N(e)?{[e]:t}:t},r,t),I=(e,t,r={})=>{const s=m(p,e);let n=t;if(s){const r=s._f;r&&(!r.disabled&&G(h,e,Te(t,r)),n=se(r.ref)&&i(t)?"":t,ke(r.ref)?[...r.ref.options].forEach((e=>e.selected=n.includes(e.value))):r.refs?a(r.ref)?r.refs.length>1?r.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):r.refs[0]&&(r.refs[0].checked=!!n):r.refs.forEach((e=>e.checked=e.value===n)):te(r.ref)?r.ref.value="":(r.ref.value=n,r.ref.type||S.values.next({name:e,values:{...h}})))}(r.shouldDirty||r.shouldTouch)&&T(e,n,r.shouldTouch,r.shouldDirty,!0),r.shouldValidate&&Q(e)},H=(e,t,r)=>{for(const s in t){const a=t[s],i=`${e}.${s}`,u=m(p,i);!b.array.has(e)&&Se(a)&&(!u||u._f)||n(a)?I(i,a,r):H(i,a,r)}},z=(e,r,s={})=>{const a=m(p,e),n=b.array.has(e),o=P(r);G(h,e,o),n?(S.array.next({name:e,values:{...h}}),(F.isDirty||F.dirtyFields)&&s.shouldDirty&&S.state.next({name:e,dirtyFields:Ee(_,h),isDirty:W(e,o)})):!a||a._f||i(o)?I(e,o,s):H(e,o,s),Y(e,b)&&S.state.next({...u}),S.values.next({name:e,values:{...h}}),!v.mount&&t()},K=async e=>{const t=e.target;let a=t.name;const n=m(p,a);if(n){let o,c;const d=t.type?Ue(n._f):l(e),f=e.type===y||e.type===g,_=!((i=n._f).mount&&(i.required||i.min||i.max||i.maxLength||i.minLength||i.pattern||i.validate)||s.resolver||m(u.errors,a)||n._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(f,m(u.touchedFields,a),u.isSubmitted,k,w),v=Y(a,b,f);G(h,a,d),f?(n._f.onBlur&&n._f.onBlur(e),r&&r(0)):n._f.onChange&&n._f.onChange(e);const A=T(a,d,f,!1),x=!E(A)||v;if(!f&&S.values.next({name:a,type:e.type,values:{...h}}),_)return F.isValid&&C(),x&&S.state.next({name:a,...v?{}:A});if(!f&&v&&S.state.next({...u}),j(!0),s.resolver){const{errors:e}=await L([a]),t=Le(u.errors,p,a),r=Le(e,p,t.name||a);o=r.error,a=r.name,c=E(e)}else o=(await ye(n,h,D,s.shouldUseNativeValidation))[a],o?c=!1:F.isValid&&(c=await M(p,!0));n._f.deps&&Q(n._f.deps),B(a,c,o,A)}var i},Q=async(e,t={})=>{let r,a;const n=U(e);if(j(!0),s.resolver){const t=await(async e=>{const{errors:t}=await L();if(e)for(const r of e){const e=m(t,r);e?G(u.errors,r,e):xe(u.errors,r)}else u.errors=t;return t})(f(e)?e:n);r=E(t),a=e?!n.some((e=>m(t,e))):r}else e?(a=(await Promise.all(n.map((async e=>{const t=m(p,e);return await M(t&&t._f?{[e]:t}:t)})))).every(Boolean),(a||u.isValid)&&C()):a=r=await M(p);return S.state.next({...!N(e)||F.isValid&&r!==u.isValid?{}:{name:e},...s.resolver||!e?{isValid:r}:{},errors:u.errors,isValidating:!1}),t.shouldFocus&&!a&&J(p,(e=>e&&m(u.errors,e)),e?n:b.mount),a},ae=e=>{const t={..._,...v.mount?h:{}};return f(e)?t:N(e)?m(t,e):e.map((e=>m(t,e)))},ie=(e,t)=>({invalid:!!m((t||u).errors,e),isDirty:!!m((t||u).dirtyFields,e),isTouched:!!m((t||u).touchedFields,e),error:m((t||u).errors,e)}),ue=(e,t={})=>{for(const r of e?U(e):b.mount)b.mount.delete(r),b.array.delete(r),m(p,r)&&(t.keepValue||(xe(p,r),xe(h,r)),!t.keepError&&xe(u.errors,r),!t.keepDirty&&xe(u.dirtyFields,r),!t.keepTouched&&xe(u.touchedFields,r),!s.shouldUnregister&&!t.keepDefaultValue&&xe(_,r));S.values.next({values:{...h}}),S.state.next({...u,...t.keepDirty?{isDirty:W()}:{}}),!t.keepIsValid&&C()},oe=(e,t={})=>{let r=m(p,e);const n=ee(t.disabled);return G(p,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),b.mount.add(e),r?n&&G(h,e,t.disabled?void 0:m(h,e,Ue(r._f))):O(e,!0,t.value),{...n?{disabled:t.disabled}:{},...s.shouldUseNativeValidation?{required:!!t.required,min:Be(t.min),max:Be(t.max),minLength:Be(t.minLength),maxLength:Be(t.maxLength),pattern:Be(t.pattern)}:{},name:e,onChange:K,onBlur:K,ref:n=>{if(n){oe(e,t),r=m(p,e);const s=f(n.value)&&n.querySelectorAll&&n.querySelectorAll("input,select,textarea")[0]||n,i=(e=>ne(e)||a(e))(s),u=r._f.refs||[];if(i?u.find((e=>e===s)):s===r._f.ref)return;G(p,e,{_f:{...r._f,...i?{refs:[...u.filter(De),s,...Array.isArray(m(_,e))?[{}]:[]],ref:{type:s.type,name:e}}:{ref:s}}}),O(e,!1,void 0,s)}else r=m(p,e,{}),r._f&&(r._f.mount=!1),(s.shouldUnregister||t.shouldUnregister)&&(!c(b.array,e)||!v.action)&&b.unMount.add(e)}}},le=()=>s.shouldFocusError&&J(p,(e=>e&&m(u.errors,e)),b.mount),ce=(r,s={})=>{const a=r||_,n=P(a),i=r&&!E(r)?n:_;if(s.keepDefaultValues||(_=a),!s.keepValues){if(s.keepDirtyValues||V)for(const e of b.mount)m(u.dirtyFields,e)?G(i,e,m(h,e)):z(e,m(i,e));else{if(q&&f(r))for(const e of b.mount){const t=m(p,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}}}}p={}}h=e.shouldUnregister?s.keepDefaultValues?P(_):{}:n,S.array.next({values:i}),S.values.next({values:i})}b={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!v.mount&&t(),v.mount=!F.isValid||!!s.keepIsValid,v.watch=!!e.shouldUnregister,S.state.next({submitCount:s.keepSubmitCount?u.submitCount:0,isDirty:s.keepDirty?u.isDirty:!(!s.keepDefaultValues||we(r,_)),isSubmitted:!!s.keepIsSubmitted&&u.isSubmitted,dirtyFields:s.keepDirtyValues?u.dirtyFields:s.keepDefaultValues&&r?Ee(_,r):{},touchedFields:s.keepTouched?u.touchedFields:{},errors:s.keepErrors?u.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},de=(e,t)=>ce(re(e)?e(h):e,t);return re(s.defaultValues)&&s.defaultValues().then((e=>{de(e,s.resetOptions),S.state.next({isLoading:!1})})),{control:{register:oe,unregister:ue,getFieldState:ie,_executeSchema:L,_getWatch:$,_getDirty:W,_updateValid:C,_removeUnmounted:()=>{for(const e of b.unMount){const t=m(p,e);t&&(t._f.refs?t._f.refs.every((e=>!De(e))):!De(t._f.ref))&&ue(e)}b.unMount=new Set},_updateFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r){if(v.action=!0,n&&Array.isArray(m(p,e))){const t=r(m(p,e),s.argA,s.argB);a&&G(p,e,t)}if(n&&Array.isArray(m(u.errors,e))){const t=r(m(u.errors,e),s.argA,s.argB);a&&G(u.errors,e,t),((e,t)=>{!d(m(e,t)).length&&xe(e,t)})(u.errors,e)}if(F.touchedFields&&n&&Array.isArray(m(u.touchedFields,e))){const t=r(m(u.touchedFields,e),s.argA,s.argB);a&&G(u.touchedFields,e,t)}F.dirtyFields&&(u.dirtyFields=Ee(_,h)),S.state.next({name:e,isDirty:W(e,t),dirtyFields:u.dirtyFields,errors:u.errors,isValid:u.isValid})}else G(h,e,t)},_getFieldArray:t=>d(m(v.mount?h:_,t,e.shouldUnregister?m(_,t,[]):[])),_reset:ce,_updateFormState:e=>{u={...u,...e}},_subjects:S,_proxyFormState:F,get _fields(){return p},get _formValues(){return h},get _stateFlags(){return v},set _stateFlags(e){v=e},get _defaultValues(){return _},get _names(){return b},set _names(e){b=e},get _formState(){return u},set _formState(e){u=e},get _options(){return s},set _options(e){s={...s,...e}}},trigger:Q,register:oe,handleSubmit:(e,t)=>async r=>{r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=P(h);if(S.state.next({isSubmitting:!0}),s.resolver){const{errors:e,values:t}=await L();u.errors=e,a=t}else await M(p);xe(u.errors,"root"),E(u.errors)?(S.state.next({errors:{}}),await e(a,r)):(t&&await t({...u.errors},r),le(),setTimeout(le)),S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:E(u.errors),submitCount:u.submitCount+1,errors:u.errors})},watch:(e,t)=>re(e)?S.values.subscribe({next:r=>e($(void 0,t),r)}):$(e,t,!0),setValue:z,getValues:ae,reset:de,resetField:(e,t={})=>{m(p,e)&&(f(t.defaultValue)?z(e,m(_,e)):(z(e,t.defaultValue),G(_,e,t.defaultValue)),t.keepTouched||xe(u.touchedFields,e),t.keepDirty||(xe(u.dirtyFields,e),u.isDirty=t.defaultValue?W(e,m(_,e)):W()),t.keepError||(xe(u.errors,e),F.isValid&&C()),S.state.next({...u}))},clearErrors:e=>{e&&U(e).forEach((e=>xe(u.errors,e))),S.state.next({errors:e?u.errors:{}})},unregister:ue,setError:(e,t,r)=>{const s=(m(p,e,{_f:{}})._f||{}).ref;G(u.errors,e,{...t,ref:s}),S.state.next({name:e,errors:u.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},setFocus:(e,t={})=>{const r=m(p,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:ie}}e.Controller=e=>e.render($(e)),e.FormProvider=e=>{const{children:t,...r}=e;return s.default.createElement(C.Provider,{value:r},t)},e.appendErrors=I,e.get=m,e.set=G,e.useController=$,e.useFieldArray=function(e){const t=j(),{control:r=t.control,name:a,keyName:n="id",shouldUnregister:i}=e,[u,o]=s.default.useState(r._getFieldArray(a)),l=s.default.useRef(r._getFieldArray(a).map(K)),c=s.default.useRef(u),d=s.default.useRef(a),f=s.default.useRef(!1);d.current=a,c.current=u,r._names.array.add(a),e.rules&&r.register(a,e.rules),L({next:({values:e,name:t})=>{if(t===d.current||!t){const t=m(e,d.current);Array.isArray(t)&&(o(t),l.current=t.map(K))}},subject:r._subjects.array});const y=s.default.useCallback((e=>{f.current=!0,r._updateFieldArray(a,e)}),[r,a]);return s.default.useEffect((()=>{if(r._stateFlags.action=!1,Y(a,r._names)&&r._subjects.state.next({...r._formState}),f.current&&(!X(r._options.mode).isOnSubmit||r._formState.isSubmitted))if(r._options.resolver)r._executeSchema([a]).then((e=>{const t=m(e.errors,a),s=m(r._formState.errors,a);(s?!t&&s.type:t&&t.type)&&(t?G(r._formState.errors,a,t):xe(r._formState.errors,a),r._subjects.state.next({errors:r._formState.errors}))}));else{const e=m(r._fields,a);e&&e._f&&ye(e,r._formValues,r._options.criteriaMode===A,r._options.shouldUseNativeValidation,!0).then((e=>!E(e)&&r._subjects.state.next({errors:Z(r._formState.errors,e,a)})))}r._subjects.values.next({name:a,values:r._formValues}),r._names.focus&&J(r._fields,(e=>!!e&&e.startsWith(r._names.focus||""))),r._names.focus="",r._updateValid()}),[u,a,r]),s.default.useEffect((()=>(!m(r._formValues,a)&&r._updateFieldArray(a),()=>{(r._options.shouldUnregister||i)&&r.unregister(a)})),[a,r,n,i]),{swap:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);Ae(s,e,t),Ae(l.current,e,t),y(s),o(s),r._updateFieldArray(a,s,Ae,{argA:e,argB:t},!1)}),[y,a,r]),move:s.default.useCallback(((e,t)=>{const s=r._getFieldArray(a);he(s,e,t),he(l.current,e,t),y(s),o(s),r._updateFieldArray(a,s,he,{argA:e,argB:t},!1)}),[y,a,r]),prepend:s.default.useCallback(((e,t)=>{const s=U(P(e)),n=ve(r._getFieldArray(a),s);r._names.focus=Q(a,0,t),l.current=ve(l.current,s.map(K)),y(n),o(n),r._updateFieldArray(a,n,ve,{argA:pe(e)})}),[y,a,r]),append:s.default.useCallback(((e,t)=>{const s=U(P(e)),n=ge(r._getFieldArray(a),s);r._names.focus=Q(a,n.length-1,t),l.current=ge(l.current,s.map(K)),y(n),o(n),r._updateFieldArray(a,n,ge,{argA:pe(e)})}),[y,a,r]),remove:s.default.useCallback((e=>{const t=be(r._getFieldArray(a),e);l.current=be(l.current,e),y(t),o(t),r._updateFieldArray(a,t,be,{argA:e})}),[y,a,r]),insert:s.default.useCallback(((e,t,s)=>{const n=U(P(t)),i=_e(r._getFieldArray(a),e,n);r._names.focus=Q(a,e,s),l.current=_e(l.current,e,n.map(K)),y(i),o(i),r._updateFieldArray(a,i,_e,{argA:e,argB:pe(t)})}),[y,a,r]),update:s.default.useCallback(((e,t)=>{const s=P(t),n=Ve(r._getFieldArray(a),e,s);l.current=[...n].map(((t,r)=>t&&r!==e?l.current[r]:K())),y(n),o([...n]),r._updateFieldArray(a,n,Ve,{argA:e,argB:s},!0,!1)}),[y,a,r]),replace:s.default.useCallback((e=>{const t=U(P(e));l.current=t.map(K),y([...t]),o([...t]),r._updateFieldArray(a,[...t],(e=>e),{},!0,!1)}),[y,a,r]),fields:s.default.useMemo((()=>u.map(((e,t)=>({...e,[n]:l.current[t]||K()})))),[u,n])}},e.useForm=function(e={}){const t=s.default.useRef(),[r,a]=s.default.useState({isDirty:!1,isValidating:!1,isLoading:!0,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:re(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ne(e,(()=>a((e=>({...e}))))),formState:r});const n=t.current.control;return n._options=e,L({subject:n._subjects.state,next:e=>{T(e,n._proxyFormState,n._updateFormState,!0)&&a({...n._formState})}}),s.default.useEffect((()=>{e.values&&!we(e.values,n._defaultValues)&&n._reset(e.values,n._options.resetOptions)}),[e.values,n]),s.default.useEffect((()=>{n._stateFlags.mount||(n._updateValid(),n._stateFlags.mount=!0),n._stateFlags.watch&&(n._stateFlags.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),t.current.formState=O(r,n),t.current},e.useFormContext=j,e.useFormState=M,e.useWatch=W,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -25,3 +25,4 @@ import { DeepPartial, FieldValues, UseFormReturn } from '../types'; | ||
delayError: number; | ||
formControl: Omit<UseFormReturn<FieldValues, unknown>, "formState">; | ||
}> | undefined, flushRootRender: () => void): Omit<UseFormReturn<TFieldValues, TContext>, 'formState'>; | ||
//# sourceMappingURL=createFormControl.d.ts.map |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.34.4" | ||
"packageVersion": "7.33.7" | ||
} | ||
] | ||
} |
import React from 'react'; | ||
import { createFormControl } from '../logic/createFormControl'; | ||
import { Subject, Subscription } from '../utils/createSubject'; | ||
@@ -35,4 +36,4 @@ import { ErrorOption, FieldError, FieldErrors } from './errors'; | ||
export type CriteriaMode = 'firstError' | 'all'; | ||
export type SubmitHandler<TFieldValues extends FieldValues> = (data: TFieldValues, event?: React.BaseSyntheticEvent) => any | Promise<any>; | ||
export type SubmitErrorHandler<TFieldValues extends FieldValues> = (errors: FieldErrors<TFieldValues>, event?: React.BaseSyntheticEvent) => any | Promise<any>; | ||
export type SubmitHandler<TFieldValues extends FieldValues> = (data: TFieldValues, event?: React.BaseSyntheticEvent) => unknown | Promise<unknown>; | ||
export type SubmitErrorHandler<TFieldValues extends FieldValues> = (errors: FieldErrors<TFieldValues>, event?: React.BaseSyntheticEvent) => unknown | Promise<unknown>; | ||
export type SetValueConfig = Partial<{ | ||
@@ -65,2 +66,3 @@ shouldValidate: boolean; | ||
delayError: number; | ||
formControl: ReturnType<typeof createFormControl>; | ||
}>; | ||
@@ -495,3 +497,3 @@ export type FieldNamesMarkedBoolean<TFieldValues extends FieldValues> = DeepMap<DeepPartial<TFieldValues>, boolean>; | ||
keepError: boolean; | ||
defaultValue: any; | ||
defaultValue: FieldPathValue<TFieldValues, TFieldName>; | ||
}>) => void; | ||
@@ -540,6 +542,6 @@ type ResetAction<TFieldValues> = (formValues: TFieldValues) => TFieldValues; | ||
export type Subjects<TFieldValues extends FieldValues = FieldValues> = { | ||
watch: Subject<{ | ||
values: Subject<{ | ||
name?: InternalFieldName; | ||
type?: EventType; | ||
values?: FieldValues; | ||
values: FieldValues; | ||
}>; | ||
@@ -546,0 +548,0 @@ array: Subject<{ |
@@ -1,3 +0,3 @@ | ||
declare const _default: <T>(obj: T, path: string, defaultValue?: unknown) => any; | ||
declare const _default: <T>(obj: T, path?: string, defaultValue?: unknown) => any; | ||
export default _default; | ||
//# sourceMappingURL=get.d.ts.map |
{ | ||
"name": "react-hook-form", | ||
"description": "Performant, flexible and extensible forms library for React Hooks", | ||
"version": "7.43.2", | ||
"version": "7.43.3", | ||
"main": "dist/index.cjs.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.esm.mjs", |
@@ -69,38 +69,17 @@ <div align="center"> | ||
<a | ||
target = _blank | ||
href = 'https://wantedlyinc.com' | ||
/> | ||
<img | ||
width = 94 | ||
src = 'https://images.opencollective.com/wantedly/d94e44e/logo/256.png' | ||
/> | ||
<a target="_blank" href='https://wantedlyinc.com'> | ||
<img width="94" src="https://images.opencollective.com/wantedly/d94e44e/logo/256.png" /> | ||
</a> | ||
<a | ||
target = _blank | ||
href = 'https://graphcms.com' | ||
/> | ||
<img | ||
width = 94 | ||
src = 'https://avatars.githubusercontent.com/u/31031438' | ||
/> | ||
<a target="_blank" href="https://graphcms.com"> | ||
<img width="94" src="https://avatars.githubusercontent.com/u/31031438" /> | ||
</a> | ||
<a | ||
target = _blank | ||
href = 'https://kanamekey.com' | ||
/> | ||
<img | ||
width = 94 | ||
src = 'https://images.opencollective.com/kaname/d15fd98/logo/256.png' | ||
/> | ||
<a target="_blank" href="https://www.beekai.com/"> | ||
<img width="94" src="https://www.beekai.com/marketing/logo/logo.svg" /> | ||
</a> | ||
<a | ||
target = _blank | ||
href = 'https://formcarry.com/' | ||
/> | ||
<img | ||
width = 94 | ||
src = 'https://images.opencollective.com/formcarry/a40a4ea/logo/256.png' | ||
/> | ||
<a target="_blank" href="https://kanamekey.com"> | ||
<img width="94" src="https://images.opencollective.com/kaname/d15fd98/logo/256.png" /> | ||
</a> | ||
<a target="_blank" href="https://formcarry.com/"> | ||
<img width="94" src="https://images.opencollective.com/formcarry/a40a4ea/logo/256.png" /> | ||
</a> | ||
@@ -107,0 +86,0 @@ ### Backers |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
819765
4691
100