{console.log(e)})}render(){return d`| Name | State | ${this.has_controls?d`Actions | `:d``}
${this.entities.map(r=>d`| ${r.name} | ${r.state} | ${this.has_controls?d`${r.has_action?this.control(r):d``} | `:d``}
`)}
`}static get styles(){return[X,wt,w`table{border-spacing:0;border-collapse:collapse;width:100%;border:1px solid currentColor;background-color:var(--c-bg)}th{font-weight:600;text-align:left}td,th{padding:.25rem .5rem;border:1px solid currentColor}td:nth-child(2),th:nth-child(2){text-align:center}tr th,tr:nth-child(2n){background-color:rgba(127,127,127,.3)}select{background-color:inherit;color:inherit;width:100%;border-radius:4px}option{color:currentColor;background-color:var(--primary-color,currentColor)}input[type=range]{width:calc(100% - 8rem);height:.75rem}.range{text-align:center}`]}};tt([M()],I.prototype,"entities",2);tt([M()],I.prototype,"has_controls",2);I=tt([N("esp-entity-table")],I);class Kt{exec(t){if(!this[t]||typeof this[t]!="function"){console.log(`ActionRenderer.${t} is not callable`);return}return this[t]()}_actionButton(t,e,i){if(!t)return;let s=i||e.toLowerCase();return d``}_switch(t){return d`{var s;let i="turn_"+e.detail.state;(s=this.actioner)==null||s.restAction(t,i.toLowerCase())}}">`}_select(t,e,i,s,n){return d``}_range(t,e,i,s,n,o,h){return d` {var g,c;let a=(g=l.target)==null?void 0:g.value;(c=this.actioner)==null||c.restAction(t,`${e}?${i}=${a}`)}}">
`}render_switch(){if(!!this.entity)return this.entity.assumed_state?d`${this._actionButton(this.entity,"\u274C","turn_off")} ${this._actionButton(this.entity,"\u2714\uFE0F","turn_on")}`:this._switch(this.entity)}render_fan(){if(!!this.entity)return[this.entity.speed," ",this.entity.speed_level,this._switch(this.entity),this.entity.speed_count?this._range(this.entity,`turn_${this.entity.state.toLowerCase()}`,"speed_level",this.entity.speed_level?this.entity.speed_level:0,0,this.entity.speed_count,1):""]}render_light(){var t;if(!!this.entity)return[this._switch(this.entity),this.entity.brightness?this._range(this.entity,"turn_on","brightness",this.entity.brightness,0,255,1):"",((t=this.entity.effects)==null?void 0:t.filter(e=>e!="None").length)?this._select(this.entity,"turn_on","effect",this.entity.effects||[],this.entity.effect):""]}render_lock(){if(!!this.entity)return d`${this._actionButton(this.entity,"\u{1F510}","lock")} ${this._actionButton(this.entity,"\u{1F513}","unlock")} ${this._actionButton(this.entity,"\u2191","open")}`}render_cover(){if(!!this.entity)return d`${this._actionButton(this.entity,"\u2191","open")} ${this._actionButton(this.entity,"\u2610","stop")} ${this._actionButton(this.entity,"\u2193","close")}`}render_button(){if(!!this.entity)return d`${this._actionButton(this.entity,"\u2610","press ")}`}render_select(){if(!!this.entity)return this._select(this.entity,"set","option",this.entity.option||[],this.entity.value)}render_number(){if(!!this.entity)return this._range(this.entity,"set","value",this.entity.value,this.entity.min_value,this.entity.max_value,this.entity.step)}render_climate(){if(!this.entity)return;let t,e;this.entity.target_temperature_low!==void 0&&this.entity.target_temperature_high!==void 0?(e=d`${this.entity.target_temperature_low} .. ${this.entity.target_temperature_high}`,t=d`${this._range(this.entity,"set","target_temperature_low",this.entity.target_temperature_low,this.entity.min_temp,this.entity.max_temp,this.entity.step)} ${this._range(this.entity,"set","target_temperature_high",this.entity.target_temperature_high,this.entity.min_temp,this.entity.max_temp,this.entity.step)}`):(e=d`${this.entity.target_temperature}`,t=d`${this._range(this.entity,"set","target_temperature",this.entity.target_temperature,this.entity.min_temp,this.entity.max_temp,this.entity.step)}`);let i=d``;return(this.entity.modes?this.entity.modes.length:0)>0&&(i=d`Mode:
${this._select(this.entity,"set","mode",this.entity.modes||[],this.entity.mode||"")}`),d` ${t} ${i}`}}var Qt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,it=(r,t,e,i)=>{for(var s=i>1?void 0:i?Zt(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Qt(t,e,s),s};let q=class extends f{constructor(){super();this.rows=10,this.logs=[]}connectedCallback(){var r;super.connectedCallback(),(r=window.source)==null||r.addEventListener("log",t=>{const i=t.data;let n=i.slice(10,i.length-4).split(":").slice(0,2).join(":"),o=i.slice(12+n.length,i.length-4);const l={type:{"[1;31m":"e","[0;33m":"w","[0;32m":"i","[0;35m":"c","[0;36m":"d","[0;37m":"v"}[i.slice(0,7)],level:i.slice(7,10),tag:n,detail:o,when:new Date().toTimeString().split(" ")[0]};this.logs.push(l),this.logs=this.logs.slice(-this.rows)})}render(){return d`| Time | level | Tag | Message |
${this.logs.map(r=>d`| ${r.when} | ${r.level} | ${r.tag} | ${r.detail} |
`)}
`}static get styles(){return w`table{font-family:monospace;background-color:#1c1c1c;color:#fff;width:100%;border:1px solid #dfe2e5;line-height:1}thead{border:1px solid #dfe2e5;line-height:1rem}th{text-align:left}td,th{padding:.25rem .5rem}pre{margin:0}.v{color:#888}.d{color:#0dd}.c{color:#ff00ff}.i{color:#32cd32}.w{color:#ff0}.e{color:red;font-weight:700}.flow-x{overflow-x:auto}`}};it([$({type:Number})],q.prototype,"rows",2);it([M()],q.prototype,"logs",2);q=it([N("esp-log")],q);var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,y=(r,t,e,i)=>{for(var s=i>1?void 0:i?Gt(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Yt(t,e,s),s};const At="checkbox-lever";let m=class extends f{constructor(){super(...arguments);this.checkbox=null,this.labelOn="On",this.labelOff="Off",this.stateOn="ON",this.stateOff="OFF",this.state="OFF",this.color="currentColor",this.disabled=!1}firstUpdated(r){var t;this.checkbox=(t=this.shadowRoot)==null?void 0:t.getElementById(At)}isOn(){return this.state===this.stateOn}toggle(r){const t=this.isOn()?this.stateOff:this.stateOn;let e=new CustomEvent("state",{detail:{state:t,id:this.id}});this.dispatchEvent(e)}render(){return d``}static get styles(){return[X,w`.sw,.sw *{-webkit-tap-highlight-color:transparent;user-select:none;cursor:pointer}input[type=checkbox]{opacity:0;width:0;height:0}input[type=checkbox]:checked+.lever{background-color:currentColor;background-image:linear-gradient(0deg,rgba(255,255,255,.5) 0,rgba(255,255,255,.5) 100%)}input[type=checkbox]:checked+.lever:after,input[type=checkbox]:checked+.lever:before{left:18px}input[type=checkbox]:checked+.lever:after{background-color:currentColor}.lever{content:"";display:inline-block;position:relative;width:36px;height:14px;background-image:linear-gradient(0deg,rgba(127,127,127,.5) 0,rgba(127,127,127,.5) 100%);background-color:inherit;border-radius:15px;margin-right:10px;transition:background .3s ease;vertical-align:middle;margin:0 16px}.lever:after,.lever:before{content:"";position:absolute;display:inline-block;width:20px;height:20px;border-radius:50%;left:0;top:-3px;transition:left .3s ease,background .3s ease,box-shadow .1s ease,transform .1s ease}.lever:before{background-color:currentColor;background-image:linear-gradient(0deg,rgba(255,255,255,.9) 0,rgba(255,255,255,.9) 100%)}.lever:after{background-color:#f1f1f1;box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12)}input[type=checkbox]:checked:not(:disabled).tabbed:focus~.lever::before,input[type=checkbox]:checked:not(:disabled)~.lever:active::before{transform:scale(2.4);background-color:currentColor;background-image:linear-gradient(0deg,rgba(255,255,255,.9) 0,rgba(255,255,255,.9) 100%)}input[type=checkbox]:not(:disabled).tabbed:focus~.lever::before,input[type=checkbox]:not(:disabled)~.lever:active:before{transform:scale(2.4);background-color:rgba(0,0,0,.08)}input[type=checkbox][disabled]+.lever{cursor:default;background-color:rgba(0,0,0,.12)}input[type=checkbox][disabled]+.lever:after,input[type=checkbox][disabled]:checked+.lever:after{background-color:#949494}`]}};y([$({type:String})],m.prototype,"labelOn",2);y([$({type:String})],m.prototype,"labelOff",2);y([$({type:String})],m.prototype,"stateOn",2);y([$({type:String})],m.prototype,"stateOff",2);y([$({type:String})],m.prototype,"state",2);y([$({type:String})],m.prototype,"color",2);y([$({type:Boolean})],m.prototype,"disabled",2);m=y([N("esp-switch")],m);var Xt='',te=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,ie=(r,t,e,i)=>{for(var s=i>1?void 0:i?ee(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&te(t,e,s),s};let xt=class extends f{render(){return Rt([Xt])}};xt=ie([N("esp-logo")],xt);var se=Object.defineProperty,re=Object.getOwnPropertyDescriptor,V=(r,t,e,i)=>{for(var s=i>1?void 0:i?re(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&se(t,e,s),s};window.source=new EventSource(et()+"/events");let B=class extends f{constructor(){super();this.scheme="",this.ping="",this.version="2.0.5",this.config={ota:!1,log:!0,title:"",comment:""},this.darkQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.frames=[{color:"inherit"},{color:"red",transform:"scale(1.25) translateY(-30%)"},{color:"inherit"}];const r=document.querySelector("script#config");r&&this.setConfig(JSON.parse(r.innerText))}setConfig(r){"log"in r||(r.log=this.config.log),this.config=r,document.title=r.title,document.documentElement.lang=r.lang}firstUpdated(r){super.firstUpdated(r),document.getElementsByTagName("head")[0].innerHTML+='';const t=document.querySelector("link[rel~='icon']");t.href='data:image/svg+xml,',this.darkQuery.addEventListener("change",()=>{this.scheme=this.isDark()}),this.scheme=this.isDark(),window.source.addEventListener("ping",e=>{const i=e;i.data.length&&this.setConfig(JSON.parse(i.data)),this.ping=i.lastEventId}),window.source.onerror=function(e){console.dir(e)}}isDark(){return this.darkQuery.matches?"dark":"light"}updated(r){super.updated(r),r.has("scheme")&&document.documentElement.style.setProperty("color-scheme",this.scheme),r.has("ping")&&this.beat.animate(this.frames,1e3)}ota(){if(this.config.ota){let r=et();return d`OTA Update
`}}renderComment(){return this.config.comment?d`${this.config.comment}
`:p}renderLog(){return this.config.log?d``:p}render(){return d`${this.config.title} ❤
${this.renderComment()}this.scheme=r.detail.state}" labelOn="🌒" labelOff="☀️" stateOn="dark" stateOff="light" optimistic>Scheme
${this.ota()}${this.renderLog()}`}static get styles(){return[X,wt,w`.flex-grid{display:flex}.flex-grid .col{flex:2}.flex-grid-half{display:flex;justify-content:space-evenly}.col{width:48%}@media (max-width:600px){.flex-grid,.flex-grid-half{display:block}.col{width:100%;margin:0 0 10px 0}}*{box-sizing:border-box}.flex-grid{margin:0 0 20px 0}h1{text-align:center;width:100%;line-height:4rem}h1,h2{border-bottom:1px solid #eaecef;margin-bottom:.25rem}h3{text-align:center;margin:.5rem 0}#beat{float:right;height:1rem}a.logo{height:4rem;float:left;color:inherit}.right{float:right}`]}};V([M()],B.prototype,"scheme",2);V([M()],B.prototype,"ping",2);V([Vt("#beat")],B.prototype,"beat",2);B=V([N("esp-app")],B);