'use strict';var $e;var af=chrome.i18n.getMessage("545449835455981095");q("mr.IssueSeverity",{ko:"fatal",Sr:"warning",Sp:"notification"});q("mr.IssueAction",{Zn:"dismiss",lp:"learn_more"});var bf=function(a,b){this.routeId=null;this.severity=b;this.isBlocking="fatal"==this.severity?!0:!1;this.title=a;this.message=null;this.defaultAction="dismiss";this.helpPageId=this.secondaryActions=null},df=function(){var a=new bf(cf,"notification");a.helpPageId=6320939;a.defaultAction="learn_more";a.secondaryActions=["dismiss"];return a};var ef=function(a,b){var c=this;this.b=void 0===b?null:b;this.a=new Promise(function(b,e){var d=function(a){c.b=null;e(a)};c.f=d;a(function(a){c.b=null;b(a)},d)})};ef.prototype.cancel=function(a){this.f(a);if(this.b){var b=this.b;this.b=null;setTimeout(function(){return b(a)},0)}};var ff=function(a,b,c){c=void 0===c?null:c;return new ef(function(d,e){a.a.then(function(a){if(b)try{d(b(a))}catch(g){e(g)}else d(a)},function(a){if(c)try{d(c(a))}catch(g){e(g)}else e(a)})},function(b){a.cancel(b)})};
ef.prototype.then=function(a,b){return ff(this,a,void 0===b?null:b)};var gf=function(a,b){return ff(a,null,b)},hf=function(a){return new ef(function(b){b(a)})},jf=function(a){return new ef(function(b,c){c(a)})},kf=function(a){return new ef(function(b,c){a.then(b,c)})},lf=function(a,b){var c=!1,d=null;return new ef(function(e,f){a.then(function(a){c||(d=b(a),d.a.then(e,f))},f)},function(a){d?d.cancel(a):c=!0})};var mf=function(){var a=ja(navigator.userAgent.match(/Windows NT (\d+.\d+)/)||[]);a.next();a=a.next().value;return 6.2<=parseFloat(a)},nf=function(){var a=navigator.userAgent;return a.includes("CrOS")?"ChromeOS":a.includes("Windows")?"Windows":a.includes("Macintosh")?"Mac":a.includes("Linux")?"Linux":"Other"};var of=!("undefined"==typeof chrome||!chrome.networkingPrivate||!chrome.networkingPrivate.setWifiTDLSEnabledState||"ChromeOS"!=nf()),pf=["ChromeOS","Windows"].includes(nf());var qf=function(a,b,c,d){this.b=a;this.a=b;this.f=c||null;this.presentationId=d||null},tf=function(a,b){if("tab"==a.b)a=rf(a);else if("offscreen_tab"==a.b)b=rf(a),b.presentationId=a.presentationId,a=b;else{var c={audio:!1,video:!1};a.a.shouldCaptureVideo&&(c.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:b}},sf(a,c.video.mandatory));pf&&a.a.shouldCaptureAudio&&(c.audio={mandatory:{chromeMediaSource:"system",chromeMediaSourceId:b}});a=c}return a},rf=function(a){var b={audio:a.a.shouldCaptureAudio,
video:a.a.shouldCaptureVideo};a.a.shouldCaptureVideo&&(b.videoConstraints={mandatory:{enableAutoThrottling:!0}},sf(a,b.videoConstraints.mandatory));return b},sf=function(a,b){var c=a.a.minWidth,d=a.a.minHeight;if(a.a.senderSideLetterboxing){c=a.a;if(0==c.minHeight||0==c.maxHeight?0:Math.floor(100*c.minWidth/c.minHeight)==Math.floor(100*c.maxWidth/c.maxHeight))c={width:c.minWidth,height:c.minHeight};else{d=c.maxWidth;for(var e=c.maxHeight;0!=e;){var f=d%e;d=e;e=f}e=c.maxWidth/d;d=c.maxHeight/d;if(e<
c.minWidth||d<c.minHeight)if(f=Math.max(c.minWidth/e,c.minHeight/d),e*=f,d*=f,e>c.maxWidth||d>c.maxHeight)e=c.maxWidth,d=c.maxHeight;e=Math.round(e);d=Math.round(d);c={width:e,height:d}}d=c;c=d.width;d=d.height}Object.assign(b,{minWidth:c,minHeight:d,maxWidth:a.a.maxWidth,maxHeight:a.a.maxHeight,minFrameRate:a.a.minFrameRate,maxFrameRate:a.a.maxFrameRate})};var uf={Bn:0,zn:1,Dn:2,An:3,dn:4,Cn:5,Ko:6,yr:7,Tn:8,Og:9},vf=function(a,b){a=Error.call(this,a);this.message=a.message;"stack"in a&&(this.stack=a.stack);this.reason=0<=b&&9>=b?b:9};qa(vf,Error);var wf=function(a){this.b=a;this.a=this.ed=null;this.j=Pa("mr.mirror.MirrorMediaStream")};wf.prototype.start=function(){return"tab"==this.b.b?xf(this):"offscreen_tab"==this.b.b?yf(this):zf(this)};var xf=function(a){var b=tf(a.b);a.j.info("Starting tab capture with constraints "+JSON.stringify(b));return new Promise(function(c,d){chrome.tabCapture.capture(b,function(b){b?(Af(a,b),c(a)):d(Bf())});window.setTimeout(function(){d(new vf("chrome.tabCapture.capture failed to call its callback",2))},5E3)})};
wf.prototype.f=function(a){a&&this.j.info(function(){return"Track "+JSON.stringify(a.target)+" ended"});this.stop()};
var Bf=function(){return chrome.runtime.lastError&&chrome.runtime.lastError.message?new vf(chrome.runtime.lastError.message,7):new vf("empty_stream",0)},zf=function(a){return(new Promise(function(a,c){var b=["screen","audio"];"Linux"==nf()&&b.push("window");var e=chrome.desktopCapture.chooseDesktopMedia(b,a);window.setTimeout(function(){chrome.desktopCapture.cancelChooseDesktopMedia(e);c(new vf("timeout",1))},6E4)})).then(function(b){if(!b)throw new vf("User cancelled capture dialog",3);var c=tf(a.b,
b);a.j.info(function(){return"Starting desktop capture with constraints "+JSON.stringify(c)});return new Promise(function(a,b){navigator.webkitGetUserMedia(c,a,function(a){var c=8;if("PermissionDeniedError"==a.name||"NotAllowedError"==a.name)c=3;b(new vf(a.name+" "+a.constraintName+": "+a.message,c))})})}).then(function(b){if(b)Af(a,b);else throw new vf("empty_stream",8);return a})},yf=function(a){var b=tf(a.b);a.j.info(function(){return"Starting offscreen tab capture with constraints "+JSON.stringify(b)});
return new Promise(function(c,d){chrome.tabCapture.captureOffscreenTab(a.b.f.toString(),b,function(b){b?(Af(a,b),c(a)):d(Bf())})})},Af=function(a,b){a.a=b;b.getAudioTracks().length||b.getVideoTracks();b.getTracks().forEach(function(b){b.onended=a.f.bind(a)})};wf.prototype.stop=function(){this.a&&(this.a.getTracks().forEach(function(a){a.onended=null;a.stop()}),this.a=null,this.ed&&this.ed())};var Cf,Df={tp:0,En:1,Fn:2,Vn:3,Wn:4,so:5,Lo:6,rp:7,Kp:8,Lp:9,Gq:10,fr:11,gr:12,nr:13,xr:14},Ef=function(a){void 0==Cf&&(ib("MediaRouter.Provider.WakeEvent",a,Df),Cf=a)};var Hf=function(a){return Ff(a)||Gf(a)},If=function(a){if(!a.startsWith("http:")&&!a.startsWith("https:"))return!1;var b=document.createElement("a");b.href=a;return"http:"!=b.protocol&&"https:"!=b.protocol?!1:-1==b.hash.indexOf("__castAppId__")},Jf=["https://docs.google.com"],Ff=function(a){return a.startsWith("urn:x-org.chromium.media:source:tab:")||-1!=a.indexOf("0F5096E8")},Gf=function(a){return"urn:x-org.chromium.media:source:desktop"==a},Kf=function(a){var b=a.search("urn:x-org.chromium.media:source:tab:");
return-1==b?null:parseInt(a.substr(b+36),10)||null};var Lf=function(a){return(new Promise(function(b){chrome.tabs.get(a,b)})).then(function(b){if(!b)throw Error("No such tab "+a);return b})};var Mf=function(){},Qf=function(a){var b=Nf.get(a)||null;if(b)return Promise.resolve(b);b=Of.get(a);b||(b=new kb,Of.set(a,b),Pf(a,b));return b.a},Pf=function(a,b){var c=Rf.get(a)||null;if(!c)b.reject(Error("No corresponding bundle for "+a));else if(!Sf.has(c)){var d=Tf.get(c);d||(Uf.info("Loading bundle "+c+" for module "+a),d=Vf(c),Tf.set(c,d));d.catch(function(a){b.reject(a)})}},Vf=function(a){var b=new kb;b.a.then(function(){Uf.info("Bundle "+a+" loaded")},function(b){Uf.error("Failed to load bundle "+
a);throw b;});var c=document.createElement("script");c.src=chrome.extension.getURL(a);c.setAttribute("type","text/javascript");c.async=!0;c.onload=function(){return b.resolve(void 0)};c.onerror=function(){return b.reject(Error("Failed to load bundle "+a))};document.head.appendChild(c);return b.a},Wf=function(a,b){if(Nf.has(a))throw Error("Duplicate module "+a);Nf.set(a,b);(a=Of.get(a))&&a.resolve(b)};
Mf.prototype.handleEvent=function(a,b){for(var c=1;c<arguments.length;++c);throw Error("Not implemented");};
var Rf=new Map([["mr.cast.ChannelService","background_script.js"],["mr.cast.SinkDiscoveryService","background_script.js"],["mr.mirror.cast.Service","mirroring_cast_streaming.js"],["mr.cloud.discovery.CloudSinkDiscoveryService","background_script.js"],["mr.dial.SinkDiscoveryService","background_script.js"],["mr.mirror.hangouts.HangoutsService","mirroring_hangouts.js"],["mr.mirror.hangouts.MeetingsService","mirroring_hangouts.js"],["mr.ProviderManager","background_script.js"],["mr.mirror.webrtc.WebRtcService",
"mirroring_webrtc.js"]]),Sf=new Set(["background_script.js"]),Uf=Pa("mr.Module"),Nf=new Map,Of=new Map,Tf=new Map;var Xf=function(a,b){this.F=a;this.l=b||null;this.b=this.a=null;this.G=Pa("mr.mirror.Service."+a);this.s=this.X.bind(this);this.g=!1};qa(Xf,Mf);Xf.prototype.Ga=function(a){this.g||(this.l=a,this.g=!0,this.ve())};Xf.prototype.ve=function(){};Xf.prototype.getName=function(){return this.F};
var bg=function(a,b,c,d,e,f){a.G.info("Start mirroring on route "+b.id);return a.g?kf(Yf(c,b.sb.tabId).then(function(){return Zf(a)}).then(function(){var a=$f(c,d,e);return(new wf(a)).start()}).then(function(c){if(a.b)throw c.stop(),new vf("Cannot start multiple streams");a.b=c;c=a.h.bind(a);a.b.ed=c;return f?f(b).a:b}).then(function(b){if(a.a)throw new vf("Cannot start multiple sessions");if(!a.b)throw new vf("Media stream ended before session could start.");a.a=a.te(d,b);return a.a.start(a.b.a)}).then(function(){Ff(c)&&
!chrome.tabs.onUpdated.hasListener(a.s)&&chrome.tabs.onUpdated.addListener(a.s);return a.A(b,c,d)}).then(null,function(b){ag(a,b);return a.h().then(function(){throw b;})})):jf(Error("Not initialized"))},Yf=function(a,b){return Ff(a)?b?Lf(b).then(function(a){if(!a.active)throw new vf("Tab to be mirrored is not active",7);}):Promise.reject(new vf("BUG: Tab ID is required.")):Promise.resolve()};
Xf.prototype.I=function(a,b,c,d,e){var f=this;if(!this.a)return Promise.reject(new vf("No session to update streams on",7));if(!this.a.Ai())return Promise.reject(new vf("Session does not support updating stream",7));var g=!1;return Promise.resolve().then(function(){var a=$f(b,c,d);return(new wf(a)).start()}).then(function(b){f.b&&(f.b.ed=null,f.b.stop(),f.Td());f.b=b;b=f.h.bind(f);f.b.ed=b;g=!0;return e?e(a).a:a}).then(function(){if(!f.a)throw new vf("Session ended while updating stream");if(!f.b)throw new vf("Media stream ended before session could be updated.");
f.a.Gf();return f.a.Fi(f.b.a)}).then(this.A.bind(this,a,b,c)).then(null,function(a){ag(f,a);if(g)return f.h().then(function(){throw a;});throw a;})};
Xf.prototype.A=function(a,b,c){var d=this;return new Promise(function(e,f){if(d.a)if(Ff(b))cg(d.a,a.sb.tabId).then(function(){d.l.Hf(d.a.b);dg(d.a);d.Ue();e(d.a.b)},function(a){d.G.error("Failed to obtain initial tab info.",a);f(a)});else{if(If(b)){var g="Capturing "+a.mediaSource;eg(d.a,g,g,null);dg(d.a);d.Wf()}else eg(d.a,"Capturing Desktop","Capturing Desktop",null),dg(d.a),d.Re();fg(d,c,d.b);e(d.a.b)}else f(new vf("Session gone before executing post-startup steps",7))})};
var ag=function(a,b){b.reason=null!=b.reason?b.reason:9;a.G.error("Failed to start mirroring: "+b.message+(",  reason = "+b.reason+": "+b.stack));a.Te(b.reason)},Zf=function(a){return a.g?a.h().then(function(b){b&&a.Se();return b}):Promise.reject("Not initialized")};
Xf.prototype.h=function(){var a=this;chrome.tabs.onUpdated.removeListener(this.s);var b=this.b;this.b=null;b&&(b.ed=null);var c=this.a;this.a=null;var d;c?d=this.kf(c).catch(function(b){return a.G.error("Error in before-cleanup steps",b)}).then(function(){return c.stop()}).catch(function(b){return a.G.error("Error stopping session",b)}).then(function(){a.l.If(c.b.id)}).catch(function(b){return a.G.error("Error in ended callbacks",b)}).then(function(){return!0}):d=Promise.resolve(!1);b&&(d=d.then(function(c){b.stop();
a.Td();return c}));return d};Xf.prototype.kf=function(){return Promise.resolve()};Xf.prototype.X=function(a,b,c){Ef(14);this.a&&this.a.tabId&&this.a.tabId==a&&("complete"==b.status||b.favIconUrl&&"complete"==c.status)&&(this.a.Gi(c),this.l.Hf(this.a.b),dg(this.a))};
var $f=function(a,b,c){if(Ff(a))return new qf("tab",b);if(Gf(a))return new qf("desktop",b);if(If(a)){if(!c)throw new vf("Missing offscreen tab presentation id");return new qf("offscreen_tab",b,a,c)}throw new vf("Source URN does not suggest a known capture type.");},fg=function(a,b,c){b.shouldCaptureAudio&&c.a&&!c.a.getAudioTracks().length&&a.l.tc(new bf(af,"notification"))};h=Xf.prototype;h.te=function(){};h.Ue=function(){};h.Re=function(){};h.Wf=function(){};h.Se=function(){};h.Te=function(){};
h.Td=function(){};h.Ff=function(){return Ma()};h.createMediaRouteController=function(){return Ma()};var gg=function(a){this.b=a;this.w=!1;this.tabId=this.B=this.iconUrl=null},eg=function(a,b,c,d){a.b.description=b;a.w||a.b.offTheRecord?(a.B=null,a.iconUrl=null):(a.B=c,a.iconUrl=d);a.Gf()},dg=function(a){a.w||a.b.offTheRecord||a.li()},cg=function(a,b){a.tabId=b;return Lf(b).then(a.Gi.bind(a))};h=gg.prototype;h.Gi=function(a){this.w=a.incognito;var b=new URL(a.url);eg(this,a.title,"file:"==b.protocol?"Local content (Tab)":b.hostname+" (Tab)",a.favIconUrl)};h.start=function(){};h.Ai=function(){return!1};
h.Fi=function(){};h.stop=function(){return Promise.resolve()};h.li=function(){};h.Gf=function(){};var kg=function(){var a=this;this.maxWidth=1920;this.maxHeight=1080;this.minHeight=this.minWidth=180;this.senderSideLetterboxing=!1;this.minFrameRate=0;this.maxFrameRate=30;this.minVideoBitrate=300;this.maxVideoBitrate=5E3;this.audioBitrate=0;this.maxLatencyMillis=800;this.animatedLatencyMillis=this.minLatencyMillis=400;this.dscpEnabled=["Mac","Linux","ChromeOS"].includes(nf())||mf();this.enableLogging=!0;this.useTdls=!1;this.shouldCaptureAudio=this.shouldCaptureVideo=!0;var b=window.localStorage?
window.localStorage.getItem(hg):null;if(b)try{var c=JSON.parse(String(b));if(c instanceof Object)ig(this,c),v(Pa("mr.mirror.Settings"),function(){return"Initial mr.mirror.Settings overridden to: "+jg(a)});else throw Error("localStorage["+hg+"] "+("does not parse as an Object: "+b));}catch(d){throw Pa("mr.mirror.Settings").error(hg+' must be of the form \'{"maxWidth":640, "maxHeight":360}\'.',d),Error("Overrides not parseable.  See ERROR log for details.");}};
kg.prototype.clone=function(){var a=new kg;ig(a,this);return a};
var jg=function(a){return JSON.stringify(a,function(a,c){if(0==a.length||!a.endsWith("_"))return c})},ig=function(a,b){for(var c=ja(Object.keys(b)),d=c.next();!d.done;d=c.next())d=d.value,d.endsWith("_")||typeof b[d]!==typeof a[d]||(a[d]=b[d])},lg=function(a){var b=screen.width,c=screen.height;a.maxHeight*b<a.maxWidth*c?(b=Math.min(a.maxWidth,b),b-=b%160,c=90*b/160):(c=Math.min(a.maxHeight,c),c-=c%90,b=160*c/90);if(b<Math.max(160,a.minWidth)||c<Math.max(90,a.minHeight))b=Math.max(160,a.minWidth),
c=Math.max(90,a.minHeight);a.maxWidth=b;a.maxHeight=c},hg="mr.mirror.Settings.Overrides";var mg=function(a,b){this.type=a;this.data=b},og=function(a){a=JSON.parse(a);if(!a.type)throw Error("Invalid message");return new mg(a.type,a.data)},pg=function(a,b,c,d,e){this.description=a;this.settings=b||null;this.mediaConstraints=c||null;this.presentationUrl=d||null;this.presentationId=e||null};var sg=function(a,b){this.j=Pa("cv2.PeerConnection");this.X=qg;this.a=rg(this,b);this.l=this.a.createDataChannel(a,{reliable:!1});this.B=new kb;this.u=!1;this.g=0;this.f=null;this.v=this.h=0;this.b=!1;this.A=function(){};this.m=function(){};this.w=function(){};this.s=function(){}},tg=function(a,b){a.m=b},ug=function(a,b){a.w=b},vg=function(a,b){a.s=b},wg=function(a,b){a.A=b},xg=function(a,b){a.l.onmessage=function(a){b(a.data)}},yg=function(a){var b={};b.iceServers=[{url:"stun:stun.l.google.com:19302"}].concat(a);
return b},rg=function(a,b){var c=yg(b);b=new webkitRTCPeerConnection(c);b.onicecandidate=a.F.bind(a);b.a=a.K.bind(a);b.oniceconnectionstatechange=a.H.bind(a);a.j.info(function(){return"Created webkitRTCPeerConnnection with config: "+JSON.stringify(c)});return b};sg.prototype.start=function(){this.b||(this.b=!0,zg(this))};sg.prototype.stop=function(){this.j.info("Stopping peer connection...");this.b&&(this.b=!1,"closed"!=this.a.signalingState&&this.a.close());this.a=null};
var zg=function(a){a.j.info("Sending offer to peer.");a.h=Date.now();a.a.createOffer(a.I.bind(a),function(b){v(a.j,"Error creating offer.",b)},a.X);a.B.a.then(function(b){a.A(b)})};sg.prototype.I=function(a){var b=this;this.j.info(function(){return"Setting local description: "+JSON.stringify(a)});this.a.setLocalDescription(a,function(){b.j.info("Local description set successfully")},function(a){v(b.j,"Error setting local description.",a)})};
var Ag=function(a,b){w(a.j,function(){return"<===: "+JSON.stringify(b)});var c=new RTCSessionDescription(b);a.j.info(function(){return"Setting remote description: "+JSON.stringify(c)});a.a.setRemoteDescription(c,function(){a.j.info("Remote description set successfully.")},function(b){v(a.j,"Error setting remote description.",b)})};
sg.prototype.F=function(a){var b=this;a.candidate?(this.g++,this.v=Date.now(),1==this.g?this.f=setTimeout(function(){b.j.info("ICE candidate gathering timed out.");b.f=null;Bg(b)},5E3):this.u&&v(this.j,"Received ICE candidate after resolving session description.")):(this.j.info("End of ICE candidates."),$a("MediaRouter.WebRtc.IceCandidateGathering.Duration.Reported",Date.now()-this.h),Bg(this),0<this.g&&$a("MediaRouter.WebRtc.IceCandidateGathering.Duration.Real",this.v-this.h))};
sg.prototype.K=function(){"completed"==this.a.iceGatheringState&&Bg(this)};var Bg=function(a){clearTimeout(a.f);a.f=null;if(!a.u){a.j.info("Resolving sesion description after gathering "+a.g+" ICE candidates.");var b=a.a.localDescription;a.B.resolve({type:b.type,sdp:b.sdp});a.u=!0}};
sg.prototype.H=function(a){var b=this;if(this.a){var c=this.a.iceConnectionState;this.j.info("New ICE connection state: "+c+".");"connected"==c?this.m("iceconnected"):"completed"==c?this.m("icecompleted"):"failed"==c?(v(this.j,function(){return"Ice connection failed: "+JSON.stringify(a)}),this.w("icefailed")):"closed"==c?this.s("iceclosed"):"disconnected"==c&&(v(this.j,"Ice connection state is bad."),this.b&&(this.j.info("Restarting ICE."),this.a.createOffer(this.I.bind(this),function(a){v(b.j,"Error creating new offer.",
a)},Cg)))}};var qg={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},Cg={mandatory:{IceRestart:!0,OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}};var Dg=window.localStorage,Eg=0,Gg=function(a){return(a=window.localStorage.getItem(Fg(a,!1)))?JSON.parse(a):null},Hg=function(a){return(a=window.localStorage.getItem(Fg(a,!0)))?JSON.parse(a):null},Jg=function(a){if(Ig.has(a.ha()))throw Error("Duplicate instance name "+a.ha());Ig.set(a.ha(),a);a.Da()},Pg=function(a){for(var b=0,c=ja(Object.keys(Dg)),d=c.next();!d.done;d=c.next()){d=d.value;var e=d.length+window.localStorage.getItem(d).length;d.startsWith("mr.")?Eg+=e:b+=e}Kg=a;(window.localStorage.getItem("version")&&
window.localStorage.getItem("version")!==chrome.runtime.getManifest().version||Lg(a))&&Mg();Ng.info("initialize: "+Eg+" chars used, "+b+" other chars");chrome.runtime.onSuspend.addListener(Og)},Kg=null,Ng=Pa("mr.PersistentDataManager"),Ig=new Map,Fg=function(a,b){return"mr."+(b?"persistent.":"temp.")+a.ha()},Lg=function(a){return!!window.localStorage.getItem("mrInstanceId")&&window.localStorage.getItem("mrInstanceId")!==a},Og=function(){Ng.info("onSuspend");Qg("version",chrome.runtime.getManifest().version);
Kg&&Qg("mrInstanceId",Kg);for(var a=Ig.get("LogManager"),b=ja(Ig),c=b.next();!c.done;c=b.next())c=ja(c.value),c.next(),c=c.next().value,c!=a&&Rg(c);a&&Rg(a)},Rg=function(a){try{var b=a.xa();b&&void 0!=b[0]&&Qg(Fg(a,!1),JSON.stringify(b[0]));b&&void 0!=b[1]&&Qg(Fg(a,!0),JSON.stringify(b[1]))}catch(c){Ng.error("Error while saving data for "+a.ha()+": "+c.message)}},Qg=function(a,b){var c=window.localStorage.getItem(a);c=null!=c?b.length-c.length:a.length+b.length;52E5<Eg+c&&(v(Ng,"Unable to write "+
c+" chars"),Mg());if(52E5<Eg+c)throw Ng.error("Unable to write "+c+" chars after clearing temporary"),Error("Setting the value of '"+a+"' would exceed the quota, according to accounting.");try{window.localStorage.setItem(a,b)}catch(d){throw Error("Setting the value of '"+a+"' would exceed the quota, according to the browser.");}Eg+=c},Sg=function(a){a=0==a.size%2?new Blob([a,new Uint8Array([0,0])]):new Blob([a,new Uint8Array([1])]);return new Promise(function(b,c){var d=new FileReader;d.onloadend=
function(){if(d.error)c(d.error);else try{for(var a=d.result,f=[],g=0,l=a.byteLength;g<l;g+=8192)f.push(String.fromCharCode.apply(null,new Uint16Array(a,g,Math.min(l-g,8192)/2)));Qg("mr.temp.mirror.cast.Service.eventsBlob",f.join(""));b()}catch(r){c(r)}};d.readAsArrayBuffer(a)})},Mg=function(){for(var a=ja(Object.keys(Dg)),b=a.next();!b.done;b=a.next())b=b.value,b.startsWith("mr.temp.")&&(Eg-=b.length+window.localStorage.getItem(b).length,delete window.localStorage[b]);Ng.info("removeTemporary_: "+
Eg+" chars used")};var Tg=function(a,b,c){this.g=c;this.f=a;this.l=b;this.b=0;this.a=null};Tg.prototype.get=function(){if(0<this.b){this.b--;var a=this.a;this.a=a.next;a.next=null}else a=this.f();return a};var Ug=function(a,b){a.l(b);a.b<a.g&&(a.b++,b.next=a.a,a.a=b)};var Vg=function(a){return function(){return a}},Wg=Vg(!1),Xg=Vg(!0),Yg=function(a){return a},Zg=function(a){return function(){throw Error(a);}},$g=function(a){var b=b||0;return function(){return a.apply(this,Array.prototype.slice.call(arguments,0,b))}};var ah=function(a){sa.setTimeout(function(){throw a;},0)},bh,ch=function(){var a=sa.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!id("Presto")&&(a=function(){var a=document.createElement("IFRAME");a.style.display="none";a.src="";document.documentElement.appendChild(a);var b=a.contentWindow;a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host;
a=p(function(a){if(("*"==d||a.origin==d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&!id("Trident")&&!id("MSIE")){var b=new a,c={},d=c;b.port1.onmessage=function(){if(m(c.next)){c=c.next;var a=c.mf;c.mf=null;a()}};return function(a){d.next={mf:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?
function(a){var b=document.createElement("SCRIPT");b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};document.documentElement.appendChild(b)}:function(a){sa.setTimeout(a,0)}};var dh=function(){this.b=this.a=null},fh=new Tg(function(){return new eh},function(a){a.reset()},100);dh.prototype.add=function(a,b){var c=fh.get();c.set(a,b);this.b?this.b.next=c:this.a=c;this.b=c};dh.prototype.remove=function(){var a=null;this.a&&(a=this.a,this.a=this.a.next,this.a||(this.b=null),a.next=null);return a};var eh=function(){this.next=this.scope=this.a=null};eh.prototype.set=function(a,b){this.a=a;this.scope=b;this.next=null};
eh.prototype.reset=function(){this.next=this.scope=this.a=null};var kh=function(a,b){gh||hh();ih||(gh(),ih=!0);jh.add(a,b)},gh,hh=function(){if(-1!=String(sa.Promise).indexOf("[native code]")){var a=sa.Promise.resolve(void 0);gh=function(){a.then(lh)}}else gh=function(){var a=lh;!Ca(sa.setImmediate)||sa.Window&&sa.Window.prototype&&!id("Edge")&&sa.Window.prototype.setImmediate==sa.setImmediate?(bh||(bh=ch()),bh(a)):sa.setImmediate(a)}},ih=!1,jh=new dh,lh=function(){for(var a;a=jh.remove();){try{a.a.call(a.scope)}catch(b){ah(b)}Ug(fh,a)}ih=!1};var mh=function(a){if("undefined"==typeof a)return"undefined";if(null==a)return"NULL";var b=[],c;for(c in a)if(!Ca(a[c])){var d=c+" = ";try{d+=a[c]}catch(e){d+="*** "+e+" ***"}b.push(d)}return b.join("\n")},nh=function(a){var b=[],c=[],d={},e=function(a,g){var f=g+"  ";try{if(m(a))if(null===a)b.push("NULL");else if(ta(a))b.push('"'+a.replace(/\n/g,"\n"+g)+'"');else if(Ca(a))b.push(String(a).replace(/\n/g,"\n"+g));else if(Da(a)){a[Ea]||c.push(a);var r=a[Ea]||(a[Ea]=++Ga);if(d[r])b.push("*** reference loop detected (id="+
r+") ***");else{d[r]=!0;b.push("{");for(var u in a)Ca(a[u])||(b.push("\n"),b.push(f),b.push(u+" = "),e(a[u],f));b.push("\n"+g+"}");delete d[r]}}else b.push(a);else b.push("undefined")}catch(z){b.push("*** "+z+" ***")}};e(a,"");for(a=0;a<c.length;a++)Fa(c[a]);return b.join("")},oh=function(a){var b=oh;var c=Error();if(Error.captureStackTrace)Error.captureStackTrace(c,b),b=String(c.stack);else{try{throw c;}catch(e){c=e}b=(b=c.stack)?String(b):null}if(b)return b;b=[];c=arguments.callee.caller;for(var d=
0;c&&(!a||d<a);){b.push(ph(c));b.push("()\n");try{c=c.caller}catch(e){b.push("[exception trying to get caller]\n");break}d++;if(50<=d){b.push("[...long stack...]");break}}a&&d>=a?b.push("[...reached max depth limit...]"):b.push("[end]");return b.join("")},ph=function(a){if(qh[a])return qh[a];a=String(a);if(!qh[a]){var b=/function ([^\(]+)/.exec(a);qh[a]=b?b[1]:"[Anonymous]"}return qh[a]},qh={},rh=Object.freeze||function(a){return a};var sh=function(a,b,c,d,e){this.reset(a,b,c,d,e)};sh.prototype.a=null;var th=0;sh.prototype.reset=function(a,b,c,d,e){"number"==typeof e||th++;this.l=d||Ka();this.b=a;this.g=b;this.f=c;delete this.a};sh.prototype.getMessage=function(){return this.g};var uh=function(a){this.l=a;this.a=this.g=this.b=this.f=null},vh=function(a,b){this.name=a;this.value=b};vh.prototype.toString=function(){return this.name};var wh=new vh("SEVERE",1E3),xh=new vh("WARNING",900),yh=new vh("INFO",800),zh=new vh("CONFIG",700),Ah=new vh("FINE",500),Bh=new vh("FINER",400),Ch=new vh("ALL",0);uh.prototype.getName=function(){return this.l};uh.prototype.getChildren=function(){this.g||(this.g={});return this.g};
var Dh=function(a){if(a.b)return a.b;if(a.f)return Dh(a.f);Hb("Root logger has no level set.");return null};uh.prototype.log=function(a,b,c){a.value>=Dh(this).value&&(Ca(b)&&(b=b()),a=new sh(a,String(b),this.l),c&&(a.a=c),Eh(this,a))};uh.prototype.info=function(a,b){this.log(yh,a,b)};uh.prototype.config=function(a,b){this.log(zh,a,b)};uh.prototype.logRecord=function(a){a.b.value>=Dh(this).value&&Eh(this,a)};
var Eh=function(a,b){var c="log:"+b.getMessage(),d=sa.console;d&&d.timeStamp&&d.timeStamp(c);for((d=sa.msWriteProfilerMark)&&d(c);a;){d=a;var e=b;if(d.a)for(var f=0;c=d.a[f];f++)c(e);a=a.f}},Fh={},Gh=null,Hh=function(){Gh||(Gh=new uh(""),Fh[""]=Gh,Gh.b=zh)},Ih=function(a){Hh();var b;if(!(b=Fh[a])){b=new uh(a);var c=a.lastIndexOf("."),d=a.substr(c+1);c=Ih(a.substr(0,c));c.getChildren()[d]=b;b.f=c;Fh[a]=b}return b};var Jh=function(){this.u=this.u;this.X=this.X};Jh.prototype.u=!1;Jh.prototype.wa=function(){this.u||(this.u=!0,this.W())};Jh.prototype.l=function(a){Kh(this,Ja(Lh,a))};var Kh=function(a,b){a.u?m(void 0)?b.call(void 0):b():(a.X||(a.X=[]),a.X.push(m(void 0)?p(b,void 0):b))};Jh.prototype.W=function(){if(this.X)for(;this.X.length;)this.X.shift()()};var Lh=function(a){a&&"function"==typeof a.wa&&a.wa()},Nh=function(a){for(var b=0,c=arguments.length;b<c;++b){var d=arguments[b];Ba(d)?Nh.apply(null,d):Lh(d)}};var Oh=!Bd||9<=Number(Xd),Ph=Bd&&!Wd("9");!Ed||Wd("528");Dd&&Wd("1.9b")||Bd&&Wd("8")||Ad&&Wd("9.5")||Ed&&Wd("528");Dd&&!Wd("8")||Bd&&Wd("9");var Qh=function(){if(!sa.addEventListener||!Object.defineProperty)return!1;var a=!1,b=Object.defineProperty({},"passive",{get:function(){a=!0}});sa.addEventListener("test",wa,b);sa.removeEventListener("test",wa,b);return a}();var A=function(a,b){this.type=a;this.b=this.target=b;this.ji=!0};A.prototype.g=function(){this.ji=!1};var Rh=function(a,b){A.call(this,a?a.type:"");this.relatedTarget=this.b=this.target=null;this.button=this.screenY=this.screenX=this.clientY=this.clientX=0;this.key="";this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1;this.state=null;this.pointerId=0;this.pointerType="";this.a=null;a&&this.init(a,b)};t(Rh,A);var Sh=rh({2:"touch",3:"pen",4:"mouse"});
Rh.prototype.init=function(a,b){var c=this.type=a.type,d=a.changedTouches?a.changedTouches[0]:null;this.target=a.target||a.srcElement;this.b=b;(b=a.relatedTarget)?Dd&&(wd(b,"nodeName")||(b=null)):"mouseover"==c?b=a.fromElement:"mouseout"==c&&(b=a.toElement);this.relatedTarget=b;null===d?(this.clientX=void 0!==a.clientX?a.clientX:a.pageX,this.clientY=void 0!==a.clientY?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0):(this.clientX=void 0!==d.clientX?d.clientX:d.pageX,this.clientY=
void 0!==d.clientY?d.clientY:d.pageY,this.screenX=d.screenX||0,this.screenY=d.screenY||0);this.button=a.button;this.key=a.key||"";this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.pointerId=a.pointerId||0;this.pointerType=ta(a.pointerType)?a.pointerType:Sh[a.pointerType]||"";this.state=a.state;this.a=a;a.defaultPrevented&&this.g()};
Rh.prototype.g=function(){Rh.aa.g.call(this);var a=this.a;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,Ph)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};var Th="closure_listenable_"+(1E6*Math.random()|0),Uh=function(a){return!(!a||!a[Th])},Vh=0;var Wh=function(a,b,c,d,e){this.listener=a;this.proxy=null;this.src=b;this.type=c;this.capture=!!d;this.Sa=e;this.key=++Vh;this.removed=this.re=!1},Xh=function(a){a.removed=!0;a.listener=null;a.proxy=null;a.src=null;a.Sa=null};var Yh=function(a){this.src=a;this.a={};this.b=0};Yh.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.a[f];a||(a=this.a[f]=[],this.b++);var g=Zh(a,b,d,e);-1<g?(b=a[g],c||(b.re=!1)):(b=new Wh(b,this.src,f,!!d,e),b.re=c,a.push(b));return b};Yh.prototype.remove=function(a,b,c,d){a=a.toString();if(!(a in this.a))return!1;var e=this.a[a];b=Zh(e,b,c,d);return-1<b?(Xh(e[b]),Zb(e,b),0==e.length&&(delete this.a[a],this.b--),!0):!1};
var $h=function(a,b){var c=b.type;if(!(c in a.a))return!1;var d=$b(a.a[c],b);d&&(Xh(b),0==a.a[c].length&&(delete a.a[c],a.b--));return d};Yh.prototype.removeAll=function(a){a=a&&a.toString();var b=0,c;for(c in this.a)if(!a||c==a){for(var d=this.a[c],e=0;e<d.length;e++)++b,Xh(d[e]);delete this.a[c];this.b--}return b};
var ai=function(a,b,c,d,e){a=a.a[b.toString()];b=-1;a&&(b=Zh(a,c,d,e));return-1<b?a[b]:null},Zh=function(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e];if(!f.removed&&f.listener==b&&f.capture==!!c&&f.Sa==d)return e}return-1};var bi="closure_lm_"+(1E6*Math.random()|0),ci={},di=0,fi=function(a,b,c,d,e){if(d&&d.once)return ei(a,b,c,d,e);if(Aa(b)){for(var f=0;f<b.length;f++)fi(a,b[f],c,d,e);return null}c=gi(c);return Uh(a)?a.listen(b,c,Da(d)?!!d.capture:!!d,e):hi(a,b,c,!1,d,e)},hi=function(a,b,c,d,e,f){if(!b)throw Error("Invalid event type");var g=Da(e)?!!e.capture:!!e,l=ii(a);l||(a[bi]=l=new Yh(a));c=l.add(b,c,d,g,f);if(c.proxy)return c;d=ji();c.proxy=d;d.src=a;d.listener=c;if(a.addEventListener)Qh||(e=g),void 0===e&&(e=
!1),a.addEventListener(b.toString(),d,e);else if(a.attachEvent)a.attachEvent(ki(b.toString()),d);else throw Error("addEventListener and attachEvent are unavailable.");di++;return c},ji=function(){var a=li,b=Oh?function(c){return a.call(b.src,b.listener,c)}:function(c){c=a.call(b.src,b.listener,c);if(!c)return c};return b},ei=function(a,b,c,d,e){if(Aa(b)){for(var f=0;f<b.length;f++)ei(a,b[f],c,d,e);return null}c=gi(c);return Uh(a)?mi(a,b,c,Da(d)?!!d.capture:!!d,e):hi(a,b,c,!0,d,e)},ni=function(a,b,
c,d,e){if(Aa(b))for(var f=0;f<b.length;f++)ni(a,b[f],c,d,e);else d=Da(d)?!!d.capture:!!d,c=gi(c),Uh(a)?a.v(b,c,d,e):a&&(a=ii(a))&&(b=ai(a,b,c,d,e))&&oi(b)},oi=function(a){if(n(a)||!a||a.removed)return!1;var b=a.src;if(Uh(b))return $h(b.Eb,a);var c=a.type,d=a.proxy;b.removeEventListener?b.removeEventListener(c,d,a.capture):b.detachEvent&&b.detachEvent(ki(c),d);di--;(c=ii(b))?($h(c,a),0==c.b&&(c.src=null,b[bi]=null)):Xh(a);return!0},pi=function(a){if(a)if(Uh(a))a.Eb&&a.Eb.removeAll(void 0);else if(a=
ii(a)){var b=0,c;for(c in a.a)for(var d=a.a[c].concat(),e=0;e<d.length;++e)oi(d[e])&&++b}},ki=function(a){return a in ci?ci[a]:ci[a]="on"+a},ri=function(a,b,c,d){var e=!0;if(a=ii(a))if(b=a.a[b.toString()])for(b=b.concat(),a=0;a<b.length;a++){var f=b[a];f&&f.capture==c&&!f.removed&&(f=qi(f,d),e=e&&!1!==f)}return e},qi=function(a,b){var c=a.listener,d=a.Sa||a.src;a.re&&oi(a);return c.call(d,b)},li=function(a,b){if(a.removed)return!0;if(!Oh){var c=b||va("window.event");b=new Rh(c,this);var d=!0;if(!(0>
c.keyCode||void 0!=c.returnValue)){a:{var e=!1;if(0==c.keyCode)try{c.keyCode=-1;break a}catch(g){e=!0}if(e||void 0==c.returnValue)c.returnValue=!0}c=[];for(e=b.b;e;e=e.parentNode)c.push(e);a=a.type;for(e=c.length-1;0<=e;e--){b.b=c[e];var f=ri(c[e],a,!0,b);d=d&&f}for(e=0;e<c.length;e++)b.b=c[e],f=ri(c[e],a,!1,b),d=d&&f}return d}return qi(a,new Rh(b,this))},ii=function(a){a=a[bi];return a instanceof Yh?a:null},si="__closure_events_fn_"+(1E9*Math.random()>>>0),gi=function(a){if(Ca(a))return a;a[si]||
(a[si]=function(b){return a.handleEvent(b)});return a[si]};var B=function(){Jh.call(this);this.Eb=new Yh(this);this.oj=this;this.I=null};t(B,Jh);B.prototype[Th]=!0;B.prototype.removeEventListener=function(a,b,c,d){ni(this,a,b,c,d)};
B.prototype.dispatchEvent=function(a){var b,c=this.I;if(c)for(b=[];c;c=c.I)b.push(c);c=this.oj;var d=a.type||a;if(ta(a))a=new A(a,c);else if(a instanceof A)a.target=a.target||c;else{var e=a;a=new A(d,c);Ec(a,e)}e=!0;if(b)for(var f=b.length-1;0<=f;f--){var g=a.b=b[f];e=ti(g,d,!0,a)&&e}g=a.b=c;e=ti(g,d,!0,a)&&e;e=ti(g,d,!1,a)&&e;if(b)for(f=0;f<b.length;f++)g=a.b=b[f],e=ti(g,d,!1,a)&&e;return e};B.prototype.W=function(){B.aa.W.call(this);this.Eb&&this.Eb.removeAll(void 0);this.I=null};
B.prototype.listen=function(a,b,c,d){return this.Eb.add(String(a),b,!1,c,d)};var mi=function(a,b,c,d,e){return a.Eb.add(String(b),c,!0,d,e)};B.prototype.v=function(a,b,c,d){return this.Eb.remove(String(a),b,c,d)};var ti=function(a,b,c,d){b=a.Eb.a[String(b)];if(!b)return!0;b=b.concat();for(var e=!0,f=0;f<b.length;++f){var g=b[f];if(g&&!g.removed&&g.capture==c){var l=g.listener,r=g.Sa||g.src;g.re&&$h(a.Eb,g);e=!1!==l.call(r,d)&&e}}return e&&0!=d.ji};var ui="StopIteration"in sa?sa.StopIteration:{message:"StopIteration",stack:""},vi=function(){};vi.prototype.next=function(){throw ui;};vi.prototype.Ua=function(){return this};
var wi=function(a){if(a instanceof vi)return a;if("function"==typeof a.Ua)return a.Ua(!1);if(Ba(a)){var b=0,c=new vi;c.next=function(){for(;;){if(b>=a.length)throw ui;if(b in a)return a[b++];b++}};return c}throw Error("Not implemented");},xi=function(a,b,c){if(Ba(a))try{x(a,b,c)}catch(d){if(d!==ui)throw d;}else{a=wi(a);try{for(;;)b.call(c,a.next(),void 0,a)}catch(d){if(d!==ui)throw d;}}},yi=function(a,b){a=wi(a);try{for(;!b.call(void 0,a.next(),void 0,a););}catch(c){if(c!==ui)throw c;}},zi=function(a){if(Ba(a))return y(a);
a=wi(a);var b=[];xi(a,function(a){b.push(a)});return b};var Ai=sa.JSON.parse,Bi=sa.JSON.stringify;var Ci=sa.JSON.parse;var Di=function(a,b,c){a&&a.log(b,c,void 0)},Ei=function(a,b,c){a&&a.log(wh,b,c)},C=function(a,b,c){a&&a.log(xh,b,c)},D=function(a,b){a&&a.info(b,void 0)},Fi=function(a,b){a&&a.log(Ah,b,void 0)};var Gi=function(){};Gi.prototype.a=null;var Ii=function(a){var b;(b=a.a)||(b={},Hi(a)&&(b[0]=!0,b[1]=!0),b=a.a=b);return b};var Ji,Ki=function(){};t(Ki,Gi);var Li=function(a){return(a=Hi(a))?new ActiveXObject(a):new XMLHttpRequest},Hi=function(a){if(!a.b&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var b=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],c=0;c<b.length;c++){var d=b[c];try{return new ActiveXObject(d),a.b=d}catch(e){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed");}return a.b};Ji=new Ki;var Ni=function(a,b){this.b={};this.a=[];this.g=this.f=0;var c=arguments.length;if(1<c){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else a&&Mi(this,a)};h=Ni.prototype;h.da=function(){return this.f};h.S=function(){Oi(this);for(var a=[],b=0;b<this.a.length;b++)a.push(this.b[this.a[b]]);return a};h.Qa=function(){Oi(this);return this.a.concat()};h.Va=function(a){return Pi(this.b,a)};
h.Nc=function(a){for(var b=0;b<this.a.length;b++){var c=this.a[b];if(Pi(this.b,c)&&this.b[c]==a)return!0}return!1};h.equals=function(a,b){if(this===a)return!0;if(this.f!=a.da())return!1;b=b||Qi;Oi(this);for(var c,d=0;c=this.a[d];d++)if(!b(this.get(c),a.get(c)))return!1;return!0};var Qi=function(a,b){return a===b};Ni.prototype.rb=function(){return 0==this.f};Ni.prototype.clear=function(){this.b={};this.g=this.f=this.a.length=0};
Ni.prototype.remove=function(a){return Pi(this.b,a)?(delete this.b[a],this.f--,this.g++,this.a.length>2*this.f&&Oi(this),!0):!1};var Oi=function(a){if(a.f!=a.a.length){for(var b=0,c=0;b<a.a.length;){var d=a.a[b];Pi(a.b,d)&&(a.a[c++]=d);b++}a.a.length=c}if(a.f!=a.a.length){var e={};for(c=b=0;b<a.a.length;)d=a.a[b],Pi(e,d)||(a.a[c++]=d,e[d]=1),b++;a.a.length=c}};Ni.prototype.get=function(a,b){return Pi(this.b,a)?this.b[a]:b};
Ni.prototype.set=function(a,b){Pi(this.b,a)||(this.f++,this.a.push(a),this.g++);this.b[a]=b};var Mi=function(a,b){if(b instanceof Ni){var c=b.Qa();b=b.S()}else c=tc(b),b=sc(b);for(var d=0;d<c.length;d++)a.set(c[d],b[d])};Ni.prototype.forEach=function(a,b){for(var c=this.Qa(),d=0;d<c.length;d++){var e=c[d],f=this.get(e);a.call(b,f,e,this)}};Ni.prototype.clone=function(){return new Ni(this)};var Ri=function(a){Oi(a);for(var b={},c=0;c<a.a.length;c++){var d=a.a[c];b[d]=a.b[d]}return b};
Ni.prototype.Ua=function(a){Oi(this);var b=0,c=this.g,d=this,e=new vi;e.next=function(){if(c!=d.g)throw Error("The map has changed since the iterator was created");if(b>=d.a.length)throw ui;var e=d.a[b++];return a?e:d.b[e]};return e};var Pi=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var Si=function(a){return a.da&&"function"==typeof a.da?a.da():Ba(a)||ta(a)?a.length:rc(a)},Ti=function(a){if(a.S&&"function"==typeof a.S)return a.S();if(ta(a))return a.split("");if(Ba(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return sc(a)},Ui=function(a){if(a.Qa&&"function"==typeof a.Qa)return a.Qa();if(!a.S||"function"!=typeof a.S){if(Ba(a)||ta(a)){var b=[];a=a.length;for(var c=0;c<a;c++)b.push(c);return b}return tc(a)}},Vi=function(a){return a.rb&&"function"==typeof a.rb?a.rb():
Ba(a)||ta(a)?0==a.length:wc(a)},Wi=function(a,b,c){if(a.forEach&&"function"==typeof a.forEach)a.forEach(b,c);else if(Ba(a)||ta(a))x(a,b,c);else for(var d=Ui(a),e=Ti(a),f=e.length,g=0;g<f;g++)b.call(c,e[g],d&&d[g],a)},Xi=function(a,b,c){if("function"==typeof a.map)return a.map(b,c);if(Ba(a)||ta(a))return Nb(a,b,c);var d=Ui(a),e=Ti(a),f=e.length;if(d){var g={};for(var l=0;l<f;l++)g[d[l]]=b.call(c,e[l],d[l],a)}else for(g=[],l=0;l<f;l++)g[l]=b.call(c,e[l],void 0,a);return g},Yi=function(a,b){if("function"==
typeof a.every)return a.every(b,void 0);if(Ba(a)||ta(a))return Qb(a,b,void 0);for(var c=Ui(a),d=Ti(a),e=d.length,f=0;f<e;f++)if(!b.call(void 0,d[f],c&&c[f],a))return!1;return!0};var Zi=function(a){a.prototype.then=a.prototype.then;a.prototype.$goog_Thenable=!0},$i=function(a){if(!a)return!1;try{return!!a.$goog_Thenable}catch(b){return!1}};var cj=function(a,b){this.a=0;this.m=void 0;this.g=this.b=this.f=null;this.l=this.h=!1;if(a!=wa)try{var c=this;a.call(b,function(a){aj(c,2,a)},function(a){if(!(a instanceof bj))try{if(a instanceof Error)throw a;throw Error("Promise rejected.");}catch(e){}aj(c,3,a)})}catch(d){aj(this,3,d)}},dj=function(){this.next=this.g=this.b=this.l=this.a=null;this.f=!1};dj.prototype.reset=function(){this.g=this.b=this.l=this.a=null;this.f=!1};
var ej=new Tg(function(){return new dj},function(a){a.reset()},100),fj=function(a,b,c){var d=ej.get();d.l=a;d.b=b;d.g=c;return d},gj=function(a){if(a instanceof cj)return a;var b=new cj(wa);aj(b,2,a);return b},hj=function(a){return new cj(function(b,c){c(a)})},jj=function(a,b,c){ij(a,b,c,null)||kh(Ja(b,a))},kj=function(a){return new cj(function(b,c){a.length||b(void 0);for(var d=0,e;d<a.length;d++)e=a[d],jj(e,b,c)})},lj=function(a){return new cj(function(b,c){var d=a.length,e=[];if(d)for(var f=function(a,
c){d--;e[a]=c;0==d&&b(e)},g=function(a){c(a)},l=0,r;l<a.length;l++)r=a[l],jj(r,Ja(f,l),g);else b(e)})},mj=function(a){return new cj(function(b){var c=a.length,d=[];if(c)for(var e=function(a,e,f){c--;d[a]=e?{dc:!0,value:f}:{dc:!1,reason:f};0==c&&b(d)},f=0,g;f<a.length;f++)g=a[f],jj(g,Ja(e,f,!0),Ja(e,f,!1));else b(d)})},xc=function(){var a,b,c=new cj(function(c,e){a=c;b=e});return new nj(c,a,b)};cj.prototype.then=function(a,b,c){return oj(this,Ca(a)?a:null,Ca(b)?b:null,c)};Zi(cj);
var qj=function(a,b,c){b=fj(b,b,c);b.f=!0;pj(a,b);return a},rj=function(a,b,c){return oj(a,null,b,c)};cj.prototype.cancel=function(a){0==this.a&&kh(function(){var b=new bj(a);sj(this,b)},this)};
var sj=function(a,b){if(0==a.a)if(a.f){var c=a.f;if(c.b){for(var d=0,e=null,f=null,g=c.b;g&&(g.f||(d++,g.a==a&&(e=g),!(e&&1<d)));g=g.next)e||(f=g);e&&(0==c.a&&1==d?sj(c,b):(f?(d=f,d.next==c.g&&(c.g=d),d.next=d.next.next):tj(c),uj(c,e,3,b)))}a.f=null}else aj(a,3,b)},pj=function(a,b){a.b||2!=a.a&&3!=a.a||vj(a);a.g?a.g.next=b:a.b=b;a.g=b},oj=function(a,b,c,d){var e=fj(null,null,null);e.a=new cj(function(a,g){e.l=b?function(c){try{var e=b.call(d,c);a(e)}catch(u){g(u)}}:a;e.b=c?function(b){try{var e=c.call(d,
b);!m(e)&&b instanceof bj?g(b):a(e)}catch(u){g(u)}}:g});e.a.f=a;pj(a,e);return e.a};cj.prototype.v=function(a){this.a=0;aj(this,2,a)};cj.prototype.s=function(a){this.a=0;aj(this,3,a)};
var aj=function(a,b,c){0==a.a&&(a===c&&(b=3,c=new TypeError("Promise cannot resolve to itself")),a.a=1,ij(c,a.v,a.s,a)||(a.m=c,a.a=b,a.f=null,vj(a),3!=b||c instanceof bj||wj(a,c)))},ij=function(a,b,c,d){if(a instanceof cj)return pj(a,fj(b||wa,c||null,d)),!0;if($i(a))return a.then(b,c,d),!0;if(Da(a))try{var e=a.then;if(Ca(e))return xj(a,e,b,c,d),!0}catch(f){return c.call(d,f),!0}return!1},xj=function(a,b,c,d,e){var f=!1,g=function(a){f||(f=!0,c.call(e,a))},l=function(a){f||(f=!0,d.call(e,a))};try{b.call(a,
g,l)}catch(r){l(r)}},vj=function(a){a.h||(a.h=!0,kh(a.u,a))},tj=function(a){var b=null;a.b&&(b=a.b,a.b=b.next,b.next=null);a.b||(a.g=null);return b};cj.prototype.u=function(){for(var a;a=tj(this);)uj(this,a,this.a,this.m);this.h=!1};
var uj=function(a,b,c,d){if(3==c&&b.b&&!b.f)for(;a&&a.l;a=a.f)a.l=!1;if(b.a)b.a.f=null,yj(b,c,d);else try{b.f?b.l.call(b.g):yj(b,c,d)}catch(e){zj.call(null,e)}Ug(ej,b)},yj=function(a,b,c){2==b?a.l.call(a.g,c):a.b&&a.b.call(a.g,c)},wj=function(a,b){a.l=!0;kh(function(){a.l&&zj.call(null,b)})},zj=ah,bj=function(a){Eb.call(this,a)};t(bj,Eb);bj.prototype.name="cancel";var nj=function(a,b,c){this.a=a;this.resolve=b;this.reject=c};var Aj=function(a,b){B.call(this);this.b=a||1;this.a=b||sa;this.f=p(this.Bm,this);this.g=Ka()};t(Aj,B);h=Aj.prototype;h.enabled=!1;h.vb=null;h.Bm=function(){if(this.enabled){var a=Ka()-this.g;0<a&&a<.8*this.b?this.vb=this.a.setTimeout(this.f,this.b-a):(this.vb&&(this.a.clearTimeout(this.vb),this.vb=null),this.dispatchEvent("tick"),this.enabled&&(this.vb=this.a.setTimeout(this.f,this.b),this.g=Ka()))}};h.start=function(){this.enabled=!0;this.vb||(this.vb=this.a.setTimeout(this.f,this.b),this.g=Ka())};
h.stop=function(){this.enabled=!1;this.vb&&(this.a.clearTimeout(this.vb),this.vb=null)};h.W=function(){Aj.aa.W.call(this);this.stop();delete this.a};
var Bj=function(a,b,c){if(Ca(a))c&&(a=p(a,c));else if(a&&"function"==typeof a.handleEvent)a=p(a.handleEvent,a);else throw Error("Invalid listener argument");return 2147483647<Number(b)?-1:sa.setTimeout(a,b||0)},Cj=function(a){sa.clearTimeout(a)},Dj=function(a){var b=null;return rj(new cj(function(c,d){b=Bj(function(){c(void 0)},a);-1==b&&d(Error("Failed to schedule timer."))}),function(a){Cj(b);throw a;})};var Ej=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/,Fj=function(a,b){if(a){a=a.split("&");for(var c=0;c<a.length;c++){var d=a[c].indexOf("="),e=null;if(0<=d){var f=a[c].substring(0,d);e=a[c].substring(d+1)}else f=a[c];b(f,e?decodeURIComponent(e.replace(/\+/g," ")):"")}}},Gj=function(a,b,c){c=null!=c?"="+encodeURIComponent(String(c)):"";if(b+=c){c=a.indexOf("#");0>c&&(c=a.length);var d=a.indexOf("?");if(0>d||d>c){d=c;var e=""}else e=
a.substring(d+1,c);a=[a.substr(0,d),e,a.substr(c)];c=a[1];a[1]=b?c?c+"&"+b:b:c;a=a[0]+(a[1]?"?"+a[1]:"")+a[2]}return a},Hj=/#|$/,Ij=function(a,b){var c=a.search(Hj);a:{var d=0;for(var e=b.length;0<=(d=a.indexOf(b,d))&&d<c;){var f=a.charCodeAt(d-1);if(38==f||63==f)if(f=a.charCodeAt(d+e),!f||61==f||38==f||35==f)break a;d+=e+1}d=-1}if(0>d)return null;e=a.indexOf("&",d);if(0>e||e>c)e=c;d+=b.length+1;return decodeURIComponent(a.substr(d,e-d).replace(/\+/g," "))},Jj=function(a,b){var c=a.length-1;0<=c&&
a.indexOf("/",c)==c&&(a=a.substr(0,a.length-1));0==b.lastIndexOf("/",0)&&(b=b.substr(1));return zb(a,"/",b)};var Kj=function(a){B.call(this);this.headers=new Ni;this.M=a||null;this.b=!1;this.K=this.a=null;this.ea=this.F="";this.m=0;this.f="";this.g=this.ba=this.B=this.R=!1;this.h=0;this.w=null;this.s="";this.H=this.A=!1};t(Kj,B);Kj.prototype.j=Ih("goog.net.XhrIo");var Lj=/^https?$/i,Mj=["POST","PUT"],Nj=[],Oj=function(a,b,c,d,e,f,g){var l=new Kj;Nj.push(l);b&&l.listen("complete",b);mi(l,"ready",l.ka);f&&(l.h=Math.max(0,f));g&&(l.A=g);l.send(a,c,d,e);return l};Kj.prototype.ka=function(){this.wa();$b(Nj,this)};
Kj.prototype.send=function(a,b,c,d){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.F+"; newUri="+a);b=b?b.toUpperCase():"GET";this.F=a;this.f="";this.m=0;this.ea=b;this.R=!1;this.b=!0;this.a=this.M?Li(this.M):Li(Ji);this.K=this.M?Ii(this.M):Ii(Ji);this.a.onreadystatechange=p(this.ma,this);try{Fi(this.j,Pj(this,"Opening Xhr")),this.ba=!0,this.a.open(b,String(a),!0),this.ba=!1}catch(f){Fi(this.j,Pj(this,"Error opening Xhr: "+f.message));Qj(this,f);return}a=c||"";
var e=this.headers.clone();d&&Wi(d,function(a,b){e.set(b,a)});d=Sb(e.Qa(),Rj);c=sa.FormData&&a instanceof sa.FormData;!Ub(Mj,b)||d||c||e.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");e.forEach(function(a,b){this.a.setRequestHeader(b,a)},this);this.s&&(this.a.responseType=this.s);"withCredentials"in this.a&&this.a.withCredentials!==this.A&&(this.a.withCredentials=this.A);try{Sj(this),0<this.h&&(this.H=Tj(this.a),Fi(this.j,Pj(this,"Will abort after "+this.h+"ms if incomplete, xhr2 "+
this.H)),this.H?(this.a.timeout=this.h,this.a.ontimeout=p(this.na,this)):this.w=Bj(this.na,this.h,this)),Fi(this.j,Pj(this,"Sending request")),this.B=!0,this.a.send(a),this.B=!1}catch(f){Fi(this.j,Pj(this,"Send error: "+f.message)),Qj(this,f)}};var Tj=function(a){return Bd&&Wd(9)&&n(a.timeout)&&m(a.ontimeout)},Rj=function(a){return lb("Content-Type",a)};
Kj.prototype.na=function(){"undefined"!=typeof ra&&this.a&&(this.f="Timed out after "+this.h+"ms, aborting",this.m=8,Fi(this.j,Pj(this,this.f)),this.dispatchEvent("timeout"),this.abort(8))};var Qj=function(a,b){a.b=!1;a.a&&(a.g=!0,a.a.abort(),a.g=!1);a.f=b;a.m=5;Uj(a);Vj(a)},Uj=function(a){a.R||(a.R=!0,a.dispatchEvent("complete"),a.dispatchEvent("error"))};
Kj.prototype.abort=function(a){this.a&&this.b&&(Fi(this.j,Pj(this,"Aborting")),this.b=!1,this.g=!0,this.a.abort(),this.g=!1,this.m=a||7,this.dispatchEvent("complete"),this.dispatchEvent("abort"),Vj(this))};Kj.prototype.W=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Vj(this,!0));Kj.aa.W.call(this)};Kj.prototype.ma=function(){this.u||(this.ba||this.B||this.g?Wj(this):this.la())};Kj.prototype.la=function(){Wj(this)};
var Wj=function(a){if(a.b&&"undefined"!=typeof ra)if(a.K[1]&&4==Xj(a)&&2==a.Ca())Fi(a.j,Pj(a,"Local request error detected and ignored"));else if(a.B&&4==Xj(a))Bj(a.ma,0,a);else if(a.dispatchEvent("readystatechange"),4==Xj(a)){Fi(a.j,Pj(a,"Request complete"));a.b=!1;try{if(Yj(a))a.dispatchEvent("complete"),a.dispatchEvent("success");else{a.m=6;try{var b=2<Xj(a)?a.a.statusText:""}catch(c){Fi(a.j,"Can not get status: "+c.message),b=""}a.f=b+" ["+a.Ca()+"]";Uj(a)}}finally{Vj(a)}}},Vj=function(a,b){if(a.a){Sj(a);
var c=a.a,d=a.K[0]?wa:null;a.a=null;a.K=null;b||a.dispatchEvent("ready");try{c.onreadystatechange=d}catch(e){Ei(a.j,"Problem encountered resetting onreadystatechange: "+e.message)}}},Sj=function(a){a.a&&a.H&&(a.a.ontimeout=null);n(a.w)&&(Cj(a.w),a.w=null)},Yj=function(a){var b=a.Ca();a:switch(b){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var c=!0;break a;default:c=!1}if(!c){if(b=0===b)a=String(a.F).match(Ej)[1]||null,!a&&sa.self&&sa.self.location&&(a=sa.self.location.protocol,
a=a.substr(0,a.length-1)),b=!Lj.test(a?a.toLowerCase():"");c=b}return c},Xj=function(a){return a.a?a.a.readyState:0};Kj.prototype.Ca=function(){try{return 2<Xj(this)?this.a.status:-1}catch(a){return-1}};
var Zj=function(a){try{return a.a?a.a.responseText:""}catch(b){return Fi(a.j,"Can not get responseText: "+b.message),""}},ak=function(a){if(a.a)return Ci(a.a.responseText)},bk=function(a){try{if(!a.a)return null;if("response"in a.a)return a.a.response;switch(a.s){case "":case "text":return a.a.responseText;case "arraybuffer":if("mozResponseArrayBuffer"in a.a)return a.a.mozResponseArrayBuffer}Ei(a.j,"Response type "+a.s+" is not supported on this browser");return null}catch(b){return Fi(a.j,"Can not get response: "+
b.message),null}};Kj.prototype.getResponseHeader=function(a){if(this.a&&4==Xj(this))return a=this.a.getResponseHeader(a),null===a?void 0:a};var ck=function(a){var b={};a=(a.a&&4==Xj(a)?a.a.getAllResponseHeaders():"").split("\r\n");for(var c=0;c<a.length;c++)if(!nb(a[c])){var d=Db(a[c],": ",2);b[d[0]]=b[d[0]]?b[d[0]]+(", "+d[1]):d[1]}return b},Pj=function(a,b){return b+" ["+a.ea+" "+a.F+" "+a.Ca()+"]"};var dk=function(){},ek=function(a){if(!a.startsWith("urn:x-org.chromium:media:route:"))return null;var b=a.substring(31);if(!b)return null;var c=b.match(/([^/]*)\/([^-/]*)-([^/]*)\/(.*)/);if(!c)return null;b=new dk;b.f=a;a=ja(c);a.next();b.a=a.next().value;b.g=a.next().value;b.l=a.next().value;b.b=a.next().value;return b};dk.prototype.Z=function(){return this.b};var fk=function(a,b,c,d,e){this.id=a;this.sinkId=b;this.mediaSource=c;this.isLocal=d;this.description=e;this.iconUrl=null;this.allowStop=!0;this.customControllerPath=null;this.supportsMediaRouteController=!1;this.controllerType=mojo&&mojo.RouteControllerType&&mojo.RouteControllerType.kNone;this.forDisplay=!0;this.offTheRecord=!1;this.Oc=d;this.isOffscreenPresentation=!1},gk=function(a,b,c,d,e,f){a=d&&If(d)?a:"urn:x-org.chromium:media:route:"+a+"/"+b+"-"+c+"/"+d;return new fk(a,c,d,e,f)};var hk=function(a){this.b=a;this.a=1E3*Math.floor(1E6*Math.random())},ik=function(a){var b=a.a++;0==b&&(b=a.a++);return b};hk.prototype.ha=function(){return"IdGenerator."+this.b};hk.prototype.xa=function(){return[this.a]};hk.prototype.Da=function(){var a=Gg(this);a&&(this.a=a)};var jk=function(a,b,c,d,e){for(var f=[],g=4;g<arguments.length;++g)f[g-4]=arguments[g];var l=this;this.l=a;this.m=b;this.h=c;this.b=d;this.g=f;this.a=!1;this.f=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];return l.Ik.apply(l,[].concat(k(b)))}};h=jk.prototype;h.addListener=function(){this.a||(this.a=!0,this.b.addListener.apply(this.b,[].concat([this.f],k(this.g))))};h.removeListener=function(){this.a&&(this.b.removeListener(this.f),this.a=!1)};
h.Xe=function(a){for(var b=0;b<arguments.length;++b);return!0};h.Ik=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var d=this;Ef(this.l);if(!this.Xe.apply(this,[].concat(k(b))))return!1;Qf(this.h).then(function(a){return a.handleEvent.apply(a,[].concat([d.b],k(b)))});return this.qf()};h.ha=function(){return"mr.EventListener."+this.m};h.xa=function(){return[this.a]};h.Da=function(){Gg(this)&&this.addListener()};h.qf=function(){};var kk={serviceType:"_googlecast._tcp.local"},lk=null,mk=function(){lk||(lk=new jk(7,"CastMdnsEventListener","mr.cast.SinkDiscoveryService",chrome.mdns.onServiceList,kk));return lk},nk=null,ok=function(){nk||(nk="ChromeOS"==nf()?new jk(9,"CastNetworkListChangedEventListener","mr.cast.SinkDiscoveryService",chrome.networkingPrivate.onNetworkListChanged):new jk(8,"CastNetworksChangedEventListener","mr.cast.SinkDiscoveryService",chrome.networkingPrivate.onNetworksChanged));return nk},pk=null,qk=null,
rk=function(){pk||(pk=new jk(2,"CastChannelMessageListener","mr.cast.ChannelService",chrome.cast.channel.onMessage));qk||(qk=new jk(1,"CastChannelErrorListener","mr.cast.ChannelService",chrome.cast.channel.onError));return[pk,qk]};chrome.cast.Ob={CUSTOM_CONTROLLER_SCOPED:"custom_controller_scoped",TAB_AND_ORIGIN_SCOPED:"tab_and_origin_scoped",ORIGIN_SCOPED:"origin_scoped",PAGE_SCOPED:"page_scoped"};q("chrome.cast.AutoJoinPolicy",chrome.cast.Ob);chrome.cast.je={CREATE_SESSION:"create_session",CAST_THIS_TAB:"cast_this_tab"};q("chrome.cast.DefaultActionPolicy",chrome.cast.je);chrome.cast.Yb={VIDEO_OUT:"video_out",AUDIO_OUT:"audio_out",VIDEO_IN:"video_in",AUDIO_IN:"audio_in",MULTIZONE_GROUP:"multizone_group"};
q("chrome.cast.Capability",chrome.cast.Yb);chrome.cast.Pb={CANCEL:"cancel",TIMEOUT:"timeout",API_NOT_INITIALIZED:"api_not_initialized",INVALID_PARAMETER:"invalid_parameter",EXTENSION_NOT_COMPATIBLE:"extension_not_compatible",EXTENSION_MISSING:"extension_missing",RECEIVER_UNAVAILABLE:"receiver_unavailable",SESSION_ERROR:"session_error",CHANNEL_ERROR:"channel_error",LOAD_MEDIA_FAILED:"load_media_failed"};q("chrome.cast.ErrorCode",chrome.cast.Pb);chrome.cast.Jj={AVAILABLE:"available",UNAVAILABLE:"unavailable"};
q("chrome.cast.ReceiverAvailability",chrome.cast.Jj);chrome.cast.Zj={CHROME:"chrome",IOS:"ios",ANDROID:"android"};q("chrome.cast.SenderPlatform",chrome.cast.Zj);chrome.cast.ne={CAST:"cast",DIAL:"dial",HANGOUT:"hangout",CUSTOM:"custom"};q("chrome.cast.ReceiverType",chrome.cast.ne);chrome.cast.Si={RUNNING:"running",STOPPED:"stopped",ERROR:"error"};q("chrome.cast.DialAppState",chrome.cast.Si);chrome.cast.wd={CAST:"cast",STOP:"stop"};q("chrome.cast.ReceiverAction",chrome.cast.wd);
chrome.cast.Kg={CONNECTED:"connected",DISCONNECTED:"disconnected",STOPPED:"stopped"};q("chrome.cast.SessionStatus",chrome.cast.Kg);chrome.cast.Pg={ATTENUATION:"attenuation",FIXED:"fixed",MASTER:"master"};q("chrome.cast.VolumeControlType",chrome.cast.Pg);chrome.cast.Ki=function(a,b,c,d,e){this.sessionRequest=a;this.sessionListener=b;this.receiverListener=c;this.autoJoinPolicy=d||chrome.cast.Ob.TAB_AND_ORIGIN_SCOPED;this.defaultActionPolicy=e||chrome.cast.je.CREATE_SESSION;this.customDialLaunchCallback=null;this.invisibleSender=!1;this.additionalSessionRequests=[]};q("chrome.cast.ApiConfig",chrome.cast.Ki);chrome.cast.Ui=function(a,b){this.appName=a;this.launchParameter=b||null};q("chrome.cast.DialRequest",chrome.cast.Ui);
chrome.cast.tg=function(a,b,c){this.receiver=a;this.appState=b;this.extraData=c||null};q("chrome.cast.DialLaunchData",chrome.cast.tg);chrome.cast.Ti=function(a,b){this.doLaunch=a;this.launchParameter=b||null};q("chrome.cast.DialLaunchResponse",chrome.cast.Ti);chrome.cast.Jg=function(a,b,c){this.appId=a;this.capabilities=Aa(b)?b:[chrome.cast.Yb.VIDEO_OUT,chrome.cast.Yb.AUDIO_OUT];this.requestSessionTimeout=c||chrome.cast.timeout.requestSession;this.dialRequest=this.language=null};
q("chrome.cast.SessionRequest",chrome.cast.Jg);
chrome.cast.bf=function(a,b,c,d){this.label=a;a=b;vb.test(a)&&(-1!=a.indexOf("&")&&(a=a.replace(pb,"&amp;")),-1!=a.indexOf("<")&&(a=a.replace(qb,"&lt;")),-1!=a.indexOf(">")&&(a=a.replace(rb,"&gt;")),-1!=a.indexOf('"')&&(a=a.replace(sb,"&quot;")),-1!=a.indexOf("'")&&(a=a.replace(tb,"&#39;")),-1!=a.indexOf("\x00")&&(a=a.replace(ub,"&#0;")));this.friendlyName=a;this.capabilities=c||[];this.volume=d||null;this.receiverType=chrome.cast.ne.CAST;this.displayStatus=this.isActiveInput=null};
q("chrome.cast.Receiver",chrome.cast.bf);chrome.cast.Kj=function(a,b){this.statusText=a;this.appImages=b;this.showStop=null};q("chrome.cast.ReceiverDisplayStatus",chrome.cast.Kj);chrome.cast.Ng=function(){this.requestSession=6E4;this.sendCustomMessage=this.setReceiverVolume=this.stopSession=this.leaveSession=3E3};q("chrome.cast.Timeout",chrome.cast.Ng);chrome.cast.timeout=new chrome.cast.Ng;q("chrome.cast.timeout",chrome.cast.timeout);chrome.cast.ng="auto-join";chrome.cast.Gg="cast-session_";var sk=function(a,b,c){this.sessionId=a;this.namespaceName=b;this.message=c};var tk={STOP_MEDIA:"STOP",MEDIA_SET_VOLUME:"SET_VOLUME",MEDIA_GET_STATUS:"GET_STATUS"};var uk=function(a,b){this.type="SET_VOLUME";this.requestId=0;this.volume=a;this.expectedVolume=b||null};var vk=function(a){this.type="STOP";this.requestId=0;this.sessionId=a||null};chrome.cast.media.mc={PAUSE:"pause",SEEK:"seek",STREAM_VOLUME:"stream_volume",STREAM_MUTE:"stream_mute"};q("chrome.cast.media.MediaCommand",chrome.cast.media.mc);chrome.cast.media.Bb={GENERIC:0,MOVIE:1,TV_SHOW:2,MUSIC_TRACK:3,PHOTO:4};q("chrome.cast.media.MetadataType",chrome.cast.media.Bb);chrome.cast.media.vd={IDLE:"IDLE",PLAYING:"PLAYING",PAUSED:"PAUSED",BUFFERING:"BUFFERING"};q("chrome.cast.media.PlayerState",chrome.cast.media.vd);
chrome.cast.media.cf={OFF:"REPEAT_OFF",ALL:"REPEAT_ALL",SINGLE:"REPEAT_SINGLE",ALL_AND_SHUFFLE:"REPEAT_ALL_AND_SHUFFLE"};q("chrome.cast.media.RepeatMode",chrome.cast.media.cf);chrome.cast.media.Lj={PLAYBACK_START:"PLAYBACK_START",PLAYBACK_PAUSE:"PLAYBACK_PAUSE"};q("chrome.cast.media.ResumeState",chrome.cast.media.Lj);chrome.cast.media.Lg={BUFFERED:"BUFFERED",LIVE:"LIVE",OTHER:"OTHER"};q("chrome.cast.media.StreamType",chrome.cast.media.Lg);
chrome.cast.media.ej={CANCELLED:"CANCELLED",INTERRUPTED:"INTERRUPTED",FINISHED:"FINISHED",ERROR:"ERROR"};q("chrome.cast.media.IdleReason",chrome.cast.media.ej);chrome.cast.media.lk={TEXT:"TEXT",AUDIO:"AUDIO",VIDEO:"VIDEO"};q("chrome.cast.media.TrackType",chrome.cast.media.lk);chrome.cast.media.ik={SUBTITLES:"SUBTITLES",CAPTIONS:"CAPTIONS",DESCRIPTIONS:"DESCRIPTIONS",CHAPTERS:"CHAPTERS",METADATA:"METADATA"};q("chrome.cast.media.TextTrackType",chrome.cast.media.ik);
chrome.cast.media.ek={NONE:"NONE",OUTLINE:"OUTLINE",DROP_SHADOW:"DROP_SHADOW",RAISED:"RAISED",DEPRESSED:"DEPRESSED"};q("chrome.cast.media.TextTrackEdgeType",chrome.cast.media.ek);chrome.cast.media.jk={NONE:"NONE",NORMAL:"NORMAL",ROUNDED_CORNERS:"ROUNDED_CORNERS"};q("chrome.cast.media.TextTrackWindowType",chrome.cast.media.jk);
chrome.cast.media.fk={SANS_SERIF:"SANS_SERIF",MONOSPACED_SANS_SERIF:"MONOSPACED_SANS_SERIF",SERIF:"SERIF",MONOSPACED_SERIF:"MONOSPACED_SERIF",CASUAL:"CASUAL",CURSIVE:"CURSIVE",SMALL_CAPITALS:"SMALL_CAPITALS"};q("chrome.cast.media.TextTrackFontGenericFamily",chrome.cast.media.fk);chrome.cast.media.gk={NORMAL:"NORMAL",BOLD:"BOLD",BOLD_ITALIC:"BOLD_ITALIC",ITALIC:"ITALIC"};q("chrome.cast.media.TextTrackFontStyle",chrome.cast.media.gk);chrome.cast.media.cj=function(){this.customData=null};q("chrome.cast.media.GetStatusRequest",chrome.cast.media.cj);chrome.cast.media.uj=function(){this.customData=null};q("chrome.cast.media.PauseRequest",chrome.cast.media.uj);chrome.cast.media.wj=function(){this.customData=null};q("chrome.cast.media.PlayRequest",chrome.cast.media.wj);chrome.cast.media.Xj=function(){this.customData=this.resumeState=this.currentTime=null};q("chrome.cast.media.SeekRequest",chrome.cast.media.Xj);
chrome.cast.media.ak=function(){this.customData=null};q("chrome.cast.media.StopRequest",chrome.cast.media.ak);chrome.cast.media.pk=function(a){this.volume=a;this.customData=null};q("chrome.cast.media.VolumeRequest",chrome.cast.media.pk);chrome.cast.media.gj=function(a){this.type="LOAD";this.requestId=0;this.sessionId=null;this.media=a;this.activeTrackIds=null;this.autoplay=!0;this.customData=this.currentTime=null};q("chrome.cast.media.LoadRequest",chrome.cast.media.gj);
chrome.cast.media.Jq=function(a){this.type="PRECACHE";this.requestId=0;this.precacheData=a};chrome.cast.media.Xi=function(a,b){this.requestId=0;this.activeTrackIds=a||null;this.textTrackStyle=b||null};q("chrome.cast.media.EditTracksInfoRequest",chrome.cast.media.Xi);chrome.cast.media.bj=function(){this.metadataType=this.type=chrome.cast.media.Bb.GENERIC;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.title=null};q("chrome.cast.media.GenericMediaMetadata",chrome.cast.media.bj);
chrome.cast.media.jj=function(){this.metadataType=this.type=chrome.cast.media.Bb.MOVIE;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.studio=this.title=null};q("chrome.cast.media.MovieMediaMetadata",chrome.cast.media.jj);chrome.cast.media.mk=function(){this.metadataType=this.type=chrome.cast.media.Bb.TV_SHOW;this.originalAirdate=this.releaseYear=this.images=this.episode=this.episodeNumber=this.season=this.seasonNumber=this.episodeTitle=this.title=this.seriesTitle=null};
q("chrome.cast.media.TvShowMediaMetadata",chrome.cast.media.mk);chrome.cast.media.kj=function(){this.metadataType=this.type=chrome.cast.media.Bb.MUSIC_TRACK;this.releaseDate=this.releaseYear=this.images=this.discNumber=this.trackNumber=this.artistName=this.songName=this.composer=this.artist=this.albumArtist=this.title=this.albumName=null};q("chrome.cast.media.MusicTrackMediaMetadata",chrome.cast.media.kj);
chrome.cast.media.vj=function(){this.metadataType=this.type=chrome.cast.media.Bb.PHOTO;this.creationDateTime=this.height=this.width=this.longitude=this.latitude=this.images=this.location=this.artist=this.title=null};q("chrome.cast.media.PhotoMediaMetadata",chrome.cast.media.vj);chrome.cast.media.ij=function(a,b){this.contentId=a;this.streamType=chrome.cast.media.Lg.BUFFERED;this.contentType=b;this.customData=this.textTrackStyle=this.tracks=this.duration=this.metadata=null};
q("chrome.cast.media.MediaInfo",chrome.cast.media.ij);chrome.cast.media.Aj=function(a){this.itemId=null;this.media=a;this.autoplay=!0;this.startTime=0;this.playbackDuration=null;this.preloadTime=0;this.customData=this.activeTrackIds=null};q("chrome.cast.media.QueueItem",chrome.cast.media.Aj);chrome.cast.media.Qi="CC1AD845";q("chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID",chrome.cast.media.Qi);chrome.cast.media.timeout={};chrome.cast.media.timeout.load=0;q("chrome.cast.media.timeout.load",chrome.cast.media.timeout.load);
chrome.cast.media.timeout.Ca=0;q("chrome.cast.media.timeout.getStatus",chrome.cast.media.timeout.Ca);chrome.cast.media.timeout.play=0;q("chrome.cast.media.timeout.play",chrome.cast.media.timeout.play);chrome.cast.media.timeout.pause=0;q("chrome.cast.media.timeout.pause",chrome.cast.media.timeout.pause);chrome.cast.media.timeout.seek=0;q("chrome.cast.media.timeout.seek",chrome.cast.media.timeout.seek);chrome.cast.media.timeout.stop=0;q("chrome.cast.media.timeout.stop",chrome.cast.media.timeout.stop);
chrome.cast.media.timeout.Nb=0;q("chrome.cast.media.timeout.setVolume",chrome.cast.media.timeout.Nb);chrome.cast.media.timeout.sf=0;q("chrome.cast.media.timeout.editTracksInfo",chrome.cast.media.timeout.sf);chrome.cast.media.timeout.Pl=0;q("chrome.cast.media.timeout.queue",chrome.cast.media.timeout.Pl);chrome.cast.media.kk=function(a,b){this.trackId=a;this.trackContentType=this.trackContentId=null;this.type=b;this.customData=this.subtype=this.language=this.name=null};q("chrome.cast.media.Track",chrome.cast.media.kk);
chrome.cast.media.hk=function(){this.customData=this.fontStyle=this.fontGenericFamily=this.fontFamily=this.fontScale=this.windowRoundedCornerRadius=this.windowColor=this.windowType=this.edgeColor=this.edgeType=this.backgroundColor=this.foregroundColor=null};q("chrome.cast.media.TextTrackStyle",chrome.cast.media.hk);chrome.cast.media.Cj=function(a){this.type="QUEUE_LOAD";this.sessionId=this.requestId=null;this.items=a;this.startIndex=0;this.repeatMode=chrome.cast.media.cf.OFF;this.customData=null};
q("chrome.cast.media.QueueLoadRequest",chrome.cast.media.Cj);chrome.cast.media.zj=function(a){this.type="QUEUE_INSERT";this.sessionId=this.requestId=null;this.items=a;this.customData=this.insertBefore=null};q("chrome.cast.media.QueueInsertItemsRequest",chrome.cast.media.zj);chrome.cast.media.Gj=function(a){this.type="QUEUE_UPDATE";this.sessionId=this.requestId=null;this.items=a;this.customData=null};q("chrome.cast.media.QueueUpdateItemsRequest",chrome.cast.media.Gj);
chrome.cast.media.Bj=function(){this.type="QUEUE_UPDATE";this.customData=this.jump=this.currentItemId=this.sessionId=this.requestId=null};q("chrome.cast.media.QueueJumpRequest",chrome.cast.media.Bj);chrome.cast.media.Fj=function(){this.type="QUEUE_UPDATE";this.customData=this.repeatMode=this.sessionId=this.requestId=null};q("chrome.cast.media.QueueSetPropertiesRequest",chrome.cast.media.Fj);
chrome.cast.media.Dj=function(a){this.type="QUEUE_REMOVE";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=null};q("chrome.cast.media.QueueRemoveItemsRequest",chrome.cast.media.Dj);chrome.cast.media.Ej=function(a){this.type="QUEUE_REORDER";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=this.insertBefore=null};q("chrome.cast.media.QueueReorderItemsRequest",chrome.cast.media.Ej);chrome.cast.VERSION=[1,2];q("chrome.cast.VERSION",chrome.cast.VERSION);chrome.cast.Dm=!0;q("chrome.cast.usingPresentationApi",chrome.cast.Dm);chrome.cast.Error=function(a,b,c){this.code=a;this.description=b||null;this.details=c||null};q("chrome.cast.Error",chrome.cast.Error);chrome.cast.Yj=function(a){this.platform=a;this.packageId=this.url=null};q("chrome.cast.SenderApplication",chrome.cast.Yj);chrome.cast.Image=function(a){this.url=a;this.width=this.height=null};q("chrome.cast.Image",chrome.cast.Image);
chrome.cast.Volume=function(a,b){this.level=m(a)?a:null;this.muted=m(b)?b:null};q("chrome.cast.Volume",chrome.cast.Volume);chrome.cast.media.J=function(a,b){this.sessionId=a;this.mediaSessionId=b;this.media=null;this.playbackRate=1;this.playerState=chrome.cast.media.vd.IDLE;this.currentTime=0;this.supportedMediaCommands=[];this.volume=new chrome.cast.Volume;this.items=this.preloadedItemId=this.loadingItemId=this.currentItemId=this.customData=this.activeTrackIds=this.idleReason=null;this.repeatMode=chrome.cast.media.cf.OFF};q("chrome.cast.media.Media",chrome.cast.media.J);chrome.cast.media.J.prototype.Ca=function(){};
chrome.cast.media.J.prototype.getStatus=chrome.cast.media.J.prototype.Ca;chrome.cast.media.J.prototype.play=function(){};chrome.cast.media.J.prototype.play=chrome.cast.media.J.prototype.play;chrome.cast.media.J.prototype.Jl=function(){};chrome.cast.media.J.prototype.playWithContext=chrome.cast.media.J.prototype.Jl;chrome.cast.media.J.prototype.pause=function(){};chrome.cast.media.J.prototype.pause=chrome.cast.media.J.prototype.pause;chrome.cast.media.J.prototype.Il=function(){};
chrome.cast.media.J.prototype.pauseWithContext=chrome.cast.media.J.prototype.Il;chrome.cast.media.J.prototype.seek=function(){};chrome.cast.media.J.prototype.seek=chrome.cast.media.J.prototype.seek;chrome.cast.media.J.prototype.stop=function(){};chrome.cast.media.J.prototype.stop=chrome.cast.media.J.prototype.stop;chrome.cast.media.J.prototype.Nb=function(){};chrome.cast.media.J.prototype.setVolume=chrome.cast.media.J.prototype.Nb;chrome.cast.media.J.prototype.sf=function(){};
chrome.cast.media.J.prototype.editTracksInfo=chrome.cast.media.J.prototype.sf;chrome.cast.media.J.prototype.Rl=function(){};chrome.cast.media.J.prototype.queueInsertItems=chrome.cast.media.J.prototype.Rl;chrome.cast.media.J.prototype.Ql=function(){};chrome.cast.media.J.prototype.queueAppendItem=chrome.cast.media.J.prototype.Ql;chrome.cast.media.J.prototype.bm=function(){};chrome.cast.media.J.prototype.queueUpdateItems=chrome.cast.media.J.prototype.bm;chrome.cast.media.J.prototype.Wl=function(){};
chrome.cast.media.J.prototype.queuePrev=chrome.cast.media.J.prototype.Wl;chrome.cast.media.J.prototype.Vl=function(){};chrome.cast.media.J.prototype.queueNext=chrome.cast.media.J.prototype.Vl;chrome.cast.media.J.prototype.Sl=function(a){wk(this,a)};chrome.cast.media.J.prototype.queueJumpToItem=chrome.cast.media.J.prototype.Sl;chrome.cast.media.J.prototype.am=function(){};chrome.cast.media.J.prototype.queueSetRepeatMode=chrome.cast.media.J.prototype.am;chrome.cast.media.J.prototype.Yl=function(){};
chrome.cast.media.J.prototype.queueRemoveItems=chrome.cast.media.J.prototype.Yl;chrome.cast.media.J.prototype.Xl=function(a){wk(this,a)};chrome.cast.media.J.prototype.queueRemoveItem=chrome.cast.media.J.prototype.Xl;chrome.cast.media.J.prototype.Zl=function(){};chrome.cast.media.J.prototype.queueReorderItems=chrome.cast.media.J.prototype.Zl;chrome.cast.media.J.prototype.Ul=function(a,b,c,d){a=wk(this,a);0>a||(0>b?d&&d(new chrome.cast.Error(chrome.cast.Pb.INVALID_PARAMETER)):a==b&&c&&c())};
chrome.cast.media.J.prototype.queueMoveItemToNewIndex=chrome.cast.media.J.prototype.Ul;chrome.cast.media.J.prototype.Am=function(a){return-1<this.supportedMediaCommands.indexOf(a)};chrome.cast.media.J.prototype.supportsCommand=chrome.cast.media.J.prototype.Am;chrome.cast.media.J.prototype.Lk=function(){return this.currentTime};chrome.cast.media.J.prototype.getEstimatedTime=chrome.cast.media.J.prototype.Lk;chrome.cast.media.J.prototype.ff=function(){};
chrome.cast.media.J.prototype.addUpdateListener=chrome.cast.media.J.prototype.ff;chrome.cast.media.J.prototype.gf=function(){};chrome.cast.media.J.prototype.addUpdateListenerWithContext=chrome.cast.media.J.prototype.gf;chrome.cast.media.J.prototype.Zf=function(){};chrome.cast.media.J.prototype.removeUpdateListener=chrome.cast.media.J.prototype.Zf;chrome.cast.media.J.prototype.ag=function(){};chrome.cast.media.J.prototype.removeUpdateListenerWithContext=chrome.cast.media.J.prototype.ag;
var wk=function(a,b){return Rb(a.items,function(a){return a.itemId==b})};chrome.cast.L=function(a,b,c,d,e){this.sessionId=a;this.appId=b;this.displayName=c;this.statusText=null;this.appImages=d;this.receiver=e;this.senderApps=[];this.namespaces=[];this.media=[];this.status=chrome.cast.Kg.CONNECTED;this.transportId=""};q("chrome.cast.Session",chrome.cast.L);chrome.cast.L.prototype.tm=function(a,b,c){this.ui(null,a,b,c)};chrome.cast.L.prototype.setReceiverVolumeLevel=chrome.cast.L.prototype.tm;
chrome.cast.L.prototype.ui=function(a,b,c,d){b=new uk(new chrome.cast.Volume(b,null),this.receiver.volume);a.setReceiverVolume(this.sessionId,b,c,d)};chrome.cast.L.prototype.setReceiverVolumeLevelWithContext=chrome.cast.L.prototype.ui;chrome.cast.L.prototype.sm=function(a,b,c){this.ti(0,a,b,c)};chrome.cast.L.prototype.setReceiverMuted=chrome.cast.L.prototype.sm;
chrome.cast.L.prototype.ti=function(a,b,c,d){a=new uk(new chrome.cast.Volume(null,b),this.receiver.volume);null.setReceiverVolume(this.sessionId,a,c,d)};chrome.cast.L.prototype.setReceiverMutedWithContext=chrome.cast.L.prototype.ti;chrome.cast.L.prototype.leave=function(a,b){null.leaveSession(this.sessionId,a,b)};chrome.cast.L.prototype.leave=chrome.cast.L.prototype.leave;chrome.cast.L.prototype.stop=function(){};chrome.cast.L.prototype.stop=chrome.cast.L.prototype.stop;
chrome.cast.L.prototype.xm=function(){};chrome.cast.L.prototype.stopWithContext=chrome.cast.L.prototype.xm;chrome.cast.L.prototype.sendMessage=function(){};chrome.cast.L.prototype.sendMessage=chrome.cast.L.prototype.sendMessage;chrome.cast.L.prototype.nm=function(){};chrome.cast.L.prototype.sendMessageWithContext=chrome.cast.L.prototype.nm;chrome.cast.L.prototype.ff=function(){};chrome.cast.L.prototype.addUpdateListener=chrome.cast.L.prototype.ff;chrome.cast.L.prototype.gf=function(){};
chrome.cast.L.prototype.addUpdateListenerWithContext=chrome.cast.L.prototype.gf;chrome.cast.L.prototype.Zf=function(){};chrome.cast.L.prototype.removeUpdateListener=chrome.cast.L.prototype.Zf;chrome.cast.L.prototype.ag=function(){};chrome.cast.L.prototype.removeUpdateListenerWithContext=chrome.cast.L.prototype.ag;chrome.cast.L.prototype.vk=function(){};chrome.cast.L.prototype.addMessageListener=chrome.cast.L.prototype.vk;chrome.cast.L.prototype.wk=function(){};
chrome.cast.L.prototype.addMessageListenerWithContext=chrome.cast.L.prototype.wk;chrome.cast.L.prototype.tk=function(){};chrome.cast.L.prototype.addMediaListener=chrome.cast.L.prototype.tk;chrome.cast.L.prototype.uk=function(){};chrome.cast.L.prototype.addMediaListenerWithContext=chrome.cast.L.prototype.uk;chrome.cast.L.prototype.fm=function(){};chrome.cast.L.prototype.removeMediaListener=chrome.cast.L.prototype.fm;chrome.cast.L.prototype.gm=function(){};
chrome.cast.L.prototype.removeMediaListenerWithContext=chrome.cast.L.prototype.gm;chrome.cast.L.prototype.hm=function(){};chrome.cast.L.prototype.removeMessageListener=chrome.cast.L.prototype.hm;chrome.cast.L.prototype.im=function(){};chrome.cast.L.prototype.removeMessageListenerWithContext=chrome.cast.L.prototype.im;chrome.cast.L.prototype.Zk=function(a){a.sessionId=this.sessionId};chrome.cast.L.prototype.loadMedia=chrome.cast.L.prototype.Zk;chrome.cast.L.prototype.Tl=function(a){a.sessionId=this.sessionId};
chrome.cast.L.prototype.queueLoad=chrome.cast.L.prototype.Tl;var xk=function(a,b,c){this.f=a;this.a=b;this.b=c},yk=function(a){var b="cast-dial:"+a.f,c=new URLSearchParams;a.a&&c.set("dialPostData",a.a);a.b&&c.set("clientId",a.b);(a=c.toString())&&(b+="?"+a);return b};var zk=function(a,b,c){this.type=a;this.message=b;this.sequenceNumber=m(c)?c:-1;this.timeoutMillis=0;this.clientId=""};var Ak=function(a,b){this.Db=this.g=this.b="";this.sa=null;this.h=this.a="";this.f=!1;var c;a instanceof Ak?(this.f=m(b)?b:a.f,Bk(this,a.b),this.g=a.g,Ck(this,a.Db),Dk(this,a.Ba()),Ek(this,a.a),Fk(this,a.l.clone()),Gk(this,a.h)):a&&(c=String(a).match(Ej))?(this.f=!!b,Bk(this,c[1]||"",!0),this.g=Hk(c[2]||""),Ck(this,c[3]||"",!0),Dk(this,c[4]),Ek(this,c[5]||"",!0),Fk(this,c[6]||"",!0),Gk(this,c[7]||"",!0)):(this.f=!!b,this.l=new Ik(null,0,this.f))};
Ak.prototype.toString=function(){var a=[],b=this.b;b&&a.push(Jk(b,Kk,!0),":");var c=this.Db;if(c||"file"==b)a.push("//"),(b=this.g)&&a.push(Jk(b,Kk,!0),"@"),a.push(encodeURIComponent(String(c)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),c=this.Ba(),null!=c&&a.push(":",String(c));if(c=this.a)this.Db&&"/"!=c.charAt(0)&&a.push("/"),a.push(Jk(c,"/"==c.charAt(0)?Lk:Mk,!0));(c=this.l.toString())&&a.push("?",c);(c=this.h)&&a.push("#",Jk(c,Nk));return a.join("")};
Ak.prototype.resolve=function(a){var b=this.clone(),c=!!a.b;c?Bk(b,a.b):c=!!a.g;c?b.g=a.g:c=!!a.Db;c?Ck(b,a.Db):c=null!=a.sa;var d=a.a;if(c)Dk(b,a.Ba());else if(c=!!a.a){if("/"!=d.charAt(0))if(this.Db&&!this.a)d="/"+d;else{var e=b.a.lastIndexOf("/");-1!=e&&(d=b.a.substr(0,e+1)+d)}e=d;if(".."==e||"."==e)d="";else if(-1!=e.indexOf("./")||-1!=e.indexOf("/.")){d=0==e.lastIndexOf("/",0);e=e.split("/");for(var f=[],g=0;g<e.length;){var l=e[g++];"."==l?d&&g==e.length&&f.push(""):".."==l?((1<f.length||1==
f.length&&""!=f[0])&&f.pop(),d&&g==e.length&&f.push("")):(f.push(l),d=!0)}d=f.join("/")}else d=e}c?Ek(b,d):c=""!==a.l.toString();c?Fk(b,a.l.clone()):c=!!a.h;c&&Gk(b,a.h);return b};Ak.prototype.clone=function(){return new Ak(this)};var Bk=function(a,b,c){a.b=c?Hk(b,!0):b;a.b&&(a.b=a.b.replace(/:$/,""))},Ck=function(a,b,c){a.Db=c?Hk(b,!0):b};Ak.prototype.Ba=function(){return this.sa};
var Dk=function(a,b){if(b){b=Number(b);if(isNaN(b)||0>b)throw Error("Bad port number "+b);a.sa=b}else a.sa=null},Ek=function(a,b,c){a.a=c?Hk(b,!0):b},Fk=function(a,b,c){b instanceof Ik?(a.l=b,Ok(a.l,a.f)):(c||(b=Jk(b,Pk)),a.l=new Ik(b,0,a.f))},Gk=function(a,b,c){a.h=c?Hk(b):b},Hk=function(a,b){return a?b?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""},Jk=function(a,b,c){return ta(a)?(a=encodeURI(a).replace(b,Qk),c&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null},Qk=function(a){a=
a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)},Kk=/[#\/\?@]/g,Mk=/[\#\?:]/g,Lk=/[\#\?]/g,Pk=/[\#\?@]/g,Nk=/#/g,Ik=function(a,b,c){this.b=this.a=null;this.f=a||null;this.g=!!c},Rk=function(a){a.a||(a.a=new Ni,a.b=0,a.f&&Fj(a.f,function(b,c){a.add(decodeURIComponent(b.replace(/\+/g," ")),c)}))},Tk=function(a){var b=Ui(a);if("undefined"==typeof b)throw Error("Keys are undefined");var c=new Ik(null,0,void 0);a=Ti(a);for(var d=0;d<b.length;d++){var e=b[d],f=a[d];Aa(f)?Sk(c,e,f):
c.add(e,f)}return c};h=Ik.prototype;h.da=function(){Rk(this);return this.b};h.add=function(a,b){Rk(this);this.f=null;a=Uk(this,a);var c=this.a.get(a);c||this.a.set(a,c=[]);c.push(b);this.b+=1;return this};h.remove=function(a){Rk(this);a=Uk(this,a);return this.a.Va(a)?(this.f=null,this.b-=this.a.get(a).length,this.a.remove(a)):!1};h.clear=function(){this.a=this.f=null;this.b=0};h.rb=function(){Rk(this);return 0==this.b};h.Va=function(a){Rk(this);a=Uk(this,a);return this.a.Va(a)};
h.Nc=function(a){var b=this.S();return Ub(b,a)};h.forEach=function(a,b){Rk(this);this.a.forEach(function(c,d){x(c,function(c){a.call(b,c,d,this)},this)},this)};h.Qa=function(){Rk(this);for(var a=this.a.S(),b=this.a.Qa(),c=[],d=0;d<b.length;d++)for(var e=a[d],f=0;f<e.length;f++)c.push(b[d]);return c};h.S=function(a){Rk(this);var b=[];if(ta(a))this.Va(a)&&(b=cc(b,this.a.get(Uk(this,a))));else{a=this.a.S();for(var c=0;c<a.length;c++)b=cc(b,a[c])}return b};
h.set=function(a,b){Rk(this);this.f=null;a=Uk(this,a);this.Va(a)&&(this.b-=this.a.get(a).length);this.a.set(a,[b]);this.b+=1;return this};h.get=function(a,b){a=a?this.S(a):[];return 0<a.length?String(a[0]):b};var Sk=function(a,b,c){a.remove(b);0<c.length&&(a.f=null,a.a.set(Uk(a,b),y(c)),a.b+=c.length)};
Ik.prototype.toString=function(){if(this.f)return this.f;if(!this.a)return"";for(var a=[],b=this.a.Qa(),c=0;c<b.length;c++){var d=b[c],e=encodeURIComponent(String(d));d=this.S(d);for(var f=0;f<d.length;f++){var g=e;""!==d[f]&&(g+="="+encodeURIComponent(String(d[f])));a.push(g)}}return this.f=a.join("&")};Ik.prototype.clone=function(){var a=new Ik;a.f=this.f;this.a&&(a.a=this.a.clone(),a.b=this.b);return a};
var Uk=function(a,b){b=String(b);a.g&&(b=b.toLowerCase());return b},Ok=function(a,b){b&&!a.g&&(Rk(a),a.f=null,a.a.forEach(function(a,b){var c=b.toLowerCase();b!=c&&(this.remove(b),Sk(this,c,a))},a));a.g=b};Ik.prototype.extend=function(a){for(var b=0;b<arguments.length;b++)Wi(arguments[b],function(a,b){this.add(b,a)},this)};var Vk=function(a,b,c,d,e,f,g,l,r,u){this.u=a;this.a=b||null;this.b=c||null;this.f=d||null;this.g=m(e)?e:null;this.m=f||null;this.s=g||null;this.v=l||!1;this.h=r||null;this.l=u||null},Wk=function(a,b){return(a=a.match(b+"=([^/]*)"))?a[1]:null},Yk=function(a){a=a.match(/__castAppId__=([^/]*)/g);return null==a?[]:Mb(Nb(a,function(a){a=Wk(a,"__castAppId__");if(!a)return null;a=a.match(Xk);if(!a||0==a.length)return null;var b=[];3==a.length&&a[2]&&(b=a[2].split(","));return{appId:a[1],capabilities:b}}),
function(a){return null!=a})},Zk=function(a){return Nb(a.u,function(a){return a.appId})},$k=function(a){return a.b?a.b:chrome.cast.Ob.TAB_AND_ORIGIN_SCOPED},bl=function(a){if(!window.localStorage||!window.localStorage.useNewCastPresentationUrls)return[al(a)];var b=a.u.map(function(b){var c="cast:"+b.appId,e=new URLSearchParams;b.capabilities&&0<b.capabilities.length&&e.set("capabilities",b.capabilities.join(","));a.a&&e.set("clientId",a.a);a.b&&e.set("autoJoinPolicy",a.b);a.f&&e.set("defaultActionPolicy",
a.f);null!=a.g&&e.set("launchTimeout",String(a.g));a.v&&e.set("invisibleSender","true");a.h&&(e.set("broadcastNamespace",a.h),e.set("broadcastId",String(Math.random())));a.l&&e.set("broadcastMessage",encodeURIComponent(JSON.stringify(a.l)));return c+"?"+e.toString()});a.m&&b.push(yk(new xk(a.m,a.s,a.a)));return b},al=function(a){var b=new Ak;Bk(b,"https");Ck(b,"google.com");Ek(b,"/cast");var c=[];x(a.u,function(a){var b="__castAppId__="+a.appId;a.capabilities&&0<a.capabilities.length&&(b=b+"("+a.capabilities.join(","),
b+=")");c.push(b)});a.a&&c.push("__castClientId__="+a.a);a.b&&c.push("__castAutoJoinPolicy__="+a.b);a.f&&c.push("__castDefaultActionPolicy__="+a.f);null!=a.g&&c.push("__castLaunchTimeout__="+a.g);a.m&&c.push("__dialAppName__="+a.m);a.s&&c.push("__dialPostData__="+a.s);a.v&&c.push("__castInvisibleSender__=true");a.h&&(c.push("__castBroadcastNamespace__="+a.h),c.push("__castBroadcastId__="+Math.random()));a.l&&c.push("__castBroadcastMessage__="+encodeURIComponent(JSON.stringify(a.l)));Gk(b,c.join("/"));
return b.toString()},dl=function(a,b){a=Zk(a);var c=cl(b);return Pb(a,function(a){return Ub(c,a)})},el=function(a){try{var b=new URL(a)}catch(z){return null}if("https:"==b.protocol)if("https:"!=b.protocol||"google.com"!=b.host||"/cast"!=b.pathname)a=null;else{var c=b.hash;if((a=Yk(c))&&0!=a.length){b=Wk(c,"__castClientId__");var d=Wk(c,"__castAutoJoinPolicy__"),e=Wk(c,"__castDefaultActionPolicy__");var f=Wk(c,"__castLaunchTimeout__");null==f?f=null:(f=Number(f),f=!isNaN(f)&&0<f?f:null);var g=Wk(c,
"__dialAppName__"),l=Wk(c,"__dialPostData__"),r=Wk(c,"__castInvisibleSender__");r=null===r?null:"true"==r;var u=Wk(c,"__castBroadcastNamespace__");c=(c=Wk(c,"__castBroadcastMessage__"))?JSON.parse(decodeURIComponent(c)):null;a=new Vk(a,b,d,e,f,g,l,r,u,c)}else a=null}else if("cast:"==b.protocol){a=b.pathname;d=b.searchParams.get("capabilities");a={appId:a,capabilities:d?d.split(","):[]};l=b.searchParams;b=l.get("clientId");d=l.get("autoJoinPolicy");e=l.get("defaultActionPolicy");c=Number(l.get("launchTimeout"));
if(isNaN(c)||0>=c)c=null;f="true"==l.get("invisibleSender");g=l.get("broadcastNamespace");l=(l=l.get("broadcastMessage"))?JSON.parse(decodeURIComponent(l)):null;a=new Vk([a],b,d,e,c,void 0,void 0,f,g,l)}else a=null;return a},cl=function(a){return(a=el(a))?Zk(a):null},fl=function(a){return(a=el(a))?a.a:null},Xk=/(^\w+)(?:\(([\w,\ ]*)\))?$/;var hl=function(a){this.a=new Ni;a&&gl(this,a)},il=function(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+(a[Ea]||(a[Ea]=++Ga)):b.substr(0,1)+a};hl.prototype.da=function(){return this.a.da()};hl.prototype.add=function(a){this.a.set(il(a),a)};var gl=function(a,b){b=Ti(b);for(var c=b.length,d=0;d<c;d++)a.add(b[d])};h=hl.prototype;h.removeAll=function(a){a=Ti(a);for(var b=a.length,c=0;c<b;c++)this.remove(a[c])};h.remove=function(a){return this.a.remove(il(a))};h.clear=function(){this.a.clear()};
h.rb=function(){return this.a.rb()};h.contains=function(a){return this.a.Va(il(a))};h.S=function(){return this.a.S()};h.clone=function(){return new hl(this)};h.equals=function(a){return this.da()==Si(a)&&jl(this,a)};var jl=function(a,b){var c=Si(b);if(a.da()>c)return!1;!(b instanceof hl)&&5<c&&(b=new hl(b));return Yi(a,function(a){var c=b;return c.contains&&"function"==typeof c.contains?c.contains(a):c.Nc&&"function"==typeof c.Nc?c.Nc(a):Ba(c)||ta(c)?Ub(c,a):vc(c,a)})};hl.prototype.Ua=function(){return this.a.Ua(!1)};var kl=function(a,b){this.sinks=a;this.origins=b||null},ll=new kl([]);var ml=function(){this.a=[]};ml.prototype.listen=function(a,b,c){this.a.push({type:a,Sa:b,target:c})};ml.prototype.v=function(a,b,c){var d=this.a.findIndex(function(d){return d.type==a&&d.Sa==b&&d.target==c});-1!=d&&this.a.splice(d,1)};ml.prototype.dispatchEvent=function(a){this.a.forEach(function(b){b.type==a.type&&Promise.resolve().then(function(){return b.Sa.call(b.target,a)})})};var nl=/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/,ol=[4278190080,4293918720,4294901760],pl=[167772160,2886729728,3232235520],ql=function(a){var b=document.createElement("a");b.href=a;return b};var sl=function(a,b,c,d){b="["+b+"]: "+c+" "+d.responseURL+" => "+d.status+" ("+d.statusText+")";rl(d)?a.info(b):w(a,b)},rl=function(a){return 200<=a.status&&299>=a.status},tl=function(a){a=(new DOMParser).parseFromString(a,"text/xml");return a.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","parsererror").length?null:a};var ul=function(){this.name="unknown";this.state="error";this.a=null;this.allowStop=!0;this.resource=null;this.extraData={}},vl=function(){var a=Error.call(this);this.message=a.message;"stack"in a&&(this.stack=a.stack)};qa(vl,Error);var xl=function(a,b){void 0===b&&(wl||(wl=new Fc(10,2E3,1)),b=wl);this.b=a;this.a=b;this.j=Pa("mr.dial.Client")};
xl.prototype.launchApp=function(a,b){var c=this;return this.a.send(yl(this,a),"POST",b,{timeoutMillis:15E3}).then(function(a){return zl(c,"launchApp","POST",a)})};
var Al=function(a,b){return a.a.send(yl(a,b),"DELETE").then(function(b){return zl(a,"stopApp","DELETE",b)})},Bl=function(a,b){return a.a.send(yl(a,b),"GET",void 0,{Jh:3}).then(function(c){sl(a.j,"GetAppInfo","GET",c);if(!rl(c)){if(404==c.status)throw new vl;throw Error("Response error: "+c.status);}c=tl(c.responseText);if(!c)throw a.j.info("Invalid or empty response"),Error("Invalid or empty response");var d=c.getElementsByTagName("service");if(!d||1!=d.length)throw a.j.info("Invalid GET response (invalid service)"),
Error("Invalid GET response (invalid service)");c=new ul;for(var e=0,f=d[0].childNodes.length;e<f;e++){var g=d[0].childNodes[e];if("state"==g.nodeName){a:switch(g.textContent){case "running":g="running";break a;case "stopped":g="stopped";break a;default:g="error"}c.state=g}else"name"==g.nodeName?c.name=g.textContent:"link"==g.nodeName?c.resource=g.getAttribute("href"):"options"==g.nodeName?c.allowStop="false"!=g.getAttribute("allowStop"):c.extraData[g.nodeName]=g.innerHTML}if("unknown"==c.name)throw a.j.info("GET response missing name value"),
Error("GET response missing name value");if(c.name!=b)throw a.j.info("GET app name mismatch"),Error("GET app name mismatch");if("error"==c.state)throw a.j.info("GET response missing state value"),Error("GET response missing state value");if((d=/installable=(.+)/.exec(c.state))&&d[1])c.state="installable",c.a=d[1];else if("running"!=c.state&&"stopped"!=c.state)throw a.j.info("GET response has invalid state value"),Error("GET response has invalid state value");return c})},yl=function(a,b){a=a.b.Rb;
"/"!=a.charAt(a.length-1)&&(a+="/");return a+b},zl=function(a,b,c,d){return new Promise(function(e,f){sl(a.j,b,c,d);rl(d)?e():f(Error(d.statusText))})},wl=null;var Cl=function(a,b,c){var d=Error.call(this);this.message=d.message;"stack"in d&&(this.stack=d.stack);this.name="RouteRequestError";this.message=b||"";if(c)this.stack=c;else if(Error.captureStackTrace)Error.captureStackTrace(this,Cl);else if(b=Error().stack)this.stack=b;this.errorCode=a};qa(Cl,Error);var Dl=(new Map).set("+","-").set("/","_").set("=","."),El=(new Map).set("-","+").set("_","/").set(".","="),Fl=function(a){return atob(a.replace(/[-_.]/g,function(a){return El.get(a)}))},Gl=function(a){return btoa(String.fromCharCode.apply(String,[].concat(k(a)))).replace(/[+/=]/g,function(a){return Dl.get(a)})};var Hl=function(){this.a=[];this.l=[];this.h=[];this.f=[];this.f[0]=128;for(var a=1;64>a;++a)this.f[a]=0;this.g=this.b=0;this.reset()};Hl.prototype.reset=function(){this.a[0]=1732584193;this.a[1]=4023233417;this.a[2]=2562383102;this.a[3]=271733878;this.a[4]=3285377520;this.g=this.b=0};
var Il=function(a,b,c){c=void 0===c?0:c;var d=a.h;if("string"===typeof b)for(var e=0;16>e;e++)d[e]=b.charCodeAt(c)<<24|b.charCodeAt(c+1)<<16|b.charCodeAt(c+2)<<8|b.charCodeAt(c+3),c+=4;else for(e=0;16>e;e++)d[e]=b[c]<<24|b[c+1]<<16|b[c+2]<<8|b[c+3],c+=4;for(b=16;80>b;b++)c=d[b-3]^d[b-8]^d[b-14]^d[b-16],d[b]=(c<<1|c>>>31)&4294967295;b=a.a[0];c=a.a[1];e=a.a[2];for(var f=a.a[3],g=a.a[4],l,r,u=0;80>u;u++)40>u?20>u?(l=f^c&(e^f),r=1518500249):(l=c^e^f,r=1859775393):60>u?(l=c&e|f&(c|e),r=2400959708):(l=
c^e^f,r=3395469782),l=(b<<5|b>>>27)+l+g+r+d[u]&4294967295,g=f,f=e,e=(c<<30|c>>>2)&4294967295,c=b,b=l;a.a[0]=a.a[0]+b&4294967295;a.a[1]=a.a[1]+c&4294967295;a.a[2]=a.a[2]+e&4294967295;a.a[3]=a.a[3]+f&4294967295;a.a[4]=a.a[4]+g&4294967295};
Hl.prototype.update=function(a,b){b=void 0===b?a.length:b;for(var c=b-64,d=0,e=this.l,f=this.b;d<b;){if(0==f)for(;d<=c;)Il(this,a,d),d+=64;if("string"===typeof a)for(;d<b;){if(e[f]=a.charCodeAt(d),++f,++d,64==f){Il(this,e);f=0;break}}else for(;d<b;)if(e[f]=a[d],++f,++d,64==f){Il(this,e);f=0;break}}this.b=f;this.g+=b};
Hl.prototype.digest=function(){var a=[],b=8*this.g;56>this.b?this.update(this.f,56-this.b):this.update(this.f,64-(this.b-56));for(var c=63;56<=c;c--)this.l[c]=b&255,b/=256;Il(this,this.l);for(c=b=0;5>c;c++)for(var d=24;0<=d;d-=8)a[b]=this.a[c]>>d&255,++b;return a};var Jl=function(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)};var Ll=function(){this.h=Jl();this.f=new Kl(null,null);this.b=new Kl(null,null);this.l=[];this.g=this.a=0;Jg(this)},Nl=function(){Ml||(Ml=new Ll);return Ml},Ol=function(a,b){b=b.toLowerCase();var c=new Hl;c.update(b);c.update(a.h);return"r"+Gl(c.digest())},Pl=function(){var a=Nl();return a.f.model?a.f:a.b.model?a.b:new Kl(null,null)};Ll.prototype.ha=function(){return"SinkUtils"};
Ll.prototype.xa=function(){return[{recentLaunchedDevice:this.f,recentDiscoveredDevice:this.b},{receiverIdToken:this.h,fixedIpList:this.l.join(","),castControlPort:this.a,lastCloudSinkCheckTimeMillis:this.g}]};
Ll.prototype.Da=function(){var a=Gg(this);a&&(this.f=a.recentLaunchedDevice||new Kl(null,null),this.b=a.recentDiscoveredDevice||new Kl(null,null));if(a=Hg(this))this.h=a.receiverIdToken||Jl(),this.l=a.fixedIpList&&a.fixedIpList.split(",")||[],this.a=a.castControlPort||0,this.g=a.lastCloudSinkCheckTimeMillis||0};var Ml=null,Kl=function(a,b){this.model=a;this.ip=b};var Ql=function(a,b){this.xb=a;this.appName=b};var Rl=function(a){this.a=new Map;this.b=a};Rl.prototype.init=function(){Jg(this)};Rl.prototype.clear=function(){this.a.clear()};Rl.prototype.add=function(a){if(!this.a.get(a.xb.id)){this.a.set(a.xb.id,a);var b=this.b;Sl(b);b.g.dd(b,a.xb)}};var Tl=function(a,b){a=ja(a.a);for(var c=a.next();!c.done;c=a.next())if(c=ja(c.value),c.next(),c=c.next().value,c.xb.sinkId==b)return c;return null},Vl=function(a,b){var c=a.a.get(b);c&&(a.a.delete(b),Ul(a.b,c))},Wl=function(a){return Array.from(a.a.values(),function(a){return a.xb})};
Rl.prototype.ha=function(){return"dial.ActivityRecords"};Rl.prototype.xa=function(){return[Array.from(this.a)]};Rl.prototype.Da=function(){var a=Gg(this);a&&(this.a=new Map(a))};var Xl={eo:0,cr:1,Xp:2,co:3},Yl={ERROR:0,rq:1,EMPTY:2},Zl=function(a){ib("MediaRouter.Dial.Create.Route",a,Xl)};var $l=function(a){return Promise.all(a.map(function(a){return a.then(function(a){return{dc:!0,value:a}},function(a){return{dc:!1,reason:a}})}))};var am=function(a,b,c,d,e){this.id=a;this.friendlyName=b;this.iconType=c||"generic";this.description=void 0===d?null:d;this.domain=void 0===e?null:e};var bm=function(a,b){this.lb=this.Qb=this.Rb=this.sa=this.kb=null;this.eb=new am(Ol(Nl(),b),a);this.jb={};this.oe={};this.Jc=!1};bm.prototype.getId=function(){return this.eb.id};var cm=function(a,b){a.Jc=b;return a};
bm.prototype.update=function(a){if(this.getId()!=a.getId())return!1;var b=!1;this.eb.friendlyName!=a.eb.friendlyName&&(this.eb.friendlyName=a.eb.friendlyName,b=!0);this.Rb!=a.Rb&&(this.Rb=a.Rb,b=!0);this.Qb!=a.Qb&&(this.Qb=a.Qb,b=!0);this.kb!=a.kb&&(this.kb=a.kb,b=!0);this.sa!=a.sa&&(this.sa=a.sa,b=!0);return b};bm.prototype.Ja=function(){return this.kb};bm.prototype.Ba=function(){return this.sa};
var dm=function(a,b){return a.jb[b]||"unknown"},em=function(a){var b=new bm(a.eb.friendlyName,"");b.eb.id=a.eb.id;b.kb=a.kb;b.sa=a.sa;b.Rb=a.Rb;b.Qb=a.Qb;b.lb=a.lb;b.jb=a.jb;b.oe=a.oe;b.Jc=a.Jc;return b};var fm=function(a,b){if(!chrome.runtime.lastError)return null;a=a+" failed, chrome.runtime.lastError: "+(chrome.runtime.lastError.message||"Unknown error");b&&w(b,a);return Error(a)};var gm=function(){this.a=this.modelName=this.deviceType=this.expireTimeMillis=this.fetchTimeMillis=this.appUrl=this.ipAddress=this.friendlyName=this.deviceLabel=this.uniqueId=null},hm=function(a){if(a.deviceLabel)if(a.uniqueId)if(a.friendlyName)if(a.ipAddress)if(a.appUrl)if(a.fetchTimeMillis)if(a.expireTimeMillis){var b=a.ipAddress;a=ql(a.appUrl);b="http:"==a.protocol&&a.hostname==b?null:"Invalid appUrl"}else b="Missing expireTimeMillis";else b="Missing fetchTimeMillis";else b="Missing appUrl";else b=
"Missing ipAddress";else b="Missing friendlyName";else b="Missing uniqueId";else b="Missing deviceLabel";return b};gm.prototype.toString=function(){return JSON.stringify(this,function(a,b){return"string"===typeof b&&b.startsWith("uuid:")?"***":b})};
var im=function(a){var b=new gm;b.uniqueId=a.uniqueId;b.deviceLabel=a.deviceLabel;b.friendlyName=a.friendlyName;b.ipAddress=a.ipAddress;b.appUrl=a.appUrl;b.fetchTimeMillis=a.fetchTimeMillis;b.expireTimeMillis=a.expireTimeMillis;b.deviceType=a.deviceType;b.modelName=a.modelName;b.a=a.configId;return b},km=function(a){void 0===a&&(jm||(jm=new Fc(10,3E3,2)),a=jm);this.a=new Map;this.b=new Map;this.f=new Map;this.g=a;this.j=Pa("mr.dial.DeviceDescriptionService");Jg(this)};km.prototype.ha=function(){return"mr.dial.DeviceDescriptionService"};
km.prototype.xa=function(){return[Array.from(this.a)]};km.prototype.Da=function(){var a=Gg(this);if(a){a=ja(a);for(var b=a.next();!b.done;b=a.next()){var c=ja(b.value);b=c.next().value;c=c.next().value;null!=hm(im(c))?this.j.error("Dropping invalid description "+(b+" loaded from storage.")):this.a.set(b,im(c))}}};
var mm=function(a,b){var c;if(c=a.a.get(b.deviceLabel)){if(c.a!=b.configId||Date.now()>=c.expireTimeMillis)w(a.j,"Removing invalid entry "+c.toString()),a.a.delete(b.deviceLabel),c=null}else c=null;return c?(hb("MediaRouter.Dial.Device.Description.Cached"),Promise.resolve(c)):lm(a,b)},lm=function(a,b){if(!nm(b.deviceDescriptionUrl))return Promise.reject(Error("Invalid device description URL: "+b.deviceDescriptionUrl));var c=a.b.get(b.deviceLabel);if(c&&c.deviceDescriptionUrl==b.deviceDescriptionUrl)return c.ta.a;
var d=new kb;c={deviceDescriptionUrl:b.deviceDescriptionUrl,ta:d};a.b.set(b.deviceLabel,c);chrome.dial.fetchDeviceDescription(b.deviceLabel,function(c){a.b.delete(b.deviceLabel);c?((c=om(a,b,c.deviceDescription,c.appUrl))?(a.j.info("Got device description for "+c.deviceLabel),w(a.j,"... device description was: "+c.toString()),null!=c.a&&(w(a.j,"Caching device description for "+c.deviceLabel),a.a.set(b.deviceLabel,c))):(ib("MediaRouter.Dial.Device.Description.Failure",1,Yl),a.j.info("Invalid device description"),
c=null),c?d.resolve(c):d.reject(Error("Failed to process device description"))):d.reject(fm("chrome.dial.fetchDeviceDescription"))});return d.a},om=function(a,b,c,d){var e=tl(c);if(!e)return null;var f=new gm;f.fetchTimeMillis=Date.now();f.expireTimeMillis=f.fetchTimeMillis+18E5;f.deviceLabel=b.deviceLabel;f.a=b.configId;b=ql(b.deviceDescriptionUrl);f.ipAddress=b.hostname;f.deviceType=pm(e,"deviceType");f.modelName=pm(e,"modelName");f.friendlyName=pm(e,"friendlyName");f.uniqueId=pm(e,"UDN");!f.friendlyName&&
f.modelName&&(f.friendlyName=f.modelName,f.uniqueId&&(f.friendlyName+="["+f.uniqueId.slice(-4)+"]"),v(a.j,"Fixed device description: created friendlyName from modelName."));f.appUrl=d;d=hm(f);w(a.j,function(){return"Device description: "+qm(e)});return d?(v(a.j,function(){return"Device description failed to validate: "+f},d),null):f},pm=function(a,b){return(a=a.getElementsByTagName(b))&&0!=a.length?a[0].textContent:null},qm=function(a){var b=function(a){for(var b=0,c=a.length;b<c;b++)a[b].textContent=
"***"};b(a.getElementsByTagName("UDN"));b(a.getElementsByTagName("serialNumber"));return(new XMLSerializer).serializeToString(a)},rm=function(a,b){var c=a.f.get(b);if(c)return c.a;c=new kb;a.f.set(b,c);a.g.send(b,"GET").then(function(d){a.f.delete(b);sl(a.j,"checkAccess","GET",d);c.resolve(rl(d))},function(){a.j.error("Timed out checking access to device description URL.");c.resolve(!1)});return c.a},nm=function(a){a=ql(a);var b;if(b="http:"==a.protocol)a:{b:if((a=a.hostname.match(nl))&&5==a.length){b=
[];for(var c=0;4>c;c++)if(b[c]=Number.parseInt(a[c+1],10),0>b[c]||255<b[c]){a=null;break b}a=b}else a=null;if(a)for(a=(a[0]<<24|a[1]<<16|a[2]<<8|a[0])>>>0,b=0;3>b;b++)if((a&ol[b])>>>0==pl[b]){b=!0;break a}b=!1}return b},jm=null;var sm=null,tm=null,um=function(){sm||(sm=new jk(3,"dial.DialOnDeviceListEventListener","mr.dial.SinkDiscoveryService",chrome.dial.onDeviceList));tm||(tm=new jk(4,"dial.DialOnErrorEventListener","mr.dial.SinkDiscoveryService",chrome.dial.onError));return[sm,tm]};var vm=function(a,b){b=void 0===b?new km:b;this.f=a;this.m=b;this.j=Pa("mr.dial.SinkDiscoveryService");this.a=new Map;this.h=this.l=!1;this.b={Zb:0,fc:0};this.g=0};qa(vm,Mf);vm.prototype.init=function(){Jg(this);Wf("mr.dial.SinkDiscoveryService",this)};vm.prototype.start=function(){this.l||(this.j.info("Starting..."),this.l=!0,um().forEach(function(a){return a.addListener()}),wm(this))};vm.prototype.stop=function(){this.j.info("Stopping...");this.l=!1;um().forEach(function(a){return a.removeListener()})};
var wm=function(a){a.l?chrome.dial.discoverNow(function(b){a.j.info("chrome.dial.discoverNow = "+b)}):a.j.info("Not started. Ignoring discover().")},Am=function(a,b){a.j.info("addSinks returned "+b.length+" sinks");w(a.j,function(){return"....the list is: "+JSON.stringify(b)});var c=new Set(a.a.keys());b.forEach(function(b){var d=xm(b.sink_id),e=b.extra_data.dial_media_sink,f=ym.test(e.model_name),u=e.ip_address.address_bytes?e.ip_address.address_bytes.join("."):e.ip_address.address.join(".");b=new bm(b.name,
d);b.kb=u;b.Rb=e.app_url.url;b.lb=e.model_name;e=cm(b,!f);zm(a,e);c.delete(e.getId())});var d=[];c.forEach(function(b){var c=a.a.get(b);d.push(c);a.a.delete(b)});0<d.length&&a.f.sc(d);var e=a.a.size;a.b={Zb:e,fc:e}};
vm.prototype.u=function(a){var b=this;this.j.info("onDeviceList returned "+a.length+" devices");w(this.j,function(){return"....the list is: "+JSON.stringify(a)});this.h=!1;var c=0,d=[],e=new Set;a.forEach(function(a){d.push(Bm(b,a).then(function(a){e.add(a.getId());zm(b,a)},function(){c++}))});$l(d).then(function(){b.h||Cm(b,e).then(function(){var a=b.a.size;Dm(b,a,a+c)})})};
var Dm=function(a,b,c){a.b={Zb:b,fc:c};36E5>Date.now()-a.g||(b=a.b,jb("MediaRouter.Dial.AvailableDevicesCount",b.Zb),jb("MediaRouter.Dial.KnownDevicesCount",b.fc),a.g=Date.now())},zm=function(a,b){if(!a.h){w(a.j,"mayAddSink, id = "+b.getId());var c=a.a.get(b.getId());c?c.update(b)&&(w(a.j,"Updated sink "+c.getId()),a.f.bd(c)):(w(a.j,function(){return"Adding new sink "+b.getId()+": "+("name = "+b.eb.friendlyName+(b.kb?", ip = "+b.kb:"")+(b.lb?", model = "+b.lb:"")+", apps = "+JSON.stringify(b.jb))}),
a.a.set(b.getId(),b),a.f.Ld(b))}},Cm=function(a,b){var c=[],d=[];a.a.forEach(function(e){b.has(e.getId())||d.push((e.Qb?rm(a.m,e.Qb):Promise.resolve(!1)).then(function(b){b||(a.a.delete(e.getId()),c.push(e))}))});return $l(d).then(function(){0<c.length&&a.f.sc(c)})},Bm=function(a,b){return mm(a.m,b).then(function(a){var c=a.uniqueId?xm(a.uniqueId):"",e=a.uniqueId?Ol(Nl(),c):b.deviceLabel,f=ym.test(a.modelName);c=new bm(a.friendlyName,c);c.eb.id=e;c.kb=a.ipAddress;c.Rb=a.appUrl;c.Qb=b.deviceDescriptionUrl;
c.lb=a.modelName;return cm(c,!f)})},xm=function(a){0==a.indexOf("uuid:")&&(a=a.substr(5));return a.replace(/-/g,"").toLowerCase()};
vm.prototype.v=function(a){switch(a.code){case "no_valid_network_interfaces":case "network_disconnected":v(this.j,"DIAL error: "+a.code+". Clear device list now.");a=Array.from(this.a.values());this.a.clear();this.f.sc(a);Dm(this,0,0);this.h=!0;break;case "no_listeners":case "socket_error":case "cellular_network":case "unknown":v(this.j,"DIAL error: "+a.code+". Keep device list.");break;default:v(this.j,"Unhandled DIAL error: "+a.code)}};
var Em=function(a,b){return a.a.get(b)||null},Gm=function(a,b){var c=[];a.a.forEach(function(a){"available"==dm(a,b)&&c.push(a.eb)});return new kl(c,Fm[b])};h=vm.prototype;h.mh=function(){return this.b};h.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];if(a==chrome.dial.onDeviceList)this.u.apply(this,[].concat(k(c)));else if(a==chrome.dial.onError)this.v.apply(this,[].concat(k(c)));else throw Error("Unhandled event");};h.ha=function(){return"dial.DialSinkDiscoveryService"};
h.xa=function(){return[new Hm(Array.from(this.a),this.b),{deviceCountMetricsRecordTime:this.g}]};h.Da=function(){var a=Gg(this);if(a){for(var b=ja(a.sinks),c=b.next();!c.done;c=b.next())c=c.value,this.a.set(c[0],em(c[1]));this.b=a.deviceCounts}if(a=Hg(this))this.g=a.deviceCountMetricsRecordTime};
var Fm={YouTube:"https://tv.youtube.com https://tv-green-qa.youtube.com https://tv-release-qa.youtube.com https://web-green-qa.youtube.com https://web-release-qa.youtube.com https://www.youtube.com".split(" "),Netflix:["https://www.netflix.com"],Pandora:["https://www.pandora.com"],Radio:["https://www.pandora.com"],Hulu:["https://www.hulu.com"],Vimeo:["https://www.vimeo.com"],Dailymotion:["https://www.dailymotion.com"],"com.dailymotion":["https://www.dailymotion.com"]},ym=/Eureka Dongle|Chromecast Audio/i,
Hm=function(a,b){this.sinks=a;this.deviceCounts=b};var Im=function(a,b){this.j=Pa("mr.dial.AppDiscoveryService");this.a=new Set;this.b=a;this.h=b;this.l=new Map;this.m=new Map;this.f=null;this.g=!1};Im.prototype.init=function(){Jg(this)};Im.prototype.start=function(){this.j.info("Starting periodic scanning.");this.g||(this.g=!0,Jm(this))};Im.prototype.stop=function(){this.j.info("Stopping periodic scanning.");this.g&&(this.g=!1,this.f&&(clearTimeout(this.f),this.f=null),this.l.clear())};
var Jm=function(a){a.j.info("Start app status scan.");var b=[];Array.from(a.b.a.values()).forEach(function(c){b.push.apply(b,Km(a,c))});Array.from(a.h.a.values()).forEach(function(c){b.push(Lm(a,c))});$l(b).then(function(){a.g&&!a.f&&(w(a.j,"Scan complete; scheduling for next scan."),a.f=setTimeout(function(){w(a.j,"Start app status scan (timer-based)");a.f=null;Jm(a)},6E4))})},Km=function(a,b){if(!b.Jc)return[];for(var c=[],d=ja(a.a),e=d.next();!e.done;e=d.next())c.push(a.u(e.value,b));return c};
Im.prototype.u=function(a,b){var c=this;if("unknown"!=dm(b,a)&&36E5>Date.now()-(b.oe[a]||0)||!b.Jc)return Promise.resolve();w(this.j,"Querying "+b.getId()+" for "+a+" to update app status");return Mm(this,b,a).then(function(d){a:if("Netflix"==d.name)d=!d.extraData||"websocket"!=d.extraData.capabilities||"running"!=d.state&&"stopped"!=d.state?"unavailable":"available";else switch(d.state){case "running":case "stopped":d="available";break a;default:d="unavailable"}Nm(c,b,a,d)},function(d){d instanceof
vl?Nm(c,b,a,"unavailable"):(v(c.j,"Failed to process app availability; "+b.getId()+" does not support app availability"),cm(b,!1))})};
var Lm=function(a,b){var c=Em(a.b,b.xb.sinkId);if(!c)return v(a.j,"Activity refers to nonexistent sink: "+b.xb.id),Promise.resolve();if(!c.Jc)return Promise.resolve();var d=b.appName;w(a.j,"Querying "+c.getId()+" for "+d+" to update activity");return Mm(a,c,d).then(function(b){"running"!=b.state&&Om(a,c,d)},function(){return Om(a,c,d)})},Pm=function(a,b){var c=a.m.get(b.getId());c||(c=new xl(b),w(a.j,"Created DIAL client for "+b.getId()),a.m.set(b.getId(),c));return c},Mm=function(a,b,c){var d=Qm(b,
c),e=a.l.get(d);if(e)return e;e=Bl(Pm(a,b),c);a.l.set(d,e);b=function(){a.l.delete(d)};e.then(b,b);return e},Qm=function(a,b){return a.getId()+":"+b},Nm=function(a,b,c,d){w(a.j,"Got app status "+d+" from "+b.getId()+" for "+c);var e=dm(b,c);b.jb[c]=d;b.oe[c]=Date.now();d!=e&&a.b.f.bd(b)},Om=function(a,b,c){(b=Tl(a.h,b.getId()))&&b.appName==c&&Vl(a.h,b.xb.id)},Rm=function(a,b){return Array.from(a.b.a.values()).some(function(a){return"unknown"==dm(a,b)})};Im.prototype.ha=function(){return"dial.AppDiscoveryService"};
Im.prototype.xa=function(){return[Array.from(this.a)]};Im.prototype.Da=function(){var a=Gg(this);this.a=new Set(a||[])};var Sm=function(a,b){this.appName=a;this.launchParameter=void 0===b?"":b},Vm=function(a){try{var b=new URL(a)}catch(c){return Tm.info("Invalid URL: "+a),null}switch(b.protocol){case "dial:":a:if(a=b.pathname,a.match(/^\w+$/)){if(b=b.searchParams.get("postData")||void 0)try{b=Fl(b)}catch(c){v(Tm,"Invalid base64 encoded postData:"+b);a=null;break a}a=new Sm(a,b)}else v(Tm,"Invalid app name: "+a),a=null;return a;case "https:":return Um(b);default:return w(Tm,"Unhandled protocol: "+b.protocol),null}},
Um=function(a){var b=a.hash;if(!b)return null;a=(a=Wm.exec(b))?a[1]:null;if(!a)return null;a=decodeURIComponent(a);if(b=(b=Xm.exec(b))?b[1]:void 0)try{b=Fl(b)}catch(c){return v(Tm,"Invalid base64 encoded postData:"+b),null}return new Sm(a,b)},Tm=Pa("mr.dial.PresentationUrl"),Wm=/__dialAppName__=([A-Za-z0-9-._~!$&'()*+,;=%]+)/,Xm=/__dialPostData__=([A-Za-z0-9]+={0,2})/;var Ym=function(a,b,c){this.g=a;this.a=b||new vm(this);this.b=new Rl(this);this.f=c||new Im(this.a,this.b);this.j=Pa("mr.DialProvider")};h=Ym.prototype;h.getName=function(){return"dial"};h.Ga=function(a){a=a?a.enable_dial_discovery:!0;this.j.info("Dial Discovery enabled: "+a+"...");this.b.init();this.a.init();this.f.init();a?(this.a.start(),Sl(this)):this.a.stop()};h.Cd=function(a){w(this.j,"GetAvailableSinks for "+a);return(a=Vm(a))?Gm(this.a,a.appName):ll};
h.startObservingMediaSinks=function(a){var b=Vm(a);if(b){a=this.f;b=b.appName;if(!a.a.has(b)||Rm(a,b))a.a.add(b),0!=a.b.a.size&&(a.g?Array.from(a.b.a.values()).forEach(a.u.bind(a,b)):a.start());Sl(this)}};h.stopObservingMediaSinks=function(a){if(a=Vm(a))this.f.a.delete(a.appName),Zm(this)};h.startObservingMediaRoutes=function(){Sl(this)};h.stopObservingMediaRoutes=function(){Zm(this)};
var Zm=function(a){(0==a.a.a.size||0==a.f.a.size&&0==a.b.a.size)&&a.f.stop()},Sl=function(a){0<a.a.a.size&&(0<a.f.a.size||0<a.b.a.size)&&a.f.start()};h=Ym.prototype;h.Kd=function(a){return(a=Em(this.a,a))?a.eb:null};h.rc=function(){return Wl(this.b)};
h.createRoute=function(a,b,c,d){var e=this,f=Em(this.a,b);if(!f)return Zl(0),jf(Error("Unkown sink: "+b));Nl().f=new Kl(f.lb,f.Ja());var g=Vm(a);if(!g)return jf(Error("No app name set."));var l=g.appName,r=new xl(f);return kf(Bl(r,l).then(function(a){if("running"==a.state)return Al(r,l)}).then(function(){return r.launchApp(l,g.launchParameter)}).then(function(){return $m(e,b,a,l,c,d)}).catch(function(a){Zl(3);throw a;}))};h.joinRoute=function(){return jf(Error("Not supported"))};
h.connectRouteByRouteId=function(){return jf(Error("Not supported"))};h.detachRoute=function(){};var $m=function(a,b,c,d,e,f){Zl(1);b=gk(e,a.getName(),b,c,!0,d);b.offTheRecord=f;a.b.add(new Ql(b,d));return b};Ym.prototype.Ld=function(a){this.g.onSinkAvailabilityUpdated(this,1);Sl(this);Km(this.f,a);this.g.Jb();Nl().b=new Kl(a.lb,a.Ja())};
Ym.prototype.sc=function(a){var b=this;if(0==this.a.a.size)this.g.onSinkAvailabilityUpdated(this,0);Zm(this);a.forEach(function(a){var c=b.b;a=a.getId();if(a=Tl(c,a))c.a.delete(a.xb.id),Ul(c.b,a)});this.g.Jb()};Ym.prototype.bd=function(){this.g.Jb()};var Ul=function(a,b){b=b.xb;if(b.isLocal)a.g.onPresentationConnectionStateChanged(b.id,"terminated");Zm(a);a.g.Md(a,b)};h=Ym.prototype;
h.terminateRoute=function(a){var b=this.b.a.get(a)||null;if(!b)return Promise.reject(new Cl(3,"Route in DIAL provider not found for routeId "+a));Vl(this.b,a);return(a=Em(this.a,b.xb.sinkId))?Al(new xl(a),b.appName):Promise.reject(new Cl(3,"Sink in DIAL provider not found for sinkId "+b.xb.sinkId))};h.Tc=function(){throw Error("Not implemented.");};h.oc=function(){return null};h.sendRouteMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};
h.sendRouteBinaryMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};h.xd=function(a,b){b=Em(this.a,b);return!b||Hf(a)?!1:(a=Vm(a))?"available"==dm(b,a.appName):!1};h.Kc=function(){return!1};h.searchSinks=function(){return Ma()};h.createMediaRouteController=function(){return Ma()};h.provideSinks=function(a){Am(this.a,a)};var an=function(a){return"available"==a||"available_rescan"==a};var cn=function(a,b,c,d,e,f){a=Ol(Nl(),a);this.b=new am(a,b,bn(d));this.lb=c||null;this.a=d||null;this.kb=e||null;this.sa=f||null;this.jb={};this.cc=!1},dn=function(a){if(!a.lb||!a.Ja())return null;var b=new cn(a.eb.id,a.eb.friendlyName,a.lb,void 0,a.Ja(),Nl().a||8009);b.b.id=a.eb.id;b.cc=!0;return b},en=function(a,b){if(b=a.update(b.b.friendlyName,b.Ja(),b.Ba(),b.a))a.cc=!1;return b};
cn.prototype.update=function(a,b,c,d){var e=!1;this.b.friendlyName!=a&&(this.b.friendlyName=a,e=!0);null!=b&&this.kb!=b&&(this.kb=b,e=!0);null!=c&&this.sa!=c&&(this.sa=c,e=!0);null!=d&&this.a!=d&&(this.a=d,e=!0);return e};var bn=function(a){return a&1?"cast":a&32?"cast_audio_group":"cast_audio"};cn.prototype.getId=function(){return this.b.id};
var fn=function(a){var b=new cn("",a.friendlyName,a.modelName,a.capabilities,a.ip,a.port);b.b.id=a.id;b.cc=a.discoveredByDial;b.jb=a.appStatusMap;for(var c in b.jb)"unavailable"==b.jb[c]&&(b.jb[c]="unavailable_rescan");return b};cn.prototype.Ja=function(){return this.kb};cn.prototype.Ba=function(){return this.sa};var gn=function(a,b){return a.jb[b]||"unknown"};var hn={kp:0,Yo:1},jn={Pr:0,Hj:1,Mq:2},kn={DIAL:0,pp:1,qp:2,Un:3},ln={Zp:0,TIMEOUT:1,FAILED:2},mn={Og:0,en:1,Mn:2,to:3,Gn:4,Jp:5,On:6,xq:7},nn={Yi:0,SUCCESS:1},on=function(a){ib("MediaRouter.Cast.Session.Ended",a,jn)},pn=function(a){ib("MediaRouter.Cast.Channel.ConnectResult",a,nn)},qn=function(a){ib("MediaRouter.Cast.Discovery.Type",a,kn)},rn=function(a){ib("MediaRouter.Cast.Session.Fail",a,ln)};var sn=function(a,b){this.f=a;this.b=b;this.a=this.f.a;this.j=Pa("mr.cast.CastDialSinkDiscoveryCallbacks");this.g=!0},tn=function(a,b){var c=a.a.b(b.getId());if(c)return c;(b=b.Ja())?(a=a.a,c=Nl().a||8009,a=a.u.get(b+":"+c)):a=null;return a};sn.prototype.Ld=function(a){tn(this,a)?qn(2):un(this,a);this.b.Ld(a)};var un=function(a,b){if(a.f.B||a.g){var c=dn(b);c&&vn(a.a,c).then(function(d){d?tn(a,b)?qn(2):(wn(a.a,c),qn(0)):hb("MediaRouter.Dial.Sink.Discovered.NonCast")},wa)}};
sn.prototype.sc=function(a){var b=this;x(a,function(a){var c=b.a.b(a.getId());c&&c.cc&&xn(b.a,a.getId())});this.b.sc(a)};sn.prototype.bd=function(a){var b=this.a.b(a.getId());b?b.cc&&(b.update(a.eb.friendlyName,a.Ja(),b.Ba(),b.a)&&this.j.info("Updated Cast sink with DIAL sink: "+a.getId()),yn(this.a.f,b)):un(this,a);this.b.bd(a)};var zn=function(a,b){this.u=new sn(b,this);this.m=new vm(this.u);this.f=new Ni;this.b=a;this.h=this.l=0;this.g=new hl;this.a=new Ym(this,this.m)};h=zn.prototype;h.ha=function(){return"cast.DialProviderWrapper"};h.xa=function(){return[new An(Ri(this.f),this.l,this.h,this.g.S())]};h.Da=function(){var a=Gg(this);a&&(Mi(this.f,a.b),this.l=a.sequenceNumber,this.h=a.f,gl(this.g,a.a))};h.getName=function(){return this.a.getName()};
h.Ga=function(a){this.a.Ga(a);Jg(this);this.u.g=a?a.enable_dial_discovery:!0};h.rc=function(){return this.a.rc()};h.Hf=function(){};h.Cd=function(a){return(a=Bn(a))?this.a.Cd(a):ll};h.startObservingMediaSinks=function(a){(a=Bn(a))&&this.a.startObservingMediaSinks(a)};h.stopObservingMediaSinks=function(a){(a=Bn(a))&&this.a.stopObservingMediaSinks(a)};h.startObservingMediaRoutes=function(a){(a=Bn(a))&&this.a.startObservingMediaRoutes(a)};h.stopObservingMediaRoutes=function(a){(a=Bn(a))&&this.a.stopObservingMediaRoutes(a)};
h.Kd=function(a){return this.a.Kd(a)};
var En=function(a,b,c,d,e){var f=Bn(b);if(!f)return Promise.reject(Error("Invalid source"));var g=Vm(f),l=Em(a.m,c);if(!l)return Promise.reject(Error("Attempting custom launch with closed route"));var r=g.appName;if(!r)return Promise.reject(Error("No app name given"));var u=Cn(b);return u?Bl(new xl(l),r).then(function(b){var z=$m(a.a,c,f,r,e,d);b={routeId:z.id,sinkId:l.getId(),appName:r,Tg:b,launchParameter:g.launchParameter,session:null,clientId:null};a.f.set(z.id,b);var G=Dn(a,b.sinkId),ha=new zk("receiver_action",
{receiver:G,action:chrome.cast.wd.CAST});ha.clientId=u;a.b.gc(a,b.routeId,ha);ha=chrome.cast.L;var La=String(a.h);a.h=(a.h+1)%9007199254740992;G=new ha(La,"",b.appName,[],G);b.session=G;b.clientId=u;G=new zk("new_session",G);G.clientId=u;a.b.gc(a,b.routeId,G);return z}):Promise.reject(Error("No client ID"))};zn.prototype.createRoute=function(a,b,c,d,e,f,g){return a.startsWith("cast-dial:")||Fn.test(a)?kf(En(this,a,b,d,c)):this.a.createRoute(a,b,c,d,e,f,g)};
zn.prototype.terminateRoute=function(a){var b=this.f.get(a);if(b&&b.session&&b.clientId){var c={receiver:Dn(this,b.sinkId),action:chrome.cast.wd.STOP};c=new zk("receiver_action",c);c.clientId=b.clientId;this.b.gc(this,b.routeId,c);this.b.onPresentationConnectionStateChanged(b.routeId,"terminated")}return this.a.terminateRoute(a)};
zn.prototype.sendRouteMessage=function(a,b,c){var d=JSON.parse(b);switch(d.type){case "client_connect":return b=d.clientId,(a=this.f.get(a))?(c=Dn(this,a.sinkId),c.receiverType=chrome.cast.ne.DIAL,c=new zk("custom_dial_launch",new chrome.cast.tg(c,a.Tg.state,a.Tg.extraData)),c.clientId=b,b=this.l,this.l=(this.l+1)%9007199254740992,c.sequenceNumber=b,this.g.add(c.sequenceNumber),this.b.gc(this,a.routeId,c),a=Promise.resolve()):a=Promise.reject(Error("Unknown route")),a;case "custom_dial_launch":if(this.g.contains(d.sequenceNumber))return this.g.remove(d.sequenceNumber),
b=d.message,(a=this.f.get(a))?b&&!b.doLaunch?a=Promise.resolve():(c=Em(this.m,a.sinkId))?(c=new xl(c),d=a.launchParameter,d=(b?b.launchParameter:null)||d,a=c.launchApp(a.appName,d)):a=Promise.reject(Error("Custom launch response for sink that no longer exists")):a=Promise.reject(Error("Unknown route")),a;break;case "v2_message":if("STOP"==d.message.type)return this.terminateRoute(a),Promise.resolve()}return this.a.sendRouteMessage(a,b,c)};
zn.prototype.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};var Dn=function(a,b){a=Em(a.m,b);b=new chrome.cast.bf(b,a.eb.friendlyName);b.ipAddress=a.Ja();b.receiverType=chrome.cast.ne.DIAL;return b};h=zn.prototype;h.Tc=function(a){return this.a.Tc(a)};h.oc=function(a){return this.a.oc(a)};h.xd=function(a,b){return a.startsWith("cast-dial:")||Fn.test(a)||this.a.xd(a,b)};h.Kc=function(a,b,c){return this.a.Kc(a,b,c)};
h.connectRouteByRouteId=function(a,b,c,d,e){return this.a.connectRouteByRouteId(a,b,c,d,e)};h.joinRoute=function(a,b,c,d,e,f){return this.a.joinRoute(a,b,c,d,e,f)};h.detachRoute=function(a){this.f.remove(a);this.a.detachRoute(a)};h.Jb=function(){this.b.Jb()};h.onSinkAvailabilityUpdated=function(a,b){this.b.onSinkAvailabilityUpdated(a,b)};h.dd=function(a,b){this.b.dd(this,b)};h.Md=function(a,b){this.b.Md(this,b)};h.hc=function(a,b){this.b.hc(this,b)};h.gc=function(a,b,c){this.b.gc(this,b,c)};
h.onPresentationConnectionStateChanged=function(a,b){this.b.onPresentationConnectionStateChanged(a,b)};h.onPresentationConnectionClosed=function(a,b,c){this.b.onPresentationConnectionClosed(a,b,c)};h.uf=function(a){return this.b.uf(a)};h.wf=function(){return this.b.wf()};h.tc=function(a){this.b.tc(a)};h.Ie=function(a,b,c){this.b.Ie(this,b,c)};h.If=function(a){this.b.If(a)};h.Ld=function(a){this.a.Ld(a)};h.sc=function(a){this.a.sc(a)};h.bd=function(a){this.a.bd(a)};h.Ef=function(){};h.Eh=function(){};
h.searchSinks=function(a,b){return this.a.searchSinks(a,b)};h.provideSinks=function(a){this.a.provideSinks(a)};h.createMediaRouteController=function(){return Ma()};h.Xf=function(a){this.b.Xf(a)};h.Cf=function(){return this.b.Cf()};h.jd=function(a,b){return this.b.jd(a,b)};
var Bn=function(a){try{var b=new URL(a)}catch(e){return null}if("dial:"==b.protocol)return a;if("cast-dial:"==b.protocol){var c=b;a="cast-dial:"!=c.protocol?null:new xk(c.pathname,c.searchParams.get("dialPostData"),c.searchParams.get("clientId"));c=a.f;var d=a.a}else if("https:"==b.protocol){a=el(a);if(!a)return null;c=a.m;d=a.s}c?(a=d||"",c=new URL("dial:"+c),a&&c.searchParams.set("postData",a),c=c.toString()):c=null;return c},Cn=function(a){try{var b=new URL(a)}catch(c){return null}return"cast-dial:"==
b.protocol?b.searchParams.get("clientId"):"https:"==b.protocol?fl(a):null},An=function(a,b,c,d){this.b=a;this.sequenceNumber=b;this.f=c;this.a=d},Fn=/__dialAppName__/;window.navigator.userAgent.match(/Chrome\/([0-9]+)/);var Gn=function(a,b){this.type=a;this.entryPoint=b};q("castApp.frontEnd.ExtensionMessage",Gn);var Hn=function(a){return"urn:x-cast:com.google.cast."+a},In=Hn("tp.connection"),Jn=Hn("receiver"),Kn=Hn("remoting"),Ln=Hn("media"),Mn=Hn("webrtc"),Nn=Hn("broadcast"),On=Cc({Ar:In,Br:Hn("tp.heartbeat"),Lq:Jn,Pq:Kn,sp:Ln,vp:Hn("media.universalRemote.optIn"),Ur:Mn,qn:Nn});var Pn=function(a,b){this.f=b;this.X=a;this.X.l=this.b.bind(this);this.a=new Ni;this.u=new Ni;this.g=new Ni;this.H=null;this.s=this.B="";this.l=null;this.I=this.v=!1;this.F=[];this.j=Pa("mr.cast.SinkDiscoveryService");this.w=new Set;this.h={Zb:0,fc:0};this.m=this.A=0};qa(Pn,Mf);Pn.prototype.init=function(){Jg(this);this.v&&(Qn(this),Rn(this));Wf("mr.cast.SinkDiscoveryService",this)};var Qn=function(a){a.j.info("Start listening to network changes");ok().addListener()};
Pn.prototype.start=function(){var a=Date.now(),b=mk();if(b.a){if(6E4>a-this.H)return;this.j.info("Forcing mdns discovery");chrome.mdns.forceDiscovery(wa);b=mk();b.removeListener()}else this.j.info("Adding mdns listener");b.addListener();this.H=a};Pn.prototype.stop=function(){this.j.info("Stopping...");mk().removeListener()};
Pn.prototype.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];if(a==chrome.mdns.onServiceList)this.K.apply(this,[].concat(k(c)));else if(a==chrome.networkingPrivate.onNetworksChanged||a==chrome.networkingPrivate.onNetworkListChanged)Rn(this);else throw Error("Unhandled event");};
var Sn=function(a,b){if(-1==b.serviceName.indexOf("._googlecast."))return null;var c={};b.serviceData.forEach(function(a){0==a.search(/[a-z]{2}=.+/)&&(c[a.substring(0,2)]=a.substring(3))});var d=c.id;if(!d)return v(a.j,"Missing ID"),null;var e=Number(b.serviceHostPort.substring(b.serviceHostPort.lastIndexOf(":")+1));if(isNaN(e)||0>e||65535<e)return v(a.j,"Missing or invalid port"),null;var f=c.fn;if(!f||!b.ipAddress)return v(a.j,"Missing friendly name or IP address"),null;a=Number(c.ca);return new cn(d,
f,c.md||"",isNaN(a)?0:a,b.ipAddress,e)},Un=function(a,b){a.j.info("addSinks returned "+b.length+" sinks");w(a.j,function(){return"....the list is: "+JSON.stringify(b)});var c=new Set(a.a.Qa());b.forEach(function(b){var d=b.sink_id,f=b.extra_data.cast_media_sink,g=f.ip_endpoint?f.ip_endpoint.address:f.ip_address,l=f.ip_endpoint?f.ip_endpoint.port:Nl().a||8009;b=new cn(d,b.name,f.model_name,f.capabilities,g.address_bytes.join("."),l);(d=a.a.get(b.getId()))?en(d,b)&&yn(a.f,d):wn(a,b);c.delete(b.getId())});
c.forEach(function(b){xn(a,b)});a.h={Zb:a.a.da(),fc:Tn(a)}};Pn.prototype.K=function(a){var b=this;this.j.info("Registering "+a.length+" devices");0!=this.m&&(clearTimeout(this.m),this.m=0);a=Vn(this,a).map(function(a){return Wn(b,a,!0)});$l(a).then(function(){b.h={Zb:b.a.da(),fc:Tn(b)};Xn(b)})};
var Xn=function(a){0!=a.m||36E5>Date.now()-a.A||(a.m=setTimeout(function(){var b=a.h;jb("MediaRouter.Cast.Discovery.KnownDevicesCount",b.fc);jb("MediaRouter.Cast.Discovery.ConnectedDevicesCount",b.Zb);a.A=Date.now();a.m=0},5E3))};Pn.prototype.mh=function(){return this.h};
var Tn=function(a){var b=a.w.size;xi(a.a.Ua(!1),function(c){a.w.has(c.getId())||b++});return b},Wn=function(a,b,c){if(a.g.Va(b.getId()))return Promise.resolve();a.g.set(b.getId(),b);return vn(a,b).then(function(d){d?(d=a.a.get(b.getId()),c&&(d?d.cc&&qn(3):qn(1)),wn(a,b)):(a.j.info("Inaccessible sink: "+b.getId()),xn(a,b.getId()));a.g.remove(b.getId())})},Yn=function(a,b){return void 0!=a.F.find(function(a){return a.ipAddress==b.ipAddress})},Vn=function(a,b){var c=[];a.w.clear();b.forEach(function(b){if(!Yn(a,
b)&&(b=Sn(a,b))){var d=b.getId();a.w.add(d);if(a.g.Va(d)){var f=a.g.get(d);if(f.Ja()==b.Ja()&&f.Ba()==b.Ba()){a.j.info("Sink has pending connection "+d);return}v(a.j,"Pending sink changed ip "+d);a.g.remove(d)}(d=a.a.get(d))?en(d,b)&&yn(a.f,d):c.push(b)}});return c},Zn=function(a,b){var c=a.a.get(b.getId()),d=null,e=b.Ja(),f=b.Ba();null!=e&&null!=f&&(d=a.u.get(e+":"+f));if(c&&!d){var g=b.Ja(),l=b.Ba();g&&l&&a.u.remove(g+":"+l)}d&&!c&&a.a.remove(d.getId());a.a.set(b.getId(),b);null!=e&&null!=f&&a.u.set(e+
":"+f,b)},wn=function(a,b){a.j.info("Adding sink "+b.getId());Zn(a,b);a.v||(a.v=!0,Qn(a));a=a.f;a.b.onSinkAvailabilityUpdated(a,1);yn(a,b);$n(a.l,b);Nl().b=new Kl(b.lb,b.Ja())},xn=function(a,b){var c=a.a.get(b);if(c){a.j.info("Removing sink "+b);a.a.remove(b);b=c.Ja();var d=c.Ba();null!=b&&null!=d&&a.u.remove(b+":"+d);a.f.I(c)}},ao=function(a){var b=a.a.S();a.a.clear();a.u.clear();b.forEach(a.f.I,a.f)},vn=function(a,b){w(a.j,"Checking access to "+b.getId());return bo(a.X,b).then(function(a){if(b.cc){var c=
4;a.audioOnly||(c|=1);b.a=c;b.b.iconType=bn(b.a)}return!0},function(){return!1})},co=function(a){a.j.info("Pruning inactive sinks.");xi(a.a.Ua(!1),function(b){a.g.set(b.getId(),b);vn(a,b).then(function(c){c||xn(a,b.getId());a.g.remove(b.getId())})})};Pn.prototype.b=function(a){return this.a.get(a,null)};var eo=function(a,b){var c=[];xi(a.a.Ua(!1),function(a){an(gn(a,b))&&c.push(a)});return c};Pn.prototype.ha=function(){return"cast.SinkDiscoveryService"};
Pn.prototype.xa=function(){var a=this,b={};xi(this.a.Ua(!0),function(c){var d=a.a.get(c);d={id:d.getId(),ip:d.Ja(),port:d.Ba(),friendlyName:d.b.friendlyName,modelName:d.lb,capabilities:d.a,discoveredByDial:d.cc,appStatusMap:d.jb};b[c]=d});return[new fo(b,this.s,this.h),new go(this.v,this.A)]};
Pn.prototype.Da=function(){var a=Gg(this);if(a&&3==a.version){this.s=a.networkIds;this.h=a.deviceCounts;a=a.sinkMap;this.I=0<Object.keys(a).length;for(var b in a){var c=fn(a[b]);this.b(c.getId())||Zn(this,c)}co(this)}if(b=Hg(this))this.v=b.hasSavedSinks,this.A=b.lastSinkCountMetricRecordTime||0};
var ho=function(a,b){a.I=0<Object.keys(b).length;for(var c in b){var d=fn(b[c]);a.b(d.getId())||Wn(a,d,!1)}},Rn=function(a){a.j.info("Fetching networks state");a.l&&Rg(a.l);chrome.networkingPrivate.getNetworks({networkType:"All",visible:!0,configured:!0},function(b){for(var c=[],d=0;d<b.length;d++)"Connected"==b[d].ConnectionState&&c.push(b[d].GUID);io(a,c.sort().join(","))})},io=function(a,b){a.j.info(function(){return"Update current network "+jo(b)});b!=a.B&&(a.l&&(Ig.delete(a.l.ha()),a.l=null),
b?(a.s&&b!=a.s?ao(a):co(a),a.B=b,a.s=b,a.l=new ko(a,a.B)):a.B="")},jo=function(a){for(var b=0,c=0;c<a.length;c++)b+=a.charCodeAt(c);return b},fo=function(a,b,c){this.sinkMap=a;this.networkIds=b;this.deviceCounts=c;this.version=3},go=function(a,b){this.hasSavedSinks=a;this.lastSinkCountMetricRecordTime=b},ko=function(a,b){this.a=a;this.b=b;Jg(this)};ko.prototype.ha=function(){return"cast.NetworkSink."+this.b};
ko.prototype.xa=function(){var a=this,b=null,c=this.a.xa();c&&(this.a.I||0<this.a.a.da())&&(b=c[0]);this.a.j.info(function(){return"Saving sink data for network "+jo(a.b)});return[null,b]};ko.prototype.Da=function(){var a=this;this.a.j.info(function(){return"Restoring sink data for network "+jo(a.b)});var b=Hg(this);b&&3==b.version&&ho(this.a,b.sinkMap)};var lo=function(){this.type="GET_STATUS";this.requestId=0};var mo=function(a,b,c){this.type="APPLICATION_BROADCAST";this.requestId=0;this.appIds=a;this.namespace=b;this.message=c};var no=function(a){this.type="LAUNCH";this.requestId=0;this.appId=a;this.language=null};var oo=function(a,b){this.requestId=a;this.b=b;this.Ci=null};oo.prototype.a=function(){};var po=function(){this.a=new Ni},qo=function(a,b){a.a.set(b.requestId,b);b.Ci=setTimeout(function(){a.a.remove(b.requestId);b.a()},b.b)},ro=function(a,b){var c=a.a.get(b);if(!c)return null;clearTimeout(c.Ci);a.a.remove(b);return c};var so=function(a,b){this.b=a;this.f=b;this.a=new po;this.g=new hk("cast.RequestIdGenerator")};so.prototype.init=function(){Jg(this.g)};var uo=function(a,b,c,d){var e=ik(a.g);b.requestId=e;b=new kb;c=new to(e,b,n(c)&&0<c?c:6E5,d);qo(a.a,c);return c};
so.prototype.sendRequest=function(a,b,c,d,e,f){var g=this;if(!On.hasOwnProperty(c))return Promise.reject(Error("Custom namespace is not supported"));var l=uo(this,a,m(d)?d:3E3,e),r=l.ta;vo(this.b,b,c,a,e||this.f,f).then(null,function(){ro(g.a,l.requestId);r.reject(wo)});return r.a};so.prototype.sendMessage=function(a,b,c,d,e,f){var g=this,l=uo(this,a,m(d)?d:3E3,e),r=l.ta;vo(this.b,b,c,a,e||this.f,f).then(function(){ro(g.a,l.requestId);r.resolve(!0)},function(){ro(g.a,l.requestId);r.reject(wo)});return r.a};
var xo=function(a,b,c){var d=new no(b.appId);d.language=b.language?b.language:chrome.i18n.getUILanguage?chrome.i18n.getUILanguage():chrome.runtime.getManifest().default_locale;return a.sendRequest(d,c,Jn,b.requestSessionTimeout)},yo=Error("Timeout"),wo=Error("Failed to send message"),to=function(a,b,c,d){oo.call(this,a,c);this.ta=b;this.sourceId=d};qa(to,oo);to.prototype.a=function(){this.ta.reject(yo)};var zo=function(a,b){this.type="cast_app";this.originId=window["castApp.eventPage.Message.OriginID"]||void 0;this.subtype=a;this.devices=b;this.logRecord=this.deviceJustSetUp=void 0};q("castApp.eventPage.Message",zo);var Ao=function(a,b,c){this.ipAddress=a;this.appId=b;this.sessionId=c};zo.DeviceData=Ao;zo.DeviceJustSetUp=function(a,b,c,d){this.ipAddress=a;this.name=b;this.udn=c;this.modelName=d};zo.DeviceCapabilities=function(){};
zo.LogRecord=function(a,b,c,d){this.levelValue=a;this.msg=b;this.loggerName=c;this.time=d};var Co=function(a,b){this.f=a;this.g=b;this.b=new Ni;this.a=new hl;this.l=0;this.u=new Ni("serviceCheck",this.Uk.bind(this),"startDeviceMonitor",this.Vk.bind(this),"releaseDeviceMonitor",this.Tk.bind(this),"deviceJustSetUp",this.Qk.bind(this),"logRecord",this.Rk.bind(this));chrome.runtime.onMessage.addListener(this.m.bind(this));chrome.runtime.onMessageExternal.addListener(this.h.bind(this));Bo(this,"serviceReady")};Co.prototype.j=Pa("castApp.eventPage.Service");
var Fo=function(a){if(Do(a)){var b=new hl;xi(a.f.a.Ua(!1),function(a){var c=a.Ja();b.add(c);this.b.Va(c)||this.g.sendRequest(new lo,a,Jn)}.bind(a));var c=!1;a.b.Qa().forEach(function(a){b.contains(a)||(this.b.remove(a),c=!0)}.bind(a));c&&Eo(a)}},Do=function(a){if(0===a.a.da())return!1;var b=Ka();3E4<b-a.l&&(a.l=b,chrome.tabs.query({url:["chrome://cast/*","chrome-extension://"+chrome.runtime.id+"/cast_setup/*"]},function(a){0===a.length?(this.j.info("No tabs found. Clearing device monitor clients."),
this.a.clear()):this.j.info(function(){return"Tab check found active tabs: "+a.map(function(a){return a.id})})}.bind(a)));b=a.a.da();a.j.info("Monitor client count: "+b);return 0<b};Co.prototype.m=function(a,b,c){if("object"!==typeof a||"cast_app"!==a.type)return!1;var d=this.u.get(a.subtype);if(!d)return!1;if(!a.originId)return Hb("Missing origin ID in the incoming message."),!1;try{var e=d(a,b,c);e&&c(e)}catch(f){this.j.error("Error while handling request",f)}return!1};
var Bo=function(a,b,c){var d=new zo(b,c);w(a.j,function(){return"Sending message: "+JSON.stringify(d)});chrome.runtime.sendMessage(d)};h=Co.prototype;h.Uk=function(){Bo(this,"serviceReady")};h.Vk=function(a){this.a.contains(a.originId)?this.j.info("Client: "+a.originId+"already registered, dispatching current device list."):(this.j.info("Registering monitor client: "+a.originId),this.a.add(a.originId));Eo(this);Go(this)};h.Tk=function(a){this.j.info("Unregistering monitor client: "+a.originId);this.a.remove(a.originId)};
h.Qk=function(a){a=a.deviceJustSetUp;var b=a.udn.replace(/-/g,"").toLowerCase(),c;a.capabilities&&(c=(a.capabilities.audioOutSupported?4:0)|(a.capabilities.videoOutSupported?1:0));c=new cn(b,a.name,a.modelName,c,a.ipAddress,Nl().a||8009);Wn(this.f,c,!0)};h.Rk=function(a){a=a.logRecord;Sa({level:Xa(a.levelValue),G:a.loggerName,time:a.time,message:a.msg})};
var Eo=function(a){var b=a.b.S();Bo(a,"devices",b)},Go=function(a){w(a.f.j,"Executing forceDiscovery.");chrome.mdns.forceDiscovery(wa);a.f.a.S().forEach(function(a){this.g.sendRequest(new lo,a,Jn)}.bind(a))};Co.prototype.h=function(a,b,c){switch(a.type){case "handshake":c(new Gn("handshake"));break;case "launch":b=b.tab&&n(b.tab.id)?b.tab.id:null,null===b||"setup"!==a.entryPoint&&"offers"!==a.entryPoint&&"devices"!==a.entryPoint||chrome.tabs.update(b,{url:"chrome://cast#"+a.entryPoint})}};var Ho=function(a){this.a=a;this.j=Pa("mr.cast.ReceiverStatusQuerier")},Io=function(a,b){return ud(new sd(p(a.b,a,b),3500,5),2).start().then(null,function(c){a.j.info("Failed to get receiver status from "+b.getId());throw c;})};Ho.prototype.b=function(a){this.j.info("Query receiver status: "+a.getId());return this.a.sendRequest(new lo,a,Jn)};var Lo=function(a,b){if(!b.applications||1!=b.applications.length)return null;var c=b.applications[0];a=Jo(a);a=new chrome.cast.L(c.sessionId,c.appId,c.displayName,c.appImages,a);a.senderApps=c.senderApps;a.namespaces=c.namespaces||[];a.transportId=c.transportId;a.statusText=c.statusText;if(!a.sessionId||!(a.namespaces&&0!=a.namespaces.length||Ko(a)))return null;a.receiver.volume=b.volume;ua(b.isActiveInput)&&(a.receiver.isActiveInput=b.isActiveInput);return a},Mo=function(a){var b=[];if(!a)return b;
a&1&&b.push(chrome.cast.Yb.VIDEO_OUT);a&2&&b.push(chrome.cast.Yb.VIDEO_IN);a&4&&b.push(chrome.cast.Yb.AUDIO_OUT);a&8&&b.push(chrome.cast.Yb.AUDIO_IN);a&32&&b.push(chrome.cast.Yb.MULTIZONE_GROUP);return b},Jo=function(a){return new chrome.cast.bf(a.getId(),a.b.friendlyName,Mo(a.a))},No=function(a,b){if(a.statusText!=b.statusText)return!0;var c=a.namespaces||[],d=b.namespaces||[];if(c.length!=d.length)return!0;for(var e={index:0};e.index<c.length;e={index:e.index},e.index++)if(!d.some(function(a){return function(b){return b.name==
c[a.index].name}}(e)))return!0;return a.receiver.volume.level!==b.receiver.volume.level||a.receiver.volume.muted!==b.receiver.volume.muted?!0:!1},Oo=function(a){Aa(a)?a.forEach(Oo):Da(a)&&Object.keys(a).forEach(function(b){null===a[b]?delete a[b]:(Da(a[b])||Aa(a[b]))&&Oo(a[b])})},Po=function(a){return a.namespaces.some(function(a){return a.name==Ln})},Qo=["MultizoneLeader","MultizoneFollower"],Ko=function(a){return null!==a&&"MultizoneLeader"==a.appId},Ro=function(a){return"E8C28D3C"==a||"00000000-0000-0000-0000-000000000000"==
a};var So=function(a,b,c){this.G=Pa("mr.MediaRouteController."+a);this.g=new mojo.Binding(mojo.MediaController,this,b);this.f=c;this.a=new mojo.MediaStatus({title:"",description:"",duration:new mojo.TimeDelta({microseconds:0}),current_time:new mojo.TimeDelta({microseconds:0})});this.s=!1;this.g.setConnectionErrorHandler(this.u.bind(this));this.f.ptr.setConnectionErrorHandler(this.u.bind(this))};So.prototype.u=function(){this.G.info("Encountered Mojo connection error.");this.wa();this.h()};
So.prototype.wa=function(){this.s||(this.s=!0,this.l(),this.g&&(this.g.close(),this.g=null),this.f&&(this.f.ptr.reset(),this.f=null))};var To=function(a){if(a.f)a.f.onMediaStatusUpdated(a.a)};So.prototype.l=function(){};So.prototype.h=function(){};So.prototype.play=function(){};So.prototype.play=So.prototype.play;So.prototype.pause=function(){};So.prototype.pause=So.prototype.pause;So.prototype.Ec=function(){};So.prototype.setMute=So.prototype.Ec;So.prototype.Nb=function(){};
So.prototype.setVolume=So.prototype.Nb;So.prototype.seek=function(){};So.prototype.seek=So.prototype.seek;So.prototype.nf=function(a){a.close();throw Error("Not implemented");};So.prototype.connectHangoutsMediaRouteController=So.prototype.nf;var Uo=function(a){var b=new URL(a);a={};a.scheme=b.protocol.replace(":","");a.host=b.hostname;b=b.port?Number.parseInt(b.port,10):0;switch(a.scheme){case "http":a.port=b||80;break;case "https":a.port=b||443;break;default:throw Error("Scheme must be http or https");}a.suborigin="";return new mojo.Origin(a)},Vo=function(a){return new mojo.TimeDelta({microseconds:Math.floor(1E6*a)})};var Wo=function(a,b,c,d){this.type=a;this.mediaSessionId=b;this.requestId=0;this.sessionId=c;this.currentTime=d},Yo=function(a,b,c,d){So.call(this,"CastRouteController",a,b);this.session=c;this.b=d;Xo(this)};qa(Yo,So);
var Xo=function(a){var b=Zo(a);b&&$o(a,b);a.a.description=a.session.displayName.substring(0,256);a.session.statusText&&a.session.statusText!==a.session.displayName&&(a.a.title=a.session.statusText.substring(0,256));a.a.volume=null===a.session.receiver.volume.level?0:a.session.receiver.volume.level;a.a.is_muted=!!a.session.receiver.volume.muted;a.a.can_mute=a.session.receiver.volume.controlType!==chrome.cast.Pg.FIXED;a.a.can_set_volume=a.a.can_mute;To(a)};Yo.prototype.h=function(){ap(this.b.a,this.session.sessionId)};
Yo.prototype.play=function(){var a=Zo(this);this.a.can_play_pause&&a&&this.a.play_state===mojo.MediaStatus.PlayState.PAUSED&&bp(this.b,this.session,new Wo("PLAY",a.mediaSessionId,this.session.sessionId))};Yo.prototype.play=Yo.prototype.play;Yo.prototype.pause=function(){var a=Zo(this);this.a.can_play_pause&&a&&this.a.play_state!==mojo.MediaStatus.PlayState.PAUSED&&bp(this.b,this.session,new Wo("PAUSE",a.mediaSessionId,this.session.sessionId))};Yo.prototype.pause=Yo.prototype.pause;
Yo.prototype.seek=function(a){var b=Zo(this);a=a?a.microseconds/1E6:0;var c;if(c=this.a.can_seek&&b&&0<=a)c=this.a.duration,c=a<=(c?c.microseconds/1E6:0);c&&bp(this.b,this.session,new Wo("SEEK",b.mediaSessionId,this.session.sessionId,a))};Yo.prototype.seek=Yo.prototype.seek;Yo.prototype.Ec=function(a){this.a.can_mute&&a!==this.a.is_muted&&cp(this.b,this.session,new chrome.cast.Volume(null,a))};Yo.prototype.setMute=Yo.prototype.Ec;
Yo.prototype.Nb=function(a){this.a.can_set_volume&&0<=a&&1>=a&&cp(this.b,this.session,new chrome.cast.Volume(a))};Yo.prototype.setVolume=Yo.prototype.Nb;
var Zo=function(a){return a.session.media.find(function(a){return!a.idleReason})||null},$o=function(a,b){var c=b.media&&(b.media.metadata||b.media.a);c&&c.title?a.a.title=c.title.substring(0,256):a.a.title="";a.a.can_play_pause=b.supportedMediaCommands.includes(chrome.cast.media.mc.PAUSE);a.a.can_seek=b.supportedMediaCommands.includes(chrome.cast.media.mc.SEEK);c=b.playerState;a.a.play_state=c===chrome.cast.media.vd.PLAYING?mojo.MediaStatus.PlayState.PLAYING:c===chrome.cast.media.vd.PAUSED?mojo.MediaStatus.PlayState.PAUSED:
mojo.MediaStatus.PlayState.BUFFERING;a.a.current_time=b.currentTime?Vo(b.currentTime):Vo(0);a.a.duration=b.media&&b.media.duration?Vo(b.media.duration):Vo(0)};var dp=function(a){this.b=a;this.j=Pa("mr.cast.SessionLauncher")},ep=function(a,b,c){ib("MediaRouter.Cast.Session.Type",0,hn);return xo(a.b,b,c).then(a.a.bind(a,c),function(a){a&&yo==a?rn(1):rn(0);throw a;})};dp.prototype.a=function(a,b){w(this.j,"Got launch result from "+a.getId());if("LAUNCH_ERROR"==b.type)throw rn(2),Error(b.reason);a=Lo(a,b.status);this.j.info("Launched session: "+a.sessionId);return a};var fp=function(a,b){this.g=a;this.a=b;this.f=[];this.b=new po},hp=function(a,b){return(a=gp(a.a,b))?a.routeId:null};fp.prototype.listen=function(a,b){this.f[a]=b};var jp=function(a,b,c,d){w(ip,"Sending to "+c);w(ip,JSON.stringify(d));d.clientId=c;a=a.g;a.b.gc(a,b,d)},kp=function(a,b,c){var d=gp(a.a,b);d&&d.a?jp(a,d.routeId,b,c):a.connect(b).then(function(d){d?(d=hp(a,b))?jp(a,d,b,c):v(ip,"No route for "+b):v(ip,"No connected client "+b)},null)};
fp.prototype.connect=function(a){var b=gp(this.a,a);if(null!=b&&b.a)return Promise.resolve(!0);b=hp(this,a);if(!b)return v(ip,"No route for client "+a),Promise.resolve(!1);if(a=this.b.a.get(b,null))return a.ta.a;a=new kb;qo(this.b,new lp(b,a));return a.a};var ip=Pa("mr.cast.ApiMessenger"),lp=function(a,b){oo.call(this,a,3E4);this.ta=b};qa(lp,oo);lp.prototype.a=function(){this.ta.resolve(!1)};var mp=function(a,b,c,d,e,f){this.f=a;this.h=b;this.l=c;this.a=d;this.m=e;this.g=f;this.b=new fp(f,c);this.w=new Ho(this.f);this.A=new dp(this.f)};mp.prototype.init=function(){this.l.init();this.b.listen("v2_message",this.s.bind(this));this.b.listen("app_message",this.u.bind(this));this.b.listen("leave_session",this.v.bind(this))};
var pp=function(a,b,c,d){np(a.a,b).slice().forEach(function(b){b!=d&&op(a,b,c)})},op=function(a,b,c){c.clientId=b;kp(a.b,b,c)},qp=function(a,b,c,d){c={receiver:Jo(c),action:d};op(a,b,new zk("receiver_action",c))};
mp.prototype.s=function(a){var b=a.message,c=b.sessionId;if(c){var d=rp(this.a,c);if(d)if(c=sp(this.a,c))if(c=this.h.b(c))switch(b.type){case "STOP":tp(this,a,c);break;case "LOAD":case "PAUSE":case "PLAY":case "SEEK":case "STOP_MEDIA":case "MEDIA_SET_VOLUME":case "MEDIA_GET_STATUS":case "EDIT_TRACKS_INFO":case "QUEUE_LOAD":case "QUEUE_INSERT":case "QUEUE_UPDATE":case "QUEUE_REMOVE":case "QUEUE_REORDER":case "PRECACHE":up(this,a,c,d);break;case "SET_VOLUME":vp(this,a,c);break;default:v(wp,"Unknown request")}else xp(this,
a,chrome.cast.Pb.INVALID_PARAMETER,"No receiver");else xp(this,a,chrome.cast.Pb.INVALID_PARAMETER,"No sink ID");else xp(this,a,chrome.cast.Pb.INVALID_PARAMETER,"Unknown session ID")}else xp(this,a,chrome.cast.Pb.INVALID_PARAMETER,"No session ID")};
var xp=function(a,b,c,d){c=new chrome.cast.Error(c,d);yp(a,b,c)},yp=function(a,b,c){kp(a.b,b.clientId,new zk("error",c,b.sequenceNumber))},tp=function(a,b,c){var d=b.message;hb("MediaRouter.Cast.Session.End");var e=d.sessionId,f=zp(a.a,e);f&&(f.g=!0);f=function(){Ap(a,e,b)};a.f.sendRequest(d,c,Jn,b.timeoutMillis,b.clientId).then(f,f)},up=function(a,b,c,d){var e=b.message,f=e.type;f in tk&&(e.type=tk[f]);a.f.sendRequest(e,c,Ln,b.timeoutMillis,b.clientId,d.transportId).then(function(c){Bp(a,d,c);kp(a.b,
b.clientId,new zk("v2_message",c,b.sequenceNumber))},function(c){yp(a,b,c)})},vp=function(a,b,c){var d=b.message;delete d.sessionId;a.f.sendRequest(d,c,Jn,b.timeoutMillis,b.clientId).then(function(){kp(a.b,b.clientId,new zk("v2_message",null,b.sequenceNumber))},function(c){yp(a,b,c)})};
mp.prototype.u=function(a){var b=this,c=a.message,d=c.sessionId;if(d){var e=sp(this.a,d);e?(e=this.h.b(e))?(d=rp(this.a,d),Sb(d.namespaces,function(a){return a.name==c.namespaceName})?vo(this.m,e,c.namespaceName,c.message,a.clientId,d.transportId).then(function(){kp(b.b,a.clientId,new zk("app_message",null,a.sequenceNumber))},function(){xp(b,a,chrome.cast.Pb.CHANNEL_ERROR,"Channel to receiver not available")}):xp(this,a,chrome.cast.Pb.INVALID_PARAMETER,"Invalid namespace")):v(wp,"No receiver from sinkId"):
v(wp,"No sinkId from sessionId")}else v(wp,"No sessionId")};
mp.prototype.v=function(a){var b=this;wp.info("Leave session");var c=zp(this.a,a.message);if(c){var d=a.clientId,e=gp(this.l,d);if(e){var f=[],g=[],l=e.tabId,r=e.origin,u=e.autoJoinPolicy;c.b.forEach(function(a){var c=gp(b.l,a);u==chrome.cast.Ob.TAB_AND_ORIGIN_SCOPED&&l==c.tabId&&r==c.origin||u==chrome.cast.Ob.ORIGIN_SCOPED&&r==c.origin?(c.b=!0,f.push(a)):g.push(a)});kp(this.b,d,new zk("leave_session",null,a.sequenceNumber));f.forEach(function(a){(a=gp(b.l,a))&&Cp(b.g,a.routeId,!0,!0)});c.b=g}else v(wp,
"No client record")}else v(wp,"No session")};
var Dp=function(a,b,c){Po(b)&&a.f.sendRequest(new lo,c,Ln,void 0,void 0,b.transportId).catch(wa)},$n=function(a,b,c){var d=b.getId();wp.info("Query status for "+d);Io(a.w,b).then(function(e){Ep(a,d,e);c&&(e=Fp(a.a,d))&&Dp(a,e,b)},wa)},Gp=function(a,b){if("*"==b.destinationId)return!0;b=b.destinationId;if(b==a.m.h||null!=gp(a.l,b))return!0;wp.info("Invalid destination "+b);return!1},Lp=function(a,b,c){w(wp,function(){return"Cast message: "+JSON.stringify(c)});if(Gp(a,c))if(c.namespace_==Kn||c.namespace_==
Mn)(b=Hp(a.a,b))&&b.a.forEach(function(b){var d=a.g,e=d.f.get(b);e&&e.Oc&&d.b.Ie(d,b,c)});else{var d=JSON.parse(c.data),e=Ip(a,d);e=e?e.sourceId:void 0;switch(d.type){case "RECEIVER_STATUS":Ep(a,b,d);break;case "MEDIA_STATUS":Jp(a,b,c,e)}}else Kp(a.m,b,c.destinationId,c.sourceId,!1)},Ip=function(a,b){a=ro(a.f.a,b.requestId);if(!a)return null;var c=a.ta;switch(b.type){case "LAUNCH_ERROR":case "INVALID_REQUEST":case "LOAD_CANCELLED":case "LOAD_FAILED":case "INVALID_PLAYER_STATE":delete b.requestId;
c.reject(new chrome.cast.Error(chrome.cast.Pb.SESSION_ERROR,b.reason||b.type,b));break;default:c.resolve(b)}return a},Mp=function(a,b,c){w(wp,function(){return"App message: "+JSON.stringify(c)});if(b=Fp(a.a,b)){var d;"*"==c.destinationId?d=np(a.a,b.sessionId):d=[c.destinationId];var e=new sk(b.sessionId,c.namespace_,c.data);d.forEach(function(b){kp(a.b,b,new zk("app_message",e))})}else v(wp,"No session for incoming app message")},Np=function(a,b){a.forEach(function(a){a.sessionId=b;var c=a.supportedMediaCommands,
e=[];c&1&&e.push(chrome.cast.media.mc.PAUSE);c&2&&e.push(chrome.cast.media.mc.SEEK);c&4&&e.push(chrome.cast.media.mc.STREAM_VOLUME);c&8&&e.push(chrome.cast.media.mc.STREAM_MUTE);a.supportedMediaCommands=e});return a},Bp=function(a,b,c){b=b.sessionId;c.sessionId=b;c=Np(c.status,b);Op(a.a,b,c);(a=zp(a.a,b))&&a.controller&&(a=a.controller,(c=Zo(a))?$o(a,c):(a.a.title="",a.a.can_play_pause=!1,a.a.can_seek=!1),To(a))},Pp=function(a,b){if(b=Fp(a.a,b)){b=b.sessionId;var c=zp(a.a,b);c&&c.g||Ap(a,b)}},Ap=
function(a,b,c){c&&op(a,c.clientId,c);(c=zp(a.a,b))&&c.a.slice().forEach(function(b){Cp(a.g,b,!0)});Qp(a.a,b);Rp(a.g)},Ep=function(a,b,c){w(wp,"Receiver status for "+b);var d=c.status;if(d)if(c=a.h.b(b)){d=Lo(c,d);var e=Hp(a.a,b);e?d?d.sessionId==e.session.sessionId?(b=e.session,No(b,d)&&(w(wp,"Updating session "+d.sessionId),b.statusText=d.statusText,b.namespaces=d.namespaces,b.receiver.volume=d.receiver.volume,Sp(a.g,e),pp(a,b.sessionId,new zk("update_session",b)),e.controller&&Xo(e.controller))):
(Pp(a,b),on(1),Tp(a.g,null,c,null,d)):(Pp(a,b),on(1)):d&&Tp(a.g,null,c,null,d)}else hb("MediaRouter.Cast.Error.Sink.Missing.From.Discovery.Service"),v(wp,"Got message from receiver "+b+", but sink is no longer available.")},Jp=function(a,b,c,d){if(b=Fp(a.a,b))if(c=JSON.parse(c.data))Bp(a,b,c),pp(a,c.sessionId,new zk("v2_message",c),d)},Up=function(a,b){var c=Mo(b.a);return(b=Sb(a.u,function(a){return Qb(a.capabilities,function(a){return Ub(c,a)})}))?b.appId:Zk(a)[0]},Vp=function(a,b,c){var d=el(b);
if(!d)return Promise.reject(Error("Invalid source "+b));var e=Up(d,c),f=new Ya("MediaRouter.Cast.Session.Launch");return ep(a.A,new chrome.cast.Jg(e,void 0,null==d.g?chrome.cast.timeout.requestSession:d.g),c).then(function(a){wp.info("Launched session "+a.sessionId+" for appId "+e);f.a("Success");return a},function(a){wp.error("Failed to session for appId "+e);f.a("Failure");throw a;})};
mp.prototype.createMediaRouteController=function(a,b,c){a=Wp(this.a,a);if(!a)return Error("Session not found for the route");var d=a.session;if(a.controller)return Error("Controller already exists for the route");var e=Xp(this,d.sessionId);if(!e)return Error("Sink not found for the route");a.controller=new Yo(b,c,d,this);Dp(this,d,e);return null};
var bp=function(a,b,c){var d=Xp(a,b.sessionId);d&&a.f.sendRequest(c,d,Ln,0,"",b.transportId).catch(function(a){v(wp,"Failed to send a media control request: "+a)})},cp=function(a,b,c){c=new uk(c);(b=Xp(a,b.sessionId))&&a.f.sendRequest(c,b,Jn).catch(function(a){v(wp,"Failed to send a volume control request: "+a)})},Xp=function(a,b){return(b=sp(a.a,b))?a.h.b(b):null},wp=Pa("mr.cast.ApiHandler");var Yp=function(){this.b=new Ni;this.f=new Ni;this.a=new Ni},cq=function(a,b,c){c=void 0===c?!1:c;var d=b.getId(),e=b.Ja()+":"+b.Ba(),f=a.b.get(d);if(f){if(a.a.get(d)==e)return w(Zp,"Using pending creation to "+d),f;Zp.info("Device "+d+" IP changed from "+a.a.get(b.getId())+" to "+e);$p(a,b)}b=aq(a,b,c?15E3:1E4).then(function(b){bq(a,d);pn(1);return b},function(b){e==a.a.get(d)&&bq(a,d);pn(0);return Promise.reject(b)});a.b.set(d,b);a.a.set(d,e);return b},$p=function(a,b){b=b.getId();w(Zp,"Aborting connection to device "+
b);var c=a.f.get(b);c&&c.abort();bq(a,b)},bq=function(a,b){a.b.remove(b);a.f.remove(b);a.a.remove(b)},aq=function(a,b,c){var d=new sd(function(){return dq(b,c)},1E3,3);a.f.set(b.getId(),d);return ud(d,1.5).start().then(null,function(a){Zp.info("Failed to create channel to "+b.getId());return Promise.reject(a)})},dq=function(a,b){var c=eq++;Zp.info("Connecting to (id "+c+") "+a.getId());var d=new Ya("MediaRouter.Cast.Mdns.Channel.Open");return fq(a,b).then(function(a){Zp.info(function(){return"Channel opened (id "+
c+"): "+JSON.stringify(a)});d.a("Success");return a},function(a){Zp.info("Channel did not open (id "+c+").");d.a("Failure");return Promise.reject(a)})},fq=function(a,b){var c={ipAddress:a.Ja(),port:a.Ba(),auth:"ssl_verified",timeout:1E4,livenessTimeout:b,pingInterval:5E3,capabilities:0};Zp.info(function(){return"Opening channel to "+JSON.stringify(c)});var d=new kb;chrome.cast.channel.open(c,function(a){a?"open"==a.readyState?d.resolve(a):(fm("chrome.cast.channel.open",Zp),chrome.cast.channel.close(a,
function(){fm("chrome.cast.channel.close",Zp)}),d.reject(Error(a.errorState))):(a=fm("chrome.cast.channel.open",Zp),d.reject(a))});return d.a},Zp=Pa("mr.cast.ChannelFactory"),eq=0;var gq=function(a,b,c,d){return{namespace_:a,data:ta(b)?b:JSON.stringify(b),sourceId:c,destinationId:d}};var hq=function(a){this.type="CLOSE";this.reasonCode=a};var iq=id("Firefox"),jq=qd()||id("iPod"),kq=id("iPad"),lq=id("Android")&&!(jd()||id("Firefox")||id("Opera")||id("Silk")),mq=jd(),nq=id("Safari")&&!(jd()||id("Coast")||id("Opera")||id("Edge")||id("Silk")||id("Android"))&&!rd();var oq=function(a){return(a=a.exec(fd))?a[1]:""},pq=function(){if(iq)return oq(/Firefox\/([0-9.]+)/);if(Bd||Cd||Ad)return Vd;if(mq)return rd()?oq(/CriOS\/([0-9.]+)/):oq(/Chrome\/([0-9.]+)/);if(nq&&!rd())return oq(/Version\/([0-9.]+)/);if(jq||kq){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(fd);if(a)return a[1]+"."+a[2]}else if(lq)return(a=oq(/Android\s+([0-9.]+)/))?a:oq(/Version\/([0-9.]+)/);return""}();var rq=function(a){this.type="CONNECT";this.origin={};this.userAgent=fd;var b=this.userAgent.indexOf("(")+1;b=this.userAgent.substr(b,this.userAgent.indexOf(")",b)-1-b+1);this.senderInfo={sdkType:2,version:chrome.runtime.getManifest().version,browserVersion:pq,platform:qq(),systemVersion:b,connectionType:1};this.connType=a?0:2},qq=function(){switch(nf()){case "ChromeOS":return 5;case "Windows":return 3;case "Mac":return 4;case "Linux":return 6}return 0};var sq=function(){this.a=new Ni};sq.prototype.init=function(){Jg(this)};var tq=function(a,b,c,d,e){if(!a.a.Va([b.channelId,c,d].join("#"))){var f=gq(In,new rq(e),c,d);chrome.cast.channel.send(b,f,a.b.bind(a));a.a.set([b.channelId,c,d].join("#"),e)}};sq.prototype.b=function(){fm("chrome.cast.channel.send",uq)};
var vq=function(a,b){a.a.Qa().forEach(function(c){c.split("#")[0]==b.channelId.toString()&&a.a.remove(c)})},wq=function(a,b,c){a.a.forEach(function(d,e){var f=e.split("#");f[0]==b.channelId.toString()&&(tq(a,c,f[1],f[2],d),a.a.remove(e))})};sq.prototype.ha=function(){return"cast.VirtualConnectionManager"};sq.prototype.xa=function(){var a=Ri(this.a);return[new xq(a)]};sq.prototype.Da=function(){var a=Gg(this);if(a)for(var b in a.a)this.a.set(b,a.a[b])};xa(sq);
var uq=Pa("mr.cast.VirtualConnectionManager"),xq=function(a){this.a=a};var yq=function(a,b){this.g=b;this.h=a;this.b=new Ni;this.a=new Ni;this.f=sq.ja();this.m=new Yp;this.l=null};qa(yq,Mf);yq.prototype.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];a==chrome.cast.channel.onMessage?this.v.apply(this,[].concat(k(c))):a==chrome.cast.channel.onError&&this.u.apply(this,[].concat(k(c)))};yq.prototype.init=function(){this.f.init();Jg(this);Wf("mr.cast.ChannelService",this);rk().forEach(function(a){return a.addListener()})};
var vo=function(a,b,c,d,e,f){var g=e||a.h,l=f||"receiver-0";return bo(a,b).then(function(b){return zq(a,b,c,d,g,l)})},Aq=function(a,b,c,d,e){bo(a,b).then(function(b){return tq(a.f,b,c,d,e)})},Kp=function(a,b,c,d,e){if(b=a.b.get(b))a=a.f,a.a.Va([b.channelId,c,d].join("#"))&&(a.a.remove([b.channelId,c,d].join("#")),c=gq(In,new hq(e?5:0),c,d),chrome.cast.channel.send(b,c,a.b.bind(a)))};
yq.prototype.v=function(a,b){var c=this.a.get(a.channelId);if(c){var d=this.l(c);if(d){if(On.hasOwnProperty(b.namespace_)){var e=JSON.parse(b.data);switch(e.type){case "CLOSE":this.f.a.remove([a.channelId,b.destinationId,b.sourceId].join("#"));return;case "RPC":break;default:w(Bq,function(){return"Got message "+(e.type||e.responseType)+" "+("from "+d.getId())})}}else w(Bq,"Got message in "+b.namespace_+" from "+d.getId());Cq(this.g,d,b)}else v(Bq,"Got message for unknown receiver (receiverId="+c+
").")}else v(Bq,"Got message for unknown channel (channelId="+a.channelId+").")};var Dq=function(a,b){chrome.cast.channel.close(b,function(){chrome.runtime.lastError||w(Bq,"Channel close success")});var c=a.a.get(b.channelId);c&&(a.a.remove(b.channelId),a.b.remove(c))};yq.prototype.u=function(a,b){v(Bq,function(){return"Channel error: "+JSON.stringify(a)+(b?", "+JSON.stringify(b):"")});b&&Eq(b);Fq(this,a)};
var Eq=function(a){switch(a.errorState){case "unknown":var b=0;break;case "authentication_error":b=1;break;case "connect_error":b=2;break;case "connect_timeout":b=6;break;case "ping_timeout":b=7;break;default:return}if(-8192<=a.nssErrorCode&&-7192>a.nssErrorCode||2==a.challengeReplyErrorType||8==a.challengeReplyErrorType||9==a.challengeReplyErrorType||11==a.challengeReplyErrorType||-200>=a.netReturnValue&&-300<a.netReturnValue||30==a.eventType||31==a.eventType||32==a.eventType)b=3;if(26==a.eventType||
-201==a.netReturnValue||-8181==a.nssErrorCode||-8162==a.nssErrorCode||-8161==a.nssErrorCode)b=4;-138==a.netReturnValue&&(b=5);if(-8182==a.nssErrorCode||10==a.eventType||12==a.eventType)b=1;v(Bq,"Channel error code: "+b);ib("MediaRouter.Cast.Channel.Error",b,mn)},Fq=function(a,b){var c=a.a.get(b.channelId);Dq(a,b);if(c){var d=a.l(c);d&&bo(a,d,!0).then(function(c){Bq.info("Re-connected to receiver: "+d.getId());wq(a.f,b,c);$n(a.g.l,d,!0)},function(){Bq.info("Failed to re-connect to receiver: "+d.getId());
vq(a.f,b);var c=a.g.a,f=d.getId();c.j.info("Channel error for sink "+f);xn(c,f);on(2)})}},bo=function(a,b,c){c=void 0===c?!1:c;var d=b.getId(),e=a.b.get(d);return e&&"open"==e.readyState?Promise.resolve(e):cq(a.m,b,c).then(function(b){if(a.a.Va(b.channelId))return b;a.b.get(d)&&(v(Bq,"Duplicate channel to a receiver "+d),Dq(a,a.b.get(d)));Bq.info("Connected to: "+d);a.b.set(d,b);a.a.set(b.channelId,d);return b},null)},zq=function(a,b,c,d,e,f){tq(a.f,b,e,f,0==f.indexOf("receiver-0"));Oo(d);var g=gq(c,
d,e,f);"object"===typeof d&&"RPC"==d.type||w(Bq,function(){return"Channel is sending message: "+JSON.stringify(g)});return new Promise(function(c,d){chrome.cast.channel.send(b,g,function(b){b?b.errorState?(d(Error("Failed to send message")),Fq(a,b)):c(!0):(b=fm("chrome.cast.channel.send",Bq),d(b))})})};yq.prototype.ha=function(){return"cast.ChannelService"};yq.prototype.xa=function(){return[new Gq(Ri(this.b),Ri(this.a))]};yq.prototype.Da=function(){var a=Gg(this);a&&(Mi(this.b,a.b),Mi(this.a,a.a))};
var Bq=Pa("mr.cast.ChannelService"),Gq=function(a,b){this.b=a;this.a=b};var Hq=function(){this.requestId=0;this.type="GET_APP_AVAILABILITY";this.appId=[]};var Iq=function(a,b){this.g=a;this.b=b;this.f=new hl;this.a=new Ni};Iq.prototype.init=function(){Jg(this)};var Jq=function(a,b){var c=a.a.get(b);c&&(c.Yf--,0<c.Yf||(xi(a.b.a.Ua(!1),function(a){switch(gn(a,b)){case "available":a.jb[b]="available_rescan";break;case "unavailable":a.jb[b]="unavailable_rescan"}}),a.a.remove(b)))};h=Iq.prototype;
h.Hh=function(a){var b=this;xi(this.a.Ua(!0),function(c){a:{switch(gn(a,c)){case "unknown":case "available_rescan":case "unavailable_rescan":var d=!0;break a}d=!1}if(d){var e=a.getId()+":"+c;b.f.contains(e)||(b.f.add(e),d=function(){b.f.remove(e)},ud(new sd(b.Fk.bind(b,a,c),5500,3),2).start().then(b.Di.bind(b,a,c),function(){b.j.error("Failed to get app availability response for "+a.getId()+", appId "+c+" after 3 attempts.");b.Di(a,c,"unknown")}).then(d,d))}})};
h.Di=function(a,b,c){c!=gn(a,b)&&(this.j.info(b+" on "+a.getId()+" is "+c),a.jb[b]=c,yn(this.b.f,a))};
h.Fk=function(a,b){var c=this,d=new Hq;d.appId=[b];var e=new Ya("MediaRouter.Cast.App.Availability");return this.g.sendRequest(d,a,Jn,5E3).then(function(a){e.a("Success");w(c.j,function(){return"App availability response "+JSON.stringify(a)});for(var b in a.availability){if("APP_AVAILABLE"==a.availability[b])return"available";if("APP_UNAVAILABLE"==a.availability[b])return"unavailable"}return"unknown"},function(d){e.a("Failure");c.j.error("checkAppAvailability_ failed for "+a.getId()+", appId "+b);
throw d;})};h.ha=function(){return"cast.AppDiscoveryService"};h.xa=function(){return[new Kq(Ri(this.a))]};h.Da=function(){var a=Gg(this);a&&Mi(this.a,a.a)};h.j=Pa("mr.cast.AppDiscoveryService");var Kq=function(a){this.a=a};var Lq=function(a,b,c,d){a=gk(c,"cast",b.getId(),a,d,"");a.supportsMediaRouteController=!0;a.controllerType=mojo&&mojo.RouteControllerType&&mojo.RouteControllerType.kGeneric;return a};var Mq=function(a,b,c,d,e,f){this.routeId=a;this.clientId=b;this.appIds=c;this.autoJoinPolicy=d;this.origin=e;this.tabId=f;this.b=this.a=!1},Nq=function(){this.a=[]};Nq.prototype.init=function(){Jg(this)};Nq.prototype.da=function(){return this.a.length};var gp=function(a,b){return Sb(a.a,function(a){return a.clientId==b})},Oq=function(a,b){return Sb(a.a,function(a){return a.routeId==b})},Pq=function(a,b){a.a=Mb(a.a,function(a){return a.clientId!=b})};Nq.prototype.ha=function(){return"cast.ClientRecords"};
Nq.prototype.xa=function(){return[new Qq(this.a)]};Nq.prototype.Da=function(){var a=Gg(this);a&&(this.a=a.a)};var Qq=function(a){this.a=a};var Rq=function(a){this.a=a},Sq=function(){var a=[];Nl().l.forEach(function(b){var c="Receiver-"+b.replace(/\./g,"_"),d=Nl().a||8009;a.push({serviceName:c+"._googlecast._tcp.local",serviceHostPort:0<b.indexOf(":")?"["+b+"]:"+d:b+":"+d,ipAddress:b,serviceData:["id=mdns:"+c,"ve=02","ca=5","st=1","fn="+c,"md=Chromecast"]})});return a};Rq.prototype.init=function(){var a=Sq(),b=this.a;b.K(a);b.F=a};var Tq=chrome.i18n.getMessage("4528089202128275824");chrome.i18n.getMessage("2810417817914017289");chrome.i18n.getMessage("3413021810593924462");chrome.i18n.getMessage("7603034707785674700");chrome.i18n.getMessage("8009014317872238527");chrome.i18n.getMessage("8636962961150071298");chrome.i18n.getMessage("1802762746589457177");var Uq=function(a,b){this.b=[];this.a=[];this.sinkId=a;this.session=b;this.l=this.f=null;this.offTheRecord=this.g=!1;this.controller=null},Vq=function(){this.j=Pa("mr.cast.SessionRecords");this.a=[]};Vq.prototype.init=function(){Jg(this)};
var Qp=function(a,b){a.j.info("Removing session "+b);ap(a,b);a.a=Mb(a.a,function(a){return a.session.sessionId!=b})},np=function(a,b){return(a=zp(a,b))?a.b:[]},Fp=function(a,b){return(a=Hp(a,b))?a.session:null},Wq=function(a,b){return Sb(a.a,function(a){return Ub(a.b,b)})},Wp=function(a,b){return Sb(a.a,function(a){return Ub(a.a,b)})},Xq=function(a,b){return Sb(a.a,function(a){return null!=Sb(a.a,function(a){return ek(a).a==b})})},Hp=function(a,b){return Sb(a.a,function(a){return a.sinkId==b||a.f==
b})},zp=function(a,b){return Sb(a.a,function(a){return a.session.sessionId==b})},sp=function(a,b){return(a=zp(a,b))?a.sinkId:null},rp=function(a,b){return(a=zp(a,b))?a.session:null},Op=function(a,b,c){var d=rp(a,b);d&&(a=Mb(c,function(a){return a.playerState!=chrome.cast.media.vd.IDLE}),a.forEach(function(a){if(!a.media){var b=Sb(d.media,function(b){return b.mediaSessionId==a.mediaSessionId});b&&(a.media=b.media)}}),d.media=a)};Vq.prototype.ha=function(){return"cast.SessionRecords"};
Vq.prototype.xa=function(){return[new Yq(this.a)]};Vq.prototype.Da=function(){var a=Gg(this);if(a)for(var b=0;b<a.a.length;b++){var c=a.a[b],d=new Uq(c.sinkId,c.session);d.b=c.b;d.a=c.a;d.g=c.g;d.l=c.l;d.f=c.f;this.a.push(d)}};
var ap=function(a,b){(a=zp(a,b))&&a.controller&&(a.controller.wa(),a.controller=null)},Yq=function(a){var b=[];a=ja(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=new Uq(c.sinkId,c.session);d.b=c.b;d.a=c.a;d.g=c.g;d.l=c.l;d.f=c.f;d.offTheRecord=c.offTheRecord;b.push(d)}this.a=b};var Zq=function(a){this.v="sender-"+Ab();this.f=new Ni;this.m=null;Jg(this);this.b=a;this.h=new Nq;this.g=new Vq;this.u=new yq(this.v,this);this.a=new Pn(this.u,this);this.X=new Rq(this.a);this.s=new so(this.u,this.v);this.w=new Iq(this.s,this.a);this.l=new mp(this.s,this.a,this.h,this.g,this.u,this);this.A=new Co(this.a,this.s);this.F=this.a.start.bind(this.a);this.B=!0};h=Zq.prototype;h.getName=function(){return"cast"};
h.Ga=function(a){a=a?a.enable_cast_discovery:!0;this.j.info("Cast discovery enabled: "+a+"...");this.s.init();this.g.init();this.l.init();this.u.init();this.a.init();this.X.init();this.w.init();(this.B=a)?this.b.Xf(this.F):this.a.stop()};h.rc=function(){return this.f.S()};h.Cd=function(a){var b=this;if(null!=$q(a))return new kl([]);var c=new hl;ar(a).forEach(function(a){eo(b.a,a).map(function(a){return a.b}).forEach(function(a){c.add(a)})});return new kl(c.S(),-1!=a.indexOf("0F5096E8")?Jf:null)};
h.startObservingMediaSinks=function(a){var b=this,c=$q(a);c?(this.j.info("Received broadcast request "+a),xi(this.a.a.Ua(!1),function(a){b.s.sendMessage(c,a,Nn).catch(function(a){b.j.error("Broadcast failed "+a.message)})})):(ar(a).forEach(function(a){var c=b.w,d=c.a.get(a);d?d.Yf++:c.a.set(a,{Yf:1});c.j.info("Scanning sinks for app availability");xi(c.b.a.Ua(!1),c.Hh,c)}),this.B&&this.b.Cf()&&this.a.start())};
h.stopObservingMediaSinks=function(a){var b=this;null!=$q(a)||ar(a).forEach(function(a){Jq(b.w,a)})};h.startObservingMediaRoutes=function(){};h.stopObservingMediaRoutes=function(){};h.Kd=function(a){return(a=this.a.b(a))?a.b:null};
var br=function(a,b,c){a.j.error("Error launching.",c);Cp(a,b.id,!1,!0,"error");c=new bf(Tq,"warning");c.routeId=b.id;a.b.tc(c)},fr=function(a,b,c,d,e,f,g,l){Nl().f=new Kl(c.lb,c.Ja());var r=Lq(b,c,d,!0);r.forDisplay=!1;r.offTheRecord=e;a.f.set(r.id,r);a.b.dd(a,r);Rp(a);(e=el(b))&&e.a&&cr(a,e,r.id,g,l);Hf(b)||If(b)?(r.sb={tabId:l,sessionId:"",Yd:c.Ja()||"",Zd:c.lb||"",vm:c.b.friendlyName||""},If(b)&&(r.isOffscreenPresentation=!0),a.b.Ef(a,r,d,function(e){return kf(dr(a,b,c,d,f,g,l,e))}).a.then(function(){er(a,
r)},function(b){br(a,r,b)})):dr(a,b,c,d,f,g,l,r).then(null,function(b){br(a,r,b)});return Promise.resolve(r)},dr=function(a,b,c,d,e,f,g,l){return Vp(a.l,gr(b,c,e),c).then(function(e){Tp(a,b,c,d,e,f,g,l);return l})};
Zq.prototype.createRoute=function(a,b,c,d,e,f,g){var l=this,r=this.a.b(b);if(!r)return jf(Error("No sink with ID "+b));var u=fl(a);if(u){setTimeout(function(){qp(l.l,u,r,chrome.cast.wd.CAST)},0);var z=function(){return fr(l,a,r,c,d,e,f,g)},I=gp(this.h,u);if(I)return kf(this.terminateRoute(I.routeId).then(z,z));if(f&&g&&(b=hr(this,a,f,g,d,e,b)))return b}return kf(fr(this,a,r,c,d,e,f,g))};
var Cp=function(a,b,c,d,e){d=void 0===d?!1:d;e=void 0===e?"closed":e;a.j.info("Remove route "+b);var f=Oq(a.h,b);if(f){c=c||f.b;var g=f.clientId;a.j.info("Remove client "+g);for(var l=a.g,r=0;r<l.a.length;r++)$b(l.a[r].b,g);Pq(a.h,g)}if(g=Wp(a.g,b))$b(g.a,b),ir(a,g.a);if(l=a.f.get(b))if(l.Oc&&g&&(Kp(a.u,l.sinkId,f?f.clientId:a.v,g.session.transportId,c),l.forDisplay&&f&&(a.m={Mc:f,oi:g})),a.f.remove(b),a.b.Md(a,l),Rp(a),d)a.b.onPresentationConnectionClosed(b,e,"Remove route");else a.b.onPresentationConnectionStateChanged(b,
"terminated")},Sp=function(a,b){b.a.forEach(function(c){if(c=a.f.get(c)){var d=b.session;c.sb&&c.forDisplay?er(a,c):(c.description=d.statusText||d.displayName,a.b.hc(a,c))}})},jr=function(a,b){Pb(b,function(b){b=a.f.get(b,null);if(!b||!b.mediaSource)return!1;var c=el(b.mediaSource);c=c?c.v:!1;return b.isLocal&&!c})&&x(b,function(b){if(b=a.f.get(b,null))b.isLocal=!0})},ir=function(a,b){var c=[],d=[],e=null;b.forEach(function(b){if(b=a.f.get(b)){b.forDisplay=!1;var f=el(b.mediaSource);f&&Sb(Zk(f),Ro)||
(b.Oc?(f=f?$k(f):null,e||f==chrome.cast.Ob.CUSTOM_CONTROLLER_SCOPED||(c.push(b),e=b.sinkId)):e&&e!=b.sinkId?c.push(b):d.push(b))}});x(0<c.length?c:d,function(a){a.forDisplay=!0})},cr=function(a,b,c,d,e){var f=b.a;if(f&&!gp(a.h,f)){a.j.info("Add client "+f);var g=Zk(b);a.h.a.push(new Mq(c,f,g,$k(b),d||null,m(e)?e:null))}},er=function(a,b){if(a=Wp(a.g,b.id))a=a.session,a.statusText=b.description||a.statusText},Tp=function(a,b,c,d,e,f,g,l){var r=Hp(a.g,c.getId());if(!r){var u=a.g;r=c.getId();u.j.info("Adding new session: "+
r+", "+e.sessionId);var z=zp(u,e.sessionId);z?(Ko(e)?(z.l=e,z.f=r):Ko(z.session)&&(z.l=z.session,z.f=z.sinkId,z.session=e,z.sinkId=r),r=z):(r=new Uq(r,e),u.a.push(r))}var I=null!=b;if(!I&&Ro(e.appId))return null;null==b?(z=new Vk([{appId:e.appId,capabilities:e.capabilities}]),b=bl(z)[0]):z=el(b);if(u=l){if(!a.f.get(u.id))return v(a.j,"Route "+u.id+" not added"),u}else u=Lq(b,c,d||e.sessionId,I),a.f.set(u.id,u);d=u.id;a.j.info("Add route "+d);b=null;z&&(b=z.a,cr(a,z,d,f,g));Ub(r.a,d)||r.a.push(d);
u.Oc&&Aq(a.u,c,b||a.v,e.transportId,!(z&&z.v));r.offTheRecord=u.offTheRecord;f=r.a;jr(a,f);ir(a,f);f=u;g=e.sessionId;d=e.appId;("0F5096E8"==d||"85CDB22F"==d)&&g&&f.sb&&(f.sb.sessionId=g);!Po(e)||null!==e&&Ub(Qo,e.appId)||(f.customControllerPath="cast_route_details.html?"+["sessionId="+g,"appId="+d].join("&"));f.description=e.statusText||e.displayName;l?a.b.hc(a,u):a.b.dd(a,u);Rp(a);if(l=b)Ub(r.b,b)?l=!1:(r.b.push(b),l=!0);l&&(a=a.l,kp(a.b,b,new zk("new_session",e)),Dp(a,e,c));return u};
Zq.prototype.terminateRoute=function(a){var b=this,c=this.f.get(a);if(!c)return Promise.reject(new Cl(3,"Route in Cast provider not found for routeId  "+a));var d=Wp(this.g,a);if(!d)return Cp(this,a,!0),Promise.resolve();var e=d.session.sessionId,f=this.a.b(c.sinkId);if(!f)return Ap(this.l,e),Promise.resolve();(a=Oq(this.h,a))&&qp(this.l,a.clientId,f,chrome.cast.wd.STOP);on(0);return new Promise(function(a){var c=function(){Pp(b.l,f.getId());a()};b.s.sendRequest(new vk(e),f,Jn).then(c,c)})};
var kr=function(a,b){var c=null;yi(a.f.Ua(!1),function(d){if(!d.Oc)return!1;var e=a.a.b(d.sinkId);if(!e||!dl(b,gr(d.mediaSource,e)))return!1;c=d;return!0});if(!c||!c.mediaSource)return null;var d=fl(c.mediaSource);if(!d)return null;var e=gp(a.h,d);return e?(d=Wq(a.g,d))?{Mc:e,oi:d}:null:null},hr=function(a,b,c,d,e,f,g){var l=null;yi(a.f.Ua(!1),function(a){var b=a.sb;return b&&null!=b.tabId&&b.tabId==d&&Ff(a.mediaSource)?(l=a,!0):!1});if(!l)return null;var r=function(){return a.createRoute(b,g||l.sinkId,
"",e,f,c,null==d?void 0:d)};return kf(a.terminateRoute(l.id).then(r,r))};h=Zq.prototype;h.connectRouteByRouteId=function(a,b,c,d,e){if(!el(a))return jf(Error("Unsupported presentation URL"));if(!b)return jf(Error("No routeId"));b=ek(b);b=zp(this.g,b.a);if(!b)return jf(Error("No matching route"));var f=this.a.b(b.sinkId);return f?(a=Tp(this,a,f,c,b.session,d,e))?hf(a):jf(Error("Failed to create route")):jf(Error("No sink"))};
h.joinRoute=function(a,b,c,d,e,f){var g=el(a);if(!g)return jf(Error("Unsupported presentation URL"));if(b==chrome.cast.ng){a:{var l=kr(this,g);if(!l){if(!this.m||this.m.Mc.origin!=e||this.m.Mc.tabId!=f){l=null;break a}l=this.m}switch($k(g)){case chrome.cast.Ob.PAGE_SCOPED:l=null;break a;case chrome.cast.Ob.ORIGIN_SCOPED:if(e!=l.Mc.origin){l=null;break a}break;case chrome.cast.Ob.TAB_AND_ORIGIN_SCOPED:if(e!=l.Mc.origin||f!=l.Mc.tabId){l=null;break a}}l=zp(this.g,l.oi.session.sessionId)}if(!l&&(g.f?
g.f:chrome.cast.je.CREATE_SESSION)!=chrome.cast.je.CAST_THIS_TAB&&(d=hr(this,a,e,f,c,d)))return d}else l=lr(this,b);if(!l)return jf(Error("No matching route"));if(l.offTheRecord!=c)return jf(Error("Off the record mismatch"));d=this.a.b(l.sinkId);if(!d)return jf(Error("No sink"));a=Tp(this,a,d,b,l.session,e,f);a.offTheRecord=c;return hf(a)};h.detachRoute=function(a){Cp(this,a,!1,!0)};
h.Tc=function(a){var b=this.a.b(a);if(!b)throw Error("Cannot mirror with no sink.");var c=new kg;b=b.a;b&1||(c.shouldCaptureVideo=!1);b&4||(c.shouldCaptureAudio=!1);c.shouldCaptureAudio&&!c.shouldCaptureVideo&&(c.minLatencyMillis=c.maxLatencyMillis,c.animatedLatencyMillis=c.maxLatencyMillis);c.senderSideLetterboxing=!0;lg(c);Object.freeze(c);this.j.info(function(){return"Settings for "+a+": "+jg(c)});if(!c.shouldCaptureAudio&&!c.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture");
return c};h.oc=function(){return"cast_streaming"};
h.sendRouteMessage=function(a,b,c){var d=this;if(!c)return new Promise(function(a,c){"string"!==typeof b&&c(Error("Cannot send non-string messages via ApiHandler."));c=d.l.b;w(ip,"Received: "+b);var e=JSON.parse(b),f=e.clientId;"client_connect"==e.type?(w(ip,"App "+f),(e=gp(c.a,f))?(e.a=!0,(c=ro(c.b,e.routeId))&&c.ta.resolve(!0)):v(ip,"Client not found "+f)):hp(c,f)?(c=c.f[e.type])&&c(e):v(ip,"No route for "+f);a()});var e=Wp(this.g,a);if(!e)return Promise.reject(Error("Not managing the route "+a));
var f=this.a.b(e.sinkId);if(!f)return Promise.reject(Error("Sink no longer accessible"));var g=(a=Oq(this.h,a))?a.clientId:this.v;return new Promise(function(a){vo(d.u,f,c.namespace,b,g,e.session.transportId).then(a,a)})};h.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};h.xd=function(a,b){var c=this.a.b(b);if(!c)return!1;a=gr(a,c);return(a=cl(a))&&0!=a.length?Pb(a,function(a){return an(gn(c,a))}):!1};
h.Kc=function(a,b,c){var d=ar(a);return d&&0!=d.length?b==chrome.cast.ng?!0:c&&c.mediaSource?(a=cl(c.mediaSource),Pb(a,function(a){return Ub(d,a)})):void 0==b||lr(this,b)?!0:!1:!1};
var gr=function(a,b,c){return Hf(a)||If(a)?(a={appId:0==(b.a&1)?"85CDB22F":"0F5096E8",capabilities:Mo(b.a)},bl(new Vk([a],void 0,void 0,void 0,c))[0]):a},ar=function(a){var b=[];if(Hf(a)||If(a)){var c=nf();Gf(a)&&"ChromeOS"!=c&&"Windows"!=c||b.push("85CDB22F");b.push("0F5096E8")}else(a=cl(a))&&(b=cc(b,a));return b},$q=function(a){var b=el(a);if(!b)return null;a=ar(a);var c=b.h||"";b=b.l;return c&&b?new mo(a,c,JSON.stringify(b)):null},lr=function(a,b){return 0==b.indexOf(chrome.cast.Gg)?zp(a.g,b.substr(chrome.cast.Gg.length)):
Xq(a.g,b)},Cq=function(a,b,c){var d=a.A;if(Do(d)&&On.hasOwnProperty(c.namespace_)){var e=b.Ja();if(e){var f=JSON.parse(c.data);if("RECEIVER_STATUS"===f.type){var g=f.status&&f.status.applications&&f.status.applications[0],l=f=null;g&&(g.appId&&(f=g.appId),g.sessionId&&(l=g.sessionId));g=d.b.get(e);d.b.set(e,new Ao(e,f,l));g&&g.appId===f||Eo(d)}}}a=a.l;b=b.getId();On.hasOwnProperty(c.namespace_)?Lp(a,b,c):Mp(a,b,c)};
Zq.prototype.I=function(a){if(0==this.a.a.da())this.b.onSinkAvailabilityUpdated(this,0);var b=this.l;a=a.getId();(a=Hp(b.a,a))&&a.session&&Ap(b,a.session.sessionId);Fo(this.A);this.b.Jb()};var yn=function(a,b){a.w.Hh(b);Fo(a.A);a.b.Jb()};h=Zq.prototype;h.ha=function(){return"cast.Provider"};h.xa=function(){return[new nr(this.v,Ri(this.f),this.m)]};h.Da=function(){var a=Gg(this);a&&(this.v=a.f,Mi(this.f,a.b),this.m=a.a)};h.searchSinks=function(){return Ma()};
h.createMediaRouteController=function(a,b,c){return(a=this.l.createMediaRouteController(a,b,c))?Promise.reject(a):Promise.resolve()};h.provideSinks=function(a){Un(this.a,a)};var Rp=function(a){var b=a.rc().some(function(a){return a.isLocal});a.b.jd(a.ha(),b)};Zq.prototype.j=Pa("mr.CastProvider");var nr=function(a,b,c){this.f=a;this.b=b;this.a=c};var or=function(a,b){this.input=a;this.domain=b};var pr=function(a){this.a=a;this.j=Pa("mr.ExternalMessageHandler")};
pr.prototype.onMessage=function(a,b,c){var d=this;this.j.info("Received a message from "+b.id+" type: "+a.type);var e=chrome.runtime.id;"start"==a.type?(a=a.message,this.a.searchSinks("pseudo:cloud","urn:x-org.chromium.media:source:desktop",new or(a.meetingName,a.domain)).then(function(a){var f="PresentationId"+b.id+qr++;d.a.createRoute("urn:x-org.chromium.media:source:desktop",a,f).then(function(a){c(new Zd(e,"route",a.id))}).catch(function(a){c(new Zd(e,"error",a))})},function(){c(new Zd(e,"error",
Error("Failed to find sink.")))})):"stop"==a.type?this.a.terminateRoute(a.message.routeId).then(function(){c(new Zd(e,"stopped"))}):"subscribe_log_data"==a.type?(Ra.push(function(a){chrome.runtime.sendMessage(b.id,new Zd(e,"log_message",a))}),c(new Zd(e,"subscribed"))):(c(new Zd(e,"error",Error("Unhandled message type"))),this.j.error("Unhandled message type "+a.type))};var qr=0;var rr=function(a){if(0>=a)throw Error("invalid buffer size");this.a=[];this.b=[];this.f=a},sr=function(a,b){if(a.da()>=a.f){if(a.rb())throw Error("Empty queue");0==a.a.length&&(a.a=a.b,a.a.reverse(),a.b=[]);a.a.pop()}a.b.push(b)};rr.prototype.da=function(){return this.a.length+this.b.length};rr.prototype.rb=function(){return 0==this.da()};rr.prototype.S=function(){var a=this.a.slice();a.reverse();a.push.apply(a,[].concat(k(this.b)));return a};rr.prototype.clear=function(){this.a=[];this.b=[]};var tr=function(){this.a=new rr(1E3);this.b=Date.now()},vr=function(){null==ur&&(ur=new tr);return ur};tr.prototype.init=function(){Qa=1;var a=Pa("browser"),b=window.onerror;window.onerror=function(c,e,f,g,l){b&&b(c,e,f,g,l);a.error("Error: "+c+" ("+e+" @ Line: "+f+")",l)};Ra.push(this.g.bind(this));var c=window.localStorage["debug.logs"];c&&(Qa=Wa(c.toUpperCase()));window.localStorage["debug.console"]&&Ra.push(this.f.bind(this))};
tr.prototype.g=function(a){sr(this.a,wr(this,a,!1));a=a.Sb;a instanceof Error&&a.stack&&sr(this.a,a.stack)};tr.prototype.f=function(a){var b=[wr(this,a,!0)];a.Sb&&b.push(a.Sb);switch(a.level){case 3:console.error.apply(console,[].concat(k(b)));break;case 2:console.warn.apply(console,[].concat(k(b)));break;case 1:console.log.apply(console,[].concat(k(b)));break;default:console.debug.apply(console,[].concat(k(b)))}};
var wr=function(a,b,c){var d=["["];if(c)d.push(("       "+((Date.now()-a.b)/1E3).toFixed(3)).slice(-7));else{a=new Date(b.time);var e=function(a){return 10>a?"0"+a:a};d.push(a.getFullYear().toString(),"-",e(a.getMonth()+1),"-",e(a.getDate())," ",e(a.getHours()),":",e(a.getMinutes()),":",e(a.getSeconds()),".",e(Math.floor(a.getMilliseconds()/10)))}d.push("][",Va[b.level],"][",b.G,"] ",b.message);if(!c&&null!=b.Sb)if(d.push("\n"),b.Sb instanceof Error)d.push(b.Sb.message);else try{d.push(JSON.stringify(b.Sb))}catch(f){d.push(b.Sb.toString())}d.push("\n");
return d.join("")},xr=function(){var a=vr();return 0==a.a.da()?"NA":a.a.S().join("")},yr=function(){var a=vr();Jg(a)};tr.prototype.ha=function(){return"LogManager"};tr.prototype.xa=function(){return[this.a.S()]};tr.prototype.Da=function(){var a=this.a.S();this.a.clear();for(var b=ja(Gg(this)||[]),c=b.next();!c.done;c=b.next())sr(this.a,c.value);a=ja(a);for(c=a.next();!c.done;c=a.next())sr(this.a,c.value)};var ur=null;var zr=function(a){this.a=a;this.j=Pa("mr.InternalMessageHandler")};
zr.prototype.onMessage=function(a,b,c){var d=this;if("retrieve_log_data"!=a.type)c(new Zd(chrome.runtime.id,"error",Error("Unhandled message type")));else{var e={logs:xr(),device:Pl()};b=[];var f=de(e.device.ip).then(function(a){a.a&&(e.device.version=a.a)});b.push(f);var g=this.a.v;g&&(a=Ar(this,g,a.source).then(function(a){a&&(e.castStreamingLogs=a)},function(){d.j.error("Log upload failed for service: "+g)}),b.push(a));b.push(Br(this,e,"mr.cast.SinkDiscoveryService","castDeviceCounts"));b.push(Br(this,
e,"mr.dial.SinkDiscoveryService","dialDeviceCounts"));$l(b).then(function(){c(e)})}};var Br=function(a,b,c,d){return Qf(c).then(function(a){a=a.mh();b[d]=a.fc+"."+a.Zb},function(){a.j.error("Failed to get device counts for "+d+".")})},Ar=function(a,b,c){return Cr(a.a,b).then(function(a){return a.Ff(c)})};var Dr=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];d=a;c=ja(c);for(var e=c.next();!e.done;e=c.next()){if(void 0==d||"object"!=typeof d)return;d=d[e.value]}return d};var Er=function(){jk.call(this,5,"cloud.GcmEventListener","mr.cloud.discovery.CloudSinkDiscoveryService",chrome.gcm.onMessage);this.j=Pa("mr.CloudGcmEventListener")};qa(Er,jk);Er.prototype.Xe=function(a){a=Dr(a,"data","notification");if(!a)return this.j.error("Notification json not found"),!1;try{var b=JSON.parse(a);return!!b&&Array.isArray(b.events)&&0<b.events.length}catch(c){return this.j.error("Invalid json: "+a),!1}};var Gr=function(){Fr||(Fr=new Er);return Fr},Fr=null;var Hr={ACCEPTED:0,Sn:1,TIMEOUT:2},Ir={SUCCESS:0,Yi:1},Jr={nk:0,Hj:1,Wr:2,Go:3,Fo:4,Dp:5,TIMEOUT:6,Eq:7},Kr={Do:0,tr:1},Lr={lq:0,op:1,USER:2,yo:3},Mr=function(a){ib("MediaRouter.Cloud.Knock.Result",a,Hr)},Nr=function(a){ib("MediaRouter.Cloud.Session.Start",a,Ir)},Or=function(a){ib("MediaRouter.Cloud.Session.Type",a,Kr)},Pr=function(a){ib("MediaRouter.Cloud.Device.UserRole",a,Lr)};var Ur=function(a,b){this.f=a;this.m=b;this.h=new kb;this.a=this.h.a;this.l=Qr(a.id);this.b=new kb;this.g=!1;Rr(this);Sr(this);Tr(this,new mg("GET_TURN_CREDENTIALS"))};Ur.prototype.start=function(){var a=this;return this.a.then(function(b){if(b.b)return Promise.reject(Error("Presentation already started"));b.start();return a.b.a})};Ur.prototype.stop=function(){var a=this;this.g=!1;return this.a.then(function(b){b.stop();a.a=Promise.reject(Error("Peer connection has already been stopped"))})};
var Rr=function(a){a.l.onMessage=function(b){if(b.type)switch(b.type){case "TURN_CREDENTIALS":a.h.resolve(new sg(a.f.id,b.data.credentials));break;case "ANSWER":a.a.then(function(a){Ag(a,b.data)});break;case "STOP":a.b.reject("Stop signal received");a.stop();break;default:throw Error("Unknown message type: "+b.type);}else a.a.then(function(a){var c={type:"PRESENTATION_CONNECTION_MESSAGE",data:b};"string"==typeof c?a.l.send(c):a.l.send(JSON.stringify(c))})}},Sr=function(a){a.a.then(function(b){wg(b,
function(b){Tr(a,new mg("OFFER",new pg(b,null,null,a.m,a.f.id)))});xg(b,function(b){b=og(b);"STOP"==b.type&&a.stop();Tr(a,b)});tg(b,function(){a.g=!0;Tr(a,new mg("SESSION_START_SUCCESS"));a.b.resolve(a.f)});vg(b,function(){Tr(a,new mg("SESSION_END"))});ug(b,function(b){a.g||a.b.reject(b);Tr(a,new mg("SESSION_FAILURE"))})})},Tr=function(a,b){a.l.sendMessage(b,Vr)},Vr={channelType:"cloud"};var Wr=function(a,b,c,d,e,f){c=void 0===c?null:c;a||null==c&&(c="default");this.Bh=a;this.ua=b;this.Db=c;this.ad=void 0===d?null:d;this.Gb=void 0===e?null:e;this.Ac=void 0===f?null:f};Wr.prototype.b=function(){var a="";this.Gb?a=this.Gb:this.ad&&(a=this.ad);return a};Wr.prototype.Fb=function(){return this.Bh};Wr.prototype.getId=function(){return this.ua};Wr.prototype.merge=function(a){!this.Ac&&a.Ac&&(this.Ac=a.Ac);!this.Gb&&a.Gb&&(this.Gb=a.Gb);this.Gb&&a.Gb&&this.Ac&&(this.Gb=a.Gb)};var Xr=function(a,b){this.a=a;this.b=b},Yr=new Xr("https://www.googleapis.com/clouddevices/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),Zr=new Xr("https://www.googleapis.com/calendar/v3",""),$r=new Xr("https://www.googleapis.com/hangouts/v1",""),as=new Xr("https://networktraversal.googleapis.com/v1alpha","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA");var bs=function(a,b){this.b=a;this.f=b;this.j=Pa("mr.cloud.calendar.CalendarService")},fs=function(a){return cs(a,a.f.a).then(function(b){a.j.info(ds(b.length)+" events discovered before filtering.");return es(a,b)},function(b){v(a.j,"Error getting Hangouts from calendar.",b);return[]})},ds=function(a){return 20<a?"20+":a.toString()},cs=function(a,b){var c=Date.now();return gs(a,b,new Date(c),new Date(c+9E5)).then(function(b){return b.filter(a.a)})};
bs.prototype.a=function(a){return!(!a.start||!a.end||a.start.date||a.end.date||!a.start.dateTime||!a.end.dateTime)};
var gs=function(a,b,c,d){b=hs(Zr.a,["calendars",b,"events"],{timeMin:c.toJSON(),timeMax:d.toJSON(),singleEvents:!0});w(a.j,"Retrieving Hangouts from Calendar: "+b);return is(a.b,b,"GET").then(function(a){return a.items?a.items:[]})},es=function(a,b){var c=[];b.filter(function(a){return a.hangoutLink}).forEach(function(b){var d=new Ak(b.hangoutLink);if("meet.google.com"==d.Db)c.push(new Wr(!0,d.a.substring(1),void 0,void 0,b.summary));else if(d=d.a.substring(12).split("/"),2==d.length){var f=ja(d);
d=f.next().value;f=f.next().value;if(-1!=d.indexOf(".")){var g=f;var l=d}c.push(new Wr(!1,f+"@"+d,l,g,b.summary,void 0))}else v(a.j,"Invalid hangout link from calendar event: "+b.hangoutLink)});a.j.info(ds(c.length)+" events discovered with Hangout links.");return c};var js=function(a){this.email=a;this.imageUrl=null},ks=function(a){this.type=a},ls=function(a,b,c,d){this.type="__cloud_webrtc_session_message__";this.sessionDescription=a;this.user=b||null;this.flungUrl=c||null;this.presentationId=d||null};qa(ls,ks);
var ms=function(a,b,c){this.name=a;this.parameters=b;this.minimalRole=null!=c?c:"user"},ns={_settings:{type:"string"},_presentationRequest:{type:"string"},_optMediaConstraints:{type:"string"},_webrtcMessage:{type:"string"},_user:{type:"string"}},os=new ms("_knockingStartWebrtcSession",ns,"viewer"),ps=new ms("_startWebrtcSession",ns),qs=new ms("_stopSession",{},"viewer");var rs=function(a){this.a=a;this.id=a.id;this.j=Pa("mr.cloud.devices.CloudDevice")};rs.prototype.isAvailable=function(){if(this.getState().appStatus){var a="online"==this.a.connectionStatus,b="available"==this.getState().appStatus,c=ss(this,864E5);w(this.j,"Device id: "+this.id+", availability: GCM connected "+a+", app Available: "+b+", checked in: "+c);return a&&b&&c}a=ss(this,9E5);this.j.info("Availability for legacy receiver app: "+a);return a};
var ss=function(a,b){a=a.a.lastUpdateTimeMs?Number(a.a.lastUpdateTimeMs):null;return!!(a&&a>Date.now()-b)};rs.prototype.b=function(){return this.getState().settings.receiverName};rs.prototype.getId=function(){return this.id};rs.prototype.getState=function(){return this.a.state._cloudCast};var ts=function(a){this.h=a;this.b=this.f=this.a=null;this.l=this.g=!1;this.j=Pa("mr.cloud.devices.CloudDevicesService");Jg(this)};ts.prototype.getDevice=function(a){a=hs(Yr.a,["devices",a]);return is(this.h,a,"GET").then(function(a){return new rs(a)})};
var us=function(a,b){var c=hs(Yr.a,["devices"],b);return is(a.h,c,"GET").then(function(c){var d=(c.devices||[]).filter(function(a){return null!=a.commandDefs&&null!=a.commandDefs._cloudCast}).map(function(a){return new rs(a)});if(c=c.nextPageToken){var f=zc(b);f.token=c;return us(a,f).then(function(a){return d.concat(a)})}return d})};ts.prototype.ha=function(){return"CloudDevicesService"};ts.prototype.xa=function(){return[new vs(this.a,this.b,this.f)]};
ts.prototype.Da=function(){var a=Gg(this);a&&(this.a=a.Yk,this.b=a.gcmRegistrationId,this.f=a.Xk)};
var ws=function(a){return new Promise(function(b,c){a.g?c(Error("Registering...")):(a.g=!0,a.b&&a.f&&a.f+864E5>=Date.now()?(a.g=!1,b(a.b)):chrome.gcm.register(["919648714761"],function(d){a.g=!1;d?(w(a.j,"Got GCM ID: "+d),a.b=d,a.f=Date.now(),a.a=null,b(d)):(v(a.j,"Error: "+chrome.runtime.lastError.message),a.b=null,a.f=null,a.a=null,c(Error(chrome.runtime.lastError.message)))}))})},xs=function(a,b){if(a.l)Promise.resolve();else if(a.l=!0,b&&(!a.a||a.a+864E5<Date.now())){b={filters:["myDevices"],
gcmRegistrationId:b,gcmSenderId:"919648714761",expirationTimeMs:864E5};var c=hs(Yr.a,["subscriptions","subscribe"],{});is(a.h,c,"POST",b).then(function(){w(a.j,"Subscribed on: "+Date.now());a.a=Date.now();a.l=!1;return Promise.resolve()},function(b){a.l=!1;throw b;})}else Promise.resolve()},vs=function(a,b,c){this.Yk=a;this.gcmRegistrationId=b;this.Xk=c};var ys=function(a,b,c,d,e,f,g){var l=Ol(Nl(),a);this.Ea=new am(l,b,f,g,e);this.deviceId=a;this.a=c;this.model=d},zs=function(a,b,c,d,e){ys.call(this,a,b,["cloud"],"Chrome Streaming Receiver",d,"education");this.ef=c;this.isAvailable=e};qa(zs,ys);var As=function(a){var b=a.Db,c;a.ad&&a.b()!=a.ad&&(c=a.ad);ys.call(this,a.getId(),a.b(),["mesi"],"Hangout",b,a.Fb()?"meeting":"hangout",c);this.Fb=a.Fb();this.zc=a.Ac||""};qa(As,ys);var Bs=function(a){this.a=a;this.j=Pa("mr.cloud.messaging.GcmMessageHandler")};Bs.prototype.onMessage=function(a){var b=this;a=JSON.parse(a.data.notification);var c=Nl();a.events.forEach(function(a){if(a.deviceId){var d=Ol(c,a.deviceId);switch(a.type){case "deviceCreated":Cs(b,a);break;case "deviceUpdated":Ds(b,a,d);break;case "deviceDeleted":Es(b.a,{sinkId:d});break;default:w(b.j,function(){return"[unhandled event] "+JSON.stringify(a)})}}else b.j.error("Device ID not provided")})};
var Cs=function(a,b){var c=Dr(b,"statePatch","_cloudCast","settings","receiverName");"string"!=typeof c?a.j.error("Receiver name not a string: "+c):(b=new zs(b.deviceId,c,"owner","default",!0),a=a.a,a.a.a.set(b.Ea.id,b),a.a.b=Date.now(),Fs(a.f,[b.Ea]))},Ds=function(a,b,c){b=Dr(b,"statePatch","_cloudCast","appStatus");if("string"!=typeof b)a.j.error("App status not a string: "+b);else if(a=a.a,b="available"==b,c=a.a.uc(c))c.isAvailable=b,a.a.b=Date.now(),Gs(a.f,[c.Ea])};var Hs=function(a,b,c){this.h=a;this.g=b;this.a=new Map;this.f=new Map;this.b=null;this.l=c};Hs.prototype.cd=function(){var a=this.b+this.l;if(null==this.b||a<Date.now())this.b=Date.now(),Is(this);return Array.from(this.a.values())};Hs.prototype.uc=function(a){return this.a.get(a)||null};
var Is=function(a){a.h().then(function(b){Js(a,b)})},Js=function(a,b){var c=new Map(a.a),d=new Map,e=new Map,f=[],g=[];b.forEach(function(a){var b=a.Ea.id;d.set(b,a);e.set(b,a.deviceId);c.has(b)?c.has(b)&&JSON.stringify(c.get(b))!=JSON.stringify(a)&&g.push(a.Ea):f.push(a.Ea);c.delete(b)});b=[].concat(k(c.values())).map(function(a){return a.Ea});a.f.clear();a.f=e;a.a.clear();a.a=d;Ks(a,f,g,b)},Ks=function(a,b,c,d){0<b.length&&Fs(a.g,b);0<c.length&&Gs(a.g,c);0<d.length&&Ls(a.g,d)},Ns=function(a){for(var b=
{},c=ja(a.a.entries()),d=c.next();!d.done;d=c.next()){var e=ja(d.value);d=e.next().value;e=e.next().value;b[d]=e}c={};d=ja(a.f.entries());for(e=d.next();!e.done;e=d.next()){var f=ja(e.value);e=f.next().value;f=f.next().value;c[e]=f}return new Ms(b,c,a.b)},Os=function(a,b){for(var c in b.sinks){var d=b.sinks[c],e=null;"Hangout"==d.model?e=new As(new Wr(d.Fb,d.deviceId,d.Ea.domain,d.Ea.description,d.Ea.friendlyName,d.zc)):"Chrome Streaming Receiver"==d.model&&(e=new zs(d.deviceId,d.Ea.friendlyName,
d.ef,d.Ea.domain,d.isAvailable));a.a.set(c,e)}for(c in b.a)a.f.set(c,b.a[c]);b.b&&(a.b=b.b)},Ms=function(a,b,c){this.sinks=a;this.a=b;this.b=c};var Ps=function(a,b){this.b=a;this.f=b;this.a=new Hs(this.bl.bind(this),b,2E4);this.g=new Bs(this);Gr().addListener();Jg(this);Wf("mr.cloud.discovery.CloudSinkDiscoveryService",this)};qa(Ps,Mf);h=Ps.prototype;h.cd=function(){var a=this;ws(this.b).then(function(b){xs(a.b,b)},function(){});return this.a.cd().filter(function(a){return a.isAvailable})};h.uc=function(a){return this.a.uc(a)};
h.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];if(a==chrome.gcm.onMessage)this.g.onMessage.apply(this.g,[].concat(k(c)));else throw Error("Unhandled event: expected chrome.gcm.onMessage");};
h.bl=function(){return us(this.b,{descriptionSubstring:"Chrome Streaming Receiver"}).then(function(a){return a.map(function(a){hb("MediaRouter.Cloud.CloudReceiver.Sink.Discovered");var b=a.isAvailable()&&!(a.a.invitations&&0!=a.a.invitations.length);return new zs(a.getId(),a.b(),a.a.personalizedInfo.maxRole,"default",b)})})};h.ha=function(){return"CloudSinkDiscoveryService"};h.xa=function(){return[{cache:Ns(this.a)}]};h.Da=function(){var a=Gg(this);a&&Os(this.a,a.cache)};
var Es=function(a,b){if(b=a.a.uc(b.sinkId))a.a.a.delete(b.Ea.id),a.a.b=Date.now(),Ls(a.f,[b.Ea])};var Ss=function(a,b,c){if(!Qs){Hh();var d=Gh;d.b=Ch;var e=Rs;d.a||(d.a=[]);d.a.push(e);Qs=!0}this.f=a;this.g=b;this.a=new Hs(this.l.bind(this),c,2E4);this.b=new Map;Jg(this)},Rs=function(a){Sa({G:a.f,level:Xa(a.b.value),time:a.l,message:a.getMessage(),Sb:a.a})};Ss.prototype.cd=function(){return this.a.cd()};Ss.prototype.uc=function(a){return this.a.uc(a)};
Ss.prototype.l=function(){var a=this;this.j.info("Fetching hangouts");return $l([Ts(this.g),fs(this.f)]).then(function(b){var c=Array.from(a.b.values());b.forEach(function(b){b.dc?c=c.concat(b.value):a.j.error("Error discovering Hangouts",b.reason)});var d=c.reduce(function(a,b){var c=a[b.getId()];c?c.merge(b):c=b;a[c.getId()]=c;return a},{});return Object.keys(d).map(function(a){a=d[a];hb("MediaRouter.Cloud.Hangout.Sink.Discovered");return new As(a)})})};
var Vs=function(a,b){return Qf("mr.mirror.hangouts.MeetingsService").then(function(a){return a.qb(b)}).then(function(b){return Us(a,b)},function(){return b.input.match(/^#/)?Promise.reject(Error("Failed to resolve meeting alias.")):Us(a,b.input,b.domain)})},Us=function(a,b,c){c=c||void 0;var d=!c;b=new Wr(d,d?b:b+"@"+c,c,b,void 0,void 0);a.b.set(b.getId(),b);b=new As(b);a.a.a.set(b.Ea.id,b);return b.Ea};Ss.prototype.ha=function(){return"HangoutSinkDiscoveryService"};
Ss.prototype.xa=function(){for(var a={},b=ja(this.b.entries()),c=b.next();!c.done;c=b.next()){var d=ja(c.value);c=d.next().value;d=d.next().value;a[c]=d}return[{cache:Ns(this.a),manualHangouts:a}]};Ss.prototype.Da=function(){var a=Gg(this);if(a){Os(this.a,a.cache);for(var b in a.manualHangouts){var c=a.manualHangouts[b];this.b.set(b,new Wr(c.Bh,c.ua,c.Db,c.ad,c.Gb,c.Ac))}}};Ss.prototype.j=Pa("mr.cloud.discovery.HangoutSinkDiscoveryService");var Qs=!1;var Ws=function(a,b,c,d,e,f,g,l){this.a=null;this.s=!1;this.v=xc();this.b=[];this.m=a?encodeURIComponent(String(a)):null;this.w=null;!d&&b&&(this.w=b);this.I=c||null;this.f=!d;this.g=null!=e?e:null;this.h=f||null;this.F=!!g;this.A=l||null};t(Ws,Jh);var Xs;var Ys=Lc("https://apis.google.com/js/client.js");Ys instanceof Kc&&Ys.constructor===Kc&&Ys.b===Jc?Xs=Ys.a:(Hb("expected object of type Const, got '"+Ys+"'"),Xs="type_error:Const");var Zs=Zc(Xs);
Ws.prototype.init=function(){var a=p(function(a){this.a=a;var b=va("auth",a);va("client.request",a)&&b?this.B():a.load("client",p(this.B,this))},this),b=$s("gapi");b?a(b.gapi):at(this,a);return this.v.a};
var $s=function(a){for(var b=window,c=va(a,b);!c&&b!=window.top&&bt(b.parent,a);)b=b.parent,c=va(a,b);return c?b:null},bt=function(a,b){try{return!!a&&null!=a.location.href&&wd(a,b)}catch(c){return!1}},at=function(a,b){var c=$s("gapi_onload");if(c){var d=c.gapi_onload;c.gapi_onload=function(){d();b(c.gapi)}}else{window.gapi_onload=function(){b(window.gapi)};var e=document.createElement("SCRIPT");e.src=Yc(Zs);a.A&&ke(e,Bi(a.A));document.getElementsByTagName("head")[0].appendChild(e)}};
Ws.prototype.B=function(){for(var a=0;a<this.b.length;a++)this.b[a].ta.resolve(ct(this,this.b[a].requestData));this.s=!0;this.v.resolve(this.a)};Ws.prototype.sendRequest=function(a){if(this.s)return ct(this,a);var b=xc();this.b.push({requestData:a,ta:b});return b.a};
var ct=function(a,b){var c,d=va("config.get",a.a);if(!a.f){var e=d("googleapis.config/auth/useFirstPartyAuth");var f=d("googleapis.config/auth/useOriginToken")}null!=a.g&&(c=d("client/cors"));try{var g=va("config.update",a.a);a.f||(g("googleapis.config/auth/useFirstPartyAuth",!1),g("googleapis.config/auth/useOriginToken",!1));null!=a.g&&g("client/cors",a.g);var l=va("client.request",a.a),r=dt(a);b.headers&&Ec(r,b.headers);var u={headers:r,root:a.I,path:b.path,method:b.method,body:b.body},z=b.params||
{};a.m&&!a.h?Ec(z,{key:a.m}):a.h&&Ec(z,{key:null});wc(z)||(u.params=z);var I=gj(l(u));b.callback&&I.then(function(a){b.callback.apply(null,[a.result,a])},function(a){b.callback.apply(null,[a.result,a])});return I}finally{g=va("config.update",a.a),a.f||(g("googleapis.config/auth/useFirstPartyAuth",e),g("googleapis.config/auth/useOriginToken",f)),null!=a.g&&g("client/cors",c)}},dt=function(a){if(a.f){if(a.h)return{Authorization:"Bearer "+a.h};var b=va("auth.getAuthHeaderValueForFirstParty",a.a);return{Authorization:a.F?
b([]):b(),"X-Goog-AuthUser":a.w}}return{}};var et=function(a){this.a=a},hs=function(a,b,c){var d="";b.forEach(function(a){d+="/"+encodeURIComponent(a)});a=new Ak(a+d);c&&(c=Tk(c),Fk(a,c));return a},is=function(a,b,c,d){return a.a.getAuthToken().then(function(e){var f=ft(e);return gt(f,b,c,d).catch(function(f){if("INVALID_ACCESS_ERROR"==f)return ht(a,e,b,c,d);throw f;})})},ht=function(a,b,c,d,e){return it(b).then(function(){return is(a,c,d,e)})},gt=function(a,b,c,d){return new Promise(function(e,f){var g=jt(b,c,function(a){a&&!a.error?e(a):
a&&401==a.error.code?f("INVALID_ACCESS_ERROR"):f(a&&a.error?a.error.errors?a.error.errors[0]:a:Error(a))},d);a.sendRequest(g)})},ft=function(a){a=new Ws(void 0,void 0,void 0,!1,!1,a);a.init();return a},jt=function(a,b,c,d){a={callback:c,method:b,path:a.toString()};d&&(a.body=d);return a};var mt=function(){this.b=!1;this.a=null;this.f=!1;this.j=Pa("mr.cloud.identity.IdentityService");Jg(this);kt(this);lt(this)},nt=function(a){return a.a?a.a.substr(a.a.indexOf("@")+1):""};mt.prototype.getAuthToken=function(){return chrome.identity?new Promise(function(a,b){chrome.identity.getAuthToken({interactive:!1},function(c){chrome.runtime.lastError?b(Error("Unable to get user auth token: "+chrome.runtime.lastError.message)):null==c?b(Error("User is not logged in (no token found)")):a(c)})}):Promise.reject(Error("chrome.identity permission required for auth."))};
var it=function(a){return new Promise(function(b){chrome.identity.removeCachedAuthToken({token:a},function(){b()})})},lt=function(a){a.getAuthToken().then(function(b){chrome.identity.getProfileUserInfo(function(c){a.b=!!c.email||!!c.id;a.a=c.email||null;b&&!a.b&&(a.f=!0)})},function(b){w(a.j,"Unable to set sign in and email.",b)})},kt=function(a){chrome.identity.onSignInChanged.addListener(function(b,c){Ef(6);a.b=c;a.j.info("Signed in change: "+a.b);a.b?lt(a):(a.a=null,a.f=!1)})},ot=function(a){return a.getAuthToken().then(function(b){var c=
window.gapi;if(!c)return a.j.error("gapi not loaded."),!1;a.j.info("Setting gapi auth token");c.auth.setToken({access_token:b});return!0})};mt.prototype.ha=function(){return"IdentityService"};mt.prototype.xa=function(){return[null,{signedIn:this.b,userEmail:this.a,kioskAuth:this.f}]};mt.prototype.Da=function(){var a=Hg(this);a&&(a.signedIn&&(this.b=a.signedIn),a.userEmail&&(this.a=a.userEmail),a.kioskAuth&&(this.f=a.kioskAuth))};var pt="cloudview.test@gmail.com castouts.qa.nohangouts@gmail.com castouts.qa@gmail.com castouts-qa.com castouts-test.com google.com youtube.com nest.com waze.com netflix.com twitter.com yahoo.com salesforce.com whirlpool.com nytimes.com kohls.com squareup.com ivci.com".split(" ");var qt={og:{1E3:{other:"0K"},1E4:{other:"00K"},1E5:{other:"000K"},1E6:{other:"0M"},1E7:{other:"00M"},1E8:{other:"000M"},1E9:{other:"0B"},1E10:{other:"00B"},1E11:{other:"000B"},1E12:{other:"0T"},1E13:{other:"00T"},1E14:{other:"000T"}},Mi:{1E3:{other:"0 thousand"},1E4:{other:"00 thousand"},1E5:{other:"000 thousand"},1E6:{other:"0 million"},1E7:{other:"00 million"},1E8:{other:"000 million"},1E9:{other:"0 billion"},1E10:{other:"00 billion"},1E11:{other:"000 billion"},1E12:{other:"0 trillion"},1E13:{other:"00 trillion"},
1E14:{other:"000 trillion"}}},rt=qt;rt=qt;var st={AED:[2,"dh","\u062f.\u0625.","DH"],ALL:[0,"Lek","Lek"],AUD:[2,"$","AU$"],BDT:[2,"\u09f3","Tk"],BGN:[2,"lev","lev"],BRL:[2,"R$","R$"],CAD:[2,"$","C$"],CDF:[2,"FrCD","CDF"],CHF:[2,"CHF","CHF"],CLP:[0,"$","CL$"],CNY:[2,"\u00a5","RMB\u00a5"],COP:[32,"$","COL$"],CRC:[0,"\u20a1","CR\u20a1"],CZK:[50,"K\u010d","K\u010d"],DKK:[50,"kr.","kr."],DOP:[2,"RD$","RD$"],EGP:[2,"\u00a3","LE"],ETB:[2,"Birr","Birr"],EUR:[2,"\u20ac","\u20ac"],GBP:[2,"\u00a3","GB\u00a3"],HKD:[2,"$","HK$"],HRK:[2,"kn","kn"],HUF:[34,
"Ft","Ft"],IDR:[0,"Rp","Rp"],ILS:[34,"\u20aa","IL\u20aa"],INR:[2,"\u20b9","Rs"],IRR:[0,"Rial","IRR"],ISK:[0,"kr","kr"],JMD:[2,"$","JA$"],JPY:[0,"\u00a5","JP\u00a5"],KRW:[0,"\u20a9","KR\u20a9"],LKR:[2,"Rs","SLRs"],LTL:[2,"Lt","Lt"],MNT:[0,"\u20ae","MN\u20ae"],MVR:[2,"Rf","MVR"],MXN:[2,"$","Mex$"],MYR:[2,"RM","RM"],NOK:[50,"kr","NOkr"],PAB:[2,"B/.","B/."],PEN:[2,"S/.","S/."],PHP:[2,"\u20b1","PHP"],PKR:[0,"Rs","PKRs."],PLN:[50,"z\u0142","z\u0142"],RON:[2,"RON","RON"],RSD:[0,"din","RSD"],RUB:[50,"\u20bd",
"RUB"],SAR:[2,"Rial","Rial"],SEK:[50,"kr","kr"],SGD:[2,"$","S$"],THB:[2,"\u0e3f","THB"],TRY:[2,"TL","YTL"],TWD:[2,"NT$","NT$"],TZS:[0,"TSh","TSh"],UAH:[2,"\u0433\u0440\u043d.","UAH"],USD:[2,"$","US$"],UYU:[2,"$","$U"],VND:[48,"\u20ab","VN\u20ab"],YER:[0,"Rial","Rial"],ZAR:[2,"R","ZAR"]};var tt={rg:".",Ye:",",Eg:"%",df:"0",sj:"+",Ag:"-",ug:"E",Fg:"\u2030",Ze:"\u221e",lj:"NaN",qg:"#,##0.###",Mj:"#E0",rj:"#,##0%",Ni:"\u00a4#,##0.00",ud:"USD"},ut=tt;ut=tt;var xt=function(a,b,c){this.w=b;this.M=c||0;this.B=40;this.b=1;this.X=0;this.g=3;this.I=this.f=0;this.K=!1;this.A=this.u="";this.l=ut.Ag;this.v="";this.a=1;this.m=!1;this.h=[];this.F=this.H=!1;this.s=0;if("number"==typeof a)switch(a){case 1:vt(this,ut.qg);break;case 2:vt(this,ut.Mj);break;case 3:vt(this,ut.rj);break;case 4:a=ut.Ni;b=["0"];c=st[this.w||ut.ud][0]&7;if(0<c){b.push(".");for(var d=0;d<c;d++)b.push("0")}a=a.replace(/0.00/g,b.join(""));vt(this,a);break;case 5:wt(this,1);break;case 6:wt(this,
2);break;default:throw Error("Unsupported pattern type.");}else vt(this,a)},vt=function(a,b){b.replace(/ /g,"\u00a0");var c=[0];a.u=yt(a,b,c);for(var d=c[0],e=-1,f=0,g=0,l=0,r=-1,u=b.length,z=!0;c[0]<u&&z;c[0]++)switch(b.charAt(c[0])){case "#":0<g?l++:f++;0<=r&&0>e&&r++;break;case "0":if(0<l)throw Error('Unexpected "0" in pattern "'+b+'"');g++;0<=r&&0>e&&r++;break;case ",":0<r&&a.h.push(r);r=0;break;case ".":if(0<=e)throw Error('Multiple decimal separators in pattern "'+b+'"');e=f+g+l;break;case "E":if(a.F)throw Error('Multiple exponential symbols in pattern "'+
b+'"');a.F=!0;a.I=0;c[0]+1<u&&"+"==b.charAt(c[0]+1)&&(c[0]++,a.K=!0);for(;c[0]+1<u&&"0"==b.charAt(c[0]+1);)c[0]++,a.I++;if(1>f+g||1>a.I)throw Error('Malformed exponential pattern "'+b+'"');z=!1;break;default:c[0]--,z=!1}0==g&&0<f&&0<=e&&(g=e,0==g&&g++,l=f-g,f=g-1,g=1);if(0>e&&0<l||0<=e&&(e<f||e>f+g)||0==r)throw Error('Malformed pattern "'+b+'"');l=f+g+l;a.g=0<=e?l-e:0;0<=e&&(a.f=f+g-e,0>a.f&&(a.f=0));a.b=(0<=e?e:l)-f;a.F&&(a.B=f+a.b,0==a.g&&0==a.b&&(a.b=1));a.h.push(Math.max(0,r));a.H=0==e||e==l;
d=c[0]-d;a.A=yt(a,b,c);c[0]<b.length&&";"==b.charAt(c[0])?(c[0]++,1!=a.a&&(a.m=!0),a.l=yt(a,b,c),c[0]+=d,a.v=yt(a,b,c)):(a.l+=a.u,a.v+=a.A)},wt=function(a,b){a.s=b;vt(a,ut.qg);a.f=0;a.g=2;if(0<a.f)throw Error("Can't combine significant digits and minimum fraction digits");a.X=2};
xt.prototype.parse=function(a,b){b=b||[0];if(0!=this.s)throw Error("Parsing of compact numbers is unimplemented");a=a.replace(/ /g,"\u00a0");var c=a.indexOf(this.u,b[0])==b[0],d=a.indexOf(this.l,b[0])==b[0];c&&d&&(this.u.length>this.l.length?d=!1:this.u.length<this.l.length&&(c=!1));c?b[0]+=this.u.length:d&&(b[0]+=this.l.length);if(a.indexOf(ut.Ze,b[0])==b[0]){b[0]+=ut.Ze.length;var e=Infinity}else{e=a;var f=!1,g=!1,l=!1,r=-1,u=1,z=ut.rg,I=ut.Ye,G=ut.ug;if(0!=this.s)throw Error("Parsing of compact style numbers is not implemented");
for(var ha="";b[0]<e.length;b[0]++){var La=e.charAt(b[0]),W=zt(La);if(0<=W&&9>=W)ha+=W,l=!0;else if(La==z.charAt(0)){if(f||g)break;ha+=".";f=!0}else if(La==I.charAt(0)&&("\u00a0"!=I.charAt(0)||b[0]+1<e.length&&0<=zt(e.charAt(b[0]+1)))){if(f||g)break}else if(La==G.charAt(0)){if(g)break;ha+="E";g=!0;r=b[0]}else if("+"==La||"-"==La){if(l&&r!=b[0]-1)break;ha+=La}else if(1==this.a&&La==ut.Eg.charAt(0)){if(1!=u)break;u=100;if(l){b[0]++;break}}else if(1==this.a&&La==ut.Fg.charAt(0)){if(1!=u)break;u=1E3;
if(l){b[0]++;break}}else break}1!=this.a&&(u=this.a);e=parseFloat(ha)/u}if(c){if(a.indexOf(this.A,b[0])!=b[0])return NaN;b[0]+=this.A.length}else if(d){if(a.indexOf(this.v,b[0])!=b[0])return NaN;b[0]+=this.v.length}return d?-e:e};
xt.prototype.format=function(a){if(isNaN(a))return ut.lj;var b=[];var c=a;if(0==this.s)c=At;else{c=Math.abs(c);var d=Bt(this,1>=c?0:Ct(c)).rf;c=Bt(this,d+Ct(Dt(this,c/Math.pow(10,d)).Ah))}a/=Math.pow(10,c.rf);b.push(c.prefix);d=0>a||0==a&&0>1/a;b.push(d?this.l:this.u);if(isFinite(a))if(a=a*(d?-1:1)*this.a,this.F){var e=a;if(0==e)Et(this,e,this.b,b),Ft(this,0,b);else{a=Math.floor(Math.log(e)/Math.log(10)+2E-15);var f=Math.pow(10,a);isFinite(f)&&0!==f?e/=f:(f=Math.pow(10,Math.floor(a/2)),e=e/f/f,1==
a%2&&(e=0<a?e/10:10*e));f=this.b;if(1<this.B&&this.B>this.b){for(;0!=a%this.B;)e*=10,a--;f=1}else 1>this.b?(a++,e/=10):(a-=this.b-1,e*=Math.pow(10,this.b-1));Et(this,e,f,b);Ft(this,a,b)}}else Et(this,a,this.b,b);else b.push(ut.Ze);b.push(d?this.v:this.A);b.push(c.zi);return b.join("")};
var Dt=function(a,b){var c=Math.pow(10,a.g);a=0>=a.X?Math.round(b*c):Math.round(Gt(b*c,a.X,a.g));isFinite(a)?(b=Math.floor(a/c),c=Math.floor(a-b*c)):c=0;return{Ah:b,Kk:c}},Et=function(a,b,c,d){if(a.f>a.g)throw Error("Min value must be less than max value");d||(d=[]);b=Dt(a,b);var e=b.Ah,f=b.Kk,g=0<a.f||0<f||!1;b=a.f;g&&(b=a.f);for(var l="",r=e;1E20<r;)l="0"+l,r=Math.round(r/10);l=r+l;var u=ut.rg;r=ut.df.charCodeAt(0);var z=l.length,I=0;if(0<e||0<c){for(e=z;e<c;e++)d.push(String.fromCharCode(r));if(2<=
a.h.length)for(c=1;c<a.h.length;c++)I+=a.h[c];c=z-I;if(0<c){e=a.h;I=z=0;for(var G,ha=ut.Ye,La=l.length,W=0;W<La;W++)if(d.push(String.fromCharCode(r+1*Number(l.charAt(W)))),1<La-W)if(G=e[I],W<c){var gb=c-W;(1===G||0<G&&1===gb%G)&&d.push(ha)}else I<e.length&&(W===c?I+=1:G===W-c-z+1&&(d.push(ha),z+=G,I+=1))}else{c=l;l=a.h;e=ut.Ye;G=c.length;ha=[];for(z=l.length-1;0<=z&&0<G;z--){I=l[z];for(La=0;La<I&&0<=G-La-1;La++)ha.push(String.fromCharCode(r+1*Number(c.charAt(G-La-1))));G-=I;0<G&&ha.push(e)}d.push.apply(d,
ha.reverse())}}else g||d.push(String.fromCharCode(r));(a.H||g)&&d.push(u);f=String(f);g=f.split("e+");2==g.length&&(f=String(Gt(parseFloat(g[0]),a.X,1)),f=f.replace(".",""),f+=wb("0",parseInt(g[1],10)-f.length+1));a.g+1>f.length&&(f="1"+wb("0",a.g-f.length)+f);for(a=f.length;"0"==f.charAt(a-1)&&a>b+1;)a--;for(e=1;e<a;e++)d.push(String.fromCharCode(r+1*Number(f.charAt(e))))},Ft=function(a,b,c){c.push(ut.ug);0>b?(b=-b,c.push(ut.Ag)):a.K&&c.push(ut.sj);b=""+b;for(var d=ut.df,e=b.length;e<a.I;e++)c.push(d);
c.push(b)},zt=function(a){a=a.charCodeAt(0);if(48<=a&&58>a)return a-48;var b=ut.df.charCodeAt(0);return b<=a&&a<b+10?a-b:-1},yt=function(a,b,c){for(var d="",e=!1,f=b.length;c[0]<f;c[0]++){var g=b.charAt(c[0]);if("'"==g)c[0]+1<f&&"'"==b.charAt(c[0]+1)?(c[0]++,d+="'"):e=!e;else if(e)d+=g;else switch(g){case "#":case "0":case ",":case ".":case ";":return d;case "\u00a4":if(c[0]+1<f&&"\u00a4"==b.charAt(c[0]+1))c[0]++,d+=a.w||ut.ud;else switch(a.M){case 0:d+=st[a.w||ut.ud][1];break;case 2:g=a.w||ut.ud;
var l=st[g];d+=g==l[1]?g:g+" "+l[1];break;case 1:d+=st[a.w||ut.ud][2]}break;case "%":if(!a.m&&1!=a.a)throw Error("Too many percent/permill");if(a.m&&100!=a.a)throw Error("Inconsistent use of percent/permill characters");a.a=100;a.m=!1;d+=ut.Eg;break;case "\u2030":if(!a.m&&1!=a.a)throw Error("Too many percent/permill");if(a.m&&1E3!=a.a)throw Error("Inconsistent use of percent/permill characters");a.a=1E3;a.m=!1;d+=ut.Fg;break;default:d+=g}}return d},At={prefix:"",zi:"",rf:0},Bt=function(a,b){a=1==
a.s?rt.og:rt.Mi;null==a&&(a=rt.og);if(3>b)return At;b=Math.min(14,b);var c=a[Math.pow(10,b)];for(--b;!c&&3<=b;)c=a[Math.pow(10,b)],b--;if(!c)return At;a=c.other;return a&&"0"!=a?(a=/([^0]*)(0+)(.*)/.exec(a))?{prefix:a[1],zi:a[3],rf:b+1-(a[2].length-1)}:At:At},Ct=function(a){if(!isFinite(a))return 0<a?a:0;for(var b=0;1<=(a/=10);)b++;return b},Gt=function(a,b,c){if(!a)return a;b=b-Ct(a)-1;if(b<-c)return c=Math.pow(10,c),Math.round(a/c)*c;c=Math.pow(10,b);return Math.round(a*c)/c};var Ht=function(a){return 1==a%10&&11!=a%100?"one":2==a%10&&12!=a%100?"two":3==a%10&&13!=a%100?"few":"other"},It=Ht;It=Ht;var Jt=function(a,b){if(void 0===b){b=a+"";var c=b.indexOf(".");b=Math.min(-1==c?0:b.length-c-1,3)}return 1==(a|0)&&0==b?"one":"other"},Kt=Jt;Kt=Jt;var Ot=function(a){this.g=a;this.b=this.a=this.l=null;a=ut;var b=rt;if(Lt!==a||Mt!==b)Lt=a,Mt=b,Nt=new xt(1);this.h=Nt},Lt=null,Mt=null,Nt=null,Pt=/'([{}#].*?)'/g,Qt=/''/g;Ot.prototype.format=function(a){if(this.g){this.l=[];var b=Rt(this,this.g);this.b=St(this,b);this.g=null}if(this.b&&0!=this.b.length)for(this.a=y(this.l),b=[],Tt(this,this.b,a,!1,b),a=b.join("");0<this.a.length;)a=a.replace(this.f(this.a),this.a.pop());else a="";return a};
var Tt=function(a,b,c,d,e){for(var f=0;f<b.length;f++)switch(b[f].type){case 4:e.push(b[f].value);break;case 3:var g=b[f].value,l=a,r=e,u=c[g];m(u)?(l.a.push(u),r.push(l.f(l.a))):r.push("Undefined parameter - "+g);break;case 2:g=b[f].value;l=e;r=g.pe;m(c[r])?(r=g[c[r]],m(r)||(r=g.other),Tt(a,r,c,d,l)):l.push("Undefined parameter - "+r);break;case 0:g=b[f].value;Ut(a,g,c,Kt,d,e);break;case 1:g=b[f].value;Ut(a,g,c,It,d,e);break;default:Hb("Unrecognized block type: "+b[f].type)}},Ut=function(a,b,c,d,
e,f){var g=b.pe,l=b.Wg,r=+c[g];isNaN(r)?f.push("Undefined or invalid parameter - "+g):(l=r-l,g=b[c[g]],m(g)||(d=a.h.R?d(l,a.h.R()):d(l),g=b[d],m(g)||(g=b.other)),b=[],Tt(a,g,c,e,b),c=b.join(""),e?f.push(c):(a=a.h.format(l),f.push(c.replace(/#/g,a))))},Rt=function(a,b){var c=a.l,d=p(a.f,a);b=b.replace(Qt,function(){c.push("'");return d(c)});return b=b.replace(Pt,function(a,b){c.push(b);return d(c)})},Vt=function(a){var b=0,c=[],d=[],e=/[{}]/g;e.lastIndex=0;for(var f;f=e.exec(a);){var g=f.index;"}"==
f[0]?(c.pop(),0==c.length&&(f={type:1},f.value=a.substring(b,g),d.push(f),b=g+1)):(0==c.length&&(b=a.substring(b,g),""!=b&&d.push({type:0,value:b}),b=g+1),c.push("{"))}b=a.substring(b);""!=b&&d.push({type:0,value:b});return d},Wt=/^\s*(\w+)\s*,\s*plural\s*,(?:\s*offset:(\d+))?/,Xt=/^\s*(\w+)\s*,\s*selectordinal\s*,/,Yt=/^\s*(\w+)\s*,\s*select\s*,/,St=function(a,b){var c=[];b=Vt(b);for(var d=0;d<b.length;d++){var e={};if(0==b[d].type)e.type=4,e.value=b[d].value;else if(1==b[d].type){var f=b[d].value;
switch(Wt.test(f)?0:Xt.test(f)?1:Yt.test(f)?2:/^\s*\w+\s*/.test(f)?3:5){case 2:e.type=2;e.value=Zt(a,b[d].value);break;case 0:e.type=0;e.value=$t(a,b[d].value);break;case 1:e.type=1;e.value=au(a,b[d].value);break;case 3:e.type=3;e.value=b[d].value;break;default:Hb("Unknown block type for pattern: "+b[d].value)}}else Hb("Unknown part of the pattern.");c.push(e)}return c},Zt=function(a,b){var c="";b=b.replace(Yt,function(a,b){c=b;return""});var d={};d.pe=c;b=Vt(b);for(var e=0;e<b.length;){var f=b[e].value;
e++;if(1==b[e].type)var g=St(a,b[e].value);else Hb("Expected block type.");d[f.replace(/\s/g,"")]=g;e++}return d},$t=function(a,b){var c="",d=0;b=b.replace(Wt,function(a,b,e){c=b;e&&(d=parseInt(e,10));return""});var e={};e.pe=c;e.Wg=d;b=Vt(b);for(var f=0;f<b.length;){var g=b[f].value;f++;if(1==b[f].type)var l=St(a,b[f].value);else Hb("Expected block type.");e[g.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=l;f++}return e},au=function(a,b){var c="";b=b.replace(Xt,function(a,b){c=b;return""});var d={};d.pe=c;
d.Wg=0;b=Vt(b);for(var e=0;e<b.length;){var f=b[e].value;e++;if(1==b[e].type)var g=St(a,b[e].value);else Hb("Expected block type.");d[f.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=g;e++}return d};Ot.prototype.f=function(a){return"\ufddf_"+(a.length-1).toString(10)+"_"};var bu=chrome.i18n.getMessage("1522140683318860351"),cu=chrome.i18n.getMessage("4246483347873264186"),du=chrome.i18n.getMessage("5991427458288444010"),cf=chrome.i18n.getMessage("6063910461797960050"),eu=chrome.i18n.getMessage("7735695102441495789"),fu=chrome.i18n.getMessage("4575332923598659024"),gu=chrome.i18n.getMessage("2297080986956220930"),hu=new Ot(gu);var iu=function(a){this.a=a;this.j=Pa("mr.cloud.mesi.MesiService")},Ts=function(a){var b=$r.a;.1>Math.random()&&(b=b.replace("v1","v1_preprod"));b=hs(b,["hangouts","search"]);a.j.info("Retrieving Hangouts from MESI: "+b);return is(a.a,b,"POST",ju).then(function(a){var b=[];a.result&&(b=a.result.map(function(a){var b=a.hangout,c=b.meeting_room_name,d;b.meeting_domain?d=b.meeting_domain:"BUSINESS"==b.type&&b.company_title&&(d=b.company_title.toLowerCase());var e=hu.format({ORGANIZER:"",PARTICIPANTS:0});
if((a=a.participant)&&0<a.length){var u=a[0].display_name;e=a.reduce(function(a,b){a.add(b.user_id);"ORGANIZER"==b.role&&(u=b.display_name);return a},new Set);e=hu.format({ORGANIZER:u,PARTICIPANTS:e.size})}return c&&d?new Wr(!1,c+"@"+d,d,c,e,b.hangout_id):new Wr(!1,b.hangout_id,d,c,e,b.hangout_id)}));return b})},ju={request_header:{client_version:{client_id:"39"}},search_sources:["0"]};var ku=function(a,b,c){this.state=a;this.type=null!=b?b:null;this.a=null!=c?c:null},lu=function(a){this.a=a},ou=function(a,b,c,d){return mu(a,os,b,c,d,35E3).then(function(b){return nu(a,b)})},qu=function(a,b,c,d){return mu(a,ps,b,c,d,23E3).then(function(a){var b=a.state;return"done"==b?(a=pu(a),new ku(b,a.type,new ls(a.sessionDescription))):new ku(b)})},mu=function(a,b,c,d,e,f){var g={_webrtcMessage:JSON.stringify(d.presentationUrl?new ls(d.description,null,d.presentationUrl,d.presentationId):new ls(d.description))};
d.settings&&(g._settings=jg(d.settings));d.mediaConstraints&&(g._optMediaConstraints=JSON.stringify(d.mediaConstraints));e&&(g._user=JSON.stringify(e));return ru(a,c,b,g,f)},nu=function(a,b){var c=b.state;switch(c){case "done":return Promise.resolve(su(b));case "queued":case "inProgress":return tu(a,b).then(function(b){return nu(a,b)});default:return Promise.resolve(new ku(c))}},tu=function(a,b){return new Promise(function(c){var d=setInterval(function(){uu(a,b.id).then(function(a){"queued"!=a.state&&
"inProgress"!=a.state&&(clearInterval(d),c(a))})},2E3)})},su=function(a){a=pu(a);return"__cloud_webrtc_session_message__"==a.type?new ku("done","knocking_cloud_webrtc_session_message",new ls(a.sessionDescription)):new ku("done",a.type)},ru=function(a,b,c,d,e){b={deviceId:b,name:"_cloudCast."+c.name,parameters:d,expirationTimeoutMs:e||1E4};c={};e&&(c.responseAwaitMs=Math.min(e+5E3,25E3));e=hs(Yr.a,["commands"],c);return is(a.a,e,"POST",b)},pu=function(a){return a.results&&a.results.results?JSON.parse(a.results.results):
null},uu=function(a,b){b=hs(Yr.a,["commands",b]);return is(a.a,b,"GET")};lu.$inject=["gapiService"];var vu=function(a,b,c,d){this.b=a;this.f=b;this.g=c;this.a=d},zu=function(a,b,c,d){return wu(a,b,d).then(function(b){a:{var d=c.id;if("done"!=b.state)d=Promise.reject(Error("Offer not executed by receiver. State: "+b.state));else{switch(b.type){case "__cloud_webrtc_session_message__":b=new mg("ANSWER",b.a.sessionDescription);xu(a.a,b,d);break;case "knocking_cloud_webrtc_session_message":Mr(0);b=new mg("KNOCK_ANSWER",b.a.sessionDescription);xu(a.a,b,d);break;case "knock_denied":Mr(1);yu(a,cu,d);break;
case "knock_timeout":Mr(2);yu(a,du,d);break;default:d=Promise.reject(Error("Invalid message type: "+b.type));break a}d=Promise.resolve()}}return d})},Bu=function(a,b){return Au(a.g).then(function(c){xu(a.a,new mg("TURN_CREDENTIALS",{credentials:c}),b.id)})},wu=function(a,b,c){var d=c.deviceId,e=a.f.a;e=e?new js(e):void 0;b=b.data;switch(c.ef){case "owner":Pr(0);break;case "manager":Pr(1);break;case "user":Pr(2);break;case "viewer":Pr(3)}return"viewer"==c.ef?ou(a.b,d,b,e):qu(a.b,d,b,e)},yu=function(a,
b,c){b=new bf(b,"warning");b.isBlocking=!0;a.a.a.tc(b);xu(a.a,new mg("STOP"),c)};var Cu=function(a,b){this.b=a;this.a=b},Eu=function(a,b,c,d){switch(b.type){case "REFRESH_AUTH":var e=d.Fb,f=d.deviceId,g=d.zc;return ot(a.b).then(function(){xu(a.a,new mg("AUTH_READY",{Fb:e,Ha:f,zc:g}),c.id)});case "LOCAL_PRESENT":return xu(a.a,new mg("AUTH_READY",{Fb:d.Fb,Ha:d.deviceId,zc:d.zc,ac:!b.data.local}),c.id),Promise.resolve();case "STATUS_REQUEST":return xu(a.a,b,c.id),Promise.resolve();case "STATUS_RESPONSE":return xu(a.a,b,c.id,!0),b.data.routeDescription||xu(a.a,b,c.id),Promise.resolve();
case "HANGOUT_INACTIVE":return Du(a.a,c,4,new bf(eu,"warning"));case "HANGOUT_INVALID":return Du(a.a,c,3,new bf(fu,"warning"));default:return Promise.reject(Error("Unknown type: "+b.type))}};var Fu=function(a,b,c){this.b=a;this.f=b;this.a=c},Gu=function(a,b,c,d,e){return new Promise(function(f){switch(b){case "cloud":case "mesi":break;default:throw Error("Unrecognized channel type");}if(!c.type)throw Error("Message has no type");switch(c.type){case "STOP":f(Du(a.a,d,1,null));return;case "SESSION_START_SUCCESS":Nr(0);break;case "SESSION_END":break;case "SESSION_FAILURE":Nr(1);f(Du(a.a,d,2,new bf(bu,"warning")));return;case "__webrtc_stats__":break;case "PRESENTATION_CONNECTION_MESSAGE":xu(a.a,
c.data,d.id,!0);break;case "OFFER":f(zu(a.b,c,d,e));return;case "GET_TURN_CREDENTIALS":f(Bu(a.b,d));return;case "REFRESH_AUTH":case "LOCAL_PRESENT":case "MUTE":case "STATUS_REQUEST":case "STATUS_RESPONSE":case "HANGOUT_INACTIVE":case "HANGOUT_INVALID":f(Eu(a.f,c,d,e));return;case "new_session":xu(a.a,c,d.id,!0);break;case "remove_session":xu(a.a,c,d.id,!0);a.a.terminateRoute(d.id);break;default:throw Error("Unknown type: "+c.type);}f()})};var Hu=function(){var a=this;this.j=Pa("mr.cloud.settings.SettingsService");this.a=null;chrome.settingsPrivate.onPrefsChanged.addListener(function(b){Ef(13);if(a.a){b=ja(b);for(var c=b.next();!c.done;c=b.next())if(c=c.value,"media_router.cloudservices.enabled"==c.key){a.a.call(null,c.value);break}}})},Iu=function(a,b){a.a=b},Ju=function(a){var b=a.j;chrome.storage.sync.set({"mr.cloud.cloudEnabled":!0},function(){chrome.runtime.lastError&&v(b,"Error setting cloud setting: "+JSON.stringify(chrome.runtime.lastError))})},
Lu=function(a){return Ku().catch(function(){return Ku().catch(function(b){v(a.j,"Error retrieving cloud on setting.",b);return!1})})},Ku=function(){return Mu("mr.cloud.cloudEnabled").then(function(a){return!!a["mr.cloud.cloudEnabled"]})},Mu=function(a){return new Promise(function(b,c){chrome.storage.sync.get(a,function(a){chrome.runtime.lastError?c(chrome.runtime.lastError):b(a)})})},Ou=function(a){return Nu().catch(function(){return Nu().catch(function(b){v(a.j,"Error retrieving cloud enabled setting.",
b);return!1})})},Nu=function(){return Pu().then(function(a){return!!a.value})},Pu=function(){return new Promise(function(a,b){chrome.settingsPrivate.getPref("media_router.cloudservices.enabled",function(c){chrome.runtime.lastError?b(chrome.runtime.lastError):a(c)})})},Qu=function(a){var b=a.j;chrome.storage.sync.set({"mr.cloud.notifiedHangouts":!0},function(){chrome.runtime.lastError&&v(b,"Error setting notified Hangout privacy.",chrome.runtime.lastError)})},Su=function(a){return Ru().catch(function(){return Ru().catch(function(b){v(a.j,
"Error retrieving hangouts notified setting.",b);return!1})})},Ru=function(){return Mu("mr.cloud.notifiedHangouts").then(function(a){return!!a["mr.cloud.notifiedHangouts"]})};var Tu=function(){var a=window.crypto.getRandomValues(new Uint8Array(16));return Nb(a,function(a){a=a.toString(16);return 1<a.length?a:"0"+a}).join("")},Uu=function(a){for(var b=[],c=0,d=0;d<a.length;d++){var e=a.charCodeAt(d);128>e?b[c++]=e:(2048>e?b[c++]=e>>6|192:(55296==(e&64512)&&d+1<a.length&&56320==(a.charCodeAt(d+1)&64512)?(e=65536+((e&1023)<<10)+(a.charCodeAt(++d)&1023),b[c++]=e>>18|240,b[c++]=e>>12&63|128):b[c++]=e>>12|224,b[c++]=e>>6&63|128),b[c++]=e&63|128)}return b},Vu=function(a){for(var b=
[],c=0,d=0;c<a.length;){var e=a[c++];if(128>e)b[d++]=String.fromCharCode(e);else if(191<e&&224>e){var f=a[c++];b[d++]=String.fromCharCode((e&31)<<6|f&63)}else if(239<e&&365>e){f=a[c++];var g=a[c++],l=a[c++];e=((e&7)<<18|(f&63)<<12|(g&63)<<6|l&63)-65536;b[d++]=String.fromCharCode(55296+(e>>10));b[d++]=String.fromCharCode(56320+(e&1023))}else f=a[c++],g=a[c++],b[d++]=String.fromCharCode((e&15)<<12|(f&63)<<6|g&63)}return b.join("")};var Wu=null,Xu=null,Zu=function(a){Yu();for(var b=Wu,c=[],d=0;d<a.length;d+=3){var e=a[d],f=d+1<a.length,g=f?a[d+1]:0,l=d+2<a.length,r=l?a[d+2]:0,u=e>>2;e=(e&3)<<4|g>>4;g=(g&15)<<2|r>>6;r&=63;l||(r=64,f||(g=64));c.push(b[u],b[e],b[g],b[r])}return c.join("")},av=function(a){var b=a.length,c=0;"="===a[b-2]?c=2:"="===a[b-1]&&(c=1);var d=new Uint8Array(Math.ceil(3*b/4)-c),e=0;$u(a,function(a){d[e++]=a});return d.subarray(0,e)},$u=function(a,b){function c(b){for(;d<a.length;){var c=a.charAt(d++),e=Xu[c];
if(null!=e)return e;if(!nb(c))throw Error("Unknown base64 encoding at char: "+c);}return b}Yu();for(var d=0;;){var e=c(-1),f=c(0),g=c(64),l=c(64);if(64===l&&-1===e)break;b(e<<2|f>>4);64!=g&&(b(f<<4&240|g>>2),64!=l&&b(g<<6&192|l))}},Yu=function(){if(!Wu){Wu={};Xu={};for(var a=0;65>a;a++)Wu[a]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a),Xu[Wu[a]]=a,62<=a&&(Xu["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(a)]=a)}};var bv=function(a,b){this.a=a;this.b=b},cv=function(a){return new bv((a.a>>>1|(a.b&1)<<31)>>>0,a.b>>>1>>>0)},dv=function(a){return new bv(a.a<<1>>>0,(a.b<<1|a.a>>>31)>>>0)};bv.prototype.add=function(a){return new bv((this.a+a.a&4294967295)>>>0>>>0,((this.b+a.b&4294967295)>>>0)+(4294967296<=this.a+a.a?1:0)>>>0)};
var ev=function(a,b){return new bv((a.a-b.a&4294967295)>>>0>>>0,((a.b-b.b&4294967295)>>>0)-(0>a.a-b.a?1:0)>>>0)},fv=function(a){var b=a&65535,c=a>>>16;a=10*b+65536*(0*b&65535)+65536*(10*c&65535);for(b=0*c+(0*b>>>16)+(10*c>>>16);4294967296<=a;)a-=4294967296,b+=1;return new bv(a>>>0,b>>>0)};
bv.prototype.toString=function(){for(var a="",b=this;0!=b.a||0!=b.b;){var c=new bv(0,0);b=new bv(b.a,b.b);for(var d=new bv(10,0),e=new bv(1,0);!(d.b&2147483648);)d=dv(d),e=dv(e);for(;0!=e.a||0!=e.b;)0>=(d.b<b.b||d.b==b.b&&d.a<b.a?-1:d.b==b.b&&d.a==b.a?0:1)&&(c=c.add(e),b=ev(b,d)),d=cv(d),e=cv(e);c=[c,b];b=c[0];a=c[1].a+a}""==a&&(a="0");return a};
var gv=function(a){for(var b=new bv(0,0),c=new bv(0,0),d=0;d<a.length;d++){if("0">a[d]||"9"<a[d])return null;c.a=parseInt(a[d],10);var e=fv(b.a);b=fv(b.b);b.b=b.a;b.a=0;b=e.add(b).add(c)}return b};bv.prototype.clone=function(){return new bv(this.a,this.b)};var hv=function(a,b){this.a=a;this.b=b};hv.prototype.add=function(a){return new hv((this.a+a.a&4294967295)>>>0>>>0,((this.b+a.b&4294967295)>>>0)+(4294967296<=this.a+a.a?1:0)>>>0)};hv.prototype.clone=function(){return new hv(this.a,this.b)};
hv.prototype.toString=function(){var a=0!=(this.b&2147483648),b=new bv(this.a,this.b);a&&(b=ev(new bv(0,0),b));return(a?"-":"")+b.toString()};var iv=0,jv=0,kv=function(a){var b=0>a;a=Math.abs(a);var c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));iv=c;jv=a},lv=function(a){if(a.constructor===Uint8Array)return a;if(a.constructor===ArrayBuffer)return new Uint8Array(a);if(a.constructor===Array)return new Uint8Array(a);if(a.constructor===String)return av(a);Hb("Type not convertible to Uint8Array.");return new Uint8Array(0)};var nv=function(a,b,c){this.b=null;this.m=this.u=this.a=this.g=this.l=0;this.h=!1;a&&mv(this,a,b,c)},ov=[],pv=function(a,b,c){if(ov.length){var d=ov.pop();a&&mv(d,a,b,c);return d}return new nv(a,b,c)};nv.prototype.clone=function(){return pv(this.b,this.l,this.g-this.l)};nv.prototype.clear=function(){this.b=null;this.a=this.g=this.l=0;this.h=!1};var mv=function(a,b,c,d){a.b=lv(b);a.l=m(c)?c:0;a.g=m(d)?a.l+d:a.b.length;a.a=a.l};nv.prototype.reset=function(){this.a=this.l};
nv.prototype.f=function(){var a=this.b;var b=a[this.a+0];var c=b&127;if(128>b)return this.a+=1,c;b=a[this.a+1];c|=(b&127)<<7;if(128>b)return this.a+=2,c;b=a[this.a+2];c|=(b&127)<<14;if(128>b)return this.a+=3,c;b=a[this.a+3];c|=(b&127)<<21;if(128>b)return this.a+=4,c;b=a[this.a+4];c|=(b&15)<<28;if(128>b)return this.a+=5,c>>>0;this.a+=10;return c};nv.prototype.v=nv.prototype.f;
var qv=function(a){a:{for(var b,c=0,d,e=0;4>e;e++)if(b=a.b[a.a++],c|=(b&127)<<7*e,128>b){a.u=c>>>0;a.m=0;break a}b=a.b[a.a++];c|=(b&127)<<28;d=0|(b&127)>>4;if(128>b)a.u=c>>>0,a.m=d>>>0;else{for(e=0;5>e;e++)if(b=a.b[a.a++],d|=(b&127)<<7*e+3,128>b){a.u=c>>>0;a.m=d>>>0;break a}Hb("Failed to read varint, encoding is invalid.");a.h=!0}}b=a.u;c=a.m;if(a=c&2147483648)b=~b+1>>>0,c=~c>>>0,0==b&&(c=c+1>>>0);b=4294967296*c+b;return a?-b:b};nv.prototype.s=function(){return this.v()};var rv=function(){this.a=[]};rv.prototype.length=function(){return this.a.length};var sv=function(a){var b=a.a;a.a=[];return b},tv=function(a,b,c){for(;0<c||127<b;)a.a.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.a.push(b)},uv=function(a,b){for(;127<b;)a.a.push(b&127|128),b>>>=7;a.a.push(b)},vv=function(a,b){if(0<=b)uv(a,b);else{for(var c=0;9>c;c++)a.a.push(b&127|128),b>>=7;a.a.push(1)}},wv=function(a,b){a.a.push(b>>>0&255);a.a.push(b>>>8&255);a.a.push(b>>>16&255);a.a.push(b>>>24&255)};var xv=function(a,b,c){this.a=pv(a,b,c);this.b=this.f=-1;this.g=!1};xv.prototype.reset=function(){this.a.reset();this.b=this.f=-1};
var yv=function(a){var b=a.a;if(b.a==b.g)return!1;(b=a.g)||(b=a.a,b=b.h||0>b.a||b.a>b.g);if(b)return Hb("Decoder hit an error"),!1;var c=a.a.f();b=c>>>3;c&=7;if(0!=c&&5!=c&&1!=c&&2!=c&&3!=c&&4!=c)return Hb("Invalid wire type"),a.g=!0,!1;a.f=b;a.b=c;return!0},zv=function(a){switch(a.b){case 0:if(0!=a.b)Hb("Invalid wire type for skipVarintField"),zv(a);else{for(a=a.a;a.b[a.a]&128;)a.a++;a.a++}break;case 1:1!=a.b?(Hb("Invalid wire type for skipFixed64Field"),zv(a)):(a=a.a,a.a+=8);break;case 2:if(2!=
a.b)Hb("Invalid wire type for skipDelimitedField"),zv(a);else{var b=a.a.f();a=a.a;a.a+=b}break;case 5:5!=a.b?(Hb("Invalid wire type for skipFixed32Field"),zv(a)):(a=a.a,a.a+=4);break;case 3:b=[a.f];do{if(!yv(a)){Hb("Unmatched start-group tag: stream EOF");a.g=!0;break}if(3==a.b)b.push(a.f);else if(4==a.b&&a.f!=b.pop()){Hb("Unmatched end-group tag");a.g=!0;break}}while(0<b.length);break;default:Hb("Invalid wire encoding for field.")}},Av=function(a,b,c){var d=a.a.g,e=a.a.f();e=a.a.a+e;a.a.g=e;c(b,
a);a.a.a=e;a.a.g=d},Bv=function(a){var b=a.a.f();a=a.a;var c=a.b,d=a.a,e=d+b,f=[];for(b="";d<e;){var g=c[d++];if(128>g)f.push(g);else if(192>g)continue;else if(224>g){var l=c[d++];f.push((g&31)<<6|l&63)}else if(240>g){l=c[d++];var r=c[d++];f.push((g&15)<<12|(l&63)<<6|r&63)}else if(248>g){l=c[d++];r=c[d++];var u=c[d++];g=(g&7)<<18|(l&63)<<12|(r&63)<<6|u&63;g-=65536;f.push((g>>10&1023)+55296,(g&1023)+56320)}8192<=f.length&&(b+=String.fromCharCode.apply(null,f),f.length=0)}if(8192>=f.length)f=String.fromCharCode.apply(null,
f);else{c="";for(e=0;e<f.length;e+=8192)c+=String.fromCharCode.apply(null,fc(f,e,e+8192));f=c}a.a=d;return b+f},Cv=function(a,b){var c=a.a.f();c=a.a.a+c;for(var d=[];a.a.a<c;)d.push(b.call(a.a));return d};var E=function(){this.f=[];this.b=0;this.a=new rv},Ev=function(a,b){Dv(a,b,2);b=sv(a.a);a.f.push(b);a.b+=b.length;b.push(a.b);return b},Fv=function(a,b){var c=b.pop();for(c=a.b+a.a.length()-c;127<c;)b.push(c&127|128),c>>>=7,a.b++;b.push(c);a.b++};E.prototype.reset=function(){this.f=[];sv(this.a);this.b=0};
var F=function(a){for(var b=new Uint8Array(a.b+a.a.length()),c=a.f,d=c.length,e=0,f=0;f<d;f++){var g=c[f];b.set(g,e);e+=g.length}c=sv(a.a);b.set(c,e);a.f=[b];return b},Dv=function(a,b,c){uv(a.a,8*b+c)},H=function(a,b,c){null!=c&&null!=c&&(Dv(a,b,0),vv(a.a,c))},J=function(a,b,c){null!=c&&null!=c&&(Dv(a,b,0),a=a.a,kv(c),tv(a,iv,jv))},Gv=function(a,b,c){if(null!=c){var d=c;(c=0<d.length&&"-"==d[0])&&(d=d.substring(1));d=gv(d);null===d?c=null:(c&&(d=ev(new bv(0,0),d)),c=new hv(d.a,d.b));Dv(a,b,0);tv(a.a,
c.a,c.b)}},Hv=function(a,b,c){null!=c&&null!=c&&(Dv(a,b,0),uv(a.a,c))},Iv=function(a,b,c){null!=c&&null!=c&&(Dv(a,b,0),a=a.a,kv(c),tv(a,iv,jv))},Jv=function(a,b,c){null!=c&&(c=gv(c),Dv(a,b,0),tv(a.a,c.a,c.b))},Kv=function(a,b,c){null!=c&&(Dv(a,b,5),wv(a.a,c))},Lv=function(a,b,c){if(null!=c){Dv(a,b,5);a=a.a;var d=c;d=(c=0>d?1:0)?-d:d;0===d?0<1/d?iv=jv=0:(jv=0,iv=2147483648):isNaN(d)?(jv=0,iv=2147483647):3.4028234663852886E38<d?(jv=0,iv=(c<<31|2139095040)>>>0):1.1754943508222875E-38>d?(d=Math.round(d/
Math.pow(2,-149)),jv=0,iv=(c<<31|d)>>>0):(b=Math.floor(Math.log(d)/Math.LN2),d*=Math.pow(2,-b),d=Math.round(8388608*d)&8388607,jv=0,iv=(c<<31|b+127<<23|d)>>>0);wv(a,iv)}},K=function(a,b,c){null!=c&&(Dv(a,b,0),a.a.a.push(c?1:0))},L=function(a,b,c){null!=c&&(Dv(a,b,0),vv(a.a,c))},M=function(a,b,c){if(null!=c){b=Ev(a,b);for(var d=a.a,e=0;e<c.length;e++){var f=c.charCodeAt(e);if(128>f)d.a.push(f);else if(2048>f)d.a.push(f>>6|192),d.a.push(f&63|128);else if(65536>f)if(55296<=f&&56319>=f&&e+1<c.length){var g=
c.charCodeAt(e+1);56320<=g&&57343>=g&&(f=1024*(f-55296)+g-56320+65536,d.a.push(f>>18|240),d.a.push(f>>12&63|128),d.a.push(f>>6&63|128),d.a.push(f&63|128),e++)}else d.a.push(f>>12|224),d.a.push(f>>6&63|128),d.a.push(f&63|128)}Fv(a,b)}},Mv=function(a,b,c){null!=c&&(c=lv(c),Dv(a,b,2),uv(a.a,c.length),b=sv(a.a),a.f.push(b),a.f.push(c),a.b+=b.length+c.length)},N=function(a,b,c,d){null!=c&&(b=Ev(a,b),d(c,a),Fv(a,b))},Nv=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(Dv(e,
b,0),vv(e.a,f))}},Ov=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(Dv(e,b,0),e=e.a,kv(f),tv(e,iv,jv))}},Pv=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(Dv(e,b,0),uv(e.a,f))}},Qv=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)Kv(a,b,c[d])},Rv=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)L(a,b,c[d])},Sv=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)M(a,b,c[d])},Tv=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)Mv(a,
b,c[d])},O=function(a,b,c,d){if(null!=c)for(var e=0;e<c.length;e++){var f=Ev(a,b);d(c[e],a);Fv(a,f)}},Uv=function(a,b,c,d){if(null!=c)for(var e=0;e<c.length;e++)Dv(a,b,3),d(c[e],a),Dv(a,b,4)},Vv=function(a,b,c){if(null!=c&&c.length){b=Ev(a,b);for(var d=0;d<c.length;d++)vv(a.a,c[d]);Fv(a,b)}};var P=function(){},Wv="function"==typeof Uint8Array,Q=function(a,b,c,d,e){a.a=null;b||(b=c?[c]:[]);a.A=c?String(c):void 0;a.g=0===c?-1:0;a.b=b;a:{if(a.b.length&&(b=a.b.length-1,(c=a.b[b])&&"object"==typeof c&&!Aa(c)&&!(Wv&&c instanceof Uint8Array))){a.l=b-a.g;a.f=c;break a}-1<d?(a.l=d,a.f=null):a.l=Number.MAX_VALUE}a.B={};if(e)for(d=0;d<e.length;d++)b=e[d],b<a.l?(b+=a.g,a.b[b]=a.b[b]||Xv):(Yv(a),a.f[b]=a.f[b]||Xv)},Xv=Object.freeze?Object.freeze([]):[],Yv=function(a){var b=a.l+a.g;a.b[b]||(a.f=a.b[b]=
{})},Zv=function(a,b,c,d){for(var e in c){var f=c[e],g=f.fs;if(!f.Yg)throw Error("Message extension present that was generated without binary serialization support");var l=d.call(a,g);if(null!=l)if(g.Ch())if(f.Ak)f.Yg.call(b,g.fh,l,f.Ak);else throw Error("Message extension present holding submessage without binary support enabled, and message is being serialized to binary format");else f.Yg.call(b,g.fh,l)}},R=function(a,b){if(b<a.l){b+=a.g;var c=a.b[b];return c===Xv?a.b[b]=[]:c}if(a.f)return c=a.f[b],
c===Xv?a.f[b]=[]:c},S=function(a,b){if(b<a.l){b+=a.g;var c=a.b[b];return c===Xv?a.b[b]=[]:c}c=a.f[b];return c===Xv?a.f[b]=[]:c},$v=function(a,b){a=R(a,b);return null==a?a:+a},aw=function(a){if(null==a||a instanceof Uint8Array)return a;if(ta(a))return av(a);Hb("Cannot coerce to Uint8Array: "+ya(a));return null},cw=function(a){bw(a);return!a.length||a[0]instanceof Uint8Array?a:Nb(a,aw)},bw=function(a){if(a&&1<a.length){var b=ya(a[0]);x(a,function(a){ya(a)!=b&&Hb("Inconsistent type in JSPB repeated field array. Got "+
ya(a)+" expected "+b)})}},T=function(a,b,c){a=R(a,b);return null==a?c:a},U=function(a,b,c){b<a.l?a.b[b+a.g]=c:(Yv(a),a.f[b]=c)},ew=function(a,b,c){dw(a,b,c,"")},dw=function(a,b,c,d){c!=d?U(a,b,c):a.b[b+a.g]=null},V=function(a,b,c,d){a.a||(a.a={});if(!a.a[c]){var e=R(a,c);if(d||e)a.a[c]=new b(e)}return a.a[c]},X=function(a,b,c){fw(a,b,c);b=a.a[c];b==Xv&&(b=a.a[c]=[]);return b},fw=function(a,b,c){a.a||(a.a={});if(!a.a[c]){for(var d=S(a,c),e=[],f=0;f<d.length;f++)e[f]=new b(d[f]);a.a[c]=e}},Y=function(a,
b,c){a.a||(a.a={});var d=c?gw(c):c;a.a[b]=c;U(a,b,d)},hw=function(a,b,c){a.a||(a.a={});c=c||[];for(var d=[],e=0;e<c.length;e++)d[e]=gw(c[e]);a.a[b]=c;U(a,b,d)},iw=function(a,b,c,d){fw(a,d,b);var e=a.a[b];e||(e=a.a[b]=[]);c=c?c:new d;a=S(a,b);e.push(c);a.push(gw(c))},jw=function(a){if(a.a)for(var b in a.a){var c=a.a[b];if(Aa(c))for(var d=0;d<c.length;d++)c[d]&&gw(c[d]);else c&&gw(c)}},gw=function(a){jw(a);return a.b};
P.prototype.ia=Wv?function(){var a=Uint8Array.prototype.toJSON;Uint8Array.prototype.toJSON=function(){return Zu(this)};try{var b=JSON.stringify(gw(this),kw)}finally{Uint8Array.prototype.toJSON=a}return b}:function(){return JSON.stringify(gw(this),kw)};var kw=function(a,b){if(n(b)){if(isNaN(b))return"NaN";if(Infinity===b)return"Infinity";if(-Infinity===b)return"-Infinity"}return b},mw=function(a){var b=lw[a[0]];if(!b)throw Error("Unknown JsPb message type: "+a[0]);return new b(a)};
P.prototype.toString=function(){jw(this);return this.b.toString()};P.prototype.m=function(a){if(this.f){this.a||(this.a={});var b=a.fh;if(a.b){if(a.Ch())return this.a[b]||(this.a[b]=Nb(this.f[b]||[],function(b){return new a.a(b)})),this.a[b]}else if(a.Ch())return!this.a[b]&&this.f[b]&&(this.a[b]=new a.a(this.f[b])),this.a[b];return this.f[b]}};
var ow=function(a,b){a=a||{};b=b||{};var c={},d;for(d in a)c[d]=0;for(d in b)c[d]=0;for(d in c)if(!nw(a[d],b[d]))return!1;return!0},nw=function(a,b){if(a==b)return!0;if(!Da(a)||!Da(b)||a.constructor!=b.constructor)return!1;if(Wv&&a.constructor===Uint8Array){if(a.length!=b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!=b[c])return!1;return!0}if(a.constructor===Array){var d=void 0,e=void 0,f=Math.max(a.length,b.length);for(c=0;c<f;c++){var g=a[c],l=b[c];g&&g.constructor==Object&&(d=g,g=void 0);
l&&l.constructor==Object&&(e=l,l=void 0);if(!nw(g,l))return!1}return d||e?(d=d||{},e=e||{},ow(d,e)):!0}if(a.constructor===Object)return ow(a,b);throw Error("Invalid type in JSPB array");};P.prototype.clone=function(){return pw(this)};
var pw=function(a){return new a.constructor(qw(gw(a)))},qw=function(a){var b;if(Aa(a)){for(var c=Array(a.length),d=0;d<a.length;d++)null!=(b=a[d])&&(c[d]="object"==typeof b?qw(b):b);return c}if(Wv&&a instanceof Uint8Array)return new Uint8Array(a);c={};for(d in a)null!=(b=a[d])&&(c[d]="object"==typeof b?qw(b):b);return c},rw=function(a,b){lw[a]=b;b.messageId=a},lw={};var Z=function(a){Q(this,a,0,-1,null)};t(Z,P);Z.prototype.o=function(){var a=new E;sw(this,a);return F(a)};var sw=function(a,b){var c=R(a,1);null!=c&&J(b,1,c);c=R(a,2);null!=c&&M(b,2,c);c=V(a,tw,3);null!=c&&N(b,3,c,uw)},tw=function(a){Q(this,a,0,-1,null)};t(tw,P);tw.prototype.o=function(){var a=new E;uw(this,a);return F(a)};var uw=function(a,b){var c=R(a,1);null!=c&&M(b,1,c);c=R(a,2);null!=c&&J(b,2,c)};Z.prototype.ub=function(){return R(this,1)};var vw=function(){this.a=null},ww=function(a,b){if(!a.a||R(a.a,2)<R(b,2))a.a=pw(b)},xw=function(a){return a.a?R(a.a,2)+";"+R(a.a,1):null};var yw=function(){this.j=Pa("mr.cloud.CredentialService")},Au=function(a){var b=new kb,c=as.a+"/iceconfig?key="+as.b;a.j.info("Requesting TURN credentials from "+c);var d=Oj(c,function(){Yj(d)?(a.j.info("Got TURN credentials: "+Zj(d)),b.resolve(zw(a,ak(d)))):b.resolve(Aw(a))},"POST",void 0,{"Content-Type":"application/json"});return b.a},zw=function(a,b){try{var c=[];b.iceServers.forEach(function(a){a.urls.forEach(function(b){0==b.indexOf("turn:")&&c.push({url:b,credential:a.credential,username:a.username})})});
return c}catch(d){return a.j.error("Error parsing TURN credentials.",d),[]}},Aw=function(a){a.j.error("XHR failed fetching TURN credentials.",null);return[]};var Bw=function(){this.u=this.I=this.B=this.A=this.w=this.m=this.s=this.l=this.b=this.h=this.g=this.f=this.v=this.a=null},Cw=function(){var a=Bw.ja();null==a.u&&(a.u=new vw);return a.u},Dw=function(a){null==a.a&&(a.a=new mt);return a.a},Ew=function(a){null==a.v&&(a.v=new et(Dw(a)));return a.v},Fw=function(a){null==a.s&&(a.s=new lu(Ew(a)));return a.s};xa(Bw);var Gw=function(a){this.a=a;this.b=new Map;this.A=new Map;this.s=[];this.l=this.I=this.v=this.B=this.h=null;this.m=this.g=this.f=!1;this.w=new Map;this.u=new Map;Jg(this)};Gw.prototype.getName=function(){return"cloud"};
Gw.prototype.Ga=function(){var a=this;this.j.info("Initializing Cloud MRP");var b=Bw.ja();null==b.g&&(null==b.f&&(b.f=new ts(Ew(b))),b.g=new Ps(b.f,this));this.s.push(b.g);if(null==b.l){null==b.b&&(b.b=new bs(Ew(b),Dw(b)));var c=b.b;null==b.h&&(b.h=new iu(Ew(b)));b.l=new Ss(c,b.h,this)}this.h=b.l;this.s.push(this.h);this.B=Fw(b);this.v=Dw(b);if(null==b.A){if(null==b.m){c=Fw(b);var d=Dw(b);null==b.I&&(b.I=new yw(Ew(b)));b.m=new vu(c,d,b.I,this)}c=b.m;null==b.w&&(b.w=new Cu(Dw(b),this));b.A=new Fu(c,
b.w,this)}this.I=b.A;null==b.B&&(b.B=new Hu);this.l=b.B;Ou(this.l).then(function(b){a.f=b;a.j.info("Cloud enabled setting: "+a.f)});Lu(this.l).then(function(b){a.g=b;a.j.info("Cloud on setting: "+a.g)});Iu(this.l,function(b){a.f=b;a.j.info("Cloud enabled setting: "+a.f);a.f&&Hw(a)});Su(this.l).then(function(b){a.m=b;a.j.info("Privacy notified setting: "+a.m)})};Gw.prototype.rc=function(){return Array.from(this.b.values())};
Gw.prototype.Cd=function(a){if(!Iw(this,a))return ll;w(this.j,"GetAvailableSinks for "+a);var b=[];if(this.g||Jw())b=Hw(this);this.u.clear();for(var c={},d=ja(this.w.values()),e=d.next();!e.done;c={kd:c.kd,xe:c.xe},e=d.next())c.kd=e.value,c.xe=!1,b.forEach(function(a){return function(b){b.Ea.id==a.kd.Ea.id&&(a.xe=!0,b.Ea.friendlyName=a.kd.Ea.friendlyName)}}(c)),c.xe||this.u.set(c.kd.Ea.id,c.kd);b=b.concat.apply(b,[].concat(k(this.u.values())));w(this.j,function(){return"Available sinks are..."+JSON.stringify(b)});
c=b.map(function(a){return a.Ea});this.h&&(c=c.concat(Kw));return new kl(c,-1!=a.indexOf("0F5096E8")?Jf:null)};var Hw=function(a){var b=[];a.j.info("Checking cloud discovery services");Nl().g=Ka();a.s.forEach(function(a){a=a.cd();b=b.concat(a)});return b};h=Gw.prototype;h.startObservingMediaSinks=function(){};h.stopObservingMediaSinks=function(){};h.startObservingMediaRoutes=function(){};h.stopObservingMediaRoutes=function(){};h.Kd=function(a){return(a=Lw(this,a))?a.Ea:null};
h.createRoute=function(a,b,c,d,e,f,g){var l=this;this.j.info("createRoute called");w(this.j,"urn: "+a+" sinkId:"+b);if(e=this.A.get(b))return ff(this.a.Eh(this,e,a,c,g,function(b){b.mediaSource=a;b.sb.tabId=g;return hf(b)}),function(a){l.a.hc(l,a);return a});e=Lw(this,b);return Mw(this,a,e,b,c,d,g)};
var Nw=function(a,b,c,d,e){b instanceof Cl&&2==b.errorCode?Du(a,c,6,null):(a.j.error("Error on start session",b instanceof Error?b:Error("Expected an Error value, got "+b)),a.b.has(c.id)&&Du(a,c,e,new bf(bu,"warning")));if(b=a.h)b=a.h,b.b.delete(d.deviceId)?(b.a.a.delete(d.Ea.id),b=!0):b=!1;b&&Ls(a,[d.Ea])},Mw=function(a,b,c,d,e,f,g){if(f)return jf(Error("not supported"));f=!1;switch(Ow(c)){case "cloud":Or(1);break;case "mesi":f=!0;if(!a.m){a.m=!0;Qu(a.l);var l=df();a.a.tc(l)}Or(0)}Nl().f=new Kl(c.model,
null);var r=gk(e,a.getName(),d,b,!0,"");f&&(r.customControllerPath="cloud_route_details/view.html?routeId="+r.id,r.controllerType=mojo.RouteControllerType&&mojo.RouteControllerType.kHangouts);a.b.set(r.id,r);a.A.set(d,r);a.w.set(r.id,c);a.a.dd(a,r);a.a.jd(a.ha(),!0);if(If(b)&&!f)return a.j.info("starting presentation on route: "+r.id),gf(Pw(r,b),function(b){Nw(a,b,r,c,7);throw b;});a.j.info("starting mirroring on route: "+r.id);r.sb={tabId:g,sessionId:"",Yd:"",Zd:c.model};If(b)&&(r.isOffscreenPresentation=
!0);return gf(a.a.Ef(a,r,e),function(b){Nw(a,b,r,c,5);throw b;})};Gw.prototype.terminateRoute=function(a){var b=this.b.get(a);return b?Du(this,b,0,null):Promise.reject(new Cl(3,"Route in cloud provider not found for routeId "+a))};
var Du=function(a,b,c,d){a.j.info("terminating route: "+b.id);a.b.delete(b.id);a.A.delete(b.sinkId);var e=a.w.get(b.id);a.w.delete(b.id);d&&a.a.tc(d);ib("MediaRouter.Cloud.Session.End",c,Jr);switch(c){case 1:break;default:switch(Ow(e)){case "cloud":ru(a.B,e.deviceId,qs,{})}}a.a.Md(a,b);0==a.b.size&&a.a.jd(a.ha(),!1);a.a.onPresentationConnectionStateChanged(b.id,"terminated");a.u.has(b.sinkId)&&(c=a.u.get(b.sinkId),Ls(a,[c.Ea]),a.u.delete(b.sinkId));return Promise.resolve()};h=Gw.prototype;
h.sendRouteMessage=function(a,b,c){if(c&&c.channelType){c=c.channelType;var d=(a=this.b.get(a)||void 0)?Lw(this,a.sinkId):void 0;return Gu(this.I,c,b,a,d)}return ta(b)?(xu(this,b,a),Promise.resolve()):Promise.reject(Error("Channel type missing"))};h.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};
h.Tc=function(a){var b=new kg;5>b.minFrameRate&&(b.minFrameRate=5);"hangouts"!=this.oc(a)&&(b.senderSideLetterboxing=!0);lg(b);Object.freeze(b);this.j.info("Settings for "+a+": "+jg(b));if(!b.shouldCaptureAudio&&!b.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture.");return b};h.oc=function(a){var b=null;a=Lw(this,a);switch(Ow(a)){case "cloud":b="webrtc";break;case "mesi":b=a.Fb?"meetings":"hangouts"}return b};
h.xd=function(a,b){w(this.j,"Checking canRoute: "+a+" for sinkId: "+b);return Iw(this,a)&&!!this.Kd(b)};h.Kc=function(a,b){return("https://hangouts.google.com/cloudmrp-mirroring"==a||If(a))&&this.b.has(b)};h.joinRoute=function(a,b){return(a=this.b.get(b))?(this.j.info("joining route: "+a.id),hf(a)):jf(Error("not supported"))};h.connectRouteByRouteId=function(){return jf(Error("not supported"))};h.detachRoute=function(){};
var Fs=function(a,b){a.j.info(b.length+" sinks added");0<b.length&&!a.g&&(Ju(a.l),a.g=!0);b=Lw(a,b[0].id);Nl().b=new Kl(b.model,null);a.a.Jb();a.a.onSinkAvailabilityUpdated(a,2);a.j.info("sinkAvailability changed to AVAILABLE")},Ls=function(a,b){a.j.info(b.length+" sinks removed");a.s.some(function(a){return 0<a.cd().length})||(a.a.onSinkAvailabilityUpdated(a,0),a.j.info("sinkAvailability changed to UNAVAILABLE"));a.a.Jb()},Gs=function(a,b){a.j.info(b.length+" sinks updated");a.a.Jb()},xu=function(a,
b,c,d){(void 0===d?0:d)?a.a.gc(a,c,b):a.a.Ie(a,c,b)},Lw=function(a,b){var c=Qw(a,b);c||(c=null,(b=a.A.get(b))&&(c=a.w.get(b.id)));return c},Qw=function(a,b){var c=null;a.s.some(function(a){c=a.uc(b);return!!c});return c},Ow=function(a){return Ub(a.a,"cloud")?"cloud":Ub(a.a,"mesi")?"mesi":null},Jw=function(){var a=Nl().g;return 3E5<=Date.now()-a},Iw=function(a,b){var c=Hf(b);b=If(b);if(a.v.f&&!a.v.b&&c)return a.a.onSinkAvailabilityUpdated(a,2),!0;var d=!1;a.f&&a.v.b&&(d=!0);var e;if(e=!chrome.declarativeWebRequest)a=
a.v,e=!(a.f||a.b&&a.a&&(-1!=pt.indexOf(a.a)||-1!=pt.indexOf(nt(a))))&&b;return e?!1:d&&(c||b)};Gw.prototype.searchSinks=function(a,b){var c=this;if(!Iw(this,a))return Promise.reject(Error("err"));a=Vs(this.h,b);a.then(function(a){Fs(c,[a])});return a};var Rw=function(a,b){b=a.b.get(b);if(!b)return Promise.reject(Error("Route not found"));a=a.oc(b.sinkId);return"hangouts"!=a&&"meetings"!=a?Promise.reject(Error("Unsupported sink channel type")):Cr(Nf.get("mr.ProviderManager")||null,a)};h=Gw.prototype;
h.createMediaRouteController=function(a,b,c){return Rw(this,a).then(function(d){return d.createMediaRouteController(a,b,c)})};h.provideSinks=function(){};h.ha=function(){return"CloudProvider"};h.xa=function(){return[void 0,{cloudEnabled:this.f,cloudOn:this.g,notifiedHangoutsPrivacy:this.m}]};h.Da=function(){var a=Hg(this);a&&(a.cloudEnabled&&(this.f=a.cloudEnabled),a.cloudOn&&(this.g=a.cloudOn),a.notifiedHangoutsPrivacy&&(this.m=a.notifiedHangoutsPrivacy))};var Pw=function(a,b){a=new Ur(a,b);return kf(a.start())};
Gw.prototype.j=Pa("mr.CloudProvider");var Kw=new am("pseudo:cloud","","meeting","","default");var Sw=function(){jk.call(this,12,"ExternalMessageListener","mr.ProviderManager",chrome.runtime.onMessageExternal)};qa(Sw,jk);Sw.prototype.Xe=function(a,b){return b.id&&-1!=Tw.indexOf(b.id)?"start"==a.type||"stop"==a.type||"subscribe_log_data"==a.type:!1};Sw.prototype.qf=function(){return!0};var Vw=function(){Uw||(Uw=new Sw);return Uw},Uw=null,Tw=["idmofbkcelhplfjnmmdolenpigiiiecc","ggedfkijiiammpnbdadhllnehapomdge","njjegkblellcjnakomndbaloifhcoccg"];var Ww=function(){jk.call(this,11,"InternalMessageListener","mr.ProviderManager",chrome.runtime.onMessage)};qa(Ww,jk);Ww.prototype.Xe=function(a,b){return"retrieve_log_data"==a.type&&b.id==chrome.runtime.id&&b.url=="chrome-extension://"+b.id+"/feedback.html"};Ww.prototype.qf=function(){return!0};var Yw=function(){Xw||(Xw=new Ww);return Xw},Xw=null;function Zw(){var a=$w,b=new Zq(a),c=new zn(a,b);b=[b,c];b.push(new Gw(a));return b};var ax=function(a,b){this.routeId=a;this.message=b},bx=function(a){return"string"!=typeof a.message};var cx=function(a){this.s=a;this.g=this.l=null},dx=function(a){if(null==a.g)if(null==a.l||Date.now()-a.l>=a.s)a.h();else{var b=Math.max(a.l+a.s-Date.now(),5);a.g=setTimeout(a.h.bind(a),b)}};cx.prototype.h=function(){null!=this.g&&(clearTimeout(this.g),this.g=null);this.v();this.l=Date.now()};cx.prototype.v=function(){};var ex=function(a,b){cx.call(this,20);this.a=new Map;this.b=new Set;this.u=null;this.m=this.f=0;this.w=!1;this.B=a;this.A=b;this.j=Pa("mr.RouteMessageSender")};qa(ex,cx);ex.prototype.init=function(a){this.u=a;Jg(this)};ex.prototype.stopListeningForRouteMessages=function(a){this.b.delete(a)};
ex.prototype.send=function(a,b){var c=this.a.get(a);c||(c=[],this.a.set(a,c));b=new ax(a,b);c.push(b);50<c.length&&1==c.length%50&&v(this.j,function(){return"Message queue length is excessively large "+("("+c.length+") for route "+a)});this.f+=bx(b)?0:b.message.length;bx(b)&&this.m++;fx(this);this.b.has(a)&&dx(this)};
var gx=function(a,b){if(0!=b.length){b=ja(b);for(var c=b.next();!c.done;c=b.next())c=c.value,a.f-=bx(c)?0:c.message.length,bx(c)&&a.m--}},fx=function(a){var b=0<a.m||a.f>a.A;b!=a.w&&(a.w=b,a.B.jd(a.ha(),b))};ex.prototype.v=function(){if(this.u){for(var a=ja(this.b),b=a.next();!b.done;b=a.next()){b=b.value;var c=this.a.get(b);c&&0!=c.length&&(this.u(b,c),gx(this,c),this.a.set(b,[]))}fx(this)}else this.j.error("sendMessagesCallback not set. Messages not delivered.")};ex.prototype.ha=function(){return"mr.RouteMessageSender"};
ex.prototype.xa=function(){var a=[].concat(k(this.a.entries())).map(function(a){return[a[0],a[1].map(function(a){return a.message})]});return[new hx(a,Array.from(this.b),this.f)]};ex.prototype.Da=function(){var a=Gg(this);if(a){this.a=new Map;for(var b={},c=ja(a.b),d=c.next();!d.done;b={routeId:b.routeId},d=c.next())d=d.value,b.routeId=d[0],d=d[1].map(function(a){return function(b){return new ax(a.routeId,b)}}(b)),this.a.set(b.routeId,d);this.b=new Set(a.a);this.f=a.f}};
var hx=function(a,b,c){this.b=a;this.a=b;this.f=c};var ix=function(a,b,c){this.m=null!=c?a.bind(c):a;this.h=b;this.l=this.u.bind(this);this.g=[];this.a=!1;this.b=null};ix.prototype.f=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];this.g=[].concat(k(b));null==this.b?jx(this):this.a=!0};var jx=function(a){a.b=setTimeout(a.l,a.h);a.m.apply(a,[].concat(k(a.g)))};ix.prototype.u=function(){this.b=null;this.a&&(this.a=!1,jx(this))};var kx=function(a,b){this.type="internal_message";this.routeId=a;this.message=b};var lx=function(a,b,c){this.a=a;this.g=b;this.f=c;this.onMessage=function(){};c.listen("internal_message",this.b,this)};lx.prototype.sendMessage=function(a,b){return this.g(this.a,a,b)};lx.prototype.b=function(a){if(a.routeId==this.a)this.onMessage(a.message)};lx.prototype.wa=function(){this.onMessage=function(){};this.f.v("internal_message",this.b,this)};
var mx=new lx("",function(){return Promise.resolve()},new ml),nx=function(a){this.a=a},Qr=function(a){var b=$e,c=b.a.uf(a);return c?new lx(a,c.sendRouteMessage.bind(c),b.a.wf()):mx};var ox=function(){this.j=Pa("mr.ProviderManager");this.b=[];this.a=new Map;this.m=new Map;this.g=new Set;this.l=new Set;this.s=new Map;this.f=this.v=null;this.F=new ml;this.H=new ix(this.pm,500,this);this.R=new ix(this.X,500,this);this.h=new ex(this,524288);this.I=0;this.u=new Map;this.B=-1==window.navigator.userAgent.indexOf("Windows");this.A=[];this.w=[];var a=new zr(this);this.M=a.onMessage.bind(a);a=new pr(this);this.K=a.onMessage.bind(a);this.onBeforeInvokeHandler=this.onBeforeInvokeHandler;
this.createRoute=this.createRoute;this.joinRoute=this.joinRoute;this.connectRouteByRouteId=this.connectRouteByRouteId;this.terminateRoute=this.terminateRoute;this.startObservingMediaSinks=this.startObservingMediaSinks;this.stopObservingMediaSinks=this.stopObservingMediaSinks;this.sendRouteMessage=this.sendRouteMessage;this.sendRouteBinaryMessage=this.sendRouteBinaryMessage;this.startListeningForRouteMessages=this.startListeningForRouteMessages;this.stopListeningForRouteMessages=this.stopListeningForRouteMessages;
this.startObservingMediaRoutes=this.startObservingMediaRoutes;this.stopObservingMediaRoutes=this.stopObservingMediaRoutes;this.detachRoute=this.detachRoute;this.enableMdnsDiscovery=this.enableMdnsDiscovery;this.searchSinks=this.searchSinks;this.provideSinks=this.provideSinks;this.updateMediaSinks=this.updateMediaSinks;this.createMediaRouteController=this.createMediaRouteController};qa(ox,Mf);
ox.prototype.handleEvent=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];if(a==chrome.runtime.onMessage)this.M.apply(this,[].concat(k(c)));else if(a==chrome.runtime.onMessageExternal)this.K.apply(this,[].concat(k(c)));else throw Error("Unhandled event");};
var Cr=function(a,b){b=a.s.get(b);return Qf(b).then(function(b){b.Ga(a);return b})},qx=function(a,b,c){b.forEach(function(b){if(px(a,b.getName()))v(a.j,"Provider "+b.getName()+" already registered.");else try{b.Ga(c),a.b.push(b),a.u.set(b.getName(),0)}catch(e){v(a.j,"Provider "+b.getName()+" failed to initialize.",e)}})};
ox.prototype.Ga=function(a,b,c){this.s.set("webrtc","mr.mirror.webrtc.WebRtcService");this.s.set("cast_streaming","mr.mirror.cast.Service");this.s.set("hangouts","mr.mirror.hangouts.HangoutsService");this.s.set("meetings","mr.mirror.hangouts.MeetingsService");var d=new nx(this);$e||($e=d);this.f=a;this.h.init(this.f.onRouteMessagesReceived.bind(this.f));qx(this,b,c);Jg(this);Wf("mr.ProviderManager",this)};
var sx=function(a,b,c){return new Promise(function(d,e){var f=null;a.I++;rx(a);f=window.setTimeout(function(){f=null;b.cancel(new Cl(2,"timeout after "+c+" ms."))},c);b.a.then(function(b){a.I--;rx(a);null!=f&&window.clearTimeout(f);d(b)},function(b){a.I--;rx(a);null!=f&&window.clearTimeout(f);e(b instanceof Cl?b:b instanceof Error?new Cl(0,b.message,b.stack):new Cl(0))})})};ox.prototype.onBeforeInvokeHandler=function(){Ef(0)};
var tx=function(a){return"string"==typeof a?a:a.unique?"":a.scheme+"://"+a.host+"\n       "+(a.port?":"+a.port:"")+"/"};h=ox.prototype;
h.createRoute=function(a,b,c,d,e,f,g){var l=this;g=void 0===g?!1:g;var r=ux(this,a,b);if(!r)return Promise.reject(new Cl(7,"No provider supports createRoute with source: "+a+" and sink: "+b));var u=void 0;void 0!==d&&(u=tx(d));f=f&&0<f?f:6E4;a=r.createRoute(a,b,c,g,f,u,e);return sx(this,a,f).then(function(a){return a},function(a){l.j.error("Error creating route.",a);throw a;})};
h.connectRouteByRouteId=function(a,b,c,d,e,f){var g=this.a.get(b);if(!g)return Promise.reject(new Cl(7,"No provider supports join "+b));a=g.connectRouteByRouteId(a,b,c,tx(d),e);return sx(this,a,f&&0<f?f:3E4)};h.joinRoute=function(a,b,c,d,e,f){f=void 0===f?!1:f;var g=vx(this,a,b);if(!g)return Promise.reject(new Cl(7,"No provider supports join "+b));e=e&&0<e?e:3E4;a=g.joinRoute(a,b,f,e,tx(c),d);return sx(this,a,e)};
h.terminateRoute=function(a){var b=this.a.get(a);return b?wx(this,a).then(function(){return b.terminateRoute(a)}):Promise.reject(new Cl(3,"Route not found for routeId "+a))};h.startObservingMediaSinks=function(a){this.g.has(a)||(this.g.add(a),this.b.forEach(function(b){b.startObservingMediaSinks(a)}));xx(this,a)};h.stopObservingMediaSinks=function(a){this.g.delete(a)?yx(this,a):this.j.info("No existing query "+a)};
var yx=function(a,b){a.b.forEach(function(a){a.stopObservingMediaSinks(b)})},xx=function(a,b){if("urn:x-org.chromium.media:source:tab:-1"==b)v(a.j,"No sinks for sourceUrn: "+b);else{var c=new Map,d=[];a.b.forEach(function(e){var f=e.Cd(b);0<f.sinks.length&&(d=f.origins);f.sinks.forEach(function(b){c.has(b.id)?v(a.j,"Detected duplicate sink "+b.id+" from provider: "+e.getName()):c.set(b.id,b)})});zx(a,b,Array.from(c.values()),d||[])}},zx=function(a,b,c,d){a.j.info("Sending "+c.length+" sinks to MR for "+
b);a.f.onSinksReceived(b,c,d.map(Uo))};h=ox.prototype;h.sendRouteMessage=function(a,b,c){var d=this.a.get(a);d?(a=d.sendRouteMessage(a,b,c),a=sx(this,kf(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};h.sendRouteBinaryMessage=function(a,b){var c=this.a.get(a);c?(a=c.sendRouteBinaryMessage(a,b),a=sx(this,kf(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};
h.startListeningForRouteMessages=function(a){var b=this.h;b.b.has(a)||(b.b.add(a),(a=b.a.get(a))&&0<a.length&&dx(b))};h.stopListeningForRouteMessages=function(a){this.h.stopListeningForRouteMessages(a)};h.detachRoute=function(a){var b=this.a.get(a);b?b.detachRoute(a):this.j.info("Route "+a+" does not exist.")};h.enableMdnsDiscovery=function(){this.B=!0;this.A.forEach(function(a){a()});this.A.length=0};
var ux=function(a,b,c){return a.b.find(function(a){return a.xd(b,c)})||null},vx=function(a,b,c){return a.b.find(function(a){return a.Kc(b,c)})||null};ox.prototype.X=function(){var a=this;this.g.forEach(function(b){xx(a,b)})};var rx=function(a){a.f.setKeepAlive(0<a.I||0<a.w.length)};h=ox.prototype;h.startObservingMediaRoutes=function(a){this.l.has(a)||(this.l.add(a),this.b.forEach(function(b){b.startObservingMediaRoutes(a)}));this.H.f()};
h.stopObservingMediaRoutes=function(a){this.l.delete(a)?this.b.forEach(function(b){b.stopObservingMediaRoutes(a)}):this.j.info("No existing route query "+a)};h.pm=function(){var a=this;if(0!=this.l.size){var b=[];this.b.forEach(function(a){b=b.concat(a.rc())});this.l.forEach(function(c){var d=[];a.b.forEach(function(a){a.rc().forEach(function(b){!b.Oc&&a.Kc(c,void 0,b)&&d.push(b.id)})});a.f.onRoutesUpdated(b,c,d)})}};h.ha=function(){return"ProviderManager"};
h.xa=function(){return[new Ax(this.b.map(function(a){return a.getName()}),Array.from(this.g),Array.from(this.l),Array.from(this.a,function(a){var b=ja(a);a=b.next().value;b=b.next().value;return[a,b.getName()]}),Array.from(this.u),this.B,this.v)]};h.Da=function(){var a=Gg(this);if(a){this.g=new Set(a.h);this.l=new Set(a.g);for(var b=ja(a.f),c=b.next();!c.done;c=b.next()){var d=ja(c.value);c=d.next().value;d=d.next().value;d=px(this,d);this.a.set(c,d)}this.u=new Map(a.l);this.v=a.a||null;a.b&&this.enableMdnsDiscovery()}};
h.uf=function(a){return this.a.get(a)};h.dd=function(a,b){this.a.set(b.id,a);this.hc(a,b)};h.Md=function(a,b){wx(this,b.id);this.a.delete(b.id);var c=this.h,d=b.id;c.b.delete(d);var e=c.a.get(d);e&&(c.a.delete(d),gx(c,e),fx(c));this.hc(a,b)};h.hc=function(){0<this.l.size&&this.H.f()};h.Hf=function(a){var b=this.a.get(a.id);b&&this.hc(b,a)};
h.gc=function(a,b,c){this.a.has(b)?("string"===typeof c||c instanceof Uint8Array||(c=JSON.stringify(c)),this.h.send(b,c)):v(this.j,"Got route message for closed route "+b)};h.onPresentationConnectionStateChanged=function(a,b){"terminated"==b&&this.h.h();this.f.onPresentationConnectionStateChanged(a,b)};h.onPresentationConnectionClosed=function(a,b,c){this.h.h();this.f.onPresentationConnectionClosed(a,b,c)};h.If=function(a){this.m.delete(a);var b=this.a.get(a);b&&b.terminateRoute(a)};
h.Ie=function(a,b,c){this.F.dispatchEvent(new kx(b,c))};h.Jb=function(){this.R.f()};h.onSinkAvailabilityUpdated=function(a,b){var c=this;if(this.u.get(a.getName())!=b){var d=Bx(this);this.u.set(a.getName(),b);a=Bx(this);d!=a&&(0==a&&this.X(),this.f.onSinkAvailabilityUpdated(a),0==a&&(this.g.forEach(function(a){yx(c,a)}),this.g.clear()))}};var Bx=function(a){return Array.from(a.u.values()).reduce(function(a,c){return Math.max(a,c)},0)};ox.prototype.wf=function(){return this.F};ox.prototype.tc=function(a){this.f.onIssue(a)};
var wx=function(a,b){return a.m.has(b)?Cr(a,a.m.get(b)).then(function(c){a.m.delete(b);return Zf(c)}):Promise.resolve(!1)};h=ox.prototype;h.Ef=function(a,b,c,d){var e=this,f=a.oc(b.sinkId);this.j.info("Starting mirroring using service: "+f);this.m.set(b.id,f);return lf(Cr(this,f),function(g){e.v=f;return gf(bg(g,b,b.mediaSource,a.Tc(b.sinkId),c,d),function(a){if(a instanceof vf&&3==a.reason)throw new Cl(8);throw a;})})};
h.Eh=function(a,b,c,d,e,f){var g=this,l=this.m.get(b.id);return l?lf(Cr(this,l),function(r){g.v=l;var u=a.Tc(b.sinkId);r.G.info("Update mirroring on route "+b.id);return r.g?kf(Yf(c,e).then(r.I.bind(r,b,c,u,d,f))):jf(Error("Not initialized"))}):jf(Error("Route "+b.id+" is not mirroring"))};h.Xf=function(a){this.B?a():-1==this.A.indexOf(a)&&this.A.push(a)};h.Cf=function(){return this.B};h.jd=function(a,b){var c=this.w.indexOf(a),d=0<=c;b&&!d?this.w.push(a):!b&&d&&this.w.splice(c,1);rx(this)};
var px=function(a,b){return a.b.find(function(a){return a.getName()==b})||null};h=ox.prototype;h.searchSinks=function(a,b,c){var d=a.startsWith("pseudo:")?a.substring(7):null;return(d=d?px(this,d):null)?d.searchSinks(b,c).then(function(a){return a.id}):Promise.reject(Error("No provider supports "+a))};h.provideSinks=function(a,b){var c=px(this,a);c?c.provideSinks(b):this.j.error("provideSinks: Provider not found for providerName "+a)};h.updateMediaSinks=function(a){this.g.has(a)||xx(this,a)};
h.createMediaRouteController=function(a,b,c){var d=this,e=this.a.get(a);return e?e.createMediaRouteController(a,b,c).catch(function(a){d.j.error("createMediaRouteController failed: "+a.message);b.close();c.ptr.reset();throw a;}):(a="createMediaRouteController: Provider not found for "+a,this.j.error(a),b.close(),c.ptr.reset(),Promise.reject(Error(a)))};h.onMediaRemoterCreated=function(a,b,c){this.f.onMediaRemoterCreated(a,b,c)};
var Ax=function(a,b,c,d,e,f,g){this.h=b;this.g=c;this.f=d;this.l=e;this.b=f;this.a=g};
