{console.log(e)})}renderShowAll(){if(!this.show_all&&this.entities.find(i=>i.is_disabled_by_default))return S`this.show_all=!0}">Show All
`}render(){const i=(s,o)=>{const r=s.reduce(function(c,l){return(c.get(l[o])||(()=>{let h=[];return c.set(l[o],h),h})()).push(l),c},new Map),a=new Map;for(const c of this.groups){const l=c.name;r.has(l)&&a.set(l,r.get(l)||[])}return a},t=this.show_all?this.entities:this.entities.filter(s=>!s.is_disabled_by_default),e=i(t,"sorting_group"),n=Array.from(e,([s,o])=>({name:s,value:o}));return S`${n.map(s=>S`
${s.value.map((o,r)=>S`
${o.icon?S` `:E}
${o.device?`[${o.device}] `:""}${o.name}
${this.has_controls&&o.has_action?this.control(o):S`
${o.state}
`}
${o.domain==="sensor"?S`
`:E}
`)}
`)} ${this.renderShowAll()}
`}static get styles(){return[$i,Wo,ba,_a,Mn]}_handleEntityRowClick(i){var t,e;((t=i==null?void 0:i.currentTarget)==null?void 0:t.domain)==="sensor"&&(i!=null&&i.ctrlKey||i.stopPropagation(),(e=i==null?void 0:i.currentTarget)==null||e.classList.toggle("expanded",i.ctrlKey?!0:void 0))}_handleTabHeaderDblClick(i){var e;const t=new CustomEvent("entity-tab-header-double-clicked",{bubbles:!0,composed:!0});(e=i.target)==null||e.dispatchEvent(t)}};G.ENTITY_UNDEFINED="States";G.ENTITY_CATEGORIES=["Sensor and Control","Configuration","Diagnostic"];Di([mt()],G.prototype,"entities",2);Di([mt()],G.prototype,"has_controls",2);Di([mt()],G.prototype,"show_all",2);G=Di([Rt("esp-entity-table")],G);class Au{exec(t){if(!this[t]||typeof this[t]!="function"){console.log(`ActionRenderer.${t} is not callable`);return}return this[t]()}_actionButton(t,e,n,s=!1){if(!t)return;let o=n||e.toLowerCase();return S`{var r;return(r=this.actioner)==null?void 0:r.restAction(t,o)}}">${e} `}_datetime(t,e,n,s,o){return S` {var c,l;const a=(c=r.target)==null?void 0:c.value;(l=this.actioner)==null||l.restAction(t,`${n}?${s}=${a.replace("T"," ")}`)}}">`}_switch(t){return S`{var s;let n="turn_"+e.detail.state;(s=this.actioner)==null||s.restAction(t,n.toLowerCase())}}"> `}_select(t,e,n,s,o){return S`{var c,l;const a=(c=r.target)==null?void 0:c.value;(l=this.actioner)==null||l.restAction(t,`${e}?${n}=${encodeURIComponent(a)}`)}}">${s.map(r=>S`${r} `)} `}_range(t,e,n,s,o,r,a=1){return t.mode==1?S`${o||0} {var h,d;const l=(h=c.target)==null?void 0:h.value;(d=this.actioner)==null||d.restAction(t,`${e}?${n}=${l}`)}}"> ${r||100}
`:S`{var l,h;(l=c.target)==null||l.value,(h=this.actioner)==null||h.restAction(t,`${e}?${n}=${c.detail.state}`)}}"> `}_textinput(t,e,n,s,o,r,a){return S` {var h,d;const l=(h=c.target)==null?void 0:h.value;(d=this.actioner)==null||d.restAction(t,`${e}?${n}=${encodeURIComponent(l)}`)}}">`}_colorpicker(t,e,n){function s(r){return Number(r).toString(16).padStart(2,"0")}function o(r){var c;const a=((c=r.match(/[0-9a-f]{2}/gi))==null?void 0:c.map(l=>parseInt(l,16)))||[0,0,0];return`r=${a[0]}&g=${a[1]}&b=${a[2]}`}return S` {var c,l;const a=(c=r.target)==null?void 0:c.value;(l=this.actioner)==null||l.restAction(t,`${e}?${o(a)}`)}}">
`}render_binary_sensor(){var e;if(!this.entity)return;const t=this.entity.state==Kr;return S` `}render_date(){if(!!this.entity)return S`${this._datetime(this.entity,"date","set","value",this.entity.value)}`}render_time(){if(!!this.entity)return S`${this._datetime(this.entity,"time","set","value",this.entity.value)}`}render_datetime(){if(!!this.entity)return S`${this._datetime(this.entity,"datetime-local","set","value",this.entity.value)}`}render_switch(){if(!!this.entity)return this.entity.assumed_state?S`${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,e;if(!!this.entity)return[S`${this._switch(this.entity)} ${this.entity.brightness?this._range(this.entity,"turn_on","brightness",this.entity.brightness,0,255,1):""} ${this.entity.color_mode==="rgb"||this.entity.color_mode==="rgbw"?this._colorpicker(this.entity,"turn_on",(t=this.entity)==null?void 0:t.color):""} ${(e=this.entity.effects)!=null&&e.filter(n=>n!="None").length?this._select(this.entity,"turn_on","effect",this.entity.effects||[],this.entity.effect):""}
`]}render_lock(){if(!!this.entity)return S`${this._actionButton(this.entity,"\u{1F510}","lock",this.entity.state==="LOCKED")} ${this._actionButton(this.entity,"\u{1F513}","unlock",this.entity.state==="UNLOCKED")} ${this._actionButton(this.entity,"\u2191","open")}`}render_cover(){if(!!this.entity)return S`${this._actionButton(this.entity,"\u2191","open",this.entity.state==="OPEN")} ${this._actionButton(this.entity,"\u2610","stop")} ${this._actionButton(this.entity,"\u2193","close",this.entity.state==="CLOSED")}`}render_button(){if(!!this.entity)return S`${this._actionButton(this.entity,"PRESS","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 S`${this._range(this.entity,"set","value",this.entity.value,this.entity.min_value,this.entity.max_value,this.entity.step)} ${this.entity.uom}`}render_text(){if(!!this.entity)return this._textinput(this.entity,"set","value",this.entity.value,this.entity.min_length,this.entity.max_length,this.entity.pattern)}render_climate(){if(!this.entity)return;let t,e=S`Current: ${this.entity.current_temperature} °C
`;this.entity.target_temperature_low!==void 0&&this.entity.target_temperature_high!==void 0?t=S`Target Low: ${this._range(this.entity,"set","target_temperature_low",this.entity.target_temperature_low,this.entity.min_temp,this.entity.max_temp,this.entity.step)}
Target High: ${this._range(this.entity,"set","target_temperature_high",this.entity.target_temperature_high,this.entity.min_temp,this.entity.max_temp,this.entity.step)}
`:t=S`Target: ${this._range(this.entity,"set","target_temperature",this.entity.target_temperature,this.entity.min_temp,this.entity.max_temp,this.entity.step)}
`;let n=S``;return(this.entity.modes?this.entity.modes.length:0)>0&&(n=S`Mode: ${this._select(this.entity,"set","mode",this.entity.modes||[],this.entity.mode||"")}
`),S`${e} ${t} ${n}
`}render_valve(){if(!!this.entity)return S`${this._actionButton(this.entity,"OPEN","open",this.entity.state==="OPEN")} ${this._actionButton(this.entity,"\u2610","stop")} ${this._actionButton(this.entity,"CLOSE","close",this.entity.state==="CLOSED")}`}render_water_heater(){var r,a;if(!this.entity)return;let t=this.entity.current_temperature!==void 0?S`Current: ${this.entity.current_temperature} °C
`:E,e;this.entity.target_temperature_low!==void 0&&this.entity.target_temperature_high!==void 0?e=S`Target Low: ${this._range(this.entity,"set","target_temperature_low",this.entity.target_temperature_low,this.entity.min_temp,this.entity.max_temp,this.entity.step)}
Target High: ${this._range(this.entity,"set","target_temperature_high",this.entity.target_temperature_high,this.entity.min_temp,this.entity.max_temp,this.entity.step)}
`:this.entity.target_temperature!==void 0?e=S`Target: ${this._range(this.entity,"set","target_temperature",this.entity.target_temperature,this.entity.min_temp,this.entity.max_temp,this.entity.step)}
`:e=E;let n=((a=(r=this.entity.modes)==null?void 0:r.length)!=null?a:0)>0?S`Mode: ${this._select(this.entity,"set","mode",this.entity.modes||[],this.entity.state||"")}
`:E,s=this.entity.away!==void 0?S`Away: ${this._actionButton(this.entity,this.entity.away?"ON":"OFF",`set?away=${!this.entity.away}`,!1)}
`:E,o=this.entity.is_on!==void 0?S`Power: ${this._actionButton(this.entity,this.entity.is_on?"ON":"OFF",`set?is_on=${!this.entity.is_on}`,!1)}
`:E;return S`${t} ${e} ${n} ${s} ${o}
`}render_infrared(){if(!this.entity)return;if(this.entity.supports_transmitter!==!0)return E;const t=this.entity,e=s=>{const o=s.split(",").map(h=>parseInt(h.trim(),10)).filter(h=>!isNaN(h)),r=new ArrayBuffer(o.length*4),a=new DataView(r);o.forEach((h,d)=>a.setInt32(d*4,h,!0));const c=new Uint8Array(r);let l="";return c.forEach(h=>l+=String.fromCharCode(h)),btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")};return S`Carrier (Hz):
Repeat:
Timings:
{var b;const r=(b=s.currentTarget.parentElement)==null?void 0:b.parentElement;if(!r){console.error("Infrared: Could not find container");return}const a=r.querySelector('input[data-field="carrier"]'),c=r.querySelector('input[data-field="repeat"]'),l=r.querySelector('input[data-field="timings"]');if(!a||!c||!l){console.error("Infrared: Could not find input elements",{carrierInput:a,repeatInput:c,timingsInput:l});return}const h=a.value||"38000",d=c.value||"1",u=l.value||"";if(!u.trim()){console.warn("Infrared: No timings provided");return}const f=e(u);console.log("Infrared: Transmitting",{carrier:h,repeat:d,timingsRaw:u,timingsEncoded:f});const p=Ti(),g=Gr(p,t,"transmit"),m=new URLSearchParams;m.append("carrier_frequency",h),m.append("repeat_count",d),m.append("data",f),fetch(g,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:m.toString()}).then(_=>{console.log("Infrared: Transmit response",_)}).catch(_=>{console.error("Infrared: Transmit error",_)})}}">TX
`}}var Eu=Object.defineProperty,Iu=Object.getOwnPropertyDescriptor,Li=(i,t,e,n)=>{for(var s=n>1?void 0:n?Iu(t,e):t,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=(n?r(t,e,s):r(s))||s);return n&&s&&Eu(t,e,s),s};let Ee=class extends J{constructor(){super(),this.rows=10,this.scheme="",this.logs=[]}connectedCallback(){var i;super.connectedCallback(),(i=window.source)==null||i.addEventListener("log",t=>{const n=t.data,o={"\x1B[1;31m":"e","\x1B[0;33m":"w","\x1B[0;32m":"i","\x1B[0;35m":"c","\x1B[0;36m":"d","\x1B[0;37m":"v"}[n.slice(0,7)];if(!o)return;const a=n.slice(7,n.length-4).split(`
`),c=a[0],h=c.slice(3).split(":").slice(0,2).join(":"),d=c.slice(5+h.length),u=c.slice(0,3),f=new Date().toTimeString().split(" ")[0];a.forEach((p,g)=>{const m={type:o,level:u,tag:h,detail:g===0?d:p,when:f};this.logs.push(m)}),this.logs=this.logs.slice(-this.rows)})}render(){return S`${this.logs.map(i=>S`
${i.when}
${i.level}
${i.tag}
${i.detail}
`)}
`}_handleTabHeaderDblClick(i){var e;const t=new CustomEvent("log-tab-header-double-clicked",{bubbles:!0,composed:!0});(e=i.target)==null||e.dispatchEvent(t)}static get styles(){return[Mn,nt`.tbody .trow:nth-child(2n),.thead{background-color:rgba(127,127,127,.05)}.trow div{font-family:monospace;width:100%;line-height:1.2rem}.trow{display:flex}.thead{line-height:1rem}.thead .trow{text-align:left;padding:.25rem .5rem}.trow{display:flex}.trow>div{align-self:flex-start;padding-right:.25em;flex:2 0;min-width:70px}.trow>div:nth-child(2){flex:1 0;overflow:hidden;text-overflow:ellipsis;max-width:40px}.trow>div:nth-child(3){flex:3 0;overflow:hidden;text-overflow:ellipsis}.trow>div:last-child{flex:15 0;padding-right:0;overflow:hidden;text-overflow:ellipsis}pre{margin:0}.v{color:#888}.d{color:#0dd}.c{color:#ff00ff}.i{color:#32cd32}.w{color:#ff0}.e{color:red;font-weight:700}.logs[color-scheme=light]{font-weight:700}.logs[color-scheme=light] .w{color:#cc0}.logs[color-scheme=dark] .d{color:#0aa}.logs{overflow-x:auto;border-radius:12px;border-width:1px;border-style:solid;border-color:rgba(127,127,127,.12);transition:all .3s ease-out 0s;font-size:14px;padding:16px}@media (max-width:1024px){.trow>div:nth-child(2){display:none!important}}`]}};Li([Y({type:Number})],Ee.prototype,"rows",2);Li([Y({type:String})],Ee.prototype,"scheme",2);Li([mt()],Ee.prototype,"logs",2);Ee=Li([Rt("esp-log")],Ee);var Du=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,Zt=(i,t,e,n)=>{for(var s=n>1?void 0:n?Tu(t,e):t,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=(n?r(t,e,s):r(s))||s);return n&&s&&Du(t,e,s),s};const To="checkbox-lever";let Dt=class extends J{constructor(){super(...arguments),this.checkbox=null,this.stateOn=Kr,this.stateOff=Do,this.state=Do,this.color="currentColor",this.disabled=!1}firstUpdated(i){var t;this.checkbox=(t=this.shadowRoot)==null?void 0:t.getElementById(To)}isOn(){return this.state===this.stateOn}toggle(i){const t=this.isOn()?this.stateOff:this.stateOn;let e=new CustomEvent("state",{detail:{state:t,id:this.id}});this.dispatchEvent(e)}render(){return S`
`}static get styles(){return[$i,nt`.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}input[type=checkbox]:not(:checked)+.lever:after{background-color:rgba(127,127,127,.5)}.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;transition:background .3s ease;vertical-align:middle}.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:rgba(255,255,255,.9) 0;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}`]}};Zt([Y({type:String})],Dt.prototype,"stateOn",2);Zt([Y({type:String})],Dt.prototype,"stateOff",2);Zt([Y({type:String})],Dt.prototype,"state",2);Zt([Y({type:String})],Dt.prototype,"color",2);Zt([Y({type:Boolean})],Dt.prototype,"disabled",2);Dt=Zt([Rt("esp-switch")],Dt);var Lu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Jt=(i,t,e,n)=>{for(var s=n>1?void 0:n?Ru(t,e):t,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=(n?r(t,e,s):r(s))||s);return n&&s&&Lu(t,e,s),s};const Lo="range",Fu="rangeValue",Ro=500;let Tt=class extends J{constructor(){super(...arguments),this.inputRange=null,this.currentValue=null,this.longPressTimer=null,this.isPopupInputVisible=!1,this.value=0,this.min=0,this.max=0,this.step=0,this.name=""}firstUpdated(i){var t,e;this.inputRange=(t=this.shadowRoot)==null?void 0:t.getElementById(Lo),this.currentValue=(e=this.shadowRoot)==null?void 0:e.getElementById(Fu),document.addEventListener("mousedown",n=>{var o;if(!document.querySelector(".popup-number-input"))return;!((o=document.querySelector(".popup-number-input"))!=null&&o.contains(n.target))&&this.isPopupInputVisible&&this.deletePopupInput()})}updated(){this.updateCurrentValueOverlay()}onMouseDownCurrentValue(i){this.longPressTimer=setTimeout(()=>{this.showPopupInput(i.pageX,i.pageY)},Ro)}onMouseUpCurrentValue(i){this.longPressTimer&&!this.isPopupInputVisible&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}onTouchStartCurrentValue(i){this.longPressTimer=setTimeout(()=>{this.showPopupInput(i.touches[0].pageX,i.touches[0].pageY)},Ro)}onTouchEndCurrentValue(i){this.longPressTimer&&!this.isPopupInputVisible&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}deletePopupInput(){const i=document.querySelector(".popup-number-input");i&&i.remove(),this.isPopupInputVisible=!1}showPopupInput(i,t){const e=document.createElement("input");e.type="number",e.value=this.inputRange.value,e.min=this.inputRange.min,e.max=this.inputRange.max,e.step=this.inputRange.step,e.classList.add("popup-number-input");const n=`
position: absolute;
left: ${i}px;
top: ${t}px;
width: 50px;
-webkit-appearance: none;
margin: 0;
`;e.setAttribute("style",n),document.body.appendChild(e),e.addEventListener("contextmenu",s=>{s.preventDefault()}),e.addEventListener("change",s=>{var a,c;let o=s.target;this.inputRange.value=o==null?void 0:o.value;var r=new Event("input");(a=this.inputRange)==null||a.dispatchEvent(r);var r=new Event("change");(c=this.inputRange)==null||c.dispatchEvent(r)}),e.addEventListener("keydown",s=>{s.key==="Enter"&&this.deletePopupInput()}),e.focus(),this.isPopupInputVisible=!0}updateCurrentValueOverlay(){var n,s;const i=Number((this.inputRange.value-this.inputRange.min)*100/(this.inputRange.max-this.inputRange.min)),t=10-i*.2;this.currentValue.innerHTML=`${(n=this.inputRange)==null?void 0:n.value} `,this.currentValue.style.left=`calc(${i}% + (${t}px))`;const e=(s=this.currentValue)==null?void 0:s.querySelector("span");e==null||e.addEventListener("mousedown",this.onMouseDownCurrentValue.bind(this)),e==null||e.addEventListener("mouseup",this.onMouseUpCurrentValue.bind(this)),e==null||e.addEventListener("touchstart",this.onTouchStartCurrentValue.bind(this)),e==null||e.addEventListener("touchend",this.onTouchEndCurrentValue.bind(this)),e==null||e.addEventListener("contextmenu",o=>{o.preventDefault()})}onInputEvent(i){this.updateCurrentValueOverlay()}onInputChangeEvent(i){var t;this.sendState((t=this.inputRange)==null?void 0:t.value)}sendState(i){let t=new CustomEvent("state",{detail:{state:i,id:this.id}});this.dispatchEvent(t)}render(){return S`${this.min||0} ${this.max||100} `}static get styles(){return[$i,nt`:host{min-width:150px;flex:1}input[type=range]{background:0 0;-webkit-appearance:none;appearance:none;margin:20px 0;width:100%;touch-action:none}input[type=range]:focus{outline:0}input[type=range]::-webkit-slider-runnable-track{width:100%;height:4px;cursor:pointer;animate:.2s;background:#03a9f4;border-radius:25px}input[type=range]::-moz-range-track{width:100%;height:4px;cursor:pointer;animate:.2s;background:#03a9f4;border-radius:25px}input[type=range]::-ms-track{background:0 0;width:100%;height:4px;cursor:pointer;animate:.2s;background:0 0;border-color:transparent;color:transparent}input[type=range]::-ms-fill-lower{background:#03a9f4;border-radius:25px}input[type=range]::-ms-fill-upper{background:#03a9f4;border-radius:25px}input[type=range]::-webkit-slider-thumb{height:20px;width:20px;border-radius:50%;background:#fff;box-shadow:0 0 4px 0 #000;cursor:pointer;-webkit-appearance:none;margin-top:-8px}input[type=range]::-moz-range-thumb{height:20px;width:20px;border-radius:50%;background:#fff;box-shadow:0 0 4px 0 #000;cursor:pointer;border:none}input[type=range]::-ms-thumb{height:20px;width:20px;border-radius:50%;background:#fff;box-shadow:0 0 4px 0 #000;cursor:pointer;border:none}input[type=range]:focus::-webkit-slider-runnable-track{background:#03a9f4}input[type=range]:focus::-moz-range-track{background:#03a9f4}input[type=range]:focus::-ms-fill-lower{background:#03a9f4}input[type=range]:focus::-ms-fill-upper{background:#03a9f4}.range-wrap{display:flex;align-items:center}.slider-wrap{flex-grow:1;margin:0 15px;position:relative}.range-value{position:absolute;top:-50%}.range-value span{padding:0 3px 0 3px;height:19px;line-height:18px;text-align:center;background:#03a9f4;color:#fff;font-size:11px;display:block;position:absolute;left:50%;transform:translate(-50%,+80%);border-radius:6px}@-moz-document url-prefix(){.range-value span{transform:translate(-50%,+150%)}}.range-value span:before{content:"";position:absolute;width:0;height:0;border-top:10px solid #03a9f4;border-left:5px solid transparent;border-right:5px solid transparent;top:100%;left:50%;margin-left:-5px;margin-top:-1px;pointer-events:none}`]}};Jt([Y({type:String})],Tt.prototype,"value",2);Jt([Y({type:String})],Tt.prototype,"min",2);Jt([Y({type:String})],Tt.prototype,"max",2);Jt([Y({type:String})],Tt.prototype,"step",2);Jt([Y({type:String})],Tt.prototype,"name",2);Tt=Jt([Rt("esp-range-slider")],Tt);var Nu=`
`,zu=Object.defineProperty,ju=Object.getOwnPropertyDescriptor,Bu=(i,t,e,n)=>{for(var s=n>1?void 0:n?ju(t,e):t,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=(n?r(t,e,s):r(s))||s);return n&&s&&zu(t,e,s),s};let Fo=class extends J{render(){return sa([Nu])}};Fo=Bu([Rt("esp-logo")],Fo);var Vu=nt`.flex-grid-half{display:grid;grid-template-columns:700px 2fr}.flex-grid-half.expanded_entity,.flex-grid-half.expanded_logs{grid-template-columns:1fr}.flex-grid-half .col{margin:8px}.flex-grid-half .col:nth-child(2){overflow:hidden}.flex-grid-half.expanded_logs .col:nth-child(1){display:none}.flex-grid-half.expanded_entity .col:nth-child(2){display:none}@media (max-width:1024px){.flex-grid,.flex-grid-half{display:block}.flex-grid-half .col{width:100%!important;margin:0 0 10px 0!important;display:block!important}}*{box-sizing:border-box}.flex-grid{margin:0 0 20px 0}h1{text-align:center;width:100%;line-height:1.1em;margin-block:.25em}header div{text-align:center;width:100%}header #logo,header iconify-icon{float:right;font-size:2.5rem;color:rgba(127,127,127,.5)}header #logo{float:left;color:rgba(127,127,127,.5)}.connected{color:rgba(0,157,16,.75)}esp-logo{float:left;line-height:1em;font-size:initial}form{display:flex;justify-content:space-between;background-color:rgba(127,127,127,.05);border-radius:12px;border-width:1px;border-style:solid;border-color:rgba(127,127,127,.12)}form .btn{margin-right:0}`,Hu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,te=(i,t,e,n)=>{for(var s=n>1?void 0:n?Uu(t,e):t,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=(n?r(t,e,s):r(s))||s);return n&&s&&Hu(t,e,s),s};window.source=new EventSource(Ti()+"/events");function Wu(i){const t=Math.sign(i);if(i===0)return new Intl.RelativeTimeFormat("en").format(0,"second");const e=[{type:"year",seconds:12*30*24*60*60*1e3},{type:"month",seconds:30*24*60*60*1e3},{type:"week",seconds:7*24*60*60*1e3},{type:"day",seconds:24*60*60*1e3},{type:"hour",seconds:60*60*1e3},{type:"minute",seconds:60*1e3},{type:"second",seconds:1e3}];let n="";const s=new Intl.RelativeTimeFormat("en");let o=0;for(let r of e){const a=Math.trunc(Math.abs(i/r.seconds));if(a>0){const c=s.format(a*t,r.type);if(i-=a*r.seconds*t,n+=o===0&&r.type!="second"?c.replace(" ago"," "):c,o++>=1)break}}return n}let Lt=class extends J{constructor(){super(),this.scheme="",this.ping=0,this.connected=!0,this.lastUpdate=0,this._hasJsonUptime=!1,this.version="3.0.0",this.config={ota:!1,log:!0,title:"",comment:""},this.darkQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.frames=[{},{color:"rgba(0, 196, 21, 0.75)"},{}];const i=document.querySelector("script#config");i&&this.setConfig(JSON.parse(i.innerText))}setConfig(i){"log"in i||(i.log=this.config.log),this.config=i,document.title=i.title,document.documentElement.lang=i.lang}firstUpdated(i){super.firstUpdated(i),document.getElementsByTagName("head")[0].innerHTML+=' ';const t=document.querySelector("link[rel~='icon']");t.href='data:image/svg+xml, ',this.scheme=this.schemeDefault(),window.source.addEventListener("ping",e=>{var n;if((n=e.data)!=null&&n.length){const s=JSON.parse(e.data);s.title!==void 0&&(this.setConfig(s),this.requestUpdate()),s.uptime!==void 0?(this._hasJsonUptime=!0,this._setUptime(s.uptime*1e3)):this._updateUptime(e)}else this._updateUptime(e);this.lastUpdate=Date.now()}),window.source.addEventListener("log",e=>{this._hasJsonUptime||this._updateUptime(e),this.lastUpdate=Date.now()}),window.source.addEventListener("state",e=>{this.lastUpdate=Date.now()}),window.source.addEventListener("error",e=>{console.dir(e),this.connected=!1,this.requestUpdate()}),setInterval(()=>{this.connected=!!this.ping&&Date.now()-this.lastUpdate<15e3},5e3),document.addEventListener("entity-tab-header-double-clicked",e=>{var s;const n=(s=this.shadowRoot)==null?void 0:s.querySelector("main.flex-grid-half");n==null||n.classList.toggle("expanded_entity")}),document.addEventListener("log-tab-header-double-clicked",e=>{var s;const n=(s=this.shadowRoot)==null?void 0:s.querySelector("main.flex-grid-half");n==null||n.classList.toggle("expanded_logs")})}schemeDefault(){return this.darkQuery.matches?"dark":"light"}updated(i){super.updated(i),i.has("scheme")&&document.documentElement.style.setProperty("color-scheme",this.scheme),i.has("ping")&&this.ping&&this.beat.animate(this.frames,1e3)}uptime(){return`${Wu(-this.ping||0)}`}renderOta(){if(this.config.ota){let i=Ti();return S``}}renderLog(){return this.config.log?S``:E}renderTitle(){return S`${this.config.title||S` `} ${[this.config.comment,`started ${this.uptime()}`].filter(i=>i).map(i=>`${i}`).join(" \xB7 ")}
`}render(){return S`${this.renderLog()} `}_setUptime(i){this.ping=i,this.connected=!0,this.requestUpdate()}_updateUptime(i){i.lastEventId&&this._setUptime(parseInt(i.lastEventId))}static get styles(){return[$i,Wo,Vu,Mn]}};te([mt()],Lt.prototype,"scheme",2);te([mt()],Lt.prototype,"ping",2);te([mt()],Lt.prototype,"connected",2);te([mt()],Lt.prototype,"lastUpdate",2);te([ma("#beat")],Lt.prototype,"beat",2);Lt=te([Rt("esp-app")],Lt);