import{s as x,E as b,G as E,ao as C,f as d,L as _,aF as S,bK as V,z as y,P as T,Q as p,aX as B,a1 as N,ah as R}from"./index-DT8qTvyx.js";var z=function(c){x(o,c);function o(){return c!==null&&c.apply(this,arguments)||this}return o.prototype.handleChange=function(e){return b(this,void 0,void 0,function(){var r,i,n,t;return E(this,function(a){switch(a.label){case 0:return r=this.props,i=r.dispatchEvent,n=r.onChange,[4,i("change",R(this.props,{value:e}))];case 1:return t=a.sent(),t!=null&&t.prevented?[2]:(n&&n(e),[2])}})})},o.prototype.getResult=function(){var e=this.props,r=e.classnames,i=e.render,n=e.onText,t=e.offText,a=n,s=t;return C(n)&&n.icon&&!n.type?a=d.createElement(_,{cx:r,icon:n.icon,className:"Switch-icon"}):n!=null&&typeof n!="string"&&(a=i("switch-on-text",n)),C(t)&&t.icon&&!t.type?s=d.createElement(_,{cx:r,icon:t.icon,className:"Switch-icon"}):t!=null&&typeof t!="string"&&(s=i("switch-off-text",t)),{on:a,off:s}},o.prototype.renderBody=function(e){var r=this.props,i=r.classnames,n=r.option,t=r.optionAtLeft,a=d.createElement("span",{className:i("Switch-option")},n);return d.createElement(d.Fragment,null,t?a:null,e,t?null:a)},o.prototype.renderStatic=function(){var e=this.props,r=e.value,i=e.trueValue,n=this.getResult(),t=n.on,a=t===void 0?"开":t,s=n.off,u=s===void 0?"关":s,l=d.createElement("span",null,r===i?a:u);return this.renderBody(l)},o.prototype.doAction=function(e,r,i,n){var t,a,s=e==null?void 0:e.actionType,u=this.props,l=u.onChange,f=u.formStore,v=u.store,g=u.name,h=u.resetValue;if(s==="clear")l==null||l("");else if(s==="reset"){var m=(a=S((t=f==null?void 0:f.pristine)!==null&&t!==void 0?t:v==null?void 0:v.pristine,g))!==null&&a!==void 0?a:h;l==null||l(m)}},o.prototype.render=function(){var e=this.props,r=e.size,i=e.className;e.style;var n=e.classPrefix,t=e.classnames,a=e.value,s=e.trueValue,u=e.falseValue;e.onChange;var l=e.disabled,f=e.loading,v=e.loadingConfig,g=e.testIdBuilder,h=this.getResult(),m=h.on,w=h.off;return d.createElement("div",{className:t("SwitchControl",i)},this.renderBody(d.createElement(V,{classPrefix:n,value:a,trueValue:s,falseValue:u,onText:m,offText:w,disabled:l,onChange:this.handleChange,size:r,loading:f,loadingConfig:v,testIdBuilder:g})))},o.defaultProps={trueValue:!0,falseValue:!1,optionAtLeft:!1},y([T,p("design:type",Function),p("design:paramtypes",[Object]),p("design:returntype",Promise)],o.prototype,"handleChange",null),y([B(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",void 0)],o.prototype,"render",null),o}(d.Component),I=function(c){x(o,c);function o(){return c!==null&&c.apply(this,arguments)||this}return o=y([N({type:"switch",sizeMutable:!1,thin:!0})],o),o}(z);export{I as SwitchControlRenderer,z as default};
