"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1406],{634:function(e,t,n){n.d(t,{N:function(){return l}});var i=n(9584);n(1703);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n.5?s/(2-r-a):s/(r+a),r){case e:i=(t-n)/s+(tu&&l>s&&l>1?(s/=l,u/=l,l=1):s>u&&s>l&&s>1?(l/=s,u/=s,s=1):u>l&&u>s&&u>1&&(l/=u,s/=u,u=1),l=l<=.0031308?12.92*l:1.055*Math.pow(l,1/2.4)-.055,s=s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055,u=u<=.0031308?12.92*u:1.055*Math.pow(u,1/2.4)-.055,l=Math.round(255*l),s=Math.round(255*s),u=Math.round(255*u),isNaN(l)&&(l=0),isNaN(s)&&(s=0),isNaN(u)&&(u=0),[l,s,u].map((function(e){return Math.min(Math.max(0,e),255)}))}},{key:"rgbToXY",value:function(e,t,n){e>1&&(e/=255),t>1&&(t/=255),n>1&&(n/=255),e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var i=.664511*e+.154324*t+.162028*n,o=.283881*e+.668433*t+.047685*n,r=88e-6*e+.07231*t+.986039*n,a=parseFloat((i/(i+o+r)).toFixed(4)),l=parseFloat((o/(i+o+r)).toFixed(4));return isNaN(a)&&(a=0),isNaN(l)&&(l=0),[a,l]}},{key:"rgbToBri",value:function(e,t,n){return Math.min(2*this.rgbToHsl(e,t,n)[2],this.ranges.bri[1])}},{key:"getRGB",value:function(e){return null!=e.red&&null!=e.green&&null!=e.blue?[e.red,e.green,e.blue]:null!=e.r&&null!=e.g&&null!=e.b?[e.r,e.g,e.b]:e.rgb?e.rgb:void 0}},{key:"getXY",value:function(e){return null!=e.x&&null!=e.y?[e.x,e.y]:e.xy?e.xy:void 0}},{key:"toRGB",value:function(e){var t=this.getRGB(e);if(t)return t;var n=this.getXY(e);return n&&e.bri?this.xyToRgb.apply(this,(0,i.Z)(n).concat([e.bri])):e.hue&&e.sat&&e.bri?this.hslToRgb(e.hue,e.sat,e.bri):(console.debug("Could not determine color space"),void console.debug(e))}},{key:"toXY",value:function(e){var t=this.getXY(e);if(t&&e.bri)return[t[0],t[1],e.bri];var n=this.getRGB(e);if(n)return this.rgbToXY.apply(this,(0,i.Z)(n));if(e.hue&&e.sat&&e.bri){var o=this.hslToRgb(e.hue,e.sat,e.bri);return this.rgbToXY.apply(this,(0,i.Z)(o))}console.debug("Could not determine color space"),console.debug(e)}},{key:"toHSL",value:function(e){if(e.hue&&e.sat&&e.bri)return[e.hue,e.sat,e.bri];var t=this.getRGB(e);if(t)return this.rgbToHsl.apply(this,(0,i.Z)(t));var n=this.getXY(e);if(n&&e.bri){var o=this.xyToRgb.apply(this,(0,i.Z)(n).concat([e.bri]));return this.rgbToHsl.apply(this,(0,i.Z)(o))}console.debug("Could not determine color space"),console.debug(e)}},{key:"hexToRgb",value:function(e){return[e.slice(1,3),e.slice(3,5),e.slice(5,7)].map((function(e){return parseInt(e,16)}))}},{key:"rgbToHex",value:function(e){return"#"+e.map((function(e){var t=e.toString(16);return t.length<2&&(t="0"+t),t})).join("")}}]),e}()},1583:function(e,t,n){n.d(t,{Z:function(){return y}});var i=n(6252),o=n(3577),r=n(9963),a={class:"slider-wrapper"},l=["textContent"],s=["textContent"],u={class:"slider-container"},c=["min","max","step","disabled","value"],g={class:"track-inner",ref:"track"},d={class:"thumb",ref:"thumb"},p=["textContent"];function h(e,t,n,h,v,f){return(0,i.wg)(),(0,i.iD)("label",a,[n.withRange?((0,i.wg)(),(0,i.iD)("span",{key:0,class:(0,o.C_)(["range-labels",{"with-label":n.withLabel}])},[n.withRange?((0,i.wg)(),(0,i.iD)("span",{key:0,class:"label left",textContent:(0,o.zw)(n.range[0])},null,8,l)):(0,i.kq)("",!0),n.withRange?((0,i.wg)(),(0,i.iD)("span",{key:1,class:"label right",textContent:(0,o.zw)(n.range[1])},null,8,s)):(0,i.kq)("",!0)],2)):(0,i.kq)("",!0),(0,i._)("span",u,[(0,i._)("input",{class:(0,o.C_)(["slider",{"with-label":n.withLabel}]),type:"range",min:n.range[0],max:n.range[1],step:n.step,disabled:n.disabled,value:n.value,ref:"range",onInput:t[0]||(t[0]=(0,r.iM)((function(){return f.onUpdate&&f.onUpdate.apply(f,arguments)}),["stop"])),onChange:t[1]||(t[1]=(0,r.iM)((function(){return f.onUpdate&&f.onUpdate.apply(f,arguments)}),["stop"]))},null,42,c),(0,i._)("div",{class:(0,o.C_)(["track",{"with-label":n.withLabel}])},[(0,i._)("div",g,null,512)],2),(0,i._)("div",d,null,512),n.withLabel?((0,i.wg)(),(0,i.iD)("span",{key:0,class:"label",textContent:(0,o.zw)(n.value),ref:"label"},null,8,p)):(0,i.kq)("",!0)])])}var v=n(4648),f=(n(9653),{name:"Slider",emits:["input","change","mouseup","mousedown","touchstart","touchend","keyup","keydown"],props:{value:{type:Number},disabled:{type:Boolean,default:!1},range:{type:Array,default:function(){return[0,100]}},step:{type:Number,default:1},withLabel:{type:Boolean,default:!1},withRange:{type:Boolean,default:!1}},methods:{onUpdate:function(e){this.update(e.target.value),this.$emit(e.type,(0,v.Z)((0,v.Z)({},e),{},{target:(0,v.Z)((0,v.Z)({},e.target),{},{value:this.$refs.range.value})}))},update:function(e){var t=this.$refs.range.clientWidth,n=(e-this.range[0])/(this.range[1]-this.range[0]),i=n*t,o=this.$refs.thumb;o.style.left="".concat(i-o.clientWidth/2,"px"),this.$refs.thumb.style.transform="translate(-".concat(n,"%, -50%)"),this.$refs.track.style.width="".concat(i,"px")}},mounted:function(){var e=this;null!=this.value&&this.update(this.value),this.$watch((function(){return e.value}),(function(t){return e.update(t)}))}}),m=n(3744);const b=(0,m.Z)(f,[["render",h],["__scopeId","data-v-28d31846"]]);var y=b},6:function(e,t,n){n.d(t,{Z:function(){return h}});var i=n(6252),o=n(3577),r=n(9963),a=function(e){return(0,i.dD)("data-v-a6396ae8"),e=e(),(0,i.Cn)(),e},l=["checked"],s=a((function(){return(0,i._)("div",{class:"switch"},[(0,i._)("div",{class:"dot"})],-1)})),u={class:"label"};function c(e,t,n,a,c,g){return(0,i.wg)(),(0,i.iD)("div",{class:(0,o.C_)(["power-switch",{disabled:n.disabled}]),onClick:t[0]||(t[0]=(0,r.iM)((function(){return g.onInput&&g.onInput.apply(g,arguments)}),["stop"]))},[(0,i._)("input",{type:"checkbox",checked:n.value},null,8,l),(0,i._)("label",null,[s,(0,i._)("span",u,[(0,i.WI)(e.$slots,"default",{},void 0,!0)])])],2)}var g={name:"ToggleSwitch",emits:["input"],props:{value:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},methods:{onInput:function(e){if(this.disabled)return!1;this.$emit("input",e)}}},d=n(3744);const p=(0,d.Z)(g,[["render",c],["__scopeId","data-v-a6396ae8"]]);var h=p},1406:function(e,t,n){n.r(t),n.d(t,{default:function(){return Ut}});n(7941);var i=n(6252),o={class:"plugin lights-plugin"},r={key:0,class:"panel"},a={key:1,class:"panel"};function l(e,t,n,l,s,u){var c=(0,i.up)("Groups"),g=(0,i.up)("Group");return(0,i.wg)(),(0,i.iD)("div",o,[null==s.selectedGroup&&n.groups&&Object.keys(n.groups).length?((0,i.wg)(),(0,i.iD)("div",r,[(0,i.Wm)(c,{groups:n.groups,"loading-groups":n.loadingGroups,"color-converter":n.colorConverter,onSelect:t[0]||(t[0]=function(e){return s.selectedGroup=e}),onToggle:t[1]||(t[1]=function(t){return e.$emit("group-toggle",t)})},null,8,["groups","loading-groups","color-converter"])])):((0,i.wg)(),(0,i.iD)("div",a,[(0,i.Wm)(g,{group:n.groups[s.selectedGroup],lights:u.displayedLights,scenes:u.scenesByGroup[s.selectedGroup],"color-converter":n.colorConverter,animations:u.animationsByGroup[s.selectedGroup],onClose:t[2]||(t[2]=function(e){return s.selectedGroup=null}),onLightToggle:t[3]||(t[3]=function(t){return e.$emit("light-toggle",t)}),onGroupToggle:t[4]||(t[4]=function(t){return e.$emit("group-toggle",t)}),onSetLight:t[5]||(t[5]=function(t){return e.$emit("set-light",t)}),onSetGroup:t[6]||(t[6]=function(t){return e.$emit("set-group",{groupId:s.selectedGroup,value:t})}),onSelectScene:t[7]||(t[7]=function(t){return e.$emit("select-scene",{groupId:s.selectedGroup,sceneId:t})}),onStartAnimation:t[8]||(t[8]=function(t){return e.$emit("start-animation",t)}),onStopAnimation:t[9]||(t[9]=function(t){return e.$emit("stop-animation",t)})},null,8,["group","lights","scenes","color-converter","animations"])]))])}var s=n(4648),u=n(6084),c=(n(9653),n(1539),n(9720),n(4747),n(2479),n(6813)),g={name:"Panel",emits:["mounted"],props:{config:{type:Object,default:function(){}},pluginName:{type:String,required:!0}},data:function(){return{loading:!1}},mounted:function(){this.$emit("mounted",this)}};const d=g;var p=d,h=(n(8309),n(3577)),v=function(e){return(0,i.dD)("data-v-42318a2b"),e=e(),(0,i.Cn)(),e},f={class:"panel-row header"},m=v((function(){return(0,i._)("div",{class:"col-3"},[(0,i._)("i",{class:"icon fas fa-home"})],-1)})),b=v((function(){return(0,i._)("div",{class:"col-6 name"}," Rooms ",-1)})),y={class:"col-3 pull-right"},_=["onClick"],w={class:"name col-9"},k={class:"controls col-3 pull-right"};function C(e,t,n,o,r,a){var l=(0,i.up)("ToggleSwitch"),s=(0,i.up)("MenuPanel");return(0,i.wg)(),(0,i.j4)(s,null,{default:(0,i.w5)((function(){return[(0,i._)("div",f,[m,b,(0,i._)("div",y,[(0,i.Wm)(l,{value:a.anyLightsOn,onInput:t[0]||(t[0]=function(t){return e.$emit("toggle")})},null,8,["value"])])]),((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(a.groupsSorted,(function(t){return(0,i.wg)(),(0,i.iD)("div",{class:"panel-row row group",key:t.id,onClick:function(n){return e.$emit("select",t.id)}},[(0,i._)("span",w,(0,h.zw)(t.name||"[Group ".concat(t.id,"]")),1),(0,i._)("span",k,[(0,i.Wm)(l,{value:t.state.any_on,disabled:t.id in(n.loadingGroups||{}),onInput:function(n){return e.$emit("toggle",t)}},null,8,["value","disabled","onInput"])])],8,_)})),128))]})),_:1})}n(1249),n(2707);var S={class:"menu-panel"},j={class:"content"};function Z(e,t,n,o,r,a){return(0,i.wg)(),(0,i.iD)("div",S,[(0,i._)("div",j,[(0,i.WI)(e.$slots,"default")])])}var O={name:"MenuPanel"},L=n(3744);const D=(0,L.Z)(O,[["render",Z]]);var M=D,x=n(6),G=n(634),$={name:"Groups",components:{ToggleSwitch:x.Z,MenuPanel:M},emits:["select","toggle"],props:{groups:{type:Object,default:function(){}},loadingGroups:{type:Object,default:function(){}},colorConverter:{type:Object,default:function(){return new G.N}}},computed:{groupsSorted:function(){return Object.entries(this.groups).sort((function(e,t){return e[1].name.localeCompare(t[1].name)})).map((function(e){var t=(0,u.Z)(e,2),n=t[0],i=t[1];return(0,s.Z)((0,s.Z)({},i),{},{id:n})}))},anyLightsOn:function(){for(var e=0,t=Object.values(this.groups);e0}},methods:{toggleSelectAll:function(){var e=this,t=Object.values(this.selectedLights).filter((function(e){return e})).length