-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathremote.js
584 lines (582 loc) · 100 KB
/
remote.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
(function(g){var window=this;'use strict';var qKa=function(a,b){return g.Lb(a,b)},rKa=function(a){if(a instanceof g.Wi)return a;
if("function"==typeof a.og)return a.og(!1);if(g.La(a)){var b=0,c=new g.Wi;c.next=function(){for(;;){if(b>=a.length)throw g.Pm;if(b in a)return a[b++];b++}};
return c}throw Error("Not implemented");},sKa=function(a,b,c){if(g.La(a))try{g.zb(a,b,c)}catch(d){if(d!==g.Pm)throw d;
}else{a=rKa(a);try{for(;;)b.call(c,a.next(),void 0,a)}catch(d){if(d!==g.Pm)throw d;}}},J4=function(a,b,c){a.l.set(b,c)},K4=function(a){J4(a,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^g.Ra()).toString(36));
return a},L4=function(a,b,c){Array.isArray(c)||(c=[String(c)]);
g.en(a.l,b,c)},tKa=function(a,b){var c=[];
sKa(b,function(d){try{var e=g.Xn.prototype.l.call(this,d,!0)}catch(f){if("Storage: Invalid value was encountered"==f)return;throw f;}void 0===e?c.push(d):g.Wn(e)&&c.push(d)},a);
return c},uKa=function(a,b){b=tKa(a,b);
g.zb(b,function(c){g.Xn.prototype.remove.call(this,c)},a)},vKa=function(a){if(a.V){if(a.V.locationOverrideToken)return{locationOverrideToken:a.V.locationOverrideToken};
if(null!=a.V.latitudeE7&&null!=a.V.longitudeE7)return{latitudeE7:a.V.latitudeE7,longitudeE7:a.V.longitudeE7}}return null},wKa=function(a,b){g.fb(a,b)||a.push(b)},M4=function(a){var b=0,c;
for(c in a)b++;return b},xKa=function(a,b){b=b instanceof g.Ac?b:g.Gc(b,/^data:image\//i.test(b));
a.src=g.Bc(b)},yKa=function(a){try{return g.B.JSON.parse(a)}catch(b){}a=String(a);
if(/^\s*$/.test(a)?0:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/(?:"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)[\s\u2028\u2029]*(?=:|,|]|}|$)/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}throw Error("Invalid JSON string: "+a);},zKa=function(a){if(a.Ag&&"function"==typeof a.Ag)return a.Ag();
if("string"===typeof a)return a.split("");if(g.La(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return g.Ib(a)},AKa=function(a,b){if(a.forEach&&"function"==typeof a.forEach)a.forEach(b,void 0);
else if(g.La(a)||"string"===typeof a)g.zb(a,b,void 0);else{if(a.Bh&&"function"==typeof a.Bh)var c=a.Bh();else if(a.Ag&&"function"==typeof a.Ag)c=void 0;else if(g.La(a)||"string"===typeof a){c=[];for(var d=a.length,e=0;e<d;e++)c.push(e)}else c=g.Jb(a);d=zKa(a);e=d.length;for(var f=0;f<e;f++)b.call(void 0,d[f],c&&c[f],a)}},BKa=function(a,b,c,d){var e=new g.Tm(null,void 0);
a&&g.Um(e,a);b&&g.Vm(e,b);c&&g.Wm(e,c);d&&(e.J=d);return e},N4=function(){},O4=function(a,b){g.Rq[a]=!0;
var c=g.Pq();c&&c.publish.apply(c,arguments);g.Rq[a]=!1},P4=function(a){this.app=this.name=this.id="";
this.type="REMOTE_CONTROL";this.obfuscatedGaiaId=this.avatar=this.username="";this.capabilities=new Set;this.experiments=new Set;this.theme="u";new g.Qm;this.model=this.brand="";this.year=0;this.chipset=this.osVersion=this.os="";a&&(this.id=a.id||a.name,this.name=a.name,this.app=a.app,this.type=a.type||"REMOTE_CONTROL",this.username=a.user||"",this.avatar=a.userAvatarUri||"",this.obfuscatedGaiaId=a.obfuscatedGaiaId||"",this.theme=a.theme||"u",CKa(this,a.capabilities||""),DKa(this,a.experiments||""),
this.brand=a.brand||"",this.model=a.model||"",this.year=a.year||0,this.os=a.os||"",this.osVersion=a.osVersion||"",this.chipset=a.chipset||"")},CKa=function(a,b){a.capabilities.clear();
g.Je(b.split(","),g.Pa(qKa,EKa)).forEach(function(c){a.capabilities.add(c)})},DKa=function(a,b){a.experiments.clear();
b.split(",").forEach(function(c){a.experiments.add(c)})},Q4=function(a){a=a||{};
this.name=a.name||"";this.id=a.id||a.screenId||"";this.token=a.token||a.loungeToken||"";this.uuid=a.uuid||a.dialId||"";this.idType=a.screenIdType||"normal"},R4=function(a,b){return!!b&&(a.id==b||a.uuid==b)},FKa=function(a){return{name:a.name,
screenId:a.id,loungeToken:a.token,dialId:a.uuid,screenIdType:a.idType}},GKa=function(a){return new Q4(a)},HKa=function(a){return Array.isArray(a)?g.Mc(a,GKa):[]},S4=function(a){return a?'{name:"'+a.name+'",id:'+a.id.substr(0,6)+"..,token:"+((a.token?".."+a.token.slice(-6):"-")+",uuid:"+(a.uuid?".."+a.uuid.slice(-6):"-")+",idType:"+a.idType+"}"):"null"},T4=function(a){return Array.isArray(a)?"["+g.Mc(a,S4).join(",")+"]":"null"},U4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,
function(a){var b=16*Math.random()|0;
return("x"==a?b:b&3|8).toString(16)})},IKa=function(a){return g.Mc(a,function(b){return{key:b.id,
name:b.name}})},V4=function(a,b){return g.cb(a,function(c){return c||b?!c!=!b?!1:c.id==b.id:!0})},W4=function(a,b){return g.cb(a,function(c){return R4(c,b)})},JKa=function(){var a=(0,g.iv)();
a&&uKa(a,a.i.og(!0))},X4=function(){var a=g.lv("ut-remote-connected-devices")||[];
g.wb(a);return a},KKa=function(a){if(g.gb(a))return[];
var b=a[0].indexOf("#"),c=-1==b?a[0]:a[0].substring(0,b);return g.Mc(a,function(d,e){return 0==e?d:d.substring(c.length)})},LKa=function(a){g.kv("ut-remote-connected-devices",a,86400)},Z4=function(){if(Y4)return Y4;
var a=g.lv("ut-remote-device-id");a||(a=U4(),g.kv("ut-remote-device-id",a,31536E3));for(var b=X4(),c=1,d=a;g.fb(b,d);)c++,d=a+"#"+c;return Y4=d},$4=function(){var a=X4(),b=Z4();
g.fb(a,b);g.ov()&&g.yb(a,b);a=KKa(a);if(g.gb(a))try{g.Go("remote_sid")}catch(c){}else try{g.Eo("remote_sid",a.join(","),-1)}catch(c){}},MKa=function(){return g.lv("ut-remote-session-browser-channel")},NKa=function(){return g.lv("ut-remote-local-screens")||[]},OKa=function(){g.kv("ut-remote-lounge-token-expiration",!0,86400)},PKa=function(a){5<a.length&&(a=a.slice(a.length-5));
var b=g.Mc(NKa(),function(d){return d.loungeToken}),c=g.Mc(a,function(d){return d.loungeToken});
g.fh(c,function(d){return!g.fb(b,d)})&&OKa();
g.kv("ut-remote-local-screens",a,31536E3)},QKa=function(a,b){g.kv("ut-remote-session-browser-channel",a);
g.kv("ut-remote-session-screen-id",b);a=X4();b=Z4();g.fb(a,b)||a.push(b);LKa(a);$4()},a5=function(a){a||(g.nv("ut-remote-session-screen-id"),g.nv("ut-remote-session-video-id"));
$4();a=X4();g.kb(a,Z4());LKa(a)},RKa=function(){if(!b5){var a=g.po();
a&&(b5=new g.Rn(a))}},SKa=function(){RKa();
return b5?!!b5.get("ut-remote-use-staging-server"):!1},c5=function(){var a=window.navigator.userAgent.match(/Chrome\/([0-9]+)/);
return a?parseInt(a[1],10):0},TKa=function(a){return!!document.currentScript&&(-1!=document.currentScript.src.indexOf("?"+a)||-1!=document.currentScript.src.indexOf("&"+a))},UKa=function(){return"function"==typeof window.__onGCastApiAvailable?window.__onGCastApiAvailable:null},d5=function(a){a.length?VKa(a.shift(),function(){d5(a)}):e5()},WKa=function(a){return"chrome-extension://"+a+"/cast_sender.js"},VKa=function(a,b,c){var d=document.createElement("script");
d.onerror=b;c&&(d.onload=c);g.Td(d,g.gg(a));(document.head||document.documentElement).appendChild(d)},XKa=function(){var a=c5(),b=[];
if(1<a){var c=a-1;b.push("//www.gstatic.com/eureka/clank/"+a+"/cast_sender.js");b.push("//www.gstatic.com/eureka/clank/"+c+"/cast_sender.js")}return b},e5=function(){var a=UKa();
a&&a(!1,"No cast extension found")},f5=function(){if(YKa){var a=2,b=UKa(),c=function(){a--;
0==a&&b&&b(!0)};
window.__onGCastApiAvailable=c;VKa("//www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js",e5,c)}},ZKa=function(){f5();
var a=XKa();a.push("//www.gstatic.com/eureka/clank/cast_sender.js");d5(a)},aLa=function(){f5();
var a=XKa();a.push.apply(a,g.ma($Ka.map(WKa)));a.push("//www.gstatic.com/eureka/clank/cast_sender.js");d5(a)},g5=function(a,b,c){g.F.call(this);
this.G=null!=c?(0,g.C)(a,c):a;this.Cf=b;this.C=(0,g.C)(this.gM,this);this.i=!1;this.l=0;this.u=this.Fb=null;this.B=[]},h5=function(a,b,c){g.F.call(this);
this.B=null!=c?a.bind(c):a;this.Cf=b;this.u=null;this.i=!1;this.l=0;this.Fb=null},i5=function(a){a.Fb=g.Hm(function(){a.Fb=null;
a.i&&!a.l&&(a.i=!1,i5(a))},a.Cf);
var b=a.u;a.u=null;a.B.apply(null,b)},j5=function(a){if(g.B.JSON)try{return g.B.JSON.parse(a)}catch(b){}return yKa(a)},k5=function(){},l5=function(a,b){if("function"!==typeof a)throw Error("Fn must not be null and must be a function");
return g.B.setTimeout(function(){a()},b)},n5=function(a){m5.dispatchEvent(new bLa(m5,a))},bLa=function(a,b){g.xl.call(this,"statevent",a);
this.stat=b},o5=function(){},cLa=function(){},eLa=function(a){return(a=dLa(a))?new ActiveXObject(a):new XMLHttpRequest},dLa=function(a){if(!a.l&&"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.l=d}catch(e){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed");}return a.l},p5=function(a,b,c,d){this.i=a;
this.l=b;this.L=c;this.J=d||1;this.C=45E3;this.B=new g.a0(this);this.u=new g.Gm;this.u.setInterval(250)},gLa=function(a,b,c){a.Nq=1;
a.Dl=K4(b.clone());a.Oo=c;a.G=!0;fLa(a,null)},q5=function(a,b,c,d,e){a.Nq=1;
a.Dl=K4(b.clone());a.Oo=null;a.G=c;e&&(a.iJ=!1);fLa(a,d)},fLa=function(a,b){a.Dq=Date.now();
r5(a);a.Fm=a.Dl.clone();L4(a.Fm,"t",a.J);a.vu=0;a.He=a.i.Qz(a.i.Tt()?b:null);0<a.Ly&&(a.bx=new h5((0,g.C)(a.fK,a,a.He),a.Ly));a.B.Pa(a.He,"readystatechange",a.vS);b=a.Ym?g.Sb(a.Ym):{};a.Oo?(a.Qx="POST",b["Content-Type"]="application/x-www-form-urlencoded",a.He.send(a.Fm,a.Qx,a.Oo,b)):(a.Qx="GET",a.iJ&&!g.ze&&(b.Connection="close"),a.He.send(a.Fm,a.Qx,null,b));a.i.zi(1)},jLa=function(a,b,c){for(var d=!0;!a.En&&a.vu<c.length;){var e=hLa(a,c);
if(e==s5){4==b&&(a.yl=4,n5(15),d=!1);break}else if(e==iLa){a.yl=4;n5(16);d=!1;break}else t5(a,e)}4==b&&0==c.length&&(a.yl=1,n5(17),d=!1);a.Li=a.Li&&d;d||(u5(a),v5(a))},hLa=function(a,b){var c=a.vu,d=b.indexOf("\n",c);
if(-1==d)return s5;c=Number(b.substring(c,d));if(isNaN(c))return iLa;d+=1;if(d+c>b.length)return s5;b=b.substr(d,c);a.vu=d+c;return b},lLa=function(a,b){a.Dq=Date.now();
r5(a);var c=b?window.location.hostname:"";a.Fm=a.Dl.clone();J4(a.Fm,"DOMAIN",c);J4(a.Fm,"t",a.J);try{a.Qi=new ActiveXObject("htmlfile")}catch(m){u5(a);a.yl=7;n5(22);v5(a);return}var d="<html><body>";if(b){var e="";for(b=0;b<c.length;b++){var f=c.charAt(b);if("<"==f)f=e+"\\x3c";else if(">"==f)f=e+"\\x3e";else{if(f in w5)f=w5[f];else if(f in kLa)f=w5[f]=kLa[f];else{var h=f.charCodeAt(0);if(31<h&&127>h)var l=f;else{if(256>h){if(l="\\x",16>h||256<h)l+="0"}else l="\\u",4096>h&&(l+="0");l+=h.toString(16).toUpperCase()}f=
w5[f]=l}f=e+f}e=f}d+='<script>document.domain="'+e+'"\x3c/script>'}c=g.ed(g.cc("b/12014412"),d+"</body></html>");a.Qi.open();a.Qi.write(g.ad(c));a.Qi.close();a.Qi.parentWindow.m=(0,g.C)(a.UR,a);a.Qi.parentWindow.d=(0,g.C)(a.xI,a,!0);a.Qi.parentWindow.rpcClose=(0,g.C)(a.xI,a,!1);c=a.Qi.createElement("DIV");a.Qi.parentWindow.document.body.appendChild(c);d=g.Fc(a.Fm.toString());d=g.md(g.Bc(d));d=g.ed(g.cc("b/12014412"),'<iframe src="'+d+'"></iframe>');g.fd(c,d);a.i.zi(1)},r5=function(a){a.cD=Date.now()+
a.C;
mLa(a,a.C)},mLa=function(a,b){if(null!=a.Sq)throw Error("WatchDog timer not null");
a.Sq=l5((0,g.C)(a.cS,a),b)},x5=function(a){a.Sq&&(g.B.clearTimeout(a.Sq),a.Sq=null)},v5=function(a){a.i.dE()||a.En||a.i.Ku(a)},u5=function(a){x5(a);
g.xi(a.bx);a.bx=null;a.u.stop();g.YEa(a.B);if(a.He){var b=a.He;a.He=null;b.abort();b.dispose()}a.Qi&&(a.Qi=null)},t5=function(a,b){try{a.i.qI(a,b),a.i.zi(4)}catch(c){}},oLa=function(a,b,c,d,e){if(0==d)c(!1);
else{var f=e||0;d--;nLa(a,b,function(h){h?c(!0):g.B.setTimeout(function(){oLa(a,b,c,d,f)},f)})}},nLa=function(a,b,c){var d=new Image;
d.onload=function(){try{y5(d),c(!0)}catch(e){}};
d.onerror=function(){try{y5(d),c(!1)}catch(e){}};
d.onabort=function(){try{y5(d),c(!1)}catch(e){}};
d.ontimeout=function(){try{y5(d),c(!1)}catch(e){}};
g.B.setTimeout(function(){if(d.ontimeout)d.ontimeout()},b);
xKa(d,a)},y5=function(a){a.onload=null;
a.onerror=null;a.onabort=null;a.ontimeout=null},z5=function(a){g.Wl.call(this);
this.headers=new g.Qm;this.ra=a||null;this.B=!1;this.ma=this.i=null;this.Fa=this.V="";this.G=0;this.u="";this.C=this.Aa=this.L=this.xa=!1;this.J=0;this.W=null;this.Ma="";this.Y=this.Da=!1},pLa=function(a){return g.xe&&g.ae(9)&&"number"===typeof a.timeout&&void 0!==a.ontimeout},qLa=function(a){return"content-type"==a.toLowerCase()},sLa=function(a,b){a.B=!1;
a.i&&(a.C=!0,a.i.abort(),a.C=!1);a.u=b;a.G=5;rLa(a);A5(a)},rLa=function(a){a.xa||(a.xa=!0,a.dispatchEvent("complete"),a.dispatchEvent("error"))},uLa=function(a){if(a.B&&"undefined"!=typeof g.e0)if(a.ma[1]&&4==B5(a)&&2==a.getStatus())C5(a,"Local request error detected and ignored");
else if(a.L&&4==B5(a))g.Hm(a.nI,0,a);else if(a.dispatchEvent("readystatechange"),a.Ud()){C5(a,"Request complete");a.B=!1;try{var b=a.getStatus();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}var d;if(!(d=c)){var e;if(e=0===b){var f=g.vd(1,String(a.V));if(!f&&g.B.self&&g.B.self.location){var h=g.B.self.location.protocol;f=h.substr(0,h.length-1)}e=!tLa.test(f?f.toLowerCase():"")}d=e}if(d)a.dispatchEvent("complete"),a.dispatchEvent("success");
else{a.G=6;try{var l=2<B5(a)?a.i.statusText:""}catch(m){l=""}a.u=l+" ["+a.getStatus()+"]";rLa(a)}}finally{A5(a)}}},A5=function(a,b){if(a.i){vLa(a);
var c=a.i,d=a.ma[0]?g.Ia:null;a.i=null;a.ma=null;b||a.dispatchEvent("ready");try{c.onreadystatechange=d}catch(e){}}},vLa=function(a){a.i&&a.Y&&(a.i.ontimeout=null);
a.W&&(g.B.clearTimeout(a.W),a.W=null)},B5=function(a){return a.i?a.i.readyState:0},D5=function(a){try{return a.i?a.i.responseText:""}catch(b){return""}},C5=function(a,b){return b+" ["+a.Fa+" "+a.V+" "+a.getStatus()+"]"},wLa=function(a){this.i=a;
this.l=new k5},xLa=function(a){var b=E5(a.i,a.Jr,"/mail/images/cleardot.gif");
K4(b);oLa(b.toString(),5E3,(0,g.C)(a.bN,a),3,2E3);a.zi(1)},G5=function(a){var b=a.i.L;
if(null!=b)n5(5),b?(n5(11),F5(a.i,a,!1)):(n5(12),F5(a.i,a,!0));else if(a.Kg=new p5(a,void 0,void 0,void 0),a.Kg.Ym=a.My,b=a.i,b=E5(b,b.Tt()?a.yr:null,a.Ny),n5(5),!g.xe||g.be(10))L4(b,"TYPE","xmlhttp"),q5(a.Kg,b,!1,a.yr,!1);else{L4(b,"TYPE","html");var c=a.Kg;a=!!a.yr;c.Nq=3;c.Dl=K4(b.clone());lLa(c,a)}},H5=function(a,b,c){this.eb=1;
this.i=[];this.u=[];this.B=new k5;this.J=a||null;this.L=null!=b?b:null;this.C=c||!1},yLa=function(a,b){this.i=a;
this.map=b;this.context=null},zLa=function(a,b,c,d){g.xl.call(this,"timingevent",a);
this.size=b;this.Nt=d},ALa=function(a){g.xl.call(this,"serverreachability",a)},DLa=function(a){BLa(a);
if(3==a.eb){var b=a.gt++,c=a.xv.clone();J4(c,"SID",a.l);J4(c,"RID",b);J4(c,"TYPE","terminate");I5(a,c);b=new p5(a,a.l,b,void 0);b.Nq=2;b.Dl=K4(c.clone());xKa(new Image,b.Dl.toString());b.Dq=Date.now();r5(b)}CLa(a)},ELa=function(a){a.yN(1,0);
a.xv=E5(a,null,a.Oy);J5(a)},BLa=function(a){a.Il&&(a.Il.abort(),a.Il=null);
a.Yd&&(a.Yd.cancel(),a.Yd=null);a.yk&&(g.B.clearTimeout(a.yk),a.yk=null);K5(a);a.yg&&(a.yg.cancel(),a.yg=null);a.Pl&&(g.B.clearTimeout(a.Pl),a.Pl=null)},FLa=function(a,b){if(0==a.eb)throw Error("Invalid operation: sending map when state is closed");
a.i.push(new yLa(a.aP++,b));2!=a.eb&&3!=a.eb||J5(a)},GLa=function(a){var b=0;
a.Yd&&b++;a.yg&&b++;return b},J5=function(a){a.yg||a.Pl||(a.Pl=l5((0,g.C)(a.vI,a),0),a.Wp=0)},ILa=function(a,b){if(1==a.eb){if(!b){a.gt=Math.floor(1E5*Math.random());
b=a.gt++;var c=new p5(a,"",b,void 0);c.Ym=a.nj;var d=L5(a),e=a.xv.clone();J4(e,"RID",b);J4(e,"CVER","1");I5(a,e);gLa(c,e,d);a.yg=c;a.eb=2}}else 3==a.eb&&(b?HLa(a,b):0==a.i.length||a.yg||HLa(a))},HLa=function(a,b){if(b)if(6<a.Fn){a.i=a.u.concat(a.i);
a.u.length=0;var c=a.gt-1;b=L5(a)}else c=b.L,b=b.Oo;else c=a.gt++,b=L5(a);var d=a.xv.clone();J4(d,"SID",a.l);J4(d,"RID",c);J4(d,"AID",a.nq);I5(a,d);c=new p5(a,a.l,c,a.Wp+1);c.Ym=a.nj;c.setTimeout(1E4+Math.round(1E4*Math.random()));a.yg=c;gLa(c,d,b)},I5=function(a,b){a.xf&&(a=a.xf.aG())&&g.Bb(a,function(c,d){J4(b,d,c)})},L5=function(a){var b=Math.min(a.i.length,1E3),c=["count="+b];
if(6<a.Fn&&0<b){var d=a.i[0].i;c.push("ofs="+d)}else d=0;for(var e={},f=0;f<b;e={qp:e.qp},f++){e.qp=a.i[f].i;var h=a.i[f].map;e.qp=6>=a.Fn?f:e.qp-d;try{g.Bb(h,function(l){return function(m,n){c.push("req"+l.qp+"_"+n+"="+encodeURIComponent(m))}}(e))}catch(l){c.push("req"+e.qp+"_type="+encodeURIComponent("_badmap"))}}a.u=a.u.concat(a.i.splice(0,b));
return c.join("&")},JLa=function(a){a.Yd||a.yk||(a.G=1,a.yk=l5((0,g.C)(a.uI,a),0),a.Kp=0)},M5=function(a){if(a.Yd||a.yk||3<=a.Kp)return!1;
a.G++;a.yk=l5((0,g.C)(a.uI,a),KLa(a,a.Kp));a.Kp++;return!0},F5=function(a,b,c){a.Ox=c;
a.pj=b.gk;a.C||ELa(a)},K5=function(a){null!=a.Mn&&(g.B.clearTimeout(a.Mn),a.Mn=null)},KLa=function(a,b){var c=5E3+Math.floor(1E4*Math.random());
a.isActive()||(c*=2);return c*b},N5=function(a,b){if(2==b||9==b){var c=null;
a.xf&&(c=null);var d=(0,g.C)(a.bT,a);c||(c=new g.Tm("//www.google.com/images/cleardot.gif"),K4(c));nLa(c.toString(),1E4,d)}else n5(2);LLa(a,b)},LLa=function(a,b){a.eb=0;
a.xf&&a.xf.sF(b);CLa(a);BLa(a)},CLa=function(a){a.eb=0;
a.pj=-1;if(a.xf)if(0==a.u.length&&0==a.i.length)a.xf.Cz();else{g.ob(a.u);var b=g.ob(a.i);a.u.length=0;a.i.length=0;a.xf.Cz(b)}},E5=function(a,b,c){var d=g.an(c);
if(""!=d.i)b&&g.Vm(d,b+"."+d.i),g.Wm(d,d.u);else{var e=window.location;d=BKa(e.protocol,b?b+"."+e.hostname:e.hostname,+e.port,c)}a.Zr&&g.Bb(a.Zr,function(f,h){J4(d,h,f)});
J4(d,"VER",a.Fn);I5(a,d);return d},MLa=function(){},NLa=function(){this.i=[];
this.l=[]},OLa=function(a,b){this.action=a;
this.params=b||{}},O5=function(a,b){g.F.call(this);
this.i=new g.J(this.MR,0,this);g.G(this,this.i);this.Cf=5E3;this.l=0;if("function"===typeof a)b&&(a=(0,g.C)(a,b));else if(a&&"function"===typeof a.handleEvent)a=(0,g.C)(a.handleEvent,a);else throw Error("Invalid listener argument");this.u=a},P5=function(a,b,c,d,e){c=void 0===c?!1:c;
d=void 0===d?function(){return""}:d;
e=void 0===e?!1:e;this.ma=a;this.G=b;this.u=new g.Qn;this.l=new O5(this.HS,this);this.i=null;this.W=!1;this.C=null;this.V="";this.L=this.B=0;this.J=[];this.ra=c;this.Y=d;this.xa=e},PLa=function(a){return{firstTestResults:[""],
secondTestResults:!a.i.Ox,sessionId:a.i.l,arrayId:a.i.nq}},QLa=function(a,b){a.L=b||0;
a.l.stop();Q5(a);a.i&&(3==a.i.getState()&&ILa(a.i),DLa(a.i));a.L=0},R5=function(a){return!!a.i&&3==a.i.getState()},Q5=function(a){if(a.i){var b=a.Y(),c=a.i.nj||{};
b?c["x-youtube-lounge-xsrf-token"]=b:delete c["x-youtube-lounge-xsrf-token"];a.i.nj=c}},S5=function(a){this.port=this.domain="";
this.i="/api/lounge";this.l=!0;a=a||document.location.href;var b=Number(g.vd(4,a))||"";b&&(this.port=":"+b);this.domain=g.wd(a)||"";a=g.Uc;0<=a.search("MSIE")&&(a=a.match(/MSIE ([\d.]+)/)[1],0>g.yc(a,"10.0")&&(this.l=!1))},T5=function(a,b){var c=a.i;
a.l&&(c="https://"+a.domain+a.port+a.i);return g.Hd(c+b,{})},U5=function(a,b,c,d,e){a={format:"JSON",
method:"POST",context:a,timeout:5E3,withCredentials:!1,onSuccess:g.Pa(a.B,d,!0),onError:g.Pa(a.u,e),onTimeout:g.Pa(a.C,e)};c&&(a.postParams=c,a.headers={"Content-Type":"application/x-www-form-urlencoded"});return g.vp(b,a)},ULa=function(){var a=RLa;
SLa();V5.push(a);TLa()},W5=function(a,b){SLa();
var c=VLa(a,String(b));g.gb(V5)?WLa(c):(TLa(),g.zb(V5,function(d){d(c)}))},SLa=function(){V5||(V5=g.Ha("ut.mdx.remote.debug.handlers_")||[],g.Ga("ut.mdx.remote.debug.handlers_",V5,void 0))},WLa=function(a){var b=(X5+1)%50;
X5=b;Y5[b]=a;Z5||(Z5=49==b)},TLa=function(){var a=V5;
if(Y5[0]){var b=Z5?X5:-1;do{b=(b+1)%50;var c=Y5[b];g.zb(a,function(d){d(c)})}while(b!=X5);
Y5=Array(50);X5=-1;Z5=!1}},VLa=function(a,b){var c=(Date.now()-XLa)/1E3;
c.toFixed&&(c=c.toFixed(3));var d=[];d.push("[",c+"s","] ");d.push("[","ut.mdx.remote","] ");d.push(a+": "+b,"\n");return d.join("")},$5=function(a){g.P.call(this);
this.G=a;this.screens=[]},YLa=function(a,b){var c=a.get(b.uuid)||a.get(b.id);
if(c)return a=c.name,c.id=b.id||c.id,c.name=b.name,c.token=b.token,c.uuid=b.uuid||c.uuid,c.name!=a;a.screens.push(b);return!0},ZLa=function(a,b){var c=a.screens.length!=b.length;
a.screens=g.Je(a.screens,function(f){return!!V4(b,f)});
for(var d=0,e=b.length;d<e;d++)c=YLa(a,b[d])||c;return c},$La=function(a,b){var c=a.screens.length;
a.screens=g.Je(a.screens,function(d){return!(d||b?!d!=!b?0:d.id==b.id:1)});
return a.screens.length<c},a6=function(a,b,c,d,e){g.P.call(this);
this.u=a;this.J=b;this.B=c;this.G=d;this.C=e;this.l=0;this.i=null;this.Fb=NaN},c6=function(a){$5.call(this,"LocalScreenService");
this.l=a;this.i=NaN;b6(this);this.info("Initializing with "+T4(this.screens))},aMa=function(a){if(a.screens.length){var b=g.Mc(a.screens,function(d){return d.id}),c=T5(a.l,"/pairing/get_lounge_token_batch");
U5(a.l,c,{screen_ids:b.join(",")},(0,g.C)(a.VN,a),(0,g.C)(a.UN,a))}},b6=function(a){if(g.Po("deprecate_pair_servlet_enabled"))return ZLa(a,[]);
var b=HKa(NKa());b=g.Je(b,function(c){return!c.uuid});
return ZLa(a,b)},d6=function(a,b){PKa(g.Mc(a.screens,FKa));
b&&OKa()},f6=function(a,b){g.P.call(this);
this.G=b;b=(b=g.lv("ut-remote-online-screen-ids")||"")?b.split(","):[];for(var c={},d=this.G(),e=0,f=d.length;e<f;++e){var h=d[e].id;c[h]=g.fb(b,h)}this.i=c;this.C=a;this.u=this.B=NaN;this.l=null;e6("Initialized with "+g.xj(this.i))},g6=function(a,b,c){var d=T5(a.C,"/pairing/get_screen_availability");
U5(a.C,d,{lounge_token:b.token},(0,g.C)(function(e){e=e.screens||[];for(var f=0,h=e.length;f<h;++f)if(e[f].loungeToken==b.token){c("online"==e[f].status);return}c(!1)},a),(0,g.C)(function(){c(!1)},a))},h6=function(a,b){a:if(M4(b)!=M4(a.i))var c=!1;
else{c=g.Jb(b);for(var d=0,e=c.length;d<e;++d)if(!a.i[c[d]]){c=!1;break a}c=!0}c||(e6("Updated online screens: "+g.xj(a.i)),a.i=b,a.X("screenChange"));bMa(a)},i6=function(a){isNaN(a.u)||g.qp(a.u);
a.u=g.op((0,g.C)(a.dC,a),0<a.B&&a.B<g.Ra()?2E4:1E4)},e6=function(a){W5("OnlineScreenService",a)},cMa=function(a){var b={};
g.zb(a.G(),function(c){c.token?b[c.token]=c.id:this.Jd("Requesting availability of screen w/o lounge token.")});
return b},bMa=function(a){a=g.Jb(g.Cb(a.i,function(b){return b}));
g.wb(a);a.length?g.kv("ut-remote-online-screen-ids",a.join(","),60):g.nv("ut-remote-online-screen-ids")},j6=function(a,b){b=void 0===b?!1:b;
$5.call(this,"ScreenService");this.B=a;this.J=b;this.i=this.l=null;this.u=[];this.C={};dMa(this)},fMa=function(a,b,c,d,e,f){a.info("getAutomaticScreenByIds "+c+" / "+b);
c||(c=a.C[b]);var h=a.Xg(),l=c?W4(h,c):null;c&&(a.J||l)||(l=W4(h,b));if(l){l.uuid=b;var m=k6(a,l);g6(a.i,m,function(n){e(n?m:null)})}else c?eMa(a,c,(0,g.C)(function(n){var p=k6(this,new Q4({name:d,
screenId:c,loungeToken:n,dialId:b||""}));g6(this.i,p,function(r){e(r?p:null)})},a),f):e(null)},gMa=function(a,b){for(var c=0,d=a.screens.length;c<d;++c)if(a.screens[c].name==b)return a.screens[c];
return null},hMa=function(a,b,c){g6(a.i,b,c)},eMa=function(a,b,c,d){a.info("requestLoungeToken_ for "+b);
var e={postParams:{screen_ids:b},method:"POST",context:a,onSuccess:function(f,h){f=h&&h.screens||[];f[0]&&f[0].screenId==b?c(f[0].loungeToken):d(Error("Missing lounge token in token response"))},
onError:function(){d(Error("Request screen lounge token failed"))}};
g.vp(T5(a.B,"/pairing/get_lounge_token_batch"),e)},iMa=function(a){a.screens=a.l.Xg();
var b=a.C,c={},d;for(d in b)c[b[d]]=d;b=0;for(d=a.screens.length;b<d;++b){var e=a.screens[b];e.uuid=c[e.id]||""}a.info("Updated manual screens: "+T4(a.screens))},dMa=function(a){l6(a);
a.l=new c6(a.B);a.l.subscribe("screenChange",(0,g.C)(a.bO,a));iMa(a);a.J||(a.u=HKa(g.lv("ut-remote-automatic-screen-cache")||[]));l6(a);a.info("Initializing automatic screens: "+T4(a.u));a.i=new f6(a.B,(0,g.C)(a.Xg,a,!0));a.i.subscribe("screenChange",(0,g.C)(function(){this.X("onlineScreenChange")},a))},k6=function(a,b){var c=a.get(b.id);
c?(c.uuid=b.uuid,b=c):((c=W4(a.u,b.uuid))?(c.id=b.id,c.token=b.token,b=c):a.u.push(b),a.J||jMa(a));l6(a);a.C[b.uuid]=b.id;g.kv("ut-remote-device-id-map",a.C,31536E3);return b},jMa=function(a){a=g.Je(a.u,function(b){return"shortLived"!=b.idType});
g.kv("ut-remote-automatic-screen-cache",g.Mc(a,FKa))},l6=function(a){a.C=g.lv("ut-remote-device-id-map")||{}},m6=function(a,b,c){g.P.call(this);
this.xa=c;this.u=a;this.i=b;this.B=null},n6=function(a,b){a.B=b;
a.X("sessionScreen",a.B)},kMa=function(a,b){a.B&&(a.B.token=b,k6(a.u,a.B));
a.X("sessionScreen",a.B)},o6=function(a,b){W5(a.xa,b)},p6=function(a,b,c){m6.call(this,a,b,"CastSession");
var d=this;this.config_=c;this.l=null;this.Y=(0,g.C)(this.lM,this);this.ra=(0,g.C)(this.fS,this);this.W=g.op(function(){lMa(d,null)},12E4);
this.J=this.C=this.G=this.L=0;this.ma=!1;this.V="unknown"},q6=function(a,b){g.qp(a.J);
a.J=0;0==b?mMa(a):a.J=g.op(function(){mMa(a)},b)},mMa=function(a){nMa(a,"getLoungeToken");
g.qp(a.C);a.C=g.op(function(){oMa(a,null)},3E4)},nMa=function(a,b){a.info("sendYoutubeMessage_: "+b+" "+g.xj(void 0));
var c={};c.type=b;a.l?a.l.sendMessage("urn:x-cast:com.google.youtube.mdx",c,g.Ia,(0,g.C)(function(){o6(this,"Failed to send message: "+b+".")},a)):o6(a,"Sending ut message without session: "+g.xj(c))},r6=function(a,b){b?(a.info("onConnectedScreenId_: Received screenId: "+b),a.getScreen()&&a.getScreen().id==b||a.oG(b,function(c){n6(a,c)},function(){return a.Yf()},5)):a.Yf(Error("Waiting for session status timed out."))},qMa=function(a,b,c){a.info("onConnectedScreenData_: Received screenData: "+JSON.stringify(b));
var d=new Q4(b);pMa(a,d,function(e){e?(a.ma=!0,k6(a.u,d),n6(a,d),a.V="unknown",q6(a,c)):(g.Uo(Error("CastSession, RemoteScreen from screenData: "+JSON.stringify(b)+" is not online.")),a.Yf())},5)},lMa=function(a,b){g.qp(a.W);
a.W=0;b?a.config_.enableCastLoungeToken&&b.loungeToken?b.deviceId?a.getScreen()&&a.getScreen().uuid==b.deviceId||(b.loungeTokenRefreshIntervalMs?qMa(a,{name:a.i.friendlyName,screenId:b.screenId,loungeToken:b.loungeToken,dialId:b.deviceId,screenIdType:"shortLived"},b.loungeTokenRefreshIntervalMs):(g.Uo(Error("No loungeTokenRefreshIntervalMs presents in mdxSessionStatusData: "+JSON.stringify(b)+".")),r6(a,b.screenId))):(g.Uo(Error("No device id presents in mdxSessionStatusData: "+JSON.stringify(b)+
".")),r6(a,b.screenId)):r6(a,b.screenId):a.Yf(Error("Waiting for session status timed out."))},oMa=function(a,b){g.qp(a.C);
a.C=0;var c=null;if(b)if(b.loungeToken){var d;(null==(d=a.getScreen())?void 0:d.token)==b.loungeToken&&(c="staleLoungeToken")}else c="missingLoungeToken";else c="noLoungeTokenResponse";c?(a.info("Did not receive a new lounge token in onLoungeToken_ with data: "+(JSON.stringify(b)+", error: "+c)),a.V=c,q6(a,3E4)):(kMa(a,b.loungeToken),a.ma=!1,a.V="unknown",q6(a,b.loungeTokenRefreshIntervalMs))},pMa=function(a,b,c,d){g.qp(a.G);
a.G=0;hMa(a.u,b,function(e){e||0>d?c(e):a.G=g.op(function(){pMa(a,b,c,d-1)},300)})},rMa=function(a){g.qp(a.L);
a.L=0;g.qp(a.G);a.G=0;g.qp(a.W);a.W=0;g.qp(a.C);a.C=0;g.qp(a.J);a.J=0},s6=function(a,b,c,d){m6.call(this,a,b,"DialSession");
this.config_=d;this.l=this.L=null;this.ra="";this.Da=c;this.Ea=null;this.W=g.Ia;this.V=NaN;this.Aa=(0,g.C)(this.mM,this);this.C=g.Ia;this.J=this.G=0;this.Y=!1;this.ma="unknown"},t6=function(a){var b;
return!!(a.config_.enableDialLoungeToken&&(null==(b=a.l)?0:b.getDialAppInfo))},sMa=function(a){a.C=a.u.fE(a.ra,a.i.label,a.i.friendlyName,t6(a),function(b,c){a.C=g.Ia;
a.Y=!0;n6(a,b);"shortLived"==b.idType&&0<c&&u6(a,c)},function(b){a.C=g.Ia;
a.Yf(b)})},tMa=function(a){var b={};
b.pairingCode=a.ra;b.theme=a.Da;SKa()&&(b.env_useStageMdx=1);return g.Fd(b)},v6=function(a){return new Promise(function(b){a.ra=U4();
if(a.Ea){var c=new chrome.cast.DialLaunchResponse(!0,tMa(a));b(c);sMa(a)}else a.W=function(){g.qp(a.V);a.W=function(){};
a.V=NaN;var d=new chrome.cast.DialLaunchResponse(!0,tMa(a));b(d);sMa(a)},a.V=g.op(function(){a.W()},100)})},vMa=function(a,b,c){a.info("initOnConnectedScreenDataPromise_: Received screenData: "+JSON.stringify(b));
var d=new Q4(b);return(new Promise(function(e){uMa(a,d,function(f){f?(a.Y=!0,k6(a.u,d),n6(a,d),u6(a,c)):g.Uo(Error("DialSession, RemoteScreen from screenData: "+JSON.stringify(b)+" is not online."));e(f)},5)})).then(function(e){return e?new chrome.cast.DialLaunchResponse(!1):v6(a)})},wMa=function(a,b){var c=a.L.receiver.label,d=a.i.friendlyName;
return(new Promise(function(e){fMa(a.u,c,b,d,function(f){f&&f.token&&n6(a,f);e(f)},function(f){o6(a,"Failed to get DIAL screen: "+f);
e(null)})})).then(function(e){return e&&e.token?new chrome.cast.DialLaunchResponse(!1):v6(a)})},uMa=function(a,b,c,d){g.qp(a.G);
a.G=0;hMa(a.u,b,function(e){e||0>d?c(e):a.G=g.op(function(){uMa(a,b,c,d-1)},300)})},u6=function(a,b){a.info("getDialAppInfoWithTimeout_ "+b);
t6(a)&&(g.qp(a.J),a.J=0,0==b?xMa(a):a.J=g.op(function(){xMa(a)},b))},xMa=function(a){t6(a)&&a.l.getDialAppInfo(function(b){a.info("getDialAppInfo dialLaunchData: "+JSON.stringify(b));
b=b.extraData||{};var c=null;if(b.loungeToken){var d;(null==(d=a.getScreen())?void 0:d.token)==b.loungeToken&&(c="staleLoungeToken")}else c="missingLoungeToken";c?(a.ma=c,u6(a,3E4)):(a.Y=!1,a.ma="unknown",kMa(a,b.loungeToken),u6(a,b.loungeTokenRefreshIntervalMs))},function(b){a.info("getDialAppInfo error: "+b);
a.ma="noLoungeTokenResponse";u6(a,3E4)})},yMa=function(a){g.qp(a.G);
a.G=0;g.qp(a.J);a.J=0;a.C();a.C=function(){};
g.qp(a.V)},w6=function(a,b){m6.call(this,a,b,"ManualSession");
this.l=g.op((0,g.C)(this.oq,this,null),150)},x6=function(a,b){g.P.call(this);
this.config_=b;this.l=a;this.J=b.appId||"233637DE";this.B=b.theme||"cl";this.L=b.disableCastApi||!1;this.V=b.forceMirroring||!1;this.i=null;this.G=!1;this.u=[];this.C=(0,g.C)(this.cR,this)},zMa=function(a,b){return b?g.cb(a.u,function(c){return R4(b,c.label)},a):null},y6=function(a){W5("Controller",a)},RLa=function(a){window.chrome&&chrome.cast&&chrome.cast.logMessage&&chrome.cast.logMessage(a)},z6=function(a){return a.G||!!a.u.length||!!a.i},A6=function(a,b,c){b!=a.i&&(g.xi(a.i),(a.i=b)?(c?a.X("ut-remote-cast2-receiver-resumed",
b.i):a.X("ut-remote-cast2-receiver-selected",b.i),b.subscribe("sessionScreen",(0,g.C)(a.tI,a,b)),b.getScreen()?a.X("ut-remote-cast2-session-change",b.getScreen()):c&&a.i.oq(null)):a.X("ut-remote-cast2-session-change",null))},AMa=function(a){var b=a.l.eE(),c=a.i&&a.i.i;
a=g.Mc(b,function(d){c&&R4(d,c.label)&&(c=null);var e=d.uuid?d.uuid:d.id,f=zMa(this,d);f?(f.label=e,f.friendlyName=d.name):(f=new chrome.cast.Receiver(e,d.name),f.receiverType=chrome.cast.ReceiverType.CUSTOM);return f},a);
c&&(c.receiverType!=chrome.cast.ReceiverType.CUSTOM&&(c=new chrome.cast.Receiver(c.label,c.friendlyName),c.receiverType=chrome.cast.ReceiverType.CUSTOM),a.push(c));return a},FMa=function(a,b,c,d){d.disableCastApi?B6("Cannot initialize because disabled by Mdx config."):BMa()?CMa(b,d)&&(C6(!0),window.chrome&&chrome.cast&&chrome.cast.isAvailable?DMa(a,c):(window.__onGCastApiAvailable=function(e,f){e?DMa(a,c):(D6("Failed to load cast API: "+f),E6(!1),C6(!1),g.nv("ut-remote-cast-available"),g.nv("ut-remote-cast-receiver"),
EMa(),c(!1))},d.loadCastApiSetupScript?g.pv("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"):0<=window.navigator.userAgent.indexOf("Android")&&0<=window.navigator.userAgent.indexOf("Chrome/")&&window.navigator.presentation?60<=c5()&&ZKa():!window.chrome||!window.navigator.presentation||0<=window.navigator.userAgent.indexOf("Edge")?e5():89<=c5()?aLa():(f5(),d5($Ka.map(WKa))))):B6("Cannot initialize because not running Chrome")},EMa=function(){B6("dispose");
var a=F6();a&&a.dispose();g.Ga("ut.mdx.remote.cloudview.instance_",null,void 0);GMa(!1);g.Uq(G6);G6.length=0},H6=function(){return!!g.lv("ut-remote-cast-installed")},HMa=function(){var a=g.lv("ut-remote-cast-receiver");
return a?a.friendlyName:null},IMa=function(){B6("clearCurrentReceiver");
g.nv("ut-remote-cast-receiver")},JMa=function(){return H6()?F6()?F6().getCastSession():(D6("getCastSelector: Cast is not initialized."),null):(D6("getCastSelector: Cast API is not installed!"),null)},J6=function(){H6()?F6()?I6()?(B6("Requesting cast selector."),F6().requestSession()):(B6("Wait for cast API to be ready to request the session."),G6.push(g.Tq("ut-remote-cast2-api-ready",J6))):D6("requestCastSelector: Cast is not initialized."):D6("requestCastSelector: Cast API is not installed!")},K6=
function(a,b){I6()?F6().setConnectedScreenStatus(a,b):D6("setConnectedScreenStatus called before ready.")},BMa=function(){var a=0<=g.Uc.search(/ (CrMo|Chrome|CriOS)\//);
return g.mB||a},KMa=function(a,b){F6().init(a,b)},CMa=function(a,b){var c=!1;
F6()||(a=new x6(a,b),a.subscribe("ut-remote-cast2-availability-change",function(d){g.kv("ut-remote-cast-available",d);O4("ut-remote-cast2-availability-change",d)}),a.subscribe("ut-remote-cast2-receiver-selected",function(d){B6("onReceiverSelected: "+d.friendlyName);
g.kv("ut-remote-cast-receiver",d);O4("ut-remote-cast2-receiver-selected",d)}),a.subscribe("ut-remote-cast2-receiver-resumed",function(d){B6("onReceiverResumed: "+d.friendlyName);
g.kv("ut-remote-cast-receiver",d);O4("ut-remote-cast2-receiver-resumed",d)}),a.subscribe("ut-remote-cast2-session-change",function(d){B6("onSessionChange: "+S4(d));
d||g.nv("ut-remote-cast-receiver");O4("ut-remote-cast2-session-change",d)}),g.Ga("ut.mdx.remote.cloudview.instance_",a,void 0),c=!0);
B6("cloudview.createSingleton_: "+c);return c},F6=function(){return g.Ha("ut.mdx.remote.cloudview.instance_")},DMa=function(a,b){E6(!0);
C6(!1);KMa(a,function(c){c?(GMa(!0),g.Vq("ut-remote-cast2-api-ready")):(D6("Failed to initialize cast API."),E6(!1),g.nv("ut-remote-cast-available"),g.nv("ut-remote-cast-receiver"),EMa());b(c)})},B6=function(a){W5("cloudview",a)},D6=function(a){W5("cloudview",a)},E6=function(a){B6("setCastInstalled_ "+a);
g.kv("ut-remote-cast-installed",a)},I6=function(){return!!g.Ha("ut.mdx.remote.cloudview.apiReady_")},GMa=function(a){B6("setApiReady_ "+a);
g.Ga("ut.mdx.remote.cloudview.apiReady_",a,void 0)},C6=function(a){g.Ga("ut.mdx.remote.cloudview.initializing_",a,void 0)},L6=function(a){this.index=-1;
this.videoId=this.listId="";this.volume=this.playerState=-1;this.muted=!1;this.audioTrackId=null;this.G=this.J=0;this.trackData=null;this.hasNext=this.Dj=!1;this.L=this.C=this.i=this.B=0;this.u=NaN;this.l=!1;this.reset(a)},M6=function(a){a.audioTrackId=null;
a.trackData=null;a.playerState=-1;a.Dj=!1;a.hasNext=!1;a.J=0;a.G=g.Ra();a.B=0;a.i=0;a.C=0;a.L=0;a.u=NaN;a.l=!1},N6=function(a){return a.uc()?(g.Ra()-a.G)/1E3:0},O6=function(a,b){a.J=b;
a.G=g.Ra()},P6=function(a){switch(a.playerState){case 1:case 1081:return(g.Ra()-a.G)/1E3+a.J;
case -1E3:return 0}return a.J},Q6=function(a,b,c){var d=a.videoId;
a.videoId=b;a.index=c;b!=d&&M6(a)},R6=function(a){var b={};
b.index=a.index;b.listId=a.listId;b.videoId=a.videoId;b.playerState=a.playerState;b.volume=a.volume;b.muted=a.muted;b.audioTrackId=a.audioTrackId;b.trackData=g.Tb(a.trackData);b.hasPrevious=a.Dj;b.hasNext=a.hasNext;b.playerTime=a.J;b.playerTimeAt=a.G;b.seekableStart=a.B;b.seekableEnd=a.i;b.duration=a.C;b.loadedTime=a.L;b.liveIngestionTime=a.u;return b},T6=function(a,b){g.P.call(this);
this.eb=0;this.u=a;this.C=[];this.B=new NLa;this.l=this.i=null;this.L=(0,g.C)(this.HP,this);this.G=(0,g.C)(this.ot,this);this.J=(0,g.C)(this.GP,this);this.V=(0,g.C)(this.OP,this);var c=0;a?(c=a.getProxyState(),3!=c&&(a.subscribe("proxyStateChange",this.pC,this),LMa(this))):c=3;0!=c&&(b?this.pC(c):g.op((0,g.C)(function(){this.pC(c)},this),0));
(a=JMa())&&S6(this,a);this.subscribe("ut-remote-cast2-session-change",this.V)},U6=function(a){return new L6(a.u.getPlayerContextData())},LMa=function(a){g.zb("nowAutoplaying autoplayDismissed remotePlayerChange remoteQueueChange autoplayModeChange autoplayUpNext previousNextChange".split(" "),function(b){this.C.push(this.u.subscribe(b,g.Pa(this.ZQ,b),this))},a)},MMa=function(a){g.zb(a.C,function(b){this.u.unsubscribeByKey(b)},a);
a.C.length=0},V6=function(a){return 1==a.getState()},W6=function(a,b){var c=a.B;
50>c.i.length+c.l.length&&a.B.l.push(b)},Y6=function(a,b,c){var d=U6(a);
O6(d,c);-1E3!=d.playerState&&(d.playerState=b);X6(a,d)},Z6=function(a,b,c){a.u.sendMessage(b,c)},X6=function(a,b){MMa(a);
a.u.setPlayerContextData(R6(b));LMa(a)},S6=function(a,b){a.l&&(a.l.removeUpdateListener(a.L),a.l.removeMediaListener(a.G),a.ot(null));
a.l=b;a.l&&(W5("CP","Setting cast session: "+a.l.sessionId),a.l.addUpdateListener(a.L),a.l.addMediaListener(a.G),a.l.media.length&&a.ot(a.l.media[0]))},NMa=function(a){var b=a.i.media,c=a.i.customData;
if(b&&c){var d=U6(a);b.contentId!=d.videoId&&W5("CP","Cast changing video to: "+b.contentId);d.videoId=b.contentId;d.playerState=c.playerState;O6(d,a.i.getEstimatedTime());X6(a,d)}else W5("CP","No cast media video. Ignoring state update.")},$6=function(a,b,c){return(0,g.C)(function(d){this.Jd("Failed to "+b+" with cast v2 channel. Error code: "+d.code);
d.code!=chrome.cast.ErrorCode.TIMEOUT&&(this.Jd("Retrying "+b+" using MDx browser channel."),Z6(this,b,c))},a)},a7=function(a,b,c){g.P.call(this);
this.C=NaN;this.ma=!1;this.L=this.J=this.W=this.Y=NaN;this.V=[];this.B=this.G=this.u=this.fc=this.i=null;this.xa=a;this.V.push(g.Up(window,"beforeunload",(0,g.C)(this.RN,this)));this.l=[];this.fc=new L6;this.Aa=b.id;this.ra=b.idType;this.i=OMa(this,c);this.i.subscribe("handlerOpened",this.LP,this);this.i.subscribe("handlerClosed",this.IP,this);this.i.subscribe("handlerError",this.JP,this);this.i.subscribe("handlerMessage",this.KP,this);this.i.qx(b.token);this.subscribe("remoteQueueChange",function(){var d=
this.fc.videoId;g.ov()&&g.kv("ut-remote-session-video-id",d)},this)},b7=function(a){W5("conn",a)},OMa=function(a,b){return new P5(T5(a.xa,"/bc"),b,!1,function(){return a.jE()},"shortLived"==a.ra)},c7=function(a,b){a.X("proxyStateChange",b)},PMa=function(a){a.C=g.op((0,g.C)(function(){b7("Connecting timeout");
this.Sp(1)},a),2E4)},d7=function(a){g.qp(a.C);
a.C=NaN},e7=function(a){g.qp(a.Y);
a.Y=NaN},QMa=function(a){f7(a);
a.W=g.op((0,g.C)(function(){g7(this,"getNowPlaying")},a),2E4)},f7=function(a){g.qp(a.W);
a.W=NaN},SMa=function(a,b){b&&(d7(a),e7(a));
var c=R5(a.i)&&isNaN(a.C);b==c?b&&(c7(a,1),g7(a,"getSubtitlesTrack")):b?(a.mG()&&a.fc.reset(),c7(a,1),g7(a,"getNowPlaying"),RMa(a)):a.Sp(1)},TMa=function(a,b){var c=b.params.videoId;
delete b.params.videoId;c==a.fc.videoId&&(g.Ob(b.params)?a.fc.trackData=null:a.fc.trackData=b.params,a.X("remotePlayerChange"))},UMa=function(a,b){var c=b.params.videoId||b.params.video_id,d=parseInt(b.params.currentIndex,10);
a.fc.listId=b.params.listId||a.fc.listId;Q6(a.fc,c,d);a.X("remoteQueueChange")},WMa=function(a,b){b.params=b.params||{};
UMa(a,b);VMa(a,b);a.X("autoplayDismissed")},VMa=function(a,b){var c=parseInt(b.params.currentTime||b.params.current_time,10);
O6(a.fc,isNaN(c)?0:c);c=parseInt(b.params.state,10);c=isNaN(c)?-1:c;-1==c&&-1E3==a.fc.playerState&&(c=-1E3);a.fc.playerState=c;c=Number(b.params.loadedTime);a.fc.L=isNaN(c)?0:c;c=Number(b.params.duration);a.fc.C=isNaN(c)?0:c;c=a.fc;var d=Number(b.params.liveIngestionTime);c.u=d;c.l=isNaN(d)?!1:!0;c=a.fc;d=Number(b.params.seekableStartTime);b=Number(b.params.seekableEndTime);c.B=isNaN(d)?0:d;c.i=isNaN(b)?0:b;1==a.fc.playerState?QMa(a):f7(a);a.X("remotePlayerChange")},XMa=function(a,b){if(-1E3!=a.fc.playerState){var c=
1085;
switch(parseInt(b.params.adState,10)){case 1:c=1081;break;case 2:c=1084;break;case 0:c=1083}a.fc.playerState=c;b=parseInt(b.params.currentTime,10);O6(a.fc,isNaN(b)?0:b);a.X("remotePlayerChange")}},YMa=function(a,b){var c="true"==b.params.muted;
a.fc.volume=parseInt(b.params.volume,10);a.fc.muted=c;a.X("remotePlayerChange")},ZMa=function(a,b){a.G=b.params.videoId;
a.X("nowAutoplaying",parseInt(b.params.timeout,10))},$Ma=function(a,b){var c="true"==b.params.hasNext;
a.fc.Dj="true"==b.params.hasPrevious;a.fc.hasNext=c;a.X("previousNextChange")},RMa=function(a){g.qp(a.L);
a.L=g.op((0,g.C)(a.Sp,a,1),864E5)},g7=function(a,b,c){c?b7("Sending: action="+b+", params="+g.xj(c)):b7("Sending: action="+b);
a.i.sendMessage(b,c)},h7=function(a){$5.call(this,"ScreenServiceProxy");
this.Bf=a;this.i=[];this.i.push(this.Bf.$_s("screenChange",(0,g.C)(this.qM,this)));this.i.push(this.Bf.$_s("onlineScreenChange",(0,g.C)(this.GQ,this)))},dNa=function(a,b){RKa();
if(!b5||!b5.get("ut-remote-disable-remote-module-for-dev")){b=g.M("MDX_CONFIG")||b;JKa();$4();i7||(i7=new S5(b?b.loungeApiHost:void 0),SKa()&&(i7.i="/api/loungedev"));j7||(j7=g.Ha("ut.mdx.remote.deferredProxies_")||[],g.Ga("ut.mdx.remote.deferredProxies_",j7,void 0));aNa();var c=k7();if(!c){var d=new j6(i7,b?b.disableAutomaticScreenCache||!1:!1);g.Ga("ut.mdx.remote.screenService_",d,void 0);c=k7();var e={};b&&(e={appId:b.appId,disableDial:b.disableDial,theme:b.theme,loadCastApiSetupScript:b.loadCastApiSetupScript,
disableCastApi:b.disableCastApi,enableDialLoungeToken:b.enableDialLoungeToken,enableCastLoungeToken:b.enableCastLoungeToken,forceMirroring:b.forceMirroring});FMa(a,d,function(f){f?l7()&&K6(l7(),"YouTube TV"):d.subscribe("onlineScreenChange",function(){O4("ut-remote-receiver-availability-change")})},e)}b&&!g.Ha("ut.mdx.remote.initialized_")&&(g.Ga("ut.mdx.remote.initialized_",!0,void 0),m7("Initializing: "+g.xj(b)),n7.push(g.Tq("ut-remote-cast2-availability-change",function(){O4("ut-remote-receiver-availability-change")})),
n7.push(g.Tq("ut-remote-cast2-receiver-selected",function(){o7(null);
O4("ut-remote-auto-connect","cast-selector-receiver")})),n7.push(g.Tq("ut-remote-cast2-receiver-resumed",function(){O4("ut-remote-receiver-resumed","cast-selector-receiver")})),n7.push(g.Tq("ut-remote-cast2-session-change",bNa)),n7.push(g.Tq("ut-remote-connection-change",function(f){f?K6(l7(),"YouTube TV"):p7()||(K6(null,null),IMa())})),a=q7(),b.isAuto&&(a.id+="#dial"),e=b.capabilities||[],g.Po("desktop_enable_autoplay")&&e.push("atp"),0<e.length&&(a.capabilities=e),a.name=b.device,a.app=b.app,(b=
b.theme)&&(a.theme=b),m7(" -- with channel params: "+g.xj(a)),a?(g.kv("ut-remote-session-app",a.app),g.kv("ut-remote-session-name",a.name)):(g.nv("ut-remote-session-app"),g.nv("ut-remote-session-name")),g.Ga("ut.mdx.remote.channelParams_",a,void 0),c.start(),l7()||cNa())}},eNa=function(){var a=k7().Bf.$_gos();
var b=r7();b&&s7()&&(V4(a,b)||a.push(b));return IKa(a)},t7=function(){var a=fNa();
!a&&H6()&&HMa()&&(a={key:"cast-selector-receiver",name:HMa()});return a},fNa=function(){var a=eNa(),b=r7();
b||(b=p7());return g.cb(a,function(c){return b&&R4(b,c.key)?!0:!1})},r7=function(){var a=l7();
if(!a)return null;var b=k7().Xg();return W4(b,a)},bNa=function(a){m7("remote.onCastSessionChange_: "+S4(a));
if(a){var b=r7();if(b&&b.id==a.id){if(K6(b.id,"YouTube TV"),"shortLived"==a.idType&&(a=a.token))u7&&(u7.token=a),(b=s7())&&b.qx(a)}else b&&v7(),w7(a,1)}else s7()&&v7()},v7=function(){I6()?F6().stopSession():D6("stopSession called before API ready.");
var a=s7();a&&(a.disconnect(1),x7(null))},y7=function(){var a=s7();
return!!a&&3!=a.getProxyState()},m7=function(a){W5("remote",a)},k7=function(){if(!z7){var a=g.Ha("ut.mdx.remote.screenService_");
z7=a?new h7(a):null}return z7},l7=function(){return g.Ha("ut.mdx.remote.currentScreenId_")},gNa=function(a){g.Ga("ut.mdx.remote.currentScreenId_",a,void 0)},hNa=function(){return g.Ha("ut.mdx.remote.connectData_")},o7=function(a){g.Ga("ut.mdx.remote.connectData_",a,void 0)},s7=function(){return g.Ha("ut.mdx.remote.connection_")},x7=function(a){var b=s7();
o7(null);a||gNa("");g.Ga("ut.mdx.remote.connection_",a,void 0);j7&&(g.zb(j7,function(c){c(a)}),j7.length=0);
b&&!a?O4("ut-remote-connection-change",!1):!b&&a&&O4("ut-remote-connection-change",!0)},p7=function(){var a=g.ov();
if(!a)return null;var b=k7();if(!b)return null;b=b.Xg();return W4(b,a)},w7=function(a,b){l7();
r7()&&r7();A7?u7=a:(gNa(a.id),a=new a7(i7,a,q7()),a.connect(b,hNa()),a.subscribe("beforeDisconnect",function(c){O4("ut-remote-before-disconnect",c)}),a.subscribe("beforeDispose",function(){s7()&&(s7(),x7(null))}),a.subscribe("browserChannelAuthError",function(){var c=r7();
c&&"shortLived"==c.idType&&(I6()?F6().handleBrowserChannelAuthError():D6("refreshLoungeToken called before API ready."))}),x7(a))},cNa=function(){var a=p7();
a?(m7("Resume connection to: "+S4(a)),w7(a,0)):(a5(),IMa(),m7("Skipping connecting because no session screen found."))},aNa=function(){var a=q7();
if(g.Ob(a)){a=Z4();var b=g.lv("ut-remote-session-name")||"",c=g.lv("ut-remote-session-app")||"";a={device:"REMOTE_CONTROL",id:a,name:b,app:c,mdxVersion:3};g.Ga("ut.mdx.remote.channelParams_",a,void 0)}},q7=function(){return g.Ha("ut.mdx.remote.channelParams_")||{}},B7=function(a,b,c){g.F.call(this);
var d=this;this.l=a;this.I=b;this.Ob=c;this.events=new g.TL(this);this.W=this.events.N(this.I,"onVolumeChange",function(e){iNa(d,e)});
this.C=!1;this.suggestion=null;this.G=new g.SI(64);this.i=new g.J(this.qJ,500,this);this.u=new g.J(this.rJ,1E3,this);this.L=new g5(this.tT,0,this);this.B={};this.V=new g.J(this.XJ,1E3,this);this.J=new h5(this.seekTo,1E3,this);this.Y=g.Ia;g.G(this,this.events);this.events.N(b,"onCaptionsTrackListChanged",this.rQ);this.events.N(b,"captionschanged",this.EP);this.events.N(b,"captionssettingschanged",this.xJ);this.events.N(b,"videoplayerreset",this.Uw);this.events.N(b,"mdxautoplaycancel",function(){d.Ob.LF()});
a=this.Ob;a.Ga();a.subscribe("proxyStateChange",this.pI,this);a.subscribe("remotePlayerChange",this.xt,this);a.subscribe("remoteQueueChange",this.Uw,this);a.subscribe("previousNextChange",this.mI,this);a.subscribe("nowAutoplaying",this.gI,this);a.subscribe("autoplayDismissed",this.HH,this);g.G(this,this.i);g.G(this,this.u);g.G(this,this.L);g.G(this,this.V);g.G(this,this.J);this.xJ();this.Uw();this.xt()},iNa=function(a,b){if(C7(a)){a.Ob.unsubscribe("remotePlayerChange",a.xt,a);
var c=Math.round(b.volume);b=!!b.muted;var d=U6(a.Ob);if(c!==d.volume||b!==d.muted)a.Ob.setVolume(c,b),a.V.start();a.Ob.subscribe("remotePlayerChange",a.xt,a)}},jNa=function(a){a.Tb(0);
a.i.stop();a.Lb(new g.SI(64))},D7=function(a,b){if(C7(a)&&!a.C){var c=null;
b&&(c={style:a.I.getSubtitlesUserSettings()},g.Vb(c,b));a.Ob.iE(a.I.getVideoData(1).videoId,c);a.B=U6(a.Ob).trackData}},E7=function(a,b){var c=a.I.getPlaylist();
if(null===c||void 0===c?0:c.listId){var d=c.index;var e=c.listId.toString()}c=a.I.getVideoData(1);a.Ob.playVideo(c.videoId,b,d,e,c.playerParams,c.Da,vKa(c));a.Lb(new g.SI(1))},kNa=function(a,b){if(b){var c=a.I.getOption("captions","tracklist",{HG:1});
c&&c.length?(a.I.setOption("captions","track",b),a.C=!1):(a.I.loadModule("captions"),a.C=!0)}else a.I.setOption("captions","track",{})},C7=function(a){return U6(a.Ob).videoId===a.I.getVideoData(1).videoId},F7=function(){g.V.call(this,{D:"div",
K:"utp-mdx-manual-pairing-popup-dialog",U:{role:"dialog"},S:[{D:"div",K:"utp-mdx-manual-pairing-popup-dialog-inner-content",S:[{D:"div",K:"utp-mdx-manual-pairing-popup-title",oa:"Connecting to your TV on web using a code will be going away soon"},{D:"div",K:"utp-mdx-manual-pairing-popup-buttons",S:[{D:"button",Ca:["utp-button","utp-mdx-manual-pairing-popup-learn-more"],oa:"Learn more"},{D:"button",Ca:["utp-button","utp-mdx-manual-pairing-popup-ok"],oa:"OK"}]}]}]});this.i=new g.xK(this,250);this.learnMoreButton=
this.Ba("utp-mdx-manual-pairing-popup-learn-more");this.okButton=this.Ba("utp-mdx-manual-pairing-popup-ok");g.G(this,this.i);this.N(this.learnMoreButton,"click",this.l);this.N(this.okButton,"click",this.u)},G7=function(){g.V.call(this,{D:"div",
K:"utp-mdx-popup-dialog",U:{role:"dialog"},S:[{D:"div",K:"utp-mdx-popup-dialog-inner-content",S:[{D:"div",K:"utp-mdx-popup-title",oa:"You're signed out"},{D:"div",K:"utp-mdx-popup-description",oa:"Videos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer."},{D:"div",K:"utp-mdx-privacy-popup-buttons",S:[{D:"button",Ca:["utp-button","utp-mdx-privacy-popup-cancel"],oa:"Cancel"},{D:"button",Ca:["utp-button",
"utp-mdx-privacy-popup-confirm"],oa:"Confirm"}]}]}]});this.i=new g.xK(this,250);this.cancelButton=this.Ba("utp-mdx-privacy-popup-cancel");this.confirmButton=this.Ba("utp-mdx-privacy-popup-confirm");g.G(this,this.i);this.N(this.cancelButton,"click",this.l);this.N(this.confirmButton,"click",this.u)},H7=function(a){g.V.call(this,{D:"div",
K:"utp-remote",S:[{D:"div",K:"utp-remote-display-status",S:[{D:"div",K:"utp-remote-display-status-icon",S:[g.Lma()]},{D:"div",K:"utp-remote-display-status-text",oa:"{{statustext}}"}]}]});this.api=a;this.i=new g.xK(this,250);g.G(this,this.i);this.N(a,"presentingplayerstatechange",this.l);lNa(this,a.sb())},lNa=function(a,b){if(3===a.api.getPresentingPlayerType()){var c={RECEIVER_NAME:a.api.getOption("remote","currentReceiver").name};
b=g.T(b,128)?g.wH("Error on $RECEIVER_NAME",c):b.uc()||g.T(b,4)?g.wH("Playing on $RECEIVER_NAME",c):g.wH("Connected to $RECEIVER_NAME",c);a.Qa("statustext",b);a.i.show()}else a.i.hide()},I7=function(a,b){g.UO.call(this,"Play on",0,a,b);
this.I=a;this.Dm={};this.N(a,"onMdxReceiversChange",this.C);this.N(a,"presentingplayerstatechange",this.C);this.C()},J7=function(a){g.dM.call(this,a);
this.ri={key:U4(),name:"This computer"};this.qh=null;this.subscriptions=[];this.QB=this.Ob=null;this.Dm=[this.ri];this.Kl=this.ri;this.dd=new g.SI(64);this.dH=0;this.Qe=-1;this.uq=null;this.Ct=this.ww=!1;this.Zk=this.Cq=null;if(!g.CD(this.player.T())&&!g.DD(this.player.T())){a=this.player;var b=g.wL(a);b&&(b=b.Yl())&&(b=new I7(a,b),g.G(this,b));b=new H7(a);g.G(this,b);g.GL(a,b.element,4);this.Cq=new G7;g.G(this,this.Cq);g.GL(a,this.Cq.element,4);g.R(this.player.T().experiments,"pair_servlet_deprecation_warning_enabled")&&
!g.R(this.player.T().experiments,"deprecate_pair_servlet_enabled")&&(this.uq=new F7,g.G(this,this.uq),g.GL(a,this.uq.element,4));this.Ct=!!p7();this.ww=!!g.lv("ut-remote-manual-pairing-warning-shown")}},K7=function(a){a.Zk&&(a.player.removeEventListener("presentingplayerstatechange",a.Zk),a.Zk=null)},mNa=function(a,b,c){a.dd=c;
a.player.X("presentingplayerstatechange",new g.jH(c,b))},nNa=function(a,b,c){var d=!1;
1===b?d=!a.Ct:2===b&&(d=!a.ww);d&&g.lH(c,8)&&(a.player.pauseVideo(),K7(a))},L7=function(a,b){if(b.key!==a.Kl.key)if(b.key===a.ri.key)v7();
else{if(a.uq&&!a.ww&&b!==a.ri&&"cast-selector-receiver"!==b.key&&g.YD(a.player.T()))oNa(a);else{var c;(c=!g.R(a.player.T().experiments,"mdx_enable_privacy_disclosure_ui"))||(c=((c=g.M("PLAYER_CONFIG"))&&c.args&&void 0!==c.args.authuser?!0:!(!g.M("SESSION_INDEX")&&!g.M("LOGGED_IN")))||a.Ct||!a.Cq);(c?0:g.YD(a.player.T())||g.bE(a.player.T()))&&pNa(a)}a.Kl=b;if(!a.player.T().Z("disable_mdx_connection_in_mdx_module_for_music_web")||!g.DD(a.player.T())){var d=a.player.getPlaylistId();c=a.player.getVideoData(1);
var e=c.videoId;if(!d&&!e||(2===a.player.getAppState()||1===a.player.getAppState())&&g.R(a.player.T().experiments,"should_clear_video_data_on_player_cued_unstarted"))a=null;else{var f=a.player.getPlaylist();if(f){var h=[];for(var l=0;l<f.length;l++)h[l]=f.bb(l).videoId}else h=[e];f=a.player.getCurrentTime(1);a={videoIds:h,listId:d,videoId:e,playerParams:c.playerParams,clickTrackingParams:c.Da,index:Math.max(a.player.getPlaylistIndex(),0),currentTime:0===f?void 0:f};(c=vKa(c))&&(a.locationInfo=c)}m7("Connecting to: "+
g.xj(b));"cast-selector-receiver"==b.key?(o7(a||null),b=a||null,I6()?F6().setLaunchParams(b):D6("setLaunchParams called before ready.")):!a&&y7()&&l7()==b.key?O4("ut-remote-connection-change",!0):(v7(),o7(a||null),a=k7().Xg(),(b=W4(a,b.key))&&w7(b,1))}}},pNa=function(a){a.player.sb().uc()?a.player.pauseVideo():(a.Zk=function(b){nNa(a,1,b)},a.player.addEventListener("presentingplayerstatechange",a.Zk));
a.Cq&&a.Cq.Vc();s7()||(A7=!0)},oNa=function(a){a.player.sb().uc()?a.player.pauseVideo():(a.Zk=function(b){nNa(a,2,b)},a.player.addEventListener("presentingplayerstatechange",a.Zk));
a.uq&&a.uq.Vc();s7()||(A7=!0)},kLa={"\x00":"\\0",
"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\","<":"\\u003C"},w5={"'":"\\'"},EKa={rU:"atp",V3:"ska",L2:"que",R0:"mus",U3:"sus",kY:"dsp",h3:"seq",u0:"mic",kX:"dpa",FU:"cds",P0:"mlm"},b5,Y4="",YKa=TKa("loadCastFramework")||TKa("loadCastApplicationFramework"),$Ka=["pkedcjkdefgpdelpbcmbmeomcjbeemfm","enhhojjnijigcajfphajepfemndkmdlo"];/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
g.Sa(g5,g.F);g.k=g5.prototype;g.k.fM=function(a){this.B=arguments;this.i=!1;this.Fb?this.u=g.Ra()+this.Cf:this.Fb=g.Hm(this.C,this.Cf)};
g.k.stop=function(){this.Fb&&(g.B.clearTimeout(this.Fb),this.Fb=null);this.u=null;this.i=!1;this.B=[]};
g.k.pause=function(){++this.l};
g.k.resume=function(){this.l&&(--this.l,!this.l&&this.i&&(this.i=!1,this.G.apply(null,this.B)))};
g.k.va=function(){this.stop();g5.Id.va.call(this)};
g.k.gM=function(){this.Fb&&(g.B.clearTimeout(this.Fb),this.Fb=null);this.u?(this.Fb=g.Hm(this.C,this.u-g.Ra()),this.u=null):this.l?this.i=!0:(this.i=!1,this.G.apply(null,this.B))};g.v(h5,g.F);g.k=h5.prototype;g.k.bE=function(a){this.u=arguments;this.Fb||this.l?this.i=!0:i5(this)};
g.k.stop=function(){this.Fb&&(g.B.clearTimeout(this.Fb),this.Fb=null,this.i=!1,this.u=null)};
g.k.pause=function(){this.l++};
g.k.resume=function(){this.l--;this.l||!this.i||this.Fb||(this.i=!1,i5(this))};
g.k.va=function(){g.F.prototype.va.call(this);this.stop()};k5.prototype.stringify=function(a){return g.B.JSON.stringify(a,void 0)};
k5.prototype.parse=function(a){return g.B.JSON.parse(a,void 0)};var m5=new g.Wl;g.v(bLa,g.xl);o5.prototype.i=null;o5.prototype.getOptions=function(){var a;(a=this.i)||(a={},dLa(this)&&(a[0]=!0,a[1]=!0),a=this.i=a);return a};var M7;g.Sa(cLa,o5);M7=new cLa;g.k=p5.prototype;g.k.Ym=null;g.k.Li=!1;g.k.Sq=null;g.k.cD=null;g.k.Dq=null;g.k.Nq=null;g.k.Dl=null;g.k.Fm=null;g.k.Oo=null;g.k.He=null;g.k.vu=0;g.k.Qi=null;g.k.Qx=null;g.k.yl=null;g.k.xr=-1;g.k.iJ=!0;g.k.En=!1;g.k.Ly=0;g.k.bx=null;var iLa={},s5={};g.k=p5.prototype;g.k.setTimeout=function(a){this.C=a};
g.k.vS=function(a){a=a.target;var b=this.bx;b&&3==B5(a)?b.bE():this.fK(a)};
g.k.fK=function(a){try{if(a==this.He)a:{var b=B5(this.He),c=this.He.G,d=this.He.getStatus();if(g.xe&&!g.be(10)||g.ze&&!g.ae("420+")){if(4>b)break a}else if(3>b||3==b&&!g.lg&&!D5(this.He))break a;this.En||4!=b||7==c||(8==c||0>=d?this.i.zi(3):this.i.zi(2));x5(this);var e=this.He.getStatus();this.xr=e;var f=D5(this.He);(this.Li=200==e)?(4==b&&u5(this),this.G?(jLa(this,b,f),g.lg&&this.Li&&3==b&&(this.B.Pa(this.u,"tick",this.qS),this.u.start())):t5(this,f),this.Li&&!this.En&&(4==b?this.i.Ku(this):(this.Li=
!1,r5(this)))):(400==e&&0<f.indexOf("Unknown SID")?(this.yl=3,n5(13)):(this.yl=0,n5(14)),u5(this),v5(this))}}catch(h){this.He&&D5(this.He)}finally{}};
g.k.qS=function(){var a=B5(this.He),b=D5(this.He);this.vu<b.length&&(x5(this),jLa(this,a,b),this.Li&&4!=a&&r5(this))};
g.k.UR=function(a){l5((0,g.C)(this.TR,this,a),0)};
g.k.TR=function(a){this.En||(x5(this),t5(this,a),r5(this))};
g.k.xI=function(a){l5((0,g.C)(this.SR,this,a),0)};
g.k.SR=function(a){this.En||(u5(this),this.Li=a,this.i.Ku(this),this.i.zi(4))};
g.k.cancel=function(){this.En=!0;u5(this)};
g.k.cS=function(){this.Sq=null;var a=Date.now();0<=a-this.cD?(2!=this.Nq&&this.i.zi(3),u5(this),this.yl=2,n5(18),v5(this)):mLa(this,this.cD-a)};
g.k.getLastError=function(){return this.yl};g.Sa(z5,g.Wl);var tLa=/^https?$/i,qNa=["POST","PUT"];g.k=z5.prototype;
g.k.send=function(a,b,c,d){if(this.i)throw Error("[goog.net.XhrIo] Object is active with another request="+this.V+"; newUri="+a);b=b?b.toUpperCase():"GET";this.V=a;this.u="";this.G=0;this.Fa=b;this.xa=!1;this.B=!0;this.i=this.ra?eLa(this.ra):eLa(M7);this.ma=this.ra?this.ra.getOptions():M7.getOptions();this.i.onreadystatechange=(0,g.C)(this.nI,this);try{N4(C5(this,"Opening Xhr")),this.Aa=!0,this.i.open(b,String(a),!0),this.Aa=!1}catch(f){N4(C5(this,"Error opening Xhr: "+f.message));sLa(this,f);return}a=
c||"";var e=this.headers.clone();d&&AKa(d,function(f,h){e.set(h,f)});
d=g.cb(e.Bh(),qLa);c=g.B.FormData&&a instanceof g.B.FormData;!g.fb(qNa,b)||d||c||e.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");e.forEach(function(f,h){this.i.setRequestHeader(h,f)},this);
this.Ma&&(this.i.responseType=this.Ma);"withCredentials"in this.i&&this.i.withCredentials!==this.Da&&(this.i.withCredentials=this.Da);try{vLa(this),0<this.J&&(this.Y=pLa(this.i),N4(C5(this,"Will abort after "+this.J+"ms if incomplete, xhr2 "+this.Y)),this.Y?(this.i.timeout=this.J,this.i.ontimeout=(0,g.C)(this.cE,this)):this.W=g.Hm(this.cE,this.J,this)),N4(C5(this,"Sending request")),this.L=!0,this.i.send(a),this.L=!1}catch(f){N4(C5(this,"Send error: "+f.message)),sLa(this,f)}};
g.k.cE=function(){"undefined"!=typeof g.e0&&this.i&&(this.u="Timed out after "+this.J+"ms, aborting",this.G=8,C5(this,this.u),this.dispatchEvent("timeout"),this.abort(8))};
g.k.abort=function(a){this.i&&this.B&&(C5(this,"Aborting"),this.B=!1,this.C=!0,this.i.abort(),this.C=!1,this.G=a||7,this.dispatchEvent("complete"),this.dispatchEvent("abort"),A5(this))};
g.k.va=function(){this.i&&(this.B&&(this.B=!1,this.C=!0,this.i.abort(),this.C=!1),A5(this,!0));z5.Id.va.call(this)};
g.k.nI=function(){this.Ga()||(this.Aa||this.L||this.C?uLa(this):this.bR())};
g.k.bR=function(){uLa(this)};
g.k.isActive=function(){return!!this.i};
g.k.Ud=function(){return 4==B5(this)};
g.k.getStatus=function(){try{return 2<B5(this)?this.i.status:-1}catch(a){return-1}};
g.k.getResponseHeader=function(a){if(this.i&&this.Ud())return a=this.i.getResponseHeader(a),null===a?void 0:a};
g.k.getLastError=function(){return"string"===typeof this.u?this.u:String(this.u)};g.k=wLa.prototype;g.k.My=null;g.k.Kg=null;g.k.dx=!1;g.k.sJ=null;g.k.wv=null;g.k.aB=null;g.k.Ny=null;g.k.eb=null;g.k.gk=-1;g.k.yr=null;g.k.Jr=null;g.k.connect=function(a){this.Ny=a;a=E5(this.i,null,this.Ny);n5(3);this.sJ=Date.now();var b=this.i.J;null!=b?(this.yr=b[0],(this.Jr=b[1])?(this.eb=1,xLa(this)):(this.eb=2,G5(this))):(L4(a,"MODE","init"),this.Kg=new p5(this,void 0,void 0,void 0),this.Kg.Ym=this.My,q5(this.Kg,a,!1,null,!0),this.eb=0)};
g.k.bN=function(a){if(a)this.eb=2,G5(this);else{n5(4);var b=this.i;b.pj=b.Il.gk;N5(b,9)}a&&this.zi(2)};
g.k.Qz=function(a){return this.i.Qz(a)};
g.k.abort=function(){this.Kg&&(this.Kg.cancel(),this.Kg=null);this.gk=-1};
g.k.dE=function(){return!1};
g.k.qI=function(a,b){this.gk=a.xr;if(0==this.eb)if(b){try{var c=this.l.parse(b)}catch(d){a=this.i;a.pj=this.gk;N5(a,2);return}this.yr=c[0];this.Jr=c[1]}else a=this.i,a.pj=this.gk,N5(a,2);else if(2==this.eb)if(this.dx)n5(7),this.aB=Date.now();else if("11111"==b){if(n5(6),this.dx=!0,this.wv=Date.now(),a=this.wv-this.sJ,!g.xe||g.be(10)||500>a)this.gk=200,this.Kg.cancel(),n5(12),F5(this.i,this,!0)}else n5(8),this.wv=this.aB=Date.now(),this.dx=!1};
g.k.Ku=function(){this.gk=this.Kg.xr;if(this.Kg.Li)0==this.eb?this.Jr?(this.eb=1,xLa(this)):(this.eb=2,G5(this)):2==this.eb&&((!g.xe||g.be(10)?!this.dx:200>this.aB-this.wv)?(n5(11),F5(this.i,this,!1)):(n5(12),F5(this.i,this,!0)));else{0==this.eb?n5(9):2==this.eb&&n5(10);var a=this.i;this.Kg.getLastError();a.pj=this.gk;N5(a,2)}};
g.k.Tt=function(){return this.i.Tt()};
g.k.isActive=function(){return this.i.isActive()};
g.k.zi=function(a){this.i.zi(a)};g.k=H5.prototype;g.k.nj=null;g.k.Zr=null;g.k.yg=null;g.k.Yd=null;g.k.Oy=null;g.k.xv=null;g.k.gF=null;g.k.Lu=null;g.k.gt=0;g.k.aP=0;g.k.xf=null;g.k.Pl=null;g.k.yk=null;g.k.Mn=null;g.k.Il=null;g.k.Ox=null;g.k.nq=-1;g.k.cH=-1;g.k.pj=-1;g.k.Wp=0;g.k.Kp=0;g.k.Fn=8;g.Sa(zLa,g.xl);g.Sa(ALa,g.xl);g.k=H5.prototype;g.k.connect=function(a,b,c,d,e){n5(0);this.Oy=b;this.Zr=c||{};d&&void 0!==e&&(this.Zr.OSID=d,this.Zr.OAID=e);this.C?(l5((0,g.C)(this.yF,this,a),100),ELa(this)):this.yF(a)};
g.k.yF=function(a){this.Il=new wLa(this);this.Il.My=this.nj;this.Il.l=this.B;this.Il.connect(a)};
g.k.dE=function(){return 0==this.eb};
g.k.getState=function(){return this.eb};
g.k.vI=function(a){this.Pl=null;ILa(this,a)};
g.k.uI=function(){this.yk=null;this.Yd=new p5(this,this.l,"rpc",this.G);this.Yd.Ym=this.nj;this.Yd.Ly=0;var a=this.gF.clone();J4(a,"RID","rpc");J4(a,"SID",this.l);J4(a,"CI",this.Ox?"0":"1");J4(a,"AID",this.nq);I5(this,a);if(!g.xe||g.be(10))J4(a,"TYPE","xmlhttp"),q5(this.Yd,a,!0,this.Lu,!1);else{J4(a,"TYPE","html");var b=this.Yd,c=!!this.Lu;b.Nq=3;b.Dl=K4(a.clone());lLa(b,c)}};
g.k.qI=function(a,b){if(0!=this.eb&&(this.Yd==a||this.yg==a))if(this.pj=a.xr,this.yg==a&&3==this.eb)if(7<this.Fn){try{var c=this.B.parse(b)}catch(d){c=null}if(Array.isArray(c)&&3==c.length)if(a=c,0==a[0])a:{if(!this.yk){if(this.Yd)if(this.Yd.Dq+3E3<this.yg.Dq)K5(this),this.Yd.cancel(),this.Yd=null;else break a;M5(this);n5(19)}}else this.cH=a[1],0<this.cH-this.nq&&37500>a[2]&&this.Ox&&0==this.Kp&&!this.Mn&&(this.Mn=l5((0,g.C)(this.BP,this),6E3));else N5(this,11)}else null!=b&&N5(this,11);else if(this.Yd==
a&&K5(this),!g.nc(b))for(a=this.B.parse(b),b=0;b<a.length;b++)c=a[b],this.nq=c[0],c=c[1],2==this.eb?"c"==c[0]?(this.l=c[1],this.Lu=c[2],c=c[3],null!=c?this.Fn=c:this.Fn=6,this.eb=3,this.xf&&this.xf.uF(),this.gF=E5(this,this.Tt()?this.Lu:null,this.Oy),JLa(this)):"stop"==c[0]&&N5(this,7):3==this.eb&&("stop"==c[0]?N5(this,7):"noop"!=c[0]&&this.xf&&this.xf.tF(c),this.Kp=0)};
g.k.BP=function(){null!=this.Mn&&(this.Mn=null,this.Yd.cancel(),this.Yd=null,M5(this),n5(20))};
g.k.Ku=function(a){if(this.Yd==a){K5(this);this.Yd=null;var b=2}else if(this.yg==a)this.yg=null,b=1;else return;this.pj=a.xr;if(0!=this.eb)if(a.Li)if(1==b){b=Date.now()-a.Dq;var c=m5;c.dispatchEvent(new zLa(c,a.Oo?a.Oo.length:0,b,this.Wp));J5(this);this.u.length=0}else JLa(this);else{c=a.getLastError();var d;if(!(d=3==c||7==c||0==c&&0<this.pj)){if(d=1==b)this.yg||this.Pl||1==this.eb||2<=this.Wp?d=!1:(this.Pl=l5((0,g.C)(this.vI,this,a),KLa(this,this.Wp)),this.Wp++,d=!0);d=!(d||2==b&&M5(this))}if(d)switch(c){case 1:N5(this,
5);break;case 4:N5(this,10);break;case 3:N5(this,6);break;case 7:N5(this,12);break;default:N5(this,2)}}};
g.k.yN=function(a){if(!g.fb(arguments,this.eb))throw Error("Unexpected channel state: "+this.eb);};
g.k.bT=function(a){a?n5(2):(n5(1),LLa(this,8))};
g.k.Qz=function(a){if(a)throw Error("Can't create secondary domain capable XhrIo object.");a=new z5;a.Da=!1;return a};
g.k.isActive=function(){return!!this.xf&&this.xf.isActive(this)};
g.k.zi=function(a){var b=m5;b.dispatchEvent(new ALa(b,a))};
g.k.Tt=function(){return!(!g.xe||g.be(10))};
g.k=MLa.prototype;g.k.uF=function(){};
g.k.tF=function(){};
g.k.sF=function(){};
g.k.Cz=function(){};
g.k.aG=function(){return{}};
g.k.isActive=function(){return!0};g.k=NLa.prototype;g.k.isEmpty=function(){return g.gb(this.i)&&g.gb(this.l)};
g.k.clear=function(){this.i=[];this.l=[]};
g.k.contains=function(a){return g.fb(this.i,a)||g.fb(this.l,a)};
g.k.remove=function(a){var b=this.i;var c=(0,g.cFa)(b,a);0<=c?(g.jb(b,c),b=!0):b=!1;return b||g.kb(this.l,a)};
g.k.Ag=function(){for(var a=[],b=this.i.length-1;0<=b;--b)a.push(this.i[b]);var c=this.l.length;for(b=0;b<c;++b)a.push(this.l[b]);return a};g.Sa(O5,g.F);g.k=O5.prototype;g.k.MR=function(){this.Cf=Math.min(3E5,2*this.Cf);this.u();this.l&&this.start()};
g.k.start=function(){var a=this.Cf+15E3*Math.random();g.on(this.i,a);this.l=g.Ra()+a};
g.k.stop=function(){this.i.stop();this.l=0};
g.k.isActive=function(){return this.i.isActive()};
g.k.reset=function(){this.i.stop();this.Cf=5E3};g.Sa(P5,MLa);g.k=P5.prototype;g.k.subscribe=function(a,b,c){return this.u.subscribe(a,b,c)};
g.k.unsubscribe=function(a,b,c){return this.u.unsubscribe(a,b,c)};
g.k.If=function(a){return this.u.If(a)};
g.k.X=function(a,b){return this.u.X.apply(this.u,arguments)};
g.k.dispose=function(){this.W||(this.W=!0,g.xi(this.u),QLa(this),g.xi(this.l),this.l=null,this.Y=function(){return""})};
g.k.Ga=function(){return this.W};
g.k.connect=function(a,b,c){if(!this.i||2!=this.i.getState()){this.V="";this.l.stop();this.C=a||null;this.B=b||0;a=this.ma+"/test";b=this.ma+"/bind";var d=new H5(c?c.firstTestResults:null,c?c.secondTestResults:null,this.ra),e=this.i;e&&(e.xf=null);d.xf=this;this.i=d;Q5(this);if(this.i){d=g.M("ID_TOKEN");var f=this.i.nj||{};d?f["x-youtube-identity-token"]=d:delete f["x-youtube-identity-token"];this.i.nj=f}e?(3!=e.getState()&&0==GLa(e)||e.getState(),this.i.connect(a,b,this.G,e.l,e.nq)):c?this.i.connect(a,
b,this.G,c.sessionId,c.arrayId):this.i.connect(a,b,this.G)}};
g.k.sendMessage=function(a,b){a={_sc:a};b&&g.Vb(a,b);this.l.isActive()||2==(this.i?this.i.getState():0)?this.J.push(a):R5(this)&&(Q5(this),FLa(this.i,a))};
g.k.uF=function(){this.l.reset();this.C=null;this.B=0;if(this.J.length){var a=this.J;this.J=[];for(var b=0,c=a.length;b<c;++b)FLa(this.i,a[b])}this.X("handlerOpened")};
g.k.sF=function(a){var b=2==a&&401==this.i.pj;4==a||b||this.l.start();this.X("handlerError",a,b)};
g.k.Cz=function(a){if(!this.l.isActive())this.X("handlerClosed");else if(a)for(var b=0,c=a.length;b<c;++b){var d=a[b].map;d&&this.J.push(d)}};
g.k.aG=function(){var a={v:2};this.V&&(a.gsessionid=this.V);0!=this.B&&(a.ui=""+this.B);0!=this.L&&(a.ui=""+this.L);this.C&&g.Vb(a,this.C);return a};
g.k.tF=function(a){"S"==a[0]?this.V=a[1]:"gracefulReconnect"==a[0]?(this.l.start(),DLa(this.i)):this.X("handlerMessage",new OLa(a[0],a[1]))};
g.k.qx=function(a){(this.G.loungeIdToken=a)||this.l.stop();if(this.xa&&this.i){var b=this.i.nj||{};a?b["X-YouTube-LoungeId-Token"]=a:delete b["X-YouTube-LoungeId-Token"];this.i.nj=b}};
g.k.HS=function(){this.l.isActive();0==GLa(this.i)&&this.connect(this.C,this.B)};S5.prototype.B=function(a,b,c,d){b?a(d):a({text:c.responseText})};
S5.prototype.u=function(a,b){a(Error("Request error: "+b.status))};
S5.prototype.C=function(a){a(Error("request timed out"))};var XLa=Date.now(),V5=null,Y5=Array(50),X5=-1,Z5=!1;g.Sa($5,g.P);$5.prototype.Xg=function(){return this.screens};
$5.prototype.contains=function(a){return!!V4(this.screens,a)};
$5.prototype.get=function(a){return a?W4(this.screens,a):null};
$5.prototype.info=function(a){W5(this.G,a)};g.v(a6,g.P);g.k=a6.prototype;g.k.start=function(){!this.i&&isNaN(this.Fb)&&this.FI()};
g.k.stop=function(){this.i&&(this.i.abort(),this.i=null);isNaN(this.Fb)||(g.qp(this.Fb),this.Fb=NaN)};
g.k.va=function(){this.stop();g.P.prototype.va.call(this)};
g.k.FI=function(){this.Fb=NaN;this.i=g.vp(T5(this.u,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:this.J},timeout:5E3,onSuccess:(0,g.C)(this.iM,this),onError:(0,g.C)(this.hM,this),onTimeout:(0,g.C)(this.jM,this)})};
g.k.iM=function(a,b){this.i=null;a=b.screen||{};a.dialId=this.B;a.name=this.G;b=-1;this.C&&a.shortLivedLoungeToken&&a.shortLivedLoungeToken.value&&a.shortLivedLoungeToken.refreshIntervalMs&&(a.screenIdType="shortLived",a.loungeToken=a.shortLivedLoungeToken.value,b=a.shortLivedLoungeToken.refreshIntervalMs);this.X("pairingComplete",new Q4(a),b)};
g.k.hM=function(a){this.i=null;a.status&&404==a.status?this.l>=rNa.length?this.X("pairingFailed",Error("DIAL polling timed out")):(a=rNa[this.l],this.Fb=g.op((0,g.C)(this.FI,this),a),this.l++):this.X("pairingFailed",Error("Server error "+a.status))};
g.k.jM=function(){this.i=null;this.X("pairingFailed",Error("Server not responding"))};
var rNa=[2E3,2E3,1E3,1E3,1E3,2E3,2E3,5E3,5E3,1E4];g.Sa(c6,$5);g.k=c6.prototype;g.k.start=function(){b6(this)&&this.X("screenChange");!g.lv("ut-remote-lounge-token-expiration")&&aMa(this);g.qp(this.i);this.i=g.op((0,g.C)(this.start,this),1E4)};
g.k.add=function(a,b){b6(this);YLa(this,a);d6(this,!1);this.X("screenChange");b(a);a.token||aMa(this)};
g.k.remove=function(a,b){var c=b6(this);$La(this,a)&&(d6(this,!1),c=!0);b(a);c&&this.X("screenChange")};
g.k.Mx=function(a,b,c,d){var e=b6(this),f=this.get(a.id);f?(f.name!=b&&(f.name=b,d6(this,!1),e=!0),c(a)):d(Error("no such local screen."));e&&this.X("screenChange")};
g.k.va=function(){g.qp(this.i);c6.Id.va.call(this)};
g.k.VN=function(a){b6(this);var b=this.screens.length;a=a&&a.screens||[];for(var c=0,d=a.length;c<d;++c){var e=a[c],f=this.get(e.screenId);f&&(f.token=e.loungeToken,--b)}d6(this,!b);b&&W5(this.G,"Missed "+b+" lounge tokens.")};
g.k.UN=function(a){W5(this.G,"Requesting lounge tokens failed: "+a)};g.v(f6,g.P);g.k=f6.prototype;g.k.start=function(){var a=parseInt(g.lv("ut-remote-fast-check-period")||"0",10);(this.B=g.Ra()-144E5<a?0:a)?i6(this):(this.B=g.Ra()+3E5,g.kv("ut-remote-fast-check-period",this.B),this.dC())};
g.k.isEmpty=function(){return g.Ob(this.i)};
g.k.update=function(){e6("Updating availability on schedule.");var a=this.G(),b=g.Cb(this.i,function(c,d){return c&&!!W4(a,d)},this);
h6(this,b)};
g.k.va=function(){g.qp(this.u);this.u=NaN;this.l&&(this.l.abort(),this.l=null);g.P.prototype.va.call(this)};
g.k.dC=function(){g.qp(this.u);this.u=NaN;this.l&&this.l.abort();var a=cMa(this);if(M4(a)){var b=T5(this.C,"/pairing/get_screen_availability");this.l=U5(this.C,b,{lounge_token:g.Jb(a).join(",")},(0,g.C)(this.vR,this,a),(0,g.C)(this.uR,this))}else h6(this,{}),i6(this)};
g.k.vR=function(a,b){this.l=null;var c=g.Jb(cMa(this));if(g.xb(c,g.Jb(a))){b=b.screens||[];c={};for(var d=0,e=b.length;d<e;++d)c[a[b[d].loungeToken]]="online"==b[d].status;h6(this,c);i6(this)}else this.Jd("Changing Screen set during request."),this.dC()};
g.k.uR=function(a){this.Jd("Screen availability failed: "+a);this.l=null;i6(this)};
g.k.Jd=function(a){W5("OnlineScreenService",a)};g.Sa(j6,$5);g.k=j6.prototype;g.k.start=function(){this.l.start();this.i.start();this.screens.length&&(this.X("screenChange"),this.i.isEmpty()||this.X("onlineScreenChange"))};
g.k.add=function(a,b,c){this.l.add(a,b,c)};
g.k.remove=function(a,b,c){this.l.remove(a,b,c);this.i.update()};
g.k.Mx=function(a,b,c,d){this.l.contains(a)?this.l.Mx(a,b,c,d):(a="Updating name of unknown screen: "+a.name,W5(this.G,a),d(Error(a)))};
g.k.Xg=function(a){return a?this.screens:g.nb(this.screens,g.Je(this.u,function(b){return!this.contains(b)},this))};
g.k.eE=function(){return g.Je(this.Xg(!0),function(a){return!!this.i.i[a.id]},this)};
g.k.fE=function(a,b,c,d,e,f){var h=this;this.info("getDialScreenByPairingCode "+a+" / "+b);var l=new a6(this.B,a,b,c,d);l.subscribe("pairingComplete",function(m,n){g.xi(l);e(k6(h,m),n)});
l.subscribe("pairingFailed",function(m){g.xi(l);f(m)});
l.start();return(0,g.C)(l.stop,l)};
g.k.kM=function(a,b,c,d){g.vp(T5(this.B,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:a},timeout:5E3,onSuccess:(0,g.C)(function(e,f){e=new Q4(f.screen||{});if(!e.name||gMa(this,e.name)){a:{f=e.name;for(var h=2,l=b(f,h);gMa(this,l);){h++;if(20<h)break a;l=b(f,h)}f=l}e.name=f}c(k6(this,e))},this),
onError:(0,g.C)(function(e){d(Error("pairing request failed: "+e.status))},this),
onTimeout:(0,g.C)(function(){d(Error("pairing request timed out."))},this)})};
g.k.va=function(){g.xi(this.l);g.xi(this.i);j6.Id.va.call(this)};
g.k.bO=function(){iMa(this);this.X("screenChange");this.i.update()};
j6.prototype.dispose=j6.prototype.dispose;g.Sa(m6,g.P);g.k=m6.prototype;g.k.getScreen=function(){return this.B};
g.k.Yf=function(a){this.Ga()||(a&&o6(this,""+a),this.B=null,this.X("sessionScreen",null))};
g.k.info=function(a){W5(this.xa,a)};
g.k.gE=function(){return null};
g.k.nC=function(a){var b=this.i;a?(b.displayStatus=new chrome.cast.ReceiverDisplayStatus(a,[]),b.displayStatus.showStop=!0):b.displayStatus=null;chrome.cast.setReceiverDisplayStatus(b,(0,g.C)(function(){this.info("Updated receiver status for "+b.friendlyName+": "+a)},this),(0,g.C)(function(){o6(this,"Failed to update receiver status for: "+b.friendlyName)},this))};
g.k.va=function(){this.nC("");m6.Id.va.call(this)};g.v(p6,m6);g.k=p6.prototype;g.k.mC=function(a){if(this.l){if(this.l==a)return;o6(this,"Overriding cast session with new session object");rMa(this);this.ma=!1;this.V="unknown";this.l.removeUpdateListener(this.Y);this.l.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.ra)}this.l=a;this.l.addUpdateListener(this.Y);this.l.addMessageListener("urn:x-cast:com.google.youtube.mdx",this.ra);nMa(this,"getMdxSessionStatus")};
g.k.oq=function(a){this.info("launchWithParams no-op for Cast: "+g.xj(a))};
g.k.stop=function(){this.l?this.l.stop((0,g.C)(function(){this.Yf()},this),(0,g.C)(function(){this.Yf(Error("Failed to stop receiver app."))},this)):this.Yf(Error("Stopping cast device without session."))};
g.k.nC=function(){};
g.k.va=function(){this.info("disposeInternal");rMa(this);this.l&&(this.l.removeUpdateListener(this.Y),this.l.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.ra));this.l=null;m6.prototype.va.call(this)};
g.k.fS=function(a,b){if(!this.Ga())if(b)if(b=j5(b),g.Ma(b))switch(a=""+b.type,b=b.data||{},this.info("onYoutubeMessage_: "+a+" "+g.xj(b)),a){case "mdxSessionStatus":lMa(this,b);break;case "loungeToken":oMa(this,b);break;default:o6(this,"Unknown youtube message: "+a)}else o6(this,"Unable to parse message.");else o6(this,"No data in message.")};
g.k.oG=function(a,b,c,d){g.qp(this.L);this.L=0;fMa(this.u,this.i.label,a,this.i.friendlyName,(0,g.C)(function(e){e?b(e):0<=d?(o6(this,"Screen "+a+" appears to be offline. "+d+" retries left."),this.L=g.op((0,g.C)(this.oG,this,a,b,c,d-1),300)):c(Error("Unable to fetch screen."))},this),c)};
g.k.gE=function(){return this.l};
g.k.lM=function(a){this.Ga()||a||(o6(this,"Cast session died."),this.Yf())};g.v(s6,m6);g.k=s6.prototype;g.k.mC=function(a){this.l=a;this.l.addUpdateListener(this.Aa)};
g.k.oq=function(a){this.Ea=a;this.W()};
g.k.stop=function(){yMa(this);this.l?this.l.stop((0,g.C)(this.Yf,this,null),(0,g.C)(this.Yf,this,"Failed to stop DIAL device.")):this.Yf()};
g.k.va=function(){yMa(this);this.l&&this.l.removeUpdateListener(this.Aa);this.l=null;m6.prototype.va.call(this)};
g.k.mM=function(a){this.Ga()||a||(o6(this,"DIAL session died."),this.C(),this.C=g.Ia,this.Yf())};g.v(w6,m6);w6.prototype.stop=function(){this.Yf()};
w6.prototype.mC=function(){};
w6.prototype.oq=function(){g.qp(this.l);this.l=NaN;var a=W4(this.u.Xg(),this.i.label);a?n6(this,a):this.Yf(Error("No such screen"))};
w6.prototype.va=function(){g.qp(this.l);this.l=NaN;m6.prototype.va.call(this)};g.v(x6,g.P);g.k=x6.prototype;
g.k.init=function(a,b){chrome.cast.timeout.requestSession=3E4;var c=new chrome.cast.SessionRequest(this.J);this.L||(c.dialRequest=new chrome.cast.DialRequest("YouTube"));var d=chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;a=a||this.V?chrome.cast.DefaultActionPolicy.CAST_THIS_TAB:chrome.cast.DefaultActionPolicy.CREATE_SESSION;var e=(0,g.C)(this.fR,this);c=new chrome.cast.ApiConfig(c,(0,g.C)(this.rI,this),e,d,a);c.customDialLaunchCallback=(0,g.C)(this.VP,this);chrome.cast.initialize(c,(0,g.C)(function(){this.Ga()||
(chrome.cast.addReceiverActionListener(this.C),ULa(),this.l.subscribe("onlineScreenChange",(0,g.C)(this.hE,this)),this.u=AMa(this),chrome.cast.setCustomReceivers(this.u,g.Ia,(0,g.C)(function(f){this.Jd("Failed to set initial custom receivers: "+g.xj(f))},this)),this.X("ut-remote-cast2-availability-change",z6(this)),b(!0))},this),(0,g.C)(function(f){this.Jd("Failed to initialize API: "+g.xj(f));
b(!1)},this))};
g.k.MS=function(a,b){y6("Setting connected screen ID: "+a+" -> "+b);if(this.i){var c=this.i.getScreen();if(!a||c&&c.id!=a)y6("Unsetting old screen status: "+this.i.i.friendlyName),A6(this,null)}if(a&&b){if(!this.i){c=W4(this.l.Xg(),a);if(!c){y6("setConnectedScreenStatus: Unknown screen.");return}if("shortLived"==c.idType){y6("setConnectedScreenStatus: Screen with id type to be short lived.");return}a=zMa(this,c);a||(y6("setConnectedScreenStatus: Connected receiver not custom..."),a=new chrome.cast.Receiver(c.uuid?
c.uuid:c.id,c.name),a.receiverType=chrome.cast.ReceiverType.CUSTOM,this.u.push(a),chrome.cast.setCustomReceivers(this.u,g.Ia,(0,g.C)(function(d){this.Jd("Failed to set initial custom receivers: "+g.xj(d))},this)));
y6("setConnectedScreenStatus: new active receiver: "+a.friendlyName);A6(this,new w6(this.l,a),!0)}this.i.nC(b)}else y6("setConnectedScreenStatus: no screen.")};
g.k.NS=function(a){this.Ga()?this.Jd("Setting connection data on disposed cast v2"):this.i?this.i.oq(a):this.Jd("Setting connection data without a session")};
g.k.oM=function(){this.Ga()?this.Jd("Stopping session on disposed cast v2"):this.i?(this.i.stop(),A6(this,null)):y6("Stopping non-existing session")};
g.k.requestSession=function(){chrome.cast.requestSession((0,g.C)(this.rI,this),(0,g.C)(this.yR,this))};
g.k.va=function(){this.l.unsubscribe("onlineScreenChange",(0,g.C)(this.hE,this));window.chrome&&chrome.cast&&chrome.cast.removeReceiverActionListener(this.C);var a=RLa,b=g.Ha("ut.mdx.remote.debug.handlers_");g.kb(b||[],a);g.xi(this.i);g.P.prototype.va.call(this)};
g.k.Jd=function(a){W5("Controller",a)};
g.k.tI=function(a,b){this.i==a&&(b||A6(this,null),this.X("ut-remote-cast2-session-change",b))};
g.k.cR=function(a,b){if(!this.Ga())if(a)switch(a.friendlyName=chrome.cast.unescape(a.friendlyName),y6("onReceiverAction_ "+a.label+" / "+a.friendlyName+"-- "+b),b){case chrome.cast.ReceiverAction.CAST:if(this.i)if(this.i.i.label!=a.label)y6("onReceiverAction_: Stopping active receiver: "+this.i.i.friendlyName),this.i.stop();else{y6("onReceiverAction_: Casting to active receiver.");this.i.getScreen()&&this.X("ut-remote-cast2-session-change",this.i.getScreen());break}switch(a.receiverType){case chrome.cast.ReceiverType.CUSTOM:A6(this,
new w6(this.l,a));break;case chrome.cast.ReceiverType.DIAL:A6(this,new s6(this.l,a,this.B,this.config_));break;case chrome.cast.ReceiverType.CAST:A6(this,new p6(this.l,a,this.config_));break;default:this.Jd("Unknown receiver type: "+a.receiverType)}break;case chrome.cast.ReceiverAction.STOP:this.i&&this.i.i.label==a.label?this.i.stop():this.Jd("Stopping receiver w/o session: "+a.friendlyName)}else this.Jd("onReceiverAction_ called without receiver.")};
g.k.VP=function(a){if(this.Ga())return Promise.reject(Error("disposed"));var b=a.receiver;b.receiverType!=chrome.cast.ReceiverType.DIAL&&(this.Jd("Not DIAL receiver: "+b.friendlyName),b.receiverType=chrome.cast.ReceiverType.DIAL);var c=this.i?this.i.i:null;if(!c||c.label!=b.label)return this.Jd("Receiving DIAL launch request for non-clicked DIAL receiver: "+b.friendlyName),Promise.reject(Error("illegal DIAL launch"));if(c&&c.label==b.label&&c.receiverType!=chrome.cast.ReceiverType.DIAL){if(this.i.getScreen())return y6("Reselecting dial screen."),
this.X("ut-remote-cast2-session-change",this.i.getScreen()),Promise.resolve(new chrome.cast.DialLaunchResponse(!1));this.Jd('Changing CAST intent from "'+c.receiverType+'" to "dial" for '+b.friendlyName);A6(this,new s6(this.l,b,this.B,this.config_))}b=this.i;b.L=a;b.L.appState==chrome.cast.DialAppState.RUNNING?(a=b.L.extraData||{},c=a.screenId||null,t6(b)&&a.loungeToken?a.loungeTokenRefreshIntervalMs?a=vMa(b,{name:b.i.friendlyName,screenId:a.screenId,loungeToken:a.loungeToken,dialId:b.L.receiver.label,
screenIdType:"shortLived"},a.loungeTokenRefreshIntervalMs):(g.Uo(Error("No loungeTokenRefreshIntervalMs presents in additionalData: "+JSON.stringify(a)+".")),a=wMa(b,c)):a=wMa(b,c)):a=v6(b);return a};
g.k.rI=function(a){if(!this.Ga()){y6("New cast session ID: "+a.sessionId);var b=a.receiver;if(b.receiverType!=chrome.cast.ReceiverType.CUSTOM){if(!this.i)if(b.receiverType==chrome.cast.ReceiverType.CAST)y6("Got resumed cast session before resumed mdx connection."),b.friendlyName=chrome.cast.unescape(b.friendlyName),A6(this,new p6(this.l,b,this.config_),!0);else{this.Jd("Got non-cast session without previous mdx receiver event, or mdx resume.");return}var c=this.i.i,d=W4(this.l.Xg(),c.label);d&&R4(d,
b.label)&&c.receiverType!=chrome.cast.ReceiverType.CAST&&b.receiverType==chrome.cast.ReceiverType.CAST&&(y6("onSessionEstablished_: manual to cast session change "+b.friendlyName),g.xi(this.i),this.i=new p6(this.l,b,this.config_),this.i.subscribe("sessionScreen",(0,g.C)(this.tI,this,this.i)),this.i.oq(null));this.i.mC(a)}}};
g.k.nM=function(){return this.i?this.i.gE():null};
g.k.yR=function(a){this.Ga()||(this.Jd("Failed to estabilish a session: "+g.xj(a)),a.code!=chrome.cast.ErrorCode.CANCEL&&A6(this,null))};
g.k.fR=function(a){y6("Receiver availability updated: "+a);if(!this.Ga()){var b=z6(this);this.G=a==chrome.cast.ReceiverAvailability.AVAILABLE;z6(this)!=b&&this.X("ut-remote-cast2-availability-change",z6(this))}};
g.k.hE=function(){this.Ga()||(this.u=AMa(this),y6("Updating custom receivers: "+g.xj(this.u)),chrome.cast.setCustomReceivers(this.u,g.Ia,(0,g.C)(function(){this.Jd("Failed to set custom receivers.")},this)),this.X("ut-remote-cast2-availability-change",z6(this)))};
x6.prototype.setLaunchParams=x6.prototype.NS;x6.prototype.setConnectedScreenStatus=x6.prototype.MS;x6.prototype.stopSession=x6.prototype.oM;x6.prototype.getCastSession=x6.prototype.nM;x6.prototype.requestSession=x6.prototype.requestSession;x6.prototype.init=x6.prototype.init;x6.prototype.dispose=x6.prototype.dispose;var G6=[];g.k=L6.prototype;
g.k.reset=function(a){this.listId="";this.index=-1;this.videoId="";M6(this);this.volume=-1;this.muted=!1;a&&(this.index=a.index,this.listId=a.listId,this.videoId=a.videoId,this.playerState=a.playerState,this.volume=a.volume,this.muted=a.muted,this.audioTrackId=a.audioTrackId,this.trackData=a.trackData,this.Dj=a.hasPrevious,this.hasNext=a.hasNext,this.J=a.playerTime,this.G=a.playerTimeAt,this.B=a.seekableStart,this.i=a.seekableEnd,this.C=a.duration,this.L=a.loadedTime,this.u=a.liveIngestionTime,this.l=
!isNaN(this.u))};
g.k.uc=function(){return 1==this.playerState};
g.k.isAdPlaying=function(){return 1081==this.playerState};
g.k.getDuration=function(){return this.l?this.C+N6(this):this.C};
g.k.clone=function(){return new L6(R6(this))};g.v(T6,g.P);g.k=T6.prototype;g.k.getState=function(){return this.eb};
g.k.play=function(){V6(this)?(this.i?this.i.play(null,g.Ia,$6(this,"play")):Z6(this,"play"),Y6(this,1,P6(U6(this))),this.X("remotePlayerChange")):W6(this,this.play)};
g.k.pause=function(){V6(this)?(this.i?this.i.pause(null,g.Ia,$6(this,"pause")):Z6(this,"pause"),Y6(this,2,P6(U6(this))),this.X("remotePlayerChange")):W6(this,this.pause)};
g.k.seekTo=function(a){if(V6(this)){if(this.i){var b=U6(this),c=new chrome.cast.media.SeekRequest;c.currentTime=a;b.uc()||3==b.playerState?c.resumeState=chrome.cast.media.ResumeState.PLAYBACK_START:c.resumeState=chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.i.seek(c,g.Ia,$6(this,"seekTo",{newTime:a}))}else Z6(this,"seekTo",{newTime:a});Y6(this,3,a);this.X("remotePlayerChange")}else W6(this,g.Pa(this.seekTo,a))};
g.k.stop=function(){if(V6(this)){this.i?this.i.stop(null,g.Ia,$6(this,"stopVideo")):Z6(this,"stopVideo");var a=U6(this);a.index=-1;a.videoId="";M6(a);X6(this,a);this.X("remotePlayerChange")}else W6(this,this.stop)};
g.k.setVolume=function(a,b){if(V6(this)){var c=U6(this);if(this.l){if(c.volume!=a){var d=Math.round(a)/100;this.l.setReceiverVolumeLevel(d,(0,g.C)(function(){W5("CP","set receiver volume: "+d)},this),(0,g.C)(function(){this.Jd("failed to set receiver volume.")},this))}c.muted!=b&&this.l.setReceiverMuted(b,(0,g.C)(function(){W5("CP","set receiver muted: "+b)},this),(0,g.C)(function(){this.Jd("failed to set receiver muted.")},this))}else{var e={volume:a,
muted:b};-1!=c.volume&&(e.delta=a-c.volume);Z6(this,"setVolume",e)}c.muted=b;c.volume=a;X6(this,c)}else W6(this,g.Pa(this.setVolume,a,b))};
g.k.iE=function(a,b){if(V6(this)){var c=U6(this);a={videoId:a};b&&(c.trackData={trackName:b.name,languageCode:b.languageCode,sourceLanguageCode:b.translationLanguage?b.translationLanguage.languageCode:"",languageName:b.languageName,kind:b.kind},a.style=g.xj(b.style),g.Vb(a,c.trackData));Z6(this,"setSubtitlesTrack",a);X6(this,c)}else W6(this,g.Pa(this.iE,a,b))};
g.k.setAudioTrack=function(a,b){V6(this)?(b=b.getLanguageInfo().getId(),Z6(this,"setAudioTrack",{videoId:a,audioTrackId:b}),a=U6(this),a.audioTrackId=b,X6(this,a)):W6(this,g.Pa(this.setAudioTrack,a,b))};
g.k.playVideo=function(a,b,c,d,e,f,h){var l=U6(this);c=c||0;var m={videoId:a,currentIndex:c};Q6(l,a,c);void 0!==b&&(O6(l,b),m.currentTime=b);void 0!==d&&(m.listId=d);null!=e&&(m.playerParams=e);null!=f&&(m.clickTrackingParams=f);null!=h&&(m.locationInfo=g.xj(h));Z6(this,"setPlaylist",m);d||X6(this,l)};
g.k.Xw=function(a,b){if(V6(this)){if(a&&b){var c=U6(this);Q6(c,a,b);X6(this,c)}Z6(this,"previous")}else W6(this,g.Pa(this.Xw,a,b))};
g.k.nextVideo=function(a,b){if(V6(this)){if(a&&b){var c=U6(this);Q6(c,a,b);X6(this,c)}Z6(this,"next")}else W6(this,g.Pa(this.nextVideo,a,b))};
g.k.LF=function(){V6(this)?Z6(this,"dismissAutoplay"):W6(this,this.LF)};
g.k.dispose=function(){if(3!=this.eb){var a=this.eb;this.eb=3;this.X("proxyStateChange",a,this.eb)}g.P.prototype.dispose.call(this)};
g.k.va=function(){MMa(this);this.u=null;this.B.clear();S6(this,null);g.P.prototype.va.call(this)};
g.k.pC=function(a){if((a!=this.eb||2==a)&&3!=this.eb&&0!=a){var b=this.eb;this.eb=a;this.X("proxyStateChange",b,a);if(1==a)for(;!this.B.isEmpty();)b=a=this.B,g.gb(b.i)&&(b.i=b.l,b.i.reverse(),b.l=[]),a.i.pop().apply(this);else 3==a&&this.dispose()}};
g.k.ZQ=function(a,b){this.X(a,b)};
g.k.HP=function(a){if(!a)this.ot(null),S6(this,null);else if(this.l.receiver.volume){a=this.l.receiver.volume;var b=U6(this),c=Math.round(100*a.level||0);if(b.volume!=c||b.muted!=a.muted)W5("CP","Cast volume update: "+a.level+(a.muted?" muted":"")),b.volume=c,b.muted=!!a.muted,X6(this,b)}};
g.k.ot=function(a){W5("CP","Cast media: "+!!a);this.i&&this.i.removeUpdateListener(this.J);if(this.i=a)this.i.addUpdateListener(this.J),NMa(this),this.X("remotePlayerChange")};
g.k.GP=function(a){a?(NMa(this),this.X("remotePlayerChange")):this.ot(null)};
g.k.GC=function(){Z6(this,"sendDebugCommand",{debugCommand:"stats4nerds "})};
g.k.OP=function(){var a=JMa();a&&S6(this,a)};
g.k.Jd=function(a){W5("CP",a)};g.v(a7,g.P);g.k=a7.prototype;
g.k.connect=function(a,b){if(b){var c=b.listId,d=b.videoId,e=b.playerParams,f=b.clickTrackingParams,h=b.index,l={videoId:d},m=b.currentTime;b=b.locationInfo;void 0!==m&&(l.currentTime=5>=m?0:m);e&&(l.playerParams=e);b&&(l.locationInfo=b);f&&(l.clickTrackingParams=f);c&&(l.listId=c);void 0!==h&&(l.currentIndex=h);c&&(this.fc.listId=c);this.fc.videoId=d;this.fc.index=h||0;this.fc.state=3;O6(this.fc,m);this.B="UNSUPPORTED";b7("Connecting with setPlaylist and params: "+g.xj(l));this.i.connect({method:"setPlaylist",
params:g.xj(l)},a,MKa())}else b7("Connecting without params"),this.i.connect({},a,MKa());PMa(this)};
g.k.qx=function(a){this.i.qx(a)};
g.k.dispose=function(){this.Ga()||(this.X("beforeDispose"),c7(this,3));g.P.prototype.dispose.call(this)};
g.k.va=function(){d7(this);f7(this);e7(this);g.qp(this.J);this.J=NaN;g.qp(this.L);this.L=NaN;this.u=null;g.Vp(this.V);this.V.length=0;this.i.dispose();g.P.prototype.va.call(this);this.B=this.G=this.l=this.fc=this.i=null};
g.k.RN=function(){this.Sp(2)};
g.k.LP=function(){b7("Channel opened");this.ma&&(this.ma=!1,e7(this),this.Y=g.op((0,g.C)(function(){b7("Timing out waiting for a screen.");this.Sp(1)},this),15E3));
QKa(PLa(this.i),this.Aa)};
g.k.IP=function(){b7("Channel closed");isNaN(this.C)?a5(!0):a5();this.dispose()};
g.k.JP=function(a,b){a5();isNaN(this.Es())?(b&&"shortLived"==this.ra&&this.X("browserChannelAuthError",a),b7("Channel error: "+a+" without reconnection"),this.dispose()):(this.ma=!0,b7("Channel error: "+a+" with reconnection in "+this.Es()+" ms"),c7(this,2))};
g.k.KP=function(a){a.params?b7("Received: action="+a.action+", params="+g.xj(a.params)):b7("Received: action="+a.action+" {}");switch(a.action){case "loungeStatus":a=j5(a.params.devices);this.l=g.Mc(a,function(c){return new P4(c)});
a=!!g.cb(this.l,function(c){return"LOUNGE_SCREEN"==c.type});
SMa(this,a);break;case "loungeScreenDisconnected":g.lb(this.l,function(c){return"LOUNGE_SCREEN"==c.type});
SMa(this,!1);break;case "remoteConnected":var b=new P4(j5(a.params.device));g.cb(this.l,function(c){return b?c.id==b.id:!1})||wKa(this.l,b);
break;case "remoteDisconnected":b=new P4(j5(a.params.device));g.lb(this.l,function(c){return b?c.id==b.id:!1});
break;case "gracefulDisconnect":break;case "playlistModified":UMa(this,a);break;case "nowPlaying":WMa(this,a);break;case "onStateChange":VMa(this,a);break;case "onAdStateChange":XMa(this,a);break;case "onVolumeChanged":YMa(this,a);break;case "onSubtitlesTrackChanged":TMa(this,a);break;case "nowAutoplaying":ZMa(this,a);break;case "autoplayDismissed":this.X("autoplayDismissed");break;case "autoplayUpNext":this.G=a.params.videoId||null;this.X("autoplayUpNext",this.G);break;case "onAutoplayModeChanged":this.B=
a.params.autoplayMode;this.X("autoplayModeChange",this.B);"DISABLED"==this.B&&this.X("autoplayDismissed");break;case "onHasPreviousNextChanged":$Ma(this,a);break;case "requestAssistedSignIn":this.X("assistedSignInRequested",a.params.authCode);break;default:b7("Unrecognized action: "+a.action)}};
g.k.CS=function(){if(this.u){var a=this.u;this.u=null;this.fc.videoId!=a&&g7(this,"getNowPlaying")}};
g.k.MN=function(){var a=3;this.Ga()||(a=0,isNaN(this.Es())?R5(this.i)&&isNaN(this.C)&&(a=1):a=2);return a};
g.k.Sp=function(a){b7("Disconnecting with "+a);d7(this);this.X("beforeDisconnect",a);1==a&&a5();QLa(this.i,a);this.dispose()};
g.k.KN=function(){var a=this.fc;this.u&&(a=this.fc.clone(),Q6(a,this.u,a.index));return R6(a)};
g.k.OS=function(a){var b=new L6(a);b.videoId&&b.videoId!=this.fc.videoId&&(this.u=b.videoId,g.qp(this.J),this.J=g.op((0,g.C)(this.CS,this),5E3));var c=[];this.fc.listId==b.listId&&this.fc.videoId==b.videoId&&this.fc.index==b.index||c.push("remoteQueueChange");this.fc.playerState==b.playerState&&this.fc.volume==b.volume&&this.fc.muted==b.muted&&P6(this.fc)==P6(b)&&g.xj(this.fc.trackData)==g.xj(b.trackData)||c.push("remotePlayerChange");this.fc.reset(a);g.zb(c,function(d){this.X(d)},this)};
g.k.mG=function(){var a=this.i.G.id,b=g.cb(this.l,function(c){return"REMOTE_CONTROL"==c.type&&c.id!=a});
return b?b.id:""};
g.k.Es=function(){var a=this.i;return a.l.isActive()?a.l.l-g.Ra():NaN};
g.k.IN=function(){return this.B||"UNSUPPORTED"};
g.k.JN=function(){return this.G||""};
g.k.pM=function(){if(!isNaN(this.Es())){var a=this.i.l;g.pn(a.i);a.start()}};
g.k.LS=function(a,b){g7(this,a,b);RMa(this)};
g.k.jE=function(){var a=g.Fo("SID","")||"",b=g.Fo("SAPISID","")||"",c=g.Fo("__Secure-3PAPISID","")||"";if(!a&&!b&&!c)return"";a=g.uf(g.Xe(a),2);b=g.uf(g.Xe(b),2);c=g.uf(g.Xe(c),2);return g.uf(g.Xe(a+","+b+","+c),2)};
a7.prototype.subscribe=a7.prototype.subscribe;a7.prototype.unsubscribeByKey=a7.prototype.If;a7.prototype.getProxyState=a7.prototype.MN;a7.prototype.disconnect=a7.prototype.Sp;a7.prototype.getPlayerContextData=a7.prototype.KN;a7.prototype.setPlayerContextData=a7.prototype.OS;a7.prototype.getOtherConnectedRemoteId=a7.prototype.mG;a7.prototype.getReconnectTimeout=a7.prototype.Es;a7.prototype.getAutoplayMode=a7.prototype.IN;a7.prototype.getAutoplayVideoId=a7.prototype.JN;a7.prototype.reconnect=a7.prototype.pM;
a7.prototype.sendMessage=a7.prototype.LS;a7.prototype.getXsrfToken=a7.prototype.jE;g.v(h7,$5);g.k=h7.prototype;g.k.Xg=function(a){return this.Bf.$_gs(a)};
g.k.contains=function(a){return!!this.Bf.$_c(a)};
g.k.get=function(a){return this.Bf.$_g(a)};
g.k.start=function(){this.Bf.$_st()};
g.k.add=function(a,b,c){this.Bf.$_a(a,b,c)};
g.k.remove=function(a,b,c){this.Bf.$_r(a,b,c)};
g.k.Mx=function(a,b,c,d){this.Bf.$_un(a,b,c,d)};
g.k.va=function(){for(var a=0,b=this.i.length;a<b;++a)this.Bf.$_ubk(this.i[a]);this.i.length=0;this.Bf=null;$5.prototype.va.call(this)};
g.k.qM=function(){this.X("screenChange")};
g.k.GQ=function(){this.X("onlineScreenChange")};
j6.prototype.$_st=j6.prototype.start;j6.prototype.$_gspc=j6.prototype.kM;j6.prototype.$_gsppc=j6.prototype.fE;j6.prototype.$_c=j6.prototype.contains;j6.prototype.$_g=j6.prototype.get;j6.prototype.$_a=j6.prototype.add;j6.prototype.$_un=j6.prototype.Mx;j6.prototype.$_r=j6.prototype.remove;j6.prototype.$_gs=j6.prototype.Xg;j6.prototype.$_gos=j6.prototype.eE;j6.prototype.$_s=j6.prototype.subscribe;j6.prototype.$_ubk=j6.prototype.If;var u7=null,A7=!1,i7=null,j7=null,z7=null,n7=[];g.v(B7,g.F);g.k=B7.prototype;g.k.va=function(){g.F.prototype.va.call(this);this.i.stop();this.u.stop();this.L.stop();this.Y();var a=this.Ob;a.unsubscribe("proxyStateChange",this.pI,this);a.unsubscribe("remotePlayerChange",this.xt,this);a.unsubscribe("remoteQueueChange",this.Uw,this);a.unsubscribe("previousNextChange",this.mI,this);a.unsubscribe("nowAutoplaying",this.gI,this);a.unsubscribe("autoplayDismissed",this.HH,this);this.Ob=this.l=null};
g.k.kE=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];if(2!=this.Ob.eb)if(C7(this)){if(!U6(this.Ob).isAdPlaying()||"control_seek"!==a)switch(a){case "control_toggle_play_pause":U6(this.Ob).uc()?this.Ob.pause():this.Ob.play();break;case "control_play":this.Ob.play();break;case "control_pause":this.Ob.pause();break;case "control_seek":this.J.bE(c[0],c[1]);break;case "control_subtitles_set_track":D7(this,c[0]);break;case "control_set_audio_track":this.setAudioTrack(c[0])}}else switch(a){case "control_toggle_play_pause":case "control_play":case "control_pause":c=
this.I.getCurrentTime();E7(this,0===c?void 0:c);break;case "control_seek":E7(this,c[0]);break;case "control_subtitles_set_track":D7(this,c[0]);break;case "control_set_audio_track":this.setAudioTrack(c[0])}};
g.k.EP=function(a){this.L.fM(a)};
g.k.tT=function(a){this.kE("control_subtitles_set_track",g.Ob(a)?null:a)};
g.k.xJ=function(){var a=this.I.getOption("captions","track");g.Ob(a)||D7(this,a)};
g.k.Tb=function(a){this.l.Tb(a,this.I.getVideoData().lengthSeconds)};
g.k.rQ=function(){g.Ob(this.B)||kNa(this,this.B);this.C=!1};
g.k.pI=function(a,b){this.u.stop();2===b&&this.rJ()};
g.k.xt=function(){if(C7(this)){this.i.stop();var a=U6(this.Ob);switch(a.playerState){case 1080:case 1081:case 1084:case 1085:this.l.Qe=1;break;case 1082:case 1083:this.l.Qe=0;break;default:this.l.Qe=-1}switch(a.playerState){case 1081:case 1:this.Lb(new g.SI(8));this.qJ();break;case 1085:case 3:this.Lb(new g.SI(9));break;case 1083:case 0:this.Lb(new g.SI(2));this.J.stop();this.Tb(this.I.getVideoData().lengthSeconds);break;case 1084:this.Lb(new g.SI(4));break;case 2:this.Lb(new g.SI(4));this.Tb(P6(a));
break;case -1:this.Lb(new g.SI(64));break;case -1E3:this.Lb(new g.SI(128,{errorCode:"mdx.remoteerror",errorMessage:"This video is not available for remote playback."}))}a=U6(this.Ob).trackData;var b=this.B;(a||b?a&&b&&a.trackName==b.trackName&&a.languageCode==b.languageCode&&a.languageName==b.languageName&&a.kind==b.kind:1)||(this.B=a,kNa(this,a));a=U6(this.Ob);-1===a.volume||Math.round(this.I.getVolume())===a.volume&&this.I.isMuted()===a.muted||this.V.isActive()||this.XJ()}else jNa(this)};
g.k.mI=function(){this.I.X("mdxpreviousnextchange")};
g.k.Uw=function(){C7(this)||jNa(this)};
g.k.gI=function(a){isNaN(a)||this.I.X("mdxnowautoplaying",a)};
g.k.HH=function(){this.I.X("mdxautoplaycanceled")};
g.k.setAudioTrack=function(a){C7(this)&&this.Ob.setAudioTrack(this.I.getVideoData(1).videoId,a)};
g.k.seekTo=function(a,b){-1===U6(this.Ob).playerState?E7(this,a):b&&this.Ob.seekTo(a)};
g.k.XJ=function(){var a=this;if(C7(this)){var b=U6(this.Ob);this.events.hc(this.W);b.muted?this.I.mute():this.I.unMute();this.I.setVolume(b.volume);this.W=this.events.N(this.I,"onVolumeChange",function(c){iNa(a,c)})}};
g.k.qJ=function(){this.i.stop();if(!this.Ob.Ga()){var a=U6(this.Ob);a.uc()&&this.Lb(new g.SI(8));this.Tb(P6(a));this.i.start()}};
g.k.rJ=function(){this.u.stop();this.i.stop();var a=this.Ob.u.getReconnectTimeout();2==this.Ob.eb&&!isNaN(a)&&this.u.start()};
g.k.Lb=function(a){this.u.stop();var b=this.G;if(!g.XI(b,a)){var c=g.T(a,2);c!==g.T(this.G,2)&&this.I.To(c);this.G=a;mNa(this.l,b,a)}};g.v(F7,g.V);F7.prototype.Vc=function(){this.i.show()};
F7.prototype.Ab=function(){this.i.hide()};
F7.prototype.l=function(){g.zI("https://support.google.com/youtube/answer/7640706")};
F7.prototype.u=function(){O4("mdx-manual-pairing-popup-ok");this.Ab()};g.v(G7,g.V);G7.prototype.Vc=function(){this.i.show()};
G7.prototype.Ab=function(){this.i.hide()};
G7.prototype.l=function(){O4("mdx-privacy-popup-cancel");this.Ab()};
G7.prototype.u=function(){O4("mdx-privacy-popup-confirm");this.Ab()};g.v(H7,g.V);H7.prototype.l=function(a){lNa(this,a.state)};g.v(I7,g.UO);I7.prototype.C=function(){var a=this.I.getOption("remote","receivers");a&&1<a.length&&!this.I.getOption("remote","quickCast")?(this.Dm=g.Ab(a,this.i,this),g.VO(this,g.Mc(a,this.i)),a=this.I.getOption("remote","currentReceiver"),a=this.i(a),this.options[a]&&this.nh(a),this.enable(!0)):this.enable(!1)};
I7.prototype.i=function(a){return a.key};
I7.prototype.Xh=function(a){return"cast-selector-receiver"===a?"Cast...":this.Dm[a].name};
I7.prototype.We=function(a){g.UO.prototype.We.call(this,a);this.I.setOption("remote","currentReceiver",this.Dm[a]);this.wb.Ab()};g.v(J7,g.dM);g.k=J7.prototype;
g.k.create=function(){var a=this.player.T(),b=g.AD(a);a={device:"Desktop",app:"youtube-desktop",loadCastApiSetupScript:g.R(a.experiments,"mdx_load_cast_api_bootstrap_script"),enableDialLoungeToken:g.R(a.experiments,"enable_dial_short_lived_lounge_token"),enableCastLoungeToken:g.R(a.experiments,"enable_cast_short_lived_lounge_token")};dNa(b,a);this.subscriptions.push(g.Tq("ut-remote-before-disconnect",this.DP,this));this.subscriptions.push(g.Tq("ut-remote-connection-change",this.gR,this));this.subscriptions.push(g.Tq("ut-remote-receiver-availability-change",
this.oI,this));this.subscriptions.push(g.Tq("ut-remote-auto-connect",this.eR,this));this.subscriptions.push(g.Tq("ut-remote-receiver-resumed",this.dR,this));this.subscriptions.push(g.Tq("mdx-privacy-popup-confirm",this.tS,this));this.subscriptions.push(g.Tq("mdx-privacy-popup-cancel",this.sS,this));this.subscriptions.push(g.Tq("mdx-manual-pairing-popup-ok",this.NO,this));this.oI()};
g.k.load=function(){this.player.cancelPlayback();g.dM.prototype.load.call(this);this.qh=new B7(this,this.player,this.Ob);var a=(a=hNa())?a.currentTime:0;var b=y7()?new T6(s7(),void 0):null;0==a&&b&&(a=P6(U6(b)));0!==a&&this.Tb(a);mNa(this,this.dd,this.dd);this.player.Xj(6)};
g.k.unload=function(){this.player.X("mdxautoplaycanceled");this.Kl=this.ri;g.yi(this.qh,this.Ob);this.Ob=this.qh=null;g.dM.prototype.unload.call(this);this.player.Xj(5);K7(this)};
g.k.va=function(){g.Uq(this.subscriptions);g.dM.prototype.va.call(this)};
g.k.Nj=function(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];this.loaded&&this.qh.kE.apply(this.qh,[a].concat(g.ma(c)))};
g.k.getAdState=function(){return this.Qe};
g.k.NN=function(){return this.loaded?this.qh.suggestion:null};
g.k.Dj=function(){return this.Ob?U6(this.Ob).Dj:!1};
g.k.hasNext=function(){return this.Ob?U6(this.Ob).hasNext:!1};
g.k.Tb=function(a,b){this.dH=a||0;this.player.X("progresssync",a,b);this.player.La("onVideoProgress",a)};
g.k.getCurrentTime=function(){return this.dH};
g.k.getProgressState=function(){var a=U6(this.Ob),b=this.player.getVideoData();return{allowSeeking:g.R(this.player.T().experiments,"web_player_mdx_allow_seeking_change_killswitch")?this.player.Pe():!a.isAdPlaying()&&this.player.Pe(),clipEnd:b.clipEnd,clipStart:b.clipStart,current:this.getCurrentTime(),displayedStart:-1,duration:a.getDuration(),ingestionTime:a.l?a.u+N6(a):a.u,isAtLiveHead:1>=(a.l?a.i+N6(a):a.i)-this.getCurrentTime(),loaded:a.L,seekableEnd:a.l?a.i+N6(a):a.i,seekableStart:0<a.B?a.B+
N6(a):a.B}};
g.k.nextVideo=function(){this.Ob&&this.Ob.nextVideo()};
g.k.Xw=function(){this.Ob&&this.Ob.Xw()};
g.k.DP=function(a){1===a&&(this.QB=this.Ob?U6(this.Ob):null)};
g.k.gR=function(){var a=y7()?new T6(s7(),void 0):null;if(a){var b=this.Kl;this.loaded&&this.unload();this.Ob=a;this.QB=null;b.key!==this.ri.key&&(this.Kl=b,this.load())}else g.xi(this.Ob),this.Ob=null,this.loaded&&(this.unload(),(a=this.QB)&&a.videoId===this.player.getVideoData().videoId&&this.player.cueVideoById(a.videoId,P6(a)));this.player.X("videodatachange","newdata",this.player.getVideoData(),3)};
g.k.oI=function(){var a=[this.ri],b=a.concat,c=eNa();H6()&&g.lv("ut-remote-cast-available")&&c.push({key:"cast-selector-receiver",name:"Cast..."});this.Dm=b.call(a,c);a=t7()||this.ri;L7(this,a);this.player.La("onMdxReceiversChange")};
g.k.eR=function(){var a=t7();L7(this,a)};
g.k.dR=function(){this.Kl=t7()};
g.k.tS=function(){this.Ct=!0;K7(this);A7=!1;u7&&w7(u7,1);u7=null};
g.k.sS=function(){this.Ct=!1;K7(this);L7(this,this.ri);this.Kl=this.ri;A7=!1;u7=null;this.player.playVideo()};
g.k.NO=function(){this.ww=!0;K7(this);g.kv("ut-remote-manual-pairing-warning-shown",!0,2592E3);A7=!1;u7&&w7(u7,1);u7=null};
g.k.Je=function(a,b){switch(a){case "casting":return this.loaded;case "receivers":return this.Dm;case "currentReceiver":return b&&("cast-selector-receiver"===b.key?J6():L7(this,b)),this.loaded?this.Kl:this.ri;case "quickCast":return 2===this.Dm.length&&"cast-selector-receiver"===this.Dm[1].key?(b&&J6(),!0):!1}};
g.k.GC=function(){this.Ob.GC()};
g.k.Qh=function(){return!1};
g.k.getOptions=function(){return["casting","receivers","currentReceiver","quickCast"]};g.oM.remote=J7;})(_ut_player);