(self.webpackJsonp=self.webpackJsonp||[]).push([[231],{113:function(t,e,s){"use strict";s.d(e,"a",(function(){return a})),s.d(e,"b",(function(){return i})),s.d(e,"c",(function(){return r}));const n=(t,e,s)=>new Promise((n,a)=>{const i=document.createElement(t);let r="src",c="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",c="head"}i[r]=e,document[c].appendChild(i)}),a=t=>n("link",t),i=t=>n("script",t),r=t=>n("script",t,"module")},801:function(t,e,s){"use strict";s.r(e);var n=s(113);let a;var i=s(604),r=s(551),c=s(603);function o(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}let h;s.d(e,"CastManager",(function(){return u})),s.d(e,"getCastManager",(function(){return d}));class u{constructor(t){o(this,"auth",void 0),o(this,"status",void 0),o(this,"_eventListeners",{}),this.auth=t;const e=this.castContext;e.setOptions({receiverApplicationId:i.a,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),e.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,t=>this._sessionStateChanged(t)),e.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,t=>this._castStateChanged(t))}addEventListener(t,e){return t in this._eventListeners||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),()=>{this._eventListeners[t].splice(this._eventListeners[t].indexOf(e))}}get castConnectedToOurHass(){return void 0!==this.status&&void 0!==this.auth&&this.status.connected&&(this.status.hassUrl===this.auth.data.hassUrl||i.b&&this.status.hassUrl===r.b)}sendMessage(t){this.castSession.sendMessage(i.c,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"))}_sessionStateChanged(t){"SESSION_STARTED"===t.sessionState||"SESSION_RESUMED"===t.sessionState?(this.auth?Object(c.a)(this,this.auth):this.sendMessage({type:"get_status"}),this._attachMessageListener()):"SESSION_ENDED"===t.sessionState&&(this.status=void 0,this._fireEvent("connection-changed"))}_castStateChanged(t){this._fireEvent("state-changed")}_attachMessageListener(){this.castSession.addMessageListener(i.c,(t,e)=>this._receiveMessage(JSON.parse(e)))}}const d=t=>(h||(h=(()=>{if(a)return a;a=new Promise(t=>{window.__onGCastApiAvailable=t});const t=document.createElement("div");return t.id="cast",document.body.append(t),Object(n.b)("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 u(t)})),h)}}]);
//# sourceMappingURL=chunk.31fa3a85396491c717e5.js.map