1 |
"use strict";(self.webpackChunkleaderslinked=self.webpackChunkleaderslinked||[]).push([[470],{847:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0});var n=t(7294),s=e=>e instanceof HTMLElement;const c="blur",u="change",i="input",a="onChange",o="onSubmit",l="pattern",f="required";var d=e=>null==e;const y=e=>"object"==typeof e;var g=e=>!d(e)&&!Array.isArray(e)&&y(e)&&!(e instanceof Date),b=e=>/^\w*$/.test(e),m=e=>e.filter(Boolean),h=e=>m(e.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."));function v(e,r,t){let n=-1;const s=b(r)?[r]:h(r),c=s.length,u=c-1;for(;++n<c;){const r=s[n];let c=t;if(n!==u){const t=e[r];c=g(t)||Array.isArray(t)?t:isNaN(+s[n+1])?{}:[]}e[r]=c,e=e[r]}return e}var p=(e,r={})=>{for(const t in e)b(t)?r[t]=e[t]:v(r,t,e[t]);return r},O=e=>void 0===e,A=(e={},r,t)=>{const n=m(r.split(/[,[\].]+?/)).reduce(((e,r)=>d(e)?e:e[r]),e);return O(n)||n===e?O(e[r])?t:e[r]:n},R=(e,r)=>{s(e)&&e.removeEventListener&&(e.removeEventListener(i,r),e.removeEventListener(u,r),e.removeEventListener(c,r))};const V={isValid:!1,value:null};var j=e=>Array.isArray(e)?e.reduce(((e,r)=>r&&r.ref.checked?{isValid:!0,value:r.ref.value}:e),V):V,C=e=>"radio"===e.type,F=e=>"file"===e.type,k=e=>"checkbox"===e.type,S=e=>"select-multiple"===e.type;const x={value:!1,isValid:!1},w={value:!0,isValid:!0};var D=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter((e=>e&&e.ref.checked)).map((({ref:{value:e}})=>e));return{value:r,isValid:!!r.length}}const{checked:r,value:t,attributes:n}=e[0].ref;return r?n&&!O(n.value)?O(t)||""===t?w:{value:t,isValid:!0}:w:x}return x};function E(e,r,t,n,s){const c=e.current[r];if(c){const{ref:{value:e,disabled:r},ref:t,valueAsNumber:i,valueAsDate:a,setValueAs:o}=c;if(r&&n)return;return F(t)?t.files:C(t)?j(c.options).value:S(t)?(u=t.options,[...u].filter((({selected:e})=>e)).map((({value:e})=>e))):k(t)?D(c.options).value:s?e:i?""===e?NaN:+e:a?t.valueAsDate:o?o(e):e}var u;if(t)return A(t.current,r)}function B(e){return!e||e instanceof HTMLElement&&e.nodeType!==Node.DOCUMENT_NODE&&B(e.parentNode)}var N=e=>g(e)&&!Object.keys(e).length,L=e=>"boolean"==typeof e;function W(e,r){const t=b(r)?[r]:h(r),n=1==t.length?e:function(e,r){const t=r.slice(0,-1).length;let n=0;for(;n<t;)e=O(e)?n++:e[r[n++]];return e}(e,t),s=t[t.length-1];let c;n&&delete n[s];for(let r=0;r<t.slice(0,-1).length;r++){let n,s=-1;const u=t.slice(0,-(r+1)),i=u.length-1;for(r>0&&(c=e);++s<u.length;){const r=u[s];n=n?n[r]:e[r],i===s&&(g(n)&&N(n)||Array.isArray(n)&&!n.filter((e=>g(e)&&!N(e)||L(e))).length)&&(c?delete c[r]:delete e[r]),c=n}}return e}const M=(e,r)=>e&&e.ref===r;var T=e=>d(e)||!y(e);function P(e,r){if(T(e)||T(r))return r;for(const t in r){const n=e[t],s=r[t];try{e[t]=g(n)&&g(s)||Array.isArray(n)&&Array.isArray(s)?P(n,s):s}catch(e){}}return e}function $(e,r,t){if(T(e)||T(r)||e instanceof Date||r instanceof Date)return e===r;if(!n.isValidElement(e)){const n=Object.keys(e),s=Object.keys(r);if(n.length!==s.length)return!1;for(const s of n){const n=e[s];if(!t||"ref"!==s){const e=r[s];if((g(n)||Array.isArray(n))&&(g(e)||Array.isArray(e))?!$(n,e,t):n!==e)return!1}}}return!0}function U(e,r,t,n,s){let c=-1;for(;++c<e.length;){for(const n in e[c])Array.isArray(e[c][n])?(!t[c]&&(t[c]={}),t[c][n]=[],U(e[c][n],A(r[c]||{},n,[]),t[c][n],t[c],n)):$(A(r[c]||{},n),e[c][n])?v(t[c]||{},n):t[c]=Object.assign(Object.assign({},t[c]),{[n]:!0});n&&!t.length&&delete n[s]}return t}var H=(e,r,t)=>P(U(e,r,t.slice(0,e.length)),U(r,e,t.slice(0,e.length))),I=e=>"string"==typeof e,_=(e,r,t,n,s)=>{const c={};for(const r in e.current)(O(s)||(I(s)?r.startsWith(s):Array.isArray(s)&&s.find((e=>r.startsWith(e)))))&&(c[r]=E(e,r,void 0,n));return t?p(c):P(r,p(c))},q=e=>e instanceof RegExp,z=e=>g(e)&&!q(e)?e:{value:e,message:""},G=e=>"function"==typeof e,J=e=>I(e)||n.isValidElement(e);function K(e,r,t="validate"){if(J(e)||L(e)&&!e)return{type:t,message:J(e)?e:"",ref:r}}var Q=(e,r,t,n,s)=>r?Object.assign(Object.assign({},t[e]),{types:Object.assign(Object.assign({},t[e]&&t[e].types?t[e].types:{}),{[n]:s||!0})}):{},X=async(e,r,{ref:t,ref:{value:n},options:s,required:c,maxLength:u,minLength:i,min:a,max:o,pattern:y,validate:b},m)=>{const h=t.name,v={},p=C(t),O=k(t),A=p||O,R=""===n,V=Q.bind(null,h,r,v),F=(e,r,n,s="maxLength",c="minLength")=>{const u=e?r:n;v[h]=Object.assign({type:e?s:c,message:u,ref:t},V(e?s:c,u))};if(c&&(!p&&!O&&(R||d(n))||L(n)&&!n||O&&!D(s).isValid||p&&!j(s).isValid)){const{value:n,message:s}=J(c)?{value:!!c,message:c}:z(c);if(n&&(v[h]=Object.assign({type:f,message:s,ref:A?((e.current[h].options||[])[0]||{}).ref:t},V(f,s)),!r))return v}if(!(d(a)&&d(o)||""===n)){let e,s;const c=z(o),u=z(a);if(isNaN(n)){const r=t.valueAsDate||new Date(n);I(c.value)&&(e=r>new Date(c.value)),I(u.value)&&(s=r<new Date(u.value))}else{const r=t.valueAsNumber||parseFloat(n);d(c.value)||(e=r>c.value),d(u.value)||(s=r<u.value)}if((e||s)&&(F(!!e,c.message,u.message,"max","min"),!r))return v}if(I(n)&&!R&&(u||i)){const e=z(u),t=z(i),s=!d(e.value)&&n.length>e.value,c=!d(t.value)&&n.length<t.value;if((s||c)&&(F(s,e.message,t.message),!r))return v}if(I(n)&&y&&!R){const{value:e,message:s}=z(y);if(q(e)&&!e.test(n)&&(v[h]=Object.assign({type:l,message:s,ref:t},V(l,s)),!r))return v}if(b){const n=E(e,h,m,!1,!0),c=A&&s?s[0].ref:t;if(G(b)){const e=K(await b(n),c);if(e&&(v[h]=Object.assign(Object.assign({},e),V("validate",e.message)),!r))return v}else if(g(b)){let e={};for(const[t,s]of Object.entries(b)){if(!N(e)&&!r)break;const u=K(await s(n),c,t);u&&(e=Object.assign(Object.assign({},u),V(t,u.message)),r&&(v[h]=e))}if(!N(e)&&(v[h]=Object.assign({ref:c},e),!r))return v}}return v};const Y=(e,r,t=[])=>{for(const n in r){const s=e+(g(r)?"."+n:`[${n}]`);T(r[n])?t.push(s):Y(s,r[n],t)}return t};var Z=(e,r,t,n,s)=>{let c;return t.add(r),N(e)||(c=A(e,r),(g(c)||Array.isArray(c))&&Y(r,c).forEach((e=>t.add(e)))),O(c)?s?n:A(n,r):c},ee=({isOnBlur:e,isOnChange:r,isOnTouch:t,isTouched:n,isReValidateOnBlur:s,isReValidateOnChange:c,isBlurEvent:u,isSubmitted:i,isOnAll:a})=>!a&&(!i&&t?!(n||u):(i?s:e)?!u:!(i?c:r)||u),re=e=>e.substring(0,e.indexOf("["));const te=(e,r)=>RegExp(`^${r}([|.)\\d+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(e);var ne=(e,r)=>[...e].some((e=>te(r,e))),se="undefined"!=typeof window&&"undefined"!=typeof document;function ce(e){var r;let t;if(T(e)||se&&(e instanceof File||s(e)))return e;if(!["Set","Map","Object","Date","Array"].includes(null===(r=e.constructor)||void 0===r?void 0:r.name))return e;if(e instanceof Date)return t=new Date(e.getTime()),t;if(e instanceof Set){t=new Set;for(const r of e)t.add(r);return t}if(e instanceof Map){t=new Map;for(const r of e.keys())t.set(r,ce(e.get(r)));return t}t=Array.isArray(e)?[]:{};for(const r in e)t[r]=ce(e[r]);return t}var ue=e=>({isOnSubmit:!e||e===o,isOnBlur:"onBlur"===e,isOnChange:e===a,isOnAll:"all"===e,isOnTouch:"onTouched"===e}),ie=e=>C(e)||k(e);const ae="undefined"==typeof window,oe=se?"Proxy"in window:"undefined"!=typeof Proxy;function le(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)r.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(t[n[s]]=e[n[s]])}return t}const fe=n.createContext(null);fe.displayName="RHFContext";const de=()=>n.useContext(fe);var ye=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(r=>{const t=(16*Math.random()+e)%16|0;return("x"==r?t:3&t|8).toString(16)}))},ge=(e,r)=>O(r)?[]:function(e,r){let t=0;const n=[...e];for(const e of r)n.splice(e-t,1),t++;return m(n).length?n:[]}(e,(Array.isArray(r)?r:[r]).sort(((e,r)=>e-r))),be=(e,r,t)=>Array.isArray(e)?(O(e[t])&&(e[t]=void 0),e.splice(t,0,e.splice(r,1)[0]),e):[],me=(e,r,t)=>{const n=[e[t],e[r]];e[r]=n[0],e[t]=n[1]};function he(e,r){return[...Array.isArray(r)?r:[r||void 0],...e]}function ve(e,r,t){return[...e.slice(0,r),...Array.isArray(t)?t:[t||void 0],...e.slice(r)]}var pe=e=>Array.isArray(e)?Array(e.length).fill(void 0):void 0,Oe=e=>(Array.isArray(e)?e:[e]).map((e=>{if(g(e)){const r={};for(const t in e)r[t]=!0;return r}return!0}));const Ae=(e=[],r,t)=>e.map((e=>Object.assign({[r]:e[r]||ye()},e)));function Re({name:e,rules:r,defaultValue:t,control:s,onFocus:c}){const u=de(),{defaultValuesRef:i,setValue:a,register:o,unregister:l,trigger:f,mode:d,reValidateMode:{isReValidateOnBlur:y,isReValidateOnChange:b},formState:m,formStateRef:{current:{isSubmitted:h,touched:p,errors:R}},updateFormState:V,readFormStateRef:j,fieldsRef:C,fieldArrayNamesRef:F,shallowFieldsStateRef:k}=s||u.control,S=!ne(F.current,e),x=()=>!O(A(k.current,e))&&S?A(k.current,e):O(t)?A(i.current,e):t,[w,D]=n.useState(x()),E=n.useRef(w),B=n.useRef({focus:()=>null}),N=n.useRef(c||(()=>{G(B.current.focus)&&B.current.focus()})),L=n.useCallback((r=>!ee(Object.assign({isBlurEvent:r,isReValidateOnBlur:y,isReValidateOnChange:b,isSubmitted:h,isTouched:!!A(p,e)},d))),[y,b,h,p,e,d]),W=n.useCallback((([e])=>{const r=(e=>T(e)||!g(e.target)||g(e.target)&&!e.type?e:O(e.target.value)?e.target.checked:e.target.value)(e);return D(r),E.current=r,r}),[]),M=n.useCallback((t=>{C.current[e]?C.current[e]=Object.assign({ref:C.current[e].ref},r):(o(Object.defineProperties({name:e,focus:N.current},{value:{set(e){D(e),E.current=e},get:()=>E.current}}),r),t=O(A(i.current,e))),t&&S&&D(x())}),[r,e,o]);n.useEffect((()=>()=>l(e)),[e]),n.useEffect((()=>{M()}),[M]),n.useEffect((()=>{!C.current[e]&&M(!0)}));const P=n.useCallback((()=>{j.current.touched&&!A(p,e)&&(v(p,e,!0),V({touched:p})),L(!0)&&f(e)}),[e,V,L,f,j]);return{field:{onChange:n.useCallback(((...r)=>a(e,W(r),{shouldValidate:L(),shouldDirty:!0})),[a,e,L]),onBlur:P,name:e,value:w,ref:B},meta:Object.defineProperties({invalid:!!A(R,e)},{isDirty:{get:()=>!!A(m.dirtyFields,e)},isTouched:{get:()=>!!A(m.touched,e)}})}}r.Controller=e=>{const{rules:r,as:t,render:s,defaultValue:c,control:u,onFocus:i}=e,a=le(e,["rules","as","render","defaultValue","control","onFocus"]),{field:o,meta:l}=Re(e),f=Object.assign(Object.assign({},a),o);return t?n.isValidElement(t)?n.cloneElement(t,f):n.createElement(t,f):s?s(o,l):null},r.FormProvider=e=>{var{children:r}=e,t=le(e,["children"]);return n.createElement(fe.Provider,{value:Object.assign({},t)},r)},r.appendErrors=Q,r.get=A,r.transformToNestObject=p,r.useController=Re,r.useFieldArray=({control:e,name:r,keyName:t="id"})=>{const s=de(),c=n.useRef(-1),u=n.useRef(!1),{isFormDirty:i,updateWatchedValue:a,resetFieldArrayFunctionRef:o,fieldArrayNamesRef:l,fieldsRef:f,defaultValuesRef:d,removeFieldEventListener:y,formStateRef:g,shallowFieldsStateRef:b,updateFormState:h,readFormStateRef:p,validFieldsRef:O,fieldsWithValidationRef:R,fieldArrayDefaultValuesRef:V,validateResolver:j,getValues:C,shouldUnregister:F,fieldArrayValuesRef:k}=e||s.control,S=e=>A(F?e:b.current,r,[]),x=re(r),w=n.useRef([...A(V.current,x)?S(V.current):S(d.current)]),[D,E]=n.useState(Ae(w.current,t));v(k.current,r,m(D));const B=e=>e.map(((e={})=>{var r=t;return e[r],le(e,["symbol"==typeof r?r:r+""])}));l.current.add(r);const N=n.useCallback((()=>A(k.current,r,[])),[r]),L=()=>Ae(A(C(),r,N()).map(((e,r)=>Object.assign(Object.assign({},N()[r]),e))),t);l.current.add(r),x&&!A(V.current,x)&&v(V.current,x,ce(A(d.current,x)));const M=e=>{if(E(e),v(k.current,r,e),p.current.isValid&&j){const t=C();v(t,r,e),j(t)}},T=()=>{for(const e in f.current)te(e,r)&&(y(f.current[e],!0),delete f.current[e])},P=e=>!m(A(e,r,[])).length&&W(e,r),$=e=>{e&&v(g.current.dirtyFields,r,H(B(e),A(d.current,r,[]),A(g.current.dirtyFields,r,[])))},U=(e,t,n,s=[],c=!0,a=!1)=>{if(A(b.current,r)){const n=e(A(b.current,r),t.argA,t.argB);c&&v(b.current,r,n)}if(A(V.current,r)){const n=e(A(V.current,r),t.argA,t.argB);c&&v(V.current,r,n)}if(Array.isArray(A(g.current.errors,r))){const n=e(A(g.current.errors,r),t.argA,t.argB);c&&v(g.current.errors,r,n),P(g.current.errors)}if(p.current.touched&&A(g.current.touched,r)){const n=e(A(g.current.touched,r),t.argA,t.argB);c&&v(g.current.touched,r,n),P(g.current.touched)}(p.current.dirtyFields||p.current.isDirty)&&(v(g.current.dirtyFields,r,H(B(s),A(d.current,r,[]),A(g.current.dirtyFields,r,[]))),$(n),P(g.current.dirtyFields)),a&&p.current.isValid&&!j&&(v(O.current,r,e(A(O.current,r,[]),t.argA)),P(O.current),v(R.current,r,e(A(R.current,r,[]),t.argA)),P(R.current)),!u.current&&p.current.isDirty&&h({isDirty:i(r,B(s))})},I=e=>{const r=L(),t=ge(r,e);M(t),T(),U(ge,{argA:e,argC:e},t,ge(r,e),!0,!0)};return n.useEffect((()=>{const e=A(V.current,r);if(e&&D.length<e.length&&v(V.current,r,e.slice(1)),a(r),c.current>-1)for(const e in f.current){const t=f.current[e];if(e.startsWith(`${r}[${c.current}]`)&&t.ref.focus){t.ref.focus();break}}c.current=-1}),[D,r]),n.useEffect((()=>{const e=o.current,n=l.current;return re(r)||(e[r]=e=>{T(),!e&&W(V.current,r),W(b.current,r),w.current=A(e||d.current,r),u.current||E(Ae(w.current,t))}),()=>{u.current=!0,F&&I(),T(),delete e[r],W(k.current,r),n.delete(r)}}),[]),{swap:n.useCallback(((e,r)=>{const t=L();me(t,e,r),T(),M([...t]),U(me,{argA:e,argB:r,argC:e,argD:r},void 0,t,!1)}),[r]),move:n.useCallback(((e,r)=>{const t=L();be(t,e,r),T(),M([...t]),U(be,{argA:e,argB:r,argC:e,argD:r},void 0,t,!1)}),[r]),prepend:n.useCallback(((e,r=!0)=>{const n=pe(e),s=he(L(),Ae(Array.isArray(e)?e:[e],t));M(s),T(),U(he,{argA:n,argC:Oe(e)},s),c.current=r?0:-1}),[r]),append:n.useCallback(((e,n=!0)=>{const s=Array.isArray(e)?e:[e],u=[...L(),...Ae(s,t)];M(u),(p.current.dirtyFields||p.current.isDirty)&&($(u),h({isDirty:!0,dirtyFields:g.current.dirtyFields})),!F&&v(b.current,r,[...A(b.current,r)||[],...ce(s)]),c.current=n?A(k.current,r).length-1:-1}),[r]),remove:n.useCallback(I,[r]),insert:n.useCallback(((e,r,n=!0)=>{const s=pe(r),u=L(),i=ve(u,e,Ae(Array.isArray(r)?r:[r],t));M(i),T(),U(ve,{argA:e,argB:s,argC:e,argD:Oe(r)},i,ve(u,e)),c.current=n?e:-1}),[r]),fields:m(D)}},r.useForm=function({mode:e=o,reValidateMode:r=a,resolver:t,context:l,defaultValues:f={},shouldFocusError:y=!0,shouldUnregister:h=!0,criteriaMode:V}={}){const j=n.useRef({}),x=n.useRef({}),w=n.useRef({}),D=n.useRef(new Set),L=n.useRef({}),P=n.useRef({}),U=n.useRef({}),q=n.useRef({}),z=n.useRef(f),J=n.useRef(!1),K=n.useRef(!1),Q=n.useRef(),te=n.useRef({}),le=n.useRef({}),fe=n.useRef(l),de=n.useRef(t),ye=n.useRef(new Set),ge=n.useRef(ue(e)),{isOnSubmit:be,isOnTouch:me}=ge.current,he="all"===V,[ve,pe]=n.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!be,errors:{}}),Oe=n.useRef({isDirty:!oe,dirtyFields:!oe,touched:!oe||me,isValidating:!oe,isSubmitting:!oe,isValid:!oe}),Ae=n.useRef(ve),Re=n.useRef(),{isOnBlur:Ve,isOnChange:je}=n.useRef(ue(r)).current;fe.current=l,de.current=t,Ae.current=ve,te.current=h?{}:N(te.current)?ce(f):te.current;const Ce=n.useCallback(((e={})=>{J.current||(Ae.current=Object.assign(Object.assign({},Ae.current),e),pe(Ae.current))}),[]),Fe=()=>Oe.current.isValidating&&Ce({isValidating:!0}),ke=n.useCallback(((e,r,t=!1,n={},s)=>{let c=t||(({errors:e,name:r,error:t,validFields:n,fieldsWithValidation:s})=>{const c=O(t),u=A(e,r);return c&&!!u||!c&&!$(u,t,!0)||c&&A(s,r)&&!A(n,r)})({errors:Ae.current.errors,error:r,name:e,validFields:q.current,fieldsWithValidation:U.current});const u=A(Ae.current.errors,e);r?(W(q.current,e),c=c||!u||!$(u,r,!0),v(Ae.current.errors,e,r)):((A(U.current,e)||de.current)&&(v(q.current,e,!0),c=c||u),W(Ae.current.errors,e)),(c&&!d(t)||!N(n)||Oe.current.isValidating)&&Ce(Object.assign(Object.assign(Object.assign({},n),de.current?{isValid:!!s}:{}),{isValidating:!1}))}),[]),Se=n.useCallback(((e,r)=>{const{ref:t,options:n}=j.current[e],c=se&&s(t)&&d(r)?"":r;C(t)?(n||[]).forEach((({ref:e})=>e.checked=e.value===c)):F(t)&&!I(c)?t.files=c:S(t)?[...t.options].forEach((e=>e.selected=c.includes(e.value))):k(t)&&n?n.length>1?n.forEach((({ref:e})=>e.checked=Array.isArray(c)?!!c.find((r=>r===e.value)):c===e.value)):n[0].ref.checked=!!c:t.value=c}),[]),xe=n.useCallback(((e,r)=>{if(Oe.current.isDirty){const t=Pe();return e&&r&&v(t,e,r),!$(t,z.current)}return!1}),[]),we=n.useCallback(((e,r=!0)=>{if(Oe.current.isDirty||Oe.current.dirtyFields){const t=!$(A(z.current,e),E(j,e,te)),n=A(Ae.current.dirtyFields,e),s=Ae.current.isDirty;t?v(Ae.current.dirtyFields,e,!0):W(Ae.current.dirtyFields,e);const c={isDirty:xe(),dirtyFields:Ae.current.dirtyFields},u=Oe.current.isDirty&&s!==c.isDirty||Oe.current.dirtyFields&&n!==A(Ae.current.dirtyFields,e);return u&&r&&Ce(c),u?c:{}}return{}}),[]),De=n.useCallback((async(e,r)=>{const t=(await X(j,he,j.current[e],te))[e];return ke(e,t,r),O(t)}),[ke,he]),Ee=n.useCallback((async e=>{const{errors:r}=await de.current(Pe(),fe.current,he),t=Ae.current.isValid;if(Array.isArray(e)){const t=e.map((e=>{const t=A(r,e);return t?v(Ae.current.errors,e,t):W(Ae.current.errors,e),!t})).every(Boolean);return Ce({isValid:N(r),isValidating:!1}),t}{const n=A(r,e);return ke(e,n,t!==N(r),{},N(r)),!n}}),[ke,he]),Be=n.useCallback((async e=>{const r=e||Object.keys(j.current);if(Fe(),de.current)return Ee(r);if(Array.isArray(r)){!e&&(Ae.current.errors={});const t=await Promise.all(r.map((async e=>await De(e,null))));return Ce({isValidating:!1}),t.every(Boolean)}return await De(r)}),[Ee,De]),Ne=n.useCallback(((e,r,{shouldDirty:t,shouldValidate:n})=>{const s={};v(s,e,r);for(const c of Y(e,r))j.current[c]&&(Se(c,A(s,c)),t&&we(c),n&&Be(c))}),[Be,Se,we]),Le=n.useCallback(((e,r,t)=>{if(!h&&!T(r)&&v(te.current,e,Array.isArray(r)?[...r]:Object.assign({},r)),j.current[e])Se(e,r),t.shouldDirty&&we(e),t.shouldValidate&&Be(e);else if(!T(r)&&(Ne(e,r,t),ye.current.has(e))){const n=re(e)||e;v(x.current,e,r),le.current[n]({[n]:A(x.current,n)}),(Oe.current.isDirty||Oe.current.dirtyFields)&&t.shouldDirty&&(v(Ae.current.dirtyFields,e,H(r,A(z.current,e,[]),A(Ae.current.dirtyFields,e,[]))),Ce({isDirty:!$(Object.assign(Object.assign({},Pe()),{[e]:r}),z.current)}))}!h&&v(te.current,e,r)}),[we,Se,Ne]),We=e=>K.current||D.current.has(e)||D.current.has((e.match(/\w+/)||[])[0]),Me=e=>{let r=!0;if(!N(L.current))for(const t in L.current)e&&L.current[t].size&&!L.current[t].has(e)&&!L.current[t].has(re(e))||(P.current[t](),r=!1);return r};function Te(e){if(!h){let r=ce(e);for(const e of ye.current)b(e)&&!r[e]&&(r=Object.assign(Object.assign({},r),{[e]:[]}));return r}return e}function Pe(e){if(I(e))return E(j,e,te);if(Array.isArray(e)){const r={};for(const t of e)v(r,t,E(j,t,te));return r}return Te(_(j,ce(te.current),h))}Q.current=Q.current?Q.current:async({type:e,target:r})=>{let t=r.name;const n=j.current[t];let s,u;if(n){const i=e===c,a=ee(Object.assign({isBlurEvent:i,isReValidateOnChange:je,isReValidateOnBlur:Ve,isTouched:!!A(Ae.current.touched,t),isSubmitted:Ae.current.isSubmitted},ge.current));let o=we(t,!1),l=!N(o)||!i&&We(t);if(i&&!A(Ae.current.touched,t)&&Oe.current.touched&&(v(Ae.current.touched,t,!0),o=Object.assign(Object.assign({},o),{touched:Ae.current.touched})),!h&&k(r)&&v(te.current,t,E(j,t)),a)return!i&&Me(t),(!N(o)||l&&N(o))&&Ce(o);if(Fe(),de.current){const{errors:e}=await de.current(Pe(),fe.current,he),n=Ae.current.isValid;if(s=A(e,t),k(r)&&!s&&de.current){const r=re(t),n=A(e,r,{});n.type&&n.message&&(s=n),r&&(n||A(Ae.current.errors,r))&&(t=r)}u=N(e),n!==u&&(l=!0)}else s=(await X(j,he,n,te))[t];!i&&Me(t),ke(t,s,l,o,u)}};const $e=n.useCallback((async(e={})=>{const r=N(j.current)?z.current:{},{errors:t}=await de.current(Object.assign(Object.assign(Object.assign({},r),Pe()),e),fe.current,he)||{},n=N(t);Ae.current.isValid!==n&&Ce({isValid:n})}),[he]),Ue=n.useCallback(((e,r)=>{!function(e,r,t,n,s,c){const{ref:u,ref:{name:i}}=t,a=e.current[i];if(!s){const r=E(e,i,n);!O(r)&&v(n.current,i,r)}u.type&&a?C(u)||k(u)?Array.isArray(a.options)&&a.options.length?(m(a.options).forEach(((e={},t)=>{(B(e.ref)&&M(e,e.ref)||c)&&(R(e.ref,r),W(a.options,`[${t}]`))})),a.options&&!m(a.options).length&&delete e.current[i]):delete e.current[i]:(B(u)&&M(a,u)||c)&&(R(u,r),delete e.current[i]):delete e.current[i]}(j,Q.current,e,te,h,r),h&&(W(q.current,e.ref.name),W(U.current,e.ref.name))}),[h]),He=n.useCallback((e=>{if(K.current)Ce();else{for(const r of D.current)if(r.startsWith(e)){Ce();break}Me(e)}}),[]),Ie=n.useCallback(((e,r)=>{e&&(Ue(e,r),h&&!m(e.options||[]).length&&(W(Ae.current.errors,e.ref.name),v(Ae.current.dirtyFields,e.ref.name,!0),Ce({isDirty:xe()}),Oe.current.isValid&&de.current&&$e(),He(e.ref.name)))}),[$e,Ue]),_e=n.useCallback(((e,r,t)=>{const n=t?L.current[t]:D.current;let s=_(j,ce(te.current),h,!1,e);if(I(e)){const t=re(e)||e;return ye.current.has(t)&&(s=Object.assign(Object.assign({},w.current),s)),Z(s,e,n,O(A(z.current,e))?r:A(z.current,e),!0)}const c=O(r)?z.current:r;return Array.isArray(e)?e.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:Z(s,r,n,c)})),{}):(K.current=O(t),p(!N(s)&&s||c))}),[]);function qe(e,r={}){const{name:t,type:n,value:a}=e,o=Object.assign({ref:e},r),l=j.current,f=ie(e),d=ne(ye.current,t),y=r=>se&&(!s(e)||r===e);let g,b=l[t],p=!0;if(b&&(f?Array.isArray(b.options)&&m(b.options).find((e=>a===e.ref.value&&y(e.ref))):y(b.ref)))return void(l[t]=Object.assign(Object.assign({},b),r));b=n?f?Object.assign({options:[...m(b&&b.options||[]),{ref:e}],ref:{type:n,name:t}},r):Object.assign({},o):o,l[t]=b;const R=O(A(te.current,t));N(z.current)&&R||(g=A(R?z.current:te.current,t),p=O(g),p||d||Se(t,g)),N(r)||(v(U.current,t,!0),!be&&Oe.current.isValid&&X(j,he,b,te).then((e=>{const r=Ae.current.isValid;N(e)?v(q.current,t,!0):W(q.current,t),r!==N(e)&&Ce()}))),!h||d&&p||!d&&W(Ae.current.dirtyFields,t),n&&function({ref:e},r,t){s(e)&&t&&(e.addEventListener(r?u:i,t),e.addEventListener(c,t))}(f&&b.options?b.options[b.options.length-1]:b,f||"select-one"===e.type,Q.current)}const ze=n.useCallback(((e,r)=>async t=>{t&&t.preventDefault&&(t.preventDefault(),t.persist());let n={},s=Te(_(j,ce(te.current),h,!0));Oe.current.isSubmitting&&Ce({isSubmitting:!0});try{if(de.current){const{errors:e,values:r}=await de.current(s,fe.current,he);Ae.current.errors=n=e,s=r}else for(const e of Object.values(j.current))if(e){const{name:r}=e.ref,t=await X(j,he,e,te);t[r]?(v(n,r,t[r]),W(q.current,r)):A(U.current,r)&&(W(Ae.current.errors,r),v(q.current,r,!0))}N(n)&&Object.keys(Ae.current.errors).every((e=>e in j.current))?(Ce({errors:{},isSubmitting:!0}),await e(s,t)):(Ae.current.errors=Object.assign(Object.assign({},Ae.current.errors),n),r&&await r(Ae.current.errors,t),y&&((e,r)=>{for(const t in e)if(A(r,t)){const r=e[t];if(r){if(r.ref.focus&&O(r.ref.focus()))break;if(r.options){r.options[0].ref.focus();break}}}})(j.current,Ae.current.errors))}finally{Ae.current.isSubmitting=!1,Ce({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:N(Ae.current.errors),submitCount:Ae.current.submitCount+1})}}),[y,he]);n.useEffect((()=>{t&&Oe.current.isValid&&$e(),Re.current=Re.current||!se?Re.current:function(e,r){const t=new MutationObserver((()=>{for(const t of Object.values(e.current))if(t&&t.options)for(const e of t.options)e&&e.ref&&B(e.ref)&&r(t);else t&&B(t.ref)&&r(t)}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(j,Ie)}),[Ie,z.current]),n.useEffect((()=>()=>{Re.current&&Re.current.disconnect(),J.current=!0,Object.values(j.current).forEach((e=>Ie(e,!0)))}),[]),!t&&Oe.current.isValid&&(ve.isValid=$(q.current,U.current)&&N(Ae.current.errors));const Ge={trigger:Be,setValue:n.useCallback((function(e,r,t){Le(e,r,t||{}),We(e)&&Ce(),Me(e)}),[Le,Be]),getValues:n.useCallback(Pe,[]),register:n.useCallback((function(e,r){if(!ae)if(I(e))qe({name:e},r);else{if(!g(e)||!("name"in e))return r=>r&&qe(r,e);qe(e,r)}}),[z.current]),unregister:n.useCallback((function(e){for(const r of Array.isArray(e)?e:[e])Ie(j.current[r],!0)}),[]),formState:oe?new Proxy(ve,{get:(e,r)=>{if(r in e)return Oe.current[r]=!0,e[r]}}):ve},Je=n.useMemo((()=>Object.assign({isFormDirty:xe,updateWatchedValue:He,shouldUnregister:h,updateFormState:Ce,removeFieldEventListener:Ue,watchInternal:_e,mode:ge.current,reValidateMode:{isReValidateOnBlur:Ve,isReValidateOnChange:je},validateResolver:t?$e:void 0,fieldsRef:j,resetFieldArrayFunctionRef:le,useWatchFieldsRef:L,useWatchRenderFunctionsRef:P,fieldArrayDefaultValuesRef:x,validFieldsRef:q,fieldsWithValidationRef:U,fieldArrayNamesRef:ye,readFormStateRef:Oe,formStateRef:Ae,defaultValuesRef:z,shallowFieldsStateRef:te,fieldArrayValuesRef:w},Ge)),[z.current,He,h,Ue,_e]);return Object.assign({watch:function(e,r){return _e(e,r)},control:Je,handleSubmit:ze,reset:n.useCallback(((e,r={})=>{if(se)for(const r of Object.values(j.current))if(r){const{ref:t,options:n}=r,c=ie(t)&&Array.isArray(n)?n[0].ref:t;if(s(c))try{c.closest("form").reset();break}catch(e){}}j.current={},z.current=Object.assign({},e||z.current),e&&Me(""),Object.values(le.current).forEach((e=>G(e)&&e())),te.current=h?{}:ce(e||z.current),(({errors:e,isDirty:r,isSubmitted:t,touched:n,isValid:s,submitCount:c,dirtyFields:u})=>{s||(q.current={},U.current={}),x.current={},D.current=new Set,K.current=!1,Ce({submitCount:c?Ae.current.submitCount:0,isDirty:!!r&&Ae.current.isDirty,isSubmitted:!!t&&Ae.current.isSubmitted,isValid:!!s&&Ae.current.isValid,dirtyFields:u?Ae.current.dirtyFields:{},touched:n?Ae.current.touched:{},errors:e?Ae.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})})(r)}),[]),clearErrors:n.useCallback((function(e){e&&(Array.isArray(e)?e:[e]).forEach((e=>j.current[e]&&b(e)?delete Ae.current.errors[e]:W(Ae.current.errors,e))),Ce({errors:e?Ae.current.errors:{}})}),[]),setError:n.useCallback((function(e,r){const t=(j.current[e]||{}).ref;v(Ae.current.errors,e,Object.assign(Object.assign({},r),{ref:t})),Ce({isValid:!1}),r.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:ve.errors},Ge)},r.useFormContext=de,r.useWatch=function({control:e,name:r,defaultValue:t}){const s=de(),{useWatchFieldsRef:c,useWatchRenderFunctionsRef:u,watchInternal:i,defaultValuesRef:a}=e||s.control,o=n.useState()[1],l=n.useRef(),f=n.useRef(t);return n.useEffect((()=>{const e=l.current=ye(),t=u.current,n=c.current;return n[e]=new Set,t[e]=()=>o({}),i(r,f.current,e),()=>{delete n[e],delete t[e]}}),[r,u,c,i,f]),l.current?i(r,f.current,l.current):O(t)?I(r)?A(a.current,r):Array.isArray(r)?r.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:A(a.current,r)})),{}):a.current:t}},3470:(e,r,t)=>{e.exports=t(847)}}]);
|
- |
|
2 |
|
1 |
"use strict";(self.webpackChunkleaderslinked=self.webpackChunkleaderslinked||[]).push([[470],{40847:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0});var n=t(67294),s=e=>e instanceof HTMLElement;const c="blur",u="change",i="input",a="onChange",o="onSubmit",l="pattern",f="required";var d=e=>null==e;const y=e=>"object"==typeof e;var g=e=>!d(e)&&!Array.isArray(e)&&y(e)&&!(e instanceof Date),b=e=>/^\w*$/.test(e),m=e=>e.filter(Boolean),h=e=>m(e.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."));function v(e,r,t){let n=-1;const s=b(r)?[r]:h(r),c=s.length,u=c-1;for(;++n<c;){const r=s[n];let c=t;if(n!==u){const t=e[r];c=g(t)||Array.isArray(t)?t:isNaN(+s[n+1])?{}:[]}e[r]=c,e=e[r]}return e}var p=(e,r={})=>{for(const t in e)b(t)?r[t]=e[t]:v(r,t,e[t]);return r},O=e=>void 0===e,A=(e={},r,t)=>{const n=m(r.split(/[,[\].]+?/)).reduce(((e,r)=>d(e)?e:e[r]),e);return O(n)||n===e?O(e[r])?t:e[r]:n},R=(e,r)=>{s(e)&&e.removeEventListener&&(e.removeEventListener(i,r),e.removeEventListener(u,r),e.removeEventListener(c,r))};const V={isValid:!1,value:null};var j=e=>Array.isArray(e)?e.reduce(((e,r)=>r&&r.ref.checked?{isValid:!0,value:r.ref.value}:e),V):V,C=e=>"radio"===e.type,F=e=>"file"===e.type,k=e=>"checkbox"===e.type,S=e=>"select-multiple"===e.type;const x={value:!1,isValid:!1},w={value:!0,isValid:!0};var D=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter((e=>e&&e.ref.checked)).map((({ref:{value:e}})=>e));return{value:r,isValid:!!r.length}}const{checked:r,value:t,attributes:n}=e[0].ref;return r?n&&!O(n.value)?O(t)||""===t?w:{value:t,isValid:!0}:w:x}return x};function E(e,r,t,n,s){const c=e.current[r];if(c){const{ref:{value:e,disabled:r},ref:t,valueAsNumber:i,valueAsDate:a,setValueAs:o}=c;if(r&&n)return;return F(t)?t.files:C(t)?j(c.options).value:S(t)?(u=t.options,[...u].filter((({selected:e})=>e)).map((({value:e})=>e))):k(t)?D(c.options).value:s?e:i?""===e?NaN:+e:a?t.valueAsDate:o?o(e):e}var u;if(t)return A(t.current,r)}function B(e){return!e||e instanceof HTMLElement&&e.nodeType!==Node.DOCUMENT_NODE&&B(e.parentNode)}var N=e=>g(e)&&!Object.keys(e).length,L=e=>"boolean"==typeof e;function W(e,r){const t=b(r)?[r]:h(r),n=1==t.length?e:function(e,r){const t=r.slice(0,-1).length;let n=0;for(;n<t;)e=O(e)?n++:e[r[n++]];return e}(e,t),s=t[t.length-1];let c;n&&delete n[s];for(let r=0;r<t.slice(0,-1).length;r++){let n,s=-1;const u=t.slice(0,-(r+1)),i=u.length-1;for(r>0&&(c=e);++s<u.length;){const r=u[s];n=n?n[r]:e[r],i===s&&(g(n)&&N(n)||Array.isArray(n)&&!n.filter((e=>g(e)&&!N(e)||L(e))).length)&&(c?delete c[r]:delete e[r]),c=n}}return e}const M=(e,r)=>e&&e.ref===r;var T=e=>d(e)||!y(e);function P(e,r){if(T(e)||T(r))return r;for(const t in r){const n=e[t],s=r[t];try{e[t]=g(n)&&g(s)||Array.isArray(n)&&Array.isArray(s)?P(n,s):s}catch(e){}}return e}function $(e,r,t){if(T(e)||T(r)||e instanceof Date||r instanceof Date)return e===r;if(!n.isValidElement(e)){const n=Object.keys(e),s=Object.keys(r);if(n.length!==s.length)return!1;for(const s of n){const n=e[s];if(!t||"ref"!==s){const e=r[s];if((g(n)||Array.isArray(n))&&(g(e)||Array.isArray(e))?!$(n,e,t):n!==e)return!1}}}return!0}function U(e,r,t,n,s){let c=-1;for(;++c<e.length;){for(const n in e[c])Array.isArray(e[c][n])?(!t[c]&&(t[c]={}),t[c][n]=[],U(e[c][n],A(r[c]||{},n,[]),t[c][n],t[c],n)):$(A(r[c]||{},n),e[c][n])?v(t[c]||{},n):t[c]=Object.assign(Object.assign({},t[c]),{[n]:!0});n&&!t.length&&delete n[s]}return t}var H=(e,r,t)=>P(U(e,r,t.slice(0,e.length)),U(r,e,t.slice(0,e.length))),I=e=>"string"==typeof e,_=(e,r,t,n,s)=>{const c={};for(const r in e.current)(O(s)||(I(s)?r.startsWith(s):Array.isArray(s)&&s.find((e=>r.startsWith(e)))))&&(c[r]=E(e,r,void 0,n));return t?p(c):P(r,p(c))},q=e=>e instanceof RegExp,z=e=>g(e)&&!q(e)?e:{value:e,message:""},G=e=>"function"==typeof e,J=e=>I(e)||n.isValidElement(e);function K(e,r,t="validate"){if(J(e)||L(e)&&!e)return{type:t,message:J(e)?e:"",ref:r}}var Q=(e,r,t,n,s)=>r?Object.assign(Object.assign({},t[e]),{types:Object.assign(Object.assign({},t[e]&&t[e].types?t[e].types:{}),{[n]:s||!0})}):{},X=async(e,r,{ref:t,ref:{value:n},options:s,required:c,maxLength:u,minLength:i,min:a,max:o,pattern:y,validate:b},m)=>{const h=t.name,v={},p=C(t),O=k(t),A=p||O,R=""===n,V=Q.bind(null,h,r,v),F=(e,r,n,s="maxLength",c="minLength")=>{const u=e?r:n;v[h]=Object.assign({type:e?s:c,message:u,ref:t},V(e?s:c,u))};if(c&&(!p&&!O&&(R||d(n))||L(n)&&!n||O&&!D(s).isValid||p&&!j(s).isValid)){const{value:n,message:s}=J(c)?{value:!!c,message:c}:z(c);if(n&&(v[h]=Object.assign({type:f,message:s,ref:A?((e.current[h].options||[])[0]||{}).ref:t},V(f,s)),!r))return v}if(!(d(a)&&d(o)||""===n)){let e,s;const c=z(o),u=z(a);if(isNaN(n)){const r=t.valueAsDate||new Date(n);I(c.value)&&(e=r>new Date(c.value)),I(u.value)&&(s=r<new Date(u.value))}else{const r=t.valueAsNumber||parseFloat(n);d(c.value)||(e=r>c.value),d(u.value)||(s=r<u.value)}if((e||s)&&(F(!!e,c.message,u.message,"max","min"),!r))return v}if(I(n)&&!R&&(u||i)){const e=z(u),t=z(i),s=!d(e.value)&&n.length>e.value,c=!d(t.value)&&n.length<t.value;if((s||c)&&(F(s,e.message,t.message),!r))return v}if(I(n)&&y&&!R){const{value:e,message:s}=z(y);if(q(e)&&!e.test(n)&&(v[h]=Object.assign({type:l,message:s,ref:t},V(l,s)),!r))return v}if(b){const n=E(e,h,m,!1,!0),c=A&&s?s[0].ref:t;if(G(b)){const e=K(await b(n),c);if(e&&(v[h]=Object.assign(Object.assign({},e),V("validate",e.message)),!r))return v}else if(g(b)){let e={};for(const[t,s]of Object.entries(b)){if(!N(e)&&!r)break;const u=K(await s(n),c,t);u&&(e=Object.assign(Object.assign({},u),V(t,u.message)),r&&(v[h]=e))}if(!N(e)&&(v[h]=Object.assign({ref:c},e),!r))return v}}return v};const Y=(e,r,t=[])=>{for(const n in r){const s=e+(g(r)?"."+n:`[${n}]`);T(r[n])?t.push(s):Y(s,r[n],t)}return t};var Z=(e,r,t,n,s)=>{let c;return t.add(r),N(e)||(c=A(e,r),(g(c)||Array.isArray(c))&&Y(r,c).forEach((e=>t.add(e)))),O(c)?s?n:A(n,r):c},ee=({isOnBlur:e,isOnChange:r,isOnTouch:t,isTouched:n,isReValidateOnBlur:s,isReValidateOnChange:c,isBlurEvent:u,isSubmitted:i,isOnAll:a})=>!a&&(!i&&t?!(n||u):(i?s:e)?!u:!(i?c:r)||u),re=e=>e.substring(0,e.indexOf("["));const te=(e,r)=>RegExp(`^${r}([|.)\\d+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(e);var ne=(e,r)=>[...e].some((e=>te(r,e))),se="undefined"!=typeof window&&"undefined"!=typeof document;function ce(e){var r;let t;if(T(e)||se&&(e instanceof File||s(e)))return e;if(!["Set","Map","Object","Date","Array"].includes(null===(r=e.constructor)||void 0===r?void 0:r.name))return e;if(e instanceof Date)return t=new Date(e.getTime()),t;if(e instanceof Set){t=new Set;for(const r of e)t.add(r);return t}if(e instanceof Map){t=new Map;for(const r of e.keys())t.set(r,ce(e.get(r)));return t}t=Array.isArray(e)?[]:{};for(const r in e)t[r]=ce(e[r]);return t}var ue=e=>({isOnSubmit:!e||e===o,isOnBlur:"onBlur"===e,isOnChange:e===a,isOnAll:"all"===e,isOnTouch:"onTouched"===e}),ie=e=>C(e)||k(e);const ae="undefined"==typeof window,oe=se?"Proxy"in window:"undefined"!=typeof Proxy;function le(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)r.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(t[n[s]]=e[n[s]])}return t}const fe=n.createContext(null);fe.displayName="RHFContext";const de=()=>n.useContext(fe);var ye=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(r=>{const t=(16*Math.random()+e)%16|0;return("x"==r?t:3&t|8).toString(16)}))},ge=(e,r)=>O(r)?[]:function(e,r){let t=0;const n=[...e];for(const e of r)n.splice(e-t,1),t++;return m(n).length?n:[]}(e,(Array.isArray(r)?r:[r]).sort(((e,r)=>e-r))),be=(e,r,t)=>Array.isArray(e)?(O(e[t])&&(e[t]=void 0),e.splice(t,0,e.splice(r,1)[0]),e):[],me=(e,r,t)=>{const n=[e[t],e[r]];e[r]=n[0],e[t]=n[1]};function he(e,r){return[...Array.isArray(r)?r:[r||void 0],...e]}function ve(e,r,t){return[...e.slice(0,r),...Array.isArray(t)?t:[t||void 0],...e.slice(r)]}var pe=e=>Array.isArray(e)?Array(e.length).fill(void 0):void 0,Oe=e=>(Array.isArray(e)?e:[e]).map((e=>{if(g(e)){const r={};for(const t in e)r[t]=!0;return r}return!0}));const Ae=(e=[],r,t)=>e.map((e=>Object.assign({[r]:e[r]||ye()},e)));function Re({name:e,rules:r,defaultValue:t,control:s,onFocus:c}){const u=de(),{defaultValuesRef:i,setValue:a,register:o,unregister:l,trigger:f,mode:d,reValidateMode:{isReValidateOnBlur:y,isReValidateOnChange:b},formState:m,formStateRef:{current:{isSubmitted:h,touched:p,errors:R}},updateFormState:V,readFormStateRef:j,fieldsRef:C,fieldArrayNamesRef:F,shallowFieldsStateRef:k}=s||u.control,S=!ne(F.current,e),x=()=>!O(A(k.current,e))&&S?A(k.current,e):O(t)?A(i.current,e):t,[w,D]=n.useState(x()),E=n.useRef(w),B=n.useRef({focus:()=>null}),N=n.useRef(c||(()=>{G(B.current.focus)&&B.current.focus()})),L=n.useCallback((r=>!ee(Object.assign({isBlurEvent:r,isReValidateOnBlur:y,isReValidateOnChange:b,isSubmitted:h,isTouched:!!A(p,e)},d))),[y,b,h,p,e,d]),W=n.useCallback((([e])=>{const r=(e=>T(e)||!g(e.target)||g(e.target)&&!e.type?e:O(e.target.value)?e.target.checked:e.target.value)(e);return D(r),E.current=r,r}),[]),M=n.useCallback((t=>{C.current[e]?C.current[e]=Object.assign({ref:C.current[e].ref},r):(o(Object.defineProperties({name:e,focus:N.current},{value:{set(e){D(e),E.current=e},get:()=>E.current}}),r),t=O(A(i.current,e))),t&&S&&D(x())}),[r,e,o]);n.useEffect((()=>()=>l(e)),[e]),n.useEffect((()=>{M()}),[M]),n.useEffect((()=>{!C.current[e]&&M(!0)}));const P=n.useCallback((()=>{j.current.touched&&!A(p,e)&&(v(p,e,!0),V({touched:p})),L(!0)&&f(e)}),[e,V,L,f,j]);return{field:{onChange:n.useCallback(((...r)=>a(e,W(r),{shouldValidate:L(),shouldDirty:!0})),[a,e,L]),onBlur:P,name:e,value:w,ref:B},meta:Object.defineProperties({invalid:!!A(R,e)},{isDirty:{get:()=>!!A(m.dirtyFields,e)},isTouched:{get:()=>!!A(m.touched,e)}})}}r.Controller=e=>{const{rules:r,as:t,render:s,defaultValue:c,control:u,onFocus:i}=e,a=le(e,["rules","as","render","defaultValue","control","onFocus"]),{field:o,meta:l}=Re(e),f=Object.assign(Object.assign({},a),o);return t?n.isValidElement(t)?n.cloneElement(t,f):n.createElement(t,f):s?s(o,l):null},r.FormProvider=e=>{var{children:r}=e,t=le(e,["children"]);return n.createElement(fe.Provider,{value:Object.assign({},t)},r)},r.appendErrors=Q,r.get=A,r.transformToNestObject=p,r.useController=Re,r.useFieldArray=({control:e,name:r,keyName:t="id"})=>{const s=de(),c=n.useRef(-1),u=n.useRef(!1),{isFormDirty:i,updateWatchedValue:a,resetFieldArrayFunctionRef:o,fieldArrayNamesRef:l,fieldsRef:f,defaultValuesRef:d,removeFieldEventListener:y,formStateRef:g,shallowFieldsStateRef:b,updateFormState:h,readFormStateRef:p,validFieldsRef:O,fieldsWithValidationRef:R,fieldArrayDefaultValuesRef:V,validateResolver:j,getValues:C,shouldUnregister:F,fieldArrayValuesRef:k}=e||s.control,S=e=>A(F?e:b.current,r,[]),x=re(r),w=n.useRef([...A(V.current,x)?S(V.current):S(d.current)]),[D,E]=n.useState(Ae(w.current,t));v(k.current,r,m(D));const B=e=>e.map(((e={})=>{var r=t;return e[r],le(e,["symbol"==typeof r?r:r+""])}));l.current.add(r);const N=n.useCallback((()=>A(k.current,r,[])),[r]),L=()=>Ae(A(C(),r,N()).map(((e,r)=>Object.assign(Object.assign({},N()[r]),e))),t);l.current.add(r),x&&!A(V.current,x)&&v(V.current,x,ce(A(d.current,x)));const M=e=>{if(E(e),v(k.current,r,e),p.current.isValid&&j){const t=C();v(t,r,e),j(t)}},T=()=>{for(const e in f.current)te(e,r)&&(y(f.current[e],!0),delete f.current[e])},P=e=>!m(A(e,r,[])).length&&W(e,r),$=e=>{e&&v(g.current.dirtyFields,r,H(B(e),A(d.current,r,[]),A(g.current.dirtyFields,r,[])))},U=(e,t,n,s=[],c=!0,a=!1)=>{if(A(b.current,r)){const n=e(A(b.current,r),t.argA,t.argB);c&&v(b.current,r,n)}if(A(V.current,r)){const n=e(A(V.current,r),t.argA,t.argB);c&&v(V.current,r,n)}if(Array.isArray(A(g.current.errors,r))){const n=e(A(g.current.errors,r),t.argA,t.argB);c&&v(g.current.errors,r,n),P(g.current.errors)}if(p.current.touched&&A(g.current.touched,r)){const n=e(A(g.current.touched,r),t.argA,t.argB);c&&v(g.current.touched,r,n),P(g.current.touched)}(p.current.dirtyFields||p.current.isDirty)&&(v(g.current.dirtyFields,r,H(B(s),A(d.current,r,[]),A(g.current.dirtyFields,r,[]))),$(n),P(g.current.dirtyFields)),a&&p.current.isValid&&!j&&(v(O.current,r,e(A(O.current,r,[]),t.argA)),P(O.current),v(R.current,r,e(A(R.current,r,[]),t.argA)),P(R.current)),!u.current&&p.current.isDirty&&h({isDirty:i(r,B(s))})},I=e=>{const r=L(),t=ge(r,e);M(t),T(),U(ge,{argA:e,argC:e},t,ge(r,e),!0,!0)};return n.useEffect((()=>{const e=A(V.current,r);if(e&&D.length<e.length&&v(V.current,r,e.slice(1)),a(r),c.current>-1)for(const e in f.current){const t=f.current[e];if(e.startsWith(`${r}[${c.current}]`)&&t.ref.focus){t.ref.focus();break}}c.current=-1}),[D,r]),n.useEffect((()=>{const e=o.current,n=l.current;return re(r)||(e[r]=e=>{T(),!e&&W(V.current,r),W(b.current,r),w.current=A(e||d.current,r),u.current||E(Ae(w.current,t))}),()=>{u.current=!0,F&&I(),T(),delete e[r],W(k.current,r),n.delete(r)}}),[]),{swap:n.useCallback(((e,r)=>{const t=L();me(t,e,r),T(),M([...t]),U(me,{argA:e,argB:r,argC:e,argD:r},void 0,t,!1)}),[r]),move:n.useCallback(((e,r)=>{const t=L();be(t,e,r),T(),M([...t]),U(be,{argA:e,argB:r,argC:e,argD:r},void 0,t,!1)}),[r]),prepend:n.useCallback(((e,r=!0)=>{const n=pe(e),s=he(L(),Ae(Array.isArray(e)?e:[e],t));M(s),T(),U(he,{argA:n,argC:Oe(e)},s),c.current=r?0:-1}),[r]),append:n.useCallback(((e,n=!0)=>{const s=Array.isArray(e)?e:[e],u=[...L(),...Ae(s,t)];M(u),(p.current.dirtyFields||p.current.isDirty)&&($(u),h({isDirty:!0,dirtyFields:g.current.dirtyFields})),!F&&v(b.current,r,[...A(b.current,r)||[],...ce(s)]),c.current=n?A(k.current,r).length-1:-1}),[r]),remove:n.useCallback(I,[r]),insert:n.useCallback(((e,r,n=!0)=>{const s=pe(r),u=L(),i=ve(u,e,Ae(Array.isArray(r)?r:[r],t));M(i),T(),U(ve,{argA:e,argB:s,argC:e,argD:Oe(r)},i,ve(u,e)),c.current=n?e:-1}),[r]),fields:m(D)}},r.useForm=function({mode:e=o,reValidateMode:r=a,resolver:t,context:l,defaultValues:f={},shouldFocusError:y=!0,shouldUnregister:h=!0,criteriaMode:V}={}){const j=n.useRef({}),x=n.useRef({}),w=n.useRef({}),D=n.useRef(new Set),L=n.useRef({}),P=n.useRef({}),U=n.useRef({}),q=n.useRef({}),z=n.useRef(f),J=n.useRef(!1),K=n.useRef(!1),Q=n.useRef(),te=n.useRef({}),le=n.useRef({}),fe=n.useRef(l),de=n.useRef(t),ye=n.useRef(new Set),ge=n.useRef(ue(e)),{isOnSubmit:be,isOnTouch:me}=ge.current,he="all"===V,[ve,pe]=n.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!be,errors:{}}),Oe=n.useRef({isDirty:!oe,dirtyFields:!oe,touched:!oe||me,isValidating:!oe,isSubmitting:!oe,isValid:!oe}),Ae=n.useRef(ve),Re=n.useRef(),{isOnBlur:Ve,isOnChange:je}=n.useRef(ue(r)).current;fe.current=l,de.current=t,Ae.current=ve,te.current=h?{}:N(te.current)?ce(f):te.current;const Ce=n.useCallback(((e={})=>{J.current||(Ae.current=Object.assign(Object.assign({},Ae.current),e),pe(Ae.current))}),[]),Fe=()=>Oe.current.isValidating&&Ce({isValidating:!0}),ke=n.useCallback(((e,r,t=!1,n={},s)=>{let c=t||(({errors:e,name:r,error:t,validFields:n,fieldsWithValidation:s})=>{const c=O(t),u=A(e,r);return c&&!!u||!c&&!$(u,t,!0)||c&&A(s,r)&&!A(n,r)})({errors:Ae.current.errors,error:r,name:e,validFields:q.current,fieldsWithValidation:U.current});const u=A(Ae.current.errors,e);r?(W(q.current,e),c=c||!u||!$(u,r,!0),v(Ae.current.errors,e,r)):((A(U.current,e)||de.current)&&(v(q.current,e,!0),c=c||u),W(Ae.current.errors,e)),(c&&!d(t)||!N(n)||Oe.current.isValidating)&&Ce(Object.assign(Object.assign(Object.assign({},n),de.current?{isValid:!!s}:{}),{isValidating:!1}))}),[]),Se=n.useCallback(((e,r)=>{const{ref:t,options:n}=j.current[e],c=se&&s(t)&&d(r)?"":r;C(t)?(n||[]).forEach((({ref:e})=>e.checked=e.value===c)):F(t)&&!I(c)?t.files=c:S(t)?[...t.options].forEach((e=>e.selected=c.includes(e.value))):k(t)&&n?n.length>1?n.forEach((({ref:e})=>e.checked=Array.isArray(c)?!!c.find((r=>r===e.value)):c===e.value)):n[0].ref.checked=!!c:t.value=c}),[]),xe=n.useCallback(((e,r)=>{if(Oe.current.isDirty){const t=Pe();return e&&r&&v(t,e,r),!$(t,z.current)}return!1}),[]),we=n.useCallback(((e,r=!0)=>{if(Oe.current.isDirty||Oe.current.dirtyFields){const t=!$(A(z.current,e),E(j,e,te)),n=A(Ae.current.dirtyFields,e),s=Ae.current.isDirty;t?v(Ae.current.dirtyFields,e,!0):W(Ae.current.dirtyFields,e);const c={isDirty:xe(),dirtyFields:Ae.current.dirtyFields},u=Oe.current.isDirty&&s!==c.isDirty||Oe.current.dirtyFields&&n!==A(Ae.current.dirtyFields,e);return u&&r&&Ce(c),u?c:{}}return{}}),[]),De=n.useCallback((async(e,r)=>{const t=(await X(j,he,j.current[e],te))[e];return ke(e,t,r),O(t)}),[ke,he]),Ee=n.useCallback((async e=>{const{errors:r}=await de.current(Pe(),fe.current,he),t=Ae.current.isValid;if(Array.isArray(e)){const t=e.map((e=>{const t=A(r,e);return t?v(Ae.current.errors,e,t):W(Ae.current.errors,e),!t})).every(Boolean);return Ce({isValid:N(r),isValidating:!1}),t}{const n=A(r,e);return ke(e,n,t!==N(r),{},N(r)),!n}}),[ke,he]),Be=n.useCallback((async e=>{const r=e||Object.keys(j.current);if(Fe(),de.current)return Ee(r);if(Array.isArray(r)){!e&&(Ae.current.errors={});const t=await Promise.all(r.map((async e=>await De(e,null))));return Ce({isValidating:!1}),t.every(Boolean)}return await De(r)}),[Ee,De]),Ne=n.useCallback(((e,r,{shouldDirty:t,shouldValidate:n})=>{const s={};v(s,e,r);for(const c of Y(e,r))j.current[c]&&(Se(c,A(s,c)),t&&we(c),n&&Be(c))}),[Be,Se,we]),Le=n.useCallback(((e,r,t)=>{if(!h&&!T(r)&&v(te.current,e,Array.isArray(r)?[...r]:Object.assign({},r)),j.current[e])Se(e,r),t.shouldDirty&&we(e),t.shouldValidate&&Be(e);else if(!T(r)&&(Ne(e,r,t),ye.current.has(e))){const n=re(e)||e;v(x.current,e,r),le.current[n]({[n]:A(x.current,n)}),(Oe.current.isDirty||Oe.current.dirtyFields)&&t.shouldDirty&&(v(Ae.current.dirtyFields,e,H(r,A(z.current,e,[]),A(Ae.current.dirtyFields,e,[]))),Ce({isDirty:!$(Object.assign(Object.assign({},Pe()),{[e]:r}),z.current)}))}!h&&v(te.current,e,r)}),[we,Se,Ne]),We=e=>K.current||D.current.has(e)||D.current.has((e.match(/\w+/)||[])[0]),Me=e=>{let r=!0;if(!N(L.current))for(const t in L.current)e&&L.current[t].size&&!L.current[t].has(e)&&!L.current[t].has(re(e))||(P.current[t](),r=!1);return r};function Te(e){if(!h){let r=ce(e);for(const e of ye.current)b(e)&&!r[e]&&(r=Object.assign(Object.assign({},r),{[e]:[]}));return r}return e}function Pe(e){if(I(e))return E(j,e,te);if(Array.isArray(e)){const r={};for(const t of e)v(r,t,E(j,t,te));return r}return Te(_(j,ce(te.current),h))}Q.current=Q.current?Q.current:async({type:e,target:r})=>{let t=r.name;const n=j.current[t];let s,u;if(n){const i=e===c,a=ee(Object.assign({isBlurEvent:i,isReValidateOnChange:je,isReValidateOnBlur:Ve,isTouched:!!A(Ae.current.touched,t),isSubmitted:Ae.current.isSubmitted},ge.current));let o=we(t,!1),l=!N(o)||!i&&We(t);if(i&&!A(Ae.current.touched,t)&&Oe.current.touched&&(v(Ae.current.touched,t,!0),o=Object.assign(Object.assign({},o),{touched:Ae.current.touched})),!h&&k(r)&&v(te.current,t,E(j,t)),a)return!i&&Me(t),(!N(o)||l&&N(o))&&Ce(o);if(Fe(),de.current){const{errors:e}=await de.current(Pe(),fe.current,he),n=Ae.current.isValid;if(s=A(e,t),k(r)&&!s&&de.current){const r=re(t),n=A(e,r,{});n.type&&n.message&&(s=n),r&&(n||A(Ae.current.errors,r))&&(t=r)}u=N(e),n!==u&&(l=!0)}else s=(await X(j,he,n,te))[t];!i&&Me(t),ke(t,s,l,o,u)}};const $e=n.useCallback((async(e={})=>{const r=N(j.current)?z.current:{},{errors:t}=await de.current(Object.assign(Object.assign(Object.assign({},r),Pe()),e),fe.current,he)||{},n=N(t);Ae.current.isValid!==n&&Ce({isValid:n})}),[he]),Ue=n.useCallback(((e,r)=>{!function(e,r,t,n,s,c){const{ref:u,ref:{name:i}}=t,a=e.current[i];if(!s){const r=E(e,i,n);!O(r)&&v(n.current,i,r)}u.type&&a?C(u)||k(u)?Array.isArray(a.options)&&a.options.length?(m(a.options).forEach(((e={},t)=>{(B(e.ref)&&M(e,e.ref)||c)&&(R(e.ref,r),W(a.options,`[${t}]`))})),a.options&&!m(a.options).length&&delete e.current[i]):delete e.current[i]:(B(u)&&M(a,u)||c)&&(R(u,r),delete e.current[i]):delete e.current[i]}(j,Q.current,e,te,h,r),h&&(W(q.current,e.ref.name),W(U.current,e.ref.name))}),[h]),He=n.useCallback((e=>{if(K.current)Ce();else{for(const r of D.current)if(r.startsWith(e)){Ce();break}Me(e)}}),[]),Ie=n.useCallback(((e,r)=>{e&&(Ue(e,r),h&&!m(e.options||[]).length&&(W(Ae.current.errors,e.ref.name),v(Ae.current.dirtyFields,e.ref.name,!0),Ce({isDirty:xe()}),Oe.current.isValid&&de.current&&$e(),He(e.ref.name)))}),[$e,Ue]),_e=n.useCallback(((e,r,t)=>{const n=t?L.current[t]:D.current;let s=_(j,ce(te.current),h,!1,e);if(I(e)){const t=re(e)||e;return ye.current.has(t)&&(s=Object.assign(Object.assign({},w.current),s)),Z(s,e,n,O(A(z.current,e))?r:A(z.current,e),!0)}const c=O(r)?z.current:r;return Array.isArray(e)?e.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:Z(s,r,n,c)})),{}):(K.current=O(t),p(!N(s)&&s||c))}),[]);function qe(e,r={}){const{name:t,type:n,value:a}=e,o=Object.assign({ref:e},r),l=j.current,f=ie(e),d=ne(ye.current,t),y=r=>se&&(!s(e)||r===e);let g,b=l[t],p=!0;if(b&&(f?Array.isArray(b.options)&&m(b.options).find((e=>a===e.ref.value&&y(e.ref))):y(b.ref)))return void(l[t]=Object.assign(Object.assign({},b),r));b=n?f?Object.assign({options:[...m(b&&b.options||[]),{ref:e}],ref:{type:n,name:t}},r):Object.assign({},o):o,l[t]=b;const R=O(A(te.current,t));N(z.current)&&R||(g=A(R?z.current:te.current,t),p=O(g),p||d||Se(t,g)),N(r)||(v(U.current,t,!0),!be&&Oe.current.isValid&&X(j,he,b,te).then((e=>{const r=Ae.current.isValid;N(e)?v(q.current,t,!0):W(q.current,t),r!==N(e)&&Ce()}))),!h||d&&p||!d&&W(Ae.current.dirtyFields,t),n&&function({ref:e},r,t){s(e)&&t&&(e.addEventListener(r?u:i,t),e.addEventListener(c,t))}(f&&b.options?b.options[b.options.length-1]:b,f||"select-one"===e.type,Q.current)}const ze=n.useCallback(((e,r)=>async t=>{t&&t.preventDefault&&(t.preventDefault(),t.persist());let n={},s=Te(_(j,ce(te.current),h,!0));Oe.current.isSubmitting&&Ce({isSubmitting:!0});try{if(de.current){const{errors:e,values:r}=await de.current(s,fe.current,he);Ae.current.errors=n=e,s=r}else for(const e of Object.values(j.current))if(e){const{name:r}=e.ref,t=await X(j,he,e,te);t[r]?(v(n,r,t[r]),W(q.current,r)):A(U.current,r)&&(W(Ae.current.errors,r),v(q.current,r,!0))}N(n)&&Object.keys(Ae.current.errors).every((e=>e in j.current))?(Ce({errors:{},isSubmitting:!0}),await e(s,t)):(Ae.current.errors=Object.assign(Object.assign({},Ae.current.errors),n),r&&await r(Ae.current.errors,t),y&&((e,r)=>{for(const t in e)if(A(r,t)){const r=e[t];if(r){if(r.ref.focus&&O(r.ref.focus()))break;if(r.options){r.options[0].ref.focus();break}}}})(j.current,Ae.current.errors))}finally{Ae.current.isSubmitting=!1,Ce({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:N(Ae.current.errors),submitCount:Ae.current.submitCount+1})}}),[y,he]);n.useEffect((()=>{t&&Oe.current.isValid&&$e(),Re.current=Re.current||!se?Re.current:function(e,r){const t=new MutationObserver((()=>{for(const t of Object.values(e.current))if(t&&t.options)for(const e of t.options)e&&e.ref&&B(e.ref)&&r(t);else t&&B(t.ref)&&r(t)}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(j,Ie)}),[Ie,z.current]),n.useEffect((()=>()=>{Re.current&&Re.current.disconnect(),J.current=!0,Object.values(j.current).forEach((e=>Ie(e,!0)))}),[]),!t&&Oe.current.isValid&&(ve.isValid=$(q.current,U.current)&&N(Ae.current.errors));const Ge={trigger:Be,setValue:n.useCallback((function(e,r,t){Le(e,r,t||{}),We(e)&&Ce(),Me(e)}),[Le,Be]),getValues:n.useCallback(Pe,[]),register:n.useCallback((function(e,r){if(!ae)if(I(e))qe({name:e},r);else{if(!g(e)||!("name"in e))return r=>r&&qe(r,e);qe(e,r)}}),[z.current]),unregister:n.useCallback((function(e){for(const r of Array.isArray(e)?e:[e])Ie(j.current[r],!0)}),[]),formState:oe?new Proxy(ve,{get:(e,r)=>{if(r in e)return Oe.current[r]=!0,e[r]}}):ve},Je=n.useMemo((()=>Object.assign({isFormDirty:xe,updateWatchedValue:He,shouldUnregister:h,updateFormState:Ce,removeFieldEventListener:Ue,watchInternal:_e,mode:ge.current,reValidateMode:{isReValidateOnBlur:Ve,isReValidateOnChange:je},validateResolver:t?$e:void 0,fieldsRef:j,resetFieldArrayFunctionRef:le,useWatchFieldsRef:L,useWatchRenderFunctionsRef:P,fieldArrayDefaultValuesRef:x,validFieldsRef:q,fieldsWithValidationRef:U,fieldArrayNamesRef:ye,readFormStateRef:Oe,formStateRef:Ae,defaultValuesRef:z,shallowFieldsStateRef:te,fieldArrayValuesRef:w},Ge)),[z.current,He,h,Ue,_e]);return Object.assign({watch:function(e,r){return _e(e,r)},control:Je,handleSubmit:ze,reset:n.useCallback(((e,r={})=>{if(se)for(const r of Object.values(j.current))if(r){const{ref:t,options:n}=r,c=ie(t)&&Array.isArray(n)?n[0].ref:t;if(s(c))try{c.closest("form").reset();break}catch(e){}}j.current={},z.current=Object.assign({},e||z.current),e&&Me(""),Object.values(le.current).forEach((e=>G(e)&&e())),te.current=h?{}:ce(e||z.current),(({errors:e,isDirty:r,isSubmitted:t,touched:n,isValid:s,submitCount:c,dirtyFields:u})=>{s||(q.current={},U.current={}),x.current={},D.current=new Set,K.current=!1,Ce({submitCount:c?Ae.current.submitCount:0,isDirty:!!r&&Ae.current.isDirty,isSubmitted:!!t&&Ae.current.isSubmitted,isValid:!!s&&Ae.current.isValid,dirtyFields:u?Ae.current.dirtyFields:{},touched:n?Ae.current.touched:{},errors:e?Ae.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})})(r)}),[]),clearErrors:n.useCallback((function(e){e&&(Array.isArray(e)?e:[e]).forEach((e=>j.current[e]&&b(e)?delete Ae.current.errors[e]:W(Ae.current.errors,e))),Ce({errors:e?Ae.current.errors:{}})}),[]),setError:n.useCallback((function(e,r){const t=(j.current[e]||{}).ref;v(Ae.current.errors,e,Object.assign(Object.assign({},r),{ref:t})),Ce({isValid:!1}),r.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:ve.errors},Ge)},r.useFormContext=de,r.useWatch=function({control:e,name:r,defaultValue:t}){const s=de(),{useWatchFieldsRef:c,useWatchRenderFunctionsRef:u,watchInternal:i,defaultValuesRef:a}=e||s.control,o=n.useState()[1],l=n.useRef(),f=n.useRef(t);return n.useEffect((()=>{const e=l.current=ye(),t=u.current,n=c.current;return n[e]=new Set,t[e]=()=>o({}),i(r,f.current,e),()=>{delete n[e],delete t[e]}}),[r,u,c,i,f]),l.current?i(r,f.current,l.current):O(t)?I(r)?A(a.current,r):Array.isArray(r)?r.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:A(a.current,r)})),{}):a.current:t}},23470:(e,r,t)=>{e.exports=t(40847)}}]);
|