text: 'use strict';var m8={TAB:0,Ni:1,Zl:2},n8=function(a){Eb("MediaRouter.WebRtc.Start.Success",a,m8)};var r8=function(a,b){Kg.call(this,b);this.s=a;this.a=new Ib;this.h=ss(b.id);this.g=new Ib;this.m=!1;this.l=null;this.u=!1;this.v=this.f=null;o8(this);p8(this);q8(this,new Qg("GET_TURN_CREDENTIALS"))};Fa(r8,Kg);r8.prototype.start=function(a){var b=this;return this.a.a.then(function(c){if(c.b)return Promise.reject(new Wf("Mirroring already started"));if(b.l)return Promise.reject(new Wf("Session permanently stopped"));b.f=new tb("MediaRouter.WebRtc.Session.Launch");c.a.addStream(a);c.start();return b.g.a})};
  r8.prototype.stop=function(){var a=this;this.g.reject(new Wf("Session stop requested."));this.v&&(this.v.a(),this.v=null);if(this.l)return this.l;this.u=this.m=!1;this.f=null;return this.l=this.a.a.then(function(a){a.stop()}).then(function(){return a.h.Na()}).catch(function(b){a.h.Na();throw b;})};
  var o8=function(a){a.h.onMessage=function(b){if(!b.type)throw Error("Message has no type.");switch(b.type){case "TURN_CREDENTIALS":a.a.resolve(new Vg(a.b.id,b.data.credentials));break;case "ANSWER":a.a.a.then(function(a){ch(a,b.data)});break;case "KNOCK_ANSWER":a.u=!0;a.a.a.then(function(a){ch(a,b.data)});break;case "STOP":a.g.reject(new Wf("Stop signal received"));a.stop();break;default:throw new Wf("Unknown message type: "+b.type);}}},p8=function(a){a.a.a.then(function(b){Zg(b,function(b){q8(a,
  new Qg("OFFER",new Sg(b,a.s,Tg)))});$g(b,function(b){q8(a,Rg(b))});Wg(b,function(){a.m=!0;q8(a,new Qg("SESSION_START_SUCCESS"));!a.u&&a.f&&a.f.a();a.f=null;a.v=new Ab("MediaRouter.WebRtc.Session.Length");a.g.resolve(a)});Yg(b,function(){q8(a,new Qg("SESSION_END"))});Xg(b,function(b){a.m||a.g.reject(b);q8(a,new Qg("SESSION_FAILURE"))})})},q8=function(a,b){a.h.sendMessage(b,s8)},s8={channelType:"cloud"};var t8=function(){Ag.call(this,"webrtc")};Fa(t8,Ag);g=t8.prototype;g.lg=function(a,b){return new r8(a,b)};g.Vg=function(){n8(0)};g.Sg=function(){n8(1)};g.pi=function(){n8(2)};g.Tg=function(){Db("MediaRouter.WebRtc.Session.End")};g.Ug=function(a){Eb("MediaRouter.WebRtc.Start.Failure",a,Vf)};g.Hf=function(){Db("MediaRouter.WebRtc.Stream.End")};var u8=new t8;zg("mr.mirror.webrtc.WebRtcService",u8);
  