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