"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1406],{634:function(e,t,n){n.d(t,{N:function(){return l}});var o=n(9584);n(1703);function i(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:o=(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 o=.664511*e+.154324*t+.162028*n,i=.283881*e+.668433*t+.047685*n,r=88e-6*e+.07231*t+.986039*n,a=parseFloat((o/(o+i+r)).toFixed(4)),l=parseFloat((i/(o+i+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,o.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,o.Z)(n));if(e.hue&&e.sat&&e.bri){var i=this.hslToRgb(e.hue,e.sat,e.bri);return this.rgbToXY.apply(this,(0,o.Z)(i))}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,o.Z)(t));var n=this.getXY(e);if(n&&e.bri){var i=this.xyToRgb.apply(this,(0,o.Z)(n).concat([e.bri]));return this.rgbToHsl.apply(this,(0,o.Z)(i))}console.debug("Could not determine color space"),console.debug(e)}}]),e}()},1120:function(e,t,n){n.d(t,{Z:function(){return m}});var o=n(6252),i=n(9963),r=n(3577),a={class:"slider-wrapper"},l=["min","max","step","disabled","value"],s={class:"track"},u={class:"track-inner",ref:"track"},c={class:"thumb",ref:"thumb"},g=["textContent"];function d(e,t,n,d,p,h){return(0,o.wg)(),(0,o.iD)("label",a,[(0,o._)("input",{class:"slider",type:"range",ref:"range",min:n.range[0],max:n.range[1],step:n.step,disabled:n.disabled,value:n.value,onInput:t[0]||(t[0]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"])),onChange:t[1]||(t[1]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"])),onMouseup:t[2]||(t[2]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"])),onMousedown:t[3]||(t[3]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"])),onTouchstart:t[4]||(t[4]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"])),onTouchend:t[5]||(t[5]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"])),onKeyup:t[6]||(t[6]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"])),onKeydown:t[7]||(t[7]=(0,i.iM)((function(){return h.onUpdate&&h.onUpdate.apply(h,arguments)}),["stop"]))},null,40,l),(0,o._)("div",s,[(0,o._)("div",u,null,512)]),(0,o._)("div",c,null,512),n.withLabel?((0,o.wg)(),(0,o.iD)("span",{key:0,class:"label",textContent:(0,r.zw)(n.value)},null,8,g)):(0,o.kq)("",!0)])}var p=n(4648),h=(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}},methods:{onUpdate:function(e){this.update(e.target.value),this.$emit(e.type,(0,p.Z)((0,p.Z)({},e),{},{target:(0,p.Z)((0,p.Z)({},e.target),{},{value:this.$refs.range.value})}))},update:function(e){var t=100*e/(this.range[1]-this.range[0]);this.$refs.thumb.style.left="".concat(t,"%"),this.$refs.thumb.style.transform="translate(-".concat(t,"%, -50%)"),this.$refs.track.style.width="".concat(t,"%")}},mounted:function(){null!=this.value&&this.update(this.value)}}),v=n(3744);const f=(0,v.Z)(h,[["render",d],["__scopeId","data-v-288acf82"]]);var m=f},6137:function(e,t,n){n.d(t,{Z:function(){return h}});var o=n(6252),i=n(3577),r=n(9963),a=function(e){return(0,o.dD)("data-v-8e097228"),e=e(),(0,o.Cn)(),e},l=["checked"],s=a((function(){return(0,o._)("div",{class:"switch"},[(0,o._)("div",{class:"dot"})],-1)})),u={class:"label"};function c(e,t,n,a,c,g){return(0,o.wg)(),(0,o.iD)("div",{class:(0,i.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,o._)("input",{type:"checkbox",checked:n.value},null,8,l),(0,o._)("label",null,[s,(0,o._)("span",u,[(0,o.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-8e097228"]]);var h=p},1406:function(e,t,n){n.r(t),n.d(t,{default:function(){return Wt}});n(7941);var o=n(6252),i={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,o.up)("Groups"),g=(0,o.up)("Group");return(0,o.wg)(),(0,o.iD)("div",i,[null==s.selectedGroup&&n.groups&&Object.keys(n.groups).length?((0,o.wg)(),(0,o.iD)("div",r,[(0,o.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,o.wg)(),(0,o.iD)("div",a,[(0,o.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(2628)),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,o.dD)("data-v-42318a2b"),e=e(),(0,o.Cn)(),e},f={class:"panel-row header"},m=v((function(){return(0,o._)("div",{class:"col-3"},[(0,o._)("i",{class:"icon fas fa-home"})],-1)})),b=v((function(){return(0,o._)("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,i,r,a){var l=(0,o.up)("ToggleSwitch"),s=(0,o.up)("MenuPanel");return(0,o.wg)(),(0,o.j4)(s,null,{default:(0,o.w5)((function(){return[(0,o._)("div",f,[m,b,(0,o._)("div",y,[(0,o.Wm)(l,{value:a.anyLightsOn,onInput:t[0]||(t[0]=function(t){return e.$emit("toggle")})},null,8,["value"])])]),((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(a.groupsSorted,(function(t){return(0,o.wg)(),(0,o.iD)("div",{class:"panel-row row group",key:t.id,onClick:function(n){return e.$emit("select",t.id)}},[(0,o._)("span",w,(0,h.zw)(t.name||"[Group ".concat(t.id,"]")),1),(0,o._)("span",k,[(0,o.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,i,r,a){return(0,o.wg)(),(0,o.iD)("div",S,[(0,o._)("div",j,[(0,o.WI)(e.$slots,"default")])])}var O={name:"MenuPanel"},M=n(3744);const L=(0,M.Z)(O,[["render",Z]]);var D=L,G=n(6137),$=n(634),I={name:"Groups",components:{ToggleSwitch:G.Z,MenuPanel:D},emits:["select","toggle"],props:{groups:{type:Object,default:function(){}},loadingGroups:{type:Object,default:function(){}},colorConverter:{type:Object,default:function(){return new $.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],o=t[1];return(0,s.Z)((0,s.Z)({},o),{},{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