platypush/platypush/backend/http/webapp/dist/static/js/chunk-cc8a6536.a5da26b6.js

2 lines
33 KiB
JavaScript

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-cc8a6536"],{"084e":function(e,t,n){"use strict";n("1015")},1015:function(e,t,n){},1804:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));n("99af"),n("d81d"),n("b680"),n("b64b");var i=n("2909");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<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function c(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=function(){function e(t){if(o(this,e),this.ranges={hue:[0,360],sat:[0,100],bri:[0,100],ct:[154,500]},t)for(var n=0,i=Object.keys(this.ranges);n<i.length;n++){var r=i[n];t[r]&&(this.ranges[r]=t[r])}}return c(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 i=[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=i[0],t=i[1],n=i[2],n/=100;var o=t*Math.min(n,1-n)/100,r=function(t){var i=(t+e/30)%12,r=n-o*Math.max(Math.min(i-3,9-i,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 i,o,r=Math.max(e,t,n),c=Math.min(e,t,n),a=(r+c)/2;if(r===c)i=o=0;else{var s=r-c;switch(o=a>.5?s/(2-r-c):s/(r+c),r){case e:i=(t-n)/s+(t<n?6:0);break;case t:i=(n-e)/s+2;break;case n:i=(e-t)/s+4;break}i/=6}return[parseInt(this.normalize(i,[0,1],this.ranges.hue)),parseInt(this.normalize(o,[0,1],this.ranges.sat)),parseInt(this.normalize(a,[0,1],this.ranges.bri))]}},{key:"xyToRgb",value:function(e,t,n){null==n&&(n=this.ranges.bri[1]);var i=1-e-t,o=(n/(this.ranges.bri[1]-1)).toFixed(2),r=o/t*e,c=o/t*i,a=1.656492*r-.354851*o-.255038*c,s=.707196*-r+1.655397*o+.036152*c,l=.051713*r-.121364*o+1.01153*c;return a>l&&a>s&&a>1?(s/=a,l/=a,a=1):s>l&&s>a&&s>1?(a/=s,l/=s,s=1):l>a&&l>s&&l>1&&(a/=l,s/=l,l=1),a=a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055,s=s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055,l=l<=.0031308?12.92*l:1.055*Math.pow(l,1/2.4)-.055,a=Math.round(255*a),s=Math.round(255*s),l=Math.round(255*l),isNaN(a)&&(a=0),isNaN(s)&&(s=0),isNaN(l)&&(l=0),[a,s,l].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,c=parseFloat((i/(i+o+r)).toFixed(4)),a=parseFloat((o/(i+o+r)).toFixed(4));return isNaN(c)&&(c=0),isNaN(a)&&(a=0),[c,a]}},{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,Object(i["a"])(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,Object(i["a"])(n));if(e.hue&&e.sat&&e.bri){var o=this.hslToRgb(e.hue,e.sat,e.bri);return this.rgbToXY.apply(this,Object(i["a"])(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,Object(i["a"])(t));var n=this.getXY(e);if(n&&e.bri){var o=this.xyToRgb.apply(this,Object(i["a"])(n).concat([e.bri]));return this.rgbToHsl.apply(this,Object(i["a"])(o))}console.debug("Could not determine color space"),console.debug(e)}}]),e}()},"1e15":function(e,t,n){"use strict";n("428e")},4022:function(e,t,n){"use strict";n("a132")},"406a":function(e,t,n){"use strict";n("965d")},"428e":function(e,t,n){},"538b":function(e,t,n){},"5a65":function(e,t,n){},6055:function(e,t,n){},"73e5":function(e,t,n){"use strict";n("538b")},"74ae":function(e,t,n){},"7e57":function(e,t,n){"use strict";n("e3f0")},"876b":function(e,t,n){"use strict";n("5a65")},"8dcb":function(e,t,n){"use strict";n("d28c")},"93d8":function(e,t,n){"use strict";n("6055")},"965d":function(e,t,n){},a132:function(e,t,n){},b322:function(e,t,n){"use strict";n("74ae")},bf6b:function(e,t,n){"use strict";n("fda1")},cf99:function(e,t,n){"use strict";n.r(t);n("b64b");var i=n("7a23"),o=Object(i["K"])("data-v-781dd72c");Object(i["u"])("data-v-781dd72c");var r={class:"plugin lights-plugin"},c={key:0,class:"panel"},a={key:1,class:"panel"};Object(i["s"])();var s=o((function(e,t,n,o,s,l){var u=Object(i["z"])("Groups"),b=Object(i["z"])("Group");return Object(i["r"])(),Object(i["e"])("div",r,[null==s.selectedGroup&&n.groups&&Object.keys(n.groups).length?(Object(i["r"])(),Object(i["e"])("div",c,[Object(i["h"])(u,{groups:n.groups,"loading-groups":n.loadingGroups,"color-converter":n.colorConverter,onSelect:t[1]||(t[1]=function(e){return s.selectedGroup=e}),onToggle:t[2]||(t[2]=function(t){return e.$emit("group-toggle",t)})},null,8,["groups","loading-groups","color-converter"])])):(Object(i["r"])(),Object(i["e"])("div",a,[Object(i["h"])(b,{group:n.groups[s.selectedGroup],lights:l.displayedLights,scenes:l.scenesByGroup[s.selectedGroup],"color-converter":n.colorConverter,animations:l.animationsByGroup[s.selectedGroup],onClose:t[3]||(t[3]=function(e){return s.selectedGroup=null}),onLightToggle:t[4]||(t[4]=function(t){return e.$emit("light-toggle",t)}),onGroupToggle:t[5]||(t[5]=function(t){return e.$emit("group-toggle",t)}),onSetLight:t[6]||(t[6]=function(t){return e.$emit("set-light",t)}),onSetGroup:t[7]||(t[7]=function(t){return e.$emit("set-group",{groupId:s.selectedGroup,value:t})}),onSelectScene:t[8]||(t[8]=function(t){return e.$emit("select-scene",{groupId:s.selectedGroup,sceneId:t})}),onStartAnimation:t[9]||(t[9]=function(t){return e.$emit("start-animation",t)}),onStopAnimation:t[10]||(t[10]=function(t){return e.$emit("stop-animation",t)})},null,8,["group","lights","scenes","color-converter","animations"])]))])})),l=(n("4160"),n("13d5"),n("a9e3"),n("4fad"),n("07ac"),n("159b"),n("5530")),u=n("3835"),b=n("3e54"),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)}},d=g,h=(n("b0c0"),Object(i["K"])("data-v-42318a2b"));Object(i["u"])("data-v-42318a2b");var p={class:"panel-row header"},O=Object(i["h"])("div",{class:"col-3"},[Object(i["h"])("i",{class:"icon fas fa-home"})],-1),j=Object(i["h"])("div",{class:"col-6 name"}," Rooms ",-1),v={class:"col-3 pull-right"},f={class:"name col-9"},m={class:"controls col-3 pull-right"};Object(i["s"])();var y=h((function(e,t,n,o,r,c){var a=Object(i["z"])("ToggleSwitch"),s=Object(i["z"])("MenuPanel");return Object(i["r"])(),Object(i["e"])(s,null,{default:h((function(){return[Object(i["h"])("div",p,[O,j,Object(i["h"])("div",v,[Object(i["h"])(a,{value:c.anyLightsOn,onInput:t[1]||(t[1]=function(t){return e.$emit("toggle")})},null,8,["value"])])]),(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(c.groupsSorted,(function(t){return Object(i["r"])(),Object(i["e"])("div",{class:"panel-row row group",key:t.id,onClick:function(n){return e.$emit("select",t.id)}},[Object(i["h"])("span",f,Object(i["C"])(t.name||"[Group ".concat(t.id,"]")),1),Object(i["h"])("span",m,[Object(i["h"])(a,{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,["onClick"])})),128))]})),_:1})})),C=(n("d81d"),{class:"menu-panel"}),w={class:"content"};function k(e,t,n,o,r,c){return Object(i["r"])(),Object(i["e"])("div",C,[Object(i["h"])("div",w,[Object(i["y"])(e.$slots,"default")])])}var _={name:"MenuPanel"};n("4022");_.render=k;var S=_,L=n("0279"),G=n("1804"),$={name:"Groups",components:{ToggleSwitch:L["a"],MenuPanel:S},emits:["select","toggle"],props:{groups:{type:Object,default:function(){}},loadingGroups:{type:Object,default:function(){}},colorConverter:{type:Object,default:function(){return new G["a"]}}},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=Object(u["a"])(e,2),n=t[0],i=t[1];return Object(l["a"])(Object(l["a"])({},i),{},{id:n})}))},anyLightsOn:function(){for(var e=0,t=Object.values(this.groups);e<t.length;e++){var n,i=t[e];if(null===i||void 0===i||null===(n=i.state)||void 0===n?void 0:n.any_on)return!0}return!1}}};n("8dcb");$.render=y,$.__scopeId="data-v-42318a2b";var x=$,A={class:"light-group-container"},T={class:"panel-row header"},I={key:0,class:"col-3"},M=Object(i["h"])("i",{class:"fas fa-chevron-left"},null,-1),z={key:1,class:"col-3 pull-right"},B={key:0,class:"no-lights"},R={key:1,class:"lights-view"},N={class:"row view-selector"},E=Object(i["h"])("i",{class:"icon fas fa-lightbulb"},null,-1),V=Object(i["h"])("i",{class:"icon far fa-image"},null,-1),F=Object(i["h"])("i",{class:"icon fas fa-video"},null,-1),H={key:0,class:"view fade-in"},P={key:1,class:"view fade-in"},X={key:2,class:"view group-controls fade-in"},Y={key:3,class:"view group-controls fade-in"};function K(e,t,n,o,r,c){var a=Object(i["z"])("ToggleSwitch"),s=Object(i["z"])("Light"),l=Object(i["z"])("Scene"),u=Object(i["z"])("Controls"),b=Object(i["z"])("Animate"),g=Object(i["z"])("MenuPanel");return Object(i["r"])(),Object(i["e"])("div",A,[Object(i["h"])(g,null,{default:Object(i["H"])((function(){return[Object(i["h"])("div",T,[n.group?(Object(i["r"])(),Object(i["e"])("div",I,[Object(i["h"])("button",{class:"back-btn",title:"Back",onClick:t[1]||(t[1]=function(){return c.close.apply(c,arguments)})},[M])])):Object(i["f"])("",!0),Object(i["h"])("div",{class:["col-6 name",{selected:"group"===r.selectedView}],textContent:Object(i["C"])(c.groupName),onClick:t[2]||(t[2]=function(e){return r.selectedView="group"===r.selectedView?null:"group"})},null,10,["textContent"]),n.group?(Object(i["r"])(),Object(i["e"])("div",z,[Object(i["h"])(a,{value:n.group.state.any_on,onInput:t[3]||(t[3]=function(t){return e.$emit("group-toggle",n.group)})},null,8,["value"])])):Object(i["f"])("",!0)]),n.lights&&Object.keys(n.lights).length?(Object(i["r"])(),Object(i["e"])("div",R,[Object(i["h"])("div",N,[Object(i["h"])("button",{class:{selected:"lights"===r.selectedView},title:"Lights",onClick:t[4]||(t[4]=function(e){return r.selectedView="lights"})},[E],2),Object(i["h"])("button",{class:{selected:"scenes"===r.selectedView},title:"Scenes",onClick:t[5]||(t[5]=function(e){return r.selectedView="scenes"})},[V],2),Object(i["h"])("button",{class:{selected:"animate"===r.selectedView},title:"Animate",onClick:t[6]||(t[6]=function(e){return r.selectedView="animate"})},[F],2)]),"lights"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",H,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(c.lightsSorted,(function(t,o){return Object(i["r"])(),Object(i["e"])("div",{class:["panel-row row",{expanded:t.id===r.selectedLight}],key:o,onClick:function(e){return r.selectedLight=r.selectedLight===t.id?null:t.id}},[Object(i["h"])(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,["onClick"])})),128))],1024))])):"scenes"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",P,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(c.scenesSorted,(function(e,t){return Object(i["r"])(),Object(i["e"])("div",{class:["panel-row row",{selected:e.id===r.selectedScene}],key:t,onClick:function(t){return c.onSceneSelected(e.id)}},[Object(i["h"])(l,{scene:e,group:n.group},null,8,["scene","group"])],10,["onClick"])})),128))],1024))])):"group"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",X,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[Object(i["h"])(u,{group:n.group,lights:n.lights,"color-converter":n.colorConverter,onSetGroup:t[7]||(t[7]=function(t){return e.$emit("set-group",t)})},null,8,["group","lights","color-converter"])],1024))])):"animate"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",Y,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[Object(i["h"])(b,{group:n.group,lights:n.lights,"color-converter":n.colorConverter,"running-animations":n.animations,onStart:t[8]||(t[8]=function(t){return e.$emit("start-animation",t)}),onStop:t[9]||(t[9]=function(t){return e.$emit("stop-animation",t)})},null,8,["group","lights","color-converter","running-animations"])],1024))])):Object(i["f"])("",!0)])):(Object(i["r"])(),Object(i["e"])("div",B," No lights found "))]})),_:1})])}var J=Object(i["K"])("data-v-52168252");Object(i["u"])("data-v-52168252");var U={class:"row"},q={class:"toggle col-3 pull-right"},D={key:0,class:"row fade-in"};Object(i["s"])();var Q=J((function(e,t,n,o,r,c){var a=Object(i["z"])("ToggleSwitch"),s=Object(i["z"])("Controls");return Object(i["r"])(),Object(i["e"])("div",{class:["light",{expanded:!n.collapsed}],ref:"element"},[Object(i["h"])("div",U,[Object(i["h"])("span",{class:"name col-9",onClick:t[1]||(t[1]=function(){return c.expandToggle.apply(c,arguments)})},Object(i["C"])(n.light.name||"[Light ".concat(n.light.id,"]")),1),Object(i["h"])("span",q,[Object(i["h"])(a,{value:n.light.state.on,disabled:n.loading,onInput:t[2]||(t[2]=function(t){return e.$emit("toggle",n.light)})},null,8,["value","disabled"])])]),n.collapsed?Object(i["f"])("",!0):(Object(i["r"])(),Object(i["e"])("div",D,[Object(i["h"])(s,{light:n.light,loading:n.loading,"color-converter":n.colorConverter,onSetLight:t[3]||(t[3]=function(t){return e.$emit("set-light",t)})},null,8,["light","loading","color-converter"])]))],2)})),W=Object(i["K"])("data-v-e2726892");Object(i["u"])("data-v-e2726892");var Z={key:1,class:"row"},ee=Object(i["h"])("div",{class:"col-1 icon"},[Object(i["h"])("i",{class:"fas fa-sun"})],-1),te={class:"col-11 control"},ne={key:2,class:"row"},ie=Object(i["h"])("div",{class:"col-1 icon"},[Object(i["h"])("i",{class:"fas fa-thermometer-half"})],-1),oe={class:"col-11 control"},re={key:3,class:"row"},ce=Object(i["h"])("span",{class:"col-1 icon"},[Object(i["h"])("i",{class:"fas fa-palette"})],-1),ae={class:"col-11 control"};Object(i["s"])();var se=W((function(e,t,n,o,r,c){var a=Object(i["z"])("Loading"),s=Object(i["z"])("Slider");return Object(i["r"])(),Object(i["e"])("div",{class:"controls light-controls",onClick:t[4]||(t[4]=function(e){return e.stopPropagation()})},[n.loading?(Object(i["r"])(),Object(i["e"])(a,{key:0})):Object(i["f"])("",!0),null!=c.state.bri?(Object(i["r"])(),Object(i["e"])("div",Z,[ee,Object(i["h"])("div",te,[Object(i["h"])(s,{range:n.colorConverter.ranges.bri,disabled:n.loading,value:c.state.bri,onMouseup:t[1]||(t[1]=Object(i["J"])((function(t){return e.$emit(n.light?"set-light":"set-group",{brightness:parseInt(t.target.value)})}),["stop"]))},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),null!=c.state.ct?(Object(i["r"])(),Object(i["e"])("div",ne,[ie,Object(i["h"])("div",oe,[Object(i["h"])(s,{range:n.colorConverter.ranges.ct,disabled:n.loading,value:c.state.ct,onMouseup:t[2]||(t[2]=Object(i["J"])((function(t){return e.$emit(n.light?"set-light":"set-group",{temperature:parseInt(t.target.value)})}),["stop"]))},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),c.rgbColor?(Object(i["r"])(),Object(i["e"])("label",re,[ce,Object(i["h"])("span",ae,[Object(i["h"])("input",{type:"color",value:c.rgbColor,onChange:t[3]||(t[3]=Object(i["J"])((function(){return c.onColorSelect.apply(c,arguments)}),["stop"]))},null,40,["value"])])])):Object(i["f"])("",!0)])})),le=(n("99af"),n("a15b"),n("fb6a"),n("d3b7"),n("ac1f"),n("25f0"),n("1276"),n("ddb0"),n("2909")),ue=n("8285"),be=n("3a5e"),ge={name:"Controls",components:{Loading:be["a"],Slider:ue["a"]},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 G["a"]}}},computed:{state:function(){var e,t;if(null===(e=this.light)||void 0===e?void 0: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 i=function e(t){return t&&t.length?t[0]instanceof Array?Object(le["a"])(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 Object(l["a"])(Object(l["a"])({},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 i;null!=(null===(i=t.state)||void 0===i?void 0:i[n])&&(e[n]=[].concat(Object(le["a"])(e[n]||[]),[t.state[n]]))})),e}),{})).reduce((function(e,t){var n=Object(u["a"])(t,2),o=n[0],r=n[1];return e[o]=i(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,i,o=e.target.value.slice(1).split(/(?=(?:..)*$)/).map((function(e){return parseInt("0x".concat(e))}));this.$emit(this.light?"set-light":"set-group",{rgb:o,xy:(t=this.colorConverter).rgbToXY.apply(t,Object(le["a"])(o)),hsl:(n=this.colorConverter).rgbToHsl.apply(n,Object(le["a"])(o)),brightness:(i=this.colorConverter).rgbToBri.apply(i,Object(le["a"])(o))})},getColor:function(e){return{rgb:this.colorConverter.toRGB(e),xy:this.colorConverter.toXY(e),hsl:this.colorConverter.toHSL(e)}}}};n("bf6b"),n("406a");ge.render=se,ge.__scopeId="data-v-e2726892";var de=ge,he={name:"Light",components:{Controls:de,ToggleSwitch:L["a"]},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 G["a"]}}},methods:{expandToggle:function(){this.$emit(this.collapsed?"expanded":"collapsed")}}};n("93d8");he.render=Q,he.__scopeId="data-v-52168252";var pe=he;function Oe(e,t,n,o,r,c){var a=Object(i["z"])("Loading");return Object(i["r"])(),Object(i["e"])(i["a"],null,[n.loading?(Object(i["r"])(),Object(i["e"])(a,{key:0})):Object(i["f"])("",!0),Object(i["h"])("div",{class:"scene row name",onClick:t[1]||(t[1]=function(){return c.onSelect.apply(c,arguments)})},Object(i["C"])(n.scene.name||"[Scene ".concat(n.scene.id,"]")),1)],64)}var je={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")}}};je.render=Oe;var ve=je,fe=(n("4de4"),Object(i["K"])("data-v-1739aaba"));Object(i["u"])("data-v-1739aaba");var me={class:"animation-container"},ye={class:"animation-header"},Ce={class:"row"},we=Object(i["h"])("div",{class:"col-3"}," Run Animation ",-1),ke={class:"col-9"},_e={class:"row"},Se=Object(i["h"])("div",{class:"col-3"},"Animation",-1),Le={class:"col-9"},Ge=Object(i["h"])("option",{value:"color_transition"},"Color transition",-1),$e=Object(i["h"])("option",{value:"blink"},"Blink",-1),xe={class:"animation"},Ae={key:0,class:"row"},Te=Object(i["h"])("div",{class:"col-3"}," Hue range ",-1),Ie={class:"col-9"},Me={key:1,class:"row"},ze=Object(i["h"])("div",{class:"col-3"}," Sat range ",-1),Be={class:"col-9"},Re={key:2,class:"row"},Ne=Object(i["h"])("div",{class:"col-3"}," Bri range ",-1),Ee={class:"col-9"},Ve={key:3,class:"row"},Fe=Object(i["h"])("div",{class:"col-3"}," Hue step ",-1),He={class:"col-9"},Pe={key:4,class:"row"},Xe=Object(i["h"])("div",{class:"col-3"}," Sat step ",-1),Ye={class:"col-9"},Ke={key:5,class:"row"},Je=Object(i["h"])("div",{class:"col-3"}," Bri step ",-1),Ue={class:"col-9"},qe={class:"row"},De=Object(i["h"])("div",{class:"col-3"}," Refresh seconds ",-1),Qe={class:"col-9"},We={class:"row"},Ze=Object(i["h"])("div",{class:"col-3"}," Duration (seconds) ",-1),et={class:"col-9"},tt={class:"lights"},nt={class:"row"},it=Object(i["g"])(" Select all lights ");Object(i["s"])();var ot=fe((function(e,t,n,o,r,c){var a=Object(i["z"])("Loading"),s=Object(i["z"])("ToggleSwitch"),l=Object(i["z"])("RangeSlider"),u=Object(i["z"])("Slider");return Object(i["r"])(),Object(i["e"])("div",{class:"controls animation-controls",onClick:t[11]||(t[11]=function(e){return e.stopPropagation()})},[n.loading?(Object(i["r"])(),Object(i["e"])(a,{key:0})):Object(i["f"])("",!0),Object(i["h"])("div",me,[Object(i["h"])("div",ye,[Object(i["h"])("div",Ce,[we,Object(i["h"])("div",ke,[Object(i["h"])(s,{value:c.animationRunning,onInput:c.toggleAnimation},null,8,["value","onInput"])])]),Object(i["h"])("div",_e,[Se,Object(i["h"])("div",Le,[Object(i["h"])("label",null,[Object(i["h"])("select",{class:"selector",onClick:t[1]||(t[1]=function(e){return r.selectedAnimation=e.target.value})},[Ge,$e])])])])]),Object(i["h"])("div",xe,["color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Ae,[Te,Object(i["h"])("div",Ie,[Object(i["h"])(l,{range:n.colorConverter.ranges.hue,disabled:n.loading,value:r.animations.color_transition.hue_range,onMouseup:t[2]||(t[2]=function(e){return r.animations.color_transition.hue_range=e.target.value})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Me,[ze,Object(i["h"])("div",Be,[Object(i["h"])(l,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.sat_range,onMouseup:t[3]||(t[3]=function(e){return r.animations.color_transition.sat_range=e.target.value})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Re,[Ne,Object(i["h"])("div",Ee,[Object(i["h"])(l,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.bri_range,onMouseup:t[4]||(t[4]=function(e){return r.animations.color_transition.bri_range=e.target.value})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Ve,[Fe,Object(i["h"])("div",He,[Object(i["h"])(u,{range:n.colorConverter.ranges.hue,disabled:n.loading,value:r.animations.color_transition.hue_step,onMouseup:t[5]||(t[5]=function(e){return r.animations.color_transition.hue_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Pe,[Xe,Object(i["h"])("div",Ye,[Object(i["h"])(u,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.sat_step,onMouseup:t[6]||(t[6]=function(e){return r.animations.color_transition.sat_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Ke,[Je,Object(i["h"])("div",Ue,[Object(i["h"])(u,{range:n.colorConverter.ranges.bri,disabled:n.loading,value:r.animations.color_transition.bri_step,onMouseup:t[7]||(t[7]=function(e){return r.animations.color_transition.bri_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),Object(i["h"])("div",qe,[De,Object(i["h"])("div",Qe,[Object(i["h"])("label",null,[Object(i["h"])("input",{type:"number",value:r.animations[r.selectedAnimation].transition_seconds,step:"0.1",onInput:t[8]||(t[8]=function(e){return r.animations[r.selectedAnimation].transition_seconds=parseFloat(e.target.value)})},null,40,["value"])])])]),Object(i["h"])("div",We,[Ze,Object(i["h"])("div",et,[Object(i["h"])("label",null,[Object(i["h"])("input",{type:"number",value:r.animations[r.selectedAnimation].duration,step:"5",onInput:t[9]||(t[9]=function(e){var t;return r.animations[r.selectedAnimation].duration=(null===(t=e.target.value)||void 0===t?void 0:t.length)?parseFloat(e.target.value):null})},null,40,["value"])])])])])]),Object(i["h"])("div",tt,[Object(i["h"])("div",nt,[Object(i["h"])("label",null,[Object(i["h"])("input",{type:"checkbox",checked:Object.keys(n.lights).length===Object.values(r.selectedLights).filter((function(e){return e})).length,onClick:t[10]||(t[10]=function(){return c.toggleSelectAll.apply(c,arguments)})},null,8,["checked"]),it])]),(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(n.lights,(function(e,t){return Object(i["r"])(),Object(i["e"])("div",{class:"row",key:t},[Object(i["h"])("label",null,[Object(i["I"])(Object(i["h"])("input",{type:"checkbox","onUpdate:modelValue":function(e){return r.selectedLights[t]=e},onInput:function(e){return r.selectedLights[t]=!r.selectedLights[t]}},null,40,["onUpdate:modelValue","onInput"]),[[i["E"],r.selectedLights[t]]]),Object(i["g"])(" "+Object(i["C"])(e.name),1)])])})),128))])])})),rt=Object(i["K"])("data-v-0e677180");Object(i["u"])("data-v-0e677180");var ct={class:"range-slider"};Object(i["s"])();var at=rt((function(e,t,n,o,r,c){return Object(i["r"])(),Object(i["e"])("div",ct,[Object(i["h"])("label",null,[(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(n.value,(function(e,o){return Object(i["r"])(),Object(i["e"])("input",{class:"slider",type:"range",value:e,min:n.range[0],max:n.range[1],disabled:n.disabled,onInput:t[1]||(t[1]=function(){return c.input.apply(c,arguments)}),onChange:t[2]||(t[2]=function(){return c.changed.apply(c,arguments)}),onMouseup:t[3]||(t[3]=function(){return c.mouseup.apply(c,arguments)}),onMousedown:t[4]||(t[4]=function(){return c.mousedown.apply(c,arguments)}),onTouchstart:t[5]||(t[5]=function(){return c.mouseup.apply(c,arguments)}),onTouchend:t[6]||(t[6]=function(){return c.mousedown.apply(c,arguments)}),ref:"input_".concat(o),key:o},null,40,["value","min","max","disabled"])})),128))])])})),st={name:"RangeSlider",emits:["input","change","mouseup","mousedown"],props:{disabled:{type:Boolean,default:!1},range:{type:Array,default:function(){return[0,100]}},value:{type:Array,default:function(){return[0,100]}}},methods:{getEvent:function(e){return Object(l["a"])(Object(l["a"])({},e),{},{target:Object(l["a"])(Object(l["a"])({},e.target),{},{value:Object.values(this.$refs).map((function(e){return parseFloat(e.value)})).sort()})})},input:function(e){this.$emit("input",this.getEvent(e))},changed:function(e){this.$emit("change",this.getEvent(e))},mouseup:function(e){this.$emit("mouseup",this.getEvent(e))},mousedown:function(e){this.$emit("mousedown",this.getEvent(e))}},mounted:function(){if(this.value){var e=this;this.value.forEach((function(t,n){e.$refs["input_".concat(n)].value=t}))}}};n("084e");st.render=at,st.__scopeId="data-v-0e677180";var lt=st,ut={name:"Animate",mixins:[b["a"]],components:{ToggleSwitch:L["a"],Slider:ue["a"],RangeSlider:lt,Loading:be["a"]},emits:["start","stop"],props:{lights:{type:Object},group:{type:Object},loading:{type:Boolean,default:!1},colorConverter:{type:Object,default:function(){return new G["a"]}},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:Object(l["a"])(Object(l["a"])({},this.animations[this.selectedAnimation]),{},{animation:this.selectedAnimation})}):this.warn("No lights have been selected")}}};n("7e57");ut.render=ot,ut.__scopeId="data-v-1739aaba";var bt=ut,gt={name:"Group",emits:["close","group-toggle","light-toggle","set-light","select-scene","start-animation","stop-animation"],components:{Animate:bt,ToggleSwitch:L["a"],MenuPanel:S,Light:pe,Scene:ve,Controls:de},props:{lights:{type:Object},group:{type:Object},scenes:{type:Object},animations:{type:Object,default:function(){}},colorConverter:{type:Object,default:function(){return new G["a"]}}},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=Object(u["a"])(e,2),n=t[0],i=t[1];return Object(l["a"])(Object(l["a"])({},i),{},{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=Object(u["a"])(e,2),n=t[0],i=t[1];return Object(l["a"])(Object(l["a"])({},i),{},{id:n})})):[]},groupName:function(){var e,t;return(null===(e=this.group)||void 0===e?void 0: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)}}};n("73e5"),n("1e15");gt.render=K;var dt=gt,ht={name:"Light",components:{Group:dt,Groups:x},mixins:[b["a"],d],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 G["a"]}},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=Object(u["a"])(t,2),i=n[0],o=n[1];return o.lights.forEach((function(t){e[t]||(e[t]={}),e[t][i]=o})),e}),{}):{}},scenesByGroup:function(){if(!this.scenes)return{};var e=this;return Object.entries(this.scenes).reduce((function(t,n){var i=Object(u["a"])(n,2),o=i[0],r=i[1];return r.lights.forEach((function(n){Object.keys(e.groupsByLight[n]).forEach((function(e){t[e]||(t[e]={}),t[e][o]=r}))})),t}),{})},animationsByGroup:function(){var e,t,n=this,i=Object.entries((null===(e=this.animations)||void 0===e?void 0:e.groups)||{}).reduce((function(e,t){var n=Object(u["a"])(t,2),i=n[0],o=n[1];return e[i]={},o&&(e[i][null]=o),e}),{});return Object(l["a"])(Object(l["a"])({},i),Object.entries((null===(t=this.animations)||void 0===t?void 0:t.lights)||{}).reduce((function(e,t){var i,o=Object(u["a"])(t,2),r=o[0],c=o[1],a=null===(i=Object.values(n.groupsByLight[r]))||void 0===i?void 0:i[0];return a&&c&&null!=a.id&&(e[a.id]||(e[a.id]={}),e[a.id][r]=c),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=Object(l["a"])({},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")}};n("876b"),n("b322");ht.render=s,ht.__scopeId="data-v-781dd72c";t["default"]=ht},d28c:function(e,t,n){},e3f0:function(e,t,n){},fda1:function(e,t,n){}}]);
//# sourceMappingURL=chunk-cc8a6536.a5da26b6.js.map