"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[6435],{6435:function(e,l,t){t.r(l),t.d(l,{default:function(){return w}});var a=t(641),s=t(33),n=t(3751);const u={class:"entity switch-container"},i={class:"icon"},o={class:"label"},v=["textContent"],c={class:"value-container"},d=["textContent"],r={class:"row"},p={class:"input"},h=["disabled"],y={key:0,value:"",selected:""},k=["value","selected","textContent"];function C(e,l,t,C,f,g){const m=(0,a.g2)("EntityIcon");return(0,a.uX)(),(0,a.CE)("div",u,[(0,a.Lk)("div",{class:(0,s.C4)(["head",{collapsed:e.collapsed}])},[(0,a.Lk)("div",i,[(0,a.bF)(m,{entity:e.value,loading:e.loading,error:e.error},null,8,["entity","loading","error"])]),(0,a.Lk)("div",o,[(0,a.Lk)("div",{class:"name",textContent:(0,s.v_)(e.value.name)},null,8,v)]),(0,a.Lk)("div",c,[null!=e.value?.value?((0,a.uX)(),(0,a.CE)("span",{key:0,class:"value",textContent:(0,s.v_)(e.value.values[e.value.value]||e.value.value)},null,8,d)):(0,a.Q3)("",!0),g.hasValues?((0,a.uX)(),(0,a.CE)("button",{key:1,onClick:l[0]||(l[0]=(0,n.D$)((l=>e.collapsed=!e.collapsed),["stop"]))},[(0,a.Lk)("i",{class:(0,s.C4)(["fas",{"fa-angle-up":!e.collapsed,"fa-angle-down":e.collapsed}])},null,2)])):(0,a.Q3)("",!0)])],2),e.collapsed?(0,a.Q3)("",!0):((0,a.uX)(),(0,a.CE)("div",{key:0,class:"body",onClick:l[2]||(l[2]=(0,n.D$)(((...e)=>g.prevent&&g.prevent(...e)),["stop"]))},[(0,a.Lk)("div",r,[(0,a.Lk)("div",p,[(0,a.Lk)("select",{onInput:l[1]||(l[1]=(...e)=>g.setValue&&g.setValue(...e)),ref:"values",disabled:e.loading},[e.value.is_write_only?((0,a.uX)(),(0,a.CE)("option",y,"--")):(0,a.Q3)("",!0),((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(g.displayValues,((l,t)=>((0,a.uX)(),(0,a.CE)("option",{value:t,selected:t==e.value.value,key:t,textContent:(0,s.v_)(l)},null,8,k)))),128))],40,h)])])]))])}var f=t(4897),g=t(1029),m={name:"EnumSwitch",components:{EntityIcon:g["default"]},mixins:[f["default"]],computed:{hasValues(){return!!Object.values(this?.value?.values||{}).length},displayValues(){return this.value?.values instanceof Array?this.value.values.reduce(((e,l)=>(e[l]=l,e)),{}):this.value?.values||{}}},methods:{prevent(e){return e.stopPropagation(),!1},async setValue(e){if(e.target.value?.length){if(this.$emit("loading",!0),this.value.is_write_only){const e=this;setTimeout((()=>{e.$refs.values.value=""}),1e3)}try{await this.request("entities.execute",{id:this.value.id,action:"set",value:e.target.value})}finally{this.$emit("loading",!1)}}}}},E=t(6262);const b=(0,E.A)(m,[["render",C],["__scopeId","data-v-043593ec"]]);var w=b}}]);
//# sourceMappingURL=6435.132d0e8c.js.map