import{r,dS as C,dT as I,dw as l,dU as E,dV as O,dW as U,dX as A,dY as M,j as k,d1 as y}from"./index-Ef5HIHwv.js";var b="Switch",[H]=M(b),[L,V]=H(b),N=r.forwardRef((t,s)=>{const{__scopeSwitch:e,name:n,checked:o,defaultChecked:m,required:c,disabled:a,value:d="on",onCheckedChange:v,form:i,...S}=t,[u,p]=r.useState(null),w=C(s,h=>p(h)),g=r.useRef(!1),x=u?i||!!u.closest("form"):!0,[f,T]=I({prop:o,defaultProp:m??!1,onChange:v,caller:b});return l.jsxs(L,{scope:e,checked:f,disabled:a,children:[l.jsx(E.button,{type:"button",role:"switch","aria-checked":f,"aria-required":c,"data-state":_(f),"data-disabled":a?"":void 0,disabled:a,value:d,...S,ref:w,onClick:O(t.onClick,h=>{T(B=>!B),x&&(g.current=h.isPropagationStopped(),g.current||h.stopPropagation())})}),x&&l.jsx(j,{control:u,bubbles:!g.current,name:n,value:d,checked:f,required:c,disabled:a,form:i,style:{transform:"translateX(-100%)"}})]})});N.displayName=b;var P="SwitchThumb",R=r.forwardRef((t,s)=>{const{__scopeSwitch:e,...n}=t,o=V(P,e);return l.jsx(E.span,{"data-state":_(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:s})});R.displayName=P;var Y="SwitchBubbleInput",j=r.forwardRef(({__scopeSwitch:t,control:s,checked:e,bubbles:n=!0,...o},m)=>{const c=r.useRef(null),a=C(c,m),d=U(e),v=A(s);return r.useEffect(()=>{const i=c.current;if(!i)return;const S=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(S,"checked").set;if(d!==e&&p){const w=new Event("click",{bubbles:n});p.call(i,e),i.dispatchEvent(w)}},[d,e,n]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:e,...o,tabIndex:-1,ref:a,style:{...o.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});j.displayName=Y;function _(t){return t?"checked":"unchecked"}var D=N,q=R;const z=r.forwardRef(({className:t,...s},e)=>k.jsxDEV(D,{className:y("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...s,ref:e,children:k.jsxDEV(q,{className:y("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/switch.tsx",lineNumber:18,columnNumber:5},void 0)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/switch.tsx",lineNumber:10,columnNumber:3},void 0));z.displayName=D.displayName;export{z as S};
