import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{$P as t}from"./lucide-C4oWPzu4.js";import{p as n,t as r}from"./utils-Bs-0X7qI.js";import{r as i}from"./bundle-mjs-C4g7ASB5.js";import{c as a,n as o}from"./dist-CImBN8k_.js";import{i as s,n as c}from"./dist-dVVC74St.js";import{t as l}from"./dist-yoGb4lVc.js";import{t as u}from"./dist-DGxLVQCb.js";import{t as d}from"./dist-DSFWiYLH.js";var f=e(t(),1),p=i(),m=`Switch`,[h,g]=s(m),[_,v]=h(m),y=f.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:u,disabled:d,value:h=`on`,onCheckedChange:g,form:v,...y}=e,[b,x]=f.useState(null),S=a(t,e=>x(e)),T=f.useRef(!1),E=b?v||!!b.closest(`form`):!0,[D,O]=l({prop:i,defaultProp:s??!1,onChange:g,caller:m});return(0,p.jsxs)(_,{scope:n,checked:D,disabled:d,children:[(0,p.jsx)(o.button,{type:`button`,role:`switch`,"aria-checked":D,"aria-required":u,"data-state":w(D),"data-disabled":d?``:void 0,disabled:d,value:h,...y,ref:S,onClick:c(e.onClick,e=>{O(e=>!e),E&&(T.current=e.isPropagationStopped(),T.current||e.stopPropagation())})}),E&&(0,p.jsx)(C,{control:b,bubbles:!T.current,name:r,value:h,checked:D,required:u,disabled:d,form:v,style:{transform:`translateX(-100%)`}})]})});y.displayName=m;var b=`SwitchThumb`,x=f.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=v(b,n);return(0,p.jsx)(o.span,{"data-state":w(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});x.displayName=b;var S=`SwitchBubbleInput`,C=f.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},o)=>{let s=f.useRef(null),c=a(s,o),l=u(n),m=d(t);return f.useEffect(()=>{let e=s.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(l!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[l,n,r]),(0,p.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:c,style:{...i.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});C.displayName=S;function w(e){return e?`checked`:`unchecked`}var T=y,E=x,D=n();function O(e){let t=(0,D.c)(11),n,i,a;t[0]===e?(n=t[1],i=t[2],a=t[3]):({className:n,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a);let o=a===void 0?`default`:a,s;t[4]===n?s=t[5]:(s=r(`data-checked:bg-primary data-unchecked:bg-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 dark:data-unchecked:bg-input/80 peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-[3px] aria-invalid:ring-[3px] data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px]`,n),t[4]=n,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,p.jsx)(E,{"data-slot":`switch-thumb`,className:`bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`}),t[6]=c):c=t[6];let l;return t[7]!==i||t[8]!==o||t[9]!==s?(l=(0,p.jsx)(T,{"data-slot":`switch`,"data-size":o,className:s,...i,children:c}),t[7]=i,t[8]=o,t[9]=s,t[10]=l):l=t[10],l}export{O as t};