import{c as g,r as a,j as n}from"./index-ukWRVZhT.js";import{d as h,c as x}from"./misc-Dj_mZhbv.js";import{e as v}from"./components-BgKv_YmS.js";const E=n.jsx("input",{type:"hidden",name:"show-progress-bar",value:"true"});function j(){const l=g(),u=v().filter(e=>{var i;return((i=e.formData)==null?void 0:i.get("show-progress-bar"))==="true"}),s=[l.state,...u.map(e=>e.state)],m=s.some(e=>e!=="idle"),t=h.useSpinDelay(m,{delay:600,minDuration:400}),o=a.useRef(null),[c,r]=a.useState(!0),d=s.every(e=>e==="idle"),p=s.some(e=>e==="submitting"),f=s.some(e=>e==="loading");return a.useEffect(()=>{if(!o.current)return;t&&r(!1);const e=o.current.getAnimations().map(({finished:i})=>i);Promise.allSettled(e).then(()=>{t||r(!0)})},[t]),n.jsx("div",{role:"progressbar","aria-hidden":t?void 0:!0,"aria-valuetext":t?"Loading":void 0,className:"fixed inset-x-0 left-0 top-0 z-50 h-[0.20rem] animate-pulse",children:n.jsx("div",{ref:o,className:x("h-full w-0 bg-highlight duration-500 ease-in-out",d&&(c?"transition-none":"w-full opacity-0 transition-all"),t&&p&&"w-5/12",t&&f&&"w-8/12")})})}export{j as E,E as s};
//# sourceMappingURL=progress-bar-CpMgJLQi.js.map
