import{g as O,p as $,j as k,d3 as G,cs as K,J as g,d4 as Q,t as w,ct as W,n as X,cu as Y,cv as C,o as l,ae as y,ap as Z,cw as ee,E as n,q as b,r as S,an as ae,cT as te,aL as le,d5 as se,b8 as oe,ah as ne}from"./index-BRUnowC8.js";import{V as P,m as ie}from"./VSelectionControl-Co1cRcmS.js";const re=$({indeterminate:Boolean,inset:Boolean,flat:Boolean,loading:{type:[Boolean,String],default:!1},...ee(),...ie()},"VSwitch"),de=O()({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}=G(e),{isFocused:x,focus:B,blur:F}=K(e),v=g(),m=g(),h=Q&&window.matchMedia("(forced-colors: active)").matches,R=w(()=>typeof e.loading=="string"&&e.loading!==""?e.loading:e.color),p=W(),z=w(()=>e.id||`switch-${p}`);function M(){i.value&&(i.value=!1)}function T(r){r.stopPropagation(),r.preventDefault(),v.value?.input?.click()}return X(()=>{const[r,D]=Y(A),L=C.filterProps(e),N=P.filterProps(e);return l(C,y({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,L,{modelValue:s.value,"onUpdate:modelValue":c=>s.value=c,id:z.value,focused:x.value,style:e.style}),{...a,default:c=>{let{id:U,messagesId:E,isDisabled:j,isReadonly:q,isValid:V}=c;const u={model:s,isValid:V};return l(P,y({ref:v},N,{modelValue:s.value,"onUpdate:modelValue":[o=>s.value=o,M],id:U.value,"aria-describedby":E.value,type:"checkbox","aria-checked":i.value?"mixed":void 0,disabled:j.value,readonly:q.value,onFocus:B,onBlur:F},D),{...a,default:o=>{let{backgroundColorClasses:d,backgroundColorStyles:t}=o;return n("div",{class:S(["v-switch__track",h?void 0:d.value]),style:b(t.value),onClick:T},[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:H,backgroundColorStyles:J}=o;return n(ne,null,[d,n("div",{class:S(["v-switch__thumb",{"v-switch__thumb--filled":t||e.loading},e.inset||h?void 0:H.value]),style:b(e.inset?void 0:J.value)},[a.thumb?l(ae,{defaults:{VIcon:{icon:t,size:"x-small"}}},{default:()=>[a.thumb({...u,icon:t})]}):l(te,null,{default:()=>[e.loading?l(se,{name:"v-switch",active:!0,color:V.value===!1?void 0:R.value},{default:f=>a.loader?a.loader(f):l(oe,{active:f.isActive,color:f.color,indeterminate:!0,size:"16",width:"2"},null)}):t&&l(le,{key:String(t),icon:t,size:"x-small"},null)]})])])}})}})}),Z({},m)}});export{de as V};
