UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 2.78 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[20947],{41278:function(t,e,s){s.d(e,{getCastManager:function(){return h}});s(16280),s(44114),s(69112),s(62953),s(3362);var n=s(25995);let a;const i="urn:x-cast:com.nabucasa.hast";s(50816);var r=s(40461);let o;class c{addEventListener(t,e){return t in this._eventListeners||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),()=>{const s=this._eventListeners[t],n=s.indexOf(e);-1!==n&&s.splice(n,1)}}get castConnectedToOurHass(){return void 0!==this.status&&void 0!==this.auth&&this.status.connected&&(this.status.hassUrl===this.auth.data.hassUrl||!1)}sendMessage(t){this.castSession.sendMessage(i,t)}get castState(){return this.castContext.getCastState()}get castContext(){return cast.framework.CastContext.getInstance()}get castSession(){return this.castContext.getCurrentSession()}requestSession(){return this.castContext.requestSession()}_fireEvent(t){for(const e of this._eventListeners[t]||[])e()}_receiveMessage(t){"receiver_status"===t.type&&(this.status=t,this._fireEvent("connection-changed"))}_attachMessageListener(){this.castSession.addMessageListener(i,(t,e)=>this._receiveMessage(JSON.parse(e)))}constructor(t){this._eventListeners={},this._sessionStateChanged=t=>{"SESSION_STARTED"===t.sessionState||"SESSION_RESUMED"===t.sessionState?(this.auth?(0,r.oK)(this,this.auth):this.sendMessage({type:"get_status"}),this._attachMessageListener()):"SESSION_ENDED"===t.sessionState&&(this.status=void 0,this._fireEvent("connection-changed"))},this._castStateChanged=t=>{this._fireEvent("state-changed")},this.auth=t;const e=this.castContext;e.setOptions({receiverApplicationId:"A078F6B0",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),e.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,this._sessionStateChanged),e.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,this._castStateChanged)}}const h=t=>(o||(o=(()=>{if(a)return a;a=new Promise(t=>{window.__onGCastApiAvailable=t});const t=document.createElement("div");return t.id="cast",document.body.append(t),(0,n.kG)("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"),a})().then(e=>{if(!e)throw new Error("No Cast API available");return new c(t)})),o)},25995:function(t,e,s){s.d(e,{Vw:function(){return r},kG:function(){return i},y6:function(){return a}});s(3362);const n=(t,e,s)=>new Promise((n,a)=>{const i=document.createElement(t);let r="src",o="body";switch(i.onload=()=>n(e),i.onerror=()=>a(e),t){case"script":i.async=!0,s&&(i.type=s);break;case"link":i.type="text/css",i.rel="stylesheet",r="href",o="head"}i[r]=e,document[o].appendChild(i)}),a=t=>n("link",t),i=t=>n("script",t),r=t=>n("script",t,"module")}}]);