'use strict';var Kf;var Lf=chrome.i18n.getMessage("545449835455981095");r("mr.IssueSeverity",{ks:"fatal",nw:"warning",du:"notification"});r("mr.IssueAction",{Wr:"dismiss",qt:"learn_more"});var Mf=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},Of=function(){var a=new Mf(Nf,"notification");a.helpPageId=6320939;a.defaultAction="learn_more";a.secondaryActions=["dismiss"];return a};var Pf=function(a,b){var c=this;this.f=void 0===b?null:b;this.b=new Promise(function(b,e){var d=function(a){c.f=null;e(a)};c.h=d;a(function(a){c.f=null;b(a)},d)})};Pf.prototype.cancel=function(a){this.h(a);if(this.f){var b=this.f;this.f=null;setTimeout(function(){return b(a)},0)}};var Qf=function(a,b,c){c=void 0===c?null:c;return new Pf(function(d,e){a.b.then(function(a){if(b)try{d(b(a))}catch(h){e(h)}else d(a)},function(a){if(c)try{d(c(a))}catch(h){e(h)}else e(a)})},function(b){a.cancel(b)})};
Pf.prototype.then=function(a,b){return Qf(this,a,void 0===b?null:b)};Pf.prototype.catch=function(a){return Qf(this,null,a)};var Rf=function(a){return new Pf(function(b){b(a)})},Sf=function(a){return new Pf(function(b,c){c(a)})},Tf=function(a){return new Pf(function(b,c){a.then(b,c)})},Uf=function(a,b){var c=!1,d=null;return new Pf(function(e,f){a.then(function(a){c||(d=b(a),d.b.then(e,f))},f)},function(a){d?d.cancel(a):c=!0})};var Vf={ir:0,gr:1,kr:2,hr:3,Jq:4,jr:5,Ls:6,Rv:7,Qr:8,qj:9},Wf=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};l(Wf,Error);var Xf=function(){var a=ma(navigator.userAgent.match(/Windows NT (\d+.\d+)/)||[]);a.next();a=a.next().value;return 6.2<=parseFloat(a)},Yf=function(){var a=navigator.userAgent;return a.includes("CrOS")?"ChromeOS":a.includes("Windows")?"Windows":a.includes("Macintosh")?"Mac":a.includes("Linux")?"Linux":"Other"};var Zf=!("undefined"==typeof chrome||!chrome.networkingPrivate||!chrome.networkingPrivate.setWifiTDLSEnabledState||"ChromeOS"!=Yf()),$f=["ChromeOS","Windows"].includes(Yf());var ag=function(a,b,c,d){this.f=a;this.b=b;this.h=c||null;this.presentationId=d||null},dg=function(a,b){if("tab"==a.f)a=bg(a);else if("offscreen_tab"==a.f)b=bg(a),b.presentationId=a.presentationId,a=b;else{var c={audio:!1,video:!1};a.b.shouldCaptureVideo?(c.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:b}},cg(a,c.video.mandatory),$f&&a.b.shouldCaptureAudio&&(c.audio={mandatory:{chromeMediaSource:"system",chromeMediaSourceId:b}})):a.b.shouldCaptureAudio&&(c.audio={mandatory:{chromeMediaSource:"system"}});
a=c}return a},bg=function(a){var b={audio:a.b.shouldCaptureAudio,video:a.b.shouldCaptureVideo};a.b.shouldCaptureVideo&&(b.videoConstraints={mandatory:{enableAutoThrottling:!0}},cg(a,b.videoConstraints.mandatory));return b},cg=function(a,b){var c=a.b.minWidth,d=a.b.minHeight;if(a.b.senderSideLetterboxing){c=a.b;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.b.maxWidth,maxHeight:a.b.maxHeight,minFrameRate:a.b.minFrameRate,maxFrameRate:a.b.maxFrameRate})};var eg=function(a){this.b=a;this.f=this.Qe=null;this.l=tb("mr.mirror.MirrorMediaStream")};eg.prototype.start=function(){return"tab"==this.b.f?fg(this):"offscreen_tab"==this.b.f?gg(this):hg(this)};var fg=function(a){var b=dg(a.b);a.l.info("Starting tab capture with constraints "+JSON.stringify(b));return new Promise(function(c,d){chrome.tabCapture.capture(b,function(b){b?(ig(a,b),c(a)):d(jg())});window.setTimeout(function(){d(new Wf("chrome.tabCapture.capture failed to call its callback",2))},5E3)})};
eg.prototype.h=function(a){a&&this.l.info(function(){return"Track "+JSON.stringify(a.target)+" ended"});this.stop()};
var jg=function(){return chrome.runtime.lastError&&chrome.runtime.lastError.message?new Wf(chrome.runtime.lastError.message,7):new Wf("empty_stream",0)},kg=function(){var a=void 0===a?6E4:a;return new Promise(function(b,c){var d=["screen","audio"];"Linux"==Yf()&&d.push("window");var e=window.setTimeout(function(){f&&chrome.desktopCapture.cancelChooseDesktopMedia(f);c(new Wf("timeout",1))},a);var f=chrome.desktopCapture.chooseDesktopMedia(d,function(a){window.clearTimeout(e);a?b(a):c(new Wf("User cancelled capture dialog",
3))})})},lg=function(a,b){return new Promise(function(c,d){a.l.info(function(){return"Starting desktop capture with constraints "+JSON.stringify(b)});navigator.mediaDevices.getUserMedia(b).then(function(b){b||d(new Wf("empty_stream",8));ig(a,b);c(b)},function(a){var b=8;"NotAllowedError"==a.name&&(b=3);d(new Wf(a.name+" "+a.constraintName+": "+a.message,b))})})},hg=function(a){return $f&&a.b.b.shouldCaptureAudio&&!a.b.b.shouldCaptureVideo?lg(a,dg(a.b)).then(function(){return a}):kg().then(function(b){b=
dg(a.b,b);return lg(a,b).then(function(){return a})})},gg=function(a){var b=dg(a.b);a.l.info(function(){return"Starting offscreen tab capture with constraints "+JSON.stringify(b)});return new Promise(function(c,d){chrome.tabCapture.captureOffscreenTab(a.b.h.toString(),b,function(b){b?(ig(a,b),c(a)):d(jg())})})},ig=function(a,b){a.f=b;b.getAudioTracks().length||b.getVideoTracks();b.getTracks().forEach(function(b){b.onended=a.h.bind(a)})};
eg.prototype.stop=function(){this.f&&(this.f.getTracks().forEach(function(a){a.onended=null;a.stop()}),this.f=null,this.Qe&&this.Qe())};var mg=function(){},rg=function(a){var b=og.get(a)||null;if(b)return Promise.resolve(b);b=pg.get(a);b||(b=new Tb,pg.set(a,b),qg(a,b));return b.b},qg=function(a,b){var c=sg.get(a)||null;if(!c)b.reject(Error("No corresponding bundle for "+a));else if(!tg.has(c)){var d=ug.get(c);d||(vg.info("Loading bundle "+c+" for module "+a),d=wg(c),ug.set(c,d));d.catch(function(a){b.reject(a)})}},wg=function(a){var b=new Tb;b.b.then(function(){vg.info("Bundle "+a+" loaded")},function(b){vg.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.b},xg=function(a,b){if(og.has(a))throw Error("Duplicate module "+a);og.set(a,b);(a=pg.get(a))&&a.resolve(b)};
mg.prototype.handleEvent=function(a,b){for(var c=1;c<arguments.length;++c);throw Error("Not implemented");};
var sg=new Map([["mr.cast.ChannelService","background_script.js"],["mr.cast.SinkDiscoveryService","background_script.js"],["mr.mirror.cast.Service","mirroring_cast_streaming.js"],["mr.cloud.slarti.SinkDiscoveryService","background_script.js"],["mr.cloud.discovery.WeaveSinkDiscoveryService","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"]]),tg=new Set(["background_script.js"]),vg=tb("mr.Module"),og=new Map,pg=new Map,ug=new Map;var yg,zg={yt:0,lr:1,mr:2,Sr:3,Tr:4,ss:5,Ms:6,wt:7,Vt:8,Wt:9,Su:10,sv:11,tv:12,Dv:13,Qv:14},Ag=function(a){void 0==yg&&(Rb("MediaRouter.Provider.WakeEvent",a,zg),yg=a)};var Dg=function(a){return Bg(a)||Cg(a)},Eg=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__")},Fg=["https://docs.google.com"],Bg=function(a){return a.startsWith("urn:x-org.chromium.media:source:tab:")||-1!=a.indexOf("0F5096E8")},Cg=function(a){return"urn:x-org.chromium.media:source:desktop"==a},Gg=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 Hg=function(a,b){this.D=a;this.j=b||null;this.f=this.b=null;this.J=tb("mr.mirror.Service."+a);this.A=this.L.bind(this);this.g=!1};l(Hg,mg);Hg.prototype.Xa=function(a){this.g||(this.j=a,this.g=!0,this.zg())};Hg.prototype.zg=function(){};Hg.prototype.getName=function(){return this.D};
var Lg=function(a,b,c,d,e,f){a.J.info("Start mirroring on route "+b.id);if(!a.g)return Sf(Error("Not initialized"));var h=new Promise(function(h,n){Ig(a).then(function(){var a=Jg(c,d,e);return(new eg(a)).start()}).then(function(c){if(a.f)throw c.stop(),new Wf("Cannot start multiple streams");a.f=c;c=a.s.bind(a);a.f.Qe=c;return f?f(b).b:b}).then(function(b){if(a.b)throw new Wf("Cannot start multiple sessions");if(!a.f)throw new Wf("Media stream ended before session could start.");a.b=a.tg(d,b);b.wb.Wb=
a.b.Wb;b=a.j.hk.bind(a.j);a.b.ka=b;return a.b.start(a.f.f)}).then(function(){Bg(c)&&!chrome.tabs.onUpdated.hasListener(a.A)&&chrome.tabs.onUpdated.addListener(a.A);return a.F(b,c,d)}).then(function(){h(b)}).catch(function(b){Kg(a,b);return a.s().then(function(){n(b)})})});return Tf(h)},Mg=function(a,b,c,d,e,f){if(!a.b)return Promise.reject(new Wf("No session to update streams on",7));if(!a.b.tl())return Promise.reject(new Wf("Session does not support updating stream",7));var h=!1;return new Promise(function(k,
n){var u=Jg(c,d,e);(new eg(u)).start().then(function(c){a.f&&(a.f.Qe=null,a.f.stop(),a.Qf());a.f=c;c=a.s.bind(a);a.f.Qe=c;h=!0;return f?f(b).b:b}).then(function(){if(!a.b)throw new Wf("Session ended while updating stream");if(!a.f)throw new Wf("Media stream ended before session could be updated.");return a.b.xl(a.f.f)}).then(a.F.bind(a,b,c,d)).then(function(){return k(b)}).catch(function(b){Kg(a,b);if(h)return a.s().then(function(){n(b)});n(b)})})};
Hg.prototype.F=function(a,b,c){var d=this;return new Promise(function(e,f){d.b?(Bg(b)?(Ng(d.b,a.wb.tabId),d.eh()):Eg(b)?(Ng(d.b,a.wb.tabId),d.ui()):d.ah(),f=d.f,c.shouldCaptureAudio&&f.f&&!f.f.getAudioTracks().length&&d.j.wd(new Mf(Lf,"notification")),Og(d.b),e()):f(new Wf("Session gone before executing post-startup steps",7))})};
var Kg=function(a,b){b.reason=null!=b.reason?b.reason:9;a.J.error("Failed to start mirroring: "+b.message+(",  reason = "+b.reason+": "+b.stack));a.dh(b.reason)},Ig=function(a){return a.g?a.s().then(function(b){b&&a.bh();return b}):Promise.reject("Not initialized")};
Hg.prototype.s=function(){var a=this;chrome.tabs.onUpdated.removeListener(this.A);var b=this.f;this.f=null;b&&(b.Qe=null);var c=this.b;this.b=null;var d;c?d=this.rh(c).catch(function(b){return a.J.error("Error in before-cleanup steps",b)}).then(function(){return c.stop()}).catch(function(b){return a.J.error("Error stopping session",b)}).then(function(){a.j.fi(c.h.id)}).catch(function(b){return a.J.error("Error in ended callbacks",b)}).then(function(){return!0}):d=Promise.resolve(!1);b&&(d=d.then(function(c){b.stop();
a.Qf();return c}));return d};Hg.prototype.rh=function(){return Promise.resolve()};Hg.prototype.L=function(a,b,c){Ag(14);if(this.b){var d=this.b;a==d.tabId&&("complete"==b.status||b.favIconUrl&&"complete"==c.status)&&(d.u=c,Og(d))}};var Jg=function(a,b,c){if(Bg(a))return new ag("tab",b);if(Cg(a))return new ag("desktop",b);if(Eg(a)){if(!c)throw new Wf("Missing offscreen tab presentation id");return new ag("offscreen_tab",b,a,c)}throw new Wf("Source URN does not suggest a known capture type.");};g=Hg.prototype;
g.tg=function(){};g.eh=function(){};g.ah=function(){};g.ui=function(){};g.bh=function(){};g.dh=function(){};g.Qf=function(){};g.di=function(){return qb()};g.createMediaRouteController=function(){return qb()};var Pg=function(a,b,c){this.f=a;this.g=b;this.b=void 0===c?null:c;this.h=null},Qg=function(a){switch(a.f){case "mirror_tab":return a.b?"Casting tab ("+a.b+")":"Casting tab";case "mirror_desktop":return"Casting desktop";case "mirror_file":return"Casting local content";case "media_remoting":return a.b?"Casting media ("+a.b+")":"Casting media";case "presentation":return"Casting "+(a.b||"site");default:return""}},Rg=function(a){if(a.g)return"Casting active";switch(a.f){case "mirror_tab":return"Casting tab";
case "mirror_desktop":return"Casting desktop";case "mirror_file":return"Casting local content";case "media_remoting":return"Casting media";case "presentation":return"Casting site";default:return""}};var Sg=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 Tg=function(a,b){this.h=a;this.ka=void 0===b?null:b;b=null;var c=a.mediaSource;if(Eg(c)){var d="presentation";b=(new URL(c)).origin}else Bg(c)?d="mirror_tab":Cg(c)&&(d="mirror_desktop");this.Wb=new Pg(d,a.offTheRecord,b);this.u=this.tabId=null;this.L=!1},Ng=function(a,b){a.tabId!=b?(a.tabId=b,Sg(b).then(function(b){a.u=b;Og(a)})):Promise.resolve()},Og=function(a){if(a.u){a.Wb.h=a.u.title;a.Wb.g=a.u.incognito;var b=new URL(a.u.url);"file:"==b.protocol?(a.Wb.f="mirror_file",a.Wb.b=null):(a.Wb.f=
a.L?"media_remoting":"mirror_tab",a.Wb.b="https:"==b.protocol?b.origin.substr(8):b.origin)}a.h.description=Qg(a.Wb);a.ka&&a.ka(a.h,a.Wb);a.cl()};g=Tg.prototype;g.start=function(){};g.tl=function(){return!1};g.xl=function(){};g.stop=function(){return Promise.resolve()};g.cl=function(){};var Xg=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(Yf())||Xf();this.enableLogging=!0;this.useTdls=!1;this.shouldCaptureAudio=this.shouldCaptureVideo=!0;var b=window.localStorage?
window.localStorage.getItem(Ug):null;if(b)try{var c=JSON.parse(String(b));if(c instanceof Object)Vg(this,c),v(tb("mr.mirror.Settings"),function(){return"Initial mr.mirror.Settings overridden to: "+Wg(a)});else throw Error("localStorage["+Ug+"] "+("does not parse as an Object: "+b));}catch(d){throw tb("mr.mirror.Settings").error(Ug+' must be of the form \'{"maxWidth":640, "maxHeight":360}\'.',d),Error("Overrides not parseable.  See ERROR log for details.");}};
Xg.prototype.clone=function(){var a=new Xg;Vg(a,this);return a};
var Wg=function(a){return JSON.stringify(a,function(a,c){if(0==a.length||!a.endsWith("_"))return c})},Vg=function(a,b){for(var c=ma(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])},Yg=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},Ug="mr.mirror.Settings.Overrides";var Zg=function(a,b){this.type=a;this.data=b},$g=function(a){a=JSON.parse(a);if(!a.type)throw Error("Invalid message");return new Zg(a.type,a.data)},ah=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 dh=function(a,b){this.l=tb("cv2.PeerConnection");this.D=bh;this.b=ch(this,b);this.j=this.b.createDataChannel(a,{reliable:!1});this.C=new Tb;this.o=!1;this.g=0;this.h=null;this.u=this.s=0;this.f=!1;this.F=function(){};this.m=function(){};this.B=function(){};this.A=function(){}},eh=function(a,b){a.m=b},fh=function(a,b){a.B=b},gh=function(a,b){a.A=b},hh=function(a,b){a.F=b},ih=function(a,b){a.j.onmessage=function(a){b(a.data)}},jh=function(a){var b={};b.iceServers=[{url:"stun:stun.l.google.com:19302"}].concat(a);
return b},ch=function(a,b){var c=jh(b);b=new webkitRTCPeerConnection(c);b.onicecandidate=a.ka.bind(a);b.b=a.M.bind(a);b.oniceconnectionstatechange=a.K.bind(a);a.l.info(function(){return"Created webkitRTCPeerConnnection with config: "+JSON.stringify(c)});return b};dh.prototype.start=function(){this.f||(this.f=!0,kh(this))};dh.prototype.stop=function(){this.l.info("Stopping peer connection...");this.f&&(this.f=!1,"closed"!=this.b.signalingState&&this.b.close());this.b=null};
var kh=function(a){a.l.info("Sending offer to peer.");a.s=Date.now();a.b.createOffer(a.L.bind(a),function(b){v(a.l,"Error creating offer.",b)},a.D);a.C.b.then(function(b){a.F(b)})};dh.prototype.L=function(a){var b=this;this.l.info(function(){return"Setting local description: "+JSON.stringify(a)});this.b.setLocalDescription(a,function(){b.l.info("Local description set successfully")},function(a){v(b.l,"Error setting local description.",a)})};
var lh=function(a,b){Ab(a.l,function(){return"<===: "+JSON.stringify(b)});var c=new RTCSessionDescription(b);a.l.info(function(){return"Setting remote description: "+JSON.stringify(c)});a.b.setRemoteDescription(c,function(){a.l.info("Remote description set successfully.")},function(b){v(a.l,"Error setting remote description.",b)})};
dh.prototype.ka=function(a){var b=this;a.candidate?(this.g++,this.u=Date.now(),1==this.g?this.h=setTimeout(function(){b.l.info("ICE candidate gathering timed out.");b.h=null;mh(b)},5E3):this.o&&v(this.l,"Received ICE candidate after resolving session description.")):(this.l.info("End of ICE candidates."),Hb("MediaRouter.WebRtc.IceCandidateGathering.Duration.Reported",Date.now()-this.s),mh(this),0<this.g&&Hb("MediaRouter.WebRtc.IceCandidateGathering.Duration.Real",this.u-this.s))};
dh.prototype.M=function(){"completed"==this.b.iceGatheringState&&mh(this)};var mh=function(a){clearTimeout(a.h);a.h=null;if(!a.o){a.l.info("Resolving sesion description after gathering "+a.g+" ICE candidates.");var b=a.b.localDescription;a.C.resolve({type:b.type,sdp:b.sdp});a.o=!0}};
dh.prototype.K=function(a){var b=this;if(this.b){var c=this.b.iceConnectionState;this.l.info("New ICE connection state: "+c+".");"connected"==c?this.m("iceconnected"):"completed"==c?this.m("icecompleted"):"failed"==c?(v(this.l,function(){return"Ice connection failed: "+JSON.stringify(a)}),this.B("icefailed")):"closed"==c?this.A("iceclosed"):"disconnected"==c&&(v(this.l,"Ice connection state is bad."),this.f&&(this.l.info("Restarting ICE."),this.b.createOffer(this.L.bind(this),function(a){v(b.l,"Error creating new offer.",
a)},nh)))}};var bh={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},nh={mandatory:{IceRestart:!0,OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}};var oh=function(){var a=window.crypto.getRandomValues(new Uint8Array(16));return bc(a,function(a){a=a.toString(16);return 1<a.length?a:"0"+a}).join("")},ph=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},qh=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 h=a[c++],k=a[c++];e=((e&7)<<18|(f&63)<<12|(h&63)<<6|k&63)-65536;b[d++]=String.fromCharCode(55296+(e>>10));b[d++]=String.fromCharCode(56320+(e&1023))}else f=a[c++],h=a[c++],b[d++]=String.fromCharCode((e&15)<<12|(f&63)<<6|h&63)}return b.join("")};var rh=cd("Firefox"),sh=xd()||cd("iPod"),th=cd("iPad"),uh=cd("Android")&&!(wd()||cd("Firefox")||cd("Opera")||cd("Silk")),vh=wd(),wh=cd("Safari")&&!(wd()||cd("Coast")||cd("Opera")||cd("Edge")||cd("Silk")||cd("Android"))&&!yd();var xh=null,yh=null,Ah=function(a){zh();for(var b=xh,c=[],d=0;d<a.length;d+=3){var e=a[d],f=d+1<a.length,h=f?a[d+1]:0,k=d+2<a.length,n=k?a[d+2]:0,u=e>>2;e=(e&3)<<4|h>>4;h=(h&15)<<2|n>>6;n&=63;k||(n=64,f||(h=64));c.push(b[u],b[e],b[h],b[n])}return c.join("")},Ch=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;Bh(a,function(a){d[e++]=a});return d.subarray(0,e)},Bh=function(a,b){function c(b){for(;d<a.length;){var c=a.charAt(d++),e=yh[c];
if(null!=e)return e;if(!Ic(c))throw Error("Unknown base64 encoding at char: "+c);}return b}zh();for(var d=0;;){var e=c(-1),f=c(0),h=c(64),k=c(64);if(64===k&&-1===e)break;b(e<<2|f>>4);64!=h&&(b(f<<4&240|h>>2),64!=k&&b(h<<6&192|k))}},zh=function(){if(!xh){xh={};yh={};for(var a=0;65>a;a++)xh[a]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a),yh[xh[a]]=a,62<=a&&(yh["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(a)]=a)}};var Dh=0,Eh=0,Fh=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)));Dh=c;Eh=a},Gh=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 Ch(a);Xb("Type not convertible to Uint8Array.");return new Uint8Array(0)};var Ih=function(a,b,c){this.h=null;this.o=this.u=this.b=this.g=this.j=0;this.s=!1;a&&Hh(this,a,b,c)},Jh=[],Kh=function(a,b,c){if(Jh.length){var d=Jh.pop();a&&Hh(d,a,b,c);return d}return new Ih(a,b,c)};Ih.prototype.clone=function(){return Kh(this.h,this.j,this.g-this.j)};Ih.prototype.clear=function(){this.h=null;this.b=this.g=this.j=0;this.s=!1};var Hh=function(a,b,c,d){a.h=Gh(b);a.j=Qa(c)?c:0;a.g=Qa(d)?a.j+d:a.h.length;a.b=a.j};Ih.prototype.reset=function(){this.b=this.j};
Ih.prototype.f=function(){var a=this.h;var b=a[this.b+0];var c=b&127;if(128>b)return this.b+=1,c;b=a[this.b+1];c|=(b&127)<<7;if(128>b)return this.b+=2,c;b=a[this.b+2];c|=(b&127)<<14;if(128>b)return this.b+=3,c;b=a[this.b+3];c|=(b&127)<<21;if(128>b)return this.b+=4,c;b=a[this.b+4];c|=(b&15)<<28;if(128>b)return this.b+=5,c>>>0;this.b+=5;128<=a[this.b++]&&128<=a[this.b++]&&128<=a[this.b++]&&128<=a[this.b++]&&this.b++;return c};Ih.prototype.m=Ih.prototype.f;Ih.prototype.A=function(){return this.m()};var Lh=function(a){this.b=Kh(a,void 0,void 0);this.g=this.f=-1;this.j=!1},Mh=function(a){return 4==a.g};Lh.prototype.reset=function(){this.b.reset();this.g=this.f=-1};
var Nh=function(a){var b=a.b;if(b.b==b.g)return!1;(b=a.j)||(b=a.b,b=b.s||0>b.b||b.b>b.g);if(b)return Xb("Decoder hit an error"),!1;var c=a.b.f();b=c>>>3;c&=7;if(0!=c&&5!=c&&1!=c&&2!=c&&3!=c&&4!=c)return Xb("Invalid wire type"),a.j=!0,!1;a.f=b;a.g=c;return!0},Oh=function(a){switch(a.g){case 0:if(0!=a.g)Xb("Invalid wire type for skipVarintField"),Oh(a);else{for(a=a.b;a.h[a.b]&128;)a.b++;a.b++}break;case 1:1!=a.g?(Xb("Invalid wire type for skipFixed64Field"),Oh(a)):(a=a.b,a.b+=8);break;case 2:if(2!=
a.g)Xb("Invalid wire type for skipDelimitedField"),Oh(a);else{var b=a.b.f();a=a.b;a.b+=b}break;case 5:5!=a.g?(Xb("Invalid wire type for skipFixed32Field"),Oh(a)):(a=a.b,a.b+=4);break;case 3:b=[a.f];do{if(!Nh(a)){Xb("Unmatched start-group tag: stream EOF");a.j=!0;break}if(3==a.g)b.push(a.f);else if(4==a.g&&a.f!=b.pop()){Xb("Unmatched end-group tag");a.j=!0;break}}while(0<b.length);break;default:Xb("Invalid wire encoding for field.")}};
Lh.prototype.h=function(a,b){var c=this.b.g,d=this.b.f();d=this.b.b+d;this.b.g=d;b(a,this);this.b.b=d;this.b.g=c};
var Ph=function(a){a=a.b;a:{for(var b,c=0,d,e=0;4>e;e++)if(b=a.h[a.b++],c|=(b&127)<<7*e,128>b){a.u=c>>>0;a.o=0;break a}b=a.h[a.b++];c|=(b&127)<<28;d=0|(b&127)>>4;if(128>b)a.u=c>>>0,a.o=d>>>0;else{for(e=0;5>e;e++)if(b=a.h[a.b++],d|=(b&127)<<7*e+3,128>b){a.u=c>>>0;a.o=d>>>0;break a}Xb("Failed to read varint, encoding is invalid.");a.s=!0}}b=a.u;c=a.o;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},Qh=function(a){var b=a.b.f();a=a.b;var c=a.h,d=a.b,e=d+b,f=[];
for(b="";d<e;){var h=c[d++];if(128>h)f.push(h);else if(192>h)continue;else if(224>h){var k=c[d++];f.push((h&31)<<6|k&63)}else if(240>h){k=c[d++];var n=c[d++];f.push((h&15)<<12|(k&63)<<6|n&63)}else if(248>h){k=c[d++];n=c[d++];var u=c[d++];h=(h&7)<<18|(k&63)<<12|(n&63)<<6|u&63;h-=65536;f.push((h>>10&1023)+55296,(h&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,
vc(f,e,e+8192));f=c}a.b=d;return b+f},Rh=function(a,b){var c=a.b.f();c=a.b.b+c;for(var d=[];a.b.b<c;)d.push(b.call(a.b));return d};var Sh=function(a,b){this.b=a;this.f=b},Th=function(a){return new Sh((a.b>>>1|(a.f&1)<<31)>>>0,a.f>>>1>>>0)},Uh=function(a){return new Sh(a.b<<1>>>0,(a.f<<1|a.b>>>31)>>>0)};Sh.prototype.add=function(a){return new Sh((this.b+a.b&4294967295)>>>0>>>0,((this.f+a.f&4294967295)>>>0)+(4294967296<=this.b+a.b?1:0)>>>0)};Sh.prototype.sub=function(a){return new Sh((this.b-a.b&4294967295)>>>0>>>0,((this.f-a.f&4294967295)>>>0)-(0>this.b-a.b?1:0)>>>0)};
var Vh=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 Sh(a>>>0,b>>>0)};
Sh.prototype.toString=function(){for(var a="",b=this;0!=b.b||0!=b.f;){var c=new Sh(0,0);b=new Sh(b.b,b.f);for(var d=new Sh(10,0),e=new Sh(1,0);!(d.f&2147483648);)d=Uh(d),e=Uh(e);for(;0!=e.b||0!=e.f;)0>=(d.f<b.f||d.f==b.f&&d.b<b.b?-1:d.f==b.f&&d.b==b.b?0:1)&&(c=c.add(e),b=b.sub(d)),d=Th(d),e=Th(e);c=[c,b];b=c[0];a=c[1].b+a}""==a&&(a="0");return a};
var Wh=function(a){for(var b=new Sh(0,0),c=new Sh(0,0),d=0;d<a.length;d++){if("0">a[d]||"9"<a[d])return null;c.b=parseInt(a[d],10);var e=Vh(b.b);b=Vh(b.f);b.f=b.b;b.b=0;b=e.add(b).add(c)}return b};Sh.prototype.clone=function(){return new Sh(this.b,this.f)};var Xh=function(a,b){this.b=a;this.f=b};Xh.prototype.add=function(a){return new Xh((this.b+a.b&4294967295)>>>0>>>0,((this.f+a.f&4294967295)>>>0)+(4294967296<=this.b+a.b?1:0)>>>0)};
Xh.prototype.sub=function(a){return new Xh((this.b-a.b&4294967295)>>>0>>>0,((this.f-a.f&4294967295)>>>0)-(0>this.b-a.b?1:0)>>>0)};Xh.prototype.clone=function(){return new Xh(this.b,this.f)};Xh.prototype.toString=function(){var a=0!=(this.f&2147483648),b=new Sh(this.b,this.f);a&&(b=(new Sh(0,0)).sub(b));return(a?"-":"")+b.toString()};var Yh=function(){this.b=[]};Yh.prototype.length=function(){return this.b.length};var Zh=function(a){var b=a.b;a.b=[];return b},$h=function(a,b,c){for(;0<c||127<b;)a.b.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.b.push(b)},ai=function(a,b){for(;127<b;)a.b.push(b&127|128),b>>>=7;a.b.push(b)},bi=function(a,b){if(0<=b)ai(a,b);else{for(var c=0;9>c;c++)a.b.push(b&127|128),b>>=7;a.b.push(1)}},ci=function(a,b){a.b.push(b>>>0&255);a.b.push(b>>>8&255);a.b.push(b>>>16&255);a.b.push(b>>>24&255)};var y=function(){this.g=[];this.h=0;this.f=new Yh},ei=function(a,b){di(a,b,2);b=Zh(a.f);a.g.push(b);a.h+=b.length;b.push(a.h);return b},fi=function(a,b){var c=b.pop();for(c=a.h+a.f.length()-c;127<c;)b.push(c&127|128),c>>>=7,a.h++;b.push(c);a.h++};y.prototype.reset=function(){this.g=[];Zh(this.f);this.h=0};
var A=function(a){for(var b=new Uint8Array(a.h+a.f.length()),c=a.g,d=c.length,e=0,f=0;f<d;f++){var h=c[f];b.set(h,e);e+=h.length}c=Zh(a.f);b.set(c,e);a.g=[b];return b},di=function(a,b,c){ai(a.f,8*b+c)},C=function(a,b,c){null!=c&&null!=c&&(di(a,b,0),bi(a.f,c))},E=function(a,b,c){null!=c&&null!=c&&(di(a,b,0),a=a.f,Fh(c),$h(a,Dh,Eh))},gi=function(a,b,c){if(null!=c){var d=c;(c=0<d.length&&"-"==d[0])&&(d=d.substring(1));d=Wh(d);null===d?c=null:(c&&(d=(new Sh(0,0)).sub(d)),c=new Xh(d.b,d.f));di(a,b,0);
$h(a.f,c.b,c.f)}},hi=function(a,b,c){null!=c&&null!=c&&(di(a,b,0),ai(a.f,c))},ii=function(a,b,c){null!=c&&null!=c&&(di(a,b,0),a=a.f,Fh(c),$h(a,Dh,Eh))},ji=function(a,b,c){null!=c&&(c=Wh(c),di(a,b,0),$h(a.f,c.b,c.f))},ki=function(a,b,c){null!=c&&(di(a,b,5),ci(a.f,c))},li=function(a,b,c){if(null!=c){di(a,b,5);a=a.f;var d=c;d=(c=0>d?1:0)?-d:d;0===d?0<1/d?Dh=Eh=0:(Eh=0,Dh=2147483648):isNaN(d)?(Eh=0,Dh=2147483647):3.4028234663852886E38<d?(Eh=0,Dh=(c<<31|2139095040)>>>0):1.1754943508222875E-38>d?(d=Math.round(d/
Math.pow(2,-149)),Eh=0,Dh=(c<<31|d)>>>0):(b=Math.floor(Math.log(d)/Math.LN2),d*=Math.pow(2,-b),d=Math.round(8388608*d)&8388607,Eh=0,Dh=(c<<31|b+127<<23|d)>>>0);ci(a,Dh)}},F=function(a,b,c){null!=c&&(di(a,b,0),a.f.b.push(c?1:0))},G=function(a,b,c){null!=c&&(di(a,b,0),bi(a.f,c))},J=function(a,b,c){if(null!=c){b=ei(a,b);for(var d=a.f,e=0;e<c.length;e++){var f=c.charCodeAt(e);if(128>f)d.b.push(f);else if(2048>f)d.b.push(f>>6|192),d.b.push(f&63|128);else if(65536>f)if(55296<=f&&56319>=f&&e+1<c.length){var h=
c.charCodeAt(e+1);56320<=h&&57343>=h&&(f=1024*(f-55296)+h-56320+65536,d.b.push(f>>18|240),d.b.push(f>>12&63|128),d.b.push(f>>6&63|128),d.b.push(f&63|128),e++)}else d.b.push(f>>12|224),d.b.push(f>>6&63|128),d.b.push(f&63|128)}fi(a,b)}},mi=function(a,b,c){null!=c&&(c=Gh(c),di(a,b,2),ai(a.f,c.length),b=Zh(a.f),a.g.push(b),a.g.push(c),a.h+=b.length+c.length)};y.prototype.b=function(a,b,c){null!=b&&(a=ei(this,a),c(b,this),fi(this,a))};
var ni=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(di(e,b,0),bi(e.f,f))}},oi=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(di(e,b,0),e=e.f,Fh(f),$h(e,Dh,Eh))}},pi=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++){var e=a,f=c[d];null!=f&&(di(e,b,0),ai(e.f,f))}},qi=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)ki(a,b,c[d])},ri=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)G(a,b,c[d])},si=function(a,b,c){if(null!=
c)for(var d=0;d<c.length;d++)J(a,b,c[d])},ti=function(a,b,c){if(null!=c)for(var d=0;d<c.length;d++)mi(a,b,c[d])},K=function(a,b,c,d){if(null!=c)for(var e=0;e<c.length;e++){var f=ei(a,b);d(c[e],a);fi(a,f)}},ui=function(a,b,c,d){if(null!=c)for(var e=0;e<c.length;e++)di(a,b,3),d(c[e],a),di(a,b,4)},vi=function(a,b,c){if(null!=c&&c.length){b=ei(a,b);for(var d=0;d<c.length;d++)bi(a.f,c[d]);fi(a,b)}};var M=function(){},wi="function"==typeof Uint8Array,N=function(a,b,c,d,e){a.b=null;b||(b=c?[c]:[]);a.F=c?String(c):void 0;a.j=0===c?-1:0;a.f=b;a:{if(a.f.length&&(b=a.f.length-1,(c=a.f[b])&&"object"==typeof c&&!fb(c)&&!(wi&&c instanceof Uint8Array))){a.s=b-a.j;a.h=c;break a}-1<d?(a.s=d,a.h=null):a.s=Number.MAX_VALUE}a.C={};if(e)for(d=0;d<e.length;d++)b=e[d],b<a.s?(b+=a.j,a.f[b]=a.f[b]||xi):(yi(a),a.h[b]=a.h[b]||xi)},xi=Object.freeze?Object.freeze([]):[],yi=function(a){var b=a.s+a.j;a.f[b]||(a.h=a.f[b]=
{})},zi=function(a,b,c,d){for(var e in c){var f=c[e],h=f.Rn;if(!f.th)throw Error("Message extension present that was generated without binary serialization support");var k=d.call(a,h);if(null!=k)if(h.rf)if(f.Bj)f.th.call(b,h.Ah,k,f.Bj);else throw Error("Message extension present holding submessage without binary support enabled, and message is being serialized to binary format");else f.th.call(b,h.Ah,k)}},O=function(a,b){if(b<a.s){b+=a.j;var c=a.f[b];return c===xi?a.f[b]=[]:c}if(a.h)return c=a.h[b],
c===xi?a.h[b]=[]:c},P=function(a,b){if(b<a.s){b+=a.j;var c=a.f[b];return c===xi?a.f[b]=[]:c}c=a.h[b];return c===xi?a.h[b]=[]:c},Ai=function(a,b){a=O(a,b);return null==a?a:+a},Bi=function(a){if(null==a||a instanceof Uint8Array)return a;if(Ra(a))return Ch(a);Xb("Cannot coerce to Uint8Array: "+bb(a));return null},Di=function(a){Ci(a);return!a.length||a[0]instanceof Uint8Array?a:bc(a,Bi)},Ci=function(a){if(a&&1<a.length){var b=bb(a[0]);w(a,function(a){bb(a)!=b&&Xb("Inconsistent type in JSPB repeated field array. Got "+
bb(a)+" expected "+b)})}},Q=function(a,b,c){a=O(a,b);return null==a?c:a},S=function(a,b,c){b<a.s?a.f[b+a.j]=c:(yi(a),a.h[b]=c)},Fi=function(a,b,c){Ei(a,b,c,"")},Gi=function(a,b,c){Ei(a,b,c,0)},Ei=function(a,b,c,d){c!=d?S(a,b,c):a.f[b+a.j]=null},T=function(a,b,c,d){a.b||(a.b={});if(!a.b[c]){var e=O(a,c);if(d||e)a.b[c]=new b(e)}return a.b[c]},U=function(a,b,c){Hi(a,b,c);b=a.b[c];b==xi&&(b=a.b[c]=[]);return b},Hi=function(a,b,c){a.b||(a.b={});if(!a.b[c]){for(var d=P(a,c),e=[],f=0;f<d.length;f++)e[f]=
new b(d[f]);a.b[c]=e}},V=function(a,b,c){a.b||(a.b={});var d=c?Ii(c):c;a.b[b]=c;S(a,b,d)},Ji=function(a,b,c){a.b||(a.b={});c=c||[];for(var d=[],e=0;e<c.length;e++)d[e]=Ii(c[e]);a.b[b]=c;S(a,b,d)},Ki=function(a,b,c,d){Hi(a,d,b);var e=a.b[b];e||(e=a.b[b]=[]);c=c?c:new d;a=P(a,b);e.push(c);a.push(Ii(c))},Li=function(a){if(a.b)for(var b in a.b){var c=a.b[b];if(fb(c))for(var d=0;d<c.length;d++)c[d]&&Ii(c[d]);else c&&Ii(c)}},Ii=function(a){Li(a);return a.f};
M.prototype.ya=wi?function(){var a=Uint8Array.prototype.toJSON;Uint8Array.prototype.toJSON=function(){return Ah(this)};try{return JSON.stringify(this.f&&Ii(this),Mi)}finally{Uint8Array.prototype.toJSON=a}}:function(){return JSON.stringify(this.f&&Ii(this),Mi)};var Mi=function(a,b){return m(b)&&(isNaN(b)||Infinity===b||-Infinity===b)?String(b):b},Oi=function(a){var b=Ni[a[0]];if(!b)throw Error("Unknown JsPb message type: "+a[0]);return new b(a)};M.prototype.toString=function(){Li(this);return this.f.toString()};
M.prototype.m=function(a){if(this.h){this.b||(this.b={});var b=a.Ah;if(a.b){if(a.rf)return this.b[b]||(this.b[b]=bc(this.h[b]||[],function(b){return new a.rf(b)})),this.b[b]}else if(a.rf)return!this.b[b]&&this.h[b]&&(this.b[b]=new a.rf(this.h[b])),this.b[b];return this.h[b]}};
var Qi=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(!Pi(a[d],b[d]))return!1;return!0},Pi=function(a,b){if(a==b)return!0;if(!ib(a)||!ib(b))return m(a)&&isNaN(a)||m(b)&&isNaN(b)?String(a)==String(b):!1;if(a.constructor!=b.constructor)return!1;if(wi&&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 h=
a[c],k=b[c];h&&h.constructor==Object&&(d=h,h=void 0);k&&k.constructor==Object&&(e=k,k=void 0);if(!Pi(h,k))return!1}return d||e?(d=d||{},e=e||{},Qi(d,e)):!0}if(a.constructor===Object)return Qi(a,b);throw Error("Invalid type in JSPB array");};M.prototype.clone=function(){return Ri(this)};
var Ri=function(a){return new a.constructor(Si(Ii(a)))},Si=function(a){if(fb(a)){for(var b=Array(a.length),c=0;c<a.length;c++){var d=a[c];null!=d&&(b[c]="object"==typeof d?Si(d):d)}return b}if(wi&&a instanceof Uint8Array)return new Uint8Array(a);b={};for(c in a)d=a[c],null!=d&&(b[c]="object"==typeof d?Si(d):d);return b},Ti=function(a,b){Ni[a]=b;b.messageId=a},Ni={};var Ui=function(a){N(this,a,0,-1,null)};t(Ui,M);Ui.prototype.w=function(){var a=new y;Vi(this,a);return A(a)};var Vi=function(a,b){var c=O(a,1);null!=c&&E(b,1,c);c=O(a,2);null!=c&&J(b,2,c);c=T(a,Wi,3);null!=c&&b.b(3,c,Xi)},Wi=function(a){N(this,a,0,-1,null)};t(Wi,M);Wi.prototype.w=function(){var a=new y;Xi(this,a);return A(a)};var Xi=function(a,b){var c=O(a,1);null!=c&&J(b,1,c);c=O(a,2);null!=c&&E(b,2,c)};Ui.prototype.mc=function(){return O(this,1)};var Yi=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};r("castApp.eventPage.Message",Yi);var Zi=function(a,b,c){this.ipAddress=a;this.appId=b;this.sessionId=c};Yi.DeviceData=Zi;Yi.DeviceJustSetUp=function(a,b,c,d){this.ipAddress=a;this.name=b;this.udn=c;this.modelName=d};Yi.DeviceCapabilities=function(){};
Yi.LogRecord=function(a,b,c,d){this.levelValue=a;this.msg=b;this.loggerName=c;this.time=d};var $i=function(a,b){this.type=a;this.entryPoint=b};r("castApp.frontEnd.ExtensionMessage",$i);var aj=function(a){return"urn:x-cast:com.google.cast."+a},bj=aj("tp.connection"),cj=aj("receiver"),dj=aj("remoting"),ej=aj("media"),fj=aj("webrtc"),gj=aj("broadcast"),hj=sd({Uv:bj,Vv:aj("tp.heartbeat"),Xu:cj,bv:dj,xt:ej,At:aj("media.universalRemote.optIn"),pw:fj,Uq:gj});var ij=function(a){return"available"==a||"available_rescan"==a};var jj=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 kj=window.localStorage,lj=0,nj=function(a){return(a=window.localStorage.getItem(mj(a,!1)))?JSON.parse(a):null},oj=function(a){return(a=window.localStorage.getItem(mj(a,!0)))?JSON.parse(a):null},qj=function(a){if(pj.has(a.ua()))throw Error("Duplicate instance name "+a.ua());pj.set(a.ua(),a);a.Ya()},wj=function(a){for(var b=0,c=ma(Object.keys(kj)),d=c.next();!d.done;d=c.next()){d=d.value;var e=d.length+window.localStorage.getItem(d).length;d.startsWith("mr.")?lj+=e:b+=e}rj=a;(window.localStorage.getItem("version")&&
window.localStorage.getItem("version")!==chrome.runtime.getManifest().version||sj(a))&&tj();uj.info("initialize: "+lj+" chars used, "+b+" other chars");chrome.runtime.onSuspend.addListener(vj)},rj=null,uj=tb("mr.PersistentDataManager"),pj=new Map,mj=function(a,b){return"mr."+(b?"persistent.":"temp.")+a.ua()},sj=function(a){return!!window.localStorage.getItem("mrInstanceId")&&window.localStorage.getItem("mrInstanceId")!==a},vj=function(){uj.info("onSuspend");xj("version",chrome.runtime.getManifest().version);
rj&&xj("mrInstanceId",rj);for(var a=pj.get("LogManager"),b=ma(pj),c=b.next();!c.done;c=b.next())c=ma(c.value),c.next(),c=c.next().value,c!=a&&yj(c);a&&yj(a)},yj=function(a){try{var b=a.Ta();b&&void 0!=b[0]&&xj(mj(a,!1),JSON.stringify(b[0]));b&&void 0!=b[1]&&xj(mj(a,!0),JSON.stringify(b[1]))}catch(c){uj.error("Error while saving data for "+a.ua()+": "+c.message)}},xj=function(a,b){var c=window.localStorage.getItem(a);c=null!=c?b.length-c.length:a.length+b.length;52E5<lj+c&&(v(uj,"Unable to write "+
c+" chars"),tj());if(52E5<lj+c)throw uj.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.");}lj+=c},zj=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=[],h=0,k=a.byteLength;h<k;h+=8192)f.push(String.fromCharCode.apply(null,new Uint16Array(a,h,Math.min(k-h,8192)/2)));xj("mr.temp.mirror.cast.Service.eventsBlob",f.join(""));b()}catch(n){c(n)}};d.readAsArrayBuffer(a)})},tj=function(){for(var a=ma(Object.keys(kj)),b=a.next();!b.done;b=a.next())b=b.value,b.startsWith("mr.temp.")&&(lj-=b.length+window.localStorage.getItem(b).length,delete window.localStorage[b]);uj.info("removeTemporary_: "+
lj+" chars used")};var Aj=(new Map).set("+","-").set("/","_").set("=","."),Bj=(new Map).set("-","+").set("_","/").set(".","="),Cj=function(a){return atob(a.replace(/[-_.]/g,function(a){return Bj.get(a)}))},Dj=function(a){return btoa(String.fromCharCode.apply(String,xa(a))).replace(/[+/=]/g,function(a){return Aj.get(a)})};var Ej=function(){this.b=[];this.j=[];this.s=[];this.h=[];this.h[0]=128;for(var a=1;64>a;++a)this.h[a]=0;this.g=this.f=0;this.reset()};Ej.prototype.reset=function(){this.b[0]=1732584193;this.b[1]=4023233417;this.b[2]=2562383102;this.b[3]=271733878;this.b[4]=3285377520;this.g=this.f=0};
var Fj=function(a,b,c){c=void 0===c?0:c;var d=a.s;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.b[0];c=a.b[1];e=a.b[2];for(var f=a.b[3],h=a.b[4],k,n,u=0;80>u;u++)40>u?20>u?(k=f^c&(e^f),n=1518500249):(k=c^e^f,n=1859775393):60>u?(k=c&e|f&(c|e),n=2400959708):(k=
c^e^f,n=3395469782),k=(b<<5|b>>>27)+k+h+n+d[u]&4294967295,h=f,f=e,e=(c<<30|c>>>2)&4294967295,c=b,b=k;a.b[0]=a.b[0]+b&4294967295;a.b[1]=a.b[1]+c&4294967295;a.b[2]=a.b[2]+e&4294967295;a.b[3]=a.b[3]+f&4294967295;a.b[4]=a.b[4]+h&4294967295};
Ej.prototype.update=function(a,b){b=void 0===b?a.length:b;for(var c=b-64,d=0,e=this.j,f=this.f;d<b;){if(0==f)for(;d<=c;)Fj(this,a,d),d+=64;if("string"===typeof a)for(;d<b;){if(e[f]=a.charCodeAt(d),++f,++d,64==f){Fj(this,e);f=0;break}}else for(;d<b;)if(e[f]=a[d],++f,++d,64==f){Fj(this,e);f=0;break}}this.f=f;this.g+=b};
Ej.prototype.digest=function(){var a=[],b=8*this.g;56>this.f?this.update(this.h,56-this.f):this.update(this.h,64-(this.f-56));for(var c=63;56<=c;c--)this.j[c]=b&255,b/=256;Fj(this,this.j);for(c=b=0;5>c;c++)for(var d=24;0<=d;d-=8)a[b]=this.b[c]>>d&255,++b;return a};var Gj=function(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)};var Ij=function(){this.s=Gj();this.h=new Hj(null,null);this.f=new Hj(null,null);this.j=[];this.g=this.b=0;qj(this)},Kj=function(){Jj||(Jj=new Ij);return Jj},Lj=function(a,b){b=b.toLowerCase();var c=new Ej;c.update(b);c.update(a.s);return"r"+Dj(c.digest())},Mj=function(){var a=Kj();return a.h.model?a.h:a.f.model?a.f:new Hj(null,null)};Ij.prototype.ua=function(){return"SinkUtils"};
Ij.prototype.Ta=function(){return[{recentLaunchedDevice:this.h,recentDiscoveredDevice:this.f},{receiverIdToken:this.s,fixedIpList:this.j.join(","),castControlPort:this.b,lastCloudSinkCheckTimeMillis:this.g}]};
Ij.prototype.Ya=function(){var a=nj(this);a&&(this.h=a.recentLaunchedDevice||new Hj(null,null),this.f=a.recentDiscoveredDevice||new Hj(null,null));if(a=oj(this))this.s=a.receiverIdToken||Gj(),this.j=a.fixedIpList&&a.fixedIpList.split(",")||[],this.b=a.castControlPort||0,this.g=a.lastCloudSinkCheckTimeMillis||0};var Jj=null,Hj=function(a,b){this.model=a;this.ip=b};var Nj=function(a,b){this.Sb=this.le=this.kd=this.Pa=this.Rb=null;this.Hb=new jj(b,a);this.Nb={};this.pg={};this.Kd=!1};Nj.prototype.getId=function(){return this.Hb.id};Nj.prototype.update=function(a){if(this.getId()!=a.getId())return!1;var b=!1;this.Hb.friendlyName!=a.Hb.friendlyName&&(this.Hb.friendlyName=a.Hb.friendlyName,b=!0);this.kd!=a.kd&&(this.kd=a.kd,b=!0);this.le!=a.le&&(this.le=a.le,b=!0);this.Rb!=a.Rb&&(this.Rb=a.Rb,b=!0);this.Pa!=a.Pa&&(this.Pa=a.Pa,b=!0);return b};Nj.prototype.eb=function(){return this.Rb};
Nj.prototype.Sa=function(){return this.Pa};var Oj=function(a,b){return a.Nb[b]||"unknown"},Pj=function(a){var b=new Nj(a.Hb.friendlyName,"");b.Hb.id=a.Hb.id;b.Rb=a.Rb;b.Pa=a.Pa;b.kd=a.kd;b.le=a.le;b.Sb=a.Sb;b.Nb=a.Nb;b.pg=a.pg;b.Kd=a.Kd;return b};var Rj=function(a,b,c,d,e,f){this.f=new jj(a,b,Qj(d));this.Sb=c||null;this.b=d||null;this.Rb=e||null;this.Pa=f||null;this.Nb={};this.pd=!1},Sj=function(a){if(!a.Sb||!a.eb())return null;var b=new Rj(a.Hb.id,a.Hb.friendlyName,a.Sb,void 0,a.eb(),Kj().b||8009);b.f.id=a.Hb.id;b.pd=!0;return b},Tj=function(a,b){if(b=a.update(b.f.friendlyName,b.eb(),b.Sa(),b.b))a.pd=!1;return b};
Rj.prototype.update=function(a,b,c,d){var e=!1;this.f.friendlyName!=a&&(this.f.friendlyName=a,e=!0);null!=b&&this.Rb!=b&&(this.Rb=b,e=!0);null!=c&&this.Pa!=c&&(this.Pa=c,e=!0);null!=d&&this.b!=d&&(this.b=d,e=!0);return e};var Qj=function(a){return a&1?"cast":a&32?"cast_audio_group":"cast_audio"};Rj.prototype.getId=function(){return this.f.id};
var Uj=function(a){var b=new Rj("",a.friendlyName,a.modelName,a.capabilities,a.ip,a.port);b.f.id=a.id;b.pd=a.discoveredByDial;b.Nb=a.appStatusMap;for(var c in b.Nb)"unavailable"==b.Nb[c]&&(b.Nb[c]="unavailable_rescan");return b};Rj.prototype.eb=function(){return this.Rb};Rj.prototype.Sa=function(){return this.Pa};var Vj=function(a,b){return a.Nb[b]||"unknown"};var Wj={pt:0,dt:1},Xj={kw:0,um:1,Yu:2},Yj={DIAL:0,ut:1,vt:2,Rr:3},Zj={ku:0,TIMEOUT:1,FAILED:2},ak={qj:0,Lq:1,Fr:2,ts:3,nr:4,Ut:5,Ir:6,Iu:7},bk={Ql:0,SUCCESS:1},ck={Ps:0,Ku:1,SEEK:2,Rt:3,Ev:4,Kq:5},dk=function(a){Rb("MediaRouter.Cast.Session.Ended",a,Xj)},ek=function(a){Rb("MediaRouter.Cast.Channel.ConnectResult",a,bk)},fk=function(a){Rb("MediaRouter.Cast.Controller.ActionType",a,ck)},gk=function(a){Rb("MediaRouter.Cast.Discovery.Type",a,Yj)},hk=function(a){Rb("MediaRouter.Cast.Session.Fail",a,Zj)};var ik=function(a,b,c,d,e){for(var f=[],h=4;h<arguments.length;++h)f[h-4]=arguments[h];var k=this;this.j=a;this.m=b;this.s=c;this.f=d;this.g=f;this.b=!1;this.h=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];return k.Ln.apply(k,xa(b))}};g=ik.prototype;g.addListener=function(){this.b||(this.b=!0,this.f.addListener.apply(this.f,[this.h].concat(xa(this.g))))};g.removeListener=function(){this.b&&(this.f.removeListener(this.h),this.b=!1)};
g.Zf=function(a){for(var b=0;b<arguments.length;++b);return!0};g.Ln=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];var d=this;Ag(this.j);if(!this.Zf.apply(this,xa(b)))return!1;rg(this.s).then(function(a){return a.handleEvent.apply(a,[d.f].concat(xa(b)))});return this.xh()};g.ua=function(){return"mr.EventListener."+this.m};g.Ta=function(){return[this.b]};g.Ya=function(){nj(this)&&this.addListener()};g.xh=function(){};var jk={serviceType:"_googlecast._tcp.local"},kk=null,lk=function(){kk||(kk=new ik(7,"CastMdnsEventListener","mr.cast.SinkDiscoveryService",chrome.mdns.onServiceList,jk));return kk},mk=null,nk=function(){mk||(mk="ChromeOS"==Yf()?new ik(9,"CastNetworkListChangedEventListener","mr.cast.SinkDiscoveryService",chrome.networkingPrivate.onNetworkListChanged):new ik(8,"CastNetworksChangedEventListener","mr.cast.SinkDiscoveryService",chrome.networkingPrivate.onNetworksChanged));return mk},ok=null,pk=null,
qk=function(){ok||(ok=new ik(2,"CastChannelMessageListener","mr.cast.ChannelService",chrome.cast.channel.onMessage));pk||(pk=new ik(1,"CastChannelErrorListener","mr.cast.ChannelService",chrome.cast.channel.onError));return[ok,pk]};var rk=function(a){return function(){return a}},sk=rk(!1),tk=rk(!0),uk=function(a){return a},vk=function(a){return function(){throw Error(a);}},wk=function(a){var b=b||0;return function(){return a.apply(this,Array.prototype.slice.call(arguments,0,b))}};var xk="StopIteration"in Pa?Pa.StopIteration:{message:"StopIteration",stack:""},yk=function(){};yk.prototype.next=function(){throw xk;};yk.prototype.tb=function(){return this};
var zk=function(a){if(a instanceof yk)return a;if("function"==typeof a.tb)return a.tb(!1);if(gb(a)){var b=0,c=new yk;c.next=function(){for(;;){if(b>=a.length)throw xk;if(b in a)return a[b++];b++}};return c}throw Error("Not implemented");},Ak=function(a,b,c){if(gb(a))try{w(a,b,c)}catch(d){if(d!==xk)throw d;}else{a=zk(a);try{for(;;)b.call(c,a.next(),void 0,a)}catch(d){if(d!==xk)throw d;}}},Bk=function(a,b){a=zk(a);try{for(;!b.call(void 0,a.next(),void 0,a););}catch(c){if(c!==xk)throw c;}},Dk=function(a){if(gb(a))return x(a);
a=zk(a);var b=[];Ak(a,function(a){b.push(a)});return b};var Fk=function(a,b){this.f={};this.b=[];this.g=this.h=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&&Ek(this,a)};Fk.prototype.pa=function(){return this.h};Fk.prototype.ea=function(){Gk(this);for(var a=[],b=0;b<this.b.length;b++)a.push(this.f[this.b[b]]);return a};Fk.prototype.ub=function(){Gk(this);return this.b.concat()};var Ik=function(a,b){return Hk(a.f,b)};
Fk.prototype.re=function(a){for(var b=0;b<this.b.length;b++){var c=this.b[b];if(Hk(this.f,c)&&this.f[c]==a)return!0}return!1};Fk.prototype.equals=function(a,b){if(this===a)return!0;if(this.h!=a.pa())return!1;b=b||Jk;Gk(this);for(var c,d=0;c=this.b[d];d++)if(!b(this.get(c),a.get(c)))return!1;return!0};var Jk=function(a,b){return a===b};Fk.prototype.cc=function(){return 0==this.h};Fk.prototype.clear=function(){this.f={};this.g=this.h=this.b.length=0};
Fk.prototype.remove=function(a){return Hk(this.f,a)?(delete this.f[a],this.h--,this.g++,this.b.length>2*this.h&&Gk(this),!0):!1};var Gk=function(a){if(a.h!=a.b.length){for(var b=0,c=0;b<a.b.length;){var d=a.b[b];Hk(a.f,d)&&(a.b[c++]=d);b++}a.b.length=c}if(a.h!=a.b.length){var e={};for(c=b=0;b<a.b.length;)d=a.b[b],Hk(e,d)||(a.b[c++]=d,e[d]=1),b++;a.b.length=c}};Fk.prototype.get=function(a,b){return Hk(this.f,a)?this.f[a]:b};
Fk.prototype.set=function(a,b){Hk(this.f,a)||(this.h++,this.b.push(a),this.g++);this.f[a]=b};var Ek=function(a,b){if(b instanceof Fk)for(var c=b.ub(),d=0;d<c.length;d++)a.set(c[d],b.get(c[d]));else for(c in b)a.set(c,b[c])};Fk.prototype.forEach=function(a,b){for(var c=this.ub(),d=0;d<c.length;d++){var e=c[d],f=this.get(e);a.call(b,f,e,this)}};Fk.prototype.clone=function(){return new Fk(this)};var Kk=function(a){Gk(a);for(var b={},c=0;c<a.b.length;c++){var d=a.b[c];b[d]=a.f[d]}return b};
Fk.prototype.tb=function(a){Gk(this);var b=0,c=this.g,d=this,e=new yk;e.next=function(){if(c!=d.g)throw Error("The map has changed since the iterator was created");if(b>=d.b.length)throw xk;var e=d.b[b++];return a?e:d.f[e]};return e};var Hk=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var Lk=function(a){return Promise.all(a.map(function(a){return a.then(function(a){return{qd:!0,value:a}},function(a){return{qd:!1,reason:a}})}))};var Mk=function(a,b){this.f=b;this.A=a;this.A.ha=this.ha.bind(this);this.b=new Fk;this.m=new Fk;this.h=new Fk;this.ka=null;this.u=this.C="";this.g=null;this.L=this.o=!1;this.D=[];this.l=tb("mr.cast.SinkDiscoveryService");this.B=new Set;this.j={Ld:0,Xd:0};this.s=this.F=0};l(Mk,mg);Mk.prototype.init=function(){qj(this);this.o&&(Nk(this),Ok(this));xg("mr.cast.SinkDiscoveryService",this)};var Nk=function(a){a.l.info("Start listening to network changes");nk().addListener()};
Mk.prototype.start=function(){var a=Date.now(),b=lk();if(b.b){if(6E4>a-this.ka)return;this.l.info("Forcing mdns discovery");chrome.mdns.forceDiscovery(Ya);b=lk();b.removeListener();b.addListener()}else this.l.info("Adding mdns listener"),b.addListener();this.ka=a};Mk.prototype.stop=function(){this.l.info("Stopping...");lk().removeListener()};
Mk.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,xa(c));else if(a==chrome.networkingPrivate.onNetworksChanged||a==chrome.networkingPrivate.onNetworkListChanged)Ok(this);else throw Error("Unhandled event");};
var Pk=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.l,"Missing ID"),null;var e=Number(b.serviceHostPort.substring(b.serviceHostPort.lastIndexOf(":")+1));if(isNaN(e)||0>e||65535<e)return v(a.l,"Missing or invalid port"),null;var f=c.fn;if(!f||!b.ipAddress)return v(a.l,"Missing friendly name or IP address"),null;a=Number(c.ca);return new Rj(d,
f,c.md||"",isNaN(a)?0:a,b.ipAddress,e)},Yk=function(a,b){a.l.info("addSinks returned "+b.length+" sinks");Ab(a.l,function(){return"....the list is: "+JSON.stringify(b)});var c=new Set(a.b.ub());b.forEach(function(b){var d=b.sink_id;var f=b.extra_data.cast_media_sink,h=f.ip_endpoint?f.ip_endpoint.address:f.ip_address,k=f.ip_endpoint?f.ip_endpoint.port:Kj().b||8009;d=new Rj(d,b.name,f.model_name,f.capabilities,h.address_bytes.join("."),k);f=a.b.get(d.getId());h=a.A;b=b.extra_data.cast_media_sink.cast_channel_id;
k=d.getId();var n=h.f.get(k);if(!n||n.channelId!=b){Qk.info("Added cast channel "+b+" to receiver: "+k);n&&h.b.remove(n.channelId);n={auth:"ssl_verified",ipAddress:d.eb(),port:d.Sa()};n={channelId:b,readyState:"open",keepAlive:!0,audioOnly:!(d.b&1),connectInfo:n};h.f.set(k,n);h.b.set(b,k);var u=h.g.get(k);u&&u.channelId!=b&&(Qk.info("Re-connected to receiver: "+d.getId()),Rk(h.h,u,n),Sk(h.j.j,d,!0));h.g.set(k,n)}f?Tj(f,d)&&Tk(a.f,f):Uk(a,d);c.delete(d.getId())});c.forEach(function(b){var c=a.A,d=
c.g.get(b);d&&(Vk(c.h,d),c.g.remove(b));Wk(a,b)});a.j={Ld:a.b.pa(),Xd:Xk(a)}};Mk.prototype.K=function(a){var b=this;this.l.info("Registering "+a.length+" devices");0!=this.s&&(clearTimeout(this.s),this.s=0);a=Zk(this,a).map(function(a){return $k(b,a,!0)});Lk(a).then(function(){b.j={Ld:b.b.pa(),Xd:Xk(b)};al(b)})};
var al=function(a){0!=a.s||36E5>Date.now()-a.F||(a.s=setTimeout(function(){var b=a.j;Sb("MediaRouter.Cast.Discovery.KnownDevicesCount",b.Xd);Sb("MediaRouter.Cast.Discovery.ConnectedDevicesCount",b.Ld);a.F=Date.now();a.s=0},5E3))};Mk.prototype.Rd=function(){return this.j};
var Xk=function(a){var b=a.B.size;Ak(a.b.tb(!1),function(c){a.B.has(c.getId())||b++});return b},$k=function(a,b,c){if(Ik(a.h,b.getId()))return Promise.resolve();a.h.set(b.getId(),b);return bl(a,b).then(function(d){d?(d=a.b.get(b.getId()),c&&(d?d.pd&&gk(3):gk(1)),Uk(a,b)):(a.l.info("Inaccessible sink: "+b.getId()),Wk(a,b.getId()));a.h.remove(b.getId())})},cl=function(a,b){return void 0!=a.D.find(function(a){return a.ipAddress==b.ipAddress})},Zk=function(a,b){var c=[];a.B.clear();b.forEach(function(b){if(!cl(a,
b)&&(b=Pk(a,b))){var d=b.getId();a.B.add(d);if(Ik(a.h,d)){var f=a.h.get(d);if(f.eb()==b.eb()&&f.Sa()==b.Sa()){a.l.info("Sink has pending connection "+d);return}v(a.l,"Pending sink changed ip "+d);a.h.remove(d)}(d=a.b.get(d))?Tj(d,b)&&Tk(a.f,d):c.push(b)}});return c},dl=function(a,b){var c=a.b.get(b.getId()),d=null,e=b.eb(),f=b.Sa();null!=e&&null!=f&&(d=a.m.get(e+":"+f));if(c&&!d){var h=b.eb(),k=b.Sa();h&&k&&a.m.remove(h+":"+k)}d&&!c&&a.b.remove(d.getId());a.b.set(b.getId(),b);null!=e&&null!=f&&a.m.set(e+
":"+f,b)},Uk=function(a,b){a.l.info("Adding sink "+b.getId());dl(a,b);a.o||(a.o=!0,Nk(a));a=a.f;a.f.onSinkAvailabilityUpdated(a,1);Tk(a,b);Sk(a.j,b);Kj().f=new Hj(b.Sb,b.eb())},Wk=function(a,b){var c=a.b.get(b);if(c){a.l.info("Removing sink "+b);a.b.remove(b);b=c.eb();var d=c.Sa();null!=b&&null!=d&&a.m.remove(b+":"+d);a.f.L(c)}},el=function(a){var b=a.b.ea();a.b.clear();a.m.clear();b.forEach(a.f.L,a.f)},bl=function(a,b){Ab(a.l,"Checking access to "+b.getId());return fl(a.A,b).then(function(a){if(b.pd){var c=
4;a.audioOnly||(c|=1);b.b=c;b.f.iconType=Qj(b.b)}return!0},function(){return!1})},gl=function(a){a.l.info("Pruning inactive sinks.");Ak(a.b.tb(!1),function(b){a.h.set(b.getId(),b);bl(a,b).then(function(c){c||Wk(a,b.getId());a.h.remove(b.getId())})})};Mk.prototype.ha=function(a){return this.b.get(a,null)};var hl=function(a,b){var c=[];Ak(a.b.tb(!1),function(a){ij(Vj(a,b))&&c.push(a)});return c};Mk.prototype.ua=function(){return"cast.SinkDiscoveryService"};
Mk.prototype.Ta=function(){var a=this,b={};Ak(this.b.tb(!0),function(c){var d=a.b.get(c);d={id:d.getId(),ip:d.eb(),port:d.Sa(),friendlyName:d.f.friendlyName,modelName:d.Sb,capabilities:d.b,discoveredByDial:d.pd,appStatusMap:d.Nb};b[c]=d});return[new il(b,this.u,this.j),new jl(this.o,this.F)]};
Mk.prototype.Ya=function(){var a=nj(this);if(a&&3==a.version){this.u=a.networkIds;this.j=a.deviceCounts;a=a.sinkMap;this.L=0<Object.keys(a).length;for(var b in a){var c=Uj(a[b]);this.ha(c.getId())||dl(this,c)}gl(this)}if(b=oj(this))this.o=b.hasSavedSinks,this.F=b.lastSinkCountMetricRecordTime||0};
var kl=function(a,b){a.L=0<Object.keys(b).length;for(var c in b){var d=Uj(b[c]);a.ha(d.getId())||$k(a,d,!1)}},Ok=function(a){a.l.info("Fetching networks state");a.g&&yj(a.g);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);ll(a,c.sort().join(","))})},ll=function(a,b){a.l.info(function(){return"Update current network "+ml(b)});b!=a.C&&(a.g&&(pj.delete(a.g.ua()),a.g=null),
b?(a.u&&b!=a.u?el(a):gl(a),a.C=b,a.u=b,a.g=new nl(a,a.C)):a.C="")},ml=function(a){for(var b=0,c=0;c<a.length;c++)b+=a.charCodeAt(c);return b},il=function(a,b,c){this.sinkMap=a;this.networkIds=b;this.deviceCounts=c;this.version=3},jl=function(a,b){this.hasSavedSinks=a;this.lastSinkCountMetricRecordTime=b},nl=function(a,b){this.b=a;this.f=b;qj(this)};nl.prototype.ua=function(){return"cast.NetworkSink."+this.f};
nl.prototype.Ta=function(){var a=this,b=null,c=this.b.Ta();c&&(this.b.L||0<this.b.b.pa())&&(b=c[0]);this.b.l.info(function(){return"Saving sink data for network "+ml(a.f)});return[null,b]};nl.prototype.Ya=function(){var a=this;this.b.l.info(function(){return"Restoring sink data for network "+ml(a.f)});var b=oj(this);b&&3==b.version&&kl(this.b,b.sinkMap)};var ol={STOP_MEDIA:"STOP",MEDIA_SET_VOLUME:"SET_VOLUME",MEDIA_GET_STATUS:"GET_STATUS"};var pl=function(){this.type="GET_STATUS";this.requestId=0};var ql=function(a,b){this.requestId=a;this.Wf=b;this.ul=null};ql.prototype.b=function(){};var rl=function(){this.b=new Fk},sl=function(a,b){a.b.set(b.requestId,b);b.ul=setTimeout(function(){a.b.remove(b.requestId);b.b()},b.Wf)},tl=function(a,b){var c=a.b.get(b);if(!c)return null;clearTimeout(c.ul);a.b.remove(b);return c};var ul=function(a,b,c){this.type="APPLICATION_BROADCAST";this.requestId=0;this.appIds=a;this.namespace=b;this.message=c};var vl=function(a){this.type="LAUNCH";this.requestId=0;this.appId=a;this.language=null};var wl=function(a){this.type="STOP";this.requestId=0;this.sessionId=a||null};var xl=function(a){this.f=a;this.b=1E3*Math.floor(1E6*Math.random())},yl=function(a){var b=a.b++;0==b&&(b=a.b++);return b};xl.prototype.ua=function(){return"IdGenerator."+this.f};xl.prototype.Ta=function(){return[this.b]};xl.prototype.Ya=function(){var a=nj(this);a&&(this.b=a)};var zl=function(a,b){this.f=a;this.h=b;this.b=new rl;this.g=new xl("cast.RequestIdGenerator")};zl.prototype.init=function(){qj(this.g)};var Bl=function(a,b,c,d){var e=yl(a.g);b.requestId=e;b=new Tb;c=new Al(e,b,m(c)&&0<c?c:6E5,d);sl(a.b,c);return c};
zl.prototype.sendRequest=function(a,b,c,d,e,f){var h=this;if(!hj.hasOwnProperty(c))return Promise.reject(Error("Custom namespace is not supported"));var k=Bl(this,a,Qa(d)?d:3E3,e),n=k.kb;Cl(this.f,b,c,a,e||this.h,f).then(null,function(){tl(h.b,k.requestId);n.reject(Dl)});return n.b};
zl.prototype.sendMessage=function(a,b,c,d,e,f){var h=this,k=Bl(this,a,Qa(d)?d:3E3,e),n=k.kb;Cl(this.f,b,c,a,e||this.h,f).then(function(){tl(h.b,k.requestId);n.resolve(!0)},function(){tl(h.b,k.requestId);n.reject(Dl)});return n.b};
var El=function(a,b,c){var d=new vl(b.appId);d.language=b.language?b.language:chrome.i18n.getUILanguage?chrome.i18n.getUILanguage():chrome.runtime.getManifest().default_locale;return a.sendRequest(d,c,cj,b.requestSessionTimeout)},Fl=Error("Timeout"),Dl=Error("Failed to send message"),Al=function(a,b,c,d){ql.call(this,a,c);this.kb=b;this.sourceId=d};l(Al,ql);Al.prototype.b=function(){this.kb.reject(Fl)};var Gl=function(a){return a.pa&&"function"==typeof a.pa?a.pa():gb(a)||Ra(a)?a.length:gd(a)},Hl=function(a){if(a.ea&&"function"==typeof a.ea)return a.ea();if(Ra(a))return a.split("");if(gb(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return id(a)},Il=function(a){if(a.ub&&"function"==typeof a.ub)return a.ub();if(!a.ea||"function"!=typeof a.ea){if(gb(a)||Ra(a)){var b=[];a=a.length;for(var c=0;c<a;c++)b.push(c);return b}return jd(a)}},Jl=function(a){return a.cc&&"function"==typeof a.cc?
a.cc():gb(a)||Ra(a)?0==a.length:nd(a)},Kl=function(a,b,c){if(a.forEach&&"function"==typeof a.forEach)a.forEach(b,c);else if(gb(a)||Ra(a))w(a,b,c);else for(var d=Il(a),e=Hl(a),f=e.length,h=0;h<f;h++)b.call(c,e[h],d&&d[h],a)},Ll=function(a,b,c){if("function"==typeof a.map)return a.map(b,c);if(gb(a)||Ra(a))return bc(a,b,c);var d=Il(a),e=Hl(a),f=e.length;if(d){var h={};for(var k=0;k<f;k++)h[d[k]]=b.call(c,e[k],d[k],a)}else for(h=[],k=0;k<f;k++)h[k]=b.call(c,e[k],void 0,a);return h},Ml=function(a,b){if("function"==
typeof a.every)return a.every(b,void 0);if(gb(a)||Ra(a))return ec(a,b,void 0);for(var c=Il(a),d=Hl(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 Ol=function(a){this.b=new Fk;a&&Nl(this,a)},Pl=function(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+(a[jb]||(a[jb]=++lb)):b.substr(0,1)+a};Ol.prototype.pa=function(){return this.b.pa()};Ol.prototype.add=function(a){this.b.set(Pl(a),a)};var Nl=function(a,b){b=Hl(b);for(var c=b.length,d=0;d<c;d++)a.add(b[d])};g=Ol.prototype;g.removeAll=function(a){a=Hl(a);for(var b=a.length,c=0;c<b;c++)this.remove(a[c])};g.remove=function(a){return this.b.remove(Pl(a))};g.clear=function(){this.b.clear()};
g.cc=function(){return this.b.cc()};g.contains=function(a){return Ik(this.b,Pl(a))};g.ea=function(){return this.b.ea()};g.clone=function(){return new Ol(this)};g.equals=function(a){return this.pa()==Gl(a)&&Ql(this,a)};var Ql=function(a,b){var c=Gl(b);if(a.pa()>c)return!1;!(b instanceof Ol)&&5<c&&(b=new Ol(b));return Ml(a,function(a){var c=b;return c.contains&&"function"==typeof c.contains?c.contains(a):c.re&&"function"==typeof c.re?c.re(a):gb(c)||Ra(c)?ic(c,a):ld(c,a)})};Ol.prototype.tb=function(){return this.b.tb(!1)};var Sl=function(a,b){this.h=a;this.g=b;this.f=new Fk;this.b=new Ol;this.j=0;this.o=new Fk("serviceCheck",this.bo.bind(this),"startDeviceMonitor",this.co.bind(this),"releaseDeviceMonitor",this.ao.bind(this),"deviceJustSetUp",this.Xn.bind(this),"logRecord",this.Yn.bind(this));chrome.runtime.onMessage.addListener(this.m.bind(this));chrome.runtime.onMessageExternal.addListener(this.s.bind(this));Rl(this,"serviceReady")};Sl.prototype.l=tb("castApp.eventPage.Service");
var Vl=function(a){if(Tl(a)){var b=new Ol;Ak(a.h.b.tb(!1),function(a){var c=a.eb();b.add(c);Ik(this.f,c)||this.g.sendRequest(new pl,a,cj)}.bind(a));var c=!1;a.f.ub().forEach(function(a){b.contains(a)||(this.f.remove(a),c=!0)}.bind(a));c&&Ul(a)}},Tl=function(a){if(0===a.b.pa())return!1;var b=q();3E4<b-a.j&&(a.j=b,chrome.tabs.query({url:["chrome://cast/*","chrome-extension://"+chrome.runtime.id+"/cast_setup/*"]},function(a){0===a.length?(this.l.info("No tabs found. Clearing device monitor clients."),
this.b.clear()):this.l.info(function(){return"Tab check found active tabs: "+a.map(function(a){return a.id})})}.bind(a)));b=a.b.pa();a.l.info("Monitor client count: "+b);return 0<b};Sl.prototype.m=function(a,b,c){if("object"!==typeof a||"cast_app"!==a.type)return!1;var d=this.o.get(a.subtype);if(!d)return!1;if(!a.originId)return Xb("Missing origin ID in the incoming message."),!1;try{var e=d(a,b,c);e&&c(e)}catch(f){this.l.error("Error while handling request",f)}return!1};
var Rl=function(a,b,c){var d=new Yi(b,c);Ab(a.l,function(){return"Sending message: "+JSON.stringify(d)});chrome.runtime.sendMessage(d)};g=Sl.prototype;g.bo=function(){Rl(this,"serviceReady")};g.co=function(a){this.b.contains(a.originId)?this.l.info("Client: "+a.originId+"already registered, dispatching current device list."):(this.l.info("Registering monitor client: "+a.originId),this.b.add(a.originId));Ul(this);Wl(this)};g.ao=function(a){this.l.info("Unregistering monitor client: "+a.originId);this.b.remove(a.originId)};
g.Xn=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 Rj(b,a.name,a.modelName,c,a.ipAddress,Kj().b||8009);$k(this.h,c,!0)};g.Yn=function(a){a=a.logRecord;wb({level:Eb(a.levelValue),J:a.loggerName,time:a.time,message:a.msg})};
var Ul=function(a){var b=a.f.ea();Rl(a,"devices",b)},Wl=function(a){Ab(a.h.l,"Executing forceDiscovery.");chrome.mdns.forceDiscovery(Ya);a.h.b.ea().forEach(function(a){this.g.sendRequest(new pl,a,cj)}.bind(a))};Sl.prototype.s=function(a,b,c){switch(a.type){case "handshake":c(new $i("handshake"));break;case "launch":b=b.tab&&m(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})}};chrome.cast.VERSION=[1,2];r("chrome.cast.VERSION",chrome.cast.VERSION);chrome.cast.hq=!0;r("chrome.cast.usingPresentationApi",chrome.cast.hq);chrome.cast.Error=function(a,b,c){this.code=a;this.description=b||null;this.details=c||null};r("chrome.cast.Error",chrome.cast.Error);chrome.cast.Lm=function(a){this.platform=a;this.packageId=this.url=null};r("chrome.cast.SenderApplication",chrome.cast.Lm);chrome.cast.Image=function(a){this.url=a;this.width=this.height=null};r("chrome.cast.Image",chrome.cast.Image);
chrome.cast.Volume=function(a,b){this.level=Qa(a)?a:null;this.muted=Qa(b)?b:null};r("chrome.cast.Volume",chrome.cast.Volume);chrome.cast.Qc={CUSTOM_CONTROLLER_SCOPED:"custom_controller_scoped",TAB_AND_ORIGIN_SCOPED:"tab_and_origin_scoped",ORIGIN_SCOPED:"origin_scoped",PAGE_SCOPED:"page_scoped"};r("chrome.cast.AutoJoinPolicy",chrome.cast.Qc);chrome.cast.cg={CREATE_SESSION:"create_session",CAST_THIS_TAB:"cast_this_tab"};r("chrome.cast.DefaultActionPolicy",chrome.cast.cg);chrome.cast.jd={VIDEO_OUT:"video_out",AUDIO_OUT:"audio_out",VIDEO_IN:"video_in",AUDIO_IN:"audio_in",MULTIZONE_GROUP:"multizone_group"};
r("chrome.cast.Capability",chrome.cast.jd);chrome.cast.Rc={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"};r("chrome.cast.ErrorCode",chrome.cast.Rc);chrome.cast.wm={AVAILABLE:"available",UNAVAILABLE:"unavailable"};
r("chrome.cast.ReceiverAvailability",chrome.cast.wm);chrome.cast.Mm={CHROME:"chrome",IOS:"ios",ANDROID:"android"};r("chrome.cast.SenderPlatform",chrome.cast.Mm);chrome.cast.kg={CAST:"cast",DIAL:"dial",HANGOUT:"hangout",CUSTOM:"custom"};r("chrome.cast.ReceiverType",chrome.cast.kg);chrome.cast.Kl={RUNNING:"running",STOPPED:"stopped",ERROR:"error"};r("chrome.cast.DialAppState",chrome.cast.Kl);chrome.cast.nf={CAST:"cast",STOP:"stop"};r("chrome.cast.ReceiverAction",chrome.cast.nf);
chrome.cast.mj={CONNECTED:"connected",DISCONNECTED:"disconnected",STOPPED:"stopped"};r("chrome.cast.SessionStatus",chrome.cast.mj);chrome.cast.rj={ATTENUATION:"attenuation",FIXED:"fixed",MASTER:"master"};r("chrome.cast.VolumeControlType",chrome.cast.rj);chrome.cast.El=function(a,b,c,d,e){this.sessionRequest=a;this.sessionListener=b;this.receiverListener=c;this.autoJoinPolicy=d||chrome.cast.Qc.TAB_AND_ORIGIN_SCOPED;this.defaultActionPolicy=e||chrome.cast.cg.CREATE_SESSION;this.customDialLaunchCallback=null;this.invisibleSender=!1;this.additionalSessionRequests=[]};r("chrome.cast.ApiConfig",chrome.cast.El);chrome.cast.Ml=function(a,b){this.appName=a;this.launchParameter=b||null};r("chrome.cast.DialRequest",chrome.cast.Ml);
chrome.cast.Si=function(a,b,c){this.receiver=a;this.appState=b;this.extraData=c||null};r("chrome.cast.DialLaunchData",chrome.cast.Si);chrome.cast.Ll=function(a,b){this.doLaunch=a;this.launchParameter=b||null};r("chrome.cast.DialLaunchResponse",chrome.cast.Ll);chrome.cast.lj=function(a,b,c){this.appId=a;this.capabilities=fb(b)?b:[chrome.cast.jd.VIDEO_OUT,chrome.cast.jd.AUDIO_OUT];this.requestSessionTimeout=c||chrome.cast.timeout.requestSession;this.dialRequest=this.language=null};
r("chrome.cast.SessionRequest",chrome.cast.lj);
chrome.cast.kh=function(a,b,c,d){this.label=a;a=b;Qc.test(a)&&(-1!=a.indexOf("&")&&(a=a.replace(Kc,"&amp;")),-1!=a.indexOf("<")&&(a=a.replace(Lc,"&lt;")),-1!=a.indexOf(">")&&(a=a.replace(Mc,"&gt;")),-1!=a.indexOf('"')&&(a=a.replace(Nc,"&quot;")),-1!=a.indexOf("'")&&(a=a.replace(Oc,"&#39;")),-1!=a.indexOf("\x00")&&(a=a.replace(Pc,"&#0;")));this.friendlyName=a;this.capabilities=c||[];this.volume=d||null;this.receiverType=chrome.cast.kg.CAST;this.displayStatus=this.isActiveInput=null};
r("chrome.cast.Receiver",chrome.cast.kh);chrome.cast.xm=function(a,b){this.statusText=a;this.appImages=b;this.showStop=null};r("chrome.cast.ReceiverDisplayStatus",chrome.cast.xm);chrome.cast.pj=function(){this.requestSession=6E4;this.sendCustomMessage=this.setReceiverVolume=this.stopSession=this.leaveSession=3E3};r("chrome.cast.Timeout",chrome.cast.pj);chrome.cast.timeout=new chrome.cast.pj;r("chrome.cast.timeout",chrome.cast.timeout);chrome.cast.Oi="auto-join";chrome.cast.fj="cast-session_";chrome.cast.media.Jd={PAUSE:"pause",SEEK:"seek",STREAM_VOLUME:"stream_volume",STREAM_MUTE:"stream_mute"};r("chrome.cast.media.MediaCommand",chrome.cast.media.Jd);chrome.cast.media.xc={GENERIC:0,MOVIE:1,TV_SHOW:2,MUSIC_TRACK:3,PHOTO:4};r("chrome.cast.media.MetadataType",chrome.cast.media.xc);chrome.cast.media.me={IDLE:"IDLE",PLAYING:"PLAYING",PAUSED:"PAUSED",BUFFERING:"BUFFERING"};r("chrome.cast.media.PlayerState",chrome.cast.media.me);
chrome.cast.media.lh={OFF:"REPEAT_OFF",ALL:"REPEAT_ALL",SINGLE:"REPEAT_SINGLE",ALL_AND_SHUFFLE:"REPEAT_ALL_AND_SHUFFLE"};r("chrome.cast.media.RepeatMode",chrome.cast.media.lh);chrome.cast.media.ym={PLAYBACK_START:"PLAYBACK_START",PLAYBACK_PAUSE:"PLAYBACK_PAUSE"};r("chrome.cast.media.ResumeState",chrome.cast.media.ym);chrome.cast.media.nj={BUFFERED:"BUFFERED",LIVE:"LIVE",OTHER:"OTHER"};r("chrome.cast.media.StreamType",chrome.cast.media.nj);
chrome.cast.media.Wl={CANCELLED:"CANCELLED",INTERRUPTED:"INTERRUPTED",FINISHED:"FINISHED",ERROR:"ERROR"};r("chrome.cast.media.IdleReason",chrome.cast.media.Wl);chrome.cast.media.Ym={TEXT:"TEXT",AUDIO:"AUDIO",VIDEO:"VIDEO"};r("chrome.cast.media.TrackType",chrome.cast.media.Ym);chrome.cast.media.Vm={SUBTITLES:"SUBTITLES",CAPTIONS:"CAPTIONS",DESCRIPTIONS:"DESCRIPTIONS",CHAPTERS:"CHAPTERS",METADATA:"METADATA"};r("chrome.cast.media.TextTrackType",chrome.cast.media.Vm);
chrome.cast.media.Rm={NONE:"NONE",OUTLINE:"OUTLINE",DROP_SHADOW:"DROP_SHADOW",RAISED:"RAISED",DEPRESSED:"DEPRESSED"};r("chrome.cast.media.TextTrackEdgeType",chrome.cast.media.Rm);chrome.cast.media.Wm={NONE:"NONE",NORMAL:"NORMAL",ROUNDED_CORNERS:"ROUNDED_CORNERS"};r("chrome.cast.media.TextTrackWindowType",chrome.cast.media.Wm);
chrome.cast.media.Sm={SANS_SERIF:"SANS_SERIF",MONOSPACED_SANS_SERIF:"MONOSPACED_SANS_SERIF",SERIF:"SERIF",MONOSPACED_SERIF:"MONOSPACED_SERIF",CASUAL:"CASUAL",CURSIVE:"CURSIVE",SMALL_CAPITALS:"SMALL_CAPITALS"};r("chrome.cast.media.TextTrackFontGenericFamily",chrome.cast.media.Sm);chrome.cast.media.Tm={NORMAL:"NORMAL",BOLD:"BOLD",BOLD_ITALIC:"BOLD_ITALIC",ITALIC:"ITALIC"};r("chrome.cast.media.TextTrackFontStyle",chrome.cast.media.Tm);chrome.cast.media.Ul=function(){this.customData=null};r("chrome.cast.media.GetStatusRequest",chrome.cast.media.Ul);chrome.cast.media.im=function(){this.customData=null};r("chrome.cast.media.PauseRequest",chrome.cast.media.im);chrome.cast.media.km=function(){this.customData=null};r("chrome.cast.media.PlayRequest",chrome.cast.media.km);chrome.cast.media.Km=function(){this.customData=this.resumeState=this.currentTime=null};r("chrome.cast.media.SeekRequest",chrome.cast.media.Km);
chrome.cast.media.Nm=function(){this.customData=null};r("chrome.cast.media.StopRequest",chrome.cast.media.Nm);chrome.cast.media.dn=function(a){this.volume=a;this.customData=null};r("chrome.cast.media.VolumeRequest",chrome.cast.media.dn);chrome.cast.media.Yl=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};r("chrome.cast.media.LoadRequest",chrome.cast.media.Yl);
chrome.cast.media.Vu=function(a){this.type="PRECACHE";this.requestId=0;this.precacheData=a};chrome.cast.media.Pl=function(a,b){this.requestId=0;this.activeTrackIds=a||null;this.textTrackStyle=b||null};r("chrome.cast.media.EditTracksInfoRequest",chrome.cast.media.Pl);chrome.cast.media.Tl=function(){this.metadataType=this.type=chrome.cast.media.xc.GENERIC;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.title=null};r("chrome.cast.media.GenericMediaMetadata",chrome.cast.media.Tl);
chrome.cast.media.bm=function(){this.metadataType=this.type=chrome.cast.media.xc.MOVIE;this.releaseDate=this.releaseYear=this.images=this.subtitle=this.studio=this.title=null};r("chrome.cast.media.MovieMediaMetadata",chrome.cast.media.bm);chrome.cast.media.Zm=function(){this.metadataType=this.type=chrome.cast.media.xc.TV_SHOW;this.originalAirdate=this.releaseYear=this.images=this.episode=this.episodeNumber=this.season=this.seasonNumber=this.episodeTitle=this.title=this.seriesTitle=null};
r("chrome.cast.media.TvShowMediaMetadata",chrome.cast.media.Zm);chrome.cast.media.cm=function(){this.metadataType=this.type=chrome.cast.media.xc.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};r("chrome.cast.media.MusicTrackMediaMetadata",chrome.cast.media.cm);
chrome.cast.media.jm=function(){this.metadataType=this.type=chrome.cast.media.xc.PHOTO;this.creationDateTime=this.height=this.width=this.longitude=this.latitude=this.images=this.location=this.artist=this.title=null};r("chrome.cast.media.PhotoMediaMetadata",chrome.cast.media.jm);chrome.cast.media.am=function(a,b){this.contentId=a;this.streamType=chrome.cast.media.nj.BUFFERED;this.contentType=b;this.customData=this.textTrackStyle=this.tracks=this.duration=this.metadata=null};
r("chrome.cast.media.MediaInfo",chrome.cast.media.am);chrome.cast.media.nm=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};r("chrome.cast.media.QueueItem",chrome.cast.media.nm);chrome.cast.media.Il="CC1AD845";r("chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID",chrome.cast.media.Il);chrome.cast.media.timeout={};chrome.cast.media.timeout.load=0;r("chrome.cast.media.timeout.load",chrome.cast.media.timeout.load);
chrome.cast.media.timeout.Ia=0;r("chrome.cast.media.timeout.getStatus",chrome.cast.media.timeout.Ia);chrome.cast.media.timeout.play=0;r("chrome.cast.media.timeout.play",chrome.cast.media.timeout.play);chrome.cast.media.timeout.pause=0;r("chrome.cast.media.timeout.pause",chrome.cast.media.timeout.pause);chrome.cast.media.timeout.seek=0;r("chrome.cast.media.timeout.seek",chrome.cast.media.timeout.seek);chrome.cast.media.timeout.stop=0;r("chrome.cast.media.timeout.stop",chrome.cast.media.timeout.stop);
chrome.cast.media.timeout.Lc=0;r("chrome.cast.media.timeout.setVolume",chrome.cast.media.timeout.Lc);chrome.cast.media.timeout.yh=0;r("chrome.cast.media.timeout.editTracksInfo",chrome.cast.media.timeout.yh);chrome.cast.media.timeout.np=0;r("chrome.cast.media.timeout.queue",chrome.cast.media.timeout.np);chrome.cast.media.Xm=function(a,b){this.trackId=a;this.trackContentType=this.trackContentId=null;this.type=b;this.customData=this.subtype=this.language=this.name=null};r("chrome.cast.media.Track",chrome.cast.media.Xm);
chrome.cast.media.Um=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};r("chrome.cast.media.TextTrackStyle",chrome.cast.media.Um);chrome.cast.media.pm=function(a){this.type="QUEUE_LOAD";this.sessionId=this.requestId=null;this.items=a;this.startIndex=0;this.repeatMode=chrome.cast.media.lh.OFF;this.customData=null};
r("chrome.cast.media.QueueLoadRequest",chrome.cast.media.pm);chrome.cast.media.mm=function(a){this.type="QUEUE_INSERT";this.sessionId=this.requestId=null;this.items=a;this.customData=this.insertBefore=null};r("chrome.cast.media.QueueInsertItemsRequest",chrome.cast.media.mm);chrome.cast.media.tm=function(a){this.type="QUEUE_UPDATE";this.sessionId=this.requestId=null;this.items=a;this.customData=null};r("chrome.cast.media.QueueUpdateItemsRequest",chrome.cast.media.tm);
chrome.cast.media.om=function(){this.type="QUEUE_UPDATE";this.customData=this.jump=this.currentItemId=this.sessionId=this.requestId=null};r("chrome.cast.media.QueueJumpRequest",chrome.cast.media.om);chrome.cast.media.sm=function(){this.type="QUEUE_UPDATE";this.customData=this.repeatMode=this.sessionId=this.requestId=null};r("chrome.cast.media.QueueSetPropertiesRequest",chrome.cast.media.sm);
chrome.cast.media.qm=function(a){this.type="QUEUE_REMOVE";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=null};r("chrome.cast.media.QueueRemoveItemsRequest",chrome.cast.media.qm);chrome.cast.media.rm=function(a){this.type="QUEUE_REORDER";this.sessionId=this.requestId=null;this.itemIds=a;this.customData=this.insertBefore=null};r("chrome.cast.media.QueueReorderItemsRequest",chrome.cast.media.rm);chrome.cast.media.N=function(a,b){this.sessionId=a;this.mediaSessionId=b;this.media=null;this.playbackRate=1;this.playerState=chrome.cast.media.me.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.lh.OFF};r("chrome.cast.media.Media",chrome.cast.media.N);chrome.cast.media.N.prototype.Ia=function(){};
chrome.cast.media.N.prototype.getStatus=chrome.cast.media.N.prototype.Ia;chrome.cast.media.N.prototype.play=function(){};chrome.cast.media.N.prototype.play=chrome.cast.media.N.prototype.play;chrome.cast.media.N.prototype.gp=function(){};chrome.cast.media.N.prototype.playWithContext=chrome.cast.media.N.prototype.gp;chrome.cast.media.N.prototype.pause=function(){};chrome.cast.media.N.prototype.pause=chrome.cast.media.N.prototype.pause;chrome.cast.media.N.prototype.fp=function(){};
chrome.cast.media.N.prototype.pauseWithContext=chrome.cast.media.N.prototype.fp;chrome.cast.media.N.prototype.seek=function(){};chrome.cast.media.N.prototype.seek=chrome.cast.media.N.prototype.seek;chrome.cast.media.N.prototype.stop=function(){};chrome.cast.media.N.prototype.stop=chrome.cast.media.N.prototype.stop;chrome.cast.media.N.prototype.Lc=function(){};chrome.cast.media.N.prototype.setVolume=chrome.cast.media.N.prototype.Lc;chrome.cast.media.N.prototype.yh=function(){};
chrome.cast.media.N.prototype.editTracksInfo=chrome.cast.media.N.prototype.yh;chrome.cast.media.N.prototype.pp=function(){};chrome.cast.media.N.prototype.queueInsertItems=chrome.cast.media.N.prototype.pp;chrome.cast.media.N.prototype.op=function(){};chrome.cast.media.N.prototype.queueAppendItem=chrome.cast.media.N.prototype.op;chrome.cast.media.N.prototype.zp=function(){};chrome.cast.media.N.prototype.queueUpdateItems=chrome.cast.media.N.prototype.zp;chrome.cast.media.N.prototype.up=function(){};
chrome.cast.media.N.prototype.queuePrev=chrome.cast.media.N.prototype.up;chrome.cast.media.N.prototype.tp=function(){};chrome.cast.media.N.prototype.queueNext=chrome.cast.media.N.prototype.tp;chrome.cast.media.N.prototype.qp=function(a){Xl(this,a)};chrome.cast.media.N.prototype.queueJumpToItem=chrome.cast.media.N.prototype.qp;chrome.cast.media.N.prototype.yp=function(){};chrome.cast.media.N.prototype.queueSetRepeatMode=chrome.cast.media.N.prototype.yp;chrome.cast.media.N.prototype.wp=function(){};
chrome.cast.media.N.prototype.queueRemoveItems=chrome.cast.media.N.prototype.wp;chrome.cast.media.N.prototype.vp=function(a){Xl(this,a)};chrome.cast.media.N.prototype.queueRemoveItem=chrome.cast.media.N.prototype.vp;chrome.cast.media.N.prototype.xp=function(){};chrome.cast.media.N.prototype.queueReorderItems=chrome.cast.media.N.prototype.xp;chrome.cast.media.N.prototype.sp=function(a,b,c,d){a=Xl(this,a);0>a||(0>b?d&&d(new chrome.cast.Error(chrome.cast.Rc.INVALID_PARAMETER)):a==b&&c&&c())};
chrome.cast.media.N.prototype.queueMoveItemToNewIndex=chrome.cast.media.N.prototype.sp;chrome.cast.media.N.prototype.fq=function(a){return-1<this.supportedMediaCommands.indexOf(a)};chrome.cast.media.N.prototype.supportsCommand=chrome.cast.media.N.prototype.fq;chrome.cast.media.N.prototype.Tn=function(){return this.currentTime};chrome.cast.media.N.prototype.getEstimatedTime=chrome.cast.media.N.prototype.Tn;chrome.cast.media.N.prototype.oh=function(){};
chrome.cast.media.N.prototype.addUpdateListener=chrome.cast.media.N.prototype.oh;chrome.cast.media.N.prototype.ph=function(){};chrome.cast.media.N.prototype.addUpdateListenerWithContext=chrome.cast.media.N.prototype.ph;chrome.cast.media.N.prototype.yi=function(){};chrome.cast.media.N.prototype.removeUpdateListener=chrome.cast.media.N.prototype.yi;chrome.cast.media.N.prototype.zi=function(){};chrome.cast.media.N.prototype.removeUpdateListenerWithContext=chrome.cast.media.N.prototype.zi;
var Xl=function(a,b){return fc(a.items,function(a){return a.itemId==b})};var Yl=function(a,b,c){this.sessionId=a;this.namespaceName=b;this.message=c};var Zl=function(a,b){this.type="SET_VOLUME";this.requestId=0;this.volume=a;this.expectedVolume=b||null};chrome.cast.R=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.mj.CONNECTED;this.transportId=""};r("chrome.cast.Session",chrome.cast.R);chrome.cast.R.prototype.Up=function(a,b,c){this.nl(null,a,b,c)};chrome.cast.R.prototype.setReceiverVolumeLevel=chrome.cast.R.prototype.Up;
chrome.cast.R.prototype.nl=function(a,b,c,d){b=new Zl(new chrome.cast.Volume(b,null),this.receiver.volume);a.setReceiverVolume(this.sessionId,b,c,d)};chrome.cast.R.prototype.setReceiverVolumeLevelWithContext=chrome.cast.R.prototype.nl;chrome.cast.R.prototype.Tp=function(a,b,c){this.ml(null,a,b,c)};chrome.cast.R.prototype.setReceiverMuted=chrome.cast.R.prototype.Tp;
chrome.cast.R.prototype.ml=function(a,b,c,d){a=new Zl(new chrome.cast.Volume(null,b),this.receiver.volume);null.setReceiverVolume(this.sessionId,a,c,d)};chrome.cast.R.prototype.setReceiverMutedWithContext=chrome.cast.R.prototype.ml;chrome.cast.R.prototype.leave=function(a,b){null.leaveSession(this.sessionId,a,b)};chrome.cast.R.prototype.leave=chrome.cast.R.prototype.leave;chrome.cast.R.prototype.stop=function(){};chrome.cast.R.prototype.stop=chrome.cast.R.prototype.stop;
chrome.cast.R.prototype.aq=function(){};chrome.cast.R.prototype.stopWithContext=chrome.cast.R.prototype.aq;chrome.cast.R.prototype.sendMessage=function(){};chrome.cast.R.prototype.sendMessage=chrome.cast.R.prototype.sendMessage;chrome.cast.R.prototype.Kp=function(){};chrome.cast.R.prototype.sendMessageWithContext=chrome.cast.R.prototype.Kp;chrome.cast.R.prototype.oh=function(){};chrome.cast.R.prototype.addUpdateListener=chrome.cast.R.prototype.oh;chrome.cast.R.prototype.ph=function(){};
chrome.cast.R.prototype.addUpdateListenerWithContext=chrome.cast.R.prototype.ph;chrome.cast.R.prototype.yi=function(){};chrome.cast.R.prototype.removeUpdateListener=chrome.cast.R.prototype.yi;chrome.cast.R.prototype.zi=function(){};chrome.cast.R.prototype.removeUpdateListenerWithContext=chrome.cast.R.prototype.zi;chrome.cast.R.prototype.tn=function(){};chrome.cast.R.prototype.addMessageListener=chrome.cast.R.prototype.tn;chrome.cast.R.prototype.un=function(){};
chrome.cast.R.prototype.addMessageListenerWithContext=chrome.cast.R.prototype.un;chrome.cast.R.prototype.rn=function(){};chrome.cast.R.prototype.addMediaListener=chrome.cast.R.prototype.rn;chrome.cast.R.prototype.sn=function(){};chrome.cast.R.prototype.addMediaListenerWithContext=chrome.cast.R.prototype.sn;chrome.cast.R.prototype.Cp=function(){};chrome.cast.R.prototype.removeMediaListener=chrome.cast.R.prototype.Cp;chrome.cast.R.prototype.Dp=function(){};
chrome.cast.R.prototype.removeMediaListenerWithContext=chrome.cast.R.prototype.Dp;chrome.cast.R.prototype.Ep=function(){};chrome.cast.R.prototype.removeMessageListener=chrome.cast.R.prototype.Ep;chrome.cast.R.prototype.Fp=function(){};chrome.cast.R.prototype.removeMessageListenerWithContext=chrome.cast.R.prototype.Fp;chrome.cast.R.prototype.oo=function(a){a.sessionId=this.sessionId};chrome.cast.R.prototype.loadMedia=chrome.cast.R.prototype.oo;chrome.cast.R.prototype.rp=function(a){a.sessionId=this.sessionId};
chrome.cast.R.prototype.queueLoad=chrome.cast.R.prototype.rp;var bm=function(a,b){if(!b.applications||1!=b.applications.length)return null;var c=b.applications[0];a=$l(a);a=new chrome.cast.R(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||am(a)))return null;a.receiver.volume=b.volume;Ta(b.isActiveInput)&&(a.receiver.isActiveInput=b.isActiveInput);return a},cm=function(a){var b=[];if(!a)return b;
a&1&&b.push(chrome.cast.jd.VIDEO_OUT);a&2&&b.push(chrome.cast.jd.VIDEO_IN);a&4&&b.push(chrome.cast.jd.AUDIO_OUT);a&8&&b.push(chrome.cast.jd.AUDIO_IN);a&32&&b.push(chrome.cast.jd.MULTIZONE_GROUP);return b},$l=function(a){var b=Lj(Kj(),a.getId());return new chrome.cast.kh(b,a.f.friendlyName,cm(a.b))},dm=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},em=function(a){fb(a)?a.forEach(em):ib(a)&&Object.keys(a).forEach(function(b){null===a[b]?delete a[b]:(ib(a[b])||fb(a[b]))&&em(a[b])})},fm=function(a){return a.namespaces.some(function(a){return a.name==ej})},am=function(a){return null!==a&&"MultizoneLeader"==a.appId},gm=function(a){return"E8C28D3C"==a||"00000000-0000-0000-0000-000000000000"==a};var hm=function(a,b,c){this.type=a;this.message=b;this.sequenceNumber=Qa(c)?c:-1;this.timeoutMillis=0;this.clientId=""};var im=function(a,b){this.g=a;this.b=b;this.h=[];this.f=new rl},km=function(a,b){return(a=jm(a.b,b))?a.routeId:null};im.prototype.listen=function(a,b){this.h[a]=b};var mm=function(a,b,c,d){Ab(lm,"Sending to "+c);Ab(lm,JSON.stringify(d));d.clientId=c;a.g.f.vd(b,d)},nm=function(a,b,c){var d=jm(a.b,b);d&&d.b?mm(a,d.routeId,b,c):a.connect(b).then(function(d){d?(d=km(a,b))?mm(a,d,b,c):v(lm,"No route for "+b):v(lm,"No connected client "+b)},null)};
im.prototype.connect=function(a){var b=jm(this.b,a);if(null!=b&&b.b)return Promise.resolve(!0);b=km(this,a);if(!b)return v(lm,"No route for client "+a),Promise.resolve(!1);if(a=this.f.b.get(b,null))return a.kb.b;a=new Tb;sl(this.f,new om(b,a));return a.b};var lm=tb("mr.cast.ApiMessenger"),om=function(a,b){ql.call(this,a,3E4);this.kb=b};l(om,ql);om.prototype.b=function(){this.kb.resolve(!1)};var pm=function(a,b,c){this.h=a;this.b=b;this.f=c},qm=function(a){var b="cast-dial:"+a.h,c=new URLSearchParams;a.b&&c.set("dialPostData",a.b);a.f&&c.set("clientId",a.f);(a=c.toString())&&(b+="?"+a);return b};var rm=function(a,b,c,d,e,f,h,k,n,u){this.j=a;this.b=b||null;this.f=c||null;this.h=d||null;this.g=Qa(e)?e:null;this.u=f||null;this.A=h||null;this.o=k||!1;this.m=n||null;this.s=u||null},sm=function(a,b){return(a=a.match(b+"=([^/]*)"))?a[1]:null},um=function(a){a=a.match(/__castAppId__=([^/]*)/g);return null==a?[]:ac(bc(a,function(a){a=sm(a,"__castAppId__");if(!a)return null;a=a.match(tm);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})},vm=function(a){return bc(a.j,function(a){return a.appId})},wm=function(a){return a.f?a.f:chrome.cast.Qc.TAB_AND_ORIGIN_SCOPED},xm=function(a){var b=a.j.map(function(b){var c="cast:"+b.appId,e=new URLSearchParams;b.capabilities&&0<b.capabilities.length&&e.set("capabilities",b.capabilities.join(","));a.b&&e.set("clientId",a.b);a.f&&e.set("autoJoinPolicy",a.f);a.h&&e.set("defaultActionPolicy",a.h);null!=a.g&&e.set("launchTimeout",String(a.g));a.o&&e.set("invisibleSender",
"true");a.m&&(e.set("broadcastNamespace",a.m),e.set("broadcastId",String(Math.random())));a.s&&e.set("broadcastMessage",encodeURIComponent(JSON.stringify(a.s)));return c+"?"+e.toString()});a.u&&b.push(qm(new pm(a.u,a.A,a.b)));return b},zm=function(a,b){a=vm(a);var c=ym(b);return dc(a,function(a){return ic(c,a)})},Am=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=um(c))&&
0!=a.length){b=sm(c,"__castClientId__");var d=sm(c,"__castAutoJoinPolicy__"),e=sm(c,"__castDefaultActionPolicy__");var f=sm(c,"__castLaunchTimeout__");null==f?f=null:(f=Number(f),f=!isNaN(f)&&0<f?f:null);var h=sm(c,"__dialAppName__"),k=sm(c,"__dialPostData__");var n=sm(c,"__castInvisibleSender__");n=null===n?null:"true"==n;var u=sm(c,"__castBroadcastNamespace__");c=(c=sm(c,"__castBroadcastMessage__"))?JSON.parse(decodeURIComponent(c)):null;a=new rm(a,b,d,e,f,h,k,n,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(","):[]};k=b.searchParams;b=k.get("clientId");d=k.get("autoJoinPolicy");e=k.get("defaultActionPolicy");c=Number(k.get("launchTimeout"));if(isNaN(c)||0>=c)c=null;f="true"==k.get("invisibleSender");h=k.get("broadcastNamespace");k=(k=k.get("broadcastMessage"))?JSON.parse(decodeURIComponent(k)):null;a=new rm([a],b,d,e,c,void 0,void 0,f,h,k)}else a=null;return a},ym=function(a){return(a=Am(a))?vm(a):null},Bm=
function(a){return(a=Am(a))?a.b:null},tm=/(^\w+)(?:\(([\w, ]*)\))?$/;var Cm=function(a,b,c){this.J=tb("mr.MediaRouteController."+a);this.g=new mojo.Binding(mojo.MediaController,this,b);this.h=c;this.b=new mojo.MediaStatus({title:"",description:"",duration:new mojo.TimeDelta({microseconds:0}),current_time:new mojo.TimeDelta({microseconds:0})});this.B=!1;this.g.setConnectionErrorHandler(this.o.bind(this));this.h.ptr.setConnectionErrorHandler(this.o.bind(this))};Cm.prototype.o=function(){this.Ra();this.m()};
Cm.prototype.Ra=function(){this.B||(this.B=!0,this.s(),this.g&&(this.g.close(),this.g=null),this.h&&(this.h.ptr.reset(),this.h=null))};var Dm=function(a){if(a.h)a.h.onMediaStatusUpdated(a.b)};Cm.prototype.s=function(){};Cm.prototype.m=function(){};Cm.prototype.play=function(){};Cm.prototype.play=Cm.prototype.play;Cm.prototype.pause=function(){};Cm.prototype.pause=Cm.prototype.pause;Cm.prototype.ie=function(){};Cm.prototype.setMute=Cm.prototype.ie;Cm.prototype.Lc=function(){};
Cm.prototype.setVolume=Cm.prototype.Lc;Cm.prototype.seek=function(){};Cm.prototype.seek=Cm.prototype.seek;Cm.prototype.wh=function(a){a.close();throw Error("Not implemented");};Cm.prototype.connectHangoutsMediaRouteController=Cm.prototype.wh;var Em=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)},Fm=function(a){return new mojo.TimeDelta({microseconds:Math.floor(1E6*a)})};var Gm=function(a,b,c,d){this.type=a;this.mediaSessionId=b;this.requestId=0;this.sessionId=c;this.currentTime=d},Im=function(a,b,c,d,e){Cm.call(this,"CastRouteController",a,b);this.session=c;this.f=d;this.j=e;this.A=new Date;this.u=new Set;Hm(this);fk(0)};l(Im,Cm);
var Hm=function(a){var b=Jm(a);b&&Km(a,b);b&&a.j||!a.session.statusText||(a.b.title=a.session.statusText.substring(0,256));a.b.volume=null===a.session.receiver.volume.level?0:a.session.receiver.volume.level;a.b.is_muted=!!a.session.receiver.volume.muted;a.b.can_mute=a.session.receiver.volume.controlType!==chrome.cast.rj.FIXED;a.b.can_set_volume=a.b.can_mute;Dm(a)};Im.prototype.m=function(){Lm(this.f.b,this.session.sessionId)};
Im.prototype.play=function(){var a=Jm(this);this.b.can_play_pause&&a&&this.b.play_state===mojo.MediaStatus.PlayState.PAUSED&&Mm(this.f,this.session,new Gm("PLAY",a.mediaSessionId,this.session.sessionId));Nm(this,1)};Im.prototype.play=Im.prototype.play;Im.prototype.pause=function(){var a=Jm(this);this.b.can_play_pause&&a&&this.b.play_state!==mojo.MediaStatus.PlayState.PAUSED&&Mm(this.f,this.session,new Gm("PAUSE",a.mediaSessionId,this.session.sessionId));Nm(this,1)};Im.prototype.pause=Im.prototype.pause;
Im.prototype.seek=function(a){var b=Jm(this);a=a?a.microseconds/1E6:0;var c;if(c=this.b.can_seek&&b&&0<=a)c=this.b.duration,c=a<=(c?c.microseconds/1E6:0);c&&Mm(this.f,this.session,new Gm("SEEK",b.mediaSessionId,this.session.sessionId,a));Nm(this,2)};Im.prototype.seek=Im.prototype.seek;Im.prototype.ie=function(a){this.b.can_mute&&a!==this.b.is_muted&&Om(this.f,this.session,new chrome.cast.Volume(null,a));Nm(this,3)};Im.prototype.setMute=Im.prototype.ie;
Im.prototype.Lc=function(a){this.b.can_set_volume&&0<=a&&1>=a&&Om(this.f,this.session,new chrome.cast.Volume(a));Nm(this,4)};Im.prototype.setVolume=Im.prototype.Lc;
var Jm=function(a){return a.session.media.find(function(a){return!a.idleReason})||null},Km=function(a,b){a.j&&b.media&&b.media.metadata&&b.media.metadata.title&&(a.b.title=b.media.metadata.title.substring(0,256));a.b.can_play_pause=b.supportedMediaCommands.includes(chrome.cast.media.Jd.PAUSE);a.b.can_seek=b.supportedMediaCommands.includes(chrome.cast.media.Jd.SEEK);var c=b.playerState;a.b.play_state=c===chrome.cast.media.me.PLAYING?mojo.MediaStatus.PlayState.PLAYING:c===chrome.cast.media.me.PAUSED?
mojo.MediaStatus.PlayState.PAUSED:mojo.MediaStatus.PlayState.BUFFERING;a.b.current_time=b.currentTime?Fm(b.playerState===chrome.cast.media.me.PLAYING?b.currentTime+(new Date-a.A)/1E3:b.currentTime):Fm(0);a.b.duration=b.media&&b.media.duration?Fm(b.media.duration):Fm(0)},Nm=function(a,b){0==a.u.size&&fk(5);a.u.has(b)||(fk(b),a.u.add(b))};var Pm=function(a){this.f=a;this.l=tb("mr.cast.SessionLauncher")},Qm=function(a,b,c){Rb("MediaRouter.Cast.Session.Type",0,Wj);return El(a.f,b,c).then(a.b.bind(a,c),function(a){a&&Fl==a?hk(1):hk(0);throw a;})};Pm.prototype.b=function(a,b){Ab(this.l,"Got launch result from "+a.getId());if("LAUNCH_ERROR"==b.type)throw hk(2),Error(b.reason);a=bm(a,b.status);this.l.info("Launched session: "+a.sessionId);return a};var Rm=function(a){this.b=a;this.l=tb("mr.cast.ReceiverStatusQuerier")},Sm=function(a,b){return Ce(new Ae(p(a.f,a,b),3500,5),2).start().then(null,function(c){a.l.info("Failed to get receiver status from "+b.getId());throw c;})};Rm.prototype.f=function(a){this.l.info("Query receiver status: "+a.getId());return this.b.sendRequest(new pl,a,cj)};var Tm=function(a,b,c,d,e,f){this.h=a;this.s=b;this.j=c;this.b=d;this.m=e;this.g=f;this.f=new im(f,c);this.B=new Rm(this.h);this.F=new Pm(this.h)};Tm.prototype.init=function(){this.j.init();this.f.listen("v2_message",this.A.bind(this));this.f.listen("app_message",this.o.bind(this));this.f.listen("leave_session",this.u.bind(this))};
var Wm=function(a,b,c,d){Um(a.b,b).slice().forEach(function(b){b!=d&&Vm(a,b,c)})},Vm=function(a,b,c){c.clientId=b;nm(a.f,b,c)},Xm=function(a,b,c,d){c={receiver:$l(c),action:d};Vm(a,b,new hm("receiver_action",c))};
Tm.prototype.A=function(a){var b=a.message,c=b.sessionId;if(c){var d=Ym(this.b,c);if(d)if(c=Zm(this.b,c))if(c=this.s.ha(c))switch(b.type){case "STOP":$m(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":an(this,a,c,d);break;case "SET_VOLUME":bn(this,a,c);break;default:v(cn,"Unknown request")}else dn(this,
a,chrome.cast.Rc.INVALID_PARAMETER,"No receiver");else dn(this,a,chrome.cast.Rc.INVALID_PARAMETER,"No sink ID");else dn(this,a,chrome.cast.Rc.INVALID_PARAMETER,"Unknown session ID")}else dn(this,a,chrome.cast.Rc.INVALID_PARAMETER,"No session ID")};
var dn=function(a,b,c,d){c=new chrome.cast.Error(c,d);en(a,b,c)},en=function(a,b,c){nm(a.f,b.clientId,new hm("error",c,b.sequenceNumber))},$m=function(a,b,c){var d=b.message;Qb("MediaRouter.Cast.Session.End");var e=d.sessionId,f=fn(a.b,e);f&&(f.j=!0);f=function(){gn(a,e,b)};a.h.sendRequest(d,c,cj,b.timeoutMillis,b.clientId).then(f,f)},an=function(a,b,c,d){var e=b.message,f=e.type;f in ol&&(e.type=ol[f]);a.h.sendRequest(e,c,ej,b.timeoutMillis,b.clientId,d.transportId).then(function(c){hn(a,d,c);nm(a.f,
b.clientId,new hm("v2_message",c,b.sequenceNumber))},function(c){en(a,b,c)})},bn=function(a,b,c){var d=b.message;delete d.sessionId;a.h.sendRequest(d,c,cj,b.timeoutMillis,b.clientId).then(function(){nm(a.f,b.clientId,new hm("v2_message",null,b.sequenceNumber))},function(c){en(a,b,c)})};
Tm.prototype.o=function(a){var b=this,c=a.message,d=c.sessionId;if(d){var e=Zm(this.b,d);e?(e=this.s.ha(e))?(d=Ym(this.b,d),gc(d.namespaces,function(a){return a.name==c.namespaceName})?Cl(this.m,e,c.namespaceName,c.message,a.clientId,d.transportId).then(function(){nm(b.f,a.clientId,new hm("app_message",null,a.sequenceNumber))},function(){dn(b,a,chrome.cast.Rc.CHANNEL_ERROR,"Channel to receiver not available")}):dn(this,a,chrome.cast.Rc.INVALID_PARAMETER,"Invalid namespace")):v(cn,"No receiver from sinkId"):
v(cn,"No sinkId from sessionId")}else v(cn,"No sessionId")};
Tm.prototype.u=function(a){var b=this;cn.info("Leave session");var c=fn(this.b,a.message);if(c){var d=a.clientId,e=jm(this.j,d);if(e){var f=[],h=[],k=e.tabId,n=e.origin,u=e.autoJoinPolicy;c.f.forEach(function(a){var c=jm(b.j,a);u==chrome.cast.Qc.TAB_AND_ORIGIN_SCOPED&&k==c.tabId&&n==c.origin||u==chrome.cast.Qc.ORIGIN_SCOPED&&n==c.origin?(c.f=!0,f.push(a)):h.push(a)});nm(this.f,d,new hm("leave_session",null,a.sequenceNumber));f.forEach(function(a){(a=jm(b.j,a))&&jn(b.g,a.routeId,!0,!0)});c.f=h}else v(cn,
"No client record")}else v(cn,"No session")};
var kn=function(a,b,c){fm(b)&&a.h.sendRequest(new pl,c,ej,void 0,void 0,b.transportId).catch(Ya)},Sk=function(a,b,c){var d=b.getId();cn.info("Query status for "+d);Sm(a.B,b).then(function(e){ln(a,d,e);c&&(e=mn(a.b,d))&&kn(a,e,b)},Ya)},nn=function(a,b){if("*"==b.destinationId)return!0;b=b.destinationId;if(b==a.m.m||null!=jm(a.j,b))return!0;cn.info("Invalid destination "+b);return!1},sn=function(a,b,c){Ab(cn,function(){return"Cast message: "+JSON.stringify(c)});if(nn(a,c))if(c.namespace_==dj||c.namespace_==
fj)(b=on(a.b,b))&&b.b.forEach(function(b){var d=a.g,e=d.h.get(b);e&&e.se&&d.f.Pg(b,c)});else{var d=JSON.parse(c.data),e=pn(a,d);e=e?e.sourceId:void 0;switch(d.type){case "RECEIVER_STATUS":ln(a,b,d);break;case "MEDIA_STATUS":qn(a,b,c,e)}}else rn(a.m,b,c.destinationId,c.sourceId,!1)},pn=function(a,b){a=tl(a.h.b,b.requestId);if(!a)return null;var c=a.kb;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.Rc.SESSION_ERROR,
b.reason||b.type,b));break;default:c.resolve(b)}return a},tn=function(a,b,c){Ab(cn,function(){return"App message: "+JSON.stringify(c)});if(b=mn(a.b,b)){var d;"*"==c.destinationId?d=Um(a.b,b.sessionId):d=[c.destinationId];var e=new Yl(b.sessionId,c.namespace_,c.data);d.forEach(function(b){nm(a.f,b,new hm("app_message",e))})}else v(cn,"No session for incoming app message")},un=function(a,b){a.forEach(function(a){a.sessionId=b;var c=a.supportedMediaCommands,e=[];c&1&&e.push(chrome.cast.media.Jd.PAUSE);
c&2&&e.push(chrome.cast.media.Jd.SEEK);c&4&&e.push(chrome.cast.media.Jd.STREAM_VOLUME);c&8&&e.push(chrome.cast.media.Jd.STREAM_MUTE);a.supportedMediaCommands=e});return a},hn=function(a,b,c){b=b.sessionId;c.sessionId=b;c=un(c.status,b);vn(a.b,b,c);(a=fn(a.b,b))&&a.controller&&(a=a.controller,a.A=new Date,(c=Jm(a))?Km(a,c):(a.j&&(a.b.title=""),a.b.can_play_pause=!1,a.b.can_seek=!1),Dm(a))},wn=function(a,b){if(b=mn(a.b,b)){b=b.sessionId;var c=fn(a.b,b);c&&c.j||gn(a,b)}},gn=function(a,b,c){c&&Vm(a,c.clientId,
c);(c=fn(a.b,b))&&c.b.slice().forEach(function(b){jn(a.g,b,!0)});xn(a.b,b);yn(a.g)},ln=function(a,b,c){Ab(cn,"Receiver status for "+b);var d=c.status;if(d)if(c=a.s.ha(b)){d=bm(c,d);var e=on(a.b,b);e?d?d.sessionId==e.session.sessionId?(b=e.session,dm(b,d)&&(Ab(cn,"Updating session "+d.sessionId),e.h&&(b.statusText=d.statusText),b.namespaces=d.namespaces,b.receiver.volume=d.receiver.volume,zn(a.g,e),Wm(a,b.sessionId,new hm("update_session",b)),e.controller&&Hm(e.controller))):(wn(a,b),dk(1),An(a.g,
null,c,null,d)):(wn(a,b),dk(1)):d&&An(a.g,null,c,null,d)}else Qb("MediaRouter.Cast.Error.Sink.Missing.From.Discovery.Service"),v(cn,"Got message from receiver "+b+", but sink is no longer available.")},qn=function(a,b,c,d){if(b=mn(a.b,b))if(c=JSON.parse(c.data))hn(a,b,c),Wm(a,c.sessionId,new hm("v2_message",c),d)},Bn=function(a,b){var c=cm(b.b);return(b=gc(a.j,function(a){return ec(a.capabilities,function(a){return ic(c,a)})}))?b.appId:vm(a)[0]},Cn=function(a,b,c){var d=Am(b);if(!d)return Promise.reject(Error("Invalid source "+
b));var e=Bn(d,c),f=new Fb("MediaRouter.Cast.Session.Launch");return Qm(a.F,new chrome.cast.lj(e,void 0,null==d.g?chrome.cast.timeout.requestSession:d.g),c).then(function(a){cn.info("Launched session "+a.sessionId+" for appId "+e);f.b("Success");return a},function(a){cn.error("Failed to session for appId "+e);f.b("Failure");throw a;})};
Tm.prototype.createMediaRouteController=function(a,b,c){a=Dn(this.b,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=En(this,d.sessionId);if(!e)return Error("Sink not found for the route");a.controller=new Im(b,c,d,this,a.h);kn(this,d,e);return null};
var Mm=function(a,b,c){var d=En(a,b.sessionId);d&&a.h.sendRequest(c,d,ej,0,"",b.transportId).catch(function(a){v(cn,"Failed to send a media control request: "+a)})},Om=function(a,b,c){c=new Zl(c);(b=En(a,b.sessionId))&&a.h.sendRequest(c,b,cj).catch(function(a){v(cn,"Failed to send a volume control request: "+a)})},En=function(a,b){return(b=Zm(a.b,b))?a.s.ha(b):null},cn=tb("mr.cast.ApiHandler");var Fn=function(a){return"0F5096E8"==a||"85CDB22F"==a};var Gn=function(){},In=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 Gn;b.h=a;a=ma(c);a.next();b.b=a.next().value;b.g=a.next().value;b.j=a.next().value;b.f=a.next().value;return b};Gn.prototype.fa=function(){return this.f};var Jn=function(a,b,c,d,e,f){this.id=a;this.presentationId=b;this.sinkId=c;this.mediaSource=d;this.isLocal=e;this.description=f;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.se=e;this.isOffscreenPresentation=!1},Kn=function(a,b,c,d,e,f){b=d&&Eg(d)?a:"urn:x-org.chromium:media:route:"+a+"/"+b+"-"+c+"/"+d;return new Jn(b,
a,c,d,e,f)};var Ln=function(a,b,c,d){c=Kn(c,"cast",b.getId(),a,d,"");c.supportsMediaRouteController=!0;mojo&&mojo.RouteControllerType&&(c.controllerType=d&&Bg(a)&&b.b&1&&mojo.RouteControllerType.kMirroring?mojo.RouteControllerType.kMirroring:mojo.RouteControllerType.kGeneric);return c},Mn=function(a,b){var c=b.wb.Wb;c&&(b.description=Qg(c),a.displayName="",a.statusText="mirror_desktop"==c.f?"":c.h||"")};var Nn=function(a,b){if(!chrome.runtime.lastError)return null;a=a+" failed, chrome.runtime.lastError: "+(chrome.runtime.lastError.message||"Unknown error");b&&Ab(b,a);return Error(a)};var On=function(){this.f=new Fk;this.h=new Fk;this.b=new Fk},Tn=function(a,b,c){c=void 0===c?!1:c;var d=b.getId(),e=b.eb()+":"+b.Sa(),f=a.f.get(d);if(f){if(a.b.get(d)==e)return Ab(Pn,"Using pending creation to "+d),f;Pn.info("Device "+d+" IP changed from "+a.b.get(b.getId())+" to "+e);Qn(a,b)}b=Rn(a,b,c?15E3:1E4).then(function(b){Sn(a,d);ek(1);return b},function(b){e==a.b.get(d)&&Sn(a,d);ek(0);return Promise.reject(b)});a.f.set(d,b);a.b.set(d,e);return b},Qn=function(a,b){b=b.getId();Ab(Pn,"Aborting connection to device "+
b);var c=a.h.get(b);c&&c.abort();Sn(a,b)},Sn=function(a,b){a.f.remove(b);a.h.remove(b);a.b.remove(b)},Rn=function(a,b,c){var d=new Ae(function(){return Un(b,c)},1E3,3);a.h.set(b.getId(),d);return Ce(d,1.5).start().then(null,function(a){Pn.info("Failed to create channel to "+b.getId());return Promise.reject(a)})},Un=function(a,b){var c=Vn++;Pn.info("Connecting to (id "+c+") "+a.getId());var d=new Fb("MediaRouter.Cast.Mdns.Channel.Open");return Wn(a,b).then(function(a){Pn.info(function(){return"Channel opened (id "+
c+"): "+JSON.stringify(a)});d.b("Success");return a},function(a){Pn.info("Channel did not open (id "+c+").");d.b("Failure");return Promise.reject(a)})},Wn=function(a,b){var c={ipAddress:a.eb(),port:a.Sa(),auth:"ssl_verified",timeout:1E4,livenessTimeout:b,pingInterval:5E3,capabilities:0};Pn.info(function(){return"Opening channel to "+JSON.stringify(c)});var d=new Tb;chrome.cast.channel.open(c,function(a){a?"open"==a.readyState?d.resolve(a):(Nn("chrome.cast.channel.open",Pn),chrome.cast.channel.close(a,
function(){Nn("chrome.cast.channel.close",Pn)}),d.reject(Error(a.errorState))):(a=Nn("chrome.cast.channel.open",Pn),d.reject(a))});return d.b},Pn=tb("mr.cast.ChannelFactory"),Vn=0;var Xn=function(a,b,c,d){return{namespace_:a,data:Ra(b)?b:JSON.stringify(b),sourceId:c,destinationId:d}};var Yn=function(a){this.type="CLOSE";this.reasonCode=a};var Zn=function(a){return(a=a.exec(Zc))?a[1]:""},$n=function(){if(rh)return Zn(/Firefox\/([0-9.]+)/);if(Ed||Fd||Dd)return Xd;if(vh)return yd()?Zn(/CriOS\/([0-9.]+)/):Zn(/Chrome\/([0-9.]+)/);if(wh&&!yd())return Zn(/Version\/([0-9.]+)/);if(sh||th){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(Zc);if(a)return a[1]+"."+a[2]}else if(uh)return(a=Zn(/Android\s+([0-9.]+)/))?a:Zn(/Version\/([0-9.]+)/);return""}(),ao=function(a){return 0<=Xc($n,a)};var co=function(a){this.type="CONNECT";this.origin={};this.userAgent=Zc;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:$n,platform:bo(),systemVersion:b,connectionType:1};this.connType=a?0:2},bo=function(){switch(Yf()){case "ChromeOS":return 5;case "Windows":return 3;case "Mac":return 4;case "Linux":return 6}return 0};var eo=function(){this.b=new Fk};eo.prototype.init=function(){qj(this)};var fo=function(a,b,c,d,e){if(!Ik(a.b,[b.channelId,c,d].join("#"))){var f=Xn(bj,new co(e),c,d);chrome.cast.channel.send(b,f,a.f.bind(a));a.b.set([b.channelId,c,d].join("#"),e)}};eo.prototype.f=function(){Nn("chrome.cast.channel.send",go)};
var Vk=function(a,b){a.b.ub().forEach(function(c){c.split("#")[0]==b.channelId.toString()&&a.b.remove(c)})},Rk=function(a,b,c){a.b.forEach(function(d,e){var f=e.split("#");f[0]==b.channelId.toString()&&(fo(a,c,f[1],f[2],d),a.b.remove(e))})};eo.prototype.ua=function(){return"cast.VirtualConnectionManager"};eo.prototype.Ta=function(){var a=Kk(this.b);return[new ho(a)]};eo.prototype.Ya=function(){var a=nj(this);if(a)for(var b in a.b)this.b.set(b,a.b[b])};ab(eo);
var go=tb("mr.cast.VirtualConnectionManager"),ho=function(a){this.b=a};var io=function(a,b){this.j=b;this.m=a;this.f=new Fk;this.b=new Fk;this.h=eo.Ha();this.o=new On;this.s=!0;this.ha=null;this.g=new Fk};l(io,mg);io.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.A.apply(this,xa(c)):a==chrome.cast.channel.onError&&this.u.apply(this,xa(c))};io.prototype.init=function(a){this.s=void 0===a?!0:a;this.h.init();qj(this);xg("mr.cast.ChannelService",this);qk().forEach(function(a){return a.addListener()})};
var Cl=function(a,b,c,d,e,f){var h=e||a.m,k=f||"receiver-0";return fl(a,b).then(function(b){return jo(a,b,c,d,h,k)})},ko=function(a,b,c,d,e){fl(a,b).then(function(b){return fo(a.h,b,c,d,e)})},rn=function(a,b,c,d,e){if(b=a.f.get(b))a=a.h,Ik(a.b,[b.channelId,c,d].join("#"))&&(a.b.remove([b.channelId,c,d].join("#")),c=Xn(bj,new Yn(e?5:0),c,d),chrome.cast.channel.send(b,c,a.f.bind(a)))};
io.prototype.A=function(a,b){var c=this.b.get(a.channelId);if(c){var d=this.ha(c);if(d){if(hj.hasOwnProperty(b.namespace_)){var e=JSON.parse(b.data);switch(e.type){case "CLOSE":this.h.b.remove([a.channelId,b.destinationId,b.sourceId].join("#"));return;case "RPC":break;default:Ab(Qk,function(){return"Got message "+(e.type||e.responseType)+" "+("from "+d.getId())})}}else Ab(Qk,"Got message in "+b.namespace_+" from "+d.getId());lo(this.j,d,b)}else v(Qk,"Got message for unknown receiver (receiverId="+
c+").")}else v(Qk,"Got message for unknown channel (channelId="+a.channelId+").")};var mo=function(a,b){a.s&&chrome.cast.channel.close(b,function(){chrome.runtime.lastError||Ab(Qk,"Channel close success")});var c=a.b.get(b.channelId);c&&(a.b.remove(b.channelId),a.f.remove(c))};io.prototype.u=function(a,b){v(Qk,function(){return"Channel error: "+JSON.stringify(a)+(b?", "+JSON.stringify(b):"")});b&&no(b);oo(this,a)};
var no=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(Qk,"Channel error code: "+b);Rb("MediaRouter.Cast.Channel.Error",b,ak)},oo=function(a,b){var c=a.b.get(b.channelId);mo(a,b);if(!a.s)Ab(Qk,"Close channel for receiver: "+c+", skip retry");else if(c){var d=a.ha(c);d&&fl(a,d,!0).then(function(c){Qk.info("Re-connected to receiver: "+d.getId());Rk(a.h,b,c);Sk(a.j.j,
d,!0)},function(){Qk.info("Failed to re-connect to receiver: "+d.getId());Vk(a.h,b);var c=a.j.b,f=d.getId();c.l.info("Channel error for sink "+f);Wk(c,f);dk(2)})}},fl=function(a,b,c){c=void 0===c?!1:c;var d=b.getId(),e=a.f.get(d);return e&&"open"==e.readyState?Promise.resolve(e):a.s?Tn(a.o,b,c).then(function(b){if(Ik(a.b,b.channelId))return b;a.f.get(d)&&(v(Qk,"Duplicate channel to a receiver "+d),mo(a,a.f.get(d)));Qk.info("Connected to: "+d);a.f.set(d,b);a.b.set(b.channelId,d);return b},null):(Qk.info("Channel not found for receiver: "+
d),Promise.reject(Error("Channel not found for receiver: "+d)))},jo=function(a,b,c,d,e,f){fo(a.h,b,e,f,0==f.indexOf("receiver-0"));em(d);var h=Xn(c,d,e,f);"object"===typeof d&&"RPC"==d.type||Ab(Qk,function(){return"Channel is sending message: "+JSON.stringify(h)});return new Promise(function(c,d){chrome.cast.channel.send(b,h,function(b){b?b.errorState?(d(Error("Failed to send message")),oo(a,b)):c(!0):(b=Nn("chrome.cast.channel.send",Qk),d(b))})})};io.prototype.ua=function(){return"cast.ChannelService"};
io.prototype.Ta=function(){return[new po(Kk(this.f),Kk(this.b),Kk(this.g))]};io.prototype.Ya=function(){var a=nj(this);a&&(Ek(this.f,a.f),Ek(this.b,a.b),Ek(this.g,a.h))};var Qk=tb("mr.cast.ChannelService"),po=function(a,b,c){this.f=a;this.b=b;this.h=c};var qo=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.f=this.b=!1},ro=function(){this.b=[]};ro.prototype.init=function(){qj(this)};ro.prototype.pa=function(){return this.b.length};var jm=function(a,b){return gc(a.b,function(a){return a.clientId==b})},so=function(a,b){return gc(a.b,function(a){return a.routeId==b})},to=function(a,b){a.b=ac(a.b,function(a){return a.clientId!=b})};ro.prototype.ua=function(){return"cast.ClientRecords"};
ro.prototype.Ta=function(){return[new uo(this.b)]};ro.prototype.Ya=function(){var a=nj(this);a&&(this.b=a.b)};var uo=function(a){this.b=a};var vo=function(a){this.b=a},wo=function(){var a=[];Kj().j.forEach(function(b){var c="Receiver-"+b.replace(/\./g,"_"),d=Kj().b||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};vo.prototype.init=function(){var a=wo(),b=this.b;b.K(a);b.D=a};var xo=function(){this.requestId=0;this.type="GET_APP_AVAILABILITY";this.appId=[]};var yo=function(a,b){this.g=a;this.f=b;this.h=new Ol;this.b=new Fk};yo.prototype.init=function(){qj(this)};var zo=function(a,b){var c=a.b.get(b);c&&(c.wi--,0<c.wi||(Ak(a.f.b.tb(!1),function(a){switch(Vj(a,b)){case "available":a.Nb[b]="available_rescan";break;case "unavailable":a.Nb[b]="unavailable_rescan"}}),a.b.remove(b)))};g=yo.prototype;
g.wk=function(a){var b=this;Ak(this.b.tb(!0),function(c){a:{switch(Vj(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.h.contains(e)||(b.h.add(e),d=function(){b.h.remove(e)},Ce(new Ae(b.Fn.bind(b,a,c),5500,3),2).start().then(b.vl.bind(b,a,c),function(){b.l.error("Failed to get app availability response for "+a.getId()+", appId "+c+" after 3 attempts.");b.vl(a,c,"unknown")}).then(d,d))}})};
g.vl=function(a,b,c){c!=Vj(a,b)&&(this.l.info(b+" on "+a.getId()+" is "+c),a.Nb[b]=c,Tk(this.f.f,a))};
g.Fn=function(a,b){var c=this,d=new xo;d.appId=[b];var e=new Fb("MediaRouter.Cast.App.Availability");return this.g.sendRequest(d,a,cj,5E3).then(function(a){e.b("Success");Ab(c.l,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.b("Failure");c.l.error("checkAppAvailability_ failed for "+a.getId()+", appId "+b);
throw d;})};g.ua=function(){return"cast.AppDiscoveryService"};g.Ta=function(){return[new Ao(Kk(this.b))]};g.Ya=function(){var a=nj(this);a&&Ek(this.b,a.b)};g.l=tb("mr.cast.AppDiscoveryService");var Ao=function(a){this.b=a};var Bo=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 Co=function(a,b){this.f=[];this.b=[];this.sinkId=a;this.session=b;this.s=this.g=null;this.offTheRecord=this.j=!1;this.controller=null;this.h=!0},Do=function(){this.l=tb("mr.cast.SessionRecords");this.b=[]};Do.prototype.init=function(){qj(this)};
var xn=function(a,b){a.l.info("Removing session "+b);Lm(a,b);a.b=ac(a.b,function(a){return a.session.sessionId!=b})},Um=function(a,b){return(a=fn(a,b))?a.f:[]},mn=function(a,b){return(a=on(a,b))?a.session:null},Eo=function(a,b){return gc(a.b,function(a){return ic(a.f,b)})},Dn=function(a,b){return gc(a.b,function(a){return ic(a.b,b)})},Fo=function(a,b){return gc(a.b,function(a){return null!=gc(a.b,function(a){return In(a).b==b})})},on=function(a,b){return gc(a.b,function(a){return a.sinkId==b||a.g==
b})},fn=function(a,b){return gc(a.b,function(a){return a.session.sessionId==b})},Zm=function(a,b){return(a=fn(a,b))?a.sinkId:null},Ym=function(a,b){return(a=fn(a,b))?a.session:null},vn=function(a,b,c){var d=Ym(a,b);d&&(a=ac(c,function(a){return a.playerState!=chrome.cast.media.me.IDLE}),a.forEach(function(a){if(!a.media){var b=gc(d.media,function(b){return b.mediaSessionId==a.mediaSessionId});b&&(a.media=b.media)}}),d.media=a)};Do.prototype.ua=function(){return"cast.SessionRecords"};
Do.prototype.Ta=function(){return[new Go(this.b)]};Do.prototype.Ya=function(){var a=nj(this);if(a)for(var b=0;b<a.b.length;b++){var c=a.b[b],d=new Co(c.sinkId,c.session);d.f=c.f;d.b=c.b;d.j=c.j;d.s=c.s;d.g=c.g;d.h=c.h;this.b.push(d)}};
var Lm=function(a,b){(a=fn(a,b))&&a.controller&&(a.controller.Ra(),a.controller=null)},Go=function(a){var b=[];a=ma(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=new Co(c.sinkId,c.session);d.f=c.f;d.b=c.b;d.j=c.j;d.s=c.s;d.g=c.g;d.offTheRecord=c.offTheRecord;d.h=c.h;b.push(d)}this.b=b};var Ho=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,Ho);else if(b=Error().stack)this.stack=b;this.errorCode=a};l(Ho,Error);var Io=function(a,b){this.sinks=a;this.origins=b||null},Jo=new Io([]);var Ko=function(a){this.A="sender-"+Vc();this.h=new Fk;this.o=null;qj(this);this.f=a;this.m=new ro;this.g=new Do;this.u=new io(this.A,this);this.b=new Mk(this.u,this);this.D=new vo(this.b);this.B=new zl(this.u,this.A);this.s=null;this.j=new Tm(this.B,this.b,this.m,this.g,this.u,this);this.F=new Sl(this.b,this.B);this.ka=this.b.start.bind(this.b);this.C=!0};g=Ko.prototype;g.getName=function(){return"cast"};
g.Xa=function(a){var b=a?a.enable_cast_discovery:!0;a=a&&"boolean"===typeof a.enable_cast_sink_query?a.enable_cast_sink_query:!0;this.l.info("Cast sink discovery enabled: "+b+", query enabled: "+a);this.B.init();this.g.init();this.j.init();this.u.init(b);this.b.init();this.D.init();a&&(this.s=new yo(this.B,this.b),this.s.init());(this.C=b)?this.f.vi(this.ka):this.b.stop()};g.Vc=function(){return this.h.ea()};
g.wf=function(a){var b=this;if(null!=Lo(a))return new Io([]);var c=new Ol;Mo(a).forEach(function(a){hl(b.b,a).map(function(a){return a.f}).forEach(function(a){c.add(a)})});return new Io(c.ea(),-1!=a.indexOf("0F5096E8")?Fg:null)};
g.startObservingMediaSinks=function(a){var b=this,c=Lo(a);c?(this.l.info("Received broadcast request "+a),Ak(this.b.b.tb(!1),function(a){b.B.sendMessage(c,a,gj).catch(function(a){b.l.error("Broadcast failed "+a.message)})})):this.s&&(Mo(a).forEach(function(a){var c=b.s,d=c.b.get(a);d?d.wi++:c.b.set(a,{wi:1});c.l.info("Scanning sinks for app availability");Ak(c.f.b.tb(!1),c.wk,c)}),this.C&&this.f.Qh()&&this.b.start())};
g.stopObservingMediaSinks=function(a){var b=this;null!=Lo(a)||this.s&&Mo(a).forEach(function(a){zo(b.s,a)})};g.startObservingMediaRoutes=function(){};g.stopObservingMediaRoutes=function(){};g.ha=function(a){return(a=this.b.ha(a))?a.f:null};
var No=function(a,b,c){a.l.error("Error launching.",c);jn(a,b.id,!1,!0,"error");c=new Mf(Bo,"warning");c.routeId=b.id;a.f.wd(c)},Qo=function(a,b,c,d,e,f,h,k){Kj().h=new Hj(c.Sb,c.eb());var n=Ln(b,c,d,!0);n.forDisplay=!1;n.offTheRecord=e;a.h.set(n.id,n);a.f.Pe(a,n);yn(a);(e=Am(b))&&e.b&&Oo(a,e,n.id,h,k);Dg(b)||Eg(b)?(n.wb={tabId:k,sessionId:"",Vf:c.eb()||"",je:c.Sb||"",Yp:c.f.friendlyName||""},Eg(b)&&(n.isOffscreenPresentation=!0),a.f.Wh(a,n,d,function(e){return Tf(Po(a,b,c,d,f,h,k,e))}).b.then(function(){var b=
Dn(a.g,n.id);b.h=!1;Mn(b.session,n);b.controller&&(b.controller.j=!1,Hm(b.controller))},function(b){No(a,n,b)})):Po(a,b,c,d,f,h,k,n).then(null,function(b){No(a,n,b)});return Promise.resolve(n)},Po=function(a,b,c,d,e,f,h,k){return Cn(a.j,Ro(b,c,e),c).then(function(e){An(a,b,c,d,e,f,h,k);return k})};
Ko.prototype.createRoute=function(a,b,c,d,e,f,h){var k=this,n=this.b.ha(b);if(!n)return Sf(Error("No sink with ID "+b));var u=Bm(a);if(u){setTimeout(function(){Xm(k.j,u,n,chrome.cast.nf.CAST)},0);var z=function(){return Qo(k,a,n,c,d,e,f,h)},B=jm(this.m,u);if(B)return Tf(this.terminateRoute(B.routeId).then(z,z));if(f&&h&&(b=So(this,a,f,h,d,e,b)))return b}return Tf(Qo(this,a,n,c,d,e,f,h))};
var jn=function(a,b,c,d,e){d=void 0===d?!1:d;e=void 0===e?"closed":e;a.l.info("Remove route "+b);var f=so(a.m,b);if(f){c=c||f.f;var h=f.clientId;a.l.info("Remove client "+h);for(var k=a.g,n=0;n<k.b.length;n++)pc(k.b[n].f,h);to(a.m,h)}if(h=Dn(a.g,b))pc(h.b,b),To(a,h.b);if(k=a.h.get(b))if(k.se&&h&&(rn(a.u,k.sinkId,f?f.clientId:a.A,h.session.transportId,c),k.forDisplay&&f&&(a.o={qe:f,il:h})),a.h.remove(b),a.f.Gf(k),yn(a),d)a.f.onPresentationConnectionClosed(b,e,"Remove route");else a.f.onPresentationConnectionStateChanged(b,
"terminated")},zn=function(a,b){b.b.forEach(function(c){if(c=a.h.get(c)){var d=b.session;if(c.forDisplay){var e=Fn(d.appId);e&&!c.isLocal?(c.description=d.statusText||"",d.displayName="",d.statusText=""):e||(c.description=d.statusText||d.displayName);b.controller&&Hm(b.controller)}a.f.ae(c)}})},Uo=function(a,b){dc(b,function(b){b=a.h.get(b,null);if(!b||!b.mediaSource)return!1;var c=Am(b.mediaSource);c=c?c.o:!1;return b.isLocal&&!c})&&w(b,function(b){if(b=a.h.get(b,null))b.isLocal=!0})},To=function(a,
b){var c=[],d=[],e=null;b.forEach(function(b){if(b=a.h.get(b)){b.forDisplay=!1;var f=Am(b.mediaSource);f&&gc(vm(f),gm)||(b.se?(f=f?wm(f):null,e||f==chrome.cast.Qc.CUSTOM_CONTROLLER_SCOPED||(c.push(b),e=b.sinkId)):e&&e!=b.sinkId?c.push(b):d.push(b))}});w(0<c.length?c:d,function(a){a.forDisplay=!0})},Oo=function(a,b,c,d,e){var f=b.b;if(f&&!jm(a.m,f)){a.l.info("Add client "+f);var h=vm(b);a.m.b.push(new qo(c,f,h,wm(b),d||null,Qa(e)?e:null))}},An=function(a,b,c,d,e,f,h,k){var n=on(a.g,c.getId());if(!n){var u=
a.g;n=c.getId();u.l.info("Adding new session: "+n+", "+e.sessionId);var z=fn(u,e.sessionId);z?(am(e)?(z.s=e,z.g=n):am(z.session)&&(z.s=z.session,z.g=z.sinkId,z.session=e,z.sinkId=n),n=z):(n=new Co(n,e),u.b.push(n))}k&&k.isLocal&&k.wb&&(n.h=!1);var B=null!=b;if(!B&&gm(e.appId))return null;null==b?(z=new rm([{appId:e.appId,capabilities:e.capabilities}]),b=xm(z)[0]):z=Am(b);if(u=k){if(!a.h.get(u.id))return v(a.l,"Route "+u.id+" not added"),u}else u=Ln(b,c,d||e.sessionId,B),a.h.set(u.id,u);d=u.id;a.l.info("Add route "+
d);b=null;z&&(b=z.b,Oo(a,z,d,f,h));ic(n.b,d)||n.b.push(d);u.se&&ko(a.u,c,b||a.A,e.transportId,!(z&&z.o));n.offTheRecord=u.offTheRecord;f=n.b;Uo(a,f);To(a,f);f=u;h=e.sessionId;Fn(e.appId)?f.isLocal&&h&&f.wb?f.wb.sessionId=h:(f.description=e.statusText||"",e.displayName="",e.statusText=""):f.description=e.statusText||e.displayName;k?a.f.ae(u):a.f.Pe(a,u);yn(a);if(k=b)ic(n.f,b)?k=!1:(n.f.push(b),k=!0);k&&(a=a.j,nm(a.f,b,new hm("new_session",e)),kn(a,e,c));return u};
Ko.prototype.terminateRoute=function(a){var b=this,c=this.h.get(a);if(!c)return Promise.reject(new Ho(3,"Route in Cast provider not found for routeId  "+a));var d=Dn(this.g,a);if(!d)return jn(this,a,!0),Promise.resolve();var e=d.session.sessionId,f=this.b.ha(c.sinkId);if(!f)return gn(this.j,e),Promise.resolve();(a=so(this.m,a))&&Xm(this.j,a.clientId,f,chrome.cast.nf.STOP);dk(0);return new Promise(function(a){var c=function(){wn(b.j,f.getId());a()};b.B.sendRequest(new wl(e),f,cj).then(c,c)})};
var Vo=function(a,b){var c=null;Bk(a.h.tb(!1),function(d){if(!d.se)return!1;var e=a.b.ha(d.sinkId);if(!e||!zm(b,Ro(d.mediaSource,e)))return!1;c=d;return!0});if(!c||!c.mediaSource)return null;var d=Bm(c.mediaSource);if(!d)return null;var e=jm(a.m,d);return e?(d=Eo(a.g,d))?{qe:e,il:d}:null:null},So=function(a,b,c,d,e,f,h){var k=null;Bk(a.h.tb(!1),function(a){var b=a.wb;return b&&null!=b.tabId&&b.tabId==d&&Bg(a.mediaSource)?(k=a,!0):!1});if(!k)return null;var n=function(){return a.createRoute(b,h||k.sinkId,
"",e,f,c,null==d?void 0:d)};return Tf(a.terminateRoute(k.id).then(n,n))};g=Ko.prototype;g.connectRouteByRouteId=function(a,b,c,d,e){if(!Am(a))return Sf(Error("Unsupported presentation URL"));if(!b)return Sf(Error("No routeId"));b=In(b);b=fn(this.g,b.b);if(!b)return Sf(Error("No matching route"));var f=this.b.ha(b.sinkId);return f?(a=An(this,a,f,c,b.session,d,e))?Rf(a):Sf(Error("Failed to create route")):Sf(Error("No sink"))};
g.joinRoute=function(a,b,c,d,e,f){var h=Am(a);if(!h)return Sf(Error("Unsupported presentation URL"));if(b==chrome.cast.Oi){a:{var k=Vo(this,h);if(!k){if(!this.o||this.o.qe.origin!=e||this.o.qe.tabId!=f){k=null;break a}k=this.o}switch(wm(h)){case chrome.cast.Qc.PAGE_SCOPED:k=null;break a;case chrome.cast.Qc.ORIGIN_SCOPED:if(e!=k.qe.origin){k=null;break a}break;case chrome.cast.Qc.TAB_AND_ORIGIN_SCOPED:if(e!=k.qe.origin||f!=k.qe.tabId){k=null;break a}}k=fn(this.g,k.il.session.sessionId)}if(!k&&(h.h?
h.h:chrome.cast.cg.CREATE_SESSION)!=chrome.cast.cg.CAST_THIS_TAB&&(d=So(this,a,e,f,c,d)))return d}else k=Wo(this,b);if(!k)return Sf(Error("No matching route"));if(k.offTheRecord!=c)return Sf(Error("Off the record mismatch"));d=this.b.ha(k.sinkId);if(!d)return Sf(Error("No sink"));a=An(this,a,d,b,k.session,e,f);a.offTheRecord=c;return Rf(a)};g.detachRoute=function(a){jn(this,a,!1,!0)};
g.De=function(a){var b=this.b.ha(a);if(!b)throw Error("Cannot mirror with no sink.");var c=new Xg;b=b.b;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;Yg(c);Object.freeze(c);this.l.info(function(){return"Settings for "+a+": "+Wg(c)});if(!c.shouldCaptureAudio&&!c.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture");
return c};g.Sd=function(){return"cast_streaming"};g.Qg=function(a){var b=this.h.get(a);b&&b.wb&&b.wb.Wb&&(a=Dn(this.g,a))&&(Mn(a.session,b),a.controller&&Hm(a.controller))};
g.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.j.f;Ab(lm,"Received: "+b);var e=JSON.parse(b),f=e.clientId;"client_connect"==e.type?(Ab(lm,"App "+f),(e=jm(c.b,f))?(e.b=!0,(c=tl(c.f,e.routeId))&&c.kb.resolve(!0)):v(lm,"Client not found "+f)):km(c,f)?(c=c.h[e.type])&&c(e):v(lm,"No route for "+f);a()});var e=Dn(this.g,a);if(!e)return Promise.reject(Error("Not managing the route "+
a));var f=this.b.ha(e.sinkId);if(!f)return Promise.reject(Error("Sink no longer accessible"));var h=(a=so(this.m,a))?a.clientId:this.A;return new Promise(function(a){Cl(d.u,f,c.namespace,b,h,e.session.transportId).then(a,a)})};g.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};g.qf=function(a,b){var c=this.b.ha(b);if(!c)return!1;if(!this.s)return!0;a=Ro(a,c);return(a=ym(a))&&0!=a.length?dc(a,function(a){return ij(Vj(c,a))}):!1};
g.oe=function(a,b,c){var d=Mo(a);return d&&0!=d.length?b==chrome.cast.Oi?!0:c&&c.mediaSource?(a=ym(c.mediaSource),dc(a,function(a){return ic(d,a)})):void 0==b||Wo(this,b)?!0:!1:!1};
var Ro=function(a,b,c){return Dg(a)||Eg(a)?(a={appId:0==(b.b&1)?"85CDB22F":"0F5096E8",capabilities:cm(b.b)},xm(new rm([a],void 0,void 0,void 0,c))[0]):a},Mo=function(a){var b=[];if(Dg(a)||Eg(a)){var c=Yf();Cg(a)&&"ChromeOS"!=c&&"Windows"!=c||b.push("85CDB22F");b.push("0F5096E8")}else(a=ym(a))&&(b=sc(b,a));return b},Lo=function(a){var b=Am(a);if(!b)return null;a=Mo(a);var c=b.m||"";b=b.s;return c&&b?new ul(a,c,JSON.stringify(b)):null},Wo=function(a,b){return 0==b.indexOf(chrome.cast.fj)?fn(a.g,b.substr(chrome.cast.fj.length)):
Fo(a.g,b)},lo=function(a,b,c){var d=a.F;if(Tl(d)&&hj.hasOwnProperty(c.namespace_)){var e=b.eb();if(e){var f=JSON.parse(c.data);if("RECEIVER_STATUS"===f.type){var h=f.status&&f.status.applications&&f.status.applications[0],k=f=null;h&&(h.appId&&(f=h.appId),h.sessionId&&(k=h.sessionId));h=d.f.get(e);d.f.set(e,new Zi(e,f,k));h&&h.appId===f||Ul(d)}}}a=a.j;b=b.getId();hj.hasOwnProperty(c.namespace_)?sn(a,b,c):tn(a,b,c)};
Ko.prototype.L=function(a){if(0==this.b.b.pa())this.f.onSinkAvailabilityUpdated(this,0);var b=this.j;a=a.getId();(a=on(b.b,a))&&a.session&&gn(b,a.session.sessionId);Vl(this.F);this.f.Jc()};var Tk=function(a,b){a.s&&a.s.wk(b);Vl(a.F);a.f.Jc()};g=Ko.prototype;g.ua=function(){return"cast.Provider"};g.Ta=function(){return[new Xo(this.A,Kk(this.h),this.o)]};g.Ya=function(){var a=nj(this);a&&(this.A=a.h,Ek(this.h,a.f),this.o=a.b)};g.searchSinks=function(){return qb()};
g.createMediaRouteController=function(a,b,c){return(a=this.j.createMediaRouteController(a,b,c))?Promise.reject(a):Promise.resolve()};g.provideSinks=function(a){Yk(this.b,a)};var yn=function(a){var b=a.Vc().some(function(a){return a.isLocal});a.f.Te(a.ua(),b)};Ko.prototype.l=tb("mr.CastProvider");var Xo=function(a,b,c){this.h=a;this.f=b;this.b=c};var Yo={ds:0,pv:1,iu:2,cs:3},Zo=function(a){Rb("MediaRouter.Dial.Create.Route",a,Yo)};var $o=function(a,b){this.h=a;this.f=b;this.b=this.h.b;this.l=tb("mr.cast.CastDialSinkDiscoveryCallbacks");this.g=!0},ap=function(a,b){var c=a.b.ha(b.getId());if(c)return c;(b=b.eb())?(a=a.b,c=Kj().b||8009,a=a.m.get(b+":"+c)):a=null;return a};$o.prototype.Ef=function(a){ap(this,a)?gk(2):bp(this,a);this.f.Ef(a)};var bp=function(a,b){if(a.h.C||a.g){var c=Sj(b);c&&bl(a.b,c).then(function(d){d?ap(a,b)?gk(2):(Uk(a.b,c),gk(0)):Qb("MediaRouter.Dial.Sink.Discovered.NonCast")},Ya)}};
$o.prototype.Ff=function(a){var b=this;w(a,function(a){var c=b.b.ha(a.getId());c&&c.pd&&Wk(b.b,a.getId())});this.f.Ff(a)};$o.prototype.Ne=function(a){var b=this.b.ha(a.getId());b?b.pd&&(b.update(a.Hb.friendlyName,a.eb(),b.Sa(),b.b)&&this.l.info("Updated Cast sink with DIAL sink: "+a.getId()),Tk(this.b.f,b)):bp(this,a);this.f.Ne(a)};var cp=function(){this.b=[]};cp.prototype.listen=function(a,b,c){this.b.push({type:a,pb:b,target:c})};var dp=function(a,b,c){var d=a.b.findIndex(function(a){return"internal_message"==a.type&&a.pb==b&&a.target==c});-1!=d&&a.b.splice(d,1)},ep=function(a,b){a.b.forEach(function(a){a.type==b.type&&Promise.resolve().then(function(){return a.pb.call(a.target,b)})})};var fp=function(a,b,c,d){b="["+b+"]: "+c+" "+d.responseURL+" => "+d.status+" ("+d.statusText+")";200<=d.status&&299>=d.status?a.info(b):Ab(a,b)};var gp=function(){this.name="unknown";this.state="error";this.b=null;this.allowStop=!0;this.resource=null;this.extraData={}},hp=function(){var a=Error.call(this);this.message=a.message;"stack"in a&&(this.stack=a.stack)};l(hp,Error);var jp=function(a){if(void 0===b){ip||(ip=new De(10,2E3));var b=ip}this.f=a;this.b=b;this.l=tb("mr.dial.Client")};
jp.prototype.launchApp=function(a,b){var c=this;return this.b.send(kp(this,a),"POST",b,{timeoutMillis:15E3}).then(function(a){return lp(c,"launchApp","POST",a)})};
var np=function(a,b){return mp(a,b).then(function(c){return c.resource?c.resource:(v(a.l,"stopApp: Resource path for not available for app "+b+": using fallback path."),"run")},function(){v(a.l,"stopApp: getAppInfo failed: using fallback path.");return"run"}).then(function(c){return a.b.send(kp(a,b)+"/"+c,"DELETE")}).then(function(b){return lp(a,"stopApp","DELETE",b)})},mp=function(a,b){return a.b.send(kp(a,b),"GET",void 0,{Ak:3}).then(function(c){fp(a.l,"GetAppInfo","GET",c);if(!(200<=c.status&&
299>=c.status)){if(404==c.status)throw new hp;throw Error("Response error: "+c.status);}c=c.responseText;c=(new DOMParser).parseFromString(c,"text/xml");c=c.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","parsererror").length?null:c;if(!c)throw a.l.info("Invalid or empty response"),Error("Invalid or empty response");var d=c.getElementsByTagName("service");if(!d||1!=d.length)throw a.l.info("Invalid GET response (invalid service)"),Error("Invalid GET response (invalid service)");c=new gp;for(var e=
0,f=d[0].childNodes.length;e<f;e++){var h=d[0].childNodes[e];if("state"==h.nodeName){a:switch(h.textContent){case "running":h="running";break a;case "stopped":h="stopped";break a;default:h="error"}c.state=h}else"name"==h.nodeName?c.name=h.textContent:"link"==h.localName?c.resource=h.getAttribute("href"):"options"==h.nodeName?c.allowStop="false"!=h.getAttribute("allowStop"):c.extraData[h.nodeName]=h.innerHTML}if("unknown"==c.name)throw a.l.info("GET response missing name value"),Error("GET response missing name value");
if(c.name!=b)throw a.l.info("GET app name mismatch"),Error("GET app name mismatch");if("error"==c.state)throw a.l.info("GET response missing state value"),Error("GET response missing state value");if((d=/installable=(.+)/.exec(c.state))&&d[1])c.state="installable",c.b=d[1];else if("running"!=c.state&&"stopped"!=c.state)throw a.l.info("GET response has invalid state value"),Error("GET response has invalid state value");return c})},kp=function(a,b){a=a.f.kd;"/"!=a.charAt(a.length-1)&&(a+="/");return a+
b},lp=function(a,b,c,d){return new Promise(function(e,f){fp(a.l,b,c,d);200<=d.status&&299>=d.status?e():f(Error(d.statusText))})},ip=null;var op=function(a,b){this.pc=a;this.appName=b};var pp=function(a){this.b=new Map;this.f=a};pp.prototype.init=function(){qj(this)};pp.prototype.clear=function(){this.b.clear()};pp.prototype.add=function(a){if(!this.b.get(a.pc.id)){this.b.set(a.pc.id,a);var b=this.f;qp(b);b.g.Pe(b,a.pc)}};var rp=function(a,b){a=ma(a.b);for(var c=a.next();!c.done;c=a.next())if(c=ma(c.value),c.next(),c=c.next().value,c.pc.sinkId==b)return c;return null},tp=function(a,b){var c=a.b.get(b);c&&(a.b.delete(b),sp(a.f,c))};
pp.prototype.Vc=function(){return Array.from(this.b.values(),function(a){return a.pc})};pp.prototype.ua=function(){return"dial.ActivityRecords"};pp.prototype.Ta=function(){return[Array.from(this.b)]};pp.prototype.Ya=function(){var a=nj(this);a&&(this.b=new Map(a))};var up=function(a){this.h=a;this.l=tb("mr.dial.SinkDiscoveryService");this.b=new Map;this.f={Ld:0,Xd:0};this.g=0};up.prototype.init=function(){qj(this)};
var xp=function(a,b){a.l.info("addSinks returned "+b.length+" sinks");Ab(a.l,function(){return"....the list is: "+JSON.stringify(b)});var c=new Set(a.b.keys());b.forEach(function(b){var d=b.sink_id,e=b.extra_data.dial_media_sink,f=vp.test(e.model_name);b=new Nj(b.name,d);b.Rb=e.ip_address.address_bytes?e.ip_address.address_bytes.join("."):e.ip_address.address.join(".");b.kd=e.app_url.url;b.Sb=e.model_name;b.Kd=!f;wp(a,b);c.delete(b.getId())});var d=[];c.forEach(function(b){var c=a.b.get(b);d.push(c);
a.b.delete(b)});0<d.length&&a.h.Ff(d);var e=a.b.size;a.f={Ld:e,Xd:e}},wp=function(a,b){Ab(a.l,"mayAddSink, id = "+b.getId());var c=a.b.get(b.getId());c?c.update(b)&&(Ab(a.l,"Updated sink "+c.getId()),a.h.Ne(c)):(Ab(a.l,function(){return"Adding new sink "+b.getId()+": "+("name = "+b.Hb.friendlyName+(b.Rb?", ip = "+b.Rb:"")+(b.Sb?", model = "+b.Sb:"")+", apps = "+JSON.stringify(b.Nb))}),a.b.set(b.getId(),b),a.h.Ef(b))};up.prototype.ha=function(a){return this.b.get(a)||null};
var zp=function(a,b){var c=[];a.b.forEach(function(a){"available"==Oj(a,b)&&c.push(a.Hb)});return new Io(c,yp[b])};up.prototype.Rd=function(){return this.f};up.prototype.ua=function(){return"dial.DialSinkDiscoveryService"};up.prototype.Ta=function(){return[new Ap(Array.from(this.b),this.f),{deviceCountMetricsRecordTime:this.g}]};
up.prototype.Ya=function(){var a=nj(this);if(a){for(var b=ma(a.sinks),c=b.next();!c.done;c=b.next())c=c.value,this.b.set(c[0],Pj(c[1]));this.f=a.deviceCounts}if(a=oj(this))this.g=a.deviceCountMetricsRecordTime};
var yp={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"]},vp=/Eureka Dongle|Chromecast Audio|Chromecast Ultra/i,
Ap=function(a,b){this.sinks=a;this.deviceCounts=b};var Bp=function(a,b){this.l=tb("mr.dial.AppDiscoveryService");this.b=new Set;this.f=a;this.s=b;this.j=new Map;this.m=new Map;this.h=null;this.g=!1};Bp.prototype.init=function(){qj(this)};Bp.prototype.start=function(){this.l.info("Starting periodic scanning.");this.g||(this.g=!0,Cp(this))};Bp.prototype.stop=function(){this.l.info("Stopping periodic scanning.");this.g&&(this.g=!1,this.h&&(clearTimeout(this.h),this.h=null),this.j.clear())};
var Cp=function(a){a.l.info("Start app status scan.");var b=[];Array.from(a.f.b.values()).forEach(function(c){b.push.apply(b,Dp(a,c))});Array.from(a.s.b.values()).forEach(function(c){b.push(Ep(a,c))});Lk(b).then(function(){a.g&&!a.h&&(Ab(a.l,"Scan complete; scheduling for next scan."),a.h=setTimeout(function(){Ab(a.l,"Start app status scan (timer-based)");a.h=null;Cp(a)},6E4))})},Dp=function(a,b){if(!b.Kd)return[];for(var c=[],d=ma(a.b),e=d.next();!e.done;e=d.next())c.push(a.o(e.value,b));return c};
Bp.prototype.o=function(a,b){var c=this;if("unknown"!=Oj(b,a)&&36E5>Date.now()-(b.pg[a]||0)||!b.Kd)return Promise.resolve();Ab(this.l,"Querying "+b.getId()+" for "+a+" to update app status");return Fp(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"}Gp(c,b,a,d)},function(d){d instanceof
hp?Gp(c,b,a,"unavailable"):(v(c.l,"Failed to process app availability; "+b.getId()+" does not support app availability"),b.Kd=!1)})};
var Ep=function(a,b){var c=a.f.ha(b.pc.sinkId);if(!c)return v(a.l,"Activity refers to nonexistent sink: "+b.pc.id),Promise.resolve();if(!c.Kd)return Promise.resolve();var d=b.appName;Ab(a.l,"Querying "+c.getId()+" for "+d+" to update activity");return Fp(a,c,d).then(function(b){"running"!=b.state&&Hp(a,c,d)},function(){return Hp(a,c,d)})},Ip=function(a,b){var c=a.m.get(b.getId());c||(c=new jp(b),Ab(a.l,"Created DIAL client for "+b.getId()),a.m.set(b.getId(),c));return c},Fp=function(a,b,c){var d=
Jp(b,c),e=a.j.get(d);if(e)return e;e=mp(Ip(a,b),c);a.j.set(d,e);b=function(){a.j.delete(d)};e.then(b,b);return e},Jp=function(a,b){return a.getId()+":"+b},Gp=function(a,b,c,d){Ab(a.l,"Got app status "+d+" from "+b.getId()+" for "+c);var e=Oj(b,c);b.Nb[c]=d;b.pg[c]=Date.now();d!=e&&a.f.h.Ne(b)},Hp=function(a,b,c){(b=rp(a.s,b.getId()))&&b.appName==c&&tp(a.s,b.pc.id)},Kp=function(a,b){return Array.from(a.f.b.values()).some(function(a){return"unknown"==Oj(a,b)})};Bp.prototype.ua=function(){return"dial.AppDiscoveryService"};
Bp.prototype.Ta=function(){return[Array.from(this.b)]};Bp.prototype.Ya=function(){var a=nj(this);this.b=new Set(a||[])};var Lp=function(a,b){this.appName=a;this.launchParameter=void 0===b?"":b},Op=function(a){try{var b=new URL(a)}catch(c){return Mp.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=Cj(b)}catch(c){v(Mp,"Invalid base64 encoded postData:"+b);a=null;break a}a=new Lp(a,b)}else v(Mp,"Invalid app name: "+a),a=null;return a;case "https:":return Np(b);default:return Ab(Mp,"Unhandled protocol: "+b.protocol),null}},
Np=function(a){var b=a.hash;if(!b)return null;a=(a=Pp.exec(b))?a[1]:null;if(!a)return null;a=decodeURIComponent(a);if(b=(b=Qp.exec(b))?b[1]:void 0)try{b=Cj(b)}catch(c){return v(Mp,"Invalid base64 encoded postData:"+b),null}return new Lp(a,b)},Mp=tb("mr.dial.PresentationUrl"),Pp=/__dialAppName__=([A-Za-z0-9-._~!$&'()*+,;=%]+)/,Qp=/__dialPostData__=([A-Za-z0-9]+={0,2})/;var Rp=function(a,b){this.g=a;this.f=b||new up(this);this.h=new pp(this);this.b=null;this.l=tb("mr.DialProvider")};g=Rp.prototype;g.getName=function(){return"dial"};g.Rd=function(){return this.f.Rd()};g.Xa=function(a){a=a&&0==a.enable_dial_sink_query?!1:!0;this.l.info("Dial sink query enabled: "+a+"...");this.h.init();this.f.init();a?(this.b=this.b||new Bp(this.f,this.h),this.b.init()):this.b=null;qp(this)};
g.wf=function(a){if(!this.b)return Jo;Ab(this.l,"GetAvailableSinks for "+a);return(a=Op(a))?zp(this.f,a.appName):Jo};g.startObservingMediaSinks=function(a){if(this.b){var b=Op(a);if(b){a=this.b;b=b.appName;if(!a.b.has(b)||Kp(a,b))a.b.add(b),0!=a.f.b.size&&(a.g?Array.from(a.f.b.values()).forEach(a.o.bind(a,b)):a.start());qp(this)}}};g.stopObservingMediaSinks=function(a){this.b&&(a=Op(a))&&(this.b.b.delete(a.appName),Sp(this))};g.startObservingMediaRoutes=function(){qp(this)};
g.stopObservingMediaRoutes=function(){Sp(this)};var Sp=function(a){a.b&&(0==a.f.b.size||0==a.b.b.size&&0==a.h.b.size)&&a.b.stop()},qp=function(a){a.b&&0<a.f.b.size&&(0<a.b.b.size||0<a.h.b.size)&&a.b.start()};g=Rp.prototype;g.ha=function(a){return(a=this.f.ha(a))?a.Hb:null};g.Vc=function(){return this.h.Vc()};
g.createRoute=function(a,b,c,d){var e=this,f=this.f.ha(b);if(!f)return Zo(0),Sf(Error("Unkown sink: "+b));Kj().h=new Hj(f.Sb,f.eb());var h=Op(a);if(!h)return Sf(Error("No app name set."));var k=h.appName,n=new jp(f);return Tf(mp(n,k).then(function(a){if("running"==a.state)return np(n,k)}).then(function(){return n.launchApp(k,h.launchParameter)}).then(function(){return Tp(e,b,a,k,c,d)}).catch(function(a){Zo(3);throw a;}))};g.joinRoute=function(){return Sf(Error("Not supported"))};
g.connectRouteByRouteId=function(){return Sf(Error("Not supported"))};g.detachRoute=function(){};var Tp=function(a,b,c,d,e,f){Zo(1);b=Kn(e,a.getName(),b,c,!0,d);b.offTheRecord=f;a.h.add(new op(b,d));return b};Rp.prototype.Ef=function(a){this.g.onSinkAvailabilityUpdated(this,1);this.b&&(qp(this),Dp(this.b,a));this.g.Jc();Kj().f=new Hj(a.Sb,a.eb())};
Rp.prototype.Ff=function(a){var b=this;if(0==this.f.b.size)this.g.onSinkAvailabilityUpdated(this,0);Sp(this);a.forEach(function(a){var c=b.h;a=a.getId();if(a=rp(c,a))c.b.delete(a.pc.id),sp(c.f,a)});this.g.Jc()};Rp.prototype.Ne=function(){this.g.Jc()};var sp=function(a,b){b=b.pc;if(b.isLocal)a.g.onPresentationConnectionStateChanged(b.id,"terminated");Sp(a);a.g.Gf(b)};g=Rp.prototype;
g.terminateRoute=function(a){var b=this.h.b.get(a)||null;if(!b)return Promise.reject(new Ho(3,"Route in DIAL provider not found for routeId "+a));tp(this.h,a);return(a=this.f.ha(b.pc.sinkId))?np(new jp(a),b.appName):Promise.reject(new Ho(3,"Sink in DIAL provider not found for sinkId "+b.pc.sinkId))};g.De=function(){throw Error("Not implemented.");};g.Sd=function(){return null};g.Qg=function(){};g.sendRouteMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};
g.sendRouteBinaryMessage=function(){return Promise.reject(Error("DIAL sending messages is not supported"))};g.qf=function(a,b){b=this.f.ha(b);return!b||Dg(a)?!1:(a=Op(a))?"available"==Oj(b,a.appName):!1};g.oe=function(){return!1};g.searchSinks=function(){return qb()};g.createMediaRouteController=function(){return qb()};g.provideSinks=function(a){xp(this.f,a)};var Up=function(a,b){this.o=new $o(b,this);this.m=new up(this.o);this.h=new Fk;this.f=a;this.s=this.j=0;this.g=new Ol;this.b=new Rp(this,this.m)};g=Up.prototype;g.ua=function(){return"cast.DialProviderWrapper"};g.Ta=function(){return[new Vp(Kk(this.h),this.j,this.s,this.g.ea())]};g.Ya=function(){var a=nj(this);a&&(Ek(this.h,a.f),this.j=a.sequenceNumber,this.s=a.h,Nl(this.g,a.b))};g.getName=function(){return this.b.getName()};
g.Xa=function(a){this.b.Xa(a);qj(this);this.o.g=a?a.enable_dial_discovery:!0};g.Vc=function(){return this.b.Vc()};g.wf=function(a){return(a=Wp(a))?this.b.wf(a):Jo};g.startObservingMediaSinks=function(a){(a=Wp(a))&&this.b.startObservingMediaSinks(a)};g.stopObservingMediaSinks=function(a){(a=Wp(a))&&this.b.stopObservingMediaSinks(a)};g.startObservingMediaRoutes=function(a){(a=Wp(a))&&this.b.startObservingMediaRoutes(a)};g.stopObservingMediaRoutes=function(a){(a=Wp(a))&&this.b.stopObservingMediaRoutes(a)};
g.ha=function(a){return this.b.ha(a)};
var Zp=function(a,b,c,d,e){var f=Wp(b);if(!f)return Promise.reject(Error("Invalid source"));var h=Op(f),k=a.m.ha(c);if(!k)return Promise.reject(Error("Attempting custom launch with closed route"));var n=h.appName;if(!n)return Promise.reject(Error("No app name given"));var u=Xp(b);return u?mp(new jp(k),n).then(function(f){var z=Tp(a.b,c,b,n,e,d);f={routeId:z.id,sinkId:k.getId(),appName:n,xj:f,launchParameter:h.launchParameter,session:null,clientId:null};a.h.set(z.id,f);var D=Yp(a,f.sinkId),R=new hm("receiver_action",
{receiver:D,action:chrome.cast.nf.CAST});R.clientId=u;a.f.vd(f.routeId,R);R=chrome.cast.R;var la=String(a.s);a.s=(a.s+1)%9007199254740992;D=new R(la,"",f.appName,[],D);f.session=D;f.clientId=u;D=new hm("new_session",D);D.clientId=u;a.f.vd(f.routeId,D);return z}):Promise.reject(Error("No client ID"))};Up.prototype.createRoute=function(a,b,c,d,e,f,h){return a.startsWith("cast-dial:")||$p.test(a)?Tf(Zp(this,a,b,d,c)):this.b.createRoute(a,b,c,d,e,f,h)};
Up.prototype.terminateRoute=function(a){var b=this.h.get(a);if(b&&b.session&&b.clientId){var c={receiver:Yp(this,b.sinkId),action:chrome.cast.nf.STOP};c=new hm("receiver_action",c);c.clientId=b.clientId;this.f.vd(b.routeId,c);this.f.onPresentationConnectionStateChanged(b.routeId,"terminated")}return this.b.terminateRoute(a)};
Up.prototype.sendRouteMessage=function(a,b,c){var d=JSON.parse(b);switch(d.type){case "client_connect":return b=d.clientId,(a=this.h.get(a))?(c=Yp(this,a.sinkId),c.receiverType=chrome.cast.kg.DIAL,c=new hm("custom_dial_launch",new chrome.cast.Si(c,a.xj.state,a.xj.extraData)),c.clientId=b,b=this.j,this.j=(this.j+1)%9007199254740992,c.sequenceNumber=b,this.g.add(c.sequenceNumber),this.f.vd(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.h.get(a))?b&&!b.doLaunch?a=Promise.resolve():(c=this.m.ha(a.sinkId))?(c=new jp(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.b.sendRouteMessage(a,b,c)};
Up.prototype.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};var Yp=function(a,b){a=a.m.ha(b);b=Lj(Kj(),b);b=new chrome.cast.kh(b,a.Hb.friendlyName);b.ipAddress=a.eb();b.receiverType=chrome.cast.kg.DIAL;return b};g=Up.prototype;g.De=function(a){return this.b.De(a)};g.Sd=function(a){return this.b.Sd(a)};g.Qg=function(){};g.qf=function(a,b){return a.startsWith("cast-dial:")||$p.test(a)||this.b.qf(a,b)};
g.oe=function(a,b,c){return this.b.oe(a,b,c)};g.connectRouteByRouteId=function(a,b,c,d,e){return this.b.connectRouteByRouteId(a,b,c,d,e)};g.joinRoute=function(a,b,c,d,e,f){return this.b.joinRoute(a,b,c,d,e,f)};g.detachRoute=function(a){this.h.remove(a);this.b.detachRoute(a)};g.Jc=function(){this.f.Jc()};g.onSinkAvailabilityUpdated=function(a,b){this.f.onSinkAvailabilityUpdated(a,b)};g.Pe=function(a,b){this.f.Pe(this,b)};g.Gf=function(a){this.f.Gf(a)};g.ae=function(a){this.f.ae(a)};g.hk=function(){};
g.vd=function(a,b){this.f.vd(a,b)};g.onPresentationConnectionStateChanged=function(a,b){this.f.onPresentationConnectionStateChanged(a,b)};g.onPresentationConnectionClosed=function(a,b,c){this.f.onPresentationConnectionClosed(a,b,c)};g.Eh=function(a){return this.f.Eh(a)};g.Gh=function(){return this.f.Gh()};g.wd=function(a){this.f.wd(a)};g.Pg=function(a,b){this.f.Pg(a,b)};g.fi=function(a){this.f.fi(a)};g.Ef=function(a){this.b.Ef(a)};g.Ff=function(a){this.b.Ff(a)};g.Ne=function(a){this.b.Ne(a)};
g.Wh=function(){};g.sk=function(){};g.searchSinks=function(a,b){return this.b.searchSinks(a,b)};g.provideSinks=function(a){this.b.provideSinks(a)};g.createMediaRouteController=function(){return qb()};g.vi=function(a){this.f.vi(a)};g.Qh=function(){return this.f.Qh()};g.Te=function(a,b){return this.f.Te(a,b)};g.Rd=function(){return this.b.Rd()};
var Wp=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 pm(c.pathname,c.searchParams.get("dialPostData"),c.searchParams.get("clientId"));c=a.h;var d=a.b}else if("https:"==b.protocol){a=Am(a);if(!a)return null;c=a.u;d=a.A}c?(a=d||"",c=new URL("dial:"+c),a&&c.searchParams.set("postData",a),c=c.toString()):c=null;return c},Xp=function(a){try{var b=new URL(a)}catch(c){return null}return"cast-dial:"==
b.protocol?b.searchParams.get("clientId"):"https:"==b.protocol?Bm(a):null},Vp=function(a,b,c,d){this.f=a;this.sequenceNumber=b;this.h=c;this.b=d},$p=/__dialAppName__/;var aq=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/,bq=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," ")):"")}}},cq=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},dq=/#|$/,eq=function(a,b){var c=a.search(dq);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," "))},fq=function(a,b){var c=a.length-1;0<=c&&
a.indexOf("/",c)==c&&(a=a.substr(0,a.length-1));Gc(b,"/")&&(b=b.substr(1));return Uc(a,"/",b)};var gq=function(a){this.Zb=this.s=this.h="";this.Pa=null;this.g=this.b="";this.j=!1;var b;a instanceof gq?(this.j=Qa(void 0)?void 0:a.j,hq(this,a.h),this.s=a.s,this.Zb=a.Zb,iq(this,a.Sa()),this.b=a.b,jq(this,a.f.clone()),this.g=a.g):a&&(b=String(a).match(aq))?(this.j=!1,hq(this,b[1]||"",!0),this.s=kq(b[2]||""),this.Zb=kq(b[3]||"",!0),iq(this,b[4]),this.b=kq(b[5]||"",!0),jq(this,b[6]||"",!0),this.g=kq(b[7]||"")):(this.j=!1,this.f=new lq(null,this.j))};
gq.prototype.toString=function(){var a=[],b=this.h;b&&a.push(mq(b,nq,!0),":");var c=this.Zb;if(c||"file"==b)a.push("//"),(b=this.s)&&a.push(mq(b,nq,!0),"@"),a.push(encodeURIComponent(String(c)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),c=this.Sa(),null!=c&&a.push(":",String(c));if(c=this.b)this.Zb&&"/"!=c.charAt(0)&&a.push("/"),a.push(mq(c,"/"==c.charAt(0)?oq:pq,!0));(c=this.f.toString())&&a.push("?",c);(c=this.g)&&a.push("#",mq(c,qq));return a.join("")};
gq.prototype.resolve=function(a){var b=this.clone(),c=!!a.h;c?hq(b,a.h):c=!!a.s;c?b.s=a.s:c=!!a.Zb;c?b.Zb=a.Zb:c=null!=a.Pa;var d=a.b;if(c)iq(b,a.Sa());else if(c=!!a.b){if("/"!=d.charAt(0))if(this.Zb&&!this.b)d="/"+d;else{var e=b.b.lastIndexOf("/");-1!=e&&(d=b.b.substr(0,e+1)+d)}e=d;if(".."==e||"."==e)d="";else if(-1!=e.indexOf("./")||-1!=e.indexOf("/.")){d=Gc(e,"/");e=e.split("/");for(var f=[],h=0;h<e.length;){var k=e[h++];"."==k?d&&h==e.length&&f.push(""):".."==k?((1<f.length||1==f.length&&""!=
f[0])&&f.pop(),d&&h==e.length&&f.push("")):(f.push(k),d=!0)}d=f.join("/")}else d=e}c?b.b=d:c=""!==a.f.toString();c?jq(b,a.f.clone()):c=!!a.g;c&&(b.g=a.g);return b};gq.prototype.clone=function(){return new gq(this)};var hq=function(a,b,c){a.h=c?kq(b,!0):b;a.h&&(a.h=a.h.replace(/:$/,""))};gq.prototype.Sa=function(){return this.Pa};
var iq=function(a,b){if(b){b=Number(b);if(isNaN(b)||0>b)throw Error("Bad port number "+b);a.Pa=b}else a.Pa=null},jq=function(a,b,c){b instanceof lq?(a.f=b,rq(a.f,a.j)):(c||(b=mq(b,sq)),a.f=new lq(b,a.j))},kq=function(a,b){return a?b?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""},mq=function(a,b,c){return Ra(a)?(a=encodeURI(a).replace(b,tq),c&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null},tq=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)},
nq=/[#\/\?@]/g,pq=/[#\?:]/g,oq=/[#\?]/g,sq=/[#\?@]/g,qq=/#/g,lq=function(a,b){this.f=this.b=null;this.h=a||null;this.g=!!b},uq=function(a){a.b||(a.b=new Fk,a.f=0,a.h&&bq(a.h,function(b,c){a.add(decodeURIComponent(b.replace(/\+/g," ")),c)}))},wq=function(a){var b=Il(a);if("undefined"==typeof b)throw Error("Keys are undefined");var c=new lq(null,void 0);a=Hl(a);for(var d=0;d<b.length;d++){var e=b[d],f=a[d];fb(f)?vq(c,e,f):c.add(e,f)}return c};g=lq.prototype;g.pa=function(){uq(this);return this.f};
g.add=function(a,b){uq(this);this.h=null;a=xq(this,a);var c=this.b.get(a);c||this.b.set(a,c=[]);c.push(b);this.f+=1;return this};g.remove=function(a){uq(this);a=xq(this,a);return Ik(this.b,a)?(this.h=null,this.f-=this.b.get(a).length,this.b.remove(a)):!1};g.clear=function(){this.b=this.h=null;this.f=0};g.cc=function(){uq(this);return 0==this.f};var yq=function(a,b){uq(a);b=xq(a,b);return Ik(a.b,b)};g=lq.prototype;g.re=function(a){var b=this.ea();return ic(b,a)};
g.forEach=function(a,b){uq(this);this.b.forEach(function(c,d){w(c,function(c){a.call(b,c,d,this)},this)},this)};g.ub=function(){uq(this);for(var a=this.b.ea(),b=this.b.ub(),c=[],d=0;d<b.length;d++)for(var e=a[d],f=0;f<e.length;f++)c.push(b[d]);return c};g.ea=function(a){uq(this);var b=[];if(Ra(a))yq(this,a)&&(b=sc(b,this.b.get(xq(this,a))));else{a=this.b.ea();for(var c=0;c<a.length;c++)b=sc(b,a[c])}return b};
g.set=function(a,b){uq(this);this.h=null;a=xq(this,a);yq(this,a)&&(this.f-=this.b.get(a).length);this.b.set(a,[b]);this.f+=1;return this};g.get=function(a,b){a=a?this.ea(a):[];return 0<a.length?String(a[0]):b};var vq=function(a,b,c){a.remove(b);0<c.length&&(a.h=null,a.b.set(xq(a,b),x(c)),a.f+=c.length)};
lq.prototype.toString=function(){if(this.h)return this.h;if(!this.b)return"";for(var a=[],b=this.b.ub(),c=0;c<b.length;c++){var d=b[c],e=encodeURIComponent(String(d));d=this.ea(d);for(var f=0;f<d.length;f++){var h=e;""!==d[f]&&(h+="="+encodeURIComponent(String(d[f])));a.push(h)}}return this.h=a.join("&")};lq.prototype.clone=function(){var a=new lq;a.h=this.h;this.b&&(a.b=this.b.clone(),a.f=this.f);return a};
var xq=function(a,b){b=String(b);a.g&&(b=b.toLowerCase());return b},rq=function(a,b){b&&!a.g&&(uq(a),a.h=null,a.b.forEach(function(a,b){var c=b.toLowerCase();b!=c&&(this.remove(b),vq(this,c,a))},a));a.g=b};lq.prototype.extend=function(a){for(var b=0;b<arguments.length;b++)Kl(arguments[b],function(a,b){this.add(b,a)},this)};var zq=function(a,b){this.input=a;this.domain=b};var Aq=function(a){this.b=a;this.l=tb("mr.ExternalMessageHandler")};
Aq.prototype.onMessage=function(a,b,c){var d=this;this.l.info("Received a message from "+b.id+" type: "+a.type);var e=chrome.runtime.id;"start"==a.type?(a=a.message,this.b.searchSinks("pseudo:cloud","urn:x-org.chromium.media:source:desktop",new zq(a.meetingName,a.domain)).then(function(a){var f="PresentationId"+b.id+Bq++;d.b.createRoute("urn:x-org.chromium.media:source:desktop",a,f).then(function(a){c(new Me(e,"route",a.id))}).catch(function(a){c(new Me(e,"error",a))})},function(){c(new Me(e,"error",
Error("Failed to find sink.")))})):"stop"==a.type?this.b.terminateRoute(a.message.routeId).then(function(){c(new Me(e,"stopped"))}):"subscribe_log_data"==a.type?(vb.push(function(a){chrome.runtime.sendMessage(b.id,new Me(e,"log_message",a))}),c(new Me(e,"subscribed"))):(c(new Me(e,"error",Error("Unhandled message type"))),this.l.error("Unhandled message type "+a.type))};var Bq=0;var Cq=function(){this.b=[];this.f=[]},Dq=function(a,b){if(1E3<=a.pa()){if(a.cc())throw Error("Empty queue");0==a.b.length&&(a.b=a.f,a.b.reverse(),a.f=[]);a.b.pop()}a.f.push(b)};Cq.prototype.pa=function(){return this.b.length+this.f.length};Cq.prototype.cc=function(){return 0==this.pa()};Cq.prototype.ea=function(){var a=this.b.slice();a.reverse();a.push.apply(a,xa(this.f));return a};Cq.prototype.clear=function(){this.b=[];this.f=[]};var Eq=function(){this.b=new Cq;this.f=Date.now()},Gq=function(){null==Fq&&(Fq=new Eq);return Fq};Eq.prototype.init=function(){ub=1;var a=tb("browser"),b=window.onerror;window.onerror=function(c,e,f,h,k){b&&b(c,e,f,h,k);a.error("Error: "+c+" ("+e+" @ Line: "+f+")",k)};vb.push(this.g.bind(this));var c=window.localStorage["debug.logs"];c&&(ub=Cb(c.toUpperCase()));(c=window.localStorage["debug.console"])&&"false"!=c.toLowerCase()&&vb.push(this.h.bind(this))};
Eq.prototype.g=function(a){Dq(this.b,Hq(this,a,!1));a=a.kc;a instanceof Error&&a.stack&&Dq(this.b,a.stack)};Eq.prototype.h=function(a){var b=[Hq(this,a,!0)];a.kc&&b.push(a.kc);switch(a.level){case 3:console.error.apply(console,xa(b));break;case 2:console.warn.apply(console,xa(b));break;case 1:console.log.apply(console,xa(b));break;default:console.debug.apply(console,xa(b))}};
var Hq=function(a,b,c){var d=["["];if(c)d.push(("       "+((Date.now()-a.f)/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("][",Bb[b.level],"][",b.J,"] ",b.message);if(!c&&null!=b.kc)if(d.push("\n"),b.kc instanceof Error)d.push(b.kc.message);else try{d.push(JSON.stringify(b.kc))}catch(f){d.push(b.kc.toString())}d.push("\n");
return d.join("")},Iq=function(){var a=Gq();return 0==a.b.pa()?"NA":a.b.ea().join("")},Jq=function(){var a=Gq();qj(a)};Eq.prototype.ua=function(){return"LogManager"};Eq.prototype.Ta=function(){return[this.b.ea()]};Eq.prototype.Ya=function(){var a=this.b.ea();this.b.clear();for(var b=ma(nj(this)||[]),c=b.next();!c.done;c=b.next())Dq(this.b,c.value);a=ma(a);for(c=a.next();!c.done;c=a.next())Dq(this.b,c.value)};var Fq=null;var Kq=function(a){this.b=a;this.l=tb("mr.InternalMessageHandler")};
Kq.prototype.onMessage=function(a,b,c){var d=this;if("retrieve_log_data"!=a.type)c(new Me(chrome.runtime.id,"error",Error("Unhandled message type")));else{var e={logs:Iq(),device:Mj()};b=[];var f=Le(e.device.ip).then(function(a){a.b&&(e.device.version=a.b)});b.push(f);var h=this.b.u;h&&(a=Lq(this,h,a.source).then(function(a){a&&(e.castStreamingLogs=a)},function(){d.l.error("Log upload failed for service: "+h)}),b.push(a));e.dialDeviceCounts=Mq(this);b.push(Nq(this,e));a=this.b.getMediaSinkServiceStatus().then(function(a){e.mediaSinkServiceStatus=
a.status},function(){d.l.error("Fail to get media sink service status")});b.push(a);Lk(b).then(function(){c(e)})}};var Nq=function(a,b){return rg("mr.cast.SinkDiscoveryService").then(function(a){a=a.Rd();b.castDeviceCounts=a.Xd+"."+a.Ld},function(){a.l.error("Failed to get device counts for castDeviceCounts.")})},Mq=function(a){a=Oq(a.b,"dial");if(!a)return"";a=a.Rd();return a.Xd+"."+a.Ld},Lq=function(a,b,c){return Pq(a.b,b).then(function(a){return a.di(c)})};var Qq={ACCEPTED:0,Pr:1,TIMEOUT:2},Rq={SUCCESS:0,Ql:1},Sq={an:0,um:1,rw:2,Gs:3,Fs:4,Nt:5,TIMEOUT:6,Qu:7},Tq={Ds:0,Mv:1},Uq={uu:0,tt:1,USER:2,ys:3},Vq=function(a){Rb("MediaRouter.Cloud.Knock.Result",a,Qq)},Wq=function(a){Rb("MediaRouter.Cloud.Session.Start",a,Rq)},Xq=function(a){Rb("MediaRouter.Cloud.Session.Type",a,Tq)},Yq=function(a){Rb("MediaRouter.Cloud.Device.UserRole",a,Uq)};var Zq=function(a,b){this.b=a;this.f=b},$q=new Zq("https://www.googleapis.com/clouddevices/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),ar=new Zq("https://castedumessaging-pa.googleapis.com/v1","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA"),br=new Zq("https://www.googleapis.com/calendar/v3",""),cr=new Zq("https://www.googleapis.com/hangouts/v1",""),dr=new Zq("https://networktraversal.googleapis.com/v1alpha","AIzaSyAOZM8ZYeov685QMjXT3sC7XNizfrTEKjA");var er=function(a,b,c,d,e,f){c=void 0===c?null:c;a||null==c&&(c="default");this.mk=a;this.Oa=b;this.Zb=c;this.Me=void 0===d?null:d;this.Cc=void 0===e?null:e;this.fe=void 0===f?null:f};er.prototype.f=function(){var a="";this.Cc?a=this.Cc:this.Me&&(a=this.Me);return a};er.prototype.Bc=function(){return this.mk};er.prototype.getId=function(){return this.Oa};er.prototype.merge=function(a){!this.fe&&a.fe&&(this.fe=a.fe);!this.Cc&&a.Cc&&(this.Cc=a.Cc);this.Cc&&a.Cc&&this.fe&&(this.Cc=a.Cc)};var fr=function(a,b){this.f=a;this.h=b;this.l=tb("mr.cloud.calendar.CalendarService")},jr=function(a){return gr(a,a.h.b).then(function(b){a.l.info(hr(b.length)+" events discovered before filtering.");return ir(a,b)},function(b){v(a.l,"Error getting Hangouts from calendar.",b);return[]})},hr=function(a){return 20<a?"20+":a.toString()},gr=function(a,b){var c=Date.now();return kr(a,b,new Date(c),new Date(c+9E5)).then(function(b){return b.filter(a.b)})};
fr.prototype.b=function(a){return!(!a.start||!a.end||a.start.date||a.end.date||!a.start.dateTime||!a.end.dateTime)};
var kr=function(a,b,c,d){b=lr(br.b,["calendars",b,"events"],{timeMin:c.toJSON(),timeMax:d.toJSON(),singleEvents:!0});Ab(a.l,"Retrieving Hangouts from Calendar: "+b);return nr(a.f,b,"GET").then(function(a){return a.items?a.items:[]})},ir=function(a,b){var c=[];b.filter(function(a){return a.hangoutLink}).forEach(function(b){var d=new gq(b.hangoutLink);if("meet.google.com"==d.Zb)c.push(new er(!0,d.b.substring(1),void 0,void 0,b.summary));else if(d=d.b.substring(12).split("/"),2==d.length){var f=ma(d);
d=f.next().value;f=f.next().value;if(-1!=d.indexOf(".")){var h=f;var k=d}c.push(new er(!1,f+"@"+d,k,h,b.summary,void 0))}else v(a.l,"Invalid hangout link from calendar event: "+b.hangoutLink)});a.l.info(hr(c.length)+" events discovered with Hangout links.");return c};var or=function(a){this.b=a;this.id=a.id;this.l=tb("mr.cloud.devices.WeaveDevice")};or.prototype.isAvailable=function(){if(this.getState().appStatus){var a="online"==this.b.connectionStatus,b="available"==this.getState().appStatus,c=pr(this,864E5);Ab(this.l,"Device id: "+this.id+", availability: GCM connected "+a+", app Available: "+b+", checked in: "+c);return a&&b&&c}a=pr(this,9E5);this.l.info("Availability for legacy receiver app: "+a);return a};
var pr=function(a,b){a=a.b.lastUpdateTimeMs?Number(a.b.lastUpdateTimeMs):null;return!!(a&&a>Date.now()-b)};or.prototype.f=function(){return this.getState().settings.receiverName};or.prototype.getId=function(){return this.id};or.prototype.getState=function(){return this.b.state._cloudCast};var qr=function(a){this.email=a;this.imageUrl=null},rr=function(a){this.type=a},sr=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};l(sr,rr);
var tr=function(a,b,c){this.name=a;this.parameters=b;this.minimalRole=null!=c?c:"user"},ur={_settings:{type:"string"},_presentationRequest:{type:"string"},_optMediaConstraints:{type:"string"},_webrtcMessage:{type:"string"},_user:{type:"string"}},vr=new tr("_knockingStartWebrtcSession",ur,"viewer"),wr=new tr("_startWebrtcSession",ur),xr=new tr("_stopSession",{},"viewer");var yr=function(a){this.s=a;this.f=this.h=this.b=null;this.j=this.g=!1;this.l=tb("mr.cloud.devices.WeaveDevicesService");qj(this)};yr.prototype.getDevice=function(a){a=lr($q.b,["devices",a]);return nr(this.s,a,"GET").then(function(a){return new or(a)})};
var zr=function(a,b){var c=lr($q.b,["devices"],b);return nr(a.s,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 or(a)});if(c=c.nextPageToken){var f=qd(b);f.token=c;return zr(a,f).then(function(a){return d.concat(a)})}return d})};yr.prototype.ua=function(){return"WeaveDevicesService"};yr.prototype.Ta=function(){return[new Ar(this.b,this.f,this.h)]};
yr.prototype.Ya=function(){var a=nj(this);a&&(this.b=a.no,this.f=a.gcmRegistrationId,this.h=a.mo)};
var Br=function(a){return new Promise(function(b,c){a.g?c(Error("Registering...")):(a.g=!0,a.f&&a.h&&a.h+864E5>=Date.now()?(a.g=!1,b(a.f)):chrome.gcm.register(["919648714761"],function(d){a.g=!1;d?(Ab(a.l,"Got GCM ID: "+d),a.f=d,a.h=Date.now(),a.b=null,b(d)):(v(a.l,"Error: "+chrome.runtime.lastError.message),a.f=null,a.h=null,a.b=null,c(Error(chrome.runtime.lastError.message)))}))})},Cr=function(a,b){if(a.j)Promise.resolve();else if(a.j=!0,b&&(!a.b||a.b+864E5<Date.now())){b={filters:["myDevices"],
gcmRegistrationId:b,gcmSenderId:"919648714761",expirationTimeMs:864E5};var c=lr($q.b,["subscriptions","subscribe"],{});nr(a.s,c,"POST",b).then(function(){Ab(a.l,"Subscribed on: "+Date.now());a.b=Date.now();a.j=!1;return Promise.resolve()},function(b){a.j=!1;throw b;})}else Promise.resolve()},Ar=function(a,b,c){this.no=a;this.gcmRegistrationId=b;this.mo=c};var Dr=function(a,b,c,d,e,f,h,k){var n=Lj(Kj(),a);this.Fa=new jj(n,b,h,k,e);this.deviceId=a;this.b=c;this.model=d;this.isAvailable=f},Er=function(a,b,c,d,e){Dr.call(this,a,b,"weave","Chrome Streaming Receiver",d,e,"education");this.nh=c};l(Er,Dr);var Fr=function(a){var b=a.Zb,c;a.Me&&a.f()!=a.Me&&(c=a.Me);Dr.call(this,a.getId(),a.f(),"mesi","Hangout",b,!1,a.Bc()?"meeting":"hangout",c);this.Bc=a.Bc();this.ee=a.fe||""};l(Fr,Dr);var Gr=function(a,b,c){Dr.call(this,a,b,"slarti","Cast Receiver for Education","default",c,"education")};l(Gr,Dr);var Hr=function(a,b,c){this.s=a;this.g=b;this.b=new Map;this.h=new Map;this.f=null;this.j=c};Hr.prototype.xd=function(){var a=this.f+this.j;if(null==this.f||a<Date.now())this.f=Date.now(),Ir(this);return Array.from(this.b.values())};Hr.prototype.ha=function(a){return this.b.get(a)||null};
var Ir=function(a){a.s().then(function(b){Jr(a,b)})},Jr=function(a,b){var c=new Map(a.b),d=new Map,e=new Map,f=[],h=[];b.forEach(function(a){var b=a.Fa.id;d.set(b,a);e.set(b,a.deviceId);c.has(b)?c.has(b)&&JSON.stringify(c.get(b))!=JSON.stringify(a)&&h.push(a.Fa):f.push(a.Fa);c.delete(b)});b=[].concat(xa(c.values())).map(function(a){return a.Fa});a.h.clear();a.h=e;a.b.clear();a.b=d;Kr(a,f,h,b)},Kr=function(a,b,c,d){0<b.length&&Lr(a.g,b);0<c.length&&Mr(a.g,c);0<d.length&&Nr(a.g,d)},Pr=function(a){for(var b=
{},c=ma(a.b.entries()),d=c.next();!d.done;d=c.next()){var e=ma(d.value);d=e.next().value;e=e.next().value;b[d]=e}c={};d=ma(a.h.entries());for(e=d.next();!e.done;e=d.next()){var f=ma(e.value);e=f.next().value;f=f.next().value;c[e]=f}return new Or(b,c,a.f)},Qr=function(a,b){for(var c in b.sinks){var d=b.sinks[c],e=null;"Hangout"==d.model?e=new Fr(new er(d.Bc,d.deviceId,d.Fa.domain,d.Fa.description,d.Fa.friendlyName,d.ee)):"Cast Receiver for Education"==d.model?e=new Gr(d.deviceId,d.Fa.friendlyName,
d.isAvailable):"Chrome Streaming Receiver"==d.model&&(e=new Er(d.deviceId,d.Fa.friendlyName,d.nh,d.Fa.domain,d.isAvailable));a.b.set(c,e)}for(c in b.b)a.h.set(c,b.b[c]);b.f&&(a.f=b.f)},Or=function(a,b,c){this.sinks=a;this.b=b;this.f=c};var Rr=function(a){var b=[],c=[],d={},e=function(a,h){var f=h+"  ";try{if(Qa(a))if(null===a)b.push("NULL");else if(Ra(a))b.push('"'+a.replace(/\n/g,"\n"+h)+'"');else if(hb(a))b.push(String(a).replace(/\n/g,"\n"+h));else if(ib(a)){a[jb]||c.push(a);var n=a[jb]||(a[jb]=++lb);if(d[n])b.push("*** reference loop detected (id="+n+") ***");else{d[n]=!0;b.push("{");for(var u in a)hb(a[u])||(b.push("\n"),b.push(f),b.push(u+" = "),e(a[u],f));b.push("\n"+h+"}");delete d[n]}}else b.push(a);else b.push("undefined")}catch(z){b.push("*** "+
z+" ***")}};e(a,"");for(a=0;a<c.length;a++)kb(c[a]);return b.join("")},Sr=function(a){var b=Sr;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(Tr(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("")},Tr=function(a){if(Ur[a])return Ur[a];a=String(a);if(!Ur[a]){var b=/function ([^\(]+)/.exec(a);Ur[a]=b?b[1]:"[Anonymous]"}return Ur[a]},Ur={},Vr=Object.freeze||function(a){return a};var Wr=function(a,b,c){this.reset(a,b,c,void 0,void 0)};Wr.prototype.b=null;var Xr=0;Wr.prototype.reset=function(a,b,c,d,e){"number"==typeof e||Xr++;this.j=d||q();this.f=a;this.g=b;this.h=c;delete this.b};Wr.prototype.getMessage=function(){return this.g};var Yr=function(a){this.j=a;this.b=this.g=this.f=this.h=null},Zr=function(a,b){this.name=a;this.value=b};Zr.prototype.toString=function(){return this.name};var $r=new Zr("SEVERE",1E3),as=new Zr("WARNING",900),bs=new Zr("INFO",800),cs=new Zr("CONFIG",700),ds=new Zr("FINE",500),es=new Zr("FINER",400),fs=new Zr("ALL",0);Yr.prototype.getName=function(){return this.j};Yr.prototype.getChildren=function(){this.g||(this.g={});return this.g};
var gs=function(a){if(a.f)return a.f;if(a.h)return gs(a.h);Xb("Root logger has no level set.");return null};Yr.prototype.log=function(a,b,c){a.value>=gs(this).value&&(hb(b)&&(b=b()),a=new Wr(a,String(b),this.j),c&&(a.b=c),hs(this,a))};Yr.prototype.info=function(a,b){this.log(bs,a,b)};Yr.prototype.config=function(a,b){this.log(cs,a,b)};Yr.prototype.logRecord=function(a){a.f.value>=gs(this).value&&hs(this,a)};
var hs=function(a,b){for(;a;){var c,d=a,e=b;if(d.b)for(var f=0;c=d.b[f];f++)c(e);a=a.h}},is={},js=null,ks=function(){js||(js=new Yr(""),is[""]=js,js.f=cs)},ls=function(a){ks();var b;if(!(b=is[a])){b=new Yr(a);var c=a.lastIndexOf("."),d=a.substr(c+1);c=ls(a.substr(0,c));c.getChildren()[d]=b;b.h=c;is[a]=b}return b};var ms=function(a,b,c,d){a&&a.log(b,c,d)},ns=function(a,b,c){a&&a.log($r,b,c)},os=function(a,b,c){a&&a.log(as,b,c)},W=function(a,b){a&&a.info(b,void 0)},ps=function(a,b){a&&a.log(ds,b,void 0)};var ss=function(a,b,c){if(!qs){ks();var d=js;d.f=fs;var e=rs;d.b||(d.b=[]);d.b.push(e);qs=!0}this.h=a;this.g=b;this.b=new Hr(this.j.bind(this),c,2E4);this.f=new Map;qj(this)},rs=function(a){wb({J:a.h,level:Eb(a.f.value),time:a.j,message:a.getMessage(),kc:a.b})};ss.prototype.xd=function(){return this.b.xd()};ss.prototype.ha=function(a){return this.b.ha(a)};
ss.prototype.j=function(){var a=this;this.l.info("Fetching hangouts");return Lk([ts(this.g),jr(this.h)]).then(function(b){var c=Array.from(a.f.values());b.forEach(function(b){b.qd?c=c.concat(b.value):a.l.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];Qb("MediaRouter.Cloud.Hangout.Sink.Discovered");return new Fr(a)})})};
var vs=function(a,b){return rg("mr.mirror.hangouts.MeetingsService").then(function(a){return a.lc(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 er(d,d?b:b+"@"+c,c,b,void 0,void 0);a.f.set(b.getId(),b);b=new Fr(b);a.b.b.set(b.Fa.id,b);return b.Fa};ss.prototype.ua=function(){return"HangoutSinkDiscoveryService"};
ss.prototype.Ta=function(){for(var a={},b=ma(this.f.entries()),c=b.next();!c.done;c=b.next()){var d=ma(c.value);c=d.next().value;d=d.next().value;a[c]=d}return[{cache:Pr(this.b),manualHangouts:a}]};ss.prototype.Ya=function(){var a=nj(this);if(a){Qr(this.b,a.cache);for(var b in a.manualHangouts){var c=a.manualHangouts[b];this.f.set(b,new er(c.mk,c.Oa,c.Zb,c.Me,c.Cc,c.fe))}}};ss.prototype.l=tb("mr.cloud.discovery.HangoutSinkDiscoveryService");var qs=!1;var ys=function(){this.f=!1;this.b=null;this.h=!1;this.l=tb("mr.cloud.identity.IdentityService");qj(this);ws(this);xs(this)},zs=function(a){return a.b?a.b.substr(a.b.indexOf("@")+1):""};ys.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 As=function(a){return new Promise(function(b){chrome.identity.removeCachedAuthToken({token:a},function(){b()})})},xs=function(a){a.getAuthToken().then(function(b){chrome.identity.getProfileUserInfo(function(c){a.f=!!c.email||!!c.id;a.b=c.email||null;b&&!a.f&&(a.h=!0)})},function(b){Ab(a.l,"Unable to set sign in and email.",b)})},ws=function(a){chrome.identity.onSignInChanged.addListener(function(b,c){Ag(6);a.f=c;a.l.info("Signed in change: "+a.f);a.f?xs(a):(a.b=null,a.h=!1)})},Bs=function(a){return a.getAuthToken().then(function(b){var c=
window.gapi;if(!c)return a.l.error("gapi not loaded."),!1;a.l.info("Setting gapi auth token");c.auth.setToken({access_token:b});return!0})};ys.prototype.ua=function(){return"IdentityService"};ys.prototype.Ta=function(){return[null,{signedIn:this.f,userEmail:this.b,kioskAuth:this.h}]};ys.prototype.Ya=function(){var a=oj(this);a&&(a.signedIn&&(this.f=a.signedIn),a.userEmail&&(this.b=a.userEmail),a.kioskAuth&&(this.h=a.kioskAuth))};var Cs="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 Ds=function(a){var b=a.method,c=a.uri,d=a.ic,e=a.qc,f=a.Rk,h=a.headers,k=a.body,n=a.start,u=a.apiKey,z=a.Wf;a=a.cb;this.method=b&&b.toUpperCase()||"GET";(b=c)||(d=[d].concat(xa(e||[])).join("/"),d=new gq(encodeURI(d)),f&&(f=wq(f),jq(d,f)),b=d);this.uri=b;u&&this.uri.f.add("key",u);this.b=a||null;this.headers=h||{};(this.body=k)&&(this.headers["Content-Type"]="application/json");this.Wf=Qa(z)?z:1E4;this.start=n||q()},Es=function(a){return(a.b?a.b.getAuthToken():Promise.resolve(null)).then(function(b){b&&
(a.headers.Authorization="Bearer "+b);b={method:a.method,headers:a.headers};a.body&&(b.body=JSON.stringify(a.body));return new Request(a.uri.toString(),b)})};var Fs=function(a,b){Ub.call(this,b&&b.message||a.statusText);this.code=a.status;this.response=a;this.status=b&&b.status};l(Fs,Ub);var Gs=function(a,b){a=new Response(void 0,{status:b||408,statusText:a});return new Fs(a)};var Hs=function(){this.s=this.s;this.ka=this.ka};Hs.prototype.s=!1;Hs.prototype.Ra=function(){this.s||(this.s=!0,this.ja())};Hs.prototype.h=function(a){Is(this,ob(Js,a))};var Is=function(a,b){a.s?Qa(void 0)?b.call(void 0):b():(a.ka||(a.ka=[]),a.ka.push(Qa(void 0)?p(b,void 0):b))};Hs.prototype.ja=function(){if(this.ka)for(;this.ka.length;)this.ka.shift()()};
var Js=function(a){a&&"function"==typeof a.Ra&&a.Ra()},Ks=function(a){for(var b=0,c=arguments.length;b<c;++b){var d=arguments[b];gb(d)?Ks.apply(null,d):Js(d)}};var X=function(a,b){this.type=a;this.f=this.target=b;this.bl=!0};X.prototype.g=function(){this.bl=!1};var Ls=!Ed||9<=Number(Zd),Ms=Ed&&!Yd("9"),Ns=function(){if(!Pa.addEventListener||!Object.defineProperty)return!1;var a=!1,b=Object.defineProperty({},"passive",{get:function(){a=!0}});Pa.addEventListener("test",Ya,b);Pa.removeEventListener("test",Ya,b);return a}();var Os=function(a,b){X.call(this,a?a.type:"");this.relatedTarget=this.f=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.b=null;a&&this.init(a,b)};t(Os,X);var Ps=Vr({2:"touch",3:"pen",4:"mouse"});
Os.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.f=b;(b=a.relatedTarget)?Gd&&(Ad(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=Ra(a.pointerType)?a.pointerType:Ps[a.pointerType]||"";this.state=a.state;this.b=a;a.defaultPrevented&&this.g()};
Os.prototype.g=function(){Os.ra.g.call(this);var a=this.b;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,Ms)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};var Qs="closure_listenable_"+(1E6*Math.random()|0),Rs=function(a){return!(!a||!a[Qs])},Ss=0;var Ts=function(a,b,c,d,e){this.listener=a;this.proxy=null;this.src=b;this.type=c;this.capture=!!d;this.pb=e;this.key=++Ss;this.removed=this.qg=!1},Us=function(a){a.removed=!0;a.listener=null;a.proxy=null;a.src=null;a.pb=null};var Vs=function(a){this.src=a;this.b={};this.f=0};Vs.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.b[f];a||(a=this.b[f]=[],this.f++);var h=Ws(a,b,d,e);-1<h?(b=a[h],c||(b.qg=!1)):(b=new Ts(b,this.src,f,!!d,e),b.qg=c,a.push(b));return b};Vs.prototype.remove=function(a,b,c,d){a=a.toString();if(!(a in this.b))return!1;var e=this.b[a];b=Ws(e,b,c,d);return-1<b?(Us(e[b]),oc(e,b),0==e.length&&(delete this.b[a],this.f--),!0):!1};
var Xs=function(a,b){var c=b.type;if(!(c in a.b))return!1;var d=pc(a.b[c],b);d&&(Us(b),0==a.b[c].length&&(delete a.b[c],a.f--));return d};Vs.prototype.removeAll=function(a){a=a&&a.toString();var b=0,c;for(c in this.b)if(!a||c==a){for(var d=this.b[c],e=0;e<d.length;e++)++b,Us(d[e]);delete this.b[c];this.f--}return b};var Ys=function(a,b,c,d,e){a=a.b[b.toString()];b=-1;a&&(b=Ws(a,c,d,e));return-1<b?a[b]:null};
Vs.prototype.hasListener=function(a,b){var c=Qa(a),d=c?a.toString():"",e=Qa(b);return fd(this.b,function(a){for(var f=0;f<a.length;++f)if(!(c&&a[f].type!=d||e&&a[f].capture!=b))return!0;return!1})};var Ws=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.pb==d)return e}return-1};var Zs="closure_lm_"+(1E6*Math.random()|0),$s={},at=0,ct=function(a,b,c,d,e){if(d&&d.once)return bt(a,b,c,d,e);if(fb(b)){for(var f=0;f<b.length;f++)ct(a,b[f],c,d,e);return null}c=dt(c);return Rs(a)?a.listen(b,c,ib(d)?!!d.capture:!!d,e):et(a,b,c,!1,d,e)},et=function(a,b,c,d,e,f){if(!b)throw Error("Invalid event type");var h=ib(e)?!!e.capture:!!e,k=ft(a);k||(a[Zs]=k=new Vs(a));c=k.add(b,c,d,h,f);if(c.proxy)return c;d=gt();c.proxy=d;d.src=a;d.listener=c;if(a.addEventListener)Ns||(e=h),void 0===e&&(e=
!1),a.addEventListener(b.toString(),d,e);else if(a.attachEvent)a.attachEvent(ht(b.toString()),d);else if(a.addListener&&a.removeListener)a.addListener(d);else throw Error("addEventListener and attachEvent are unavailable.");at++;return c},gt=function(){var a=it,b=Ls?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},bt=function(a,b,c,d,e){if(fb(b)){for(var f=0;f<b.length;f++)bt(a,b[f],c,d,e);return null}c=dt(c);return Rs(a)?jt(a,b,c,ib(d)?
!!d.capture:!!d,e):et(a,b,c,!0,d,e)},kt=function(a,b,c,d,e){if(fb(b))for(var f=0;f<b.length;f++)kt(a,b[f],c,d,e);else d=ib(d)?!!d.capture:!!d,c=dt(c),Rs(a)?a.F.remove(String(b),c,d,e):a&&(a=ft(a))&&(b=Ys(a,b,c,d,e))&&lt(b)},lt=function(a){if(m(a)||!a||a.removed)return!1;var b=a.src;if(Rs(b))return Xs(b.F,a);var c=a.type,d=a.proxy;b.removeEventListener?b.removeEventListener(c,d,a.capture):b.detachEvent?b.detachEvent(ht(c),d):b.addListener&&b.removeListener&&b.removeListener(d);at--;(c=ft(b))?(Xs(c,
a),0==c.f&&(c.src=null,b[Zs]=null)):Us(a);return!0},mt=function(a){if(a)if(Rs(a))a.xi(void 0);else if(a=ft(a)){var b=0,c;for(c in a.b)for(var d=a.b[c].concat(),e=0;e<d.length;++e)lt(d[e])&&++b}},ht=function(a){return a in $s?$s[a]:$s[a]="on"+a},ot=function(a,b,c,d){var e=!0;if(a=ft(a))if(b=a.b[b.toString()])for(b=b.concat(),a=0;a<b.length;a++){var f=b[a];f&&f.capture==c&&!f.removed&&(f=nt(f,d),e=e&&!1!==f)}return e},nt=function(a,b){var c=a.listener,d=a.pb||a.src;a.qg&&lt(a);return c.call(d,b)},it=
function(a,b){if(a.removed)return!0;if(!Ls){var c=b||Xa("window.event");b=new Os(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(h){e=!0}if(e||void 0==c.returnValue)c.returnValue=!0}c=[];for(e=b.f;e;e=e.parentNode)c.push(e);a=a.type;for(e=c.length-1;0<=e;e--){b.f=c[e];var f=ot(c[e],a,!0,b);d=d&&f}for(e=0;e<c.length;e++)b.f=c[e],f=ot(c[e],a,!1,b),d=d&&f}return d}return nt(a,new Os(b,this))},ft=function(a){a=a[Zs];return a instanceof
Vs?a:null},pt="__closure_events_fn_"+(1E9*Math.random()>>>0),dt=function(a){if(hb(a))return a;a[pt]||(a[pt]=function(b){return a.handleEvent(b)});return a[pt]};var Y=function(){Hs.call(this);this.F=new Vs(this);this.Jm=this;this.L=null};t(Y,Hs);Y.prototype[Qs]=!0;Y.prototype.removeEventListener=function(a,b,c,d){kt(this,a,b,c,d)};
Y.prototype.I=function(a){var b,c=this.L;if(c)for(b=[];c;c=c.L)b.push(c);c=this.Jm;var d=a.type||a;if(Ra(a))a=new X(a,c);else if(a instanceof X)a.target=a.target||c;else{var e=a;a=new X(d,c);ud(a,e)}e=!0;if(b)for(var f=b.length-1;0<=f;f--){var h=a.f=b[f];e=h.ve(d,!0,a)&&e}h=a.f=c;e=h.ve(d,!0,a)&&e;e=h.ve(d,!1,a)&&e;if(b)for(f=0;f<b.length;f++)h=a.f=b[f],e=h.ve(d,!1,a)&&e;return e};Y.prototype.ja=function(){Y.ra.ja.call(this);this.xi();this.L=null};
Y.prototype.listen=function(a,b,c,d){return this.F.add(String(a),b,!1,c,d)};var jt=function(a,b,c,d,e){return a.F.add(String(b),c,!0,d,e)};Y.prototype.xi=function(a){this.F&&this.F.removeAll(a)};Y.prototype.ve=function(a,b,c){a=this.F.b[String(a)];if(!a)return!0;a=a.concat();for(var d=!0,e=0;e<a.length;++e){var f=a[e];if(f&&!f.removed&&f.capture==b){var h=f.listener,k=f.pb||f.src;f.qg&&Xs(this.F,f);d=!1!==h.call(k,c)&&d}}return d&&0!=c.bl};
Y.prototype.hasListener=function(a,b){return this.F.hasListener(Qa(a)?String(a):void 0,b)};var qt=function(a,b){this.h=a;this.g=b;this.f=0;this.b=null};qt.prototype.get=function(){if(0<this.f){this.f--;var a=this.b;this.b=a.next;a.next=null}else a=this.h();return a};var rt=function(a,b){a.g(b);100>a.f&&(a.f++,b.next=a.b,a.b=b)};var st=function(a){Pa.setTimeout(function(){throw a;},0)},tt,ut=function(){var a=Pa.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!cd("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&&!cd("Trident")&&!cd("MSIE")){var b=new a,c={},d=c;b.port1.onmessage=function(){if(Qa(c.next)){c=c.next;var a=c.Fj;c.Fj=null;a()}};return function(a){d.next={Fj: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){Pa.setTimeout(a,0)}};var vt=function(){this.f=this.b=null},xt=new qt(function(){return new wt},function(a){a.reset()});vt.prototype.add=function(a,b){var c=xt.get();c.set(a,b);this.f?this.f.next=c:this.b=c;this.f=c};vt.prototype.remove=function(){var a=null;this.b&&(a=this.b,this.b=this.b.next,this.b||(this.f=null),a.next=null);return a};var wt=function(){this.next=this.scope=this.b=null};wt.prototype.set=function(a,b){this.b=a;this.scope=b;this.next=null};wt.prototype.reset=function(){this.next=this.scope=this.b=null};var Ct=function(a,b){yt||zt();At||(yt(),At=!0);Bt.add(a,b)},yt,zt=function(){if(Pa.Promise&&Pa.Promise.resolve){var a=Pa.Promise.resolve(void 0);yt=function(){a.then(Dt)}}else yt=function(){var a=Dt;!hb(Pa.setImmediate)||Pa.Window&&Pa.Window.prototype&&!cd("Edge")&&Pa.Window.prototype.setImmediate==Pa.setImmediate?(tt||(tt=ut()),tt(a)):Pa.setImmediate(a)}},At=!1,Bt=new vt,Dt=function(){for(var a;a=Bt.remove();){try{a.b.call(a.scope)}catch(b){st(b)}rt(xt,a)}At=!1};var Et=function(a){a.prototype.then=a.prototype.then;a.prototype.$goog_Thenable=!0},Ft=function(a){if(!a)return!1;try{return!!a.$goog_Thenable}catch(b){return!1}};var It=function(a,b){this.b=0;this.m=void 0;this.g=this.f=this.h=null;this.j=this.s=!1;if(a!=Ya)try{var c=this;a.call(b,function(a){Gt(c,2,a)},function(a){if(!(a instanceof Ht))try{if(a instanceof Error)throw a;throw Error("Promise rejected.");}catch(e){}Gt(c,3,a)})}catch(d){Gt(this,3,d)}},Jt=function(){this.next=this.context=this.f=this.g=this.b=null;this.h=!1};Jt.prototype.reset=function(){this.context=this.f=this.g=this.b=null;this.h=!1};
var Kt=new qt(function(){return new Jt},function(a){a.reset()}),Lt=function(a,b,c){var d=Kt.get();d.g=a;d.f=b;d.context=c;return d},Mt=function(a){if(a instanceof It)return a;var b=new It(Ya);Gt(b,2,a);return b},Nt=function(a){return new It(function(b,c){c(a)})},Pt=function(a,b,c){Ot(a,b,c,null)||Ct(ob(b,a))},Qt=function(a){return new It(function(b,c){a.length||b(void 0);for(var d=0,e;d<a.length;d++)e=a[d],Pt(e,b,c)})},Rt=function(a){return new It(function(b,c){var d=a.length,e=[];if(d)for(var f=
function(a,c){d--;e[a]=c;0==d&&b(e)},h=function(a){c(a)},k=0,n;k<a.length;k++)n=a[k],Pt(n,ob(f,k),h);else b(e)})},St=function(a){return new It(function(b){var c=a.length,d=[];if(c)for(var e=function(a,e,f){c--;d[a]=e?{qd:!0,value:f}:{qd:!1,reason:f};0==c&&b(d)},f=0,h;f<a.length;f++)h=a[f],Pt(h,ob(e,f,!0),ob(e,f,!1));else b(d)})},Ut=function(){var a,b,c=new It(function(c,e){a=c;b=e});return new Tt(c,a,b)};It.prototype.then=function(a,b,c){return Vt(this,hb(a)?a:null,hb(b)?b:null,c)};Et(It);
var Xt=function(a,b,c){b=Lt(b,b,c);b.h=!0;Wt(a,b);return a},Yt=function(a,b,c){return Vt(a,null,b,c)};It.prototype.cancel=function(a){0==this.b&&Ct(function(){var b=new Ht(a);Zt(this,b)},this)};
var Zt=function(a,b){if(0==a.b)if(a.h){var c=a.h;if(c.f){for(var d=0,e=null,f=null,h=c.f;h&&(h.h||(d++,h.b==a&&(e=h),!(e&&1<d)));h=h.next)e||(f=h);e&&(0==c.b&&1==d?Zt(c,b):(f?(d=f,d.next==c.g&&(c.g=d),d.next=d.next.next):$t(c),au(c,e,3,b)))}a.h=null}else Gt(a,3,b)},Wt=function(a,b){a.f||2!=a.b&&3!=a.b||bu(a);a.g?a.g.next=b:a.f=b;a.g=b},Vt=function(a,b,c,d){var e=Lt(null,null,null);e.b=new It(function(a,h){e.g=b?function(c){try{var e=b.call(d,c);a(e)}catch(u){h(u)}}:a;e.f=c?function(b){try{var e=c.call(d,
b);!Qa(e)&&b instanceof Ht?h(b):a(e)}catch(u){h(u)}}:h});e.b.h=a;Wt(a,e);return e.b};It.prototype.u=function(a){this.b=0;Gt(this,2,a)};It.prototype.A=function(a){this.b=0;Gt(this,3,a)};
var Gt=function(a,b,c){0==a.b&&(a===c&&(b=3,c=new TypeError("Promise cannot resolve to itself")),a.b=1,Ot(c,a.u,a.A,a)||(a.m=c,a.b=b,a.h=null,bu(a),3!=b||c instanceof Ht||cu(a,c)))},Ot=function(a,b,c,d){if(a instanceof It)return Wt(a,Lt(b||Ya,c||null,d)),!0;if(Ft(a))return a.then(b,c,d),!0;if(ib(a))try{var e=a.then;if(hb(e))return du(a,e,b,c,d),!0}catch(f){return c.call(d,f),!0}return!1},du=function(a,b,c,d,e){var f=!1,h=function(a){f||(f=!0,c.call(e,a))},k=function(a){f||(f=!0,d.call(e,a))};try{b.call(a,
h,k)}catch(n){k(n)}},bu=function(a){a.s||(a.s=!0,Ct(a.o,a))},$t=function(a){var b=null;a.f&&(b=a.f,a.f=b.next,b.next=null);a.f||(a.g=null);return b};It.prototype.o=function(){for(var a;a=$t(this);)au(this,a,this.b,this.m);this.s=!1};
var au=function(a,b,c,d){if(3==c&&b.f&&!b.h)for(;a&&a.j;a=a.h)a.j=!1;if(b.b)b.b.h=null,eu(b,c,d);else try{b.h?b.g.call(b.context):eu(b,c,d)}catch(e){fu.call(null,e)}rt(Kt,b)},eu=function(a,b,c){2==b?a.g.call(a.context,c):a.f&&a.f.call(a.context,c)},cu=function(a,b){a.j=!0;Ct(function(){a.j&&fu.call(null,b)})},fu=st,Ht=function(a){Ub.call(this,a)};t(Ht,Ub);Ht.prototype.name="cancel";var Tt=function(a,b,c){this.U=a;this.resolve=b;this.reject=c};var gu=function(a,b){Y.call(this);this.g=a||1;this.f=b||Pa;this.j=p(this.o,this);this.m=q()};t(gu,Y);gu.prototype.enabled=!1;gu.prototype.b=null;var hu=function(a,b){a.g=b;a.b&&a.enabled?(a.stop(),a.start()):a.b&&a.stop()};gu.prototype.o=function(){if(this.enabled){var a=q()-this.m;0<a&&a<.8*this.g?this.b=this.f.setTimeout(this.j,this.g-a):(this.b&&(this.f.clearTimeout(this.b),this.b=null),this.I("tick"),this.enabled&&(this.b=this.f.setTimeout(this.j,this.g),this.m=q()))}};
gu.prototype.start=function(){this.enabled=!0;this.b||(this.b=this.f.setTimeout(this.j,this.g),this.m=q())};gu.prototype.stop=function(){this.enabled=!1;this.b&&(this.f.clearTimeout(this.b),this.b=null)};gu.prototype.ja=function(){gu.ra.ja.call(this);this.stop();delete this.f};
var iu=function(a,b,c){if(hb(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:Pa.setTimeout(a,b||0)},ju=function(a){Pa.clearTimeout(a)},ku=function(a){var b=null;return Yt(new It(function(c,d){b=iu(function(){c(void 0)},a);-1==b&&d(Error("Failed to schedule timer."))}),function(a){ju(b);throw a;})};var lu=function(){this.l=ls("mr.cloud.slarti.Fetcher");this.b=0};lu.prototype.execute=function(a){var b="Fetch call "+ ++this.b;return mu(this,b,a)};
var mu=function(a,b,c){var d=c.uri.toString().replace(/\?.*/,"?<redacted>"),e=c.method+" "+d;W(a.l,b+": "+e);d=[Es(c).then(function(a){return Promise.resolve(fetch(a))})];c.Wf&&d.push(ku(c.Wf).then(function(){throw Gs("API call timed out",504);}));return Promise.race(d).then(function(d){if(!d.ok)return d.json().then(function(a){return a},function(){return null}).then(function(a){var b;a&&a instanceof Object&&a.error&&(b=a.error);throw new Fs(d,b);});var f=(q()-c.start)/1E3;W(a.l,b+" succeeded: "+
e+" duration = "+f+"s");return(f=d.headers.get("content-type"))&&f.includes("application/json")?d.json():f&&(f.includes("image")||f.includes("application/octet-stream"))?d.blob():d.text()},function(c){var d="";if(c instanceof Fs)d=", ("+c.status+"): "+c.message;else{try{d=", "+JSON.stringify(c,null,2)}catch(k){}c instanceof Error&&"Failed to fetch"==c.message&&(c=Gs(c.message))}ns(a.l,b+" failed: "+d);throw c;})};var nu=function(a,b){this.b=ar.b;this.cb=a;this.f=b};var ou=function(a,b){nu.call(this,a,b)};l(ou,nu);ou.prototype.register=function(a){a=new Ds({method:"POST",ic:this.b,qc:["user:register"],cb:this.cb,body:{gcmId:a}});return this.f.execute(a)};ou.prototype.unregister=function(a){a=new Ds({method:"POST",ic:this.b,qc:["user:unregister"],cb:this.cb,body:{gcmId:a}});return this.f.execute(a)};var pu=function(a){var b=window.localStorage;this.l=tb("mr.cloud.slarti.GcmRegistration");this.h=a;this.f=b;this.b=null},ru=function(a){if(!a.b){var b=a.f["mr.cloud.slarti.GcmRegistration.ID"];a.b=new Promise(function(c,d){chrome.gcm.register(["307539924703"],function(e){if(e)if(e==b)Ab(a.l,"Slarti GCM ID unchanged: "+e),c();else{Ab(a.l,"Got new Slarti GCM ID: "+e);var f=b?qu(a,b):Promise.resolve();c(f.then(function(){return a.h.register(e).then(function(){a.f["mr.cloud.slarti.GcmRegistration.ID"]=
e})}))}else f=chrome.runtime.lastError&&chrome.runtime.lastError.message||"unknown error",v(a.l,"Error registering for GCM notifications: "+f),b&&qu(a,b).catch(function(b){v(a.l,"Failed to unregister GCM ID with Slarti",b)}),d(Error(f))})});a.b.then(function(){a.b=null},function(){a.b=null})}return a.b},qu=function(a,b){return a.h.unregister(b).then(function(){delete a.f["mr.cloud.slarti.GcmRegistration.ID"]},function(b){v(a.l,"Failed to unregister GCM ID with Slarti",b)})};var su=null,tu=function(){ik.call(this,5,"mr.cloud.slarti.GcmEventListener","mr.cloud.slarti.SinkDiscoveryService",chrome.gcm.onMessage);this.l=tb("mr.cloud.slarti.GcmEventListener")};l(tu,ik);tu.prototype.Zf=function(a){return a&&"307539924703"==a.from&&(a=a.data.data)&&(a=JSON.parse(a).type)?(this.l.info("Received Slarti GCM notification: "+a),!0):!1};var uu=function(){null==su&&(su=new tu);return su};var vu=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];d=a;c=ma(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 wu=function(){ik.call(this,5,"cloud.GcmEventListener","mr.cloud.discovery.WeaveSinkDiscoveryService",chrome.gcm.onMessage);this.l=tb("mr.WeaveGcmEventListener")};l(wu,ik);wu.prototype.Zf=function(a){if(!a||"919648714761"!=a.from)return!1;a=vu(a,"data","notification");if(!a)return this.l.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.l.error("Invalid json: "+a),!1}};
var yu=function(){xu||(xu=new wu);return xu},xu=null;var zu=function(a){this.b=a;this.l=tb("mr.cloud.messaging.WeaveGcmMessageHandler")};zu.prototype.onMessage=function(a){var b=this;a=JSON.parse(a.data.notification);var c=Kj();a.events.forEach(function(a){if(a.deviceId){var d=Lj(c,a.deviceId);switch(a.type){case "deviceCreated":Au(b,a);break;case "deviceUpdated":Bu(b,a,d);break;case "deviceDeleted":Cu(b.b,{sinkId:d});break;default:Ab(b.l,function(){return"[unhandled event] "+JSON.stringify(a)})}}else b.l.error("Device ID not provided")})};
var Au=function(a,b){var c=vu(b,"statePatch","_cloudCast","settings","receiverName");"string"!=typeof c?a.l.error("Receiver name not a string: "+c):(b=new Er(b.deviceId,c,"owner","default",!0),a=a.b,a.b.b.set(b.Fa.id,b),a.b.f=Date.now(),Lr(a.f,[b.Fa]))},Bu=function(a,b,c){b=vu(b,"statePatch","_cloudCast","appStatus");if("string"!=typeof b)a.l.error("App status not a string: "+b);else if(a=a.b,b="available"==b,c=a.b.ha(c))c.isAvailable=b||!1,a.b.f=Date.now(),Mr(a.f,[c.Fa])};var Du=function(a,b){this.h=a;this.f=b;this.b=new Hr(this.wo.bind(this),b,2E4);this.g=new zu(this);yu().addListener();qj(this);xg("mr.cloud.discovery.WeaveSinkDiscoveryService",this)};l(Du,mg);g=Du.prototype;g.xd=function(){var a=this;Br(this.h).then(function(b){Cr(a.h,b)},function(){});return this.b.xd().filter(function(a){return a.isAvailable})};g.ha=function(a){return this.b.ha(a)};
g.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,xa(c));else throw Error("Unhandled event: expected chrome.gcm.onMessage");};
g.wo=function(){return zr(this.h,{descriptionSubstring:"Chrome Streaming Receiver"}).then(function(a){return a.map(function(a){Qb("MediaRouter.Cloud.CloudReceiver.Sink.Discovered");var b=a.isAvailable()&&!(a.b.invitations&&0!=a.b.invitations.length);return new Er(a.getId(),a.f(),a.b.personalizedInfo.maxRole,"default",b)})})};g.ua=function(){return"WeaveSinkDiscoveryService"};g.Ta=function(){return[{cache:Pr(this.b)}]};g.Ya=function(){var a=nj(this);a&&Qr(this.b,a.cache)};
var Cu=function(a,b){if(b=a.b.ha(b.sinkId))a.b.b.delete(b.Fa.id),a.b.f=Date.now(),Nr(a.f,[b.Fa])};var Eu=Pa.JSON.parse,Fu=Pa.JSON.stringify;var Gu=function(a,b,c,d,e,f,h,k){this.b=null;this.A=!1;this.u=Ut();this.f=[];this.o=a?encodeURIComponent(String(a)):null;this.B=null;!d&&b&&(this.B=b);this.L=c||null;this.g=!d;this.j=null!=e?e:null;this.m=f||null;this.D=!!h;this.F=k||null};t(Gu,Hs);var Hu;var Iu=ce("https://apis.google.com/js/client.js");Iu instanceof be&&Iu.constructor===be&&Iu.f===ae?Hu=Iu.b:(Xb("expected object of type Const, got '"+Iu+"'"),Hu="type_error:Const");var Ju=oe(Hu);
Gu.prototype.init=function(){var a=p(function(a){this.b=a;var b=Xa("auth",a);Xa("client.request",a)&&b?this.C():a.load("client",p(this.C,this))},this),b=Ku("gapi");b?a(b.gapi):Lu(this,a);return this.u.U};
var Ku=function(a){for(var b=window,c=Xa(a,b);!c&&b!=window.top&&Mu(b.parent,a);)b=b.parent,c=Xa(a,b);return c?b:null},Mu=function(a,b){try{return!!a&&null!=a.location.href&&Ad(a,b)}catch(c){return!1}},Lu=function(a,b){var c=Ku("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");ye(e,Ju);a.F&&Te(e,Fu(a.F));document.getElementsByTagName("head")[0].appendChild(e)}};
Gu.prototype.C=function(){for(var a=0;a<this.f.length;a++)this.f[a].kb.resolve(Nu(this,this.f[a].requestData));this.A=!0;this.u.resolve(this.b)};Gu.prototype.sendRequest=function(a){if(this.A)return Nu(this,a);var b=Ut();this.f.push({requestData:a,kb:b});return b.U};
var Nu=function(a,b){var c,d=Xa("config.get",a.b);if(!a.g){var e=d("googleapis.config/auth/useFirstPartyAuth");var f=d("googleapis.config/auth/useOriginToken")}null!=a.j&&(c=d("client/cors"));try{var h=Xa("config.update",a.b);a.g||(h("googleapis.config/auth/useFirstPartyAuth",!1),h("googleapis.config/auth/useOriginToken",!1));null!=a.j&&h("client/cors",a.j);var k=Ou(a);b.headers&&ud(k,b.headers);var n={headers:k,root:a.L,path:b.path,method:b.method,body:b.body},u=b.params||{};a.o&&!a.m?ud(u,{key:a.o}):
a.m&&ud(u,{key:null});nd(u)||(n.params=u);var z=Mt(Xa("client.request",a.b)(n));b.callback&&z.then(function(a){b.callback.apply(null,[a.result,a])},function(a){b.callback.apply(null,[a.result,a])});return z}finally{d=Xa("config.update",a.b),a.g||(d("googleapis.config/auth/useFirstPartyAuth",e),d("googleapis.config/auth/useOriginToken",f)),null!=a.j&&d("client/cors",c)}},Ou=function(a){if(a.g){if(a.m)return{Authorization:"Bearer "+a.m};var b=Xa("auth.getAuthHeaderValueForFirstParty",a.b);return{Authorization:a.D?
b([]):b(),"X-Goog-AuthUser":a.B}}return{}};var Pu=function(a){this.b=a},lr=function(a,b,c){var d="";b.forEach(function(a){d+="/"+encodeURIComponent(a)});a=new gq(a+d);c&&(c=wq(c),jq(a,c));return a},nr=function(a,b,c,d){return a.b.getAuthToken().then(function(e){var f=Qu(e);return Ru(f,b,c,d).catch(function(f){if("INVALID_ACCESS_ERROR"==f)return Su(a,e,b,c,d);throw f;})})},Su=function(a,b,c,d,e){return As(b).then(function(){return nr(a,c,d,e)})},Ru=function(a,b,c,d){return new Promise(function(e,f){a.sendRequest(Tu(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))})},Qu=function(a){a=new Gu(void 0,void 0,void 0,!1,!1,a);a.init();return a},Tu=function(a,b,c,d){a={callback:c,method:b,path:a.toString()};d&&(a.body=d);return a};var Uu={Cr:{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"}},Br:{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"}}},Vu=Uu;Vu=Uu;var Wu={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,"\u20ba","TRY"],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 Xu={Pi:".",gh:",",dj:"%",mh:"0",hm:"+",Xi:"-",Ti:"E",ej:"\u2030",hh:"\u221e",dm:"NaN",Gl:"#,##0.###",uv:"#E0",Gu:"#,##0%",Mr:"\u00a4#,##0.00",Qi:"USD"},Yu=Xu;Yu=Xu;var $u=function(){this.B=40;this.f=1;this.o=3;this.F=this.j=0;this.D=!1;this.A=this.m="";this.h=Yu.Xi;this.u="";this.b=1;this.s=!1;this.g=[];this.C=this.L=!1;var a=Yu.Gl;a.replace(/ /g,"\u00a0");var b=[0];this.m=Zu(this,a,b);for(var c=b[0],d=-1,e=0,f=0,h=0,k=-1,n=a.length,u=!0;b[0]<n&&u;b[0]++)switch(a.charAt(b[0])){case "#":0<f?h++:e++;0<=k&&0>d&&k++;break;case "0":if(0<h)throw Error('Unexpected "0" in pattern "'+a+'"');f++;0<=k&&0>d&&k++;break;case ",":0<k&&this.g.push(k);k=0;break;case ".":if(0<=
d)throw Error('Multiple decimal separators in pattern "'+a+'"');d=e+f+h;break;case "E":if(this.C)throw Error('Multiple exponential symbols in pattern "'+a+'"');this.C=!0;this.F=0;b[0]+1<n&&"+"==a.charAt(b[0]+1)&&(b[0]++,this.D=!0);for(;b[0]+1<n&&"0"==a.charAt(b[0]+1);)b[0]++,this.F++;if(1>e+f||1>this.F)throw Error('Malformed exponential pattern "'+a+'"');u=!1;break;default:b[0]--,u=!1}0==f&&0<e&&0<=d&&(f=d,0==f&&f++,h=e-f,e=f-1,f=1);if(0>d&&0<h||0<=d&&(d<e||d>e+f)||0==k)throw Error('Malformed pattern "'+
a+'"');h=e+f+h;this.o=0<=d?h-d:0;0<=d&&(this.j=e+f-d,0>this.j&&(this.j=0));this.f=(0<=d?d:h)-e;this.C&&(this.B=e+this.f,0==this.o&&0==this.f&&(this.f=1));this.g.push(Math.max(0,k));this.L=0==d||d==h;c=b[0]-c;this.A=Zu(this,a,b);b[0]<a.length&&";"==a.charAt(b[0])?(b[0]++,1!=this.b&&(this.s=!0),this.h=Zu(this,a,b),b[0]+=c,this.u=Zu(this,a,b)):(this.h+=this.m,this.u+=this.A)};
$u.prototype.parse=function(a,b){b=b||[0];a=a.replace(/ /g,"\u00a0");var c=a.indexOf(this.m,b[0])==b[0],d=a.indexOf(this.h,b[0])==b[0];c&&d&&(this.m.length>this.h.length?d=!1:this.m.length<this.h.length&&(c=!1));c?b[0]+=this.m.length:d&&(b[0]+=this.h.length);if(a.indexOf(Yu.hh,b[0])==b[0]){b[0]+=Yu.hh.length;var e=Infinity}else{e=a;for(var f=!1,h=!1,k=!1,n=-1,u=1,z=Yu.Pi,B=Yu.gh,D=Yu.Ti,R="";b[0]<e.length;b[0]++){var la=e.charAt(b[0]),ra=av(la);if(0<=ra&&9>=ra)R+=ra,k=!0;else if(la==z.charAt(0)){if(f||
h)break;R+=".";f=!0}else if(la==B.charAt(0)&&("\u00a0"!=B.charAt(0)||b[0]+1<e.length&&0<=av(e.charAt(b[0]+1)))){if(f||h)break}else if(la==D.charAt(0)){if(h)break;R+="E";h=!0;n=b[0]}else if("+"==la||"-"==la){if(k&&n!=b[0]-1)break;R+=la}else if(1==this.b&&la==Yu.dj.charAt(0)){if(1!=u)break;u=100;if(k){b[0]++;break}}else if(1==this.b&&la==Yu.ej.charAt(0)){if(1!=u)break;u=1E3;if(k){b[0]++;break}}else break}1!=this.b&&(u=this.b);e=parseFloat(R)/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.u,b[0])!=b[0])return NaN;b[0]+=this.u.length}return d?-e:e};
$u.prototype.format=function(a){if(isNaN(a))return Yu.dm;var b=[];var c=bv;a/=Math.pow(10,c.Mn);b.push(c.prefix);var d=0>a||0==a&&0>1/a;b.push(d?this.h:this.m);if(isFinite(a))if(a=a*(d?-1:1)*this.b,this.C){var e=a;if(0==e)cv(this,e,this.f,b),dv(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.f;if(1<this.B&&this.B>this.f){for(;0!=a%this.B;)e*=10,a--;f=1}else 1>this.f?(a++,
e/=10):(a-=this.f-1,e*=Math.pow(10,this.f-1));cv(this,e,f,b);dv(this,a,b)}}else cv(this,a,this.f,b);else b.push(Yu.hh);b.push(d?this.u:this.A);b.push(c.cq);return b.join("")};
var cv=function(a,b,c,d){if(a.j>a.o)throw Error("Min value must be less than max value");d||(d=[]);var e=Math.pow(10,a.o);var f=Math.round(b*e);isFinite(f)?(b=Math.floor(f/e),f=Math.floor(f-b*e)):f=0;var h=e=b;b=f;var k=0<a.j||0<b||!1;e=a.j;k&&(e=a.j);var n="";for(f=h;1E20<f;)n="0"+n,f=Math.round(f/10);n=f+n;var u=Yu.Pi;f=Yu.mh.charCodeAt(0);var z=n.length,B=0;if(0<h||0<c){for(h=z;h<c;h++)d.push(String.fromCharCode(f));if(2<=a.g.length)for(c=1;c<a.g.length;c++)B+=a.g[c];c=z-B;if(0<c){h=a.g;B=z=0;
for(var D,R=Yu.gh,la=n.length,ra=0;ra<la;ra++)if(d.push(String.fromCharCode(f+1*Number(n.charAt(ra)))),1<la-ra)if(D=h[B],ra<c){var Db=c-ra;(1===D||0<D&&1===Db%D)&&d.push(R)}else B<h.length&&(ra===c?B+=1:D===ra-c-z+1&&(d.push(R),z+=D,B+=1))}else{c=n;n=a.g;h=Yu.gh;D=c.length;R=[];for(z=n.length-1;0<=z&&0<D;z--){B=n[z];for(la=0;la<B&&0<=D-la-1;la++)R.push(String.fromCharCode(f+1*Number(c.charAt(D-la-1))));D-=B;0<D&&R.push(h)}d.push.apply(d,R.reverse())}}else k||d.push(String.fromCharCode(f));(a.L||k)&&
d.push(u);k=String(b);b=k.split("e+");if(2==b.length){if(k=parseFloat(b[0])){u=k;if(isFinite(u)){for(c=0;1<=(u/=10);)c++;u=c}else u=0<u?u:0;u=0-u-1;-1>u?(u=Math.pow(10,1),k=Math.round(k/u)*u):(u=Math.pow(10,u),k=Math.round(k*u)/u)}k=String(k);k=k.replace(".","");k+=Rc("0",parseInt(b[1],10)-k.length+1)}a.o+1>k.length&&(k="1"+Rc("0",a.o-k.length)+k);for(a=k.length;"0"==k.charAt(a-1)&&a>e+1;)a--;for(h=1;h<a;h++)d.push(String.fromCharCode(f+1*Number(k.charAt(h))))},dv=function(a,b,c){c.push(Yu.Ti);0>
b?(b=-b,c.push(Yu.Xi)):a.D&&c.push(Yu.hm);b=""+b;for(var d=Yu.mh,e=b.length;e<a.F;e++)c.push(d);c.push(b)},av=function(a){a=a.charCodeAt(0);if(48<=a&&58>a)return a-48;var b=Yu.mh.charCodeAt(0);return b<=a&&a<b+10?a-b:-1},Zu=function(a,b,c){for(var d="",e=!1,f=b.length;c[0]<f;c[0]++){var h=b.charAt(c[0]);if("'"==h)c[0]+1<f&&"'"==b.charAt(c[0]+1)?(c[0]++,d+="'"):e=!e;else if(e)d+=h;else switch(h){case "#":case "0":case ",":case ".":case ";":return d;case "\u00a4":c[0]+1<f&&"\u00a4"==b.charAt(c[0]+1)?
(c[0]++,d+=Yu.Qi):d+=Wu[Yu.Qi][1];break;case "%":if(!a.s&&1!=a.b)throw Error("Too many percent/permill");if(a.s&&100!=a.b)throw Error("Inconsistent use of percent/permill characters");a.b=100;a.s=!1;d+=Yu.dj;break;case "\u2030":if(!a.s&&1!=a.b)throw Error("Too many percent/permill");if(a.s&&1E3!=a.b)throw Error("Inconsistent use of percent/permill characters");a.b=1E3;a.s=!1;d+=Yu.ej;break;default:d+=h}}return d},bv={prefix:"",cq:"",Mn:0};var ev=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"},fv=ev;fv=ev;var gv=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"},hv=gv;hv=gv;var mv=function(){this.g=iv;this.f=this.b=this.j=null;var a=Yu,b=Vu;if(jv!==a||kv!==b)jv=a,kv=b,lv=new $u;this.s=lv},jv=null,kv=null,lv=null,nv=/'([{}#].*?)'/g,ov=/''/g;mv.prototype.format=function(a){if(this.g){this.j=[];var b=pv(this,this.g);this.f=qv(this,b);this.g=null}if(this.f&&0!=this.f.length)for(this.b=x(this.j),b=[],rv(this,this.f,a,!1,b),a=b.join("");0<this.b.length;)a=a.replace(this.h(this.b),this.b.pop());else a="";return a};
var rv=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 h=b[f].value,k=a,n=e,u=c[h];Qa(u)?(k.b.push(u),n.push(k.h(k.b))):n.push("Undefined parameter - "+h);break;case 2:h=b[f].value;k=e;n=h.og;Qa(c[n])?(n=h[c[n]],Qa(n)||(n=h.other),rv(a,n,c,d,k)):k.push("Undefined parameter - "+n);break;case 0:h=b[f].value;sv(a,h,c,hv,d,e);break;case 1:h=b[f].value;sv(a,h,c,fv,d,e);break;default:Xb("Unrecognized block type: "+b[f].type)}},sv=function(a,b,
c,d,e,f){var h=b.og,k=b.zj,n=+c[h];isNaN(n)?f.push("Undefined or invalid parameter - "+h):(k=n-k,h=b[c[h]],Qa(h)||(d=a.s.ka?d(k,a.s.ka()):d(k),h=b[d],Qa(h)||(h=b.other)),b=[],rv(a,h,c,e,b),c=b.join(""),e?f.push(c):(a=a.s.format(k),f.push(c.replace(/#/g,a))))},pv=function(a,b){var c=a.j,d=p(a.h,a);b=b.replace(ov,function(){c.push("'");return d(c)});return b=b.replace(nv,function(a,b){c.push(b);return d(c)})},tv=function(a){var b=0,c=[],d=[],e=/[{}]/g;e.lastIndex=0;for(var f;f=e.exec(a);){var h=f.index;
"}"==f[0]?(c.pop(),0==c.length&&(f={type:1},f.value=a.substring(b,h),d.push(f),b=h+1)):(0==c.length&&(b=a.substring(b,h),""!=b&&d.push({type:0,value:b}),b=h+1),c.push("{"))}b=a.substring(b);""!=b&&d.push({type:0,value:b});return d},uv=/^\s*(\w+)\s*,\s*plural\s*,(?:\s*offset:(\d+))?/,vv=/^\s*(\w+)\s*,\s*selectordinal\s*,/,wv=/^\s*(\w+)\s*,\s*select\s*,/,qv=function(a,b){var c=[];b=tv(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(uv.test(f)?0:vv.test(f)?1:wv.test(f)?2:/^\s*\w+\s*/.test(f)?3:5){case 2:e.type=2;e.value=xv(a,b[d].value);break;case 0:e.type=0;e.value=yv(a,b[d].value);break;case 1:e.type=1;e.value=zv(a,b[d].value);break;case 3:e.type=3;e.value=b[d].value;break;default:Xb("Unknown block type for pattern: "+b[d].value)}}else Xb("Unknown part of the pattern.");c.push(e)}return c},xv=function(a,b){var c="";b=b.replace(wv,function(a,b){c=b;return""});var d={};d.og=c;b=tv(b);for(var e=0;e<b.length;){var f=b[e].value;
e++;if(1==b[e].type)var h=qv(a,b[e].value);else Xb("Expected block type.");d[f.replace(/\s/g,"")]=h;e++}return d},yv=function(a,b){var c="",d=0;b=b.replace(uv,function(a,b,e){c=b;e&&(d=parseInt(e,10));return""});var e={};e.og=c;e.zj=d;b=tv(b);for(var f=0;f<b.length;){var h=b[f].value;f++;if(1==b[f].type)var k=qv(a,b[f].value);else Xb("Expected block type.");e[h.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=k;f++}return e},zv=function(a,b){var c="";b=b.replace(vv,function(a,b){c=b;return""});var d={};d.og=c;
d.zj=0;b=tv(b);for(var e=0;e<b.length;){var f=b[e].value;e++;if(1==b[e].type)var h=qv(a,b[e].value);else Xb("Expected block type.");d[f.replace(/\s*(?:=)?(\w+)\s*/,"$1")]=h;e++}return d};mv.prototype.h=function(a){return"\ufddf_"+(a.length-1).toString(10)+"_"};var Av=chrome.i18n.getMessage("1522140683318860351"),Bv=chrome.i18n.getMessage("4246483347873264186"),Cv=chrome.i18n.getMessage("5991427458288444010"),Nf=chrome.i18n.getMessage("6063910461797960050"),Dv=chrome.i18n.getMessage("7735695102441495789"),Ev=chrome.i18n.getMessage("4575332923598659024"),iv=chrome.i18n.getMessage("2297080986956220930"),Fv=new mv;var Gv=function(a){this.b=a;this.l=tb("mr.cloud.mesi.MesiService")},ts=function(a){var b=cr.b;.1>Math.random()&&(b=b.replace("v1","v1_preprod"));b=lr(b,["hangouts","search"]);a.l.info("Retrieving Hangouts from MESI: "+b);return nr(a.b,b,"POST",Hv).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=Fv.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=Fv.format({ORGANIZER:u,PARTICIPANTS:e.size})}return c&&d?new er(!1,c+"@"+d,d,c,e,b.hangout_id):new er(!1,b.hangout_id,d,c,e,b.hangout_id)}));return b})},Hv={request_header:{client_version:{client_id:"39"}},search_sources:["0"]};var Iv=function(a,b){this.f=a;this.b=b},Lv=function(a,b,c,d){switch(b.type){case "REFRESH_AUTH":var e=d.Bc,f=d.deviceId,h=d.ee;return Bs(a.f).then(function(){Jv(a.b,new Zg("AUTH_READY",{Bc:e,fb:f,ee:h}),c.id)});case "LOCAL_PRESENT":return Jv(a.b,new Zg("AUTH_READY",{Bc:d.Bc,fb:d.deviceId,ee:d.ee,nd:!b.data.local}),c.id),Promise.resolve();case "STATUS_REQUEST":return Jv(a.b,b,c.id),Promise.resolve();case "STATUS_RESPONSE":return Jv(a.b,b,c.id,!0),b.data.routeDescription||Jv(a.b,b,c.id),Promise.resolve();
case "HANGOUT_INACTIVE":return Kv(a.b,c,4,new Mf(Dv,"warning"));case "HANGOUT_INVALID":return Kv(a.b,c,3,new Mf(Ev,"warning"));default:return Promise.reject(Error("Unknown type: "+b.type))}};var Mv=new Map([["status","status"],["results","result"],["expirationTime","expiration_time"]]),Nv=function(a,b){nu.call(this,a,b)};l(Nv,nu);Nv.prototype.get=function(a){a=new Ds({method:"GET",ic:this.b,qc:["commands",a],cb:this.cb});return this.f.execute(a).then(function(a){return a})};Nv.prototype.list=function(a){a=new Ds({method:"GET",ic:this.b,qc:["commands"],Rk:{deviceId:a},cb:this.cb});return this.f.execute(a).then(function(a){return a.command||[]})};
Nv.prototype.send=function(a,b){a=new Ds({method:"POST",ic:this.b,qc:["commands:send"],cb:this.cb,body:{command:b,deviceId:a}});return this.f.execute(a).then(function(a){return a})};Nv.prototype.update=function(a,b){for(var c=[],d={},e=ma(Mv.keys()),f=e.next();!f.done;f=e.next())f=f.value,b[f]&&(d[f]=b[f],c.push(Mv.get(f)));d.id=a;a=new Ds({method:"PUT",ic:this.b,qc:["commands",a],cb:this.cb,body:{command:d,updateMask:c}});return this.f.execute(a).then(function(a){return a})};var Ov=Pa.JSON.parse;var Pv=function(){};Pv.prototype.b=null;var Rv=function(a){var b;(b=a.b)||(b={},Qv(a)&&(b[0]=!0,b[1]=!0),b=a.b=b);return b};var Sv,Tv=function(){};t(Tv,Pv);var Uv=function(a){return(a=Qv(a))?new ActiveXObject(a):new XMLHttpRequest},Qv=function(a){if(!a.f&&"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.f=d}catch(e){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed");}return a.f};Sv=new Tv;var Vv=function(a){Y.call(this);this.headers=new Fk;this.P=a||null;this.f=!1;this.M=this.b=null;this.la=this.D="";this.o=0;this.g="";this.j=this.Z=this.C=this.T=!1;this.m=0;this.A=null;this.u="";this.K=this.B=!1};t(Vv,Y);Vv.prototype.l=ls("goog.net.XhrIo");var Wv=/^https?$/i,Xv=["POST","PUT"],Yv=[],Zv=function(a,b,c,d,e,f,h){var k=new Vv;Yv.push(k);b&&k.listen("complete",b);jt(k,"ready",k.va);f&&(k.m=Math.max(0,f));h&&(k.B=h);k.send(a,c,d,e);return k};Vv.prototype.va=function(){this.Ra();pc(Yv,this)};
Vv.prototype.send=function(a,b,c,d){if(this.b)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+a);b=b?b.toUpperCase():"GET";this.D=a;this.g="";this.o=0;this.la=b;this.T=!1;this.f=!0;this.b=this.P?Uv(this.P):Uv(Sv);this.M=this.P?Rv(this.P):Rv(Sv);this.b.onreadystatechange=p(this.ma,this);try{ps(this.l,$v(this,"Opening Xhr")),this.Z=!0,this.b.open(b,String(a),!0),this.Z=!1}catch(f){ps(this.l,$v(this,"Error opening Xhr: "+f.message));aw(this,f);return}a=c||"";
var e=this.headers.clone();d&&Kl(d,function(a,b){e.set(b,a)});d=gc(e.ub(),bw);c=Pa.FormData&&a instanceof Pa.FormData;!ic(Xv,b)||d||c||e.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");e.forEach(function(a,b){this.b.setRequestHeader(b,a)},this);this.u&&(this.b.responseType=this.u);"withCredentials"in this.b&&this.b.withCredentials!==this.B&&(this.b.withCredentials=this.B);try{cw(this),0<this.m&&(this.K=dw(this.b),ps(this.l,$v(this,"Will abort after "+this.m+"ms if incomplete, xhr2 "+
this.K)),this.K?(this.b.timeout=this.m,this.b.ontimeout=p(this.ta,this)):this.A=iu(this.ta,this.m,this)),ps(this.l,$v(this,"Sending request")),this.C=!0,this.b.send(a),this.C=!1}catch(f){ps(this.l,$v(this,"Send error: "+f.message)),aw(this,f)}};var dw=function(a){return Ed&&Yd(9)&&m(a.timeout)&&Qa(a.ontimeout)},bw=function(a){return Hc("Content-Type",a)};
Vv.prototype.ta=function(){"undefined"!=typeof Oa&&this.b&&(this.g="Timed out after "+this.m+"ms, aborting",this.o=8,ps(this.l,$v(this,this.g)),this.I("timeout"),this.abort(8))};var aw=function(a,b){a.f=!1;a.b&&(a.j=!0,a.b.abort(),a.j=!1);a.g=b;a.o=5;ew(a);fw(a)},ew=function(a){a.T||(a.T=!0,a.I("complete"),a.I("error"))};Vv.prototype.abort=function(a){this.b&&this.f&&(ps(this.l,$v(this,"Aborting")),this.f=!1,this.j=!0,this.b.abort(),this.j=!1,this.o=a||7,this.I("complete"),this.I("abort"),fw(this))};
Vv.prototype.ja=function(){this.b&&(this.f&&(this.f=!1,this.j=!0,this.b.abort(),this.j=!1),fw(this,!0));Vv.ra.ja.call(this)};Vv.prototype.ma=function(){this.s||(this.Z||this.C||this.j?gw(this):this.wa())};Vv.prototype.wa=function(){gw(this)};
var gw=function(a){if(a.f&&"undefined"!=typeof Oa)if(a.M[1]&&4==hw(a)&&2==a.Ia())ps(a.l,$v(a,"Local request error detected and ignored"));else if(a.C&&4==hw(a))iu(a.ma,0,a);else if(a.I("readystatechange"),4==hw(a)){ps(a.l,$v(a,"Request complete"));a.f=!1;try{if(iw(a))a.I("complete"),a.I("success");else{a.o=6;try{var b=2<hw(a)?a.b.statusText:""}catch(c){ps(a.l,"Can not get status: "+c.message),b=""}a.g=b+" ["+a.Ia()+"]";ew(a)}}finally{fw(a)}}},fw=function(a,b){if(a.b){cw(a);var c=a.b,d=a.M[0]?Ya:null;
a.b=null;a.M=null;b||a.I("ready");try{c.onreadystatechange=d}catch(e){ns(a.l,"Problem encountered resetting onreadystatechange: "+e.message)}}},cw=function(a){a.b&&a.K&&(a.b.ontimeout=null);a.A&&(ju(a.A),a.A=null)},iw=function(a){var b=a.Ia();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.D).match(aq)[1]||null,!a&&Pa.self&&Pa.self.location&&(a=Pa.self.location.protocol,a=a.substr(0,a.length-1)),b=!Wv.test(a?a.toLowerCase():
"");c=b}return c},hw=function(a){return a.b?a.b.readyState:0};Vv.prototype.Ia=function(){try{return 2<hw(this)?this.b.status:-1}catch(a){return-1}};
var jw=function(a){try{return a.b?a.b.responseText:""}catch(b){return ps(a.l,"Can not get responseText: "+b.message),""}},kw=function(a){if(a.b)return Ov(a.b.responseText)},lw=function(a){try{if(!a.b)return null;if("response"in a.b)return a.b.response;switch(a.u){case "":case "text":return a.b.responseText;case "arraybuffer":if("mozResponseArrayBuffer"in a.b)return a.b.mozResponseArrayBuffer}ns(a.l,"Response type "+a.u+" is not supported on this browser");return null}catch(b){return ps(a.l,"Can not get response: "+
b.message),null}};Vv.prototype.getResponseHeader=function(a){if(this.b&&4==hw(this))return a=this.b.getResponseHeader(a),null===a?void 0:a};var mw=function(a){var b={};a=(a.b&&4==hw(a)?a.b.getAllResponseHeaders()||"":"").split("\r\n");for(var c=0;c<a.length;c++)if(!Ic(a[c])){var d=Yc(a[c],": ",2);b[d[0]]=b[d[0]]?b[d[0]]+(", "+d[1]):d[1]}return b},$v=function(a,b){return b+" ["+a.la+" "+a.D+" "+a.Ia()+"]"};var nw=function(){this.l=tb("mr.cloud.CredentialService")},qw=function(a){var b=new Tb,c=dr.b+"/iceconfig?key="+dr.f;a.l.info("Requesting TURN credentials from "+c);var d=Zv(c,function(){iw(d)?(a.l.info("Got TURN credentials: "+jw(d)),b.resolve(ow(a,kw(d)))):b.resolve(pw(a))},"POST",void 0,{"Content-Type":"application/json"});return b.b},ow=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.l.error("Error parsing TURN credentials.",d),[]}},pw=function(a){a.l.error("XHR failed fetching TURN credentials.",null);return[]};var rw=function(a,b,c){this.l=tb("mr.cloud.slarti.MessageHandler");this.h=a;this.g=b;this.b=c;this.f=new Map},sw=function(a,b,c,d){var e=d.deviceId,f=c.wb&&c.wb.tabId,h=b.data;return(null==f?Promise.resolve():new Promise(function(a){chrome.tabs.get(f,a)})).then(function(b){b={id:null,issuer:null,name:"stream",status:null,results:null,expirationTime:null,parameters:JSON.stringify({info:{title:b&&b.title||"",url:b&&b.url||""},sessionDescription:h.description,mediaConstraints:h.mediaConstraints,settings:h.settings})};
return a.h.send(e,b).then(function(b){return new Promise(function(d,e){a.f.set(b.id,{routeId:c.id,resolve:d,reject:e,lo:"PENDING_APPROVAL"==b.status})})})})},tw=function(a,b){return qw(a.g).then(function(c){Jv(a.b,new Zg("TURN_CREDENTIALS",{credentials:c}),b.id)})};var uw=function(a,b,c,d){this.f=a;this.h=b;this.g=c;this.b=d},xw=function(a,b,c,d,e){return new Promise(function(f){switch(b){case "slarti":case "weave":case "mesi":break;default:throw Error("Unrecognized channel type: "+b);}if(!c.type)throw Error("Message has no type");switch(c.type){case "STOP":f(Kv(a.b,d,1,null));return;case "SESSION_START_SUCCESS":Wq(0);break;case "SESSION_END":break;case "SESSION_FAILURE":Wq(1);f(Kv(a.b,d,2,new Mf(Av,"warning")));return;case "__webrtc_stats__":break;case "PRESENTATION_CONNECTION_MESSAGE":Jv(a.b,
c.data,d.id,!0);break;case "OFFER":switch(b){case "slarti":f(sw(a.f,c,d,e));return;case "weave":f(vw(a.h,c,d,e));return;default:throw Error("Unexpected channel type: "+b);}case "GET_TURN_CREDENTIALS":switch(b){case "slarti":f(tw(a.f,d));return;case "weave":f(ww(a.h,d));return;default:throw Error("Unexpected channel type: "+b);}case "REFRESH_AUTH":case "LOCAL_PRESENT":case "MUTE":case "STATUS_REQUEST":case "STATUS_RESPONSE":case "HANGOUT_INACTIVE":case "HANGOUT_INVALID":f(Lv(a.g,c,d,e));return;case "new_session":Jv(a.b,
c,d.id,!0);break;case "remove_session":Jv(a.b,c,d.id,!0);a.b.terminateRoute(d.id);break;default:throw Error("Unknown type: "+c.type);}f()})};var yw=function(a,b,c){this.state=a;this.type=null!=b?b:null;this.results=null!=c?c:null},zw=function(a){this.b=a},Cw=function(a,b,c,d){return Aw(a,vr,b,c,d,35E3).then(function(b){return Bw(a,b)})},Ew=function(a,b,c,d){return Aw(a,wr,b,c,d,23E3).then(function(a){var b=a.state;return"done"==b?(a=Dw(a),new yw(b,a.type,new sr(a.sessionDescription))):new yw(b)})},Aw=function(a,b,c,d,e,f){var h={_webrtcMessage:JSON.stringify(d.presentationUrl?new sr(d.description,null,d.presentationUrl,d.presentationId):
new sr(d.description))};d.settings&&(h._settings=Wg(d.settings));d.mediaConstraints&&(h._optMediaConstraints=JSON.stringify(d.mediaConstraints));e&&(h._user=JSON.stringify(e));return Fw(a,c,b,h,f)},Bw=function(a,b){var c=b.state;switch(c){case "done":return Promise.resolve(Gw(b));case "queued":case "inProgress":return Hw(a,b).then(function(b){return Bw(a,b)});default:return Promise.resolve(new yw(c))}},Hw=function(a,b){return new Promise(function(c){var d=setInterval(function(){Iw(a,b.id).then(function(a){"queued"!=
a.state&&"inProgress"!=a.state&&(clearInterval(d),c(a))})},2E3)})},Gw=function(a){a=Dw(a);return"__cloud_webrtc_session_message__"==a.type?new yw("done","knocking_cloud_webrtc_session_message",new sr(a.sessionDescription)):new yw("done",a.type)},Fw=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=lr($q.b,["commands"],c);return nr(a.b,e,"POST",b)},Dw=function(a){return a.results&&a.results.results?
JSON.parse(a.results.results):null},Iw=function(a,b){b=lr($q.b,["commands",b]);return nr(a.b,b,"GET")};zw.$inject=["gapiService"];var Jw=function(a,b,c,d){this.f=a;this.h=b;this.g=c;this.b=d},vw=function(a,b,c,d){return Kw(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 Zg("ANSWER",b.results.sessionDescription);Jv(a.b,b,d);break;case "knocking_cloud_webrtc_session_message":Vq(0);b=new Zg("KNOCK_ANSWER",b.results.sessionDescription);Jv(a.b,b,d);break;case "knock_denied":Vq(1);Lw(a,
Bv,d);break;case "knock_timeout":Vq(2);Lw(a,Cv,d);break;default:d=Promise.reject(Error("Invalid message type: "+b.type));break a}d=Promise.resolve()}}return d})},ww=function(a,b){return qw(a.g).then(function(c){Jv(a.b,new Zg("TURN_CREDENTIALS",{credentials:c}),b.id)})},Kw=function(a,b,c){var d=c.deviceId,e=a.h.b;e=e?new qr(e):void 0;b=b.data;switch(c.nh){case "owner":Yq(0);break;case "manager":Yq(1);break;case "user":Yq(2);break;case "viewer":Yq(3)}return"viewer"==c.nh?Cw(a.f,d,b,e):Ew(a.f,d,b,e)},
Lw=function(a,b,c){b=new Mf(b,"warning");b.isBlocking=!0;a.b.b.wd(b);Jv(a.b,new Zg("STOP"),c)};var Mw=function(){var a=this;this.l=tb("mr.cloud.settings.SettingsService");this.b=null;chrome.settingsPrivate.onPrefsChanged.addListener(function(b){Ag(13);if(a.b){b=ma(b);for(var c=b.next();!c.done;c=b.next())if(c=c.value,"media_router.cloudservices.enabled"==c.key){a.b.call(null,c.value);break}}})},Nw=function(a,b){a.b=b},Ow=function(a){var b=a.l;chrome.storage.sync.set({"mr.cloud.cloudEnabled":!0},function(){chrome.runtime.lastError&&v(b,"Error setting cloud setting: "+JSON.stringify(chrome.runtime.lastError))})},
Qw=function(a){return Pw().catch(function(){return Pw().catch(function(b){v(a.l,"Error retrieving cloud on setting.",b);return!1})})},Pw=function(){return Rw("mr.cloud.cloudEnabled").then(function(a){return!!a["mr.cloud.cloudEnabled"]})},Rw=function(a){return new Promise(function(b,c){chrome.storage.sync.get(a,function(a){chrome.runtime.lastError?c(chrome.runtime.lastError):b(a)})})},Tw=function(a){return Sw().catch(function(){return Sw().catch(function(b){v(a.l,"Error retrieving cloud enabled setting.",
b);return!1})})},Sw=function(){return Uw().then(function(a){return!!a.value})},Uw=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)})})},Vw=function(a){var b=a.l;chrome.storage.sync.set({"mr.cloud.notifiedHangouts":!0},function(){chrome.runtime.lastError&&v(b,"Error setting notified Hangout privacy.",chrome.runtime.lastError)})},Xw=function(a){return Ww().catch(function(){return Ww().catch(function(b){v(a.l,
"Error retrieving hangouts notified setting.",b);return!1})})},Ww=function(){return Rw("mr.cloud.notifiedHangouts").then(function(a){return!!a["mr.cloud.notifiedHangouts"]})};var Yw=new Map([["displayName","display_name"],["description","description"],["type","type"],["status","status"],["state","state"],["commandDefs","command_defs"]]),Zw=function(a,b){nu.call(this,a,b)};l(Zw,nu);g=Zw.prototype;g.act=function(a,b){a=new Ds({method:"POST",ic:this.b,qc:["devices:act"],cb:this.cb,body:{gcmId:b,id:a}});return this.f.execute(a).then(function(a){return a})};g.create=function(a){a=new Ds({method:"POST",ic:this.b,qc:["devices"],cb:this.cb,body:a});return this.f.execute(a).then(function(a){return a})};
g.delete=function(a){a=new Ds({method:"DELETE",ic:this.b,qc:["devices",a],cb:this.cb});return this.f.execute(a)};g.get=function(a){a=new Ds({method:"GET",ic:this.b,qc:["devices",a],cb:this.cb});return this.f.execute(a).then(function(a){return a})};g.list=function(a){var b=a.type,c=a.status;a=a.permission;var d={};b&&(d.type=b);c&&(d.status=c);a&&(d.permission=a);b=new Ds({method:"GET",ic:this.b,qc:["devices"],Rk:d,cb:this.cb});return this.f.execute(b).then(function(a){return a.device||[]})};
g.update=function(a,b){for(var c=[],d={},e=ma(Yw.keys()),f=e.next();!f.done;f=e.next())f=f.value,b[f]&&(d[f]=b[f],c.push(Yw.get(f)));d.id=a;a=new Ds({method:"PUT",ic:this.b,qc:["devices",a],cb:this.cb,body:{device:d,updateMask:c}});return this.f.execute(a).then(function(a){return a})};var $w=function(a,b,c,d,e,f){f=void 0===f?null:f;this.l=tb("mr.cloud.slarti.SinkDiscoveryService");this.s=a;this.h=b;this.f=c;this.j=d;this.g=e;this.b=f||new Hr(this.m.bind(this),c,36E5);uu().addListener();qj(this);xg("mr.cloud.slarti.SinkDiscoveryService",this)};l($w,mg);$w.prototype.xd=function(){ru(this.g).catch(function(){});return this.b.xd().filter(function(a){return a.isAvailable})};$w.prototype.ha=function(a){return this.b.ha(a)};
$w.prototype.handleEvent=function(a,b){if(a!=chrome.gcm.onMessage)throw Error("Unhandled event: expected chrome.gcm.onMessage");ax(this,b)};
var ax=function(a,b){b=JSON.parse(b.data.data);Ab(a.l,"Got notification: "+JSON.stringify(b));switch(b.type){case "DEVICE_ADDED":bx(a,b).then(function(b){"cast-receiver"==b.type&&(b=new Gr(b.id,b.displayName,"ONLINE"==b.status),a.b.b.set(b.Fa.id,b),Lr(a.f,[b.Fa]))});break;case "DEVICE_CHANGED":bx(a,b).then(function(b){if("cast-receiver"==b.type){var c=Lj(Kj(),b.id);if(c=a.b.ha(c))c.isAvailable="ONLINE"==b.status,Mr(a.f,[c.Fa])}});break;case "DEVICE_REMOVED":cx(a,dx(b));Promise.resolve();break;case "COMMAND_CHANGED":ex(a,
b).then(function(b){var c=a.j,e=b.id,f=c.f.get(e);if(f){var h=f.routeId,k=f.resolve,n=f.reject,u=f.lo;f=!0;try{var z=JSON.parse(b.results||"{}"),B=z.sessionDescription,D=z.errorCode,R=z.errorText;switch(b.status){case "SUCCESS":k(Jv(c.b,new Zg("ANSWER",B),h));u&&Vq(0);break;case "ERROR":case "TIMEOUT":var la="TIMEOUT"==b.status;k=Av;"KNOCK_DENIED"==D&&(Vq(la?2:1),k=la?Cv:Bv);var ra=c.b,Db=new Mf(k,"warning");Db.isBlocking=!0;Db.routeId=h;ra.b.wd(Db);Jv(c.b,new Zg("STOP"),h);throw Error("Slarti command "+
e+" failed with status: "+(b.status+", errorCode: "+D+", ")+("errorText: "+R));default:f=!1}}catch(pb){n(pb)}f&&c.f.delete(e)}else v(c.l,"Received update to unknown command with "+("name = "+b.name+" and id = "+e))});break;default:Promise.resolve()}};$w.prototype.m=function(){return this.h.list({type:"cast-receiver"}).then(function(a){return a.map(function(a){return new Gr(a.id,a.displayName,"ONLINE"==a.status)})})};$w.prototype.ua=function(){return"SlartiSinkDiscoveryService"};$w.prototype.Ta=function(){return[{cache:Pr(this.b)}]};
$w.prototype.Ya=function(){var a=nj(this);a&&Qr(this.b,a.cache)};var cx=function(a,b){b=Lj(Kj(),b);var c=a.b.ha(b);c&&(a.b.b.delete(b),Nr(a.f,[c.Fa]))},dx=function(a){a=a.deviceInfo;return a.device?a.device.id:a.deviceId},bx=function(a,b){b=b.deviceInfo;return b.device?Promise.resolve(b.device):a.h.get(b.deviceId)},ex=function(a,b){b=b.commandInfo;return b.command?Promise.resolve(b.command):a.s.get(b.commandId)};var fx=function(){this.b=null},gx=function(a,b){if(!a.b||O(a.b,2)<O(b,2))a.b=Ri(b)},hx=function(a){return a.b?O(a.b,2)+";"+O(a.b,1):null};var ix=function(){this.s=this.L=this.F=this.B=this.A=this.h=this.u=this.g=this.f=this.j=this.Z=this.T=this.K=this.C=this.M=this.P=this.ka=this.D=this.m=this.o=this.b=null},jx=function(){var a=ix.Ha();null==a.s&&(a.s=new fx);return a.s},kx=function(a){null==a.b&&(a.b=new ys);return a.b},lx=function(a){null==a.o&&(a.o=new Pu(kx(a)));return a.o},mx=function(a){null==a.m&&(a.m=new lu(kx(a)));return a.m},nx=function(a){null==a.D&&(a.D=new Nv(kx(a),mx(a)));return a.D},px=function(a,b){null==a.C&&(a.C=new rw(nx(a),
ox(a),b));return a.C},qx=function(a){null==a.u&&(a.u=new zw(lx(a)));return a.u},ox=function(a){null==a.L&&(a.L=new nw(lx(a)));return a.L};ab(ix);var ux=function(a,b){this.g=a;this.m=b;this.s=new Tb;this.f=this.s.b;this.b=rx(a.id);this.h=new Tb;this.j=!1;sx(this);tx(this);this.b.sendMessage(new Zg("GET_TURN_CREDENTIALS"))};ux.prototype.start=function(){var a=this;return this.f.then(function(b){if(b.f)return Promise.reject(Error("Presentation already started"));b.start();return a.h.b})};ux.prototype.stop=function(){var a=this;this.j=!1;return this.f.then(function(b){b.stop();a.f=Promise.reject(Error("Peer connection has already been stopped"))})};
var sx=function(a){a.b.onMessage=function(b){if(b.type)switch(b.type){case "TURN_CREDENTIALS":a.s.resolve(new dh(a.g.id,b.data.credentials));break;case "ANSWER":a.f.then(function(a){lh(a,b.data)});break;case "STOP":a.h.reject("Stop signal received");a.stop();break;default:throw Error("Unknown message type: "+b.type);}else a.f.then(function(a){var c={type:"PRESENTATION_CONNECTION_MESSAGE",data:b};"string"==typeof c?a.j.send(c):a.j.send(JSON.stringify(c))})}},tx=function(a){a.f.then(function(b){hh(b,
function(b){a.b.sendMessage(new Zg("OFFER",new ah(b,null,null,a.m,a.g.id)))});ih(b,function(b){b=$g(b);"STOP"==b.type&&a.stop();a.b.sendMessage(b)});eh(b,function(){a.j=!0;a.b.sendMessage(new Zg("SESSION_START_SUCCESS"));a.h.resolve(a.g)});gh(b,function(){a.b.sendMessage(new Zg("SESSION_END"))});fh(b,function(b){a.j||a.h.reject(b);a.b.sendMessage(new Zg("SESSION_FAILURE"))})})};var vx=function(a){this.b=a;this.f=new Map;this.F=new Map;this.C=new Map;this.o=[];this.j=this.D=this.A=this.L=this.s=null;this.m=this.g=this.h=!1;this.B=new Map;this.u=new Map;qj(this)};vx.prototype.getName=function(){return"cloud"};
vx.prototype.Xa=function(){var a=this;this.l.info("Initializing Cloud MRP");var b=ix.Ha();null==b.Z&&(null==b.T&&(b.T=new yr(lx(b))),b.Z=new Du(b.T,this));this.o.push(b.Z);if(null==b.M){var c=nx(b);null==b.ka&&(b.ka=new Zw(kx(b),mx(b)));var d=b.ka,e=px(b,this);null==b.K&&(null==b.P&&(b.P=new ou(kx(b),mx(b))),b.K=new pu(b.P));b.M=new $w(c,d,this,e,b.K)}this.o.push(b.M);null==b.g&&(null==b.f&&(b.f=new fr(lx(b),kx(b))),c=b.f,null==b.j&&(b.j=new Gv(lx(b))),b.g=new ss(c,b.j,this));this.s=b.g;this.o.push(this.s);
this.L=qx(b);px(b,this);this.A=kx(b);null==b.B&&(c=px(b,this),null==b.h&&(b.h=new Jw(qx(b),kx(b),ox(b),this)),d=b.h,null==b.A&&(b.A=new Iv(kx(b),this)),b.B=new uw(c,d,b.A,this));this.D=b.B;null==b.F&&(b.F=new Mw);this.j=b.F;Tw(this.j).then(function(b){a.h=b;a.l.info("Cloud enabled setting: "+a.h)});Qw(this.j).then(function(b){a.g=b;a.l.info("Cloud on setting: "+a.g)});Nw(this.j,function(b){a.h=b;a.l.info("Cloud enabled setting: "+a.h);a.h&&wx(a)});Xw(this.j).then(function(b){a.m=b;a.l.info("Privacy notified setting: "+
a.m)})};vx.prototype.Vc=function(){return Array.from(this.f.values())};
vx.prototype.wf=function(a){if(!xx(this,a))return Jo;Ab(this.l,"GetAvailableSinks for "+a);var b=[];if(this.g||yx())b=wx(this);this.u.clear();for(var c={},d=ma(this.B.values()),e=d.next();!e.done;c={We:c.We,Ag:c.Ag},e=d.next())c.We=e.value,c.Ag=!1,b.forEach(function(a){return function(b){b.Fa.id==a.We.Fa.id&&(a.Ag=!0,b.Fa.friendlyName=a.We.Fa.friendlyName)}}(c)),c.Ag||this.u.set(c.We.Fa.id,c.We);b=b.concat.apply(b,xa(this.u.values()));Ab(this.l,function(){return"Available sinks are..."+JSON.stringify(b)});
c=b.map(function(a){return a.Fa});this.s&&(c=c.concat(zx));return new Io(c,-1!=a.indexOf("0F5096E8")?Fg:null)};var wx=function(a){var b=[];a.l.info("Checking cloud discovery services");Kj().g=q();a.o.forEach(function(a){a=a.xd();b=b.concat(a)});return b};g=vx.prototype;g.startObservingMediaSinks=function(){};g.stopObservingMediaSinks=function(){};g.startObservingMediaRoutes=function(){};g.stopObservingMediaRoutes=function(){};g.ha=function(a){return(a=Ax(this,a))?a.Fa:null};
g.createRoute=function(a,b,c,d,e,f,h){var k=this;this.l.info("createRoute called");Ab(this.l,"urn: "+a+" sinkId:"+b);if(e=this.F.get(b))return Qf(this.b.sk(this,e,a,c,function(b){b.mediaSource=a;b.wb.tabId=h;return Rf(b)}),function(a){k.b.ae(a);return a});e=Ax(this,b);return Bx(this,a,e,b,c,d,h)};
var Cx=function(a,b,c,d,e){b instanceof Ho&&2==b.errorCode?Kv(a,c,6,null):(a.l.error("Error on start session",b instanceof Error?b:Error("Expected an Error value, got "+b)),a.f.has(c.id)&&Kv(a,c,e,new Mf(Av,"warning")));if(b=a.s)b=a.s,b.f.delete(d.deviceId)?(b.b.b.delete(d.Fa.id),b=!0):b=!1;b&&Nr(a,[d.Fa])},Bx=function(a,b,c,d,e,f,h){if(f)return Sf(Error("not supported"));f=!1;switch(c.b){case "slarti":case "weave":Xq(1);break;case "mesi":f=!0;if(!a.m){a.m=!0;Vw(a.j);var k=Of();a.b.wd(k)}Xq(0)}Kj().h=
new Hj(c.model,null);var n=Kn(e,a.getName(),d,b,!0,"");f&&(n.customControllerPath="cloud_route_details/view.html?routeId="+n.id,n.controllerType=mojo.RouteControllerType&&mojo.RouteControllerType.kHangouts);a.f.set(n.id,n);a.F.set(d,n);a.B.set(n.id,c);a.C.set(n.id,c.b);a.b.Pe(a,n);a.b.Te(a.ua(),!0);if(Eg(b)&&!f)return a.l.info("starting presentation on route: "+n.id),Dx(n,b).catch(function(b){Cx(a,b,n,c,7);throw b;});a.l.info("starting mirroring on route: "+n.id);n.wb={tabId:h,sessionId:"",Vf:"",
je:c.model};Eg(b)&&(n.isOffscreenPresentation=!0);return a.b.Wh(a,n,e).catch(function(b){Cx(a,b,n,c,5);throw b;})};vx.prototype.terminateRoute=function(a){var b=this.f.get(a);return b?Kv(this,b,0,null):Promise.reject(new Ho(3,"Route in cloud provider not found for routeId "+a))};
var Kv=function(a,b,c,d){a.l.info("terminating route: "+b.id);a.f.delete(b.id);a.F.delete(b.sinkId);var e=a.B.get(b.id);a.B.delete(b.id);d&&a.b.wd(d);Rb("MediaRouter.Cloud.Session.End",c,Sq);switch(c){case 1:break;default:switch(e.b){case "weave":Fw(a.L,e.deviceId,xr,{})}}a.b.Gf(b);0==a.f.size&&a.b.Te(a.ua(),!1);a.b.onPresentationConnectionStateChanged(b.id,"terminated");a.u.has(b.sinkId)&&(c=a.u.get(b.sinkId),Nr(a,[c.Fa]),a.u.delete(b.sinkId));return Promise.resolve()};g=vx.prototype;
g.sendRouteMessage=function(a,b){var c=this.C.get(a);if(c){var d=(a=this.f.get(a)||void 0)?Ax(this,a.sinkId):void 0;return xw(this.D,c,b,a,d)}return Ra(b)?(Jv(this,b,a),Promise.resolve()):Promise.reject(Error("Channel type missing"))};g.sendRouteBinaryMessage=function(a){return Promise.reject(Error("Route "+a+" does not support sending binary data."))};
g.De=function(a){var b=new Xg;5>b.minFrameRate&&(b.minFrameRate=5);var c=this.Sd(a);"hangouts"!=c&&"meetings"!=c&&(b.senderSideLetterboxing=!0);Yg(b);Object.freeze(b);this.l.info("Settings for "+a+": "+Wg(b));if(!b.shouldCaptureAudio&&!b.shouldCaptureVideo)throw Error("Cannot start mirroring without video or audio capture.");return b};g.Sd=function(a){var b=null;a=Ax(this,a);switch(a.b){case "slarti":case "weave":b="webrtc";break;case "mesi":b=a.Bc?"meetings":"hangouts"}return b};g.Qg=function(){};
g.qf=function(a,b){Ab(this.l,"Checking canRoute: "+a+" for sinkId: "+b);return xx(this,a)&&!!this.ha(b)};g.oe=function(a,b){return("https://hangouts.google.com/cloudmrp-mirroring"==a||Eg(a))&&this.f.has(b)};g.joinRoute=function(a,b){return(a=this.f.get(b))?(this.l.info("joining route: "+a.id),Rf(a)):Sf(Error("not supported"))};g.connectRouteByRouteId=function(){return Sf(Error("not supported"))};g.detachRoute=function(){};
var Lr=function(a,b){a.l.info(b.length+" sinks added");0<b.length&&!a.g&&(Ow(a.j),a.g=!0);b=Ax(a,b[0].id);Kj().f=new Hj(b.model,null);a.b.Jc();a.b.onSinkAvailabilityUpdated(a,2);a.l.info("sinkAvailability changed to AVAILABLE")},Nr=function(a,b){a.l.info(b.length+" sinks removed");a.o.some(function(a){return 0<a.xd().length})||(a.b.onSinkAvailabilityUpdated(a,0),a.l.info("sinkAvailability changed to UNAVAILABLE"));a.b.Jc()},Mr=function(a,b){a.l.info(b.length+" sinks updated");a.b.Jc()},Jv=function(a,
b,c,d){(void 0===d?0:d)?a.b.vd(c,b):a.b.Pg(c,b)},Ax=function(a,b){var c=Ex(a,b);c||(c=null,(b=a.F.get(b))&&(c=a.B.get(b.id)));return c},Ex=function(a,b){var c=null;a.o.some(function(a){c=a.ha(b);return!!c});return c},yx=function(){var a=Kj().g;return 3E5<=Date.now()-a},xx=function(a,b){var c=Dg(b);b=Eg(b);if(a.A.h&&!a.A.f&&c)return a.b.onSinkAvailabilityUpdated(a,2),!0;var d=!1;a.h&&a.A.f&&(d=!0);var e;if(e=!chrome.declarativeWebRequest)a=a.A,e=!(a.h||a.f&&a.b&&(-1!=Cs.indexOf(a.b)||-1!=Cs.indexOf(zs(a))))&&
b;return e?!1:d&&(c||b)};vx.prototype.searchSinks=function(a,b){var c=this;if(!xx(this,a))return Promise.reject(Error("err"));a=vs(this.s,b);a.then(function(a){Lr(c,[a])});return a};var Fx=function(a,b){b=a.f.get(b);if(!b)return Promise.reject(Error("Route not found"));a=a.Sd(b.sinkId);return"hangouts"!=a&&"meetings"!=a?Promise.reject(Error("Unsupported sink channel type")):Pq(og.get("mr.ProviderManager")||null,a)};g=vx.prototype;
g.createMediaRouteController=function(a,b,c){return Fx(this,a).then(function(d){return d.createMediaRouteController(a,b,c)})};g.provideSinks=function(){};g.ua=function(){return"CloudProvider"};g.Ta=function(){return[void 0,{cloudEnabled:this.h,cloudOn:this.g,notifiedHangoutsPrivacy:this.m}]};g.Ya=function(){var a=oj(this);a&&(a.cloudEnabled&&(this.h=a.cloudEnabled),a.cloudOn&&(this.g=a.cloudOn),a.notifiedHangoutsPrivacy&&(this.m=a.notifiedHangoutsPrivacy))};var Dx=function(a,b){a=new ux(a,b);return Tf(a.start())};
vx.prototype.l=tb("mr.CloudProvider");var zx=new jj("pseudo:cloud","","meeting","","default");var Gx=function(){ik.call(this,12,"ExternalMessageListener","mr.ProviderManager",chrome.runtime.onMessageExternal)};l(Gx,ik);Gx.prototype.Zf=function(a,b){return b.id&&-1!=Hx.indexOf(b.id)?"start"==a.type||"stop"==a.type||"subscribe_log_data"==a.type:!1};Gx.prototype.xh=function(){return!0};var Jx=function(){Ix||(Ix=new Gx);return Ix},Ix=null,Hx=["idmofbkcelhplfjnmmdolenpigiiiecc","ggedfkijiiammpnbdadhllnehapomdge","njjegkblellcjnakomndbaloifhcoccg"];var Kx=function(){ik.call(this,11,"InternalMessageListener","mr.ProviderManager",chrome.runtime.onMessage)};l(Kx,ik);Kx.prototype.Zf=function(a,b){return"retrieve_log_data"==a.type&&b.id==chrome.runtime.id&&b.url=="chrome-extension://"+b.id+"/feedback.html"};Kx.prototype.xh=function(){return!0};var Mx=function(){Lx||(Lx=new Kx);return Lx},Lx=null;function Nx(){var a=Ox;var b=new Ko(a);var c=new Up(a,b);b=[b,c];b.push(new vx(a));return b};var Px=function(a,b){this.routeId=a;this.message=b},Qx=function(a){return"string"!=typeof a.message};var Rx=function(a){this.A=a;this.g=this.j=null},Sx=function(a){if(null==a.g)if(null==a.j||Date.now()-a.j>=a.A)a.s();else{var b=Math.max(a.j+a.A-Date.now(),5);a.g=setTimeout(a.s.bind(a),b)}};Rx.prototype.s=function(){null!=this.g&&(clearTimeout(this.g),this.g=null);this.u();this.j=Date.now()};Rx.prototype.u=function(){};var Tx=function(a,b){Rx.call(this,20);this.b=new Map;this.f=new Set;this.o=null;this.m=this.h=0;this.B=!1;this.C=a;this.F=b;this.l=tb("mr.RouteMessageSender")};l(Tx,Rx);Tx.prototype.init=function(a){this.o=a;qj(this)};Tx.prototype.stopListeningForRouteMessages=function(a){this.f.delete(a)};
Tx.prototype.send=function(a,b){var c=this.b.get(a);c||(c=[],this.b.set(a,c));b=new Px(a,b);c.push(b);50<c.length&&1==c.length%50&&v(this.l,function(){return"Message queue length is excessively large "+("("+c.length+") for route "+a)});this.h+=Qx(b)?0:b.message.length;Qx(b)&&this.m++;Ux(this);this.f.has(a)&&Sx(this)};
var Vx=function(a,b){if(0!=b.length){b=ma(b);for(var c=b.next();!c.done;c=b.next())c=c.value,a.h-=Qx(c)?0:c.message.length,Qx(c)&&a.m--}},Ux=function(a){var b=0<a.m||a.h>a.F;b!=a.B&&(a.B=b,a.C.Te(a.ua(),b))};Tx.prototype.u=function(){if(this.o){for(var a=ma(this.f),b=a.next();!b.done;b=a.next()){b=b.value;var c=this.b.get(b);c&&0!=c.length&&(this.o(b,c),Vx(this,c),this.b.set(b,[]))}Ux(this)}else this.l.error("sendMessagesCallback not set. Messages not delivered.")};Tx.prototype.ua=function(){return"mr.RouteMessageSender"};
Tx.prototype.Ta=function(){var a=[].concat(xa(this.b.entries())).map(function(a){return[a[0],a[1].map(function(a){return a.message})]});return[new Wx(a,Array.from(this.f),this.h)]};Tx.prototype.Ya=function(){var a=nj(this);if(a){this.b=new Map;for(var b={},c=ma(a.f),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 Px(a.routeId,b)}}(b)),this.b.set(b.routeId,d);this.f=new Set(a.b);this.h=a.h}};
var Wx=function(a,b,c){this.f=a;this.b=b;this.h=c};var Xx=function(a,b){this.type="internal_message";this.routeId=a;this.message=b};var Yx=function(a,b,c){this.b=a;this.g=b;this.h=c;this.onMessage=function(){};c.listen("internal_message",this.f,this)};Yx.prototype.sendMessage=function(a,b){return this.g(this.b,a,b)};Yx.prototype.f=function(a){if(a.routeId==this.b)this.onMessage(a.message)};Yx.prototype.Ra=function(){this.onMessage=function(){};dp(this.h,this.f,this)};
var Zx=new Yx("",function(){return Promise.resolve()},new cp),$x=function(a){this.b=a},rx=function(a){var b=Kf,c=b.b.Eh(a);return c?new Yx(a,c.sendRouteMessage.bind(c),b.b.Gh()):Zx};var ay=function(a,b){this.s=null!=b?a.bind(b):a;this.j=this.m.bind(this);this.g=[];this.b=!1;this.f=null};ay.prototype.h=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c-0]=arguments[c];this.g=[].concat(xa(b));null==this.f?by(this):this.b=!0};var by=function(a){a.f=setTimeout(a.j,500);a.s.apply(a,xa(a.g))};ay.prototype.m=function(){this.f=null;this.b&&(this.b=!1,by(this))};var cy=function(){this.l=tb("mr.ProviderManager");this.h=[];this.b=new Map;this.m=new Map;this.j=new Set;this.g=new Set;this.A=new Map;this.f=this.u=null;this.ka=new cp;this.K=new ay(this.fl,this);this.T=new ay(this.D,this);this.s=new Tx(this,524288);this.L=0;this.o=new Map;this.C=-1==window.navigator.userAgent.indexOf("Windows");this.F=[];this.B=[];var a=new Kq(this);this.P=a.onMessage.bind(a);a=new Aq(this);this.M=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};l(cy,mg);
cy.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.P.apply(this,xa(c));else if(a==chrome.runtime.onMessageExternal)this.M.apply(this,xa(c));else throw Error("Unhandled event");};
var Pq=function(a,b){b=a.A.get(b);return rg(b).then(function(b){b.Xa(a);return b})},dy=function(a,b,c){b.forEach(function(b){if(Oq(a,b.getName()))v(a.l,"Provider "+b.getName()+" already registered.");else try{b.Xa(c),a.h.push(b),a.o.set(b.getName(),0)}catch(e){v(a.l,"Provider "+b.getName()+" failed to initialize.",e)}})};
cy.prototype.Xa=function(a,b,c){this.A.set("webrtc","mr.mirror.webrtc.WebRtcService");this.A.set("cast_streaming","mr.mirror.cast.Service");this.A.set("hangouts","mr.mirror.hangouts.HangoutsService");this.A.set("meetings","mr.mirror.hangouts.MeetingsService");var d=new $x(this);Kf||(Kf=d);this.f=a;this.s.init(this.f.onRouteMessagesReceived.bind(this.f));dy(this,b,c);qj(this);xg("mr.ProviderManager",this)};
var fy=function(a,b,c){return new Promise(function(d,e){var f=null;a.L++;ey(a);f=window.setTimeout(function(){f=null;b.cancel(new Ho(2,"timeout after "+c+" ms."))},c);b.b.then(function(b){a.L--;ey(a);null!=f&&window.clearTimeout(f);d(b)},function(b){a.L--;ey(a);null!=f&&window.clearTimeout(f);e(b instanceof Ho?b:b instanceof Error?new Ho(0,b.message,b.stack):new Ho(0))})})};cy.prototype.onBeforeInvokeHandler=function(){Ag(0)};
var gy=function(a){return"string"==typeof a?a:a.unique?"":a.scheme+"://"+a.host+"\n       "+(a.port?":"+a.port:"")+"/"};g=cy.prototype;
g.createRoute=function(a,b,c,d,e,f,h){var k=this;h=void 0===h?!1:h;var n=hy(this,a,b);if(!n)return Promise.reject(new Ho(7,"No provider supports createRoute with source: "+a+" and sink: "+b));var u=void 0;void 0!==d&&(u=gy(d));f=f&&0<f?f:6E4;a=n.createRoute(a,b,c,h,f,u,e);return fy(this,a,f).then(function(a){return a},function(a){k.l.error("Error creating route.",a);throw a;})};
g.connectRouteByRouteId=function(a,b,c,d,e,f){var h=this.b.get(b);if(!h)return Promise.reject(new Ho(7,"No provider supports join "+b));a=h.connectRouteByRouteId(a,b,c,gy(d),e);return fy(this,a,f&&0<f?f:3E4)};g.joinRoute=function(a,b,c,d,e,f){f=void 0===f?!1:f;var h=iy(this,a,b);if(!h)return Promise.reject(new Ho(7,"No provider supports join "+b));e=e&&0<e?e:3E4;a=h.joinRoute(a,b,f,e,gy(c),d);return fy(this,a,e)};
g.terminateRoute=function(a){var b=this.b.get(a);return b?jy(this,a).then(function(){return b.terminateRoute(a)}):Promise.reject(new Ho(3,"Route not found for routeId "+a))};g.startObservingMediaSinks=function(a){this.j.has(a)||(this.j.add(a),this.h.forEach(function(b){b.startObservingMediaSinks(a)}));ky(this,a)};g.stopObservingMediaSinks=function(a){this.j.delete(a)?ly(this,a):this.l.info("No existing query "+a)};
var ly=function(a,b){a.h.forEach(function(a){a.stopObservingMediaSinks(b)})},ky=function(a,b){if("urn:x-org.chromium.media:source:tab:-1"==b)v(a.l,"No sinks for sourceUrn: "+b);else{var c=new Map,d=[];a.h.forEach(function(e){var f=e.wf(b);0<f.sinks.length&&(d=f.origins);f.sinks.forEach(function(b){c.has(b.id)?v(a.l,"Detected duplicate sink "+b.id+" from provider: "+e.getName()):c.set(b.id,b)})});my(a,b,Array.from(c.values()),d||[])}},my=function(a,b,c,d){a.l.info("Sending "+c.length+" sinks to MR for "+
b);a.f.onSinksReceived(b,c,d.map(Em))};g=cy.prototype;g.sendRouteMessage=function(a,b,c){var d=this.b.get(a);d?(a=d.sendRouteMessage(a,b,c),a=fy(this,Tf(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};g.sendRouteBinaryMessage=function(a,b){var c=this.b.get(a);c?(a=c.sendRouteBinaryMessage(a,b),a=fy(this,Tf(a),3E4)):a=Promise.reject(Error("Invalid route ID "+a));return a};
g.startListeningForRouteMessages=function(a){var b=this.s;b.f.has(a)||(b.f.add(a),(a=b.b.get(a))&&0<a.length&&Sx(b))};g.stopListeningForRouteMessages=function(a){this.s.stopListeningForRouteMessages(a)};g.detachRoute=function(a){var b=this.b.get(a);b?b.detachRoute(a):this.l.info("Route "+a+" does not exist.")};g.enableMdnsDiscovery=function(){this.C=!0;this.F.forEach(function(a){a()});this.F.length=0};
var hy=function(a,b,c){return a.h.find(function(a){return a.qf(b,c)})||null},iy=function(a,b,c){return a.h.find(function(a){return a.oe(b,c)})||null};cy.prototype.D=function(){var a=this;this.j.forEach(function(b){ky(a,b)})};var ey=function(a){a.f.setKeepAlive(0<a.L||0<a.B.length)};g=cy.prototype;g.startObservingMediaRoutes=function(a){this.g.has(a)||(this.g.add(a),this.h.forEach(function(b){b.startObservingMediaRoutes(a)}));this.K.h()};
g.stopObservingMediaRoutes=function(a){this.g.delete(a)?this.h.forEach(function(b){b.stopObservingMediaRoutes(a)}):this.l.info("No existing route query "+a)};g.fl=function(){var a=this;if(0!=this.g.size){var b=[];this.h.forEach(function(a){b=b.concat(a.Vc())});this.g.forEach(function(c){var d=[];a.h.forEach(function(a){a.Vc().forEach(function(b){!b.se&&a.oe(c,void 0,b)&&d.push(b.id)})});a.f.onRoutesUpdated(b,c,d)})}};g.ua=function(){return"ProviderManager"};
g.Ta=function(){return[new ny(this.h.map(function(a){return a.getName()}),Array.from(this.j),Array.from(this.g),Array.from(this.b,function(a){var b=ma(a);a=b.next().value;b=b.next().value;return[a,b.getName()]}),Array.from(this.o),this.C,this.u)]};g.Ya=function(){var a=nj(this);if(a){this.j=new Set(a.s);this.g=new Set(a.g);for(var b=ma(a.h),c=b.next();!c.done;c=b.next()){var d=ma(c.value);c=d.next().value;d=d.next().value;d=Oq(this,d);this.b.set(c,d)}this.o=new Map(a.j);this.u=a.b||null;a.f&&this.enableMdnsDiscovery()}};
g.Eh=function(a){return this.b.get(a)};g.Pe=function(a,b){this.b.set(b.id,a);this.ae(b)};g.Gf=function(a){jy(this,a.id);this.b.delete(a.id);var b=this.s,c=a.id;b.f.delete(c);var d=b.b.get(c);d&&(b.b.delete(c),Vx(b,d),Ux(b));this.ae(a)};g.ae=function(){0<this.g.size&&this.K.h()};g.hk=function(a){var b=this.b.get(a.id);b&&(b.Qg(a.id),0<this.g.size&&this.fl())};
g.vd=function(a,b){this.b.has(a)?("string"===typeof b||b instanceof Uint8Array||(b=JSON.stringify(b)),this.s.send(a,b)):v(this.l,"Got route message for closed route "+a)};g.onPresentationConnectionStateChanged=function(a,b){"terminated"==b&&this.s.s();this.f.onPresentationConnectionStateChanged(a,b)};g.onPresentationConnectionClosed=function(a,b,c){this.s.s();this.f.onPresentationConnectionClosed(a,b,c)};g.fi=function(a){this.m.delete(a);var b=this.b.get(a);b&&b.terminateRoute(a)};
g.Pg=function(a,b){ep(this.ka,new Xx(a,b))};g.Jc=function(){this.T.h()};g.onSinkAvailabilityUpdated=function(a,b){var c=this;if(this.o.get(a.getName())!=b){var d=oy(this);this.o.set(a.getName(),b);a=oy(this);d!=a&&(0==a&&this.D(),this.f.onSinkAvailabilityUpdated(a),0==a&&(this.j.forEach(function(a){ly(c,a)}),this.j.clear()))}};var oy=function(a){return Array.from(a.o.values()).reduce(function(a,c){return Math.max(a,c)},0)};cy.prototype.Gh=function(){return this.ka};cy.prototype.wd=function(a){this.f.onIssue(a)};
var jy=function(a,b){return a.m.has(b)?Pq(a,a.m.get(b)).then(function(c){a.m.delete(b);return Ig(c)}):Promise.resolve(!1)};g=cy.prototype;g.Wh=function(a,b,c,d){var e=this,f=a.Sd(b.sinkId);this.l.info("Starting mirroring using service: "+f);this.m.set(b.id,f);return Uf(Pq(this,f),function(h){e.u=f;return Lg(h,b,b.mediaSource,a.De(b.sinkId),c,d).catch(function(a){if(a instanceof Wf&&3==a.reason)throw new Ho(8);throw a;})})};
g.sk=function(a,b,c,d,e){var f=this,h=this.m.get(b.id);return h?Uf(Pq(this,h),function(k){f.u=h;var n=a.De(b.sinkId);k.J.info("Update mirroring on route "+b.id);return k.g?Tf(Mg(k,b,c,n,d,e)):Sf(Error("Not initialized"))}):Sf(Error("Route "+b.id+" is not mirroring"))};g.vi=function(a){this.C?a():-1==this.F.indexOf(a)&&this.F.push(a)};g.Qh=function(){return this.C};g.Te=function(a,b){var c=this.B.indexOf(a),d=0<=c;b&&!d?this.B.push(a):!b&&d&&this.B.splice(c,1);ey(this)};
var Oq=function(a,b){return a.h.find(function(a){return a.getName()==b})||null};g=cy.prototype;g.searchSinks=function(a,b,c){var d=a.startsWith("pseudo:")?a.substring(7):null;return(d=d?Oq(this,d):null)?d.searchSinks(b,c).then(function(a){return a.id}):Promise.reject(Error("No provider supports "+a))};g.provideSinks=function(a,b){var c=Oq(this,a);c?c.provideSinks(b):this.l.error("provideSinks: Provider not found for providerName "+a)};g.updateMediaSinks=function(a){this.j.has(a)||ky(this,a)};
g.createMediaRouteController=function(a,b,c){var d=this,e=this.b.get(a);return e?e.createMediaRouteController(a,b,c).catch(function(a){d.l.error("createMediaRouteController failed: "+a.message);b.close();c.ptr.reset();throw a;}):(a="createMediaRouteController: Provider not found for "+a,this.l.error(a),b.close(),c.ptr.reset(),Promise.reject(Error(a)))};g.onMediaRemoterCreated=function(a,b,c){this.f.onMediaRemoterCreated(a,b,c)};
g.getMediaSinkServiceStatus=function(){return"function"!=typeof this.f.getMediaSinkServiceStatus?Promise.resolve({status:""}):this.f.getMediaSinkServiceStatus()};var ny=function(a,b,c,d,e,f,h){this.s=b;this.g=c;this.h=d;this.j=e;this.f=f;this.b=h};
