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