import{cF as d,j as a,cG as f,cH as h,r as i,cI as p,i as u,cn as b,T as x}from"./index-BX768Frx.js";const g=(t,n)=>{const s=n.split(".");let e,r=0,l=t;for(;(e=s[r++])!=null&&l!=null;)l=l[e];return l!=null};function j(){const t=d();if(t.some(e=>e.status==="pending"))return null;let s=t.filter(e=>g(e,"loaderData.crumbs")).map(e=>e.loaderData?.crumbs?.map(r=>r)).flat();return s.length===0?null:(s.length>7&&(s=[...s.slice(0,3),a.jsx(f,{children:"..."},"ellipsis"),...s.slice(s.length-2,s.length)]),a.jsx(h,{children:s.map(e=>e)}))}function v({isLoading:t,className:n}){const[s,e]=i.useState(!1),[r,l]=i.useState(0);return i.useEffect(()=>{let m,o;return t?(e(!0),l(0),o=setInterval(()=>{l(c=>c<90?c+Math.random()*10:c)},200)):(l(100),m=setTimeout(()=>{e(!1),l(0)},300)),()=>{clearTimeout(m),clearInterval(o)}},[t]),s?a.jsxs(p,{value:r,minValue:0,maxValue:100,className:u("h-1 w-full bg-transparent",n),children:[a.jsx(b,{className:"sr-only",children:"Loading..."}),a.jsx("div",{className:u("bg-accent h-full transition-all duration-200 ease-out"),style:{width:`${r}%`}})]}):null}function y({title:t,description:n,isLoading:s=!1,children:e,className:r}){return a.jsxs("div",{className:u("flex flex-col gap-4 px-2 py-4 lg:px-4",r),children:[a.jsx(v,{isLoading:s,className:"fixed top-0 left-0 z-50"}),a.jsxs("div",{className:"flex flex-col gap-2 2xl:container 2xl:mx-auto",children:[a.jsx(j,{}),t&&a.jsxs("div",{children:[a.jsx(x,{as:"h1",variant:"heading",size:"md",weight:"medium",className:"text-primary",children:t}),a.jsx(x,{variant:"body",size:"lg",className:"text-secondary",children:n})]})]}),a.jsx("div",{className:"flex-1 2xl:container 2xl:mx-auto",children:e})]})}export{y as M};
