import{V as j}from"./LWaCnj-p.js";import{g as q,k,bO as G,c2 as J,c3 as K,a as Q,aX as W,b as l,l as g,aH as w,a4 as C,p as Y,c as n,ah as b,n as y,d as Z,h as ee,bP as ae,c4 as te,F as le}from"#entry";import{u as se,V as S,m as oe}from"./C1aoz2cp.js";import{V as P,m as ne}from"./bVMbXo56.js";import{f as ie}from"./D_qxKlPu.js";const re=Y({indeterminate:Boolean,inset:Boolean,flat:Boolean,loading:{type:[Boolean,String],default:!1},...oe(),...ne()},"VSwitch"),ve=q()({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:p,focus:F,blur:x}=se(e),m=C(),v=C(),h=J&&window.matchMedia("(forced-colors: active)").matches,B=w(()=>typeof e.loading=="string"&&e.loading!==""?e.loading:e.color),R=K(),z=w(()=>e.id||`switch-${R}`);function M(){i.value&&(i.value=!1)}function D(r){r.stopPropagation(),r.preventDefault(),m.value?.input?.click()}return Q(()=>{const[r,T]=W(A),N=S.filterProps(e),U=P.filterProps(e);return l(S,g({ref:v,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":u=>s.value=u,id:z.value,focused:p.value,style:e.style}),{...a,default:u=>{let{id:H,messagesId:L,isDisabled:O,isReadonly:E,isValid:V}=u;const c={model:s,isValid:V};return l(P,g({ref:m},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:O.value,readonly:E.value,onFocus:F,onBlur:x},T),{...a,default:o=>{let{backgroundColorClasses:d,backgroundColorStyles:t}=o;return n("div",{class:y(["v-switch__track",h?void 0:d.value]),style:b(t.value),onClick:D},[a["track-true"]&&n("div",{key:"prepend",class:"v-switch__track-true"},[a["track-true"](c)]),a["track-false"]&&n("div",{key:"append",class:"v-switch__track-false"},[a["track-false"](c)])])},input:o=>{let{inputNode:d,icon:t,backgroundColorClasses:X,backgroundColorStyles:$}=o;return n(le,null,[d,n("div",{class:y(["v-switch__thumb",{"v-switch__thumb--filled":t||e.loading},e.inset||h?void 0:X.value]),style:b(e.inset?void 0:$.value)},[a.thumb?l(Z,{defaults:{VIcon:{icon:t,size:"x-small"}}},{default:()=>[a.thumb({...c,icon:t})]}):l(j,null,{default:()=>[e.loading?l(ae,{name:"v-switch",active:!0,color:V.value===!1?void 0:B.value},{default:f=>a.loader?a.loader(f):l(te,{active:f.isActive,color:f.color,indeterminate:!0,size:"16",width:"2"},null)}):t&&l(ee,{key:String(t),icon:t,size:"x-small"},null)]})])])}})}})}),ie({},v)}});export{ve as V};
