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