import{b as $,g as W,s as F,r as A,_ as D,a as G,j as H,h as J,c as K,i as M}from"./styled-6f3628cf.js";import{_ as c}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-e1338cfd.js";import{r as Q}from"./index-8ee6c85d.js";import{u as T}from"./useFormControl-67bfd31d.js";import{B as V}from"./ButtonBase-01f8628f.js";import{u as X}from"./useControlled-b748c5f1.js";function Y(e){return $("PrivateSwitchBase",e)}W("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Z=["autoFocus","checked","checkedIcon","className","defaultChecked","disabled","disableFocusRipple","edge","icon","id","inputProps","inputRef","name","onBlur","onChange","onFocus","readOnly","required","tabIndex","type","value"],ee=e=>{const{classes:o,checked:i,disabled:r,edge:a}=e,l={root:["root",i&&"checked",r&&"disabled",a&&`edge${K(a)}`],input:["input"]};return M(l,Y,o)},se=F(V)(({ownerState:e})=>c({padding:9,borderRadius:"50%"},e.edge==="start"&&{marginLeft:e.size==="small"?-3:-12},e.edge==="end"&&{marginRight:e.size==="small"?-3:-12})),te=F("input",{shouldForwardProp:A})({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),oe=Q.forwardRef(function(o,i){const{autoFocus:r,checked:a,checkedIcon:l,className:w,defaultChecked:h,disabled:x,disableFocusRipple:p=!1,edge:y=!1,icon:S,id:P,inputProps:R,inputRef:I,name:_,onBlur:f,onChange:m,onFocus:g,readOnly:j,required:z=!1,tabIndex:N,type:d,value:b}=o,U=D(o,Z),[k,q]=X({controlled:a,default:!!h,name:"SwitchBase",state:"checked"}),t=T(),v=s=>{g&&g(s),t&&t.onFocus&&t.onFocus(s)},E=s=>{f&&f(s),t&&t.onBlur&&t.onBlur(s)},L=s=>{if(s.nativeEvent.defaultPrevented)return;const C=s.target.checked;q(C),m&&m(s,C)};let n=x;t&&typeof n>"u"&&(n=t.disabled);const O=d==="checkbox"||d==="radio",u=c({},o,{checked:k,disabled:n,disableFocusRipple:p,edge:y}),B=ee(u);return G(se,c({component:"span",className:J(B.root,w),centerRipple:!0,focusRipple:!p,disabled:n,tabIndex:null,role:void 0,onFocus:v,onBlur:E,ownerState:u,ref:i},U,{children:[H(te,c({autoFocus:r,checked:a,defaultChecked:h,className:B.input,disabled:n,id:O?P:void 0,name:_,onChange:L,readOnly:j,ref:I,required:z,ownerState:u,tabIndex:N,type:d},d==="checkbox"&&b===void 0?{}:{value:b},R)),k?l:S]}))}),le=oe;export{le as S};
