import{k as e,R as a,bU as l,M as u,bW as n,z as s,d as t,bX as o,r as d,o as i,j as v,f as r}from"./index-018fb6dd.js";const c=t({__name:"index",props:{modelValue:Boolean|Number|String,api:String,id:Number|String},emits:["update:modelValue","refresh"],setup(t,{emit:c}){const m=t,{enabled:b,success:f,loading:p,afterEnabled:g}=function(){const t=e(!1),o=e(!1),d=e();return{enabled:function(e,s,i={}){o.value=!0,a.put(e+"/enable/"+s,i).then((e=>{e.data.code===l.SUCCESS?(t.value=!0,u.success(e.data.message),n(d.value)&&d.value()):u.error(e.data.message)})).finally((()=>{o.value=!1}))},success:e=>{s(t,(function(){t.value=!1,e()}))},loading:o,afterEnabled:d}}(),S=e(),E=e();return"boolean"==typeof m.modelValue?(S.value=!0,E.value=!1):(S.value=o.ENABLE,E.value=o.DISABLE),f((()=>{c("update:modelValue",m.modelValue===S.value?E.value:S.value)})),g.value=()=>{c("refresh")},(e,a)=>{const l=d("el-switch");return i(),v(l,{onChange:a[0]||(a[0]=e=>r(b)(t.api,t.id)),"active-value":S.value,"inactive-value":E.value,"model-value":t.modelValue,loading:r(p)},null,8,["active-value","inactive-value","model-value","loading"])}}});export{c as _};
