(window.webpackJsonpvtex_store_form_0_10_1=window.webpackJsonpvtex_store_form_0_10_1||[]).push([[0],[,function(e,t,r){"use strict";r.d(t,"a",(function(){return Re})),r.d(t,"b",(function(){return ze})),r.d(t,"c",(function(){return Je})),r.d(t,"d",(function(){return We})),r.d(t,"e",(function(){return et})),r.d(t,"f",(function(){return ct})),r.d(t,"g",(function(){return mt})),r.d(t,"h",(function(){return pt})),r.d(t,"i",(function(){return Et})),r.d(t,"j",(function(){return St})),r.d(t,"k",(function(){return ht})),r.d(t,"l",(function(){return yt})),r.d(t,"m",(function(){return wt}));var n=r(0),i=r.n(n),s=e=>void 0===e,a=e=>null===e||s(e),c=e=>Array.isArray(e);const u=e=>"object"==typeof e;var o=e=>!a(e)&&!c(e)&&u(e),l=e=>o(e)&&e.nodeType===Node.ELEMENT_NODE;const d={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit"},m="blur",f="change",p="input",g="max",b="min",h="maxLength",v="minLength",O="pattern",y="required",j="validate",S=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,x=/^\w*$/,_=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,w=/\\(\\)?/g;var V=e=>!c(e)&&(x.test(e)||!S.test(e)),E=e=>{const t=[];return e.replace(_,(e,r,n,i)=>{t.push(n?i.replace(w,"$1"):r||e)}),t};function k(e,t,r){let n=-1;const i=V(t)?[t]:E(t),s=i.length,a=s-1;for(;++nObject.entries(e).reduce((e,[t,r])=>V(t)?Object.assign(Object.assign({},e),{[t]:r}):(k(e,t,r),e),{}),L=(e,t,r)=>{const n=t.split(/[,[\].]+?/).filter(Boolean).reduce((e,t)=>a(e)?e:e[t],e);return s(n)||n===e?e[t]||r:n},P=(e,t)=>{l(e)&&e.removeEventListener&&(e.removeEventListener(p,t),e.removeEventListener(f,t),e.removeEventListener(m,t))},N=e=>!!e&&"radio"===e.type,I=e=>!!e&&"checkbox"===e.type;function q(e){return!e||e instanceof HTMLElement&&e.nodeType!==Node.DOCUMENT_NODE&&q(e.parentNode)}var F=e=>o(e)&&!Object.keys(e).length;function C(e){return c(e)?e:E(e)}function M(e,t){return 1==t.length?e:function(e,t){const r=V(t)?[t]:C(t),n=t.length;let i=0;for(;ii?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t;const s=Array(i);for(;++n{!function(e,t){const r=V(t)?[t]:C(t),n=M(e,r),i=r[r.length-1],s=!(null!=n)||delete n[i];let a=void 0;for(let t=0;t0&&(a=e);++no(e)&&!F(e)).length&&delete a[t]),a=i}}}(e,t)}),e}const $={isValid:!1,value:""};var A=e=>c(e)?e.reduce((e,{ref:{checked:t,value:r}})=>t?{isValid:!0,value:r}:e,$):$,D=e=>!!e&&"file"===e.type,J=e=>!!e&&"select-multiple"===e.type,W=e=>""===e;const T={value:!1,isValid:!1},z={value:!0,isValid:!0};var U=e=>{if(c(e)){if(e.length>1){const t=e.filter(({ref:{checked:e}})=>e).map(({ref:{value:e}})=>e);return{value:t,isValid:!!t.length}}const{checked:t,value:r,attributes:n}=e[0].ref;return t?n&&!s(n.value)?s(r)||W(r)?z:{value:r,isValid:!0}:z:T}return T};function H(e,t){const{name:r,value:n}=t,i=e[r];return D(t)?t.files:N(t)?i?A(i.options).value:"":J(t)?(s=t.options,[...s].filter(({selected:e})=>e).map(({value:e})=>e)):I(t)?!!i&&U(i.options).value:n;var s}var G=e=>"string"==typeof e,K=(e,t)=>{const r={},n=G(t),i=c(t),a=t&&t.nest;for(const c in e)(s(t)||a||n&&c.startsWith(t)||i&&t.find(e=>c.startsWith(e)))&&(r[c]=H(e,e[c].ref));return r},Q=(e,{type:t,types:r,message:n})=>o(e)&&e.type===t&&e.message===n&&((e={},t={})=>Object.entries(e).reduce((e,[r,n])=>!!e&&(t[r]&&t[r]===n),!0))(e.types,r);var X=e=>e instanceof RegExp,Y=e=>{const t=o(e)&&!X(e);return{value:t?e.value:e,message:t?e.message:""}},Z=e=>"function"==typeof e,ee=e=>"boolean"==typeof e;function te(e,t,r="validate"){const n=G(e);if(n||ee(e)&&!e){return{type:r,message:n?e:"",ref:t}}}var re=(e,t,r,n,i)=>{if(!t)return{};const s=r[e];return Object.assign(Object.assign({},s),{types:Object.assign(Object.assign({},s&&s.types?s.types:{}),{[n]:i||!0})})},ne=async(e,t,{ref:r,ref:{type:n,value:i,name:s},options:c,required:u,maxLength:l,minLength:d,min:m,max:f,pattern:p,validate:S})=>{const x=e.current,_={},w=N(r),V=I(r),E=w||V,k=W(i),R=re.bind(null,s,t,_),L=(e,n,i,a=h,c=v)=>{const u=e?n:i;if(_[s]=Object.assign({type:e?a:c,message:u,ref:r},R(e?a:c,u)),!t)return _};if(u&&(!w&&!V&&(k||a(i))||ee(i)&&!i||V&&!U(c).isValid||w&&!A(c).isValid)){const{value:e,message:n}=G(u)?{value:!!u,message:u}:Y(u);if(e&&(_[s]=Object.assign({type:y,message:n,ref:E?x[s].options[0].ref:r},R(y,n)),!t))return _}if(!a(m)||!a(f)){let e,s;const{value:c,message:u}=Y(f),{value:o,message:l}=Y(m);if("number"===n||!n&&!isNaN(i)){const t=r.valueAsNumber||parseFloat(i);a(c)||(e=t>c),a(o)||(s=tnew Date(c)),G(o)&&(s=te,u=d&&a{r.reduce(async(a,[c,u],o)=>{if(!F(await a)&&!t||!Z(u))return i(a);let l;const d=te(await u(e),n,c);return d?(l=Object.assign(Object.assign({},d),R(c,d.message)),t&&(_[s]=l)):l=a,r.length-1===o?i(l):l},{})});if(!F(i)&&(_[s]=Object.assign({ref:n},i),!t))return _}}return _};const ie=(e,t)=>c(e.inner)?e.inner.reduce((e,{path:r,message:n,type:i})=>Object.assign(Object.assign({},e),e[r]&&t?{[r]:re(r,t,e,i,n)}:{[r]:e[r]||Object.assign({message:n,type:i},t?{types:{[i]:n||!0}}:{})}),{}):{[e.path]:{message:e.message,type:e.type}};async function se(e,t,r,n,i){if(n)return n(r,i);try{return{values:await e.validate(r,{abortEarly:!1,context:i}),errors:{}}}catch(e){return{values:{},errors:R(ie(e,t))}}}var ae=(e,t,r)=>s(e[t])?L(e,t,r):e[t];var ce=e=>a(e)||!u(e);const ue=(e,t)=>{const r=(t,r,n)=>{const i=n?`${e}.${r}`:`${e}[${r}]`;return ce(t)?i:ue(i,t)};return c(t)?t.map((e,t)=>r(e,t)):Object.entries(t).map(([e,t])=>r(t,e,!0))};var oe=(e,t)=>function e(t){return t.reduce((t,r)=>t.concat(c(r)?e(r):r),[])}(ue(e,t)),le=(e,t,r,n,i)=>{let a;return r.add(t),F(e)?a=i||void 0:s(e[t])?(a=L(R(e),t),c(i)&&c(a)&&a.length!==i.length&&(a=i),s(a)||oe(t,a).forEach(e=>r.add(e))):(a=e[t],r.add(t)),s(a)?o(n)?ae(n,t):n:a},de=({hasError:e,isBlurEvent:t,isOnSubmit:r,isReValidateOnSubmit:n,isOnBlur:i,isReValidateOnBlur:s,isSubmitted:a})=>r&&n||r&&!a||i&&!t&&!e||s&&!t&&e||n&&a,me=(e,t)=>{const r=R(K(e));return t?L(r,t,r):r};function fe(e,t){let r=!1;if(!c(e)||!c(t)||e.length!==t.length)return!0;for(let n=0;ne.startsWith(t+"[");var ge=(e,t)=>[...e].reduce((e,r)=>!!pe(t,r)||e,!1);var be=e=>({isOnSubmit:!e||e===d.onSubmit,isOnBlur:e===d.onBlur,isOnChange:e===d.onChange});const{useRef:he,useState:ve,useCallback:Oe,useEffect:ye}=n;function je({mode:e=d.onSubmit,reValidateMode:t=d.onChange,validationSchema:r,validationResolver:n,validationContext:i,defaultValues:u={},submitFocusError:g=!0,validateCriteriaMode:b}={}){const h=he({}),v="all"===b,O=he({}),y=he({}),j=he({}),S=he(new Set),x=he(new Set),_=he(new Set),w=he(new Set),E=he(!0),C=he({}),M=he(u),$=he(!1),A=he(!1),T=he(!1),z=he(!1),U=he(0),X=he(!1),Y=he(),te=he({}),re=he(i),ie=he(new Set),[,ue]=ve(),{isOnBlur:oe,isOnSubmit:pe}=he(be(e)).current,je="undefined"==typeof window,Se=!(!r&&!n),xe="undefined"!=typeof document&&!je&&!s(window.HTMLElement),_e=xe&&"Proxy"in window,we=he({dirty:!_e,dirtyFields:!_e,isSubmitted:pe,submitCount:!_e,touched:!_e,isSubmitting:!_e,isValid:!_e}),{isOnBlur:Ve,isOnSubmit:Ee}=he(be(t)).current,ke=Oe(()=>{$.current||ue({})},[]),Re=Oe((e,t,r,n)=>{let i=r||function({errors:e,name:t,error:r,validFields:n,fieldsWithValidation:i}){const s=F(r),a=F(e),c=L(r,t),u=L(e,t);return!(s&&n.has(t)||u&&u.isManual)&&(!!(a!==s||!a&&!u||s&&i.has(t)&&!n.has(t))||c&&!Q(u,c))}({errors:O.current,error:t,name:e,validFields:w.current,fieldsWithValidation:_.current});if(F(t)?((_.current.has(e)||Se)&&(w.current.add(e),i=i||L(O.current,e)),O.current=B(O.current,[e])):(w.current.delete(e),i=i||!L(O.current,e),k(O.current,e,t[e])),i&&!n)return ke(),!0},[ke,Se]),Le=Oe((e,t)=>{const r=e.ref,n=e.options,{type:i}=r,s=xe&&l(r)&&a(t)?"":t;var c;return N(r)&&n?n.forEach(({ref:e})=>e.checked=e.value===s):D(r)?W(s)||(c=s,"undefined"!=typeof FileList&&c instanceof FileList)?r.files=s:r.value=s:J(r)?[...r.options].forEach(e=>e.selected=s.includes(e.value)):I(r)&&n?n.length>1?n.forEach(({ref:e})=>e.checked=s.includes(e.value)):n[0].ref.checked=!!s:r.value=s,!!i},[xe]),Pe=e=>{if(!h.current[e]||!we.current.dirty&&!we.current.dirtyFields)return!1;const t=ge(ie.current,e),r=x.current.size;let n=C.current[e]!==H(h.current,h.current[e].ref);if(t){const t=e.substring(0,e.indexOf("["));n=fe(me(h.current,t),L(M.current,t))}const i=(t?z.current:x.current.has(e))!==n;return n?x.current.add(e):x.current.delete(e),z.current=t?n:!!x.current.size,we.current.dirty?i:r!==x.current.size},Ne=Oe(e=>{if(Pe(e)||!L(y.current,e)&&we.current.touched)return!!k(y.current,e,!0)},[]),Ie=Oe((e,t,r)=>{const n=c(t);for(const i in t){const s=`${r||e}${n?`[${i}]`:"."+i}`;o(t[i])&&Ie(e,t[i],s);const a=h.current[s];a&&(Le(a,t[i]),Ne(s))}},[Le,Ne]),qe=Oe((e,t)=>{const r=h.current[e];if(r){Le(r,t);const n=Ne(e);if(ee(n))return n}else ce(t)||Ie(e,t)},[Ne,Le,Ie]),Fe=Oe(async(e,t)=>{const r=h.current[e];if(!r)return!1;const n=await ne(h,v,r);return Re(e,n,!1,t),F(n)},[Re,v]),Ce=Oe(async e=>{const{errors:t}=await se(r,v,me(h.current),n,re.current),i=E.current;return E.current=F(t),c(e)?(e.forEach(e=>{const r=L(t,e);r?k(O.current,e,r):B(O.current,[e])}),ke()):Re(e,L(t,e)?{[e]:L(t,e)}:{},i!==E.current),F(O.current)},[ke,Re,v,n,r]),Me=Oe(async e=>{const t=e||Object.keys(h.current);if(Se)return Ce(t);if(c(t)){const e=await Promise.all(t.map(async e=>await Fe(e,!0)));return ke(),e.every(Boolean)}return await Fe(t)},[Ce,Fe,ke,Se]),Be=e=>{const t=(e.match(/\w+/)||[])[0];return A.current||S.current.has(e)||S.current.has(t)&&!V(e)&&ie.current.has(t)};function $e(e,t,r){let n=!1;const i=c(e);(i?e:[e]).forEach(e=>{const r=G(e);n=!(!qe(r?e:Object.keys(e)[0],r?t:Object.values(e)[0])&&!i)||Be(e)}),(n||i)&&ke(),(r||i&&t)&&Me(i?void 0:e)}Y.current=Y.current?Y.current:async({type:e,target:t})=>{const i=t?t.name:"",s=h.current,a=O.current,c=s[i],u=L(a,i);let o;if(!c)return;const l=e===m,d=de({hasError:!!u,isBlurEvent:l,isOnSubmit:pe,isReValidateOnSubmit:Ee,isOnBlur:oe,isReValidateOnBlur:Ve,isSubmitted:T.current}),f=Pe(i);let p=Be(i)||f;if(l&&!L(y.current,i)&&we.current.touched&&(k(y.current,i,!0),p=!0),d)return p&&ke();if(Se){const{errors:e}=await se(r,v,me(s),n,re.current),t=E.current;E.current=F(e),o=L(e,i)?{[i]:L(e,i)}:{},t!==E.current&&(p=!0)}else o=await ne(h,v,c);!Re(i,o)&&p&&ke()};const Ae=Oe((e={})=>{const t=F(M.current)?K(h.current):M.current;se(r,v,R(Object.assign(Object.assign({},t),e)),n,re.current).then(({errors:e})=>{const t=E.current;E.current=F(e),t!==E.current&&ke()})},[ke,v,n]),De=(e,t)=>{!s(Y.current)&&e&&function(e,t,r,n){if(!r)return;const{ref:i,ref:{name:s,type:a},mutationWatcher:u}=r;if(!a)return void delete e[s];const o=e[s];if((N(i)||I(i))&&o){const{options:r}=o;c(r)&&r.length?(r.forEach(({ref:e,mutationWatcher:i},s)=>{(e&&q(e)||n)&&(P(e,t),i&&i.disconnect(),B(r,[`[${s}]`]))}),r&&!r.filter(Boolean).length&&delete e[s]):delete e[s]}else(q(i)||n)&&(P(i,t),u&&u.disconnect(),delete e[s])}(h.current,Y.current,e,t)},Je=Oe((e,t)=>{if(!e||e&&ge(ie.current,e.ref.name)&&!t)return;De(e,t);const{name:r}=e.ref;O.current=B(O.current,[r]),y.current=B(y.current,[r]),C.current=B(C.current,[r]),[x,_,w,S].forEach(e=>e.current.delete(r)),(we.current.isValid||we.current.touched)&&(ke(),Se&&Ae())},[ke,Se,Ae]);const We=({name:e,type:t,types:r,message:n,preventRender:i})=>{const s=h.current[e];Q(O.current[e],{type:t,message:n,types:r})||(k(O.current,e,{type:t,types:r,message:n,ref:s?s.ref:{},isManual:!0}),i||ke())};function Te(e){F(h.current)||(c(e)?e:[e]).forEach(e=>Je(h.current[e],!0))}function ze(e,t={}){if(!e.name)return console.warn("Missing name @",e);const{name:r,type:n,value:i}=e,a=Object.assign({ref:e},t),u=h.current,o=N(e)||I(e);let d,g=u[r],b=!0,O=!1;if(o?g&&c(g.options)&&g.options.find(({ref:e})=>i===e.value):g)return void(u[r]=Object.assign(Object.assign({},g),t));if(n){const i=function(e,t){const r=new MutationObserver(()=>{q(e)&&(r.disconnect(),t())});return r.observe(window.document,{childList:!0,subtree:!0}),r}(e,()=>Je(a));g=o?Object.assign({options:[...g&&g.options||[],{ref:e,mutationWatcher:i}],ref:{type:n,name:r}},t):Object.assign(Object.assign({},a),{mutationWatcher:i})}else g=a;if(u[r]=g,F(M.current)||(d=ae(M.current,r),b=s(d),O=ge(ie.current,r),b||O||Le(g,d)),Se&&!O&&we.current.isValid?Ae():F(t)||(_.current.add(r),!pe&&we.current.isValid&&ne(h,v,g).then(e=>{const t=E.current;F(e)?w.current.add(r):E.current=!1,t!==E.current&&ke()})),C.current[r]||O&&b||(C.current[r]=b?H(u,g.ref):d),!n)return;!function({field:e,handleChange:t,isRadioOrCheckbox:r}){const{ref:n}=e;l(n)&&n.addEventListener&&t&&(n.addEventListener(r?f:p,t),n.addEventListener(m,t))}({field:o&&g.options?g.options[g.options.length-1]:g,isRadioOrCheckbox:o,handleChange:Y.current})}function Ue(e,t){if(!je)if(G(e))ze({name:e},t);else{if(!o(e)||!("name"in e))return t=>t&&ze(t,e);ze(e,t)}}const He=Oe(e=>async t=>{let i,s;t&&(t.preventDefault(),t.persist());const a=h.current;we.current.isSubmitting&&(X.current=!0,ke());try{if(Se){s=K(a);const{errors:e,values:t}=await se(r,v,R(s),n,re.current);O.current=e,i=e,s=t}else{const{errors:e,values:t}=await Object.values(a).reduce(async(e,t)=>{if(!t)return e;const r=await e,{ref:n,ref:{name:i}}=t;if(!a[i])return Promise.resolve(r);const s=await ne(h,v,t);return s[i]?(k(r.errors,i,s[i]),w.current.delete(i),Promise.resolve(r)):(_.current.has(i)&&w.current.add(i),r.values[i]=H(a,n),Promise.resolve(r))},Promise.resolve({errors:{},values:{}}));i=e,s=t}F(i)?(O.current={},await e(R(s),t)):(g&&xe&&((e,t)=>{for(const r in e)if(L(t,r)){const t=e[r];if(t){if(l(t.ref)&&t.ref.focus){t.ref.focus();break}if(t.options){t.options[0].ref.focus();break}}}})(a,i),O.current=i)}finally{T.current=!0,X.current=!1,U.current=U.current+1,ke()}},[xe,ke,Se,g,v,n,r]),Ge=e=>{const t=K(h.current),r=F(t)?M.current:t;return e&&e.nest?R(r):r};ye(()=>()=>{$.current=!0,h.current&&Object.values(h.current).forEach(e=>Je(e,!0))},[Je]),Se||(E.current=w.current.size>=_.current.size&&F(O.current));const Ke={dirty:z.current,dirtyFields:x.current,isSubmitted:T.current,submitCount:U.current,touched:y.current,isSubmitting:X.current,isValid:pe?T.current&&F(O.current):E.current};return{watch:function(e,t){const r=s(t)?s(M.current)?{}:M.current:t,n=K(h.current,e),i=S.current;if(G(e))return le(n,e,i,r,ie.current.has(e)?j.current[e]:void 0);if(c(e))return e.reduce((e,t)=>{let s;return s=F(h.current)&&o(r)?ae(r,t):le(n,t,i,r),Object.assign(Object.assign({},e),{[t]:s})},{});A.current=!0;const a=!F(n)&&n||t||M.current;return e&&e.nest?R(a):a},control:Object.assign(Object.assign({register:Ue,unregister:Te,removeFieldEventListener:De,getValues:Ge,setValue:$e,reRender:ke,triggerValidation:Me},Se?{validateSchemaIsValid:Ae}:{}),{formState:Ke,mode:{isOnBlur:oe,isOnSubmit:pe},reValidateMode:{isReValidateOnBlur:Ve,isReValidateOnSubmit:Ee},errorsRef:O,touchedFieldsRef:y,fieldsRef:h,resetFieldArrayFunctionRef:te,validFieldsRef:w,fieldsWithValidationRef:_,watchFieldArrayRef:j,fieldArrayNamesRef:ie,isDirtyRef:z,readFormStateRef:we,defaultValuesRef:M}),handleSubmit:He,setValue:Oe($e,[ke,qe,Me]),triggerValidation:Me,getValues:Oe(Ge,[]),reset:Oe(e=>{if(xe)for(const e of Object.values(h.current))if(e&&l(e.ref)&&e.ref.closest)try{e.ref.closest("form").reset();break}catch(e){}e&&(M.current=e),Object.values(te.current).forEach(e=>Z(e)&&e()),O.current={},h.current={},y.current={},w.current=new Set,_.current=new Set,C.current={},S.current=new Set,x.current=new Set,A.current=!1,T.current=!1,z.current=!1,E.current=!0,U.current=0,ke()},[]),register:Oe(Ue,[M.current,C.current,j.current]),unregister:Oe(Te,[]),clearError:Oe((function(e){s(e)?O.current={}:B(O.current,c(e)?e:[e]),ke()}),[]),setError:Oe((function(e,t="",r){G(e)?We(Object.assign({name:e},o(t)?{types:t,type:""}:{type:t,message:r})):c(e)&&(e.forEach(e=>We(Object.assign(Object.assign({},e),{preventRender:!0}))),ke())}),[]),errors:O.current,formState:_e?new Proxy(Ke,{get:(e,t)=>t in e?(we.current[t]=!0,e[t]):{}}):Ke}}function Se(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i{var{name:t,rules:r,as:i,onBlur:a,onChange:c,onChangeName:u=d.onChange,onBlurName:l=d.onBlur,valueName:m,defaultValue:f,control:p}=e,g=Se(e,["name","rules","as","onBlur","onChange","onChangeName","onBlurName","valueName","defaultValue","control"]);const b=_e(),{defaultValuesRef:h,setValue:v,register:O,unregister:y,errorsRef:j,removeFieldEventListener:S,triggerValidation:x,mode:{isOnSubmit:_,isOnBlur:w},reValidateMode:{isReValidateOnBlur:V,isReValidateOnSubmit:E},formState:{isSubmitted:k},fieldsRef:R,fieldArrayNamesRef:P}=p||b.control,[N,I]=Object(n.useState)(s(f)?L(h.current,t):f),q=Object(n.useRef)(N),F=ee(N),C=()=>!de({hasError:!!L(j.current,t),isOnBlur:w,isOnSubmit:_,isReValidateOnBlur:V,isReValidateOnSubmit:E,isSubmitted:k}),M=e=>{const t=((e,t)=>ce(e)||!o(e.target)||o(e.target)&&!e.type?e:t||s(e.target.value)?e.target.checked:e.target.value)(e,F);return I(t),q.current=t,t},B=()=>{ge(P.current,t)&&R.current[t]&&S(R.current[t],!0),O(Object.defineProperty({name:t},"value",{set(e){I(e),q.current=e},get:()=>q.current}),Object.assign({},r))};Object(n.useEffect)(()=>{R.current[t]||(B(),I(s(f)?L(h.current,t):f))}),Object(n.useEffect)(()=>(B(),()=>{ge(P.current,t)||y(t)}),[t]);const $=w||V,A=Object.assign(Object.assign(Object.assign(Object.assign({name:t},g),c?{[u]:(D=c,(...e)=>v(t,M(D(e)),C()))}:{[u]:e=>{const r=M(e);v(t,r,C())}}),a||$?{[l]:(...e)=>{a&&a(e),$&&x(t)}}:{}),{[m||(F?"checked":"value")]:N});var D;return Object(n.isValidElement)(i)?Object(n.cloneElement)(i,A):Object(n.createElement)(i,A)},Le=(e,t)=>e+"/"+t,Pe=e=>{const t=e.split("/");return"#"===t[0]&&t.shift(),t},Ne=/^[a-z][a-z0-9+.-]*:/i,Ie=e=>Ne.test(e),qe=/^#(\/(([^#/~])|(~[01]))*)*/i,Fe=(e,t,r)=>{if(Ie(e)){const r=new URL(e);if(r.hash)return Fe(r.hash,t,t[`${r.origin}${r.pathname}`])}else if(n=e,qe.test(n)&&r)return Pe(e).reduce((e,t)=>{if(e)return e[t]},r);var n;return t[e]},Ce=(e,t,r)=>{let n={};if(e.$ref){const i=e.$ref;if(r.indexOf(i)>-1)return n;r.push(i),n=Object.assign({},Fe(i,t))}else n=Object.assign({},e);return Object.keys(n).reduce((e,n)=>("object"!=typeof e[n]||null===e[n]||Array.isArray(e[n])||r.indexOf(e[n].$ref)>-1||(e[n]=Ce(e[n],t,r.slice())),e),n)},Me={integer:e=>parseInt(e),number:e=>parseFloat(e),boolean:e=>"true"===e},Be=(e,t)=>Object.keys(t).sort().reduce((r,n)=>{const i=Pe(n);return i&&t[n]?(i.reduce((e,r,i,s)=>{var a;return e.currentSubSchema=e.currentSubSchema?e.currentSubSchema[r]:void 0,"properties"!==r||e.insideProperties?(i===s.length-1&&e.currentSubSchema?e.currentJSON[r]=e.currentSubSchema.type&&Me[e.currentSubSchema.type]?Me[e.currentSubSchema.type](t[n]):null!==(a=e.targetData)&&void 0!==a?a:{}:!e.currentJSON[r]&&e.currentSubSchema&&(e.currentJSON[r]={}),e.currentJSON=e.currentJSON[r],Object.assign(Object.assign({},e),{insideProperties:!1})):Object.assign(Object.assign({},e),{insideProperties:!0})},{currentJSON:r,currentSubSchema:e,insideProperties:!1,targetData:t[n]}),r):r},{}),$e=(e,t,r)=>{var n;const{schema:i}=r,s=Pe(e).reduce((e,t)=>{var r;const{JSONSchema:n,currentData:i}=e;if(!(n&&"object"===n.type||e.insideProperties))return Object.assign(Object.assign({},e),{JSONSchema:void 0,invalidPointer:!0});if("properties"===t&&!e.insideProperties){const i=e.isRequired;return Object.assign(Object.assign({},e),{JSONSchema:n.properties,fatherIsRequired:i,pointer:Le(e.pointer,t),insideProperties:!0,currentRequiredField:null!==(r=n.required)&&void 0!==r?r:[]})}const s=!!i,a=i?i[t]:i,c=e.currentRequiredField.indexOf(t)>-1;return Object.assign(Object.assign({},e),{JSONSchema:n[t],currentData:a,fatherExists:s,isRequired:c,invalidPointer:!1,objectName:t,pointer:Le(e.pointer,t),insideProperties:!1})},{JSONSchema:i,currentData:t,fatherExists:!0,fatherIsRequired:!0,invalidPointer:!1,isRequired:!0,objectName:"",pointer:"#",insideProperties:!1,currentRequiredField:null!==(n=i.required)&&void 0!==n?n:[]});return{JSONSchema:s.JSONSchema,invalidPointer:s.invalidPointer,isRequired:s.fatherIsRequired&&s.isRequired||!s.fatherIsRequired&&s.isRequired&&s.fatherExists,objectName:s.objectName,pointer:s.pointer}},Ae=Object(n.createContext)(null);function De(){return Object(n.useContext)(Ae)}const Je=e=>{const{formProps:t,onChange:r,validationMode:s="onSubmit",revalidateMode:a="onChange",submitFocusError:c=!0,defaultValues:u}=e,o=je({defaultValues:u,mode:s,reValidateMode:a,submitFocusError:c}),l=i.a.useRef(!0);if("function"==typeof r){const t=o.watch();!1===l.current&&r(Be(e.schema,t))}const d=Object(n.useMemo)(()=>(e=>{const t=(e,r,n)=>Object.keys(r).reduce((i,s)=>{if("object"==typeof r[s]&&null!==r[s]&&!Array.isArray(r[s]))return Object.assign(Object.assign({},t(Le(e,s),r[s],n)),i);const a=r[s];if("$id"===s&&a&&(i[a]=r,!Ie(a)))try{i[new URL(a,n).href]=r}catch(e){if(!(e instanceof TypeError))throw e}return i},{[e]:r});let r=void 0;if(e.$id&&Ie(e.$id))try{r=new URL(e.$id)}catch(e){if(r=void 0,!(e instanceof TypeError))throw e}return r?Object.assign({[r.href]:e},t("#",e,r)):t("#",e,r)})(e.schema),[e.schema]),m=Object(n.useMemo)(()=>Ce(e.schema,d,[]),[e.schema,d]),f=Object(n.useMemo)(()=>Object.assign(Object.assign({},o),{schema:m,idMap:d,customValidators:e.customValidators}),[o,m,d,e.customValidators]),p=Object.assign({},t);return p.onSubmit=o.handleSubmit(async(t,r)=>{if(e.onSubmit)return e.onSubmit({data:Be(e.schema,t),event:r,methods:f})}),e.noNativeValidate&&(p.noValidate=e.noNativeValidate),!0===l.current&&(l.current=!1),i.a.createElement(Ae.Provider,{value:f},i.a.createElement("form",Object.assign({},p),e.children))};var We,Te,ze,Ue;(Ue=We||(We={})).generic="generic",Ue.radio="radio",Ue.select="select",Ue.input="input",Ue.textArea="textArea",Ue.checkbox="checkbox",function(e){e.default="default",e.radio="radio",e.select="select",e.input="input",e.hidden="hidden",e.password="password",e.textArea="textArea",e.checkbox="checkbox"}(Te||(Te={})),function(e){e.required="__form_error_required__",e.maxLength="__form_error_maxLength__",e.minLength="__form_error_minLength__",e.maxValue="__form_error_maxValue__",e.minValue="__form_error_minValue__",e.pattern="__form_error_pattern__",e.notInteger="__form_error_notInteger__",e.notFloat="__form_error_notFloat__",e.multipleOf="__form_error_multipleOf__",e.notInEnum="__form_error_notInEnum",e.undefinedError="__form_error_undefinedError__"}(ze||(ze={}));const He=(e,t)=>{const r=Math.pow(10,t||0);return String(Math.round(e*r)/r)},Ge=e=>{const t=void 0!==e.multipleOf?"integer"===e.type?parseInt(e.multipleOf):parseFloat(e.multipleOf):"integer"===e.type?1:"any";let r=void 0;if(e.multipleOf){const t=e.multipleOf.toString().split(".")[1];r=t?t.length:0}return[t,r]},Ke=e=>{const[t]=Ge(e);let r=void 0!==e.exclusiveMinimum?e.exclusiveMinimum:void 0!==e.minimum?e.minimum:void 0;return void 0!==r&&void 0!==e.exclusiveMinimum&&(r+=t&&"any"!=t?t:1e-4),r},Qe=e=>{const[t]=Ge(e);let r=void 0!==e.exclusiveMaximum?parseFloat(e.exclusiveMaximum):void 0!==e.maximum?parseFloat(e.maximum):void 0;return void 0!==r&&void 0!==e.exclusiveMaximum&&(r-=t&&"any"!=t?t:1e-4),r};function Xe(e,t){return Object.keys(e).reduce((r,n)=>(r[n]=r=>e[n](r,t),r),{})}const Ye=(e,t)=>{const{JSONSchema:r,isRequired:n}=e,i=Object.keys(t).length>0||r.enum,s=Object.assign({},i?{validate:Object.assign(Object.assign({},Xe(t,e)),r.enum?{enumValidator:e=>{if(!r.enum||!e)return!0;for(const t of r.enum)if(t==e)return!0;return ze.notInEnum}}:void 0)}:void 0);switch(n&&(s.required=ze.required),r.type){case"integer":case"number":return((e,t)=>{const r=Ke(e),n=Qe(e);return t.validate=Object.assign(Object.assign({},t.validate),{multipleOf:t=>"integer"!==e.type||!t||e.multipleOf&&(parseInt(t)%parseInt(e.multipleOf)==0||ze.multipleOf)}),"integer"===e.type?t.pattern={value:/^([+-]?[1-9]\d*|0)$/,message:ze.notInteger}:t.pattern={value:/^([+-]?[0-9]+([.][0-9]+))?$/,message:ze.notFloat},(r||0===r)&&(t.min={value:r,message:ze.minValue}),(n||0===n)&&(t.max={value:n,message:ze.maxValue}),t})(r,s);case"string":return c=s,(a=r).minLength&&(c.minLength={value:a.minLength,message:ze.minLength}),a.maxLength&&(c.maxLength={value:a.maxLength,message:ze.maxLength}),a.pattern&&(c.pattern={value:new RegExp(a.pattern),message:ze.pattern}),c;case"boolean":return s;default:return{}}var a,c},Ze=(e,t)=>$e(e,t,De()),et=(e,t)=>{var r;const n=Pe(e);let i=!1;return null===(r=n.reduce((e,t)=>"properties"!==t||i?(i=!1,{currentData:e.currentData?e.currentData[t]:void 0,insideProperties:!0}):(i=!0,Object.assign(Object.assign({},e),{insideProperties:!0})),{currentData:t,insideProperties:!1}).currentData)||void 0===r?void 0:r.toString()},tt=(e,t,r)=>{var n;const{JSONSchema:i,isRequired:s,objectName:a}=t;let c,u,o;if("number"===i.type||"integer"===i.type){const e=Ge(i);o=e[0],c=Ke(i),u=Qe(i)}return{name:a,pointer:r,isRequired:s,formContext:e,type:We.generic,validator:Ye(t,null!==(n=e.customValidators)&&void 0!==n?n:{}),getError:()=>((e,t,r,n,i,s,a,c)=>{if("array"===t.type){const e=n.getValues({nest:!0})[i];if(e){const r=e.filter(e=>!1!==e).length||0;if(t.minItems&&rt.maxItems)return{message:ze.maxLength,expected:t.maxItems}}}if(!e)return;const u={message:"string"==typeof e.message?e.message:ze.undefinedError,expected:void 0};switch(e.message){case ze.required:u.message=ze.required,u.expected=r;break;case ze.maxLength:u.message=ze.maxLength,u.expected=t.maxLength;break;case ze.minLength:u.message=ze.minLength,u.expected=t.minLength;break;case ze.maxValue:u.message=ze.maxValue,u.expected=a;break;case ze.minValue:u.message=ze.minValue,u.expected=s;break;case ze.multipleOf:u.message=ze.multipleOf,u.expected=c;break;case ze.pattern:u.message=ze.pattern,u.expected=t.pattern;break;case ze.notInEnum:u.message=ze.notInEnum,u.expected=t.enum}return u})(e.errors[r]?e.errors[r]:void 0,i,s,e,r,c,u,o),getObject:()=>i,getCurrentValue:()=>e.getValues()[r]}},rt=e=>{const t=De(),r=Be(t.schema,t.getValues()),n=Ze(e,r);return tt(t,n,e)},nt=e=>e?e.toString():"",it=e=>e.enum?e.enum.map(nt):[],st=(e,t,r)=>e+"-checkbox-input-"+(r[t]?r[t]:""),at=e=>{const{register:t}=e.formContext,{validator:r}=e,n=e.getObject();let i,s,a,c,u=[];if("array"===n.type){if(n.items.enum)u=it(n.items);else if("string"===n.items.type)u=it(n);else if("number"===n.items.type||"integer"===n.items.type){const e=Ge(n);if(a=e[0],c=e[1],i=Ke(n),s=Qe(n),void 0!==i&&void 0!==s&&"any"!=a)for(let e=i;e<=s;e+=a)u.push(He(e,c||0))}n.uniqueItems&&(u=[...new Set(u)])}else"boolean"===n.type&&(u=["true"]);return Object.assign(Object.assign({},e),{type:We.checkbox,isSingle:"boolean"===n.type,getItemInputProps:i=>{const s={key:""};return s.name="array"===n.type?`${e.pointer}[${i}]`:e.pointer,s.ref=t(r),s.type="checkbox",s.id=st(e.pointer,i,u),s.value=u[i],s},getItemLabelProps:t=>{const r={};return r.id=((e,t,r)=>e+"-checkbox-label-"+(r[t]?r[t]:""))(e.pointer,t,u),r.htmlFor=st(e.pointer,t,u),r},getItems:()=>u})},ct=e=>at(rt(e)),ut=(e,t)=>e+"-"+t+"-input",ot=(e,t)=>{const{register:r}=e.formContext,{validator:n}=e,i=e.getObject();let s,a,c,u;const o={key:""};if("string"===i.type)o.pattern=i.pattern,o.minLength=i.minLength,o.maxLength=i.maxLength;else if("number"===i.type||"integer"===i.type){const e=Ge(i);c=e[0],u=e[1],s=Ke(i),a=Qe(i),o.min=""+s,o.max=""+a,o.step="any"===c?"any":He(c,u||0)}return Object.assign(Object.assign({},e),{type:We.input,getLabelProps:()=>{const r={};return r.id=((e,t)=>e+"-"+t+"-label")(e.pointer,t),r.htmlFor=ut(e.pointer,t),r},getInputProps:()=>(o.name=e.pointer,o.ref=r(n),o.type=t,o.required=e.isRequired,o.id=ut(e.pointer,t),o)})},lt=()=>({}),dt=e=>Object.assign(Object.assign({},ot(e,"hidden")),{isRequired:!1,getLabelProps:lt}),mt=e=>dt(rt(e)),ft=e=>{const t=e.getObject();let r="text";if("string"===t.type)switch(t.format){case"date":r="date";break;case"date-time":r="datetime-local";break;case"email":r="email";break;case"hostname":case"uri":r="url"}else"integer"!==t.type&&"number"!==t.type||(r="number");return ot(e,r)},pt=e=>ft(rt(e)),gt=(e,t,r)=>e+"-radio-input-"+(r[t]?r[t]:""),bt=e=>{const{register:t}=e.formContext,{validator:r}=e,n=e.getObject();let i,s,a,c,u=[];if("string"===n.type)u=it(n);else if("number"===n.type||"integer"===n.type){const e=Ge(n);if(a=e[0],c=e[1],i=Ke(n),s=Qe(n),void 0!==i&&void 0!==s&&"any"!=a)for(let e=i;e<=s;e+=a)u.push(He(e,c||0))}else"boolean"===n.type&&(u=["true","false"]);return Object.assign(Object.assign({},e),{type:We.radio,getLabelProps:()=>{const t={};return t.id=e.pointer+"-label",t.htmlFor=void 0!==n.title?n.title:e.pointer,t},getItemInputProps:n=>{const i={key:""};return i.name=e.pointer,i.ref=t(r),i.type="radio",i.required=e.isRequired,i.id=gt(e.pointer,n,u),i.value=u[n],i},getItemLabelProps:t=>{const r={};return r.id=((e,t,r)=>e+"-radio-label-"+(r[t]?r[t]:""))(e.pointer,t,u),r.htmlFor=gt(e.pointer,t,u),r},getItems:()=>u})},ht=e=>bt(rt(e)),vt=e=>e+"-select",Ot=e=>{const{register:t}=e.formContext,{validator:r}=e,n=e.getObject();let i,s,a,c,u=[""];if("string"===n.type)u=u.concat(it(n));else if("number"===n.type||"integer"===n.type){const e=Ge(n);if(a=e[0],c=e[1],i=Ke(n),s=Qe(n),void 0!==i&&void 0!==s&&"any"!=a)for(let e=i;e<=s;e+=a)u.push(He(e,c||0))}else"boolean"===n.type&&(u=["true","false"]);return Object.assign(Object.assign({},e),{type:We.select,validator:r,getLabelProps:()=>{const t={};return t.id=e.pointer+"-label",t.htmlFor=vt(e.pointer),t},getSelectProps:()=>{const n={};return n.name=e.pointer,n.ref=t(r),n.required=e.isRequired,n.id=vt(e.pointer),n},getItemOptionProps:t=>{const r={};return r.id=((e,t,r)=>e+"-select-option-"+(r[t]?r[t]:""))(e.pointer,t,u),r.value=u[t],r},getItems:()=>u})},yt=e=>Ot(rt(e)),jt=e=>ot(e,"password"),St=e=>jt(rt(e)),xt=e=>e+"-textarea-input",_t=e=>{const{register:t}=e.formContext,{validator:r}=e,n=e.getObject(),i={};return"string"===n.type&&(i.minLength=n.minLength,i.maxLength=n.maxLength),Object.assign(Object.assign({},e),{type:We.textArea,getLabelProps:()=>{const t={};return t.id=e.pointer+"-textarea-label",t.htmlFor=xt(e.pointer),t},getTextAreaProps:()=>(i.name=e.pointer,i.ref=t(r),i.required=e.isRequired,i.id=xt(e.pointer),i)})},wt=e=>_t(rt(e));function Vt(e){const t=e.getObject(),r=[];switch(t.type){case"string":t.enum?r.push(Ot(e)):r.push(ft(e));break;case"integer":case"number":r.push(ft(e));break;case"array":case"boolean":r.push(at(e))}return r}const Et=e=>{const t=De(),r=Be(t.schema,t.getValues());return function e(t,r,n,i,s){let a=[];const{JSONSchema:c}=r,u=tt(t,r,n);if("object"===c.type)return Object.keys(c.properties).reduce(function(t,r,n,i){return(s,a)=>{const c=r&&r.properties?r.properties[a]:void 0,u=Le(Le(t,"properties"),a),o=$e(u,i,n),l=e(n,o,u,c,i);return s.concat(l)}}(n,i,t,s),[]);if(!i)return a.concat(Vt(u));switch(i.type){case Te.default:a=a.concat(Vt(u));break;case Te.checkbox:a.push(at(u));break;case Te.hidden:a.push(dt(u));break;case Te.input:a.push(ft(u));break;case Te.password:a.push(jt(u));break;case Te.radio:a.push(bt(u));break;case Te.select:a.push(Ot(u));break;case Te.textArea:a.push(_t(u))}return a}(t,Ze(e.pointer,r),e.pointer,e.UISchema,r)}}]]);