import{toNestErrors as e,validateFieldsNatively as r}from"@hookform/resolvers";import{getDotPath as t}from"@standard-schema/utils";function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},o.apply(null,arguments)}var a=Symbol("Schema root");function s(e,r){r&&(e.message=e.message?e.message+"\n"+r:r)}function i(i,u,l){return void 0===l&&(l={}),function(u,c,f){try{var v=function(){if(m.issues){var i=function(e,r){for(var i=new Map,u=0;u<e.length;u++){var l=e[u],c=t(l)||a,f=i.get(c);if(f?c===a&&s(f,l.message):i.set(c,{message:l.message,type:""}),r){var v,m=i.get(c),g=m.types||{};m.types=o({},g,((v={})[Object.keys(g).length]=l.message,v))}}for(var y,d={},h=function(e){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,r){if(e){if("string"==typeof e)return n(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(e,r):void 0}}(e))){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(i);!(y=h()).done;){var p=y.value,b=p[0];b!==a&&(d[b]=p[1])}var j=i.get(a);return j&&(d.root?(s(d.root,j.message),function(e,r){if(r){for(var t=e.types||{},n=0,o=Object.values(r);n<o.length;n++){var a=o[n];t[Object.keys(t).length]=a}e.types=t}}(d.root,j.types)):d.root=j),d}(m.issues,!f.shouldUseNativeValidation&&"all"===f.criteriaMode);return{values:{},errors:e(i,f)}}return f.shouldUseNativeValidation&&r({},f),{values:l.raw?Object.assign({},u):m.value,errors:{}}},m=i["~standard"].validate(u),g=function(){if(m instanceof Promise)return Promise.resolve(m).then(function(e){m=e})}();return Promise.resolve(g&&g.then?g.then(v):v())}catch(e){return Promise.reject(e)}}}export{i as standardSchemaResolver};
//# sourceMappingURL=standard-schema.module.js.map
