import{j as m,a as q}from"./jsx-runtime-5BUNAZ9W.js";import{L as I}from"./label-y8FHTf1c.js";import{c as v}from"./cn-466VSCev.js";import{$ as C,_ as k}from"./index-VfKohXEB.js";import{r as t}from"./index-4g5l5LRQ.js";import{$ as L}from"./index-pbeB-vsG.js";import{$ as T}from"./index-dNGI4_9C.js";import{$ as j}from"./index-tktZLsKA.js";import{$ as A}from"./index-nyvS1vus.js";import{$ as F}from"./index-FkhxRFYx.js";import{$ as H}from"./index-bKbe1a_Q.js";import"./index-polp_dyw.js";import"./extends-dGVwEr9R.js";import"./index-zaNpaTzt.js";import"./_commonjsHelpers-4gQjN7DL.js";import"./index-TrPPXL0M.js";import"./index-gxNcLOY3.js";const E="Switch",[O,pe]=j(E),[z,D]=O(E),U=t.forwardRef((e,o)=>{const{__scopeSwitch:r,name:c,checked:a,defaultChecked:l,required:d,disabled:s,value:i="on",onCheckedChange:$,...g}=e,[n,h]=t.useState(null),R=T(o,f=>h(f)),x=t.useRef(!1),w=n?!!n.closest("form"):!0,[p=!1,B]=A({prop:a,defaultProp:l,onChange:$});return t.createElement(z,{scope:r,checked:p,disabled:s},t.createElement(C.button,k({type:"button",role:"switch","aria-checked":p,"aria-required":d,"data-state":P(p),"data-disabled":s?"":void 0,disabled:s,value:i},g,{ref:R,onClick:L(e.onClick,f=>{B(M=>!M),w&&(x.current=f.isPropagationStopped(),x.current||f.stopPropagation())})})),w&&t.createElement(X,{control:n,bubbles:!x.current,name:c,value:i,checked:p,required:d,disabled:s,style:{transform:"translateX(-100%)"}}))}),V="SwitchThumb",W=t.forwardRef((e,o)=>{const{__scopeSwitch:r,...c}=e,a=D(V,r);return t.createElement(C.span,k({"data-state":P(a.checked),"data-disabled":a.disabled?"":void 0},c,{ref:o}))}),X=e=>{const{control:o,checked:r,bubbles:c=!0,...a}=e,l=t.useRef(null),d=F(r),s=H(o);return t.useEffect(()=>{const i=l.current,$=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor($,"checked").set;if(d!==r&&n){const h=new Event("click",{bubbles:c});n.call(i,r),i.dispatchEvent(h)}},[d,r,c]),t.createElement("input",k({type:"checkbox","aria-hidden":!0,defaultChecked:r},a,{tabIndex:-1,ref:l,style:{...e.style,...s,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function P(e){return e?"checked":"unchecked"}const N=U,G=W,b=t.forwardRef(({className:e,...o},r)=>m(N,{className:v("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-info focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-background-primary data-[state=unchecked]:bg-background-stronger",e),...o,ref:r,children:m(G,{className:v("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));b.displayName=N.displayName;try{b.displayName="Switch",b.__docgenInfo={description:"",displayName:"Switch",props:{asChild:{defaultValue:null,description:"",name:"asChild",required:!1,type:{name:"boolean"}}}}}catch{}const fe={title:"ui/Switch",component:b,tags:["autodocs"],argTypes:{}},u={render:e=>q("div",{className:"flex items-center space-x-2 text-text-primary",children:[m(b,{id:"airplane-mode"}),m(I,{htmlFor:"airplane-mode",children:"Airplane Mode"})]}),args:{}};var _,S,y;u.parameters={...u.parameters,docs:{...(_=u.parameters)==null?void 0:_.docs,source:{originalSource:`{
  render: args => <div className="flex items-center space-x-2 text-text-primary">
      <Switch id="airplane-mode" />
      <Label htmlFor="airplane-mode">Airplane Mode</Label>
    </div>,
  args: {}
}`,...(y=(S=u.parameters)==null?void 0:S.docs)==null?void 0:y.source}}};const ue=["Base"];export{u as Base,ue as __namedExportsOrder,fe as default};
