import{c as B,r as a,_ as C,u as I,j as o,a as T,P as y,d as H,ar as L,f as g}from"./index-D98I4G-d.js";/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const q=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],$=B("RefreshCw",q);function z(e){const t=a.useRef({value:e,previous:e});return a.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var b="Switch",[A,G]=T(b),[U,O]=A(b),R=a.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:s,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:v,form:i,...k}=e,[l,p]=a.useState(null),w=C(t,f=>p(f)),S=a.useRef(!1),x=l?i||!!l.closest("form"):!0,[h,M]=I({prop:s,defaultProp:m??!1,onChange:v,caller:b});return o.jsxs(U,{scope:r,checked:h,disabled:c,children:[o.jsx(y.button,{type:"button",role:"switch","aria-checked":h,"aria-required":d,"data-state":j(h),"data-disabled":c?"":void 0,disabled:c,value:u,...k,ref:w,onClick:H(e.onClick,f=>{M(N=>!N),x&&(S.current=f.isPropagationStopped(),S.current||f.stopPropagation())})}),x&&o.jsx(E,{control:l,bubbles:!S.current,name:n,value:u,checked:h,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});R.displayName=b;var P="SwitchThumb",_=a.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,s=O(P,r);return o.jsx(y.span,{"data-state":j(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:t})});_.displayName=P;var D="SwitchBubbleInput",E=a.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...s},m)=>{const d=a.useRef(null),c=C(d,m),u=z(r),v=L(t);return a.useEffect(()=>{const i=d.current;if(!i)return;const k=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(k,"checked").set;if(u!==r&&p){const w=new Event("click",{bubbles:n});p.call(i,r),i.dispatchEvent(w)}},[u,r,n]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:c,style:{...s.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});E.displayName=D;function j(e){return e?"checked":"unchecked"}var F=R,W=_;function J({className:e,...t}){return o.jsx(F,{"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),...t,children:o.jsx(W,{"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 R,J as S,z as u};
