import{r as l,j as e}from"./index-DiwDH9aE.js";const d=({checked:n=!1,onChange:u,disabled:t=!1,size:f="md",colorActive:x="bg-blue-600",colorInactive:m="bg-gray-300",label:o,loading:s=!1})=>{const[r,c]=l.useState(n);l.useEffect(()=>{c(n)},[n]);const h=()=>{if(t||s)return;const i=!r;c(i),u?.(i)},a={sm:{container:"w-9 h-5",circle:"w-4 h-4",translate:"translate-x-4"},md:{container:"w-11 h-6",circle:"w-5 h-5",translate:"translate-x-5"},lg:{container:"w-14 h-7",circle:"w-6 h-6",translate:"translate-x-7"}}[f];return e.jsxs("div",{className:"flex items-center gap-3",children:[o&&e.jsx("span",{className:`text-sm font-medium text-gray-700 ${t?"opacity-50":""}`,children:o}),e.jsx("button",{type:"button",role:"switch","aria-checked":r,onClick:h,disabled:t||s,className:`
          relative inline-flex flex-shrink-0 ${a.container} 
          border-2 border-transparent rounded-full cursor-pointer 
          transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 
          focus:ring-offset-2 focus:ring-blue-500
          ${r?x:m}
          ${t||s?"opacity-50 cursor-not-allowed":""}
        `,children:e.jsx("span",{className:`
            ${a.circle} inline-block bg-white rounded-full shadow 
            transform transition-transform duration-200 ease-in-out
            ${r?a.translate:"translate-x-0"}
            flex items-center justify-center
          `,children:s&&e.jsxs("svg",{className:"animate-spin h-3 w-3 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})})]})};export{d as T};
