import{c as $}from"./CEoxYnb5.js";import{au as j,cv as V,cp as G,k as J,cn as K,cw as Q,al as X,a3 as l,bi as b,c3 as g,bO as w,bI as Y,W as n,bo as C,bm as y,q as Z,r as ee,L as ae,s as te,F as le}from"#entry";import{h as se,b as S,f as oe}from"./DmHQoNBb.js";import{V as P,m as ne}from"./QUYPESwd.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=j()({name:"VSwitch",inheritAttrs:!1,props:re(),emits:{"update:focused":e=>!0,"update:modelValue":e=>!0,"update:indeterminate":e=>!0},setup(e,_){let{attrs:I,slots:a}=_;const i=V(e,"indeterminate"),s=V(e,"modelValue"),{loaderClasses:A}=G(e),{isFocused:p,focus:F,blur:x}=se(e),m=w(),v=w(),h=J&&window.matchMedia("(forced-colors: active)").matches,B=g(()=>typeof e.loading=="string"&&e.loading!==""?e.loading:e.color),R=K(),z=g(()=>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]=X(I),L=S.filterProps(e),N=P.filterProps(e);return l(S,b({ref:v,class:["v-switch",{"v-switch--flat":e.flat},{"v-switch--inset":e.inset},{"v-switch--indeterminate":i.value},A.value,e.class]},r,L,{modelValue:s.value,"onUpdate:modelValue":c=>s.value=c,id:z.value,focused:p.value,style:e.style}),{...a,default:c=>{let{id:U,messagesId:O,isDisabled:q,isReadonly:E,isValid:k}=c;const u={model:s,isValid:k};return l(P,b({ref:m},N,{modelValue:s.value,"onUpdate:modelValue":[o=>s.value=o,M],id:U.value,"aria-describedby":O.value,type:"checkbox","aria-checked":i.value?"mixed":void 0,disabled:q.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:C(t.value),onClick:D},[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:W}=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:H.value]),style:C(e.inset?void 0:W.value)},[a.thumb?l(Z,{defaults:{VIcon:{icon:t,size:"x-small"}}},{default:()=>[a.thumb({...u,icon:t})]}):l($,null,{default:()=>[e.loading?l(ae,{name:"v-switch",active:!0,color:k.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};
