import{jsxs as e,jsx as a}from"react/jsx-runtime";import r,{useRef as c,useMemo as l}from"react";import i from"classnames";import{useSwitchChecked as s}from"./hooks/useSwitchChecked.js";import n from"./Switch.module.scss.js";var o=function(o){var t=o.id,d=o.name,h=o.value,m=o.role,u=o.disabled,p=o.ariaLabel,b=o.ariaLabelledBy,k=o.checked,f=o.inputClassName,C=o.onChange,g=o.ariaControls,j=o.defaultChecked,v=o.children,w=o.wrapperClassName,N=c(),x=s({checked:k,defaultChecked:j,onChange:C}),y=x.onChange,O=x.checked,L=l((function(){return r.cloneElement(v,Object.assign(Object.assign({},null==v?void 0:v.props),{checked:O}))}),[v,O]);return e("label",Object.assign({htmlFor:t,className:w},{children:[a("input",{ref:N,id:t,"aria-controls":g,value:h,name:d,type:"checkbox",className:i(n["hidden-switch"],f),checked:O,role:m||"switch",onChange:y,disabled:u,"aria-label":p,"aria-labelledby":b,"aria-checked":O}),L]}))};export{o as Switch};
