const e=require(`./chunk-BcutgqC9.cjs`),t=require(`./dist-B9QvvA-B.cjs`),n=require(`./dist-C1zbYA0G.cjs`),r=require(`./utils-8yHOSEWy.cjs`),i=require(`./dist-BOF8kEoj.cjs`),a=require(`./check-Bb0ojItM.cjs`),o=require(`./x-BCptJoBS.cjs`),s=require(`./Typography.cjs`),c=require(`./dist-dGUVscIX.cjs`),l=require(`./dist-B2uBVqFa.cjs`);let u=require(`react`);u=e.n(u,1);let d=require(`react/jsx-runtime`);var f=`Switch`,[p,m]=t.a(f),[h,g]=p(f),_=u.forwardRef((e,r)=>{let{__scopeSwitch:i,name:a,checked:o,defaultChecked:s,required:c,disabled:l,value:p=`on`,onCheckedChange:m,form:g,..._}=e,[v,y]=u.useState(null),b=n.o(r,e=>y(e)),C=u.useRef(!1),w=v?g||!!v.closest(`form`):!0,[T,E]=t.t({prop:o,defaultProp:s??!1,onChange:m,caller:f});return(0,d.jsxs)(h,{scope:i,checked:T,disabled:l,children:[(0,d.jsx)(n.t.button,{type:`button`,role:`switch`,"aria-checked":T,"aria-required":c,"data-state":S(T),"data-disabled":l?``:void 0,disabled:l,value:p,..._,ref:b,onClick:t.r(e.onClick,e=>{E(e=>!e),w&&(C.current=e.isPropagationStopped(),C.current||e.stopPropagation())})}),w&&(0,d.jsx)(x,{control:v,bubbles:!C.current,name:a,value:p,checked:T,required:c,disabled:l,form:g,style:{transform:`translateX(-100%)`}})]})});_.displayName=f;var v=`SwitchThumb`,y=u.forwardRef((e,t)=>{let{__scopeSwitch:r,...i}=e,a=g(v,r);return(0,d.jsx)(n.t.span,{"data-state":S(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t})});y.displayName=v;var b=`SwitchBubbleInput`,x=u.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:i=!0,...a},o)=>{let s=u.useRef(null),f=n.o(s,o),p=c.t(r),m=l.t(t);return u.useEffect(()=>{let e=s.current;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set;if(p!==r&&n){let t=new Event(`click`,{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[p,r,i]),(0,d.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:f,style:{...a.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});x.displayName=b;function S(e){return e?`checked`:`unchecked`}var C=_,w=y,T=i.t(`peer inline-flex h-[30px] w-[60px] shrink-0 cursor-pointer items-center rounded-full transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-primary-blue-100 disabled:cursor-not-allowed disabled:opacity-50`,{variants:{color:{blue:`bg-primary-gray-400 data-[state=checked]:bg-primary-blue-600 dark:bg-primary-gray-550 dark:data-[state=checked]:bg-primary-blue-400`,red:`bg-primary-gray-400 data-[state=checked]:bg-accent-dark-red dark:bg-primary-gray-550 dark:data-[state=checked]:bg-accent-red`,black:`bg-primary-gray-400 data-[state=checked]:bg-primary-gray-600 dark:bg-primary-gray-550 dark:data-[state=checked]:bg-primary-gray-300`,custom:`bg-primary-gray-400 data-[state=checked]:bg-custom-color-600`},size:{small:`h-[20px] w-[40px]`,normal:`h-[30px] w-[60px]`}},defaultVariants:{color:`blue`,size:`normal`}}),E=i.t(`bg-primary-white pointer-events-none block rounded-full shadow-lg ring-0 transition-transform data-[state=unchecked]:translate-x-[4px] data-[state=unchecked]:rtl:translate-x-[-2px]`,{variants:{size:{small:`h-[14px] w-[14px] `,normal:`h-[22px] w-[22px] `},showIconWithSize:{yes_with_small:`data-[state=checked]:translate-x-[8px] data-[state=checked]:rtl:translate-x-[-8px]`,no_with_small:`data-[state=checked]:translate-x-[22px] data-[state=checked]:rtl:translate-x-[-22px]`,yes_with_normal:`data-[state=checked]:translate-x-[12px] data-[state=checked]:rtl:translate-x-[-12px]`,no_with_normal:`data-[state=checked]:translate-x-[32px] data-[state=checked]:rtl:translate-x-[-32px]`}},defaultVariants:{size:`normal`,showIconWithSize:`no_with_normal`}}),D=u.default.forwardRef(({className:e,showValue:t=!1,showIcon:n=!0,values:i=[`On`,`Off`],onCheckedChange:c,color:l,size:f=`normal`,...p},m)=>{let[h,g]=(0,u.useState)(p.defaultChecked||!1);return(0,d.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,d.jsxs)(C,{...p,className:r.t(T({color:l,size:f}),e),ref:m,onCheckedChange:e=>{g(e),c?.(e)},children:[n&&h?(0,d.jsx)(a.t,{size:f===`normal`?14:10,className:f===`normal`?`ml-2 rtl:mr-2 rtl:ml-0 text-primary-white`:`ml-1 rtl:mr-1 rtl:ml-0 text-primary-white`}):null,(0,d.jsx)(w,{className:r.t(E({size:f,showIconWithSize:n?`yes_with_${f}`:`no_with_${f}`}))}),n&&!h?(0,d.jsx)(o.t,{size:f===`normal`?14:10,className:f===`normal`?`ml-3 rtl:mr-3 rtl:ml-0`:`ml-2 rtl:mr-2 rtl:ml-0`}):null]}),t?(0,d.jsx)(s.P,{size:`base`,marginBottom:`none`,leading:`none`,children:h?i[0]:i[1]}):null]})});D.displayName=C.displayName,Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return D}});
//# sourceMappingURL=switch-i4A4VKU1.cjs.map