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