'use client';
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),V=require("react"),g=require("framer-motion"),B=require("@heroui/react"),k=require("../../../hooks/use-theme.cjs"),y=require("../../../hooks/use-config.cjs"),M=e=>e&&e.__esModule?e:{default:e},p=M(V),O=({size:e,color:i,duration:n=1})=>t.jsx(g.motion.div,{className:`border-2 border-transparent border-t-current border-r-current rounded-full ${e}`,animate:{rotate:360},transition:{duration:n,repeat:1/0,ease:"linear"},style:{color:`var(--${i})`}}),P=({size:e,color:i,duration:n=1.4})=>{const s={"w-2 h-2":"w-2 h-2","w-3 h-3":"w-3 h-3","w-4 h-4":"w-4 h-4","w-6 h-6":"w-6 h-6"}[e]||"w-3 h-3";return t.jsx("div",{className:"flex gap-1",children:[0,1,2].map(a=>t.jsx(g.motion.div,{className:`${s} rounded-full bg-current`,style:{color:`var(--${i})`},animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:n,repeat:1/0,delay:a*.2,ease:"easeInOut"}},a))})},R=({size:e,color:i,duration:n=1.5})=>t.jsx(g.motion.div,{className:`rounded-full bg-current ${e}`,style:{color:`var(--${i})`},animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:n,repeat:1/0,ease:"easeInOut"}}),T=({size:e,color:i,duration:n=1.2})=>{const s={"w-2 h-2":"w-1 h-4","w-3 h-3":"w-1 h-6","w-4 h-4":"w-1 h-8","w-6 h-6":"w-2 h-12"}[e]||"w-1 h-6";return t.jsx("div",{className:"flex items-end gap-1",children:[0,1,2,3].map(a=>t.jsx(g.motion.div,{className:`${s} bg-current rounded-sm`,style:{color:`var(--${i})`},animate:{scaleY:[1,2,1]},transition:{duration:n,repeat:1/0,delay:a*.1,ease:"easeInOut"}},a))})};function v({variant:e="spinner",size:i="md",color:n="primary",text:r="Loading...",showText:s=!1,textPosition:a="bottom",centered:o=!1,overlay:c=!1,className:m="",children:x,duration:l=1,backdrop:f=!1,backdropOpacity:h=.5}){const{getColorValue:$}=k.useTheme(),{components:L}=y.useConfig(),b=L.LoadingSpinner;if(b)return t.jsx(b,{variant:e,size:i,color:n,text:r,showText:s,textPosition:a,centered:o,overlay:c,className:m,children:x,duration:l,backdrop:f,backdropOpacity:h});const S={sm:"w-4 h-4",md:"w-6 h-6",lg:"w-8 h-8",xl:"w-12 h-12"},C={sm:"text-xs",md:"text-sm",lg:"text-base",xl:"text-lg"};$(n);const N=()=>{const d=S[i],u=`text-${n}-600 dark:text-${n}-400`;switch(e){case"dots":return t.jsx(P,{size:d,color:u,duration:l});case"pulse":return t.jsx(R,{size:d,color:u,duration:l});case"bars":return t.jsx(T,{size:d,color:u,duration:l});case"custom":return x||t.jsx(O,{size:d,color:u,duration:l});case"spinner":default:return t.jsx(B.Spinner,{size:i,color:n})}},z=()=>!s||!r?null:t.jsx("span",{className:`${C[i]} text-${n}-600 dark:text-${n}-400 font-medium`,children:r}),I=()=>{const d=N(),u=z();if(!s)return d;const _={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"},q={top:"gap-2",bottom:"gap-2",left:"gap-3",right:"gap-3"};return t.jsxs("div",{className:`flex items-center justify-center ${_[a]} ${q[a]}`,children:[d,u]})},j=t.jsx("div",{className:`
      ${o?"flex items-center justify-center":""}
      ${m}
    `,children:I()});return c?t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[f&&t.jsx(g.motion.div,{initial:{opacity:0},animate:{opacity:h},exit:{opacity:0},className:"absolute inset-0 bg-background/80 backdrop-blur-sm"}),t.jsx(g.motion.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},className:"relative z-10",children:j})]}):j}function D({isLoading:e=!1,loadingText:i="Loading...",spinnerProps:n={},variant:r="solid",color:s="primary",size:a="md",children:o,disabled:c,className:m="",...x}){const{components:l}=y.useConfig(),f=l.LoadingButton;if(f)return t.jsx(f,{isLoading:e,loadingText:i,spinnerProps:n,variant:r,color:s,size:a,children:o,disabled:c,className:m,...x});const h={sm:"sm",md:"sm",lg:"md"};return t.jsxs("button",{...x,disabled:c||e,className:`
        relative inline-flex items-center justify-center gap-2 px-4 py-2 
        text-sm font-medium rounded-md transition-colors
        ${r==="solid"?`bg-${s}-600 text-white hover:bg-${s}-700`:""}
        ${r==="bordered"?`border border-${s}-600 text-${s}-600 hover:bg-${s}-50`:""}
        ${r==="light"?`text-${s}-600 hover:bg-${s}-50`:""}
        disabled:opacity-50 disabled:cursor-not-allowed
        ${m}
      `,children:[e&&t.jsx(v,{variant:"spinner",size:h[a],color:r==="solid"?"default":s,...n}),t.jsx("span",{className:e?"opacity-70":"",children:e?i:o})]})}const H={signIn:{text:"Signing in...",variant:"spinner"},signUp:{text:"Creating account...",variant:"spinner"},signOut:{text:"Signing out...",variant:"dots"},verifying:{text:"Verifying...",variant:"pulse"},processing:{text:"Processing...",variant:"bars"},loading:{text:"Loading...",variant:"spinner"},sending:{text:"Sending...",variant:"dots"},redirecting:{text:"Redirecting...",variant:"pulse"}},w=p.default.createContext(null);function E({children:e}){const[i,n]=p.default.useState(!1),[r,s]=p.default.useState("Loading..."),a=p.default.useCallback((o,c="Loading...")=>{n(o),s(c)},[]);return t.jsxs(w.Provider,{value:{isLoading:i,loadingText:r,setLoading:a},children:[e,i&&t.jsx(v,{overlay:!0,backdrop:!0,showText:!0,text:r,variant:"spinner",size:"lg",color:"primary"})]})}function U(){const e=p.default.useContext(w);if(!e)throw new Error("useLoading must be used within a LoadingProvider");return e}var Y=v;exports.LoadingButton=D;exports.LoadingProvider=E;exports.LoadingSpinner=v;exports.LoadingStates=H;exports.default=Y;exports.useLoading=U;
//# sourceMappingURL=loading-spinner.cjs.map
