import{g as j,p as q,s as k,d6 as J,H as g,dc as K,t as w,cb as Q,b as W,cc as X,x as l,ad as b,am as Y,d as n,n as C,e as y,ak as Z,cV as ee,aG as ae,d8 as te,b3 as le,ag as se}from"./index-C-Ivu3jU.js";import{u as oe,V as S,m as ne}from"./VInput-CnrZS6Kh.js";import{a as P,b as ie}from"./VCheckboxBtn-BmKOjEU4.js";const re=q({indeterminate:Boolean,inset:Boolean,flat:Boolean,loading:{type:[Boolean,String],default:!1},...ne(),...ie()},"VSwitch"),fe=j()({name:"VSwitch",inheritAttrs:!1,props:re(),emits:{"update:focused":e=>!0,"update:modelValue":e=>!0,"update:indeterminate":e=>!0},setup(e,_){let{attrs:A,slots:a}=_;const i=k(e,"indeterminate"),s=k(e,"modelValue"),{loaderClasses:I}=J(e),{isFocused:x,focus:B,blur:F}=oe(e),v=g(),m=g(),h=K&&window.matchMedia("(forced-colors: active)").matches,R=w(()=>typeof e.loading=="string"&&e.loading!==""?e.loading:e.color),p=Q(),z=w(()=>e.id||`switch-${p}`);function M(){i.value&&(i.value=!1)}function D(r){r.stopPropagation(),r.preventDefault(),v.value?.input?.click()}return W(()=>{const[r,T]=X(A),N=S.filterProps(e),U=P.filterProps(e);return l(S,b({ref:m,class:["v-switch",{"v-switch--flat":e.flat},{"v-switch--inset":e.inset},{"v-switch--indeterminate":i.value},I.value,e.class]},r,N,{modelValue:s.value,"onUpdate:modelValue":c=>s.value=c,id:z.value,focused:x.value,style:e.style}),{...a,default:c=>{let{id:H,messagesId:L,isDisabled:E,isReadonly:G,isValid:V}=c;const u={model:s,isValid:V};return l(P,b({ref:v},U,{modelValue:s.value,"onUpdate:modelValue":[o=>s.value=o,M],id:H.value,"aria-describedby":L.value,type:"checkbox","aria-checked":i.value?"mixed":void 0,disabled:E.value,readonly:G.value,onFocus:B,onBlur:F},T),{...a,default:o=>{let{backgroundColorClasses:d,backgroundColorStyles:t}=o;return n("div",{class:y(["v-switch__track",h?void 0:d.value]),style:C(t.value),onClick:D},[a["track-true"]&&n("div",{key:"prepend",class:"v-switch__track-true"},[a["track-true"](u)]),a["track-false"]&&n("div",{key:"append",class:"v-switch__track-false"},[a["track-false"](u)])])},input:o=>{let{inputNode:d,icon:t,backgroundColorClasses:O,backgroundColorStyles:$}=o;return n(se,null,[d,n("div",{class:y(["v-switch__thumb",{"v-switch__thumb--filled":t||e.loading},e.inset||h?void 0:O.value]),style:C(e.inset?void 0:$.value)},[a.thumb?l(Z,{defaults:{VIcon:{icon:t,size:"x-small"}}},{default:()=>[a.thumb({...u,icon:t})]}):l(ee,null,{default:()=>[e.loading?l(te,{name:"v-switch",active:!0,color:V.value===!1?void 0:R.value},{default:f=>a.loader?a.loader(f):l(le,{active:f.isActive,color:f.color,indeterminate:!0,size:"16",width:"2"},null)}):t&&l(ae,{key:String(t),icon:t,size:"x-small"},null)]})])])}})}})}),Y({},m)}});export{fe as V};
