'use strict';var c=function(a,b,e,d,f,g,h,k,l,m){this.v=a;this.m=b;this.f=e;this.g=d;this.i=f;this.j=g;this.l=h;this.u=k;this.s=l;this.b=this.c=!1;this.a=null;this.A(m)};
c.prototype.A=function(a){if(a=a||window.location.search){for(var b={},e=/([^&=]+)=?([^&]*)/g,d;d=e.exec(a.substring(1));)b[decodeURIComponent(d[1])]=decodeURIComponent(d[2]);if(a=b.routeId)this.v.textContent="Casting:",this.m.textContent="",this.f.title="Mute",this.g.title="Unmute",this.h(),b=function(a){a&&a.key&&" "!=a.key&&"Enter"!=a.key||(this.muteOrUnmute(),this.h())}.bind(this),this.f.onclick=b,this.f.onkeydown=b,this.g.onclick=b,this.g.onkeydown=b,this.u.textContent="Smooth Motion [beta]",
this.s.textContent="Use high bandwidth for best video or animation.\nOther people with slow connections may not see your content.",b=function(a){a&&a.key&&" "!=a.key&&"Enter"!=a.key||(this.toggleLocalPresent(),this.o())}.bind(this),this.i.onclick=b,this.i.onkeydown=b,(new PresentationRequest("chrome://media-router/cloudmrp-mirroring")).reconnect(a).then(function(a){this.a=a;this.a.onmessage=this.w.bind(this);this.a.send('{"type":"STATUS_REQUEST"}')}.bind(this),null)}};
c.prototype.muteOrUnmute=function(){this.c=!this.c;this.a.send('{"type":"MUTE", "data": {"mute":'+this.c+"}}")};c.prototype.h=function(){this.c?(this.g.style.display="",this.f.style.display="none"):(this.g.style.display="none",this.f.style.display="")};c.prototype.toggleLocalPresent=function(){this.b=!this.b;this.a.send('{"type":"LOCAL_PRESENT", "data": {"local":'+this.b+"}}")};
c.prototype.o=function(){this.b?(this.j.className="checked paper-checkbox",this.l.className="paper-checkbox"):(this.j.className="paper-checkbox",this.l.className="hidden paper-checkbox")};c.prototype.w=function(a){if(a=a.data)a=JSON.parse(a),"STATUS_RESPONSE"==a.type&&a.data&&(a=a.data,a.routeDescription&&(this.m.textContent=a.routeDescription),void 0!=a.mute&&(this.c=a.mute,this.h()),void 0!=a.local&&(this.b=a.local,this.o()))};window.addEventListener("DOMContentLoaded",function(){window.routeController=new c(document.getElementById("displayNameHolder"),document.getElementById("statusTextHolder"),document.getElementById("mute"),document.getElementById("unmute"),document.getElementById("checkboxElement"),document.getElementById("checkbox"),document.getElementById("checkmark"),document.getElementById("checkboxLabelTitle"),document.getElementById("checkboxLabelSubtitle"))});
