From bb7b7fa6fff4cc1f94b47b4eaefc492cd49cd6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Wed, 3 Aug 2022 21:21:25 +0000 Subject: [PATCH] Update popup design. Add form popups --- custom_components/browser_mod/browser_mod.js | 101 +++++++++------- .../browser_mod/browser_mod_panel.js | 22 ++-- custom_components/browser_mod/manifest.json | 2 +- documentation/popups.md | 110 ++++++++++++++++-- documentation/services.md | 8 +- js/config_panel/registered-browsers-card.ts | 2 - js/helpers.ts | 16 ++- js/plugin/main.ts | 29 ++--- js/plugin/mediaPlayer.ts | 21 ++-- js/plugin/popups.ts | 86 +++++++++----- js/plugin/services.ts | 21 +++- package.json | 2 +- 12 files changed, 289 insertions(+), 131 deletions(-) diff --git a/custom_components/browser_mod/browser_mod.js b/custom_components/browser_mod/browser_mod.js index 9662d29..bc1cbcb 100644 --- a/custom_components/browser_mod/browser_mod.js +++ b/custom_components/browser_mod/browser_mod.js @@ -1,4 +1,4 @@ -function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(n<3?o(r):n>3?o(t,i,r):o(t,i))||r);return n>3&&r&&Object.defineProperty(t,i,r),r}const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class o{constructor(e,t,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const i=this.t;if(t&&void 0===e){const t=void 0!==i&&1===i.length;t&&(e=s.get(i)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&s.set(i,e))}return e}toString(){return this.cssText}}const n=(e,...t)=>{const s=1===e.length?e[0]:t.reduce(((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1]),e[0]);return new o(s,e,i)},r=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,i))(t)})(e):e;var a;const d=window.trustedTypes,l=d?d.emptyScript:"",c=window.reactiveElementPolyfillSupport,h={toAttribute(e,t){switch(t){case Boolean:e=e?l:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},u=(e,t)=>t!==e&&(t==t||e==e),p={attribute:!0,type:String,converter:h,reflect:!1,hasChanged:u};class v extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;null!==(t=this.h)&&void 0!==t||(this.h=[]),this.h.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const s=this._$Ep(i,t);void 0!==s&&(this._$Ev.set(s,i),e.push(s))})),e}static createProperty(e,t=p){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(r(e))}else void 0!==e&&t.push(r(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const i=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,i)=>{t?e.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):i.forEach((t=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=t.cssText,e.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=p){var s,o;const n=this.constructor._$Ep(e,i);if(void 0!==n&&!0===i.reflect){const r=(null!==(o=null===(s=i.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==o?o:h.toAttribute)(t,i.type);this._$El=e,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$El=null}}_$AK(e,t){var i,s;const o=this.constructor,n=o._$Ev.get(e);if(void 0!==n&&this._$El!==n){const e=o.getPropertyOptions(n),r=e.converter,a=null!==(s=null!==(i=null==r?void 0:r.fromAttribute)&&void 0!==i?i:"function"==typeof r?r:null)&&void 0!==s?s:h.fromAttribute;this._$El=n,this[n]=a(t,e.type),this._$El=null}}requestUpdate(e,t,i){let s=!0;void 0!==e&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||u)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(i)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}var m;v.finalized=!0,v.elementProperties=new Map,v.elementStyles=[],v.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:v}),(null!==(a=globalThis.reactiveElementVersions)&&void 0!==a?a:globalThis.reactiveElementVersions=[]).push("1.3.4");const _=globalThis.trustedTypes,g=_?_.createPolicy("lit-html",{createHTML:e=>e}):void 0,w=`lit$${(Math.random()+"").slice(9)}$`,b="?"+w,y=`<${b}>`,f=document,$=(e="")=>f.createComment(e),E=e=>null===e||"object"!=typeof e&&"function"!=typeof e,A=Array.isArray,x=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,S=/-->/g,C=/>/g,T=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),P=/'/g,k=/"/g,I=/^(?:script|style|textarea|title)$/i,M=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),O=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),U=new WeakMap,D=f.createTreeWalker(f,129,null,!1),R=(e,t)=>{const i=e.length-1,s=[];let o,n=2===t?"":"",r=x;for(let t=0;t"===d[0]?(r=null!=o?o:x,l=-1):void 0===d[1]?l=-2:(l=r.lastIndex-d[2].length,a=d[1],r=void 0===d[3]?T:'"'===d[3]?k:P):r===k||r===P?r=T:r===S||r===C?r=x:(r=T,o=void 0);const h=r===T&&e[t+1].startsWith("/>")?" ":"";n+=r===x?i+y:l>=0?(s.push(a),i.slice(0,l)+"$lit$"+i.slice(l)+w+h):i+w+(-2===l?(s.push(void 0),t):h)}const a=n+(e[i]||"")+(2===t?"":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==g?g.createHTML(a):a,s]};class j{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,n=0;const r=e.length-1,a=this.parts,[d,l]=R(e,t);if(this.el=j.createElement(d,i),D.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=D.nextNode())&&a.length0){s.textContent=_?_.emptyScript:"";for(let i=0;iA(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.S(e):this.T(e)}j(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}k(e){this._$AH!==e&&(this._$AR(),this._$AH=this.j(e))}T(e){this._$AH!==L&&E(this._$AH)?this._$AA.nextSibling.data=e:this.k(f.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,o="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=j.createElement(s.h,this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===o)this._$AH.m(i);else{const e=new N(o,this),t=e.p(this.options);e.m(i),this.k(t),this._$AH=e}}_$AC(e){let t=U.get(e.strings);return void 0===t&&U.set(e.strings,t=new j(e)),t}S(e){A(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const o of e)s===t.length?t.push(i=new z(this.j($()),this.j($()),this,this.options)):i=t[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=L}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,s){const o=this.strings;let n=!1;if(void 0===o)e=H(this,e,t,0),n=!E(e)||e!==this._$AH&&e!==O,n&&(this._$AH=e);else{const s=e;let r,a;for(e=o[0],r=0;r{var s,o;const n=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:t;let r=n._$litPart$;if(void 0===r){const e=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;n._$litPart$=r=new z(t.insertBefore($(),e),e,void 0,null!=i?i:{})}return r._$AI(e),r})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return O}}Q.finalized=!0,Q._$litElement$=!0,null===(J=globalThis.litElementHydrateSupport)||void 0===J||J.call(globalThis,{LitElement:Q});const X=globalThis.litElementPolyfillSupport;null==X||X({LitElement:Q}),(null!==(Z=globalThis.litElementVersions)&&void 0!==Z?Z:globalThis.litElementVersions=[]).push("3.2.2");const Y=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(i){i.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}};function ee(e){return(t,i)=>void 0!==i?((e,t,i)=>{t.constructor.createProperty(i,e)})(e,t,i):Y(e,t)}function te(e){return ee({...e,state:!0})}function ie(e,t){return(({finisher:e,descriptor:t})=>(i,s)=>{var o;if(void 0===s){const s=null!==(o=i.originalKey)&&void 0!==o?o:i.key,n=null!=t?{kind:"method",placement:"prototype",key:s,descriptor:t(i.key)}:{...i,key:s};return null!=e&&(n.finisher=function(t){e(t,s)}),n}{const o=i.constructor;void 0!==t&&Object.defineProperty(i,s,t(s)),null==e||e(o,s)}})({descriptor:i=>{const s={get(){var t,i;return null!==(i=null===(t=this.renderRoot)||void 0===t?void 0:t.querySelector(e))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(t){const t="symbol"==typeof i?Symbol():"__"+i;s.get=function(){var i,s;return void 0===this[t]&&(this[t]=null!==(s=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(e))&&void 0!==s?s:null),this[t]}}return s}})}var se;null===(se=window.HTMLSlotElement)||void 0===se||se.prototype.assignedElements;class oe extends Q{setConfig(e){}render(){return M`
Nothing to configure.
`}}(async()=>{for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));await window.browser_mod.connectionPromise,customElements.get("browser-player-editor")||(customElements.define("browser-player-editor",oe),window.customCards=window.customCards||[],window.customCards.push({type:"browser-player",name:"Browser Player",preview:!0}))})();class ne extends Q{static getConfigElement(){return document.createElement("browser-player-editor")}static getStubConfig(){return{}}async setConfig(e){for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));for(const e of["play","pause","ended","volumechange","canplay","loadeddata"])window.browser_mod._audio_player.addEventListener(e,(()=>this.requestUpdate()));window.browser_mod._video_player.addEventListener(event,(()=>this.requestUpdate()))}handleMute(e){window.browser_mod.player.muted=!window.browser_mod.player.muted}handleVolumeChange(e){const t=parseFloat(e.target.value);window.browser_mod.player.volume=t}handleMoreInfo(e){var t;this.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:null===(t=window.browser_mod.browserEntities)||void 0===t?void 0:t.player}}))}handlePlayPause(e){!window.browser_mod.player.src||window.browser_mod.player.paused||window.browser_mod.player.ended?(window.browser_mod.player.play(),window.browser_mod._show_video_player()):window.browser_mod.player.pause()}render(){return window.browser_mod?M` +function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}const e=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class o{constructor(t,e,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=s.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&s.set(i,t))}return t}toString(){return this.cssText}}const n=(t,...e)=>{const s=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new o(s,t,i)},r=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new o("string"==typeof t?t:t+"",void 0,i))(e)})(t):t;var a;const d=window.trustedTypes,l=d?d.emptyScript:"",c=window.reactiveElementPolyfillSupport,h={toAttribute(t,e){switch(e){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},u=(t,e)=>e!==t&&(e==e||t==t),p={attribute:!0,type:String,converter:h,reflect:!1,hasChanged:u};class v extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=p){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const i=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,i)=>{e?t.adoptedStyleSheets=i.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):i.forEach((e=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=p){var s,o;const n=this.constructor._$Ep(t,i);if(void 0!==n&&!0===i.reflect){const r=(null!==(o=null===(s=i.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==o?o:h.toAttribute)(e,i.type);this._$El=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$El=null}}_$AK(t,e){var i,s;const o=this.constructor,n=o._$Ev.get(t);if(void 0!==n&&this._$El!==n){const t=o.getPropertyOptions(n),r=t.converter,a=null!==(s=null!==(i=null==r?void 0:r.fromAttribute)&&void 0!==i?i:"function"==typeof r?r:null)&&void 0!==s?s:h.fromAttribute;this._$El=n,this[n]=a(e,t.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||u)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var m;v.finalized=!0,v.elementProperties=new Map,v.elementStyles=[],v.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:v}),(null!==(a=globalThis.reactiveElementVersions)&&void 0!==a?a:globalThis.reactiveElementVersions=[]).push("1.3.4");const _=globalThis.trustedTypes,g=_?_.createPolicy("lit-html",{createHTML:t=>t}):void 0,w=`lit$${(Math.random()+"").slice(9)}$`,b="?"+w,y=`<${b}>`,f=document,$=(t="")=>f.createComment(t),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,A=Array.isArray,x=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,S=/-->/g,C=/>/g,T=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),P=/'/g,k=/"/g,I=/^(?:script|style|textarea|title)$/i,O=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),M=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),U=new WeakMap,D=f.createTreeWalker(f,129,null,!1),R=(t,e)=>{const i=t.length-1,s=[];let o,n=2===e?"":"",r=x;for(let e=0;e"===d[0]?(r=null!=o?o:x,l=-1):void 0===d[1]?l=-2:(l=r.lastIndex-d[2].length,a=d[1],r=void 0===d[3]?T:'"'===d[3]?k:P):r===k||r===P?r=T:r===S||r===C?r=x:(r=T,o=void 0);const h=r===T&&t[e+1].startsWith("/>")?" ":"";n+=r===x?i+y:l>=0?(s.push(a),i.slice(0,l)+"$lit$"+i.slice(l)+w+h):i+w+(-2===l?(s.push(void 0),e):h)}const a=n+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==g?g.createHTML(a):a,s]};class j{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,n=0;const r=t.length-1,a=this.parts,[d,l]=R(t,e);if(this.el=j.createElement(d,i),D.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=D.nextNode())&&a.length0){s.textContent=_?_.emptyScript:"";for(let i=0;iA(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.S(t):this.T(t)}j(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.j(t))}T(t){this._$AH!==L&&E(this._$AH)?this._$AA.nextSibling.data=t:this.k(f.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=j.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.m(i);else{const t=new N(o,this),e=t.p(this.options);t.m(i),this.k(e),this._$AH=t}}_$AC(t){let e=U.get(t.strings);return void 0===e&&U.set(t.strings,e=new j(t)),e}S(t){A(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new z(this.j($()),this.j($()),this,this.options)):i=e[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=L}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let n=!1;if(void 0===o)t=H(this,t,e,0),n=!E(t)||t!==this._$AH&&t!==M,n&&(this._$AH=t);else{const s=t;let r,a;for(t=o[0],r=0;r{var s,o;const n=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;n._$litPart$=r=new z(e.insertBefore($(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return M}}Q.finalized=!0,Q._$litElement$=!0,null===(J=globalThis.litElementHydrateSupport)||void 0===J||J.call(globalThis,{LitElement:Q});const X=globalThis.litElementPolyfillSupport;null==X||X({LitElement:Q}),(null!==(Z=globalThis.litElementVersions)&&void 0!==Z?Z:globalThis.litElementVersions=[]).push("3.2.2");const Y=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function tt(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):Y(t,e)}function et(t){return tt({...t,state:!0})}function it(t,e){return(({finisher:t,descriptor:e})=>(i,s)=>{var o;if(void 0===s){const s=null!==(o=i.originalKey)&&void 0!==o?o:i.key,n=null!=e?{kind:"method",placement:"prototype",key:s,descriptor:e(i.key)}:{...i,key:s};return null!=t&&(n.finisher=function(e){t(e,s)}),n}{const o=i.constructor;void 0!==e&&Object.defineProperty(i,s,e(s)),null==t||t(o,s)}})({descriptor:i=>{const s={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;s.get=function(){var i,s;return void 0===this[e]&&(this[e]=null!==(s=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==s?s:null),this[e]}}return s}})}var st;null===(st=window.HTMLSlotElement)||void 0===st||st.prototype.assignedElements;class ot extends Q{setConfig(t){}render(){return O`
Nothing to configure.
`}}(async()=>{for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));await window.browser_mod.connectionPromise,customElements.get("browser-player-editor")||(customElements.define("browser-player-editor",ot),window.customCards=window.customCards||[],window.customCards.push({type:"browser-player",name:"Browser Player",preview:!0}))})();class nt extends Q{static getConfigElement(){return document.createElement("browser-player-editor")}static getStubConfig(){return{}}async setConfig(t){for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));for(const t of["play","pause","ended","volumechange","canplay","loadeddata"])window.browser_mod._audio_player.addEventListener(t,(()=>this.requestUpdate()));window.browser_mod._video_player.addEventListener(event,(()=>this.requestUpdate()))}handleMute(t){window.browser_mod.player.muted=!window.browser_mod.player.muted}handleVolumeChange(t){const e=parseFloat(t.target.value);window.browser_mod.player.volume=e}handleMoreInfo(t){var e;this.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:null===(e=window.browser_mod.browserEntities)||void 0===e?void 0:e.player}}))}handlePlayPause(t){!window.browser_mod.player.src||window.browser_mod.player.paused||window.browser_mod.player.ended?(window.browser_mod.player.play(),window.browser_mod._show_video_player()):window.browser_mod.player.pause()}render(){return window.browser_mod?O`
@@ -15,7 +15,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro @change=${this.handleVolumeChange} > - ${"stopped"===window.browser_mod.player_state?M`
`:M` + ${"stopped"===window.browser_mod.player_state?O`
`:O` ${window.browser_mod.browserID}
- `:(window.setTimeout((()=>this.requestUpdate()),100),M``)}static get styles(){return n` + `:(window.setTimeout((()=>this.requestUpdate()),100),O``)}static get styles(){return n` paper-icon-button[highlight] { color: var(--accent-color); } @@ -53,7 +53,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro ha-icon-button ha-icon { display: flex; } - `}}e([ee()],ne.prototype,"hass",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));await window.browser_mod.connectionPromise,customElements.get("browser-player")||customElements.define("browser-player",ne)})();async function re(e){var t;(null===(t=e.localName)||void 0===t?void 0:t.includes("-"))&&await customElements.whenDefined(e.localName),e.updateComplete&&await e.updateComplete}async function ae(e,t,i=!1){let s=[e];for("string"==typeof t&&(t=t.split(/(\$| )/));""===t[t.length-1];)t.pop();for(const[e,i]of t.entries()){const e=s[0];if(!e)return null;i.trim().length&&(re(e),s="$"===i?[e.shadowRoot]:e.querySelectorAll(i))}return i?s:s[0]}async function de(e,t,i=!1,s=1e4){return Promise.race([ae(e,t,i),new Promise(((e,t)=>setTimeout((()=>t(new Error("SELECTTREE-TIMEOUT"))),s)))]).catch((e=>{if(!e.message||"SELECTTREE-TIMEOUT"!==e.message)throw e;return null}))}async function le(){await Promise.race([customElements.whenDefined("home-assistant"),customElements.whenDefined("hc-main")]);const e=customElements.get("home-assistant")?"home-assistant":"hc-main";for(;!document.querySelector(e);)await new Promise((e=>window.setTimeout(e,100)));return document.querySelector(e)}async function ce(e){(await le()).provideHass(e)}const he=async()=>{var e,t,i;if(void 0!==window.loadCardHelpers)return;await customElements.whenDefined("partial-panel-resolver");const s=document.createElement("partial-panel-resolver").getRoutes([{component_name:"lovelace",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==s?void 0:s.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t))},ue=e=>class extends e{constructor(){super(...arguments),this.connected=!1,this.connectionPromise=new Promise((e=>{this._connectionResolve=e})),this.browserEntities={}}LOG(...e){}fireEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}incoming_message(e){var t;e.command?(this.LOG("Command:",e),this.fireEvent(`command-${e.command}`,e)):e.browserEntities?this.browserEntities=e.browserEntities:e.result&&this.update_config(e.result),null===(t=this._connectionResolve)||void 0===t||t.call(this)}update_config(e){var t;this.LOG("Receive:",e);let i=!1;!this.registered&&(null===(t=e.browsers)||void 0===t?void 0:t[this.browserID])&&(i=!0),this._data=e,this.connected||(this.connected=!0,this.fireEvent("browser-mod-connected")),this.fireEvent("browser-mod-config-update"),i&&this.sendUpdate({})}async connect(){const e=(await async function(){const e=await le();for(;!e.hass;)await new Promise((e=>window.setTimeout(e,100)));return e.hass}()).connection;this.connection=e,e.subscribeMessage((e=>this.incoming_message(e)),{type:"browser_mod/connect",browserID:this.browserID}),e.addEventListener("disconnected",(()=>{this.connected=!1,this.fireEvent("browser-mod-disconnected")})),e.addEventListener("ready",(()=>{this.connected=!0,this.fireEvent("browser-mod-connected"),this.sendUpdate({})})),ce(this)}get config(){var e,t;return null!==(t=null===(e=this._data)||void 0===e?void 0:e.config)&&void 0!==t?t:{}}get browsers(){var e,t;return null!==(t=null===(e=this._data)||void 0===e?void 0:e.browsers)&&void 0!==t?t:[]}get registered(){var e;return void 0!==(null===(e=this.browsers)||void 0===e?void 0:e[this.browserID])}set registered(e){(async()=>{if(e){if(this.registered)return;await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID})}else{if(!this.registered)return;await this.connection.sendMessage({type:"browser_mod/unregister",browserID:this.browserID})}})()}async _reregister(e={}){await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID,data:Object.assign(Object.assign({},this.browsers[this.browserID]),e)})}get global_settings(){var e,t;const i={},s=null!==(t=null===(e=this._data)||void 0===e?void 0:e.settings)&&void 0!==t?t:{};for(const[e,t]of Object.entries(s))null!==t&&(i[e]=t);return i}get user_settings(){var e,t,i,s,o;const n={},r=null!==(o=null===(t=null===(e=this._data)||void 0===e?void 0:e.user_settings)||void 0===t?void 0:t[null===(s=null===(i=this.hass)||void 0===i?void 0:i.user)||void 0===s?void 0:s.id])&&void 0!==o?o:{};for(const[e,t]of Object.entries(r))null!==t&&(n[e]=t);return n}get browser_settings(){var e,t,i;const s={},o=null!==(i=null===(t=null===(e=this.browsers)||void 0===e?void 0:e[this.browserID])||void 0===t?void 0:t.settings)&&void 0!==i?i:{};for(const[e,t]of Object.entries(o))null!==t&&(s[e]=t);return s}get settings(){return Object.assign(Object.assign(Object.assign({},this.global_settings),this.browser_settings),this.user_settings)}set_setting(e,t,i){var s;switch(i){case"global":this.connection.sendMessage({type:"browser_mod/settings",key:e,value:t});break;case"user":{const i=this.hass.user.id;this.connection.sendMessage({type:"browser_mod/settings",user:i,key:e,value:t});break}case"browser":{const i=null===(s=this.browsers[this.browserID])||void 0===s?void 0:s.settings;i[e]=t,this._reregister({settings:i});break}}}get cameraEnabled(){return this.registered?this.browsers[this.browserID].camera:null}set cameraEnabled(e){this._reregister({camera:e})}sendUpdate(e){this.connected&&this.registered&&(this.LOG("Send:",e),this.connection.sendMessage({type:"browser_mod/update",browserID:this.browserID,data:e}))}browserIDChanged(e,t){var i,s;this.fireEvent("browser-mod-config-update"),void 0!==(null===(i=this.browsers)||void 0===i?void 0:i[e])&&void 0===(null===(s=this.browsers)||void 0===s?void 0:s[this.browserID])&&(async()=>{await this.connection.sendMessage({type:"browser_mod/register",browserID:e,data:Object.assign(Object.assign({},this.browsers[e]),{browserID:this.browserID})})})()}},pe=e=>class extends e{constructor(){super(),this._listeners={},this._brightness=255;const e=this._panel=document.createElement("div");document.body.append(e),e.classList.add("browser-mod-blackout"),e.attachShadow({mode:"open"});const t=document.createElement("style");e.shadowRoot.append(t),t.innerHTML="\n :host {\n background: rgba(0,0,0, var(--darkness));\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n width: 100%;\n height: 100%;\n z-index: 10000;\n display: block;\n pointer-events: none;\n }\n :host([dark]) {\n background: rgba(0,0,0,1);\n }\n ",this.addEventListener("command-screen_off",(()=>this._screen_off())),this.addEventListener("command-screen_on",(e=>this._screen_on(e))),this.addEventListener("fully-update",(()=>this.send_screen_status())),this.connectionPromise.then((()=>this._screen_on()))}send_screen_status(){let e=!this._panel.hasAttribute("dark"),t=this._brightness;this.fully&&(e=this.fully_screen,t=this.fully_brightness),this.sendUpdate({screen_on:e,screen_brightness:t})}_screen_off(){this.fully?this.fully_screen=!1:this._panel.setAttribute("dark",""),this.send_screen_status();const e=()=>this._screen_on();for(const t of["pointerdown","pointermove","keydown"])this._listeners[t]=e,window.addEventListener(t,e)}_screen_on(e){var t,i;this.fully?(this.fully_screen=!0,(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.brightness)&&(this.fully_brightness=e.detail.brightness)):((null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.brightness)&&(this._brightness=e.detail.brightness,this._panel.style.setProperty("--darkness",1-e.detail.brightness/255)),this._panel.removeAttribute("dark")),this.send_screen_status();for(const e of["pointerdown","pointermove","keydown"])this._listeners[e]&&(window.removeEventListener(e,this._listeners[e]),this._listeners[e]=void 0)}},ve=e=>class extends e{constructor(){super(),this._audio_player=new Audio,this._video_player=document.createElement("video"),this._video_player.controls=!0,this._video_player.style.setProperty("width","100%"),this.player=this._audio_player,this._player_enabled=!1;for(const e of["play","pause","ended","volumechange"])this._audio_player.addEventListener(e,(()=>this._player_update())),this._video_player.addEventListener(e,(()=>this._player_update()));for(const e of["timeupdate"])this._audio_player.addEventListener(e,(()=>this._player_update_choked())),this._video_player.addEventListener(e,(()=>this._player_update_choked()));this.firstInteraction.then((()=>{this._player_enabled=!0,this.player.ended||this.player.play()})),this.addEventListener("command-player-play",(e=>{var t,i,s;this.player.src&&this.player.pause(),(null===(t=e.detail)||void 0===t?void 0:t.media_type)&&((null===(i=e.detail)||void 0===i?void 0:i.media_type.startsWith("video"))?this.player=this._video_player:this.player=this._audio_player),(null===(s=e.detail)||void 0===s?void 0:s.media_content_id)&&(this.player.src=e.detail.media_content_id),this.player.play(),this._show_video_player()})),this.addEventListener("command-player-pause",(e=>this.player.pause())),this.addEventListener("command-player-stop",(e=>{this.player.src=null,this.player.pause()})),this.addEventListener("command-player-set-volume",(e=>{var t;void 0!==(null===(t=e.detail)||void 0===t?void 0:t.volume_level)&&(this.player.volume=e.detail.volume_level)})),this.addEventListener("command-player-mute",(e=>{var t;void 0!==(null===(t=e.detail)||void 0===t?void 0:t.mute)?this.player.muted=Boolean(e.detail.mute):this.player.muted=!this.player.muted})),this.addEventListener("command-player-seek",(e=>{this.player.currentTime=e.detail.position,setTimeout((()=>this._player_update()),10)})),this.addEventListener("command-player-turn-off",(e=>{this.player===this._video_player&&this._video_player.isConnected?this.closePopup():this.player.src&&this.player.pause(),this.player.src="",this._player_update()})),this.connectionPromise.then((()=>this._player_update()))}_show_video_player(){this.player===this._video_player&&this.player.src?(de(document,"home-assistant $ dialog-media-player-browse").then((e=>null==e?void 0:e.closeDialog())),this.showPopup(void 0,this._video_player,{dismiss_action:()=>this._video_player.pause(),size:"wide"})):this.player!==this._video_player&&this._video_player.isConnected&&this.closePopup()}_player_update_choked(){this._player_update_cooldown||(this._player_update_cooldown=window.setTimeout((()=>this._player_update_cooldown=void 0),3e3),this._player_update())}_player_update(){const e=this._player_enabled?this.player.src&&this.player.src!==window.location.href?this.player.ended?"stopped":this.player.paused?"paused":"playing":"off":"unavailable";this.sendUpdate({player:{volume:this.player.volume,muted:this.player.muted,src:this.player.src,state:e,media_duration:this.player.duration,media_position:this.player.currentTime}})}},me=e=>class extends e{constructor(){super(),this._framerate=2,this._setup_camera()}async _setup_camera(){if(this._video)return;if(await this.connectionPromise,await this.firstInteraction,!this.cameraEnabled)return;if(this.fully)return this.update_camera();const e=document.createElement("div");document.body.append(e),e.classList.add("browser-mod-camera"),e.attachShadow({mode:"open"});const t=document.createElement("style");e.shadowRoot.append(t),t.innerHTML="\n :host {\n display: none;\n }";const i=this._video=document.createElement("video");e.shadowRoot.append(i),i.autoplay=!0,i.playsInline=!0,i.style.display="none";const s=this._canvas=document.createElement("canvas");if(e.shadowRoot.append(s),s.style.display="none",!navigator.mediaDevices)return;const o=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});i.srcObject=o,i.play(),this.update_camera()}async update_camera(){var e;if(!this.cameraEnabled){const t=null===(e=this._video)||void 0===e?void 0:e.srcObject;return void(t&&(t.getTracks().forEach((e=>e.stop())),this._video.scrObject=void 0))}if(this.fully)this.sendUpdate({camera:this.fully_camera});else{const e=this._video,t=e.videoWidth,i=e.videoHeight;this._canvas.width=t,this._canvas.height=i;this._canvas.getContext("2d").drawImage(e,0,0,t,i),this.sendUpdate({camera:this._canvas.toDataURL("image/jpeg")})}const t=Math.round(1e3/this._framerate);setTimeout((()=>this.update_camera()),t)}},_e=e=>class extends e{constructor(){super(),this.firstInteraction=new Promise((e=>{this._interactionResolve=e})),this.show_indicator()}async show_indicator(){if(await this.connectionPromise,!this.registered)return;const e=document.createElement("div");document.body.append(e),e.classList.add("browser-mod-require-interaction"),e.attachShadow({mode:"open"});const t=document.createElement("style");e.shadowRoot.append(t),t.innerHTML='\n :host {\n position: fixed;\n right: 8px;\n bottom: 8px;\n color: var(--warning-color, red);\n opacity: 0.5;\n --mdc-icon-size: 48px;\n }\n ha-icon::before {\n content: "Browser\\00a0Mod";\n font-size: 0.75rem;\n position: absolute;\n right: 0;\n bottom: 90%;\n }\n video {\n display: none;\n }\n ';const i=document.createElement("ha-icon");e.shadowRoot.append(i),i.icon="mdi:gesture-tap";const s=this._video=document.createElement("video");e.shadowRoot.append(s);const o=s.play();o&&(o.then((()=>{this._interactionResolve()})).catch((e=>{"AbortError"===e.name&&this._interactionResolve()})),s.pause()),window.addEventListener("pointerdown",this._interactionResolve),await this.firstInteraction,e.remove()}},ge=e=>class extends e{constructor(){if(super(),this._fully_screensaver=!1,this.fully){for(const e of["screenOn","screenOff","pluggedAC","pluggedUSB","onBatteryLevelChanged","unplugged","networkReconnect","onMotion","onDaydreamStart","onDaydreamStop"])window.fully.bind(e,`window.browser_mod.fullyEvent("${e}");`);window.fully.bind("onScreensaverStart","window.browser_mod._fully_screensaver = true; window.browser_mod.fullyEvent();"),window.fully.bind("onScreensaverStop","window.browser_mod._fully_screensaver = false; window.browser_mod.fullyEvent();")}}get fully(){return void 0!==window.fully}get fully_screen(){var e;return!1===this._fully_screensaver&&(null===(e=window.fully)||void 0===e?void 0:e.getScreenOn())}set fully_screen(e){var t,i,s;e?(null===(t=window.fully)||void 0===t||t.turnScreenOn(),null===(i=window.fully)||void 0===i||i.stopScreensaver()):null===(s=window.fully)||void 0===s||s.turnScreenOff()}get fully_brightness(){var e;return null===(e=window.fully)||void 0===e?void 0:e.getScreenBrightness()}set fully_brightness(e){var t;null===(t=window.fully)||void 0===t||t.setScreenBrightness(e)}get fully_camera(){var e;return null===(e=window.fully)||void 0===e?void 0:e.getCamshotJpgBase64()}fullyEvent(e){this.fireEvent("fully-update",{event:e})}},we=e=>class extends e{constructor(){super(),document.addEventListener("visibilitychange",(()=>this._browser_state_update())),window.addEventListener("location-changed",(()=>this._browser_state_update())),this.addEventListener("fully-update",(()=>this._browser_state_update())),this.connectionPromise.then((()=>this._browser_state_update()))}_browser_state_update(){(async()=>{var e,t,i,s,o,n,r,a,d,l,c,h;const u=null===(t=(e=navigator).getBattery)||void 0===t?void 0:t.call(e);this.sendUpdate({browser:{path:window.location.pathname,visibility:document.visibilityState,userAgent:navigator.userAgent,currentUser:null===(s=null===(i=this.hass)||void 0===i?void 0:i.user)||void 0===s?void 0:s.name,fullyKiosk:this.fully||!1,width:window.innerWidth,height:window.innerHeight,battery_level:null!==(n=null===(o=window.fully)||void 0===o?void 0:o.getBatteryLevel())&&void 0!==n?n:100*(null==u?void 0:u.level),charging:null!==(a=null===(r=window.fully)||void 0===r?void 0:r.isPlugged())&&void 0!==a?a:null==u?void 0:u.charging,darkMode:null===(l=null===(d=this.hass)||void 0===d?void 0:d.themes)||void 0===l?void 0:l.darkMode,userData:null===(c=this.hass)||void 0===c?void 0:c.user,ip_address:null===(h=window.fully)||void 0===h?void 0:h.getIp4Address()}})})()}async browser_navigate(e){e&&(history.pushState(null,"",e),window.dispatchEvent(new CustomEvent("location-changed")))}},be=e=>class extends e{constructor(){super();const e=["sequence","delay","popup","more_info","close_popup","navigate","refresh","console","javascript"];for(const t of e)this.addEventListener(`command-${t}`,(e=>{this.service(t,e.detail)}));document.body.addEventListener("ll-custom",(e=>{e.detail.browser_mod&&this._service_action(e.detail.browser_mod)}))}async service(e,t){this._service_action({service:e,data:t})}async _service_action({service:e,data:t}){let i=e;if(!i.startsWith("browser_mod.")&&i.includes(".")||void 0!==t.browser_id){const e=Object.assign({},t);"THIS"===e.browser_id&&(e.browser_id=this.browserID);const[s,o]=i.split(".");return this.hass.callService(s,o,e)}switch(i.startsWith("browser_mod.")&&(i=i.substring(12)),i){case"sequence":for(const e of t.sequence)await this._service_action(e);break;case"delay":await new Promise((e=>setTimeout(e,t.time)));break;case"more_info":const{entity:e,large:i,ignore_popup_card:s}=t;this.showMoreInfo(e,i,s);break;case"popup":const{title:o,content:n}=t,r=function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(e);othis._service_action(t));this.showPopup(o,n,r);break;case"close_popup":this.closePopup();break;case"navigate":this.browser_navigate(t.path);break;case"refresh":window.location.href=window.location.href;break;case"console":console.log(t.message);break;case"javascript":const a=`\n "use strict";\n // Insert global definitions here\n const hass = (document.querySelector("home-assistant") || document.querySelector("hc-main")).hass;\n ${t.code}\n `;new Function(a)()}}},ye=e=>class extends e{constructor(){super(),this.activityTriggered=!1,this._activityCooldown=15e3;for(const e of["pointerdown","pointermove","keydown"])window.addEventListener(e,(()=>this.activityTrigger(!0)));this.addEventListener("fully-update",(()=>{this.activityTrigger()}))}activityTrigger(e=!1){this.activityTriggered||this.sendUpdate({activity:!0}),this.activityTriggered=!0,e&&this.fireEvent("browser-mod-activity"),clearTimeout(this._activityTimeout),this._activityTimeout=setTimeout((()=>this.activityReset()),this._activityCooldown)}activityReset(){clearTimeout(this._activityTimeout),this.activityTriggered&&this.sendUpdate({activity:!1}),this.activityTriggered=!1}},fe=2;class $e extends class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}{constructor(e){if(super(e),this.it=L,e.type!==fe)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===L||null==e)return this._t=void 0,this.it=e;if(e===O)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}$e.directiveName="unsafeHTML",$e.resultType=1;const Ee=(e=>(...t)=>({_$litDirective$:e,values:t}))($e);class Ae extends Q{async closeDialog(){this.open=!1,clearInterval(this._timeoutTimer),this._autocloseListener&&(window.browser_mod.removeEventListener("browser-mod-activity",this._autocloseListener),this._autocloseListener=void 0)}openDialog(){var e;this.open=!0,null===(e=this.dialog)||void 0===e||e.show(),this.timeout&&(this._timeoutStart=(new Date).getTime(),this._timeoutTimer=setInterval((()=>{const e=(new Date).getTime()-this._timeoutStart,t=e/this.timeout*100;this.style.setProperty("--progress",`${t}%`),e>=this.timeout&&this._timeout()}),10)),this._autocloseListener=void 0,this._autoclose&&(this._autocloseListener=()=>this.dialog.close(),window.browser_mod.addEventListener("browser-mod-activity",this._autocloseListener,{once:!0}))}async setupDialog(e,t,{right_button:i,right_button_action:s,left_button:o,left_button_action:n,dismissable:r=!0,dismiss_action:a,timeout:d,timeout_action:l,size:c,style:h,autoclose:u=!1}={}){if(this.title=e,t&&t instanceof HTMLElement)this.card=void 0,this.content=t;else if(t&&"object"==typeof t){this.card=!0;const e=await window.loadCardHelpers(),i=await e.createCardElement(t);i.hass=window.browser_mod.hass,ce(i),this.content=i}else this.card=void 0,this.content=Ee(t);this.right_button=i,this.left_button=o,this.actions=void 0===i?void 0:"",this.dismissable=r,this.timeout=d,this._actions={right_button_action:s,left_button_action:n,dismiss_action:a,timeout_action:l},this.wide="wide"===c?"":void 0,this.fullscreen="fullscreen"===c?"":void 0,this._style=h,this._autoclose=u}async _primary(){var e,t,i,s;(null===(e=this._actions)||void 0===e?void 0:e.dismiss_action)&&(this._actions.dismiss_action=void 0),null===(t=this.dialog)||void 0===t||t.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.right_button_action)||void 0===s||s.call(i)}async _secondary(){var e,t,i,s;(null===(e=this._actions)||void 0===e?void 0:e.dismiss_action)&&(this._actions.dismiss_action=void 0),null===(t=this.dialog)||void 0===t||t.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.left_button_action)||void 0===s||s.call(i)}async _dismiss(e){var t,i,s;null===(t=this.dialog)||void 0===t||t.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.dismiss_action)||void 0===s||s.call(i)}async _timeout(){var e,t,i,s;(null===(e=this._actions)||void 0===e?void 0:e.dismiss_action)&&(this._actions.dismiss_action=void 0),null===(t=this.dialog)||void 0===t||t.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.timeout_action)||void 0===s||s.call(i)}render(){return this.open?M` + `}}t([tt()],nt.prototype,"hass",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));await window.browser_mod.connectionPromise,customElements.get("browser-player")||customElements.define("browser-player",nt)})();async function rt(t){var e;(null===(e=t.localName)||void 0===e?void 0:e.includes("-"))&&await customElements.whenDefined(t.localName),t.updateComplete&&await t.updateComplete}async function at(t,e,i=!1){let s=[t];for("string"==typeof e&&(e=e.split(/(\$| )/));""===e[e.length-1];)e.pop();for(const[t,i]of e.entries()){const t=s[0];if(!t)return null;i.trim().length&&(rt(t),s="$"===i?[t.shadowRoot]:t.querySelectorAll(i))}return i?s:s[0]}async function dt(t,e,i=!1,s=1e4){return Promise.race([at(t,e,i),new Promise(((t,e)=>setTimeout((()=>e(new Error("SELECTTREE-TIMEOUT"))),s)))]).catch((t=>{if(!t.message||"SELECTTREE-TIMEOUT"!==t.message)throw t;return null}))}async function lt(){await Promise.race([customElements.whenDefined("home-assistant"),customElements.whenDefined("hc-main")]);const t=customElements.get("home-assistant")?"home-assistant":"hc-main";for(;!document.querySelector(t);)await new Promise((t=>window.setTimeout(t,100)));return document.querySelector(t)}async function ct(t){(await lt()).provideHass(t)}const ht=async()=>{var t,e,i;if(void 0!==window.loadCardHelpers)return;await customElements.whenDefined("partial-panel-resolver");const s=document.createElement("partial-panel-resolver").getRoutes([{component_name:"lovelace",url_path:"a"}]);await(null===(i=null===(e=null===(t=null==s?void 0:s.routes)||void 0===t?void 0:t.a)||void 0===e?void 0:e.load)||void 0===i?void 0:i.call(e))},ut=async()=>{if(customElements.get("ha-form"))return;await ht();const t=await window.loadCardHelpers();if(!t)return;const e=await t.createCardElement({type:"button"});e&&await e.constructor.getConfigElement()};const pt=t=>class extends t{constructor(){super(...arguments),this.connected=!1,this.connectionPromise=new Promise((t=>{this._connectionResolve=t})),this.browserEntities={}}LOG(...t){}fireEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}incoming_message(t){var e;t.command?(this.LOG("Command:",t),this.fireEvent(`command-${t.command}`,t)):t.browserEntities?this.browserEntities=t.browserEntities:t.result&&this.update_config(t.result),null===(e=this._connectionResolve)||void 0===e||e.call(this)}update_config(t){var e;this.LOG("Receive:",t);let i=!1;!this.registered&&(null===(e=t.browsers)||void 0===e?void 0:e[this.browserID])&&(i=!0),this._data=t,this.connected||(this.connected=!0,this.fireEvent("browser-mod-connected")),this.fireEvent("browser-mod-config-update"),i&&this.sendUpdate({})}async connect(){const t=(await async function(){const t=await lt();for(;!t.hass;)await new Promise((t=>window.setTimeout(t,100)));return t.hass}()).connection;this.connection=t,t.subscribeMessage((t=>this.incoming_message(t)),{type:"browser_mod/connect",browserID:this.browserID}),t.addEventListener("disconnected",(()=>{this.connected=!1,this.fireEvent("browser-mod-disconnected")})),t.addEventListener("ready",(()=>{this.connected=!0,this.fireEvent("browser-mod-connected"),this.sendUpdate({})})),ct(this)}get config(){var t,e;return null!==(e=null===(t=this._data)||void 0===t?void 0:t.config)&&void 0!==e?e:{}}get browsers(){var t,e;return null!==(e=null===(t=this._data)||void 0===t?void 0:t.browsers)&&void 0!==e?e:[]}get registered(){var t;return void 0!==(null===(t=this.browsers)||void 0===t?void 0:t[this.browserID])}set registered(t){(async()=>{if(t){if(this.registered)return;await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID})}else{if(!this.registered)return;await this.connection.sendMessage({type:"browser_mod/unregister",browserID:this.browserID})}})()}async _reregister(t={}){await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID,data:Object.assign(Object.assign({},this.browsers[this.browserID]),t)})}get global_settings(){var t,e;const i={},s=null!==(e=null===(t=this._data)||void 0===t?void 0:t.settings)&&void 0!==e?e:{};for(const[t,e]of Object.entries(s))null!==e&&(i[t]=e);return i}get user_settings(){var t,e,i,s,o;const n={},r=null!==(o=null===(e=null===(t=this._data)||void 0===t?void 0:t.user_settings)||void 0===e?void 0:e[null===(s=null===(i=this.hass)||void 0===i?void 0:i.user)||void 0===s?void 0:s.id])&&void 0!==o?o:{};for(const[t,e]of Object.entries(r))null!==e&&(n[t]=e);return n}get browser_settings(){var t,e,i;const s={},o=null!==(i=null===(e=null===(t=this.browsers)||void 0===t?void 0:t[this.browserID])||void 0===e?void 0:e.settings)&&void 0!==i?i:{};for(const[t,e]of Object.entries(o))null!==e&&(s[t]=e);return s}get settings(){return Object.assign(Object.assign(Object.assign({},this.global_settings),this.browser_settings),this.user_settings)}set_setting(t,e,i){var s;switch(i){case"global":this.connection.sendMessage({type:"browser_mod/settings",key:t,value:e});break;case"user":{const i=this.hass.user.id;this.connection.sendMessage({type:"browser_mod/settings",user:i,key:t,value:e});break}case"browser":{const i=null===(s=this.browsers[this.browserID])||void 0===s?void 0:s.settings;i[t]=e,this._reregister({settings:i});break}}}get cameraEnabled(){return this.registered?this.browsers[this.browserID].camera:null}set cameraEnabled(t){this._reregister({camera:t})}sendUpdate(t){this.connected&&this.registered&&(this.LOG("Send:",t),this.connection.sendMessage({type:"browser_mod/update",browserID:this.browserID,data:t}))}browserIDChanged(t,e){var i,s;this.fireEvent("browser-mod-config-update"),void 0!==(null===(i=this.browsers)||void 0===i?void 0:i[t])&&void 0===(null===(s=this.browsers)||void 0===s?void 0:s[this.browserID])&&(async()=>{await this.connection.sendMessage({type:"browser_mod/register",browserID:t,data:Object.assign(Object.assign({},this.browsers[t]),{browserID:this.browserID})})})()}},vt=t=>class extends t{constructor(){super(),this._listeners={},this._brightness=255;const t=this._panel=document.createElement("div");document.body.append(t),t.classList.add("browser-mod-blackout"),t.attachShadow({mode:"open"});const e=document.createElement("style");t.shadowRoot.append(e),e.innerHTML="\n :host {\n background: rgba(0,0,0, var(--darkness));\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n width: 100%;\n height: 100%;\n z-index: 10000;\n display: block;\n pointer-events: none;\n }\n :host([dark]) {\n background: rgba(0,0,0,1);\n }\n ",this.addEventListener("command-screen_off",(()=>this._screen_off())),this.addEventListener("command-screen_on",(t=>this._screen_on(t))),this.addEventListener("fully-update",(()=>this.send_screen_status())),this.connectionPromise.then((()=>this._screen_on()))}send_screen_status(){let t=!this._panel.hasAttribute("dark"),e=this._brightness;this.fully&&(t=this.fully_screen,e=this.fully_brightness),this.sendUpdate({screen_on:t,screen_brightness:e})}_screen_off(){this.fully?this.fully_screen=!1:this._panel.setAttribute("dark",""),this.send_screen_status();const t=()=>this._screen_on();for(const e of["pointerdown","pointermove","keydown"])this._listeners[e]=t,window.addEventListener(e,t)}_screen_on(t){var e,i;this.fully?(this.fully_screen=!0,(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.brightness)&&(this.fully_brightness=t.detail.brightness)):((null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.brightness)&&(this._brightness=t.detail.brightness,this._panel.style.setProperty("--darkness",1-t.detail.brightness/255)),this._panel.removeAttribute("dark")),this.send_screen_status();for(const t of["pointerdown","pointermove","keydown"])this._listeners[t]&&(window.removeEventListener(t,this._listeners[t]),this._listeners[t]=void 0)}},mt=e=>{class i extends e{constructor(){super(),this._audio_player=new Audio,this._video_player=document.createElement("video"),this._video_player.controls=!0,this._video_player.style.setProperty("width","100%"),this.player=this._audio_player,this._player_enabled=!1;for(const t of["play","pause","ended","volumechange"])this._audio_player.addEventListener(t,(()=>this._player_update())),this._video_player.addEventListener(t,(()=>this._player_update()));for(const t of["timeupdate"])this._audio_player.addEventListener(t,(()=>this._player_update_throttled())),this._video_player.addEventListener(t,(()=>this._player_update_throttled()));this.firstInteraction.then((()=>{this._player_enabled=!0,this.player.ended||this.player.play()})),this.addEventListener("command-player-play",(t=>{var e,i,s;this.player.src&&this.player.pause(),(null===(e=t.detail)||void 0===e?void 0:e.media_type)&&((null===(i=t.detail)||void 0===i?void 0:i.media_type.startsWith("video"))?this.player=this._video_player:this.player=this._audio_player),(null===(s=t.detail)||void 0===s?void 0:s.media_content_id)&&(this.player.src=t.detail.media_content_id),this.player.play(),this._show_video_player()})),this.addEventListener("command-player-pause",(t=>this.player.pause())),this.addEventListener("command-player-stop",(t=>{this.player.src=null,this.player.pause()})),this.addEventListener("command-player-set-volume",(t=>{var e;void 0!==(null===(e=t.detail)||void 0===e?void 0:e.volume_level)&&(this.player.volume=t.detail.volume_level)})),this.addEventListener("command-player-mute",(t=>{var e;void 0!==(null===(e=t.detail)||void 0===e?void 0:e.mute)?this.player.muted=Boolean(t.detail.mute):this.player.muted=!this.player.muted})),this.addEventListener("command-player-seek",(t=>{this.player.currentTime=t.detail.position,setTimeout((()=>this._player_update()),10)})),this.addEventListener("command-player-turn-off",(t=>{this.player===this._video_player&&this._video_player.isConnected?this.closePopup():this.player.src&&this.player.pause(),this.player.src="",this._player_update()})),this.connectionPromise.then((()=>this._player_update()))}_show_video_player(){this.player===this._video_player&&this.player.src?(dt(document,"home-assistant $ dialog-media-player-browse").then((t=>null==t?void 0:t.closeDialog())),this.showPopup(void 0,this._video_player,{dismiss_action:()=>this._video_player.pause(),size:"wide"})):this.player!==this._video_player&&this._video_player.isConnected&&this.closePopup()}_player_update_throttled(){this._player_update()}_player_update(){const t=this._player_enabled?this.player.src&&this.player.src!==window.location.href?this.player.ended?"stopped":this.player.paused?"paused":"playing":"off":"unavailable";this.sendUpdate({player:{volume:this.player.volume,muted:this.player.muted,src:this.player.src,state:t,media_duration:this.player.duration,media_position:this.player.currentTime}})}}var s;return t([(s=3e3,function(t,e,i){const o=i.value;let n;i.value=function(...t){if(!n)return n=setTimeout((()=>n=void 0),s),o.bind(this)(...t)}})],i.prototype,"_player_update_throttled",null),i},_t=t=>class extends t{constructor(){super(),this._framerate=2,this._setup_camera()}async _setup_camera(){if(this._video)return;if(await this.connectionPromise,await this.firstInteraction,!this.cameraEnabled)return;if(this.fully)return this.update_camera();const t=document.createElement("div");document.body.append(t),t.classList.add("browser-mod-camera"),t.attachShadow({mode:"open"});const e=document.createElement("style");t.shadowRoot.append(e),e.innerHTML="\n :host {\n display: none;\n }";const i=this._video=document.createElement("video");t.shadowRoot.append(i),i.autoplay=!0,i.playsInline=!0,i.style.display="none";const s=this._canvas=document.createElement("canvas");if(t.shadowRoot.append(s),s.style.display="none",!navigator.mediaDevices)return;const o=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});i.srcObject=o,i.play(),this.update_camera()}async update_camera(){var t;if(!this.cameraEnabled){const e=null===(t=this._video)||void 0===t?void 0:t.srcObject;return void(e&&(e.getTracks().forEach((t=>t.stop())),this._video.scrObject=void 0))}if(this.fully)this.sendUpdate({camera:this.fully_camera});else{const t=this._video,e=t.videoWidth,i=t.videoHeight;this._canvas.width=e,this._canvas.height=i;this._canvas.getContext("2d").drawImage(t,0,0,e,i),this.sendUpdate({camera:this._canvas.toDataURL("image/jpeg")})}const e=Math.round(1e3/this._framerate);setTimeout((()=>this.update_camera()),e)}},gt=t=>class extends t{constructor(){super(),this.firstInteraction=new Promise((t=>{this._interactionResolve=t})),this.show_indicator()}async show_indicator(){if(await this.connectionPromise,!this.registered)return;const t=document.createElement("div");document.body.append(t),t.classList.add("browser-mod-require-interaction"),t.attachShadow({mode:"open"});const e=document.createElement("style");t.shadowRoot.append(e),e.innerHTML='\n :host {\n position: fixed;\n right: 8px;\n bottom: 8px;\n color: var(--warning-color, red);\n opacity: 0.5;\n --mdc-icon-size: 48px;\n }\n ha-icon::before {\n content: "Browser\\00a0Mod";\n font-size: 0.75rem;\n position: absolute;\n right: 0;\n bottom: 90%;\n }\n video {\n display: none;\n }\n ';const i=document.createElement("ha-icon");t.shadowRoot.append(i),i.icon="mdi:gesture-tap";const s=this._video=document.createElement("video");t.shadowRoot.append(s);const o=s.play();o&&(o.then((()=>{this._interactionResolve()})).catch((t=>{"AbortError"===t.name&&this._interactionResolve()})),s.pause()),window.addEventListener("pointerdown",this._interactionResolve),await this.firstInteraction,t.remove()}},wt=t=>class extends t{constructor(){if(super(),this._fully_screensaver=!1,this.fully){for(const t of["screenOn","screenOff","pluggedAC","pluggedUSB","onBatteryLevelChanged","unplugged","networkReconnect","onMotion","onDaydreamStart","onDaydreamStop"])window.fully.bind(t,`window.browser_mod.fullyEvent("${t}");`);window.fully.bind("onScreensaverStart","window.browser_mod._fully_screensaver = true; window.browser_mod.fullyEvent();"),window.fully.bind("onScreensaverStop","window.browser_mod._fully_screensaver = false; window.browser_mod.fullyEvent();")}}get fully(){return void 0!==window.fully}get fully_screen(){var t;return!1===this._fully_screensaver&&(null===(t=window.fully)||void 0===t?void 0:t.getScreenOn())}set fully_screen(t){var e,i,s;t?(null===(e=window.fully)||void 0===e||e.turnScreenOn(),null===(i=window.fully)||void 0===i||i.stopScreensaver()):null===(s=window.fully)||void 0===s||s.turnScreenOff()}get fully_brightness(){var t;return null===(t=window.fully)||void 0===t?void 0:t.getScreenBrightness()}set fully_brightness(t){var e;null===(e=window.fully)||void 0===e||e.setScreenBrightness(t)}get fully_camera(){var t;return null===(t=window.fully)||void 0===t?void 0:t.getCamshotJpgBase64()}fullyEvent(t){this.fireEvent("fully-update",{event:t})}},bt=t=>class extends t{constructor(){super(),document.addEventListener("visibilitychange",(()=>this._browser_state_update())),window.addEventListener("location-changed",(()=>this._browser_state_update())),this.addEventListener("fully-update",(()=>this._browser_state_update())),this.connectionPromise.then((()=>this._browser_state_update()))}_browser_state_update(){(async()=>{var t,e,i,s,o,n,r,a,d,l,c,h;const u=null===(e=(t=navigator).getBattery)||void 0===e?void 0:e.call(t);this.sendUpdate({browser:{path:window.location.pathname,visibility:document.visibilityState,userAgent:navigator.userAgent,currentUser:null===(s=null===(i=this.hass)||void 0===i?void 0:i.user)||void 0===s?void 0:s.name,fullyKiosk:this.fully||!1,width:window.innerWidth,height:window.innerHeight,battery_level:null!==(n=null===(o=window.fully)||void 0===o?void 0:o.getBatteryLevel())&&void 0!==n?n:100*(null==u?void 0:u.level),charging:null!==(a=null===(r=window.fully)||void 0===r?void 0:r.isPlugged())&&void 0!==a?a:null==u?void 0:u.charging,darkMode:null===(l=null===(d=this.hass)||void 0===d?void 0:d.themes)||void 0===l?void 0:l.darkMode,userData:null===(c=this.hass)||void 0===c?void 0:c.user,ip_address:null===(h=window.fully)||void 0===h?void 0:h.getIp4Address()}})})()}async browser_navigate(t){t&&(history.pushState(null,"",t),window.dispatchEvent(new CustomEvent("location-changed")))}},yt=t=>class extends t{constructor(){super();const t=["sequence","delay","popup","more_info","close_popup","navigate","refresh","console","javascript"];for(const e of t)this.addEventListener(`command-${e}`,(t=>{this.service(e,t.detail)}));document.body.addEventListener("ll-custom",(t=>{t.detail.browser_mod&&this._service_action(t.detail.browser_mod)}))}async service(t,e){this._service_action({service:t,data:e})}async _service_action({service:t,data:e}){let i=t;if(!i.startsWith("browser_mod.")&&i.includes(".")||void 0!==e.browser_id){const t=Object.assign({},e);"THIS"===t.browser_id&&(t.browser_id=this.browserID);const[s,o]=i.split(".");return this.hass.callService(s,o,t)}switch(i.startsWith("browser_mod.")&&(i=i.substring(12)),i){case"sequence":for(const t of e.sequence)await this._service_action(t);break;case"delay":await new Promise((t=>setTimeout(t,e.time)));break;case"more_info":const{entity:t,large:i,ignore_popup_card:s}=e;this.showMoreInfo(t,i,s);break;case"popup":const{title:o,content:n}=e,r=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o{const{service:i,data:s}=e;this._service_action({service:i,data:Object.assign(Object.assign({},s),t)})});this.showPopup(o,n,r);break;case"close_popup":this.closePopup();break;case"navigate":this.browser_navigate(e.path);break;case"refresh":window.location.href=window.location.href;break;case"console":Object.keys(e).length>1||e&&void 0===e.message?console.dir(e):console.log(e.message);break;case"javascript":const a=`\n "use strict";\n ${e.code}\n `;new Function("hass","data",a)(this.hass,e)}}},ft=t=>class extends t{constructor(){super(),this.activityTriggered=!1,this._activityCooldown=15e3;for(const t of["pointerdown","pointermove","keydown"])window.addEventListener(t,(()=>this.activityTrigger(!0)));this.addEventListener("fully-update",(()=>{this.activityTrigger()}))}activityTrigger(t=!1){this.activityTriggered||this.sendUpdate({activity:!0}),this.activityTriggered=!0,t&&this.fireEvent("browser-mod-activity"),clearTimeout(this._activityTimeout),this._activityTimeout=setTimeout((()=>this.activityReset()),this._activityCooldown)}activityReset(){clearTimeout(this._activityTimeout),this.activityTriggered&&this.sendUpdate({activity:!1}),this.activityTriggered=!1}},$t=2;class Et extends class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}{constructor(t){if(super(t),this.it=L,t.type!==$t)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===L||null==t)return this._t=void 0,this.it=t;if(t===M)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}Et.directiveName="unsafeHTML",Et.resultType=1;const At=(t=>(...e)=>({_$litDirective$:t,values:e}))(Et);class xt extends Q{async closeDialog(){this.open=!1,clearInterval(this._timeoutTimer),this._autocloseListener&&(window.browser_mod.removeEventListener("browser-mod-activity",this._autocloseListener),this._autocloseListener=void 0)}openDialog(){var t;this.open=!0,null===(t=this.dialog)||void 0===t||t.show(),this.timeout&&(this._timeoutStart=(new Date).getTime(),this._timeoutTimer=setInterval((()=>{const t=(new Date).getTime()-this._timeoutStart,e=t/this.timeout*100;this.style.setProperty("--progress",`${e}%`),t>=this.timeout&&this._timeout()}),10)),this._autocloseListener=void 0,this._autoclose&&(this._autocloseListener=()=>this.dialog.close(),window.browser_mod.addEventListener("browser-mod-activity",this._autocloseListener,{once:!0}))}async setupDialog(t,e,{right_button:i,right_button_action:s,left_button:o,left_button_action:n,dismissable:r=!0,dismiss_action:a,timeout:d,timeout_action:l,size:c,style:h,autoclose:u=!1}={}){if(this._formdata=void 0,this.title=t,this.card=void 0,e&&e instanceof HTMLElement)this.content=e;else if(e&&Array.isArray(e)){ut();const t=document.createElement("ha-form");t.schema=e,t.computeLabel=t=>{var e;return null!==(e=t.label)&&void 0!==e?e:t.name},t.hass=window.browser_mod.hass,this._formdata={};for(const t of e)t.name&&void 0!==t.default&&(this._formdata[t.name]=t.default);t.data=this._formdata,ct(t),t.addEventListener("value-changed",(e=>{this._formdata=Object.assign({},e.detail.value),t.data=this._formdata})),this.content=t}else if(e&&"object"==typeof e){this.card=!0;const t=await window.loadCardHelpers(),i=await t.createCardElement(e);i.hass=window.browser_mod.hass,ct(i),this.content=i}else this.content=At(e);this.right_button=i,this.left_button=o,this.actions=void 0===i?void 0:"",this.dismissable=r,this.timeout=d,this._actions={right_button_action:s,left_button_action:n,dismiss_action:a,timeout_action:l},this.wide="wide"===c?"":void 0,this.fullscreen="fullscreen"===c?"":void 0,this._style=h,this._autoclose=u}async _primary(){var t,e,i,s;(null===(t=this._actions)||void 0===t?void 0:t.dismiss_action)&&(this._actions.dismiss_action=void 0),null===(e=this.dialog)||void 0===e||e.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.right_button_action)||void 0===s||s.call(i,this._formdata)}async _secondary(){var t,e,i,s;(null===(t=this._actions)||void 0===t?void 0:t.dismiss_action)&&(this._actions.dismiss_action=void 0),null===(e=this.dialog)||void 0===e||e.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.left_button_action)||void 0===s||s.call(i,this._formdata)}async _dismiss(t){var e,i,s;null===(e=this.dialog)||void 0===e||e.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.dismiss_action)||void 0===s||s.call(i)}async _timeout(){var t,e,i,s;(null===(t=this._actions)||void 0===t?void 0:t.dismiss_action)&&(this._actions.dismiss_action=void 0),null===(e=this.dialog)||void 0===e||e.close(),null===(s=null===(i=this._actions)||void 0===i?void 0:i.timeout_action)||void 0===s||s.call(i)}render(){return this.open?O` - ${this.timeout?M`
`:""} - ${this.title?M` - - ${this.dismissable?M` - - - - `:""} -
${this.title}
-
- `:M``} + ${this.timeout?O`
`:""} + ${this.title?O` +
+ + ${this.dismissable?O` + + + + `:""} +
${this.title}
+
+
+ `:O``}
${this.content}
- ${void 0!==this.right_button?M` + ${void 0!==this.right_button?O` `:""} - ${void 0!==this.left_button?M` + ${void 0!==this.left_button?O` `:""}
- `:M``}static get styles(){return n` + `:O``}static get styles(){return n` ha-dialog { + --dialog-backdrop-filter: blur(5px); z-index: 10; --mdc-dialog-min-width: var(--popup-min-width, 400px); --mdc-dialog-max-width: var(--popup-max-width, 600px); @@ -106,13 +114,12 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro --mdc-dialog-content-ink-color: var(--primary-text-color); --justify-action-buttons: space-between; - --mdc-dialog-box-shadow: 0px 0px 0px + --dialog-box-shadow: 0px 0px 0px var(--popup-border-width, var(--ha-card-border-width, 2px)) var( --popup-border-color, var(--ha-card-border-color, var(--divider-color, #e0e0e0)) ); - --ha-dialog-border-radius: var(--popup-border-radius, 8px); --mdc-theme-surface: var( --popup-background-color, var(--ha-card-background, var(--card-background-color, white)) @@ -128,6 +135,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro --mdc-dialog-max-height: 100%; --mdc-shape-medium: 0px; --vertial-align-dialog: flex-end; + --ha-dialog-border-radius: 0px; } .progress::before { content: ""; @@ -140,23 +148,20 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro z-index: 10; } - app-toolbar { + ha-header-bar { + --mdc-theme-on-primary: var(--primary-text-color); + --mdc-theme-primary: var(--mdc-theme-surface); flex-shrink: 0; - color: var(--primary-text-color); - background-color: var( - --popup-header-background-color, - var(--popup-background-color, var(--sidebar-background-color)) - ); + display: block; } + ha-icon-button > * { display: flex; } .main-title { - margin-left: 16px; - line-height: 1.3em; - max-height: 2.6em; overflow: hidden; text-overflow: ellipsis; + cursor: default; } .content { --padding-x: 24px; @@ -173,9 +178,11 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro :host([card]) .content { --padding-x: 0px; --padding-y: 0px; + --ha-card-box-shadow: none; } :host([actions]) .content { - border-bottom: 1px solid var(--popup-border-color, var(--divider-color)); + xborder-bottom: 2px solid + var(--popup-border-color, var(--divider-color)); --footer-height: 54px; } :host([wide]) .content { @@ -184,10 +191,14 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro :host([fullscreen]) .content { height: calc( 100vh - var(--header-height) - var(--footer-height) - 2 * - var(--padding-y) + var(--padding-y) - 16px ); } + .action-button { + margin-bottom: -24px; + } + @media all and (max-width: 450px), all and (max-height: 500px) { ha-dialog { --mdc-dialog-min-width: 100vw; @@ -198,7 +209,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro --vertial-align-dialog: flex-end; } } - `}}e([ee()],Ae.prototype,"open",void 0),e([ee()],Ae.prototype,"content",void 0),e([ee()],Ae.prototype,"title",void 0),e([ee({reflect:!0})],Ae.prototype,"actions",void 0),e([ee({reflect:!0})],Ae.prototype,"card",void 0),e([ee()],Ae.prototype,"right_button",void 0),e([ee()],Ae.prototype,"left_button",void 0),e([ee()],Ae.prototype,"dismissable",void 0),e([ee({reflect:!0})],Ae.prototype,"wide",void 0),e([ee({reflect:!0})],Ae.prototype,"fullscreen",void 0),e([ee()],Ae.prototype,"_style",void 0),e([ie("ha-dialog")],Ae.prototype,"dialog",void 0),customElements.get("browser-mod-popup")||customElements.define("browser-mod-popup",Ae);const xe=e=>class extends e{constructor(){super(),he(),this._popupEl=document.createElement("browser-mod-popup"),document.body.append(this._popupEl)}showPopup(...e){this._popupEl.setupDialog(...e).then((()=>this._popupEl.openDialog()))}closePopup(...e){this._popupEl.closeDialog(),this.showMoreInfo("")}async showMoreInfo(e,t=!1,i){const s=await le();if(s.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:e,ignore_popup_card:i}})),t){await new Promise((e=>setTimeout(e,50)));const e=s.shadowRoot.querySelector("ha-more-info-dialog");e&&(e.large=!0)}}};var Se="2.0.0b2";const Ce=[{name:"entity",label:"Entity",selector:{entity:{}}},{name:"title",label:"Title",selector:{text:{}}},{name:"size",selector:{select:{mode:"dropdown",options:["normal","wide","fullscreen"]}}},{type:"grid",schema:[{name:"right_button",label:"Right button",selector:{text:{}}},{name:"left_button",label:"Left button",selector:{text:{}}}]},{type:"grid",schema:[{name:"right_button_action",label:"Right button action",selector:{object:{}}},{name:"left_button_action",label:"Left button action",selector:{object:{}}}]},{type:"grid",schema:[{name:"dismissable",label:"User dismissable",selector:{boolean:{}}},{name:"timeout",label:"Auto close timeout (ms)",selector:{number:{mode:"box"}}}]},{type:"grid",schema:[{name:"dismiss_action",label:"Dismiss action",selector:{object:{}}},{name:"timeout_action",label:"Timeout action",selector:{object:{}}}]},{name:"style",label:"CSS style",selector:{text:{multiline:!0}}}];class Te extends Q{constructor(){super(...arguments),this._selectedTab=0,this._cardGUIMode=!0,this._cardGUIModeAvailable=!0}setConfig(e){this._config=e}connectedCallback(){super.connectedCallback(),(async()=>{if(customElements.get("ha-form"))return;await he();const e=await window.loadCardHelpers();if(!e)return;const t=await e.createCardElement({type:"entity"});t&&await t.getConfigElement()})()}_handleSwitchTab(e){this._selectedTab=parseInt(e.detail.index,10)}_configChanged(e){e.stopPropagation(),this._config&&(this._config=Object.assign({},e.detail.value),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardConfigChanged(e){if(e.stopPropagation(),!this._config)return;const t=Object.assign({},e.detail.config);this._config=Object.assign(Object.assign({},this._config),{card:t}),this._cardGUIModeAvailable=e.detail.guiModeAvailable,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_toggleCardMode(e){var t;null===(t=this._cardEditorEl)||void 0===t||t.toggleMode()}_deleteCard(e){this._config&&(this._config=Object.assign({},this._config),delete this._config.card,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardGUIModeChanged(e){e.stopPropagation(),this._cardGUIMode=e.detail.guiMode,this._cardGUIModeAvailable=e.detail.guiModeAvailable}render(){return this.hass&&this._config?M` + `}}t([tt()],xt.prototype,"open",void 0),t([tt()],xt.prototype,"content",void 0),t([tt()],xt.prototype,"title",void 0),t([tt({reflect:!0})],xt.prototype,"actions",void 0),t([tt({reflect:!0})],xt.prototype,"card",void 0),t([tt()],xt.prototype,"right_button",void 0),t([tt()],xt.prototype,"left_button",void 0),t([tt()],xt.prototype,"dismissable",void 0),t([tt({reflect:!0})],xt.prototype,"wide",void 0),t([tt({reflect:!0})],xt.prototype,"fullscreen",void 0),t([tt()],xt.prototype,"_style",void 0),t([it("ha-dialog")],xt.prototype,"dialog",void 0),customElements.get("browser-mod-popup")||customElements.define("browser-mod-popup",xt);const St=t=>class extends t{constructor(){super(),ht(),this._popupEl=document.createElement("browser-mod-popup"),document.body.append(this._popupEl)}showPopup(...t){this._popupEl.setupDialog(...t).then((()=>this._popupEl.openDialog()))}closePopup(...t){this._popupEl.closeDialog(),this.showMoreInfo("")}async showMoreInfo(t,e=!1,i){const s=await lt();if(s.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:t,ignore_popup_card:i}})),e){await new Promise((t=>setTimeout(t,50)));const t=s.shadowRoot.querySelector("ha-more-info-dialog");t&&(t.large=!0)}}};var Ct="2.0.0b3";const Tt=[{name:"entity",label:"Entity",selector:{entity:{}}},{name:"title",label:"Title",selector:{text:{}}},{name:"size",selector:{select:{mode:"dropdown",options:["normal","wide","fullscreen"]}}},{type:"grid",schema:[{name:"right_button",label:"Right button",selector:{text:{}}},{name:"left_button",label:"Left button",selector:{text:{}}}]},{type:"grid",schema:[{name:"right_button_action",label:"Right button action",selector:{object:{}}},{name:"left_button_action",label:"Left button action",selector:{object:{}}}]},{type:"grid",schema:[{name:"dismissable",label:"User dismissable",selector:{boolean:{}}},{name:"timeout",label:"Auto close timeout (ms)",selector:{number:{mode:"box"}}}]},{type:"grid",schema:[{name:"dismiss_action",label:"Dismiss action",selector:{object:{}}},{name:"timeout_action",label:"Timeout action",selector:{object:{}}}]},{name:"style",label:"CSS style",selector:{text:{multiline:!0}}}];class Pt extends Q{constructor(){super(...arguments),this._selectedTab=0,this._cardGUIMode=!0,this._cardGUIModeAvailable=!0}setConfig(t){this._config=t}connectedCallback(){super.connectedCallback(),ut()}_handleSwitchTab(t){this._selectedTab=parseInt(t.detail.index,10)}_configChanged(t){t.stopPropagation(),this._config&&(this._config=Object.assign({},t.detail.value),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardConfigChanged(t){if(t.stopPropagation(),!this._config)return;const e=Object.assign({},t.detail.config);this._config=Object.assign(Object.assign({},this._config),{card:e}),this._cardGUIModeAvailable=t.detail.guiModeAvailable,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_toggleCardMode(t){var e;null===(e=this._cardEditorEl)||void 0===e||e.toggleMode()}_deleteCard(t){this._config&&(this._config=Object.assign({},this._config),delete this._config.card,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardGUIModeChanged(t){t.stopPropagation(),this._cardGUIMode=t.detail.guiMode,this._cardGUIModeAvailable=t.detail.guiModeAvailable}render(){return this.hass&&this._config?O`
- `:M``}_renderSettingsEditor(){return M`
+ `:O``}_renderSettingsEditor(){return O`
{var t;return null!==(t=e.label)&&void 0!==t?t:e.name}} + .schema=${Tt} + .computeLabel=${t=>{var e;return null!==(e=t.label)&&void 0!==e?e:t.name}} @value-changed=${this._configChanged} > -
`}_renderCardEditor(){return M` +
`}_renderCardEditor(){return O`
- ${this._config.card?M` + ${this._config.card?O`
- `:M` + `:O` {for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card-editor")||(customElements.define("popup-card-editor",Te),window.customCards=window.customCards||[],window.customCards.push({type:"popup-card",name:"Popup card",preview:!1,description:"Replace the more-info dialog for a given entity in the view that includes this card. (Browser Mod)"}))})();class Pe extends Q{constructor(){super(),this.popup=this.popup.bind(this)}static getConfigElement(){return document.createElement("popup-card-editor")}static getStubConfig(e,t){return{entity:t[0],title:"Custom popup",dismissable:!0,card:{type:"markdown",content:"This replaces the more-info dialog"}}}setConfig(e){this._config=e,(async()=>{const t=await window.loadCardHelpers();this._element=await t.createCardElement(e.card),this._element.hass=this.hass})()}async connectedCallback(){super.connectedCallback(),window.addEventListener("hass-more-info",this.popup),"hui-card-preview"===this.parentElement.localName?(this.editMode=!0,this.removeAttribute("hidden")):this.setAttribute("hidden","")}async disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("hass-more-info",this.popup)}popup(e){var t,i,s;if((null===(t=e.detail)||void 0===t?void 0:t.entityId)===this._config.entity&&!(null===(i=e.detail)||void 0===i?void 0:i.ignore_popup_card)){e.stopPropagation(),e.preventDefault();delete Object.assign({},this._config).card,null===(s=window.browser_mod)||void 0===s||s.service("popup",Object.assign({content:this._config.card},this._config)),setTimeout((()=>this.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:"."}}))),50)}}updated(e){super.updated(e),e.has("hass")&&this._element&&(this._element.hass=this.hass)}render(){return this.editMode?M` + `}}t([et()],Pt.prototype,"_config",void 0),t([tt()],Pt.prototype,"lovelace",void 0),t([tt()],Pt.prototype,"hass",void 0),t([et()],Pt.prototype,"_selectedTab",void 0),t([et()],Pt.prototype,"_cardGUIMode",void 0),t([et()],Pt.prototype,"_cardGUIModeAvailable",void 0),t([it("hui-card-element-editor")],Pt.prototype,"_cardEditorEl",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card-editor")||(customElements.define("popup-card-editor",Pt),window.customCards=window.customCards||[],window.customCards.push({type:"popup-card",name:"Popup card",preview:!1,description:"Replace the more-info dialog for a given entity in the view that includes this card. (Browser Mod)"}))})();class kt extends Q{constructor(){super(),this.popup=this.popup.bind(this)}static getConfigElement(){return document.createElement("popup-card-editor")}static getStubConfig(t,e){return{entity:e[0],title:"Custom popup",dismissable:!0,card:{type:"markdown",content:"This replaces the more-info dialog"}}}setConfig(t){this._config=t,(async()=>{const e=await window.loadCardHelpers();this._element=await e.createCardElement(t.card),this._element.hass=this.hass})()}async connectedCallback(){super.connectedCallback(),window.addEventListener("hass-more-info",this.popup),"hui-card-preview"===this.parentElement.localName?(this.editMode=!0,this.removeAttribute("hidden")):this.setAttribute("hidden","")}async disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("hass-more-info",this.popup)}popup(t){var e,i,s;if((null===(e=t.detail)||void 0===e?void 0:e.entityId)===this._config.entity&&!(null===(i=t.detail)||void 0===i?void 0:i.ignore_popup_card)){t.stopPropagation(),t.preventDefault();delete Object.assign({},this._config).card,null===(s=window.browser_mod)||void 0===s||s.service("popup",Object.assign({content:this._config.card},this._config)),setTimeout((()=>this.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:"."}}))),50)}}updated(t){super.updated(t),t.has("hass")&&this._element&&(this._element.hass=this.hass)}render(){return this.editMode?O`
- ${this._config.dismissable?M` + ${this._config.dismissable?O` @@ -287,17 +298,17 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro ${this._config.style} } - ${void 0!==this._config.right_button||void 0!==this._config.left_button?M` + ${void 0!==this._config.right_button||void 0!==this._config.left_button?O`
- ${void 0!==this._config.left_button?M` + ${void 0!==this._config.left_button?O` `:""} - ${void 0!==this._config.right_button?M` + ${void 0!==this._config.right_button?O` @@ -305,7 +316,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
`:""} - `:M``}static get styles(){return n` + `:O``}static get styles(){return n` :host { display: none !important; } @@ -352,4 +363,4 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro padding: 8px; border-top: 1px solid transparent; } - `}}e([ee()],Pe.prototype,"hass",void 0),e([te()],Pe.prototype,"_config",void 0),e([ee({attribute:"edit-mode",reflect:!0})],Pe.prototype,"editMode",void 0),e([te()],Pe.prototype,"_element",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card")||customElements.define("popup-card",Pe)})();const ke=e=>class extends e{constructor(){super(),this.__currentTitle=void 0,this._auto_settings_setup(),this.addEventListener("browser-mod-config-update",(()=>this._auto_settings_setup())),window.addEventListener("location-changed",(()=>{this._updateTitle(),setTimeout((()=>this._updateTitle()),500),setTimeout((()=>this._updateTitle()),1e3),setTimeout((()=>this._updateTitle()),5e3)}))}async _auto_settings_setup(){await this.connectionPromise;const e=this.settings;e.sidebarPanelOrder&&localStorage.setItem("sidebarPanelOrder",e.sidebarPanelOrder),e.sidebarHiddenPanels&&localStorage.setItem("sidebarHiddenPanels",e.sidebarHiddenPanels),e.defaultPanel&&localStorage.setItem("defaultPanel",e.defaultPanel),!0===e.hideSidebar&&(de(document.body,"home-assistant$home-assistant-main$app-drawer-layout").then((e=>{var t;return null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.setProperty("--app-drawer-width","0px")})),de(document.body,"home-assistant$home-assistant-main$app-drawer-layout app-drawer").then((e=>{var t;return null===(t=null==e?void 0:e.remove)||void 0===t?void 0:t.call(e)}))),!0===e.hideHeader&&customElements.whenDefined("app-header-layout").then((()=>{const e=customElements.get("app-header").prototype,t=e.attached;e.attached=function(){t.bind(this)(),this.style.setProperty("display","none")}})),void 0!==e.faviconTemplate&&(async()=>{this._faviconTemplateSubscription&&this._faviconTemplateSubscription(),this._faviconTemplateSubscription=void 0,this._faviconTemplateSubscription=await this.connection.subscribeMessage(this._updateFavicon,{type:"render_template",template:e.faviconTemplate,variables:{}})})(),void 0!==e.titleTemplate&&(async()=>{this._titleTemplateSubscription&&this._titleTemplateSubscription(),this._titleTemplateSubscription=void 0,this._titleTemplateSubscription=await this.connection.subscribeMessage(this._updateTitle.bind(this),{type:"render_template",template:e.titleTemplate,variables:{}})})()}get _currentFavicon(){const e=document.head.querySelector("link[rel~='icon']");return null==e?void 0:e.href}_updateFavicon({result:e}){document.head.querySelector("link[rel~='icon']").href=e,window.browser_mod.fireEvent("browser-mod-favicon-update")}get _currentTitle(){return this.__currentTitle}_updateTitle(e){e&&(this.__currentTitle=e.result),this.__currentTitle&&(document.title=this.__currentTitle),window.browser_mod.fireEvent("browser-mod-favicon-update")}},Ie="browser_mod-browser-id",Me=e=>class extends e{constructor(){if(super(),Storage&&!Storage.prototype.browser_mod_patched){const e=Storage.prototype.clear;Storage.prototype.clear=function(){const t=this.getItem(Ie),i=this.getItem("suspendWhenHidden");e.apply(this),this.setItem(Ie,t),this.setItem("suspendWhenHidden",i)},Storage.prototype.browser_mod_patched=!0}}async recall_id(){if(!this.connection)return;const e=await this.connection.sendMessagePromise({type:"browser_mod/recall_id"});e&&(localStorage[Ie]=e)}get browserID(){return document.querySelector("hc-main")?"CAST":localStorage[Ie]?localStorage[Ie]:(this.browserID="",this.recall_id(),this.browserID)}set browserID(e){""===e&&(e=function(){var e,t;const i=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);return null!==(t=null===(e=window.fully)||void 0===e?void 0:e.getDeviceId())&&void 0!==t?t:`${i()}${i()}-${i()}${i()}`}());const t=localStorage[Ie];localStorage[Ie]=e,this.browserIDChanged(t,e)}browserIDChanged(e,t){}};class Oe extends(be(xe(ye(we(me(ve(pe(ke(ge(_e(ue(Me(EventTarget))))))))))))){constructor(){super(),this.connect(),console.info(`%cBROWSER_MOD ${Se} IS INSTALLED\n %cBrowserID: ${this.browserID}`,"color: green; font-weight: bold","")}}window.browser_mod||(window.browser_mod=new Oe);export{Oe as BrowserMod}; + `}}t([tt()],kt.prototype,"hass",void 0),t([et()],kt.prototype,"_config",void 0),t([tt({attribute:"edit-mode",reflect:!0})],kt.prototype,"editMode",void 0),t([et()],kt.prototype,"_element",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card")||customElements.define("popup-card",kt)})();const It=t=>class extends t{constructor(){super(),this.__currentTitle=void 0,this._auto_settings_setup(),this.addEventListener("browser-mod-config-update",(()=>this._auto_settings_setup())),window.addEventListener("location-changed",(()=>{this._updateTitle(),setTimeout((()=>this._updateTitle()),500),setTimeout((()=>this._updateTitle()),1e3),setTimeout((()=>this._updateTitle()),5e3)}))}async _auto_settings_setup(){await this.connectionPromise;const t=this.settings;t.sidebarPanelOrder&&localStorage.setItem("sidebarPanelOrder",t.sidebarPanelOrder),t.sidebarHiddenPanels&&localStorage.setItem("sidebarHiddenPanels",t.sidebarHiddenPanels),t.defaultPanel&&localStorage.setItem("defaultPanel",t.defaultPanel),!0===t.hideSidebar&&(dt(document.body,"home-assistant$home-assistant-main$app-drawer-layout").then((t=>{var e;return null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.setProperty("--app-drawer-width","0px")})),dt(document.body,"home-assistant$home-assistant-main$app-drawer-layout app-drawer").then((t=>{var e;return null===(e=null==t?void 0:t.remove)||void 0===e?void 0:e.call(t)}))),!0===t.hideHeader&&customElements.whenDefined("app-header-layout").then((()=>{const t=customElements.get("app-header").prototype,e=t.attached;t.attached=function(){e.bind(this)(),this.style.setProperty("display","none")}})),void 0!==t.faviconTemplate&&(async()=>{this._faviconTemplateSubscription&&this._faviconTemplateSubscription(),this._faviconTemplateSubscription=void 0,this._faviconTemplateSubscription=await this.connection.subscribeMessage(this._updateFavicon,{type:"render_template",template:t.faviconTemplate,variables:{}})})(),void 0!==t.titleTemplate&&(async()=>{this._titleTemplateSubscription&&this._titleTemplateSubscription(),this._titleTemplateSubscription=void 0,this._titleTemplateSubscription=await this.connection.subscribeMessage(this._updateTitle.bind(this),{type:"render_template",template:t.titleTemplate,variables:{}})})()}get _currentFavicon(){const t=document.head.querySelector("link[rel~='icon']");return null==t?void 0:t.href}_updateFavicon({result:t}){document.head.querySelector("link[rel~='icon']").href=t,window.browser_mod.fireEvent("browser-mod-favicon-update")}get _currentTitle(){return this.__currentTitle}_updateTitle(t){t&&(this.__currentTitle=t.result),this.__currentTitle&&(document.title=this.__currentTitle),window.browser_mod.fireEvent("browser-mod-favicon-update")}},Ot="browser_mod-browser-id",Mt=t=>class extends t{constructor(){if(super(),Storage&&!Storage.prototype.browser_mod_patched){const t=Storage.prototype.clear;Storage.prototype.clear=function(){const e=this.getItem(Ot),i=this.getItem("suspendWhenHidden");t.apply(this),this.setItem(Ot,e),this.setItem("suspendWhenHidden",i)},Storage.prototype.browser_mod_patched=!0}}async recall_id(){if(!this.connection)return;const t=await this.connection.sendMessagePromise({type:"browser_mod/recall_id"});t&&(localStorage[Ot]=t)}get browserID(){return document.querySelector("hc-main")?"CAST":localStorage[Ot]?localStorage[Ot]:(this.browserID="",this.recall_id(),this.browserID)}set browserID(t){""===t&&(t=function(){var t,e;const i=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);return null!==(e=null===(t=window.fully)||void 0===t?void 0:t.getDeviceId())&&void 0!==e?e:`${i()}${i()}-${i()}${i()}`}());const e=localStorage[Ot];localStorage[Ot]=t,this.browserIDChanged(e,t)}browserIDChanged(t,e){}};class Lt extends(yt(St(ft(bt(_t(mt(vt(It(wt(gt(pt(Mt(EventTarget))))))))))))){constructor(){super(),this.connect(),console.info(`%cBROWSER_MOD ${Ct} IS INSTALLED\n %cBrowserID: ${this.browserID}`,"color: green; font-weight: bold","")}}window.browser_mod||(window.browser_mod=new Lt);export{Lt as BrowserMod}; diff --git a/custom_components/browser_mod/browser_mod_panel.js b/custom_components/browser_mod/browser_mod_panel.js index 5a51ffb..ba45cd6 100644 --- a/custom_components/browser_mod/browser_mod_panel.js +++ b/custom_components/browser_mod/browser_mod_panel.js @@ -1,4 +1,4 @@ -function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(n=(r<3?o(n):r>3?o(t,s,n):o(t,s))||n);return r>3&&n&&Object.defineProperty(t,s,n),n}const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new WeakMap;class o{constructor(e,t,i){if(this._$cssResult$=!0,i!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const s=this.t;if(t&&void 0===e){const t=void 0!==s&&1===s.length;t&&(e=i.get(s)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&i.set(s,e))}return e}toString(){return this.cssText}}const r=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,s,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[i+1]),e[0]);return new o(i,e,s)},n=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,s))(t)})(e):e;var a;const l=window.trustedTypes,d=l?l.emptyScript:"",h=window.reactiveElementPolyfillSupport,c={toAttribute(e,t){switch(t){case Boolean:e=e?d:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=null!==e;break;case Number:s=null===e?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch(e){s=null}}return s}},u=(e,t)=>t!==e&&(t==t||e==e),p={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:u};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;null!==(t=this.h)&&void 0!==t||(this.h=[]),this.h.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,s)=>{const i=this._$Ep(s,t);void 0!==i&&(this._$Ev.set(i,s),e.push(i))})),e}static createProperty(e,t=p){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const s="symbol"==typeof e?Symbol():"__"+e,i=this.getPropertyDescriptor(e,s,t);void 0!==i&&Object.defineProperty(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){return{get(){return this[t]},set(i){const o=this[e];this[t]=i,this.requestUpdate(e,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of t)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const e of s)t.unshift(n(e))}else void 0!==e&&t.push(n(e));return t}static _$Ep(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,s;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(s=e.hostConnected)||void 0===s||s.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const s=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,s)=>{t?e.adoptedStyleSheets=s.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):s.forEach((t=>{const s=document.createElement("style"),i=window.litNonce;void 0!==i&&s.setAttribute("nonce",i),s.textContent=t.cssText,e.appendChild(s)}))})(s,this.constructor.elementStyles),s}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$EO(e,t,s=p){var i,o;const r=this.constructor._$Ep(e,s);if(void 0!==r&&!0===s.reflect){const n=(null!==(o=null===(i=s.converter)||void 0===i?void 0:i.toAttribute)&&void 0!==o?o:c.toAttribute)(t,s.type);this._$El=e,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$El=null}}_$AK(e,t){var s,i;const o=this.constructor,r=o._$Ev.get(e);if(void 0!==r&&this._$El!==r){const e=o.getPropertyOptions(r),n=e.converter,a=null!==(i=null!==(s=null==n?void 0:n.fromAttribute)&&void 0!==s?s:"function"==typeof n?n:null)&&void 0!==i?i:c.fromAttribute;this._$El=r,this[r]=a(t,e.type),this._$El=null}}requestUpdate(e,t,s){let i=!0;void 0!==e&&(((s=s||this.constructor.getPropertyOptions(e)).hasChanged||u)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===s.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,s))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(s)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(s)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}var v;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:w}),(null!==(a=globalThis.reactiveElementVersions)&&void 0!==a?a:globalThis.reactiveElementVersions=[]).push("1.3.4");const g=globalThis.trustedTypes,b=g?g.createPolicy("lit-html",{createHTML:e=>e}):void 0,m=`lit$${(Math.random()+"").slice(9)}$`,_="?"+m,f=`<${_}>`,$=document,y=(e="")=>$.createComment(e),A=e=>null===e||"object"!=typeof e&&"function"!=typeof e,S=Array.isArray,E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,C=/-->/g,x=/>/g,P=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),T=/'/g,k=/"/g,U=/^(?:script|style|textarea|title)$/i,H=(e=>(t,...s)=>({_$litType$:e,strings:t,values:s}))(1),O=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),D=new WeakMap,R=$.createTreeWalker($,129,null,!1),I=(e,t)=>{const s=e.length-1,i=[];let o,r=2===t?"":"",n=E;for(let t=0;t"===l[0]?(n=null!=o?o:E,d=-1):void 0===l[1]?d=-2:(d=n.lastIndex-l[2].length,a=l[1],n=void 0===l[3]?P:'"'===l[3]?k:T):n===k||n===T?n=P:n===C||n===x?n=E:(n=P,o=void 0);const c=n===P&&e[t+1].startsWith("/>")?" ":"";r+=n===E?s+f:d>=0?(i.push(a),s.slice(0,d)+"$lit$"+s.slice(d)+m+c):s+m+(-2===d?(i.push(void 0),t):c)}const a=r+(e[s]||"")+(2===t?"":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==b?b.createHTML(a):a,i]};class M{constructor({strings:e,_$litType$:t},s){let i;this.parts=[];let o=0,r=0;const n=e.length-1,a=this.parts,[l,d]=I(e,t);if(this.el=M.createElement(l,s),R.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(i=R.nextNode())&&a.length0){i.textContent=g?g.emptyScript:"";for(let s=0;sS(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.S(e):this.T(e)}j(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}k(e){this._$AH!==e&&(this._$AR(),this._$AH=this.j(e))}T(e){this._$AH!==B&&A(this._$AH)?this._$AA.nextSibling.data=e:this.k($.createTextNode(e)),this._$AH=e}$(e){var t;const{values:s,_$litType$:i}=e,o="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=M.createElement(i.h,this.options)),i);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===o)this._$AH.m(s);else{const e=new L(o,this),t=e.p(this.options);e.m(s),this.k(t),this._$AH=e}}_$AC(e){let t=D.get(e.strings);return void 0===t&&D.set(e.strings,t=new M(e)),t}S(e){S(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,i=0;for(const o of e)i===t.length?t.push(s=new j(this.j(y()),this.j(y()),this,this.options)):s=t[i],s._$AI(o),i++;i2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=B}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,s,i){const o=this.strings;let r=!1;if(void 0===o)e=N(this,e,t,0),r=!A(e)||e!==this._$AH&&e!==O,r&&(this._$AH=e);else{const i=e;let n,a;for(e=o[0],n=0;n{var i,o;const r=null!==(i=null==s?void 0:s.renderBefore)&&void 0!==i?i:t;let n=r._$litPart$;if(void 0===n){const e=null!==(o=null==s?void 0:s.renderBefore)&&void 0!==o?o:null;r._$litPart$=n=new j(t.insertBefore(y(),e),e,void 0,null!=s?s:{})}return n._$AI(e),n})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return O}}Z.finalized=!0,Z._$litElement$=!0,null===(J=globalThis.litElementHydrateSupport)||void 0===J||J.call(globalThis,{LitElement:Z});const Q=globalThis.litElementPolyfillSupport;null==Q||Q({LitElement:Z}),(null!==(Y=globalThis.litElementVersions)&&void 0!==Y?Y:globalThis.litElementVersions=[]).push("3.2.2");const X=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(s){s.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(s){s.createProperty(t.key,e)}};function ee(e){return(t,s)=>void 0!==s?((e,t,s)=>{t.constructor.createProperty(s,e)})(e,t,s):X(e,t)}var te;null===(te=window.HTMLSlotElement)||void 0===te||te.prototype.assignedElements;class se extends Z{constructor(){super(...arguments),this.dirty=!1}toggleRegister(){var e;(null===(e=window.browser_mod)||void 0===e?void 0:e.connected)&&(window.browser_mod.registered=!window.browser_mod.registered,this.dirty=!0)}changeBrowserID(e){window.browser_mod.browserID=e.target.value,this.dirty=!0}toggleCameraEnabled(){window.browser_mod.cameraEnabled=!window.browser_mod.cameraEnabled,this.dirty=!0}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e,t,s,i,o;return H` +function e(e,t,i,s){var o,r=arguments.length,n=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(n=(r<3?o(n):r>3?o(t,i,n):o(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n}const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class o{constructor(e,t,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const i=this.t;if(t&&void 0===e){const t=void 0!==i&&1===i.length;t&&(e=s.get(i)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&s.set(i,e))}return e}toString(){return this.cssText}}const r=(e,...t)=>{const s=1===e.length?e[0]:t.reduce(((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1]),e[0]);return new o(s,e,i)},n=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,i))(t)})(e):e;var a;const l=window.trustedTypes,d=l?l.emptyScript:"",h=window.reactiveElementPolyfillSupport,c={toAttribute(e,t){switch(t){case Boolean:e=e?d:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},u=(e,t)=>t!==e&&(t==t||e==e),p={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:u};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;null!==(t=this.h)&&void 0!==t||(this.h=[]),this.h.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const s=this._$Ep(i,t);void 0!==s&&(this._$Ev.set(s,i),e.push(s))})),e}static createProperty(e,t=p){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(n(e))}else void 0!==e&&t.push(n(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const i=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,i)=>{t?e.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):i.forEach((t=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=t.cssText,e.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=p){var s,o;const r=this.constructor._$Ep(e,i);if(void 0!==r&&!0===i.reflect){const n=(null!==(o=null===(s=i.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==o?o:c.toAttribute)(t,i.type);this._$El=e,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$El=null}}_$AK(e,t){var i,s;const o=this.constructor,r=o._$Ev.get(e);if(void 0!==r&&this._$El!==r){const e=o.getPropertyOptions(r),n=e.converter,a=null!==(s=null!==(i=null==n?void 0:n.fromAttribute)&&void 0!==i?i:"function"==typeof n?n:null)&&void 0!==s?s:c.fromAttribute;this._$El=r,this[r]=a(t,e.type),this._$El=null}}requestUpdate(e,t,i){let s=!0;void 0!==e&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||u)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(i)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}var v;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:w}),(null!==(a=globalThis.reactiveElementVersions)&&void 0!==a?a:globalThis.reactiveElementVersions=[]).push("1.3.4");const g=globalThis.trustedTypes,b=g?g.createPolicy("lit-html",{createHTML:e=>e}):void 0,m=`lit$${(Math.random()+"").slice(9)}$`,_="?"+m,$=`<${_}>`,f=document,y=(e="")=>f.createComment(e),A=e=>null===e||"object"!=typeof e&&"function"!=typeof e,S=Array.isArray,E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,C=/-->/g,x=/>/g,P=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),T=/'/g,k=/"/g,U=/^(?:script|style|textarea|title)$/i,H=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),O=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),R=new WeakMap,D=f.createTreeWalker(f,129,null,!1),I=(e,t)=>{const i=e.length-1,s=[];let o,r=2===t?"":"",n=E;for(let t=0;t"===l[0]?(n=null!=o?o:E,d=-1):void 0===l[1]?d=-2:(d=n.lastIndex-l[2].length,a=l[1],n=void 0===l[3]?P:'"'===l[3]?k:T):n===k||n===T?n=P:n===C||n===x?n=E:(n=P,o=void 0);const c=n===P&&e[t+1].startsWith("/>")?" ":"";r+=n===E?i+$:d>=0?(s.push(a),i.slice(0,d)+"$lit$"+i.slice(d)+m+c):i+m+(-2===d?(s.push(void 0),t):c)}const a=r+(e[i]||"")+(2===t?"":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==b?b.createHTML(a):a,s]};class M{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,r=0;const n=e.length-1,a=this.parts,[l,d]=I(e,t);if(this.el=M.createElement(l,i),D.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=D.nextNode())&&a.length0){s.textContent=g?g.emptyScript:"";for(let i=0;iS(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.S(e):this.T(e)}j(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}k(e){this._$AH!==e&&(this._$AR(),this._$AH=this.j(e))}T(e){this._$AH!==B&&A(this._$AH)?this._$AA.nextSibling.data=e:this.k(f.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,o="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=M.createElement(s.h,this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===o)this._$AH.m(i);else{const e=new L(o,this),t=e.p(this.options);e.m(i),this.k(t),this._$AH=e}}_$AC(e){let t=R.get(e.strings);return void 0===t&&R.set(e.strings,t=new M(e)),t}S(e){S(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const o of e)s===t.length?t.push(i=new j(this.j(y()),this.j(y()),this,this.options)):i=t[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=B}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,s){const o=this.strings;let r=!1;if(void 0===o)e=N(this,e,t,0),r=!A(e)||e!==this._$AH&&e!==O,r&&(this._$AH=e);else{const s=e;let n,a;for(e=o[0],n=0;n{var s,o;const r=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:t;let n=r._$litPart$;if(void 0===n){const e=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;r._$litPart$=n=new j(t.insertBefore(y(),e),e,void 0,null!=i?i:{})}return n._$AI(e),n})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return O}}Z.finalized=!0,Z._$litElement$=!0,null===(J=globalThis.litElementHydrateSupport)||void 0===J||J.call(globalThis,{LitElement:Z});const Q=globalThis.litElementPolyfillSupport;null==Q||Q({LitElement:Z}),(null!==(Y=globalThis.litElementVersions)&&void 0!==Y?Y:globalThis.litElementVersions=[]).push("3.2.2");const X=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(i){i.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}};function ee(e){return(t,i)=>void 0!==i?((e,t,i)=>{t.constructor.createProperty(i,e)})(e,t,i):X(e,t)}var te;null===(te=window.HTMLSlotElement)||void 0===te||te.prototype.assignedElements;class ie extends Z{constructor(){super(...arguments),this.dirty=!1}toggleRegister(){var e;(null===(e=window.browser_mod)||void 0===e?void 0:e.connected)&&(window.browser_mod.registered=!window.browser_mod.registered,this.dirty=!0)}changeBrowserID(e){window.browser_mod.browserID=e.target.value,this.dirty=!0}toggleCameraEnabled(){window.browser_mod.cameraEnabled=!window.browser_mod.cameraEnabled,this.dirty=!0}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e,t,i,s,o;return H`

This Browser
@@ -42,12 +42,12 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro >A unique identifier for this browser-device combination. - ${(null===(i=window.browser_mod)||void 0===i?void 0:i.registered)?H` + ${(null===(s=window.browser_mod)||void 0===s?void 0:s.registered)?H` ${this._renderSuspensionAlert()} Enable camera @@ -115,9 +115,9 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro `),"true"!==window.fully.getBooleanSetting("preventSleepWhileScreenOff")&&e.push(H`
  • Power Settings
    • Prevent from Sleep while Screen Off
    • -
    `);const s=[];return"true"!==window.fully.getBooleanSetting("motionDetection")&&s.push(H`
  • Enable Visual Motion Detection
  • `),"true"!==window.fully.getBooleanSetting("screenOnOnMotion")&&s.push(H`
  • Turn Screen On on Motion
  • `),"true"!==window.fully.getBooleanSetting("stopScreensaverOnMotion")&&s.push(H`
  • Exit Screensaver on Motion
  • `),0!==s.length&&e.push(H`
  • Motion Detection (PLUS)
  • + `);const i=[];return"true"!==window.fully.getBooleanSetting("motionDetection")&&i.push(H`
  • Enable Visual Motion Detection
  • `),"true"!==window.fully.getBooleanSetting("screenOnOnMotion")&&i.push(H`
  • Turn Screen On on Motion
  • `),"true"!==window.fully.getBooleanSetting("stopScreensaverOnMotion")&&i.push(H`
  • Exit Screensaver on Motion
  • `),0!==i.length&&e.push(H`
  • Motion Detection (PLUS)
    • - ${s} + ${i}
    `),"true"!==window.fully.getBooleanSetting("remoteAdmin")&&e.push(H`
  • Remote Administration (PLUS)
    • Enable Remote Administration
    • @@ -131,7 +131,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro display: block; margin-top: 8px; } - `}}e([ee()],se.prototype,"hass",void 0),e([ee()],se.prototype,"dirty",void 0),customElements.define("browser-mod-browser-settings-card",se);class ie extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}unregister_browser(e){const t=e.currentTarget.browserID;window.browser_mod.showPopup("Unregister browser",`Are you sure you want to unregister Browser ${t}?`,{right_button:"Yes",right_button_action:()=>{console.log(t,window.browser_mod.browserID),t===window.browser_mod.browserID?(console.log("Unregister self"),window.browser_mod.registered=!1):window.browser_mod.connection.sendMessage({type:"browser_mod/unregister",browserID:t})},left_button:"No"})}register_cast(){window.browser_mod.connection.sendMessage({type:"browser_mod/register",browserID:"CAST"})}render(){return H` + `}}e([ee()],ie.prototype,"hass",void 0),e([ee()],ie.prototype,"dirty",void 0),customElements.define("browser-mod-browser-settings-card",ie);class se extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}unregister_browser(e){const t=e.currentTarget.browserID;window.browser_mod.showPopup("Unregister browser",`Are you sure you want to unregister Browser ${t}?`,{right_button:"Yes",right_button_action:()=>{t===window.browser_mod.browserID?window.browser_mod.registered=!1:window.browser_mod.connection.sendMessage({type:"browser_mod/unregister",browserID:t})},left_button:"No"})}register_cast(){window.browser_mod.connection.sendMessage({type:"browser_mod/register",browserID:"CAST"})}render(){return H`
      ${Object.keys(window.browser_mod.browsers).map((e=>H` @@ -160,7 +160,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro ha-icon-button > * { display: flex; } - `}}e([ee()],ie.prototype,"hass",void 0),customElements.define("browser-mod-registered-browsers-card",ie),(async()=>{var e,t,s,i,o,r,n;await customElements.whenDefined("partial-panel-resolver"),await customElements.whenDefined("partial-panel-resolver");const a=document.createElement("partial-panel-resolver").getRoutes([{component_name:"developer-tools",url_path:"a"}]);await(null===(s=null===(t=null===(e=null==a?void 0:a.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===s?void 0:s.call(t));const l=document.createElement("developer-tools-router");await(null===(n=null===(r=null===(o=null===(i=null==l?void 0:l.routerOptions)||void 0===i?void 0:i.routes)||void 0===o?void 0:o.template)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await customElements.whenDefined("developer-tools-template")})();class oe extends Z{constructor(){super(...arguments),this._selectedTab=0}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate())),window.browser_mod.addEventListener("browser-mod-favicon-update",(()=>this.requestUpdate()))}_handleSwitchTab(e){this._selectedTab=parseInt(e.detail.index,10)}render(){const e=["user","browser","global"][this._selectedTab];return H` + `}}e([ee()],se.prototype,"hass",void 0),customElements.define("browser-mod-registered-browsers-card",se),(async()=>{var e,t,i,s,o,r,n;await customElements.whenDefined("partial-panel-resolver"),await customElements.whenDefined("partial-panel-resolver");const a=document.createElement("partial-panel-resolver").getRoutes([{component_name:"developer-tools",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==a?void 0:a.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t));const l=document.createElement("developer-tools-router");await(null===(n=null===(r=null===(o=null===(s=null==l?void 0:l.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.template)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await customElements.whenDefined("developer-tools-template")})();class oe extends Z{constructor(){super(...arguments),this._selectedTab=0}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate())),window.browser_mod.addEventListener("browser-mod-favicon-update",(()=>this.requestUpdate()))}_handleSwitchTab(e){this._selectedTab=parseInt(e.detail.index,10)}render(){const e=["user","browser","global"][this._selectedTab];return H`
      @@ -195,7 +195,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro ${this._render_settings(e)}
      - `}_render_settings(e){const t=window.browser_mod.global_settings,s=window.browser_mod.browser_settings,i=window.browser_mod.user_settings,o={global:t,browser:s,user:i}[e],r=e=>({true:"Enabled",false:"Disabled",undefined:"Unset"}[String(e)]),n=e=>void 0===e?"Unset":"Set",a=t=>"browser"!==e&&void 0!==s[t]?H`
      Overridden by browser setting`:"global"===e&&void 0!==i[t]?H`
      Overridden by user setting`:void 0;return H` + `}_render_settings(e){const t=window.browser_mod.global_settings,i=window.browser_mod.browser_settings,s=window.browser_mod.user_settings,o={global:t,browser:i,user:s}[e],r=e=>({true:"Enabled",false:"Disabled",undefined:"Unset"}[String(e)]),n=e=>void 0===e?"Unset":"Set",a=t=>"browser"!==e&&void 0!==i[t]?H`
      Overridden by browser setting`:"global"===e&&void 0!==s[t]?H`
      Overridden by user setting`:void 0;return H`
      Favicon template @@ -205,7 +205,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro {const s=t.detail.value||void 0;window.browser_mod.set_setting("faviconTemplate",s,e)}} + @value-changed=${t=>{const i=t.detail.value||void 0;window.browser_mod.set_setting("faviconTemplate",i,e)}} > {const s=t.detail.value||void 0;window.browser_mod.set_setting("titleTemplate",s,e)}} + @value-changed=${t=>{const i=t.detail.value||void 0;window.browser_mod.set_setting("titleTemplate",i,e)}} > {var e,t,s,i,o,r,n,a,l,d,h;await customElements.whenDefined("partial-panel-resolver");const c=document.createElement("partial-panel-resolver").getRoutes([{component_name:"config",url_path:"a"}]);await(null===(s=null===(t=null===(e=null==c?void 0:c.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===s?void 0:s.call(t)),await customElements.whenDefined("ha-panel-config");const u=document.createElement("ha-panel-config");await(null===(n=null===(r=null===(o=null===(i=null==u?void 0:u.routerOptions)||void 0===i?void 0:i.routes)||void 0===o?void 0:o.dashboard)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await(null===(h=null===(d=null===(l=null===(a=null==u?void 0:u.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.cloud)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){return H` + `}}e([ee()],oe.prototype,"hass",void 0),e([function(e){return ee({...e,state:!0})}()],oe.prototype,"_selectedTab",void 0),customElements.define("browser-mod-frontend-settings-card",oe),(async()=>{var e,t,i,s,o,r,n,a,l,d,h;await customElements.whenDefined("partial-panel-resolver");const c=document.createElement("partial-panel-resolver").getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==c?void 0:c.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const u=document.createElement("ha-panel-config");await(null===(n=null===(r=null===(o=null===(s=null==u?void 0:u.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.dashboard)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await(null===(h=null===(d=null===(l=null===(a=null==u?void 0:u.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.cloud)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){return H` diff --git a/custom_components/browser_mod/manifest.json b/custom_components/browser_mod/manifest.json index 85c7046..e3ffb55 100644 --- a/custom_components/browser_mod/manifest.json +++ b/custom_components/browser_mod/manifest.json @@ -5,7 +5,7 @@ "dependencies": ["panel_custom", "websocket_api", "http", "frontend", "lovelace"], "codeowners": [], "requirements": [], - "version": "2.0.0b2", + "version": "2.0.0b3", "iot_class": "local_push", "config_flow": true } diff --git a/documentation/popups.md b/documentation/popups.md index ea310fd..7b913f2 100644 --- a/documentation/popups.md +++ b/documentation/popups.md @@ -10,16 +10,38 @@ data: left_button: Left button ``` -![Popup](https://user-images.githubusercontent.com/1299821/180668969-c647f301-3f3d-4f3b-a1f8-d95af8b48873.png) +![Dialog Anatomy](https://user-images.githubusercontent.com/1299821/182708739-f89e3b2b-199f-43e0-bf04-e1dfc7075b2a.png) -## Displaying a dashboard card in a popup +## Size + +The `size` parameter can be set to `normal`, `wide` and `fullscreen` with results as below (background blur has been exagerated for clarity): + +![Normal Size](https://user-images.githubusercontent.com/1299821/182709146-439814f1-d479-4fc7-aab1-e28f5c9a13c7.png) + +![Wide Size](https://user-images.githubusercontent.com/1299821/182709172-c98a9c23-5e58-4564-bcb7-1d187842948f.png) + +![Fullscreen Size](https://user-images.githubusercontent.com/1299821/182709224-fb2e7b92-8a23-4422-95a0-f0f2835909e0.png) + + +## HTML content ```yaml service: browser_mod.popup data: - title: The title - right_button: Right button - left_button: Left button + title: HTML content + content: | + An HTML string. +

      Pretty much any HTML works: +``` + +![HTML content](https://user-images.githubusercontent.com/1299821/182710044-6fea3ba3-5262-4361-a131-691770340518.png) + +## Dashboard card content + +```yaml +service: browser_mod.popup +data: + title: HTML content content: type: entities entities: @@ -28,10 +50,53 @@ data: - light.kitchen_lights ``` -![Popup with card](https://user-images.githubusercontent.com/1299821/180669077-bbc86831-3a8a-4e54-b098-d900d62d3508.png) +![Card content](https://user-images.githubusercontent.com/1299821/182710445-f09b74b8-dd53-4d65-8eba-0945fc1d418e.png) + +## Form content +`content` can be a list of ha-form schemas and the popup will then contain a form for user input: + +``` +: + name: + [label: ] + [default: ] + selector: +``` + +| | | +|-|-| +| `name` | A unique parameter name | +| `label` | A description of the parameter | +| `default` | The default value for the parameter | +| `selector` | A [Home Assistant selector](https://www.home-assistant.io/docs/blueprint/selectors) | + +The data from the form will be forwarded as data for any `right_button_action` or `left_button_action` of the popup. + +```yaml +service: browser_mod.popup +data: + title: Form content + content: + - name: parameter_name + label: Descriptive name + selector: + text: null + - name: another_parameter + label: A number + default: 5 + selector: + number: + min: 0 + max: 10 + slider: true +``` + +![Form content](https://user-images.githubusercontent.com/1299821/182712670-f3b4fdb7-84a9-49d1-a26f-2cdaa450fa0e.png) ## Actionable popups +Example of a popup with actions opening more popups or calling Home Assistant services: + ```yaml service: browser_mod.popup data: @@ -62,4 +127,35 @@ data: entity_id: light.bed_light ``` -![Advanced popup](https://user-images.githubusercontent.com/1299821/180670190-18cf8eee-cf18-47b9-84d1-e62ef327c615.gif) \ No newline at end of file +![Multi-level popup](https://user-images.githubusercontent.com/1299821/182713421-708d0026-bcfa-4ba6-bbcd-3b85b584162d.gif) + +## Forward form data + +The following popup would ask the user for a list of rooms to vacuum and then populate the `params` parameter of the `vacuum.send_command` service call from the result: + +```yaml +service: browser_mod.popup +data: + title: Where to vacuum? + right_button: Go! + right_button_action: + service: vacuum.send_command + data: + entity_id: vacuum.xiaomi + command: app_segment_clean + content: + - name: params + label: Rooms to clean + selector: + select: + multiple: true + options: + - label: Kitchen + value: 11 + - label: Living room + value: 13 + - label: Bedroom + value: 12 +``` + +![Vacuum popup](https://user-images.githubusercontent.com/1299821/182713714-ef4149b1-217a-4d41-9737-714f5320c25c.png) \ No newline at end of file diff --git a/documentation/services.md b/documentation/services.md index 9503f9c..9501b68 100644 --- a/documentation/services.md +++ b/documentation/services.md @@ -125,7 +125,7 @@ Display a popup dialog service: browser_mod.popup data: [title: ] - content: + content: [size: ] [right_button: ] [right_button_action: ] @@ -143,7 +143,7 @@ data: | | | |---|---| |`title` | The title of the popup window.| -|`content`| HTML or a dashboard card configuration to display.| +|`content`| HTML, a dashboard card configuration or ha-form schema to display.| | `size` | `wide` will make the popup window wider. `fullscreen` will make it cover the entire screen. | | `right_button`| The text of the right action button.| | `right_button_action`| Action to perform when the right action button is pressed. | @@ -171,7 +171,9 @@ style: Note that any Browser Mod services performed as `_action`s here will be performed only on the same Browser as initiated the action unless `browser_id` is given. -For usage examples, see [popups.md](popups.md). +If a ha-form schema is used for `content` the resulting data will be inserted into the `data` for any `_action`. + +See [popups.md](popups.md) for more information and usage examples. ## `browser_mod.close_popup` diff --git a/js/config_panel/registered-browsers-card.ts b/js/config_panel/registered-browsers-card.ts index 30ce9c2..eb4af6f 100644 --- a/js/config_panel/registered-browsers-card.ts +++ b/js/config_panel/registered-browsers-card.ts @@ -14,9 +14,7 @@ class BrowserModRegisteredBrowsersCard extends LitElement { const browserID = ev.currentTarget.browserID; const unregisterCallback = () => { - console.log(browserID, window.browser_mod.browserID); if (browserID === window.browser_mod.browserID) { - console.log("Unregister self"); window.browser_mod.registered = false; } else { window.browser_mod.connection.sendMessage({ diff --git a/js/helpers.ts b/js/helpers.ts index b819948..a621e7c 100644 --- a/js/helpers.ts +++ b/js/helpers.ts @@ -81,9 +81,9 @@ export const loadHaForm = async () => { await loadLoadCardHelpers(); const helpers = await window.loadCardHelpers(); if (!helpers) return; - const card = await helpers.createCardElement({ type: "entity" }); + const card = await helpers.createCardElement({ type: "button" }); if (!card) return; - await card.getConfigElement(); + await card.constructor.getConfigElement(); }; // Loads in ha-config-dashboard which is used to copy styling @@ -120,3 +120,15 @@ export const loadDeveloperToolsTemplate = async () => { await dtRouter?.routerOptions?.routes?.template?.load?.(); await customElements.whenDefined("developer-tools-template"); }; + +export function throttle(timeout) { + return function (target, propertyKey, descriptor) { + const fn = descriptor.value; + let cooldown = undefined; + descriptor.value = function (...rest) { + if (cooldown) return; + cooldown = setTimeout(() => (cooldown = undefined), timeout); + return fn.bind(this)(...rest); + }; + }; +} diff --git a/js/plugin/main.ts b/js/plugin/main.ts index 7f371d6..6e6eba8 100644 --- a/js/plugin/main.ts +++ b/js/plugin/main.ts @@ -1,6 +1,5 @@ import "./browser-player"; -// import { BrowserModConnection } from "./connection"; import { ConnectionMixin } from "./connection"; import { ScreenSaverMixin } from "./screensaver"; import { MediaPlayerMixin } from "./mediaPlayer"; @@ -19,7 +18,8 @@ import { BrowserIDMixin } from "./browserID"; /* TODO: - - Fix nomenclature + - More pictures for documentation + x Fix nomenclature x Command -> Service x Device -> Browser - Popups @@ -28,6 +28,8 @@ import { BrowserIDMixin } from "./browserID"; X Timeout X Fullscreen x Popup-card + x Auto-close + x Forms that are forwarded to service calls x Motion/occupancy tracker x Information about interaction requirement x Information about fullykiosk @@ -39,29 +41,28 @@ import { BrowserIDMixin } from "./browserID"; x ll-custom handling - Commands x popup - x Auto-close x close_popup x more-info x navigate - - lovelace-reload? - - Not needed + o lovelace-reload? + o Not needed x window-reload - - screensaver ? - - Refer to automations instead + o screensaver ? + o Refer to automations instead x sequence x delay x javascript eval - - toast? - - Replaced with popups with timeout + o toast? + o Replaced with popups with timeout x Redesign services to target devices x frontend editor for popup cards - - also screensavers - - Saved frontend settings + o also screensavers + x Saved frontend settings X Framework x Save sidebar x Kiosk mode x Default dashboard - - Screensaver? + o Screensaver? x Favicon templates x Title templates - Tweaks @@ -69,9 +70,9 @@ import { BrowserIDMixin } from "./browserID"; x Card-mod preload x Video player x Media_seek - - Screensavers + o Screensavers x IMPORTANT: FIX DEFAULT HIDING OF ENTITIES - - NOFIX. Home Assistant bug + o NOFIX. Home Assistant bug X Check functionality with CAST - may need to add frontend part as a lovelace resource */ export class BrowserMod extends ServicesMixin( diff --git a/js/plugin/mediaPlayer.ts b/js/plugin/mediaPlayer.ts index 2e3e273..d94dd83 100644 --- a/js/plugin/mediaPlayer.ts +++ b/js/plugin/mediaPlayer.ts @@ -1,12 +1,11 @@ -import { selectTree } from "../helpers"; +import { selectTree, throttle } from "../helpers"; export const MediaPlayerMixin = (SuperClass) => { - return class MediaPlayerMixinClass extends SuperClass { + class MediaPlayerMixinClass extends SuperClass { public player; private _audio_player; private _video_player; private _player_enabled; - private _player_update_cooldown; constructor() { super(); @@ -24,10 +23,10 @@ export const MediaPlayerMixin = (SuperClass) => { } for (const ev of ["timeupdate"]) { this._audio_player.addEventListener(ev, () => - this._player_update_choked() + this._player_update_throttled() ); this._video_player.addEventListener(ev, () => - this._player_update_choked() + this._player_update_throttled() ); } @@ -99,12 +98,8 @@ export const MediaPlayerMixin = (SuperClass) => { } } - private _player_update_choked() { - if (this._player_update_cooldown) return; - this._player_update_cooldown = window.setTimeout( - () => (this._player_update_cooldown = undefined), - 3000 - ); + @throttle(3000) + _player_update_throttled() { this._player_update(); } @@ -129,5 +124,7 @@ export const MediaPlayerMixin = (SuperClass) => { }, }); } - }; + } + + return MediaPlayerMixinClass; }; diff --git a/js/plugin/popups.ts b/js/plugin/popups.ts index f450573..6e4091d 100644 --- a/js/plugin/popups.ts +++ b/js/plugin/popups.ts @@ -2,6 +2,7 @@ import { LitElement, html, css } from "lit"; import { property, query } from "lit/decorators.js"; import { unsafeHTML } from "lit/directives/unsafe-html.js"; import { provideHass, loadLoadCardHelpers, hass_base_el } from "../helpers"; +import { loadHaForm } from "../helpers"; class BrowserModPopup extends LitElement { @property() open; @@ -23,6 +24,7 @@ class BrowserModPopup extends LitElement { _timeoutStart; _timeoutTimer; _resolveClosed; + _formdata; async closeDialog() { this.open = false; @@ -76,10 +78,30 @@ class BrowserModPopup extends LitElement { autoclose = false, } = {} ) { + this._formdata = undefined; this.title = title; + this.card = undefined; if (content && content instanceof HTMLElement) { - this.card = undefined; this.content = content; + } else if (content && Array.isArray(content)) { + loadHaForm(); + const form: any = document.createElement("ha-form"); + form.schema = content; + form.computeLabel = (s) => s.label ?? s.name; + form.hass = window.browser_mod.hass; + this._formdata = {}; + for (const i of content) { + if (i.name && i.default !== undefined) { + this._formdata[i.name] = i.default; + } + } + form.data = this._formdata; + provideHass(form); + form.addEventListener("value-changed", (ev) => { + this._formdata = { ...ev.detail.value }; + form.data = this._formdata; + }); + this.content = form; } else if (content && typeof content === "object") { // Create a card from config in content this.card = true; @@ -90,7 +112,6 @@ class BrowserModPopup extends LitElement { this.content = card; } else { // Basic HTML content - this.card = undefined; this.content = unsafeHTML(content); } @@ -115,12 +136,12 @@ class BrowserModPopup extends LitElement { async _primary() { if (this._actions?.dismiss_action) this._actions.dismiss_action = undefined; this.dialog?.close(); - this._actions?.right_button_action?.(); + this._actions?.right_button_action?.(this._formdata); } async _secondary() { if (this._actions?.dismiss_action) this._actions.dismiss_action = undefined; this.dialog?.close(); - this._actions?.left_button_action?.(); + this._actions?.left_button_action?.(this._formdata); } async _dismiss(ev?) { this.dialog?.close(); @@ -150,16 +171,21 @@ class BrowserModPopup extends LitElement { : ""} ${this.title ? html` - - ${this.dismissable - ? html` - - - - ` - : ""} -

      ${this.title}
      -
      +
      + + ${this.dismissable + ? html` + + + + ` + : ""} +
      ${this.title}
      +
      +
      ` : html``} @@ -171,6 +197,7 @@ class BrowserModPopup extends LitElement { slot="primaryAction" .label=${this.right_button} @click=${this._primary} + class="action-button" >
      ` : ""} @@ -180,6 +207,7 @@ class BrowserModPopup extends LitElement { slot="secondaryAction" .label=${this.left_button} @click=${this._secondary} + class="action-button" >
      ` : ""} @@ -195,6 +223,7 @@ class BrowserModPopup extends LitElement { static get styles() { return css` ha-dialog { + --dialog-backdrop-filter: blur(5px); z-index: 10; --mdc-dialog-min-width: var(--popup-min-width, 400px); --mdc-dialog-max-width: var(--popup-max-width, 600px); @@ -202,13 +231,12 @@ class BrowserModPopup extends LitElement { --mdc-dialog-content-ink-color: var(--primary-text-color); --justify-action-buttons: space-between; - --mdc-dialog-box-shadow: 0px 0px 0px + --dialog-box-shadow: 0px 0px 0px var(--popup-border-width, var(--ha-card-border-width, 2px)) var( --popup-border-color, var(--ha-card-border-color, var(--divider-color, #e0e0e0)) ); - --ha-dialog-border-radius: var(--popup-border-radius, 8px); --mdc-theme-surface: var( --popup-background-color, var(--ha-card-background, var(--card-background-color, white)) @@ -224,6 +252,7 @@ class BrowserModPopup extends LitElement { --mdc-dialog-max-height: 100%; --mdc-shape-medium: 0px; --vertial-align-dialog: flex-end; + --ha-dialog-border-radius: 0px; } .progress::before { content: ""; @@ -236,23 +265,20 @@ class BrowserModPopup extends LitElement { z-index: 10; } - app-toolbar { + ha-header-bar { + --mdc-theme-on-primary: var(--primary-text-color); + --mdc-theme-primary: var(--mdc-theme-surface); flex-shrink: 0; - color: var(--primary-text-color); - background-color: var( - --popup-header-background-color, - var(--popup-background-color, var(--sidebar-background-color)) - ); + display: block; } + ha-icon-button > * { display: flex; } .main-title { - margin-left: 16px; - line-height: 1.3em; - max-height: 2.6em; overflow: hidden; text-overflow: ellipsis; + cursor: default; } .content { --padding-x: 24px; @@ -269,9 +295,11 @@ class BrowserModPopup extends LitElement { :host([card]) .content { --padding-x: 0px; --padding-y: 0px; + --ha-card-box-shadow: none; } :host([actions]) .content { - border-bottom: 1px solid var(--popup-border-color, var(--divider-color)); + xborder-bottom: 2px solid + var(--popup-border-color, var(--divider-color)); --footer-height: 54px; } :host([wide]) .content { @@ -280,10 +308,14 @@ class BrowserModPopup extends LitElement { :host([fullscreen]) .content { height: calc( 100vh - var(--header-height) - var(--footer-height) - 2 * - var(--padding-y) + var(--padding-y) - 16px ); } + .action-button { + margin-bottom: -24px; + } + @media all and (max-width: 450px), all and (max-height: 500px) { ha-dialog { --mdc-dialog-min-width: 100vw; diff --git a/js/plugin/services.ts b/js/plugin/services.ts index 7bde390..360f778 100644 --- a/js/plugin/services.ts +++ b/js/plugin/services.ts @@ -128,7 +128,13 @@ export const ServicesMixin = (SuperClass) => { const { title, content, ...d } = data; for (const [k, v] of Object.entries(d)) { if (k.endsWith("_action")) { - d[k] = () => this._service_action(v as any); + d[k] = (ext_data?) => { + const { service, data } = v as any; + this._service_action({ + service, + data: { ...data, ...ext_data }, + }); + }; } } this.showPopup(title, content, d); @@ -147,18 +153,21 @@ export const ServicesMixin = (SuperClass) => { break; case "console": - console.log(data.message); + if ( + Object.keys(data).length > 1 || + (data && data.message === undefined) + ) + console.dir(data); + else console.log(data.message); break; case "javascript": const code = ` "use strict"; - // Insert global definitions here - const hass = (document.querySelector("home-assistant") || document.querySelector("hc-main")).hass; ${data.code} `; - const fn = new Function(code); - fn(); + const fn = new Function("hass", "data", code); + fn(this.hass, data); break; } } diff --git a/package.json b/package.json index f542948..b3237cd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "browser_mod", "private": true, - "version": "2.0.0b2", + "version": "2.0.0b3", "description": "", "scripts": { "build": "rollup -c",