import{g as d,s as u,a as g}from"./react-hook-form-D5KfObyh.js";const m=(r,n,t)=>{if(r&&"reportValidity"in r){const e=d(t,n);r.setCustomValidity(e&&e.message||""),r.reportValidity()}},v=(r,n)=>{for(const t in n.fields){const e=n.fields[t];e&&e.ref&&"reportValidity"in e.ref?m(e.ref,t,r):e&&e.refs&&e.refs.forEach(l=>m(l,t,r))}},V=(r,n)=>{n.shouldUseNativeValidation&&v(r,n);const t={};for(const e in r){const l=d(n.fields,e),i=Object.assign(r[e]||{},{ref:l&&l.ref});if(b(n.names||Object.keys(r),e)){const a=Object.assign({},d(t,e));u(a,"root",i),u(t,e,a)}else u(t,e,i)}return t},b=(r,n)=>{const t=y(n).replace(/[.*+?^${}()|\\]/g,"\\$&");return r.some(e=>y(e).match(`^${t}\\.\\d+`))};function y(r){return r.replace(/[\[\]]/g,"")}function O(r,n,t){return t===void 0&&(t={}),function(e,l,i){try{return Promise.resolve((function(a,f){try{var c=(n?.context,Promise.resolve(r[t.mode==="sync"?"validateSync":"validate"](e,Object.assign({abortEarly:!1},n,{context:l}))).then(function(o){return i.shouldUseNativeValidation&&v({},i),{values:t.raw?Object.assign({},e):o,errors:{}}}))}catch(o){return f(o)}return c&&c.then?c.then(void 0,f):c})(0,function(a){if(!a.inner)throw a;return{values:{},errors:V((f=a,c=!i.shouldUseNativeValidation&&i.criteriaMode==="all",(f.inner||[]).reduce(function(o,s){if(o[s.path]||(o[s.path]={message:s.message,type:s.type}),c){var p=o[s.path].types,h=p&&p[s.type];o[s.path]=g(s.path,c,o,s.type,h?[].concat(h,s.message):s.message)}return o},{})),i)};var f,c}))}catch(a){return Promise.reject(a)}}}export{O as o};
