import{r,U as b,j as U}from"./vendor.e6eaca24.js";function v(o,y,f,d,h){const[u,k]=r.exports.useState(!1),[e,p]=r.exports.useState(!1),[C,F]=r.exports.useState(null),n=r.exports.useRef();n.current=o;const g=r.exports.useRef();g.current=e;let s=r.exports.useRef(null);async function l(c){if(u||C===o&&!y&&!c)return;k(!0);async function a(t){const i=!d||d(t);if(i!==!0)return i;p(!1);const x=!h||await h(t);return x!==!0?x:!0}for(;;){const t=n.current,i=await a(t);if(n.current===t){p(i);break}}F(n.current),k(!1),s.current&&(s.current(),s.current=null)}const R=b(l,f||1);async function S(c){if(C===null||u||c){const a=new Promise(t=>s.current=t);(!u||c)&&l(!0),await a}return g.current===!0}function m(){return u?"validating":typeof e=="string"?"error":e===!0?"success":""}function w(){return typeof e=="string"?e.indexOf(`
`)!==-1?U("div",{style:{marginBottom:6},children:e}):e:null}function V(){return n.current}return[f?async()=>void R():l,S,m,w,V]}export{v as u};
