platypush/platypush/backend/http/webapp/dist/static/js/1406-legacy.41c0c47e.js

2 lines
34 KiB
JavaScript

"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<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}n(7941),n(6977),n(1249),n(2222);var l=function(){function e(t){if(i(this,e),this.ranges={hue:[0,360],sat:[0,100],bri:[0,100],ct:[154,500]},t)for(var n=0,o=Object.keys(this.ranges);n<o.length;n++){var r=o[n];t[r]&&(this.ranges[r]=t[r])}}return a(e,[{key:"normalize",value:function(e,t,n){return n[0]+(e-t[0])*(n[1]-n[0])/(t[1]-t[0])}},{key:"hslToRgb",value:function(e,t,n){var o=[this.normalize(e,this.ranges.hue,[0,360]),this.normalize(t,this.ranges.sat,[0,100]),this.normalize(n,this.ranges.bri,[0,100])];e=o[0],t=o[1],n=o[2],n/=100;var i=t*Math.min(n,1-n)/100,r=function(t){var o=(t+e/30)%12,r=n-i*Math.max(Math.min(o-3,9-o,1),-1);return Math.round(255*r)};return[r(0),r(8),r(4)]}},{key:"rgbToHsl",value:function(e,t,n){e/=255,t/=255,n/=255;var o,i,r=Math.max(e,t,n),a=Math.min(e,t,n),l=(r+a)/2;if(r===a)o=i=0;else{var s=r-a;switch(i=l>.5?s/(2-r-a):s/(r+a),r){case e:o=(t-n)/s+(t<n?6:0);break;case t:o=(n-e)/s+2;break;case n:o=(e-t)/s+4;break}o/=6}return[parseInt(this.normalize(o,[0,1],this.ranges.hue)),parseInt(this.normalize(i,[0,1],this.ranges.sat)),parseInt(this.normalize(l,[0,1],this.ranges.bri))]}},{key:"xyToRgb",value:function(e,t,n){null==n&&(n=this.ranges.bri[1]);var o=1-e-t,i=(n/(this.ranges.bri[1]-1)).toFixed(2),r=i/t*e,a=i/t*o,l=1.656492*r-.354851*i-.255038*a,s=.707196*-r+1.655397*i+.036152*a,u=.051713*r-.121364*i+1.01153*a;return l>u&&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);e<t.length;e++){var n,o=t[e];if(null!==o&&void 0!==o&&null!==(n=o.state)&&void 0!==n&&n.any_on)return!0}return!1}}};const T=(0,M.Z)(I,[["render",C],["__scopeId","data-v-42318a2b"]]);var U=T,x={class:"light-group-container"},A={class:"panel-row header"},B={key:0,class:"col-3"},N=(0,o._)("i",{class:"fas fa-chevron-left"},null,-1),W=[N],R=["textContent"],q={key:1,class:"col-3 pull-right"},z={key:0,class:"no-lights"},V={key:1,class:"lights-view"},Y={class:"row view-selector"},H=(0,o._)("i",{class:"icon fas fa-lightbulb"},null,-1),F=[H],P=(0,o._)("i",{class:"icon far fa-image"},null,-1),X=[P],E=(0,o._)("i",{class:"icon fas fa-video"},null,-1),K=[E],J={key:0,class:"view fade-in"},Q=["onClick"],ee={key:1,class:"view fade-in"},te=["onClick"],ne={key:2,class:"view group-controls fade-in"},oe={key:3,class:"view group-controls fade-in"};function ie(e,t,n,i,r,a){var l=(0,o.up)("ToggleSwitch"),s=(0,o.up)("Light"),u=(0,o.up)("Scene"),c=(0,o.up)("Controls"),g=(0,o.up)("Animate"),d=(0,o.up)("MenuPanel");return(0,o.wg)(),(0,o.iD)("div",x,[(0,o.Wm)(d,null,{default:(0,o.w5)((function(){return[(0,o._)("div",A,[n.group?((0,o.wg)(),(0,o.iD)("div",B,[(0,o._)("button",{class:"back-btn",title:"Back",onClick:t[0]||(t[0]=function(){return a.close&&a.close.apply(a,arguments)})},W)])):(0,o.kq)("",!0),(0,o._)("div",{class:(0,h.C_)(["col-6 name",{selected:"group"===r.selectedView}]),textContent:(0,h.zw)(a.groupName),onClick:t[1]||(t[1]=function(e){return r.selectedView="group"===r.selectedView?null:"group"})},null,10,R),n.group?((0,o.wg)(),(0,o.iD)("div",q,[(0,o.Wm)(l,{value:n.group.state.any_on,onInput:t[2]||(t[2]=function(t){return e.$emit("group-toggle",n.group)})},null,8,["value"])])):(0,o.kq)("",!0)]),n.lights&&Object.keys(n.lights).length?((0,o.wg)(),(0,o.iD)("div",V,[(0,o._)("div",Y,[(0,o._)("button",{class:(0,h.C_)({selected:"lights"===r.selectedView}),title:"Lights",onClick:t[3]||(t[3]=function(e){return r.selectedView="lights"})},F,2),(0,o._)("button",{class:(0,h.C_)({selected:"scenes"===r.selectedView}),title:"Scenes",onClick:t[4]||(t[4]=function(e){return r.selectedView="scenes"})},X,2),(0,o._)("button",{class:(0,h.C_)({selected:"animate"===r.selectedView}),title:"Animate",onClick:t[5]||(t[5]=function(e){return r.selectedView="animate"})},K,2)]),"lights"===r.selectedView?((0,o.wg)(),(0,o.iD)("div",J,[((0,o.wg)(),(0,o.j4)(o.Ob,null,[((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(a.lightsSorted,(function(t,i){return(0,o.wg)(),(0,o.iD)("div",{class:(0,h.C_)(["panel-row row",{expanded:t.id===r.selectedLight}]),key:i,onClick:function(e){return r.selectedLight=r.selectedLight===t.id?null:t.id}},[(0,o.Wm)(s,{light:t,group:n.group,collapsed:t.id!==r.selectedLight,"color-converter":n.colorConverter,onToggle:function(n){return e.$emit("light-toggle",t)},onSetLight:function(n){return e.$emit("set-light",{light:t,value:n})}},null,8,["light","group","collapsed","color-converter","onToggle","onSetLight"])],10,Q)})),128))],1024))])):"scenes"===r.selectedView?((0,o.wg)(),(0,o.iD)("div",ee,[((0,o.wg)(),(0,o.j4)(o.Ob,null,[((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(a.scenesSorted,(function(e,t){return(0,o.wg)(),(0,o.iD)("div",{class:(0,h.C_)(["panel-row row",{selected:e.id===r.selectedScene}]),key:t,onClick:function(t){return a.onSceneSelected(e.id)}},[(0,o.Wm)(u,{scene:e,group:n.group},null,8,["scene","group"])],10,te)})),128))],1024))])):"group"===r.selectedView?((0,o.wg)(),(0,o.iD)("div",ne,[((0,o.wg)(),(0,o.j4)(o.Ob,null,[(0,o.Wm)(c,{group:n.group,lights:n.lights,"color-converter":n.colorConverter,onSetGroup:t[6]||(t[6]=function(t){return e.$emit("set-group",t)})},null,8,["group","lights","color-converter"])],1024))])):"animate"===r.selectedView?((0,o.wg)(),(0,o.iD)("div",oe,[((0,o.wg)(),(0,o.j4)(o.Ob,null,[(0,o.Wm)(g,{group:n.group,lights:n.lights,"color-converter":n.colorConverter,"running-animations":n.animations,onStart:t[7]||(t[7]=function(t){return e.$emit("start-animation",t)}),onStop:t[8]||(t[8]=function(t){return e.$emit("stop-animation",t)})},null,8,["group","lights","color-converter","running-animations"])],1024))])):(0,o.kq)("",!0)])):((0,o.wg)(),(0,o.iD)("div",z," No lights found "))]})),_:1})])}var re={class:"row"},ae={class:"toggle col-3 pull-right"},le={key:0,class:"row fade-in"};function se(e,t,n,i,r,a){var l=(0,o.up)("ToggleSwitch"),s=(0,o.up)("Controls");return(0,o.wg)(),(0,o.iD)("div",{class:(0,h.C_)(["light",{expanded:!n.collapsed}]),ref:"element"},[(0,o._)("div",re,[(0,o._)("span",{class:"name col-9",onClick:t[0]||(t[0]=function(){return a.expandToggle&&a.expandToggle.apply(a,arguments)})},(0,h.zw)(n.light.name||"[Light ".concat(n.light.id,"]")),1),(0,o._)("span",ae,[(0,o.Wm)(l,{value:n.light.state.on,disabled:n.loading,onInput:t[1]||(t[1]=function(t){return e.$emit("toggle",n.light)})},null,8,["value","disabled"])])]),n.collapsed?(0,o.kq)("",!0):((0,o.wg)(),(0,o.iD)("div",le,[(0,o.Wm)(s,{light:n.light,loading:n.loading,"color-converter":n.colorConverter,onSetLight:t[2]||(t[2]=function(t){return e.$emit("set-light",t)})},null,8,["light","loading","color-converter"])]))],2)}var ue=n(9963),ce=function(e){return(0,o.dD)("data-v-e2726892"),e=e(),(0,o.Cn)(),e},ge={key:1,class:"row"},de=ce((function(){return(0,o._)("div",{class:"col-1 icon"},[(0,o._)("i",{class:"fas fa-sun"})],-1)})),pe={class:"col-11 control"},he={key:2,class:"row"},ve=ce((function(){return(0,o._)("div",{class:"col-1 icon"},[(0,o._)("i",{class:"fas fa-thermometer-half"})],-1)})),fe={class:"col-11 control"},me={key:3,class:"row"},be=ce((function(){return(0,o._)("span",{class:"col-1 icon"},[(0,o._)("i",{class:"fas fa-palette"})],-1)})),ye={class:"col-11 control"},_e=["value"];function we(e,t,n,i,r,a){var l=(0,o.up)("Loading"),s=(0,o.up)("Slider");return(0,o.wg)(),(0,o.iD)("div",{class:"controls light-controls",onClick:t[3]||(t[3]=function(e){return e.stopPropagation()})},[n.loading?((0,o.wg)(),(0,o.j4)(l,{key:0})):(0,o.kq)("",!0),null!=a.state.bri?((0,o.wg)(),(0,o.iD)("div",ge,[de,(0,o._)("div",pe,[(0,o.Wm)(s,{range:n.colorConverter.ranges.bri,disabled:n.loading,value:a.state.bri,onMouseup:t[0]||(t[0]=(0,ue.iM)((function(t){return e.$emit(n.light?"set-light":"set-group",{brightness:parseInt(t.target.value)})}),["stop"]))},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),null!=a.state.ct?((0,o.wg)(),(0,o.iD)("div",he,[ve,(0,o._)("div",fe,[(0,o.Wm)(s,{range:n.colorConverter.ranges.ct,disabled:n.loading,value:a.state.ct,onMouseup:t[1]||(t[1]=(0,ue.iM)((function(t){return e.$emit(n.light?"set-light":"set-group",{temperature:parseInt(t.target.value)})}),["stop"]))},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),a.rgbColor?((0,o.wg)(),(0,o.iD)("label",me,[be,(0,o._)("span",ye,[(0,o._)("input",{type:"color",value:a.rgbColor,onChange:t[2]||(t[2]=(0,ue.iM)((function(){return a.onColorSelect&&a.onColorSelect.apply(a,arguments)}),["stop"]))},null,40,_e)])])):(0,o.kq)("",!0)])}var ke=n(9584),Ce=(n(3948),n(2222),n(9600),n(9714),n(4916),n(3123),n(7042),n(1120)),Se=n(1232),je={name:"Controls",components:{Loading:Se.Z,Slider:Ce.Z},emits:["set-light","set-group"],props:{light:{type:Object},lights:{type:Object},group:{type:Object},loading:{type:Boolean,default:!1},colorConverter:{type:Object,default:function(){return new $.N}}},computed:{state:function(){var e,t;if(null!==(e=this.light)&&void 0!==e&&e.state)return this.light.state;var n=(null===(t=this.group)||void 0===t?void 0:t.state)||{};if(!this.lights)return n;var o=function e(t){return t&&t.length?t[0]instanceof Array?(0,ke.Z)(t[0].keys()).map((function(n){return e(t.map((function(e){return e[n]})))})):t.reduce((function(e,t){return e+t}),0)/t.length:0};return(0,s.Z)((0,s.Z)({},n),Object.entries(Object.values(this.lights).reduce((function(e,t){return["bri","hue","sat","rgb","xy","red","green","blue","ct"].forEach((function(n){var o;null!=(null===(o=t.state)||void 0===o?void 0:o[n])&&(e[n]=[].concat((0,ke.Z)(e[n]||[]),[t.state[n]]))})),e}),{})).reduce((function(e,t){var n=(0,u.Z)(t,2),i=n[0],r=n[1];return e[i]=o(r),e}),{}))},color:function(){return this.getColor(this.state)},rgbColor:function(){var e=this.colorConverter.toRGB(this.state);return e?"#"+e.map((function(e){var t=e.toString(16);return t.length<2&&(t="0"+t),t})).join(""):null}},methods:{onColorSelect:function(e){var t,n,o,i=e.target.value.slice(1).split(/(?=(?:..)*$)/).map((function(e){return parseInt("0x".concat(e))}));this.$emit(this.light?"set-light":"set-group",{rgb:i,xy:(t=this.colorConverter).rgbToXY.apply(t,(0,ke.Z)(i)),hsl:(n=this.colorConverter).rgbToHsl.apply(n,(0,ke.Z)(i)),brightness:(o=this.colorConverter).rgbToBri.apply(o,(0,ke.Z)(i))})},getColor:function(e){return{rgb:this.colorConverter.toRGB(e),xy:this.colorConverter.toXY(e),hsl:this.colorConverter.toHSL(e)}}}};const Ze=(0,M.Z)(je,[["render",we],["__scopeId","data-v-e2726892"]]);var Oe=Ze,Me={name:"Light",components:{Controls:Oe,ToggleSwitch:G.Z},emits:["toggle","set-light","collapsed","expanded"],props:{light:{type:Object,default:function(){}},group:{type:Object,default:function(){}},loading:{type:Boolean,default:!1},collapsed:{type:Boolean,default:!0},colorConverter:{type:Object,default:function(){return new $.N}}},methods:{expandToggle:function(){this.$emit(this.collapsed?"expanded":"collapsed")}}};const Le=(0,M.Z)(Me,[["render",se],["__scopeId","data-v-52168252"]]);var De=Le;function Ge(e,t,n,i,r,a){var l=(0,o.up)("Loading");return(0,o.wg)(),(0,o.iD)(o.HY,null,[n.loading?((0,o.wg)(),(0,o.j4)(l,{key:0})):(0,o.kq)("",!0),(0,o._)("div",{class:"scene row name",onClick:t[0]||(t[0]=function(){return a.onSelect&&a.onSelect.apply(a,arguments)})},(0,h.zw)(n.scene.name||"[Scene ".concat(n.scene.id,"]")),1)],64)}var $e={name:"Light",emits:["select"],props:{scene:{type:Object,default:function(){}},group:{type:Object,default:function(){}},loading:{type:Boolean,default:!1}},methods:{onSelect:function(){if(this.loading)return!1;this.$emit("select")}}};const Ie=(0,M.Z)($e,[["render",Ge]]);var Te=Ie,Ue=(n(7327),function(e){return(0,o.dD)("data-v-1739aaba"),e=e(),(0,o.Cn)(),e}),xe={class:"animation-container"},Ae={class:"animation-header"},Be={class:"row"},Ne=Ue((function(){return(0,o._)("div",{class:"col-3"}," Run Animation ",-1)})),We={class:"col-9"},Re={class:"row"},qe=Ue((function(){return(0,o._)("div",{class:"col-3"},"Animation",-1)})),ze={class:"col-9"},Ve=Ue((function(){return(0,o._)("option",{value:"color_transition"},"Color transition",-1)})),Ye=Ue((function(){return(0,o._)("option",{value:"blink"},"Blink",-1)})),He=[Ve,Ye],Fe={class:"animation"},Pe={key:0,class:"row"},Xe=Ue((function(){return(0,o._)("div",{class:"col-3"}," Hue range ",-1)})),Ee={class:"col-9"},Ke={key:1,class:"row"},Je=Ue((function(){return(0,o._)("div",{class:"col-3"}," Sat range ",-1)})),Qe={class:"col-9"},et={key:2,class:"row"},tt=Ue((function(){return(0,o._)("div",{class:"col-3"}," Bri range ",-1)})),nt={class:"col-9"},ot={key:3,class:"row"},it=Ue((function(){return(0,o._)("div",{class:"col-3"}," Hue step ",-1)})),rt={class:"col-9"},at={key:4,class:"row"},lt=Ue((function(){return(0,o._)("div",{class:"col-3"}," Sat step ",-1)})),st={class:"col-9"},ut={key:5,class:"row"},ct=Ue((function(){return(0,o._)("div",{class:"col-3"}," Bri step ",-1)})),gt={class:"col-9"},dt={class:"row"},pt=Ue((function(){return(0,o._)("div",{class:"col-3"}," Refresh seconds ",-1)})),ht={class:"col-9"},vt=["value"],ft={class:"row"},mt=Ue((function(){return(0,o._)("div",{class:"col-3"}," Duration (seconds) ",-1)})),bt={class:"col-9"},yt=["value"],_t={class:"lights"},wt={class:"row"},kt=["checked"],Ct=(0,o.Uk)(" Select all lights "),St=["onUpdate:modelValue","onInput"];function jt(e,t,n,i,r,a){var l=(0,o.up)("Loading"),s=(0,o.up)("ToggleSwitch"),u=(0,o.up)("RangeSlider"),c=(0,o.up)("Slider");return(0,o.wg)(),(0,o.iD)("div",{class:"controls animation-controls",onClick:t[10]||(t[10]=function(e){return e.stopPropagation()})},[n.loading?((0,o.wg)(),(0,o.j4)(l,{key:0})):(0,o.kq)("",!0),(0,o._)("div",xe,[(0,o._)("div",Ae,[(0,o._)("div",Be,[Ne,(0,o._)("div",We,[(0,o.Wm)(s,{value:a.animationRunning,onInput:a.toggleAnimation},null,8,["value","onInput"])])]),(0,o._)("div",Re,[qe,(0,o._)("div",ze,[(0,o._)("label",null,[(0,o._)("select",{class:"selector",onClick:t[0]||(t[0]=function(e){return r.selectedAnimation=e.target.value})},He)])])])]),(0,o._)("div",Fe,["color_transition"===r.selectedAnimation?((0,o.wg)(),(0,o.iD)("div",Pe,[Xe,(0,o._)("div",Ee,[(0,o.Wm)(u,{range:n.colorConverter.ranges.hue,disabled:n.loading,value:r.animations.color_transition.hue_range,onMouseup:t[1]||(t[1]=function(e){return r.animations.color_transition.hue_range=e.target.value})},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),"color_transition"===r.selectedAnimation?((0,o.wg)(),(0,o.iD)("div",Ke,[Je,(0,o._)("div",Qe,[(0,o.Wm)(u,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.sat_range,onMouseup:t[2]||(t[2]=function(e){return r.animations.color_transition.sat_range=e.target.value})},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),"color_transition"===r.selectedAnimation?((0,o.wg)(),(0,o.iD)("div",et,[tt,(0,o._)("div",nt,[(0,o.Wm)(u,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.bri_range,onMouseup:t[3]||(t[3]=function(e){return r.animations.color_transition.bri_range=e.target.value})},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),"color_transition"===r.selectedAnimation?((0,o.wg)(),(0,o.iD)("div",ot,[it,(0,o._)("div",rt,[(0,o.Wm)(c,{range:n.colorConverter.ranges.hue,disabled:n.loading,value:r.animations.color_transition.hue_step,onMouseup:t[4]||(t[4]=function(e){return r.animations.color_transition.hue_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),"color_transition"===r.selectedAnimation?((0,o.wg)(),(0,o.iD)("div",at,[lt,(0,o._)("div",st,[(0,o.Wm)(c,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.sat_step,onMouseup:t[5]||(t[5]=function(e){return r.animations.color_transition.sat_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),"color_transition"===r.selectedAnimation?((0,o.wg)(),(0,o.iD)("div",ut,[ct,(0,o._)("div",gt,[(0,o.Wm)(c,{range:n.colorConverter.ranges.bri,disabled:n.loading,value:r.animations.color_transition.bri_step,onMouseup:t[6]||(t[6]=function(e){return r.animations.color_transition.bri_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):(0,o.kq)("",!0),(0,o._)("div",dt,[pt,(0,o._)("div",ht,[(0,o._)("label",null,[(0,o._)("input",{type:"number",value:r.animations[r.selectedAnimation].transition_seconds,step:"0.1",onInput:t[7]||(t[7]=function(e){return r.animations[r.selectedAnimation].transition_seconds=parseFloat(e.target.value)})},null,40,vt)])])]),(0,o._)("div",ft,[mt,(0,o._)("div",bt,[(0,o._)("label",null,[(0,o._)("input",{type:"number",value:r.animations[r.selectedAnimation].duration,step:"5",onInput:t[8]||(t[8]=function(e){var t;return r.animations[r.selectedAnimation].duration=null!==(t=e.target.value)&&void 0!==t&&t.length?parseFloat(e.target.value):null})},null,40,yt)])])])])]),(0,o._)("div",_t,[(0,o._)("div",wt,[(0,o._)("label",null,[(0,o._)("input",{type:"checkbox",checked:Object.keys(n.lights).length===Object.values(r.selectedLights).filter((function(e){return e})).length,onClick:t[9]||(t[9]=function(){return a.toggleSelectAll&&a.toggleSelectAll.apply(a,arguments)})},null,8,kt),Ct])]),((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(n.lights,(function(e,t){return(0,o.wg)(),(0,o.iD)("div",{class:"row",key:t},[(0,o._)("label",null,[(0,o.wy)((0,o._)("input",{type:"checkbox","onUpdate:modelValue":function(e){return r.selectedLights[t]=e},onInput:function(e){return r.selectedLights[t]=!r.selectedLights[t]}},null,40,St),[[ue.e8,r.selectedLights[t]]]),(0,o.Uk)(" "+(0,h.zw)(e.name),1)])])})),128))])])}var Zt={class:"range-wrapper"},Ot=["value","min","max","step","disabled"];function Mt(e,t,n,i,r,a){return(0,o.wg)(),(0,o.iD)("div",Zt,[((0,o.wg)(!0),(0,o.iD)(o.HY,null,(0,o.Ko)(n.value,(function(e,i){return(0,o.wg)(),(0,o.iD)("input",{class:"slider",type:"range",value:e,min:n.range[0],max:n.range[1],step:n.step,disabled:n.disabled,ref_for:!0,ref:"ranges",onInput:t[0]||(t[0]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),onChange:t[1]||(t[1]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),onMouseup:t[2]||(t[2]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),onMousedown:t[3]||(t[3]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),onTouchstart:t[4]||(t[4]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),onTouchend:t[5]||(t[5]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),onKeyup:t[6]||(t[6]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),onKeydown:t[7]||(t[7]=(0,ue.iM)((function(){return a.onUpdate&&a.onUpdate.apply(a,arguments)}),["stop"])),key:i},null,40,Ot)})),128))])}var Lt={name:"RangeSlider",emits:["input","change","mouseup","mousedown","touchstart","touchend","keyup","keydown"],props:{disabled:{type:Boolean,default:!1},range:{type:Array,default:function(){return[0,100]}},step:{type:Number,default:1},value:{type:Array,default:function(){return[0,100]}}},methods:{onUpdate:function(e){this.$emit(e.type,(0,s.Z)((0,s.Z)({},e),{},{target:(0,s.Z)((0,s.Z)({},e.target),{},{value:this.$refs.ranges.map((function(e){return parseFloat(e.value)})).sort()})}))}}};const Dt=(0,M.Z)(Lt,[["render",Mt],["__scopeId","data-v-981c5de0"]]);var Gt=Dt,$t={name:"Animate",mixins:[c.Z],components:{ToggleSwitch:G.Z,Slider:Ce.Z,RangeSlider:Gt,Loading:Se.Z},emits:["start","stop"],props:{lights:{type:Object},group:{type:Object},loading:{type:Boolean,default:!1},colorConverter:{type:Object,default:function(){return new $.N}},runningAnimations:{type:Object,default:function(){}}},data:function(){return{selectedAnimation:"color_transition",animation:{},selectedLights:Object.keys(this.lights).reduce((function(e,t){return e[t]=!0,e}),{}),animations:{color_transition:{hue_range:this.colorConverter.ranges.hue,sat_range:[parseInt((this.colorConverter.ranges.sat[1]-this.colorConverter.ranges.sat[0])/2),this.colorConverter.ranges.sat[1]],bri_range:[parseInt(.75*(this.colorConverter.ranges.bri[1]-this.colorConverter.ranges.bri[0])),this.colorConverter.ranges.bri[1]],hue_step:parseInt((this.colorConverter.ranges.hue[1]-this.colorConverter.ranges.hue[0])/25),sat_step:parseInt((this.colorConverter.ranges.sat[1]-this.colorConverter.ranges.sat[0])/50),bri_step:parseInt((this.colorConverter.ranges.bri[1]-this.colorConverter.ranges.bri[0])/50),transition_seconds:1,duration:null},blink:{transition_seconds:1,duration:null}}}},computed:{animationRunning:function(){return Object.keys(this.runningAnimations).length>0}},methods:{toggleSelectAll:function(){var e=this,t=Object.values(this.selectedLights).filter((function(e){return e})).length<Object.keys(this.lights).length;Object.keys(this.lights).forEach((function(n){e.selectedLights[n]=t}))},toggleAnimation:function(){var e=this.animationRunning?"stop":"start",t=Object.entries(this.selectedLights).filter((function(e){return e[1]})).map((function(e){return e[0]}));t.length?this.$emit(e,{lights:t,animation:(0,s.Z)((0,s.Z)({},this.animations[this.selectedAnimation]),{},{animation:this.selectedAnimation})}):this.warn("No lights have been selected")}}};const It=(0,M.Z)($t,[["render",jt],["__scopeId","data-v-1739aaba"]]);var Tt=It,Ut={name:"Group",emits:["close","group-toggle","light-toggle","set-light","select-scene","start-animation","stop-animation"],components:{Animate:Tt,ToggleSwitch:G.Z,MenuPanel:D,Light:De,Scene:Te,Controls:Oe},props:{lights:{type:Object},group:{type:Object},scenes:{type:Object},animations:{type:Object,default:function(){}},colorConverter:{type:Object,default:function(){return new $.N}}},data:function(){return{selectedLight:null,selectedScene:null,selectedView:"lights"}},computed:{lightsSorted:function(){return this.lights?Object.entries(this.lights).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})})):[]},scenesSorted:function(){return this.scenes?Object.entries(this.scenes).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})})):[]},groupName:function(){var e,t;return null!==(e=this.group)&&void 0!==e&&e.name?this.group.name:null!=(null===(t=this.group)||void 0===t?void 0:t.id)?"[Group ".concat(this.group.id,"]"):"Lights"}},methods:{close:function(e){e.stopPropagation(),this.$emit("close")},onSceneSelected:function(e){this.selectedScene=e,this.$emit("select-scene",e)}}};const xt=(0,M.Z)(Ut,[["render",ie]]);var At=xt,Bt={name:"Light",components:{Group:At,Groups:U},mixins:[c.Z,p],emits:["group-toggle","light-toggle","set-light","set-group","select-scene","start-animation","stop-animation","refresh","light-changed"],props:{lights:{type:Object},groups:{type:Object},scenes:{type:Object},animations:{type:Object},colorConverter:{type:Object,default:function(){return new $.N}},loadingLights:{type:Object,default:function(){}},loadingGroups:{type:Object,default:function(){}},pluginName:{type:String},initialGroup:{type:[Number,String]}},data:function(){return{selectedGroup:null,initialized:!1}},computed:{displayedLights:function(){var e=this,t=this.selectedGroup||this.initialGroup;return null==t?this.lights:this.groups[t].lights.reduce((function(t,n){return t[n]=e.lights[n],t}),{})},groupsByLight:function(){return this.groups?Object.entries(this.groups).reduce((function(e,t){var n=(0,u.Z)(t,2),o=n[0],i=n[1];return i.lights.forEach((function(t){e[t]||(e[t]={}),e[t][o]=i})),e}),{}):{}},scenesByGroup:function(){if(!this.scenes)return{};var e=this;return Object.entries(this.scenes).reduce((function(t,n){var o=(0,u.Z)(n,2),i=o[0],r=o[1];return r.lights.forEach((function(n){Object.keys(e.groupsByLight[n]).forEach((function(e){t[e]||(t[e]={}),t[e][i]=r}))})),t}),{})},animationsByGroup:function(){var e,t,n=this,o=Object.entries((null===(e=this.animations)||void 0===e?void 0:e.groups)||{}).reduce((function(e,t){var n=(0,u.Z)(t,2),o=n[0],i=n[1];return e[o]={},i&&(e[o][null]=i),e}),{});return(0,s.Z)((0,s.Z)({},o),Object.entries((null===(t=this.animations)||void 0===t?void 0:t.lights)||{}).reduce((function(e,t){var o,i=(0,u.Z)(t,2),r=i[0],a=i[1],l=null===(o=Object.values(n.groupsByLight[r]))||void 0===o?void 0:o[0];return l&&a&&null!=l.id&&(e[l.id]||(e[l.id]={}),e[l.id][r]=a),e}),{}))}},methods:{initSelectedGroup:function(){var e=this,t=this.$watch((function(){return e.initialGroup}),(function(n){e.initialized||(e.initialized=!0,t(),null==e.selectedGroup&&null!=n&&(e.selectedGroup=e.initialGroup))}))},refresh:function(){this.$emit("refresh")},onLightChange:function(e){if(e.plugin_name===this.pluginName)if(this.lights[e.light_id]){var t=(0,s.Z)({},e),n=t.light_id;delete t.light_id,delete t.type,delete t.plugin_name,this.$emit("light-changed",{id:n,state:t})}else this.refresh()},onAnimationChange:function(e){e.plugin_name===this.pluginName&&this.refresh()}},mounted:function(){this.subscribe(this.onLightChange,"on-light-change","platypush.message.event.light.LightStatusChangeEvent"),this.subscribe(this.onAnimationChange,"on-animation-change","platypush.message.event.light.LightAnimationStartedEvent","platypush.message.event.light.LightAnimationStoppedEvent"),this.initSelectedGroup()},unmounted:function(){this.unsubscribe("on-light-change"),this.unsubscribe("on-animation-change")}};const Nt=(0,M.Z)(Bt,[["render",l],["__scopeId","data-v-781dd72c"]]);var Wt=Nt}}]);
//# sourceMappingURL=1406-legacy.41c0c47e.js.map