import{c_ as X,b as Y,C as I,d as Z,de as x,cv as N,D as w,cn as V,i as S,cw as P,df as B,a as L,dg as ee,da as ae,u as ie,dh as te,di as ne,c as u,x as E,e as se,Q as F,d2 as le,A as oe,f as ce,o as i,g as v,k as T,l as a,n as d,ch as re,E as c,w as p,I as y,J as h,s as r,t as C,h as de,ab as ue,r as M,m as ve,aa as fe,_ as pe,bn as he,dj as O,d5 as me,p as ye}from"./post-2433f428.js";const be=l=>["",...X].includes(l),ge=Y({modelValue:{type:[Boolean,String,Number],default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},size:{type:String,validator:be},width:{type:[String,Number],default:""},inlinePrompt:{type:Boolean,default:!1},inactiveActionIcon:{type:I},activeActionIcon:{type:I},activeIcon:{type:I},inactiveIcon:{type:I},activeText:{type:String,default:""},inactiveText:{type:String,default:""},activeValue:{type:[Boolean,String,Number],default:!0},inactiveValue:{type:[Boolean,String,Number],default:!1},name:{type:String,default:""},validateEvent:{type:Boolean,default:!0},beforeChange:{type:Z(Function)},id:String,tabindex:{type:[String,Number]},label:{type:String,default:void 0},...x(["ariaLabel"])}),ke={[N]:l=>w(l)||V(l)||S(l),[P]:l=>w(l)||V(l)||S(l),[B]:l=>w(l)||V(l)||S(l)},Ie=["onClick"],we=["id","aria-checked","aria-disabled","aria-label","name","true-value","false-value","disabled","tabindex","onKeydown"],Ve=["aria-hidden"],Se=["aria-hidden"],Ee=["aria-hidden"],U="ElSwitch",Te=L({name:U}),Ce=L({...Te,props:ge,emits:ke,setup(l,{expose:_,emit:f}){const t=l,{formItem:b}=ee(),$=ae(),n=ie("switch"),{inputId:j}=te(t,{formItemContext:b}),g=ne(u(()=>t.loading)),A=E(t.modelValue!==!1),m=E(),G=E(),H=u(()=>[n.b(),n.m($.value),n.is("disabled",g.value),n.is("checked",s.value)]),J=u(()=>[n.e("label"),n.em("label","left"),n.is("active",!s.value)]),Q=u(()=>[n.e("label"),n.em("label","right"),n.is("active",s.value)]),R=u(()=>({width:se(t.width)}));F(()=>t.modelValue,()=>{A.value=!0});const D=u(()=>A.value?t.modelValue:!1),s=u(()=>D.value===t.activeValue);[t.activeValue,t.inactiveValue].includes(D.value)||(f(N,t.inactiveValue),f(P,t.inactiveValue),f(B,t.inactiveValue)),F(s,e=>{var o;m.value.checked=e,t.validateEvent&&((o=b?.validate)==null||o.call(b,"change").catch(q=>le()))});const k=()=>{const e=s.value?t.inactiveValue:t.activeValue;f(N,e),f(P,e),f(B,e),he(()=>{m.value.checked=s.value})},z=()=>{if(g.value)return;const{beforeChange:e}=t;if(!e){k();return}const o=e();[O(o),w(o)].includes(!0)||me(U,"beforeChange must return type `Promise<boolean>` or `boolean`"),O(o)?o.then(K=>{K&&k()}).catch(K=>{}):o&&k()},W=()=>{var e,o;(o=(e=m.value)==null?void 0:e.focus)==null||o.call(e)};return oe(()=>{m.value.checked=s.value}),ce({from:"label",replacement:"aria-label",version:"2.8.0",scope:"el-switch",ref:"https://element-plus.org/en-US/component/switch.html"},u(()=>!!t.label)),_({focus:W,checked:s}),(e,o)=>(i(),v("div",{class:d(a(H)),onClick:fe(z,["prevent"])},[T("input",{id:a(j),ref_key:"input",ref:m,class:d(a(n).e("input")),type:"checkbox",role:"switch","aria-checked":a(s),"aria-disabled":a(g),"aria-label":e.label||e.ariaLabel,name:e.name,"true-value":e.activeValue,"false-value":e.inactiveValue,disabled:a(g),tabindex:e.tabindex,onChange:k,onKeydown:re(z,["enter"])},null,42,we),!e.inlinePrompt&&(e.inactiveIcon||e.inactiveText)?(i(),v("span",{key:0,class:d(a(J))},[e.inactiveIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(y(e.inactiveIcon)))]),_:1})):r("v-if",!0),!e.inactiveIcon&&e.inactiveText?(i(),v("span",{key:1,"aria-hidden":a(s)},C(e.inactiveText),9,Ve)):r("v-if",!0)],2)):r("v-if",!0),T("span",{ref_key:"core",ref:G,class:d(a(n).e("core")),style:ve(a(R))},[e.inlinePrompt?(i(),v("div",{key:0,class:d(a(n).e("inner"))},[e.activeIcon||e.inactiveIcon?(i(),c(a(h),{key:0,class:d(a(n).is("icon"))},{default:p(()=>[(i(),c(y(a(s)?e.activeIcon:e.inactiveIcon)))]),_:1},8,["class"])):e.activeText||e.inactiveText?(i(),v("span",{key:1,class:d(a(n).is("text")),"aria-hidden":!a(s)},C(a(s)?e.activeText:e.inactiveText),11,Se)):r("v-if",!0)],2)):r("v-if",!0),T("div",{class:d(a(n).e("action"))},[e.loading?(i(),c(a(h),{key:0,class:d(a(n).is("loading"))},{default:p(()=>[de(a(ue))]),_:1},8,["class"])):a(s)?M(e.$slots,"active-action",{key:1},()=>[e.activeActionIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(y(e.activeActionIcon)))]),_:1})):r("v-if",!0)]):a(s)?r("v-if",!0):M(e.$slots,"inactive-action",{key:2},()=>[e.inactiveActionIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(y(e.inactiveActionIcon)))]),_:1})):r("v-if",!0)])],2)],6),!e.inlinePrompt&&(e.activeIcon||e.activeText)?(i(),v("span",{key:1,class:d(a(Q))},[e.activeIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(y(e.activeIcon)))]),_:1})):r("v-if",!0),!e.activeIcon&&e.activeText?(i(),v("span",{key:1,"aria-hidden":!a(s)},C(e.activeText),9,Ee)):r("v-if",!0)],2)):r("v-if",!0)],10,Ie))}});var Ne=pe(Ce,[["__file","switch.vue"]]);const Be=ye(Ne);export{Be as E};
//# sourceMappingURL=switch-6d25050e.js.map
