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