"use client";
import{a as m}from"./chunk-CLTGASR6.js";import{g as p,i as k,j as C}from"./chunk-KEPQUAOX.js";import*as s from"react";function R(B){let{checked:r,defaultChecked:i,disabled:u,onBlur:d,onChange:f,onFocus:h,onFocusVisible:b,readOnly:F,required:g}=B,[x,V]=p({controlled:r,default:Boolean(i),name:"Switch",state:"checked"}),_=o=>e=>{var l;e.nativeEvent.defaultPrevented||(V(e.target.checked),f?.(e),(l=o.onChange)==null||l.call(o,e))},{isFocusVisibleRef:n,onBlur:S,onFocus:v,ref:w}=C(),[t,c]=s.useState(!1);u&&t&&c(!1),s.useEffect(()=>{n.current=t},[t,n]);let a=s.useRef(null),y=o=>e=>{var l;a.current||(a.current=e.currentTarget),v(e),n.current===!0&&(c(!0),b?.(e)),h?.(e),(l=o.onFocus)==null||l.call(o,e)},I=o=>e=>{var l;S(e),n.current===!1&&c(!1),d?.(e),(l=o.onBlur)==null||l.call(o,e)},H=k(w,a),$=(o={})=>m({checked:r,defaultChecked:i,disabled:u,readOnly:F,ref:H,required:g,type:"checkbox"},o,{onChange:_(o),onFocus:y(o),onBlur:I(o)});return{checked:x,disabled:Boolean(u),focusVisible:t,getInputProps:$,readOnly:Boolean(F)}}export{R as a};
