"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["10405"],{44688:function(t,n,a){a.d(n,{Oc:function(){return o},gk:function(){return s},oS:function(){return i}});var e=a(50816),i=!1,s=i?e._:"A078F6B0",o="urn:x-cast:com.nabucasa.hast"},50816:function(t,n,a){a.d(n,{I:function(){return i},_:function(){return e}});var e="5FE44367",i="http://192.168.1.234:8123"},40461:function(t,n,a){a.d(n,{oK:function(){return s},tb:function(){return o},xV:function(){return r}});a(26099),a(3362);var e=a(44688),i=a(50816),s=function(t,n){return t.sendMessage({type:"connect",refreshToken:n.data.refresh_token,clientId:n.data.clientId,hassUrl:e.oS?i.I:n.data.hassUrl})},o=function(t,n,a,s){return t.sendMessage({type:"show_lovelace_view",viewPath:a,urlPath:s||null,hassUrl:e.oS?i.I:n})},r=function(t,n){if(!t.castConnectedToOurHass)return new Promise(function(a){var e=t.addEventListener("connection-changed",function(){t.castConnectedToOurHass&&(e(),a())});s(t,n)})}},96612:function(t,n,a){a.a(t,async function(t,e){try{a.r(n);var i,s,o,r,c,u,h=a(61397),l=a(50264),d=a(72153),f=a(44734),g=a(43080),v=a(69683),_=a(6454),p=a(25460),y=(a(28706),a(23792),a(69085),a(26099),a(3362),a(47764),a(62953),a(40445)),A=a(96196),m=a(77845),w=a(94333),M=a(40461),k=a(18350),b=(a(88945),t([k]));k=(b.then?(await b)():b)[0];var x=function(t){function n(){var t;(0,f.A)(this,n);for(var a=arguments.length,e=new Array(a),i=0;i<a;i++)e[i]=arguments[i];return(t=(0,v.A)(this,n,[].concat(e)))._noHTTPS=!1,t}return(0,_.A)(n,t),(0,g.A)(n,[{key:"setConfig",value:function(t){this._config=Object.assign({icon:"mdi:television",name:"Home Assistant Cast",view:0},t)}},{key:"shouldUpdate",value:function(t){return!(1===t.size&&t.has("hass"))}},{key:"render",value:function(){if(!this._config)return A.s6;var t=this._castManager&&this._castManager.status&&this._config.view===this._castManager.status.lovelacePath&&this._config.dashboard===this._castManager.status.urlPath;return(0,A.qy)(i||(i=(0,d.A)([' <ha-icon .icon="','"></ha-icon> <div class="flex"> <div class="name">',"</div> "," </div> "])),this._config.icon,this._config.name,this._noHTTPS?(0,A.qy)(s||(s=(0,d.A)([" Cast requires HTTPS "]))):void 0===this._castManager?A.s6:null===this._castManager?(0,A.qy)(o||(o=(0,d.A)([" Cast API unavailable "]))):"NO_DEVICES_AVAILABLE"===this._castManager.castState?(0,A.qy)(r||(r=(0,d.A)([" No devices found "]))):(0,A.qy)(c||(c=(0,d.A)([' <div class="controls"> <google-cast-launcher></google-cast-launcher> <ha-button @click="','" class="','" appearance="plain" size="small" .disabled="','"> SHOW </ha-button> </div> '])),this._sendLovelace,(0,w.H)({inactive:!t}),!this._castManager.status))}},{key:"firstUpdated",value:function(t){var e=this;(0,p.A)(n,"firstUpdated",this,3)([t]),"http:"===location.protocol&&"localhost"!==location.hostname&&(this._noHTTPS=!0),a.e("80444").then(a.bind(a,51671)).then(function(t){return(0,t.getCastManager)(e.hass.auth).then(function(t){e._castManager=t,t.addEventListener("connection-changed",function(){e.requestUpdate()}),t.addEventListener("state-changed",function(){e.requestUpdate()})},function(){e._castManager=null})})}},{key:"updated",value:function(t){(0,p.A)(n,"updated",this,3)([t]),this._config&&this._config.hide_if_unavailable&&(this.style.display=this._castManager&&"NO_DEVICES_AVAILABLE"!==this._castManager.castState?"":"none")}},{key:"_sendLovelace",value:(e=(0,l.A)((0,h.A)().m(function t(){return(0,h.A)().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,(0,M.xV)(this._castManager,this.hass.auth);case 1:(0,M.tb)(this._castManager,this.hass.auth.data.hassUrl,this._config.view,this._config.dashboard);case 2:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})}]);var e}(A.WF);x.styles=(0,A.AH)(u||(u=(0,d.A)([":host{display:flex;align-items:center}ha-icon{padding:8px;color:var(--state-icon-color)}.flex{flex:1;margin-left:16px;margin-inline-start:16px;margin-inline-end:initial;display:flex;justify-content:space-between;align-items:center}.name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.controls{display:flex;align-items:center}google-cast-launcher{margin-right:.57em;margin-inline-end:-.57em;margin-inline-start:initial;cursor:pointer;display:inline-block;height:24px;width:24px}.inactive{padding:0 4px}"]))),(0,y.Cg)([(0,m.MZ)({attribute:!1})],x.prototype,"hass",void 0),(0,y.Cg)([(0,m.wk)()],x.prototype,"_config",void 0),(0,y.Cg)([(0,m.wk)()],x.prototype,"_castManager",void 0),(0,y.Cg)([(0,m.wk)()],x.prototype,"_noHTTPS",void 0),x=(0,y.Cg)([(0,m.EM)("hui-cast-row")],x),e()}catch(C){e(C)}})}}]);
//# sourceMappingURL=10405.334026ed82a3e06a.js.map