var O=Object.defineProperty,D=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var R=(e,o,t)=>o in e?O(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,d=(e,o)=>{for(var t in o||(o={}))N.call(o,t)&&R(e,t,o[t]);if(S)for(var t of S(o))j.call(o,t)&&R(e,t,o[t]);return e},p=(e,o)=>D(e,F(o));var b=(e,o)=>{var t={};for(var s in e)N.call(e,s)&&o.indexOf(s)<0&&(t[s]=e[s]);if(e!=null&&S)for(var s of S(e))o.indexOf(s)<0&&j.call(e,s)&&(t[s]=e[s]);return t};import{e as B,u as W,j as u,c as X,P as T,b as $,ah as G,ai as J}from"./radixui-DBNNXUn7.js";import{r as n}from"./router-ZPDjRWWZ.js";import{c as _}from"./index-C1-9bQes.js";var g="Switch",[K,ae]=X(g),[Q,V]=K(g),I=n.forwardRef((e,o)=>{const E=e,{__scopeSwitch:t,name:s,checked:r,defaultChecked:a,required:k,disabled:c,value:f="on",onCheckedChange:x,form:h}=E,C=b(E,["__scopeSwitch","name","checked","defaultChecked","required","disabled","value","onCheckedChange","form"]),[i,y]=n.useState(null),P=B(o,v=>y(v)),l=n.useRef(!1),m=i?h||!!i.closest("form"):!0,[w,z]=W({prop:r,defaultProp:a!=null?a:!1,onChange:x,caller:g});return u.jsxs(Q,{scope:t,checked:w,disabled:c,children:[u.jsx(T.button,p(d({type:"button",role:"switch","aria-checked":w,"aria-required":k,"data-state":U(w),"data-disabled":c?"":void 0,disabled:c,value:f},C),{ref:P,onClick:$(e.onClick,v=>{z(L=>!L),m&&(l.current=v.isPropagationStopped(),l.current||v.stopPropagation())})})),m&&u.jsx(A,{control:i,bubbles:!l.current,name:s,value:f,checked:w,required:k,disabled:c,form:h,style:{transform:"translateX(-100%)"}})]})});I.displayName=g;var M="SwitchThumb",H=n.forwardRef((e,o)=>{const a=e,{__scopeSwitch:t}=a,s=b(a,["__scopeSwitch"]),r=V(M,t);return u.jsx(T.span,p(d({"data-state":U(r.checked),"data-disabled":r.disabled?"":void 0},s),{ref:o}))});H.displayName=M;var Y="SwitchBubbleInput",A=n.forwardRef((k,a)=>{var c=k,{__scopeSwitch:e,control:o,checked:t,bubbles:s=!0}=c,r=b(c,["__scopeSwitch","control","checked","bubbles"]);const f=n.useRef(null),x=B(f,a),h=G(t),C=J(o);return n.useEffect(()=>{const i=f.current;if(!i)return;const y=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(y,"checked").set;if(h!==t&&l){const m=new Event("click",{bubbles:s});l.call(i,t),i.dispatchEvent(m)}},[h,t,s]),u.jsx("input",p(d({type:"checkbox","aria-hidden":!0,defaultChecked:t},r),{tabIndex:-1,ref:x,style:p(d(d({},r.style),C),{position:"absolute",pointerEvents:"none",opacity:0,margin:0})}))});A.displayName=Y;function U(e){return e?"checked":"unchecked"}var q=I,Z=H;const ee=n.forwardRef((s,t)=>{var r=s,{className:e}=r,o=b(r,["className"]);return u.jsx(q,p(d({className:_("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm 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",e)},o),{ref:t,children:u.jsx(Z,{className:_("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}))});ee.displayName=q.displayName;export{ee as S};
