import{r as o,j as a}from"./vendor-codemirror-C7mXSpXt.js";import{w as C,v as T,r as I,s as y,x as M,y as H,m as g}from"./index-LZWfu62c.js";import{u as z}from"./index-CYARH0Cq.js";var m="Switch",[A]=I(m),[U,q]=A(m),P=o.forwardRef((e,r)=>{const{__scopeSwitch:t,name:n,checked:s,defaultChecked:b,required:d,disabled:c,value:u="on",onCheckedChange:w,form:i,...k}=e,[l,p]=o.useState(null),v=C(r,f=>p(f)),x=o.useRef(!1),S=l?i||!!l.closest("form"):!0,[h,N]=T({prop:s,defaultProp:b??!1,onChange:w,caller:m});return a.jsxs(U,{scope:t,checked:h,disabled:c,children:[a.jsx(y.button,{type:"button",role:"switch","aria-checked":h,"aria-required":d,"data-state":_(h),"data-disabled":c?"":void 0,disabled:c,value:u,...k,ref:v,onClick:M(e.onClick,f=>{N(B=>!B),S&&(x.current=f.isPropagationStopped(),x.current||f.stopPropagation())})}),S&&a.jsx(j,{control:l,bubbles:!x.current,name:n,value:u,checked:h,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});P.displayName=m;var E="SwitchThumb",R=o.forwardRef((e,r)=>{const{__scopeSwitch:t,...n}=e,s=q(E,t);return a.jsx(y.span,{"data-state":_(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:r})});R.displayName=E;var L="SwitchBubbleInput",j=o.forwardRef(({__scopeSwitch:e,control:r,checked:t,bubbles:n=!0,...s},b)=>{const d=o.useRef(null),c=C(d,b),u=z(t),w=H(r);return o.useEffect(()=>{const i=d.current;if(!i)return;const k=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(k,"checked").set;if(u!==t&&p){const v=new Event("click",{bubbles:n});p.call(i,t),i.dispatchEvent(v)}},[u,t,n]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...s,tabIndex:-1,ref:c,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});j.displayName=L;function _(e){return e?"checked":"unchecked"}var O=P,D=R;function $({className:e,...r}){return a.jsx(O,{"code-path":"src/components/ui/switch.tsx:13:5","data-slot":"switch",className:g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:a.jsx(D,{"code-path":"src/components/ui/switch.tsx:21:7","data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{$ as S};