· 6 years ago · Oct 11, 2019, 04:34 AM
1! function(e) {
2 function t(i) {
3 if (n[i]) return n[i].exports;
4 var s = n[i] = {
5 i: i,
6 l: !1,
7 exports: {}
8 };
9 return e[i].call(s.exports, s, s.exports, t), s.l = !0, s.exports
10 }
11 var n = {};
12 t.m = e, t.c = n, t.d = function(e, n, i) {
13 t.o(e, n) || Object.defineProperty(e, n, {
14 configurable: !1,
15 enumerable: !0,
16 get: i
17 })
18 }, t.n = function(e) {
19 var n = e && e.__esModule ? function() {
20 return e.default
21 } : function() {
22 return e
23 };
24 return t.d(n, "a", n), n
25 }, t.o = function(e, t) {
26 return Object.prototype.hasOwnProperty.call(e, t)
27 }, t.p = "", t(t.s = 12)
28}([function(e, t, n) {
29 "use strict";
30 Object.defineProperty(t, "__esModule", {
31 value: !0
32 }), t.ExtensionEventActions = void 0;
33 var i = n(13);
34 Object.keys(i).forEach(function(e) {
35 "default" !== e && "__esModule" !== e && Object.defineProperty(t, e, {
36 enumerable: !0,
37 get: function() {
38 return i[e]
39 }
40 })
41 });
42 var s = n(14);
43 Object.keys(s).forEach(function(e) {
44 "default" !== e && "__esModule" !== e && Object.defineProperty(t, e, {
45 enumerable: !0,
46 get: function() {
47 return s[e]
48 }
49 })
50 });
51 var r = n(15);
52 Object.keys(r).forEach(function(e) {
53 "default" !== e && "__esModule" !== e && Object.defineProperty(t, e, {
54 enumerable: !0,
55 get: function() {
56 return r[e]
57 }
58 })
59 });
60 var o = n(16);
61 Object.keys(o).forEach(function(e) {
62 "default" !== e && "__esModule" !== e && Object.defineProperty(t, e, {
63 enumerable: !0,
64 get: function() {
65 return o[e]
66 }
67 })
68 });
69 var a = n(17);
70 Object.keys(a).forEach(function(e) {
71 "default" !== e && "__esModule" !== e && Object.defineProperty(t, e, {
72 enumerable: !0,
73 get: function() {
74 return a[e]
75 }
76 })
77 });
78 var c = n(18);
79 Object.keys(c).forEach(function(e) {
80 "default" !== e && "__esModule" !== e && Object.defineProperty(t, e, {
81 enumerable: !0,
82 get: function() {
83 return c[e]
84 }
85 })
86 });
87 t.ExtensionEventActions = [s.SupervisorAction.SupervisorReady, i.ExtensionAction.TwitchExtLoaded, i.ExtensionAction.TwitchExtLongtask, i.ExtensionAction.TwitchExtUserAction, i.ExtensionAction.TwitchExtNetworkTiming, i.ExtensionAction.TwitchExtBeginPurchase, i.ExtensionAction.TwitchExtBitsOnHover, i.ExtensionAction.TwitchExtUseBits, i.ExtensionAction.TwitchExtPubSubReceived, i.ExtensionAction.TwitchExtPubsubListen, i.ExtensionAction.TwitchExtPubsubUnlisten, r.FunctionAction.FollowAction, r.FunctionAction.FollowStatusRequest, r.FunctionAction.IdShareRequest, r.FunctionAction.TwitchExtMinimize, r.FunctionAction.UseBits, r.FunctionAction.SubscribeToChannel]
88}, function(e, t, n) {
89 "use strict";
90 (function(i) {
91 var s, r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
92 return typeof e
93 } : function(e) {
94 return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
95 };
96 ! function(o) {
97 function a() {
98 this._events = {}, this._conf && c.call(this, this._conf)
99 }
100
101 function c(e) {
102 e ? (this._conf = e, e.delimiter && (this.delimiter = e.delimiter), this._maxListeners = e.maxListeners !== o ? e.maxListeners : p, e.wildcard && (this.wildcard = e.wildcard), e.newListener && (this._newListener = e.newListener), e.removeListener && (this._removeListener = e.removeListener), e.verboseMemoryLeak && (this.verboseMemoryLeak = e.verboseMemoryLeak), this.wildcard && (this.listenerTree = {})) : this._maxListeners = p
103 }
104
105 function u(e, t) {
106 var n = "(node) warning: possible EventEmitter memory leak detected. " + e + " listeners added. Use emitter.setMaxListeners() to increase limit.";
107 if (this.verboseMemoryLeak && (n += " Event name: " + t + "."), void 0 !== i && i.emitWarning) {
108 var s = new Error(n);
109 s.name = "MaxListenersExceededWarning", s.emitter = this, s.count = e, i.emitWarning(s)
110 } else console.error(n), console.trace && console.trace()
111 }
112
113 function l(e) {
114 this._events = {}, this._newListener = !1, this._removeListener = !1, this.verboseMemoryLeak = !1, c.call(this, e)
115 }
116
117 function h(e, t, n, i) {
118 if (!n) return [];
119 var s, r, o, a, c, u, l, f = [],
120 d = t.length,
121 p = t[i],
122 _ = t[i + 1];
123 if (i === d && n._listeners) {
124 if ("function" == typeof n._listeners) return e && e.push(n._listeners), [n];
125 for (s = 0, r = n._listeners.length; s < r; s++) e && e.push(n._listeners[s]);
126 return [n]
127 }
128 if ("*" === p || "**" === p || n[p]) {
129 if ("*" === p) {
130 for (o in n) "_listeners" !== o && n.hasOwnProperty(o) && (f = f.concat(h(e, t, n[o], i + 1)));
131 return f
132 }
133 if ("**" === p) {
134 l = i + 1 === d || i + 2 === d && "*" === _, l && n._listeners && (f = f.concat(h(e, t, n, d)));
135 for (o in n) "_listeners" !== o && n.hasOwnProperty(o) && ("*" === o || "**" === o ? (n[o]._listeners && !l && (f = f.concat(h(e, t, n[o], d))), f = f.concat(h(e, t, n[o], i))) : f = o === _ ? f.concat(h(e, t, n[o], i + 2)) : f.concat(h(e, t, n[o], i)));
136 return f
137 }
138 f = f.concat(h(e, t, n[p], i + 1))
139 }
140 if (a = n["*"], a && h(e, t, a, i + 1), c = n["**"])
141 if (i < d) {
142 c._listeners && h(e, t, c, d);
143 for (o in c) "_listeners" !== o && c.hasOwnProperty(o) && (o === _ ? h(e, t, c[o], i + 2) : o === p ? h(e, t, c[o], i + 1) : (u = {}, u[o] = c[o], h(e, t, {
144 "**": u
145 }, i + 1)))
146 } else c._listeners ? h(e, t, c, d) : c["*"] && c["*"]._listeners && h(e, t, c["*"], d);
147 return f
148 }
149
150 function f(e, t) {
151 e = "string" == typeof e ? e.split(this.delimiter) : e.slice();
152 for (var n = 0, i = e.length; n + 1 < i; n++)
153 if ("**" === e[n] && "**" === e[n + 1]) return;
154 for (var s = this.listenerTree, r = e.shift(); r !== o;) {
155 if (s[r] || (s[r] = {}), s = s[r], 0 === e.length) return s._listeners ? ("function" == typeof s._listeners && (s._listeners = [s._listeners]), s._listeners.push(t), !s._listeners.warned && this._maxListeners > 0 && s._listeners.length > this._maxListeners && (s._listeners.warned = !0, u.call(this, s._listeners.length, r))) : s._listeners = t, !0;
156 r = e.shift()
157 }
158 return !0
159 }
160 var d = Array.isArray ? Array.isArray : function(e) {
161 return "[object Array]" === Object.prototype.toString.call(e)
162 },
163 p = 10;
164 l.EventEmitter2 = l, l.prototype.delimiter = ".", l.prototype.setMaxListeners = function(e) {
165 e !== o && (this._maxListeners = e, this._conf || (this._conf = {}), this._conf.maxListeners = e)
166 }, l.prototype.event = "", l.prototype.once = function(e, t) {
167 return this._once(e, t, !1)
168 }, l.prototype.prependOnceListener = function(e, t) {
169 return this._once(e, t, !0)
170 }, l.prototype._once = function(e, t, n) {
171 return this._many(e, 1, t, n), this
172 }, l.prototype.many = function(e, t, n) {
173 return this._many(e, t, n, !1)
174 }, l.prototype.prependMany = function(e, t, n) {
175 return this._many(e, t, n, !0)
176 }, l.prototype._many = function(e, t, n, i) {
177 function s() {
178 return 0 == --t && r.off(e, s), n.apply(this, arguments)
179 }
180 var r = this;
181 if ("function" != typeof n) throw new Error("many only accepts instances of Function");
182 return s._origin = n, this._on(e, s, i), r
183 }, l.prototype.emit = function() {
184 this._events || a.call(this);
185 var e = arguments[0];
186 if ("newListener" === e && !this._newListener && !this._events.newListener) return !1;
187 var t, n, i, s, r, o = arguments.length;
188 if (this._all && this._all.length) {
189 if (r = this._all.slice(), o > 3)
190 for (t = new Array(o), s = 0; s < o; s++) t[s] = arguments[s];
191 for (i = 0, n = r.length; i < n; i++) switch (this.event = e, o) {
192 case 1:
193 r[i].call(this, e);
194 break;
195 case 2:
196 r[i].call(this, e, arguments[1]);
197 break;
198 case 3:
199 r[i].call(this, e, arguments[1], arguments[2]);
200 break;
201 default:
202 r[i].apply(this, t)
203 }
204 }
205 if (this.wildcard) {
206 r = [];
207 var c = "string" == typeof e ? e.split(this.delimiter) : e.slice();
208 h.call(this, r, c, this.listenerTree, 0)
209 } else {
210 if ("function" == typeof(r = this._events[e])) {
211 switch (this.event = e, o) {
212 case 1:
213 r.call(this);
214 break;
215 case 2:
216 r.call(this, arguments[1]);
217 break;
218 case 3:
219 r.call(this, arguments[1], arguments[2]);
220 break;
221 default:
222 for (t = new Array(o - 1), s = 1; s < o; s++) t[s - 1] = arguments[s];
223 r.apply(this, t)
224 }
225 return !0
226 }
227 r && (r = r.slice())
228 }
229 if (r && r.length) {
230 if (o > 3)
231 for (t = new Array(o - 1), s = 1; s < o; s++) t[s - 1] = arguments[s];
232 for (i = 0, n = r.length; i < n; i++) switch (this.event = e, o) {
233 case 1:
234 r[i].call(this);
235 break;
236 case 2:
237 r[i].call(this, arguments[1]);
238 break;
239 case 3:
240 r[i].call(this, arguments[1], arguments[2]);
241 break;
242 default:
243 r[i].apply(this, t)
244 }
245 return !0
246 }
247 if (!this._all && "error" === e) throw arguments[1] instanceof Error ? arguments[1] : new Error("Uncaught, unspecified 'error' event.");
248 return !!this._all
249 }, l.prototype.emitAsync = function() {
250 this._events || a.call(this);
251 var e = arguments[0];
252 if ("newListener" === e && !this._newListener && !this._events.newListener) return Promise.resolve([!1]);
253 var t, n, i, s, r, o = [],
254 c = arguments.length;
255 if (this._all) {
256 if (c > 3)
257 for (t = new Array(c), s = 1; s < c; s++) t[s] = arguments[s];
258 for (i = 0, n = this._all.length; i < n; i++) switch (this.event = e, c) {
259 case 1:
260 o.push(this._all[i].call(this, e));
261 break;
262 case 2:
263 o.push(this._all[i].call(this, e, arguments[1]));
264 break;
265 case 3:
266 o.push(this._all[i].call(this, e, arguments[1], arguments[2]));
267 break;
268 default:
269 o.push(this._all[i].apply(this, t))
270 }
271 }
272 if (this.wildcard) {
273 r = [];
274 var u = "string" == typeof e ? e.split(this.delimiter) : e.slice();
275 h.call(this, r, u, this.listenerTree, 0)
276 } else r = this._events[e];
277 if ("function" == typeof r) switch (this.event = e, c) {
278 case 1:
279 o.push(r.call(this));
280 break;
281 case 2:
282 o.push(r.call(this, arguments[1]));
283 break;
284 case 3:
285 o.push(r.call(this, arguments[1], arguments[2]));
286 break;
287 default:
288 for (t = new Array(c - 1), s = 1; s < c; s++) t[s - 1] = arguments[s];
289 o.push(r.apply(this, t))
290 } else if (r && r.length) {
291 if (r = r.slice(), c > 3)
292 for (t = new Array(c - 1), s = 1; s < c; s++) t[s - 1] = arguments[s];
293 for (i = 0, n = r.length; i < n; i++) switch (this.event = e, c) {
294 case 1:
295 o.push(r[i].call(this));
296 break;
297 case 2:
298 o.push(r[i].call(this, arguments[1]));
299 break;
300 case 3:
301 o.push(r[i].call(this, arguments[1], arguments[2]));
302 break;
303 default:
304 o.push(r[i].apply(this, t))
305 }
306 } else if (!this._all && "error" === e) return arguments[1] instanceof Error ? Promise.reject(arguments[1]) : Promise.reject("Uncaught, unspecified 'error' event.");
307 return Promise.all(o)
308 }, l.prototype.on = function(e, t) {
309 return this._on(e, t, !1)
310 }, l.prototype.prependListener = function(e, t) {
311 return this._on(e, t, !0)
312 }, l.prototype.onAny = function(e) {
313 return this._onAny(e, !1)
314 }, l.prototype.prependAny = function(e) {
315 return this._onAny(e, !0)
316 }, l.prototype.addListener = l.prototype.on, l.prototype._onAny = function(e, t) {
317 if ("function" != typeof e) throw new Error("onAny only accepts instances of Function");
318 return this._all || (this._all = []), t ? this._all.unshift(e) : this._all.push(e), this
319 }, l.prototype._on = function(e, t, n) {
320 if ("function" == typeof e) return this._onAny(e, t), this;
321 if ("function" != typeof t) throw new Error("on only accepts instances of Function");
322 return this._events || a.call(this), this._newListener && this.emit("newListener", e, t), this.wildcard ? (f.call(this, e, t), this) : (this._events[e] ? ("function" == typeof this._events[e] && (this._events[e] = [this._events[e]]), n ? this._events[e].unshift(t) : this._events[e].push(t), !this._events[e].warned && this._maxListeners > 0 && this._events[e].length > this._maxListeners && (this._events[e].warned = !0, u.call(this, this._events[e].length, e))) : this._events[e] = t, this)
323 }, l.prototype.off = function(e, t) {
324 function n(e) {
325 if (e !== o) {
326 var t = Object.keys(e);
327 for (var i in t) {
328 var s = t[i],
329 a = e[s];
330 a instanceof Function || "object" !== (void 0 === a ? "undefined" : r(a)) || null === a || (Object.keys(a).length > 0 && n(e[s]), 0 === Object.keys(a).length && delete e[s])
331 }
332 }
333 }
334 if ("function" != typeof t) throw new Error("removeListener only takes instances of Function");
335 var i, s = [];
336 if (this.wildcard) {
337 var a = "string" == typeof e ? e.split(this.delimiter) : e.slice();
338 s = h.call(this, null, a, this.listenerTree, 0)
339 } else {
340 if (!this._events[e]) return this;
341 i = this._events[e], s.push({
342 _listeners: i
343 })
344 }
345 for (var c = 0; c < s.length; c++) {
346 var u = s[c];
347 if (i = u._listeners, d(i)) {
348 for (var l = -1, f = 0, p = i.length; f < p; f++)
349 if (i[f] === t || i[f].listener && i[f].listener === t || i[f]._origin && i[f]._origin === t) {
350 l = f;
351 break
352 }
353 if (l < 0) continue;
354 return this.wildcard ? u._listeners.splice(l, 1) : this._events[e].splice(l, 1), 0 === i.length && (this.wildcard ? delete u._listeners : delete this._events[e]), this._removeListener && this.emit("removeListener", e, t), this
355 }(i === t || i.listener && i.listener === t || i._origin && i._origin === t) && (this.wildcard ? delete u._listeners : delete this._events[e], this._removeListener && this.emit("removeListener", e, t))
356 }
357 return n(this.listenerTree), this
358 }, l.prototype.offAny = function(e) {
359 var t, n = 0,
360 i = 0;
361 if (e && this._all && this._all.length > 0) {
362 for (t = this._all, n = 0, i = t.length; n < i; n++)
363 if (e === t[n]) return t.splice(n, 1), this._removeListener && this.emit("removeListenerAny", e), this
364 } else {
365 if (t = this._all, this._removeListener)
366 for (n = 0, i = t.length; n < i; n++) this.emit("removeListenerAny", t[n]);
367 this._all = []
368 }
369 return this
370 }, l.prototype.removeListener = l.prototype.off, l.prototype.removeAllListeners = function(e) {
371 if (e === o) return !this._events || a.call(this), this;
372 if (this.wildcard)
373 for (var t = "string" == typeof e ? e.split(this.delimiter) : e.slice(), n = h.call(this, null, t, this.listenerTree, 0), i = 0; i < n.length; i++) {
374 var s = n[i];
375 s._listeners = null
376 } else this._events && (this._events[e] = null);
377 return this
378 }, l.prototype.listeners = function(e) {
379 if (this.wildcard) {
380 var t = [],
381 n = "string" == typeof e ? e.split(this.delimiter) : e.slice();
382 return h.call(this, t, n, this.listenerTree, 0), t
383 }
384 return this._events || a.call(this), this._events[e] || (this._events[e] = []), d(this._events[e]) || (this._events[e] = [this._events[e]]), this._events[e]
385 }, l.prototype.eventNames = function() {
386 return Object.keys(this._events)
387 }, l.prototype.listenerCount = function(e) {
388 return this.listeners(e).length
389 }, l.prototype.listenersAny = function() {
390 return this._all ? this._all : []
391 }, (s = function() {
392 return l
393 }.call(t, n, t, e)) !== o && (e.exports = s)
394 }()
395 }).call(t, n(8))
396}, function(e, t, n) {
397 "use strict";
398
399 function i(e, t) {
400 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
401 }
402 Object.defineProperty(t, "__esModule", {
403 value: !0
404 });
405 var s = function() {
406 function e(e, t) {
407 for (var n = 0; n < t.length; n++) {
408 var i = t[n];
409 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
410 }
411 }
412 return function(t, n, i) {
413 return n && e(t.prototype, n), i && e(t, i), t
414 }
415 }(),
416 r = n(3),
417 o = function(e) {
418 return e && e.__esModule ? e : {
419 default: e
420 }
421 }(r),
422 a = function() {},
423 c = a,
424 u = {},
425 l = {
426 DEBUG: 1,
427 INFO: 2,
428 WARNING: 3,
429 ERROR: 4,
430 CRITICAL: 5
431 },
432 h = l.WARNING,
433 f = function() {
434 function e(t) {
435 i(this, e), this._opts = t
436 }
437 return s(e, [{
438 key: "debug",
439 value: function(e) {
440 h <= l.DEBUG && this._log("DEBUG: " + e)
441 }
442 }, {
443 key: "info",
444 value: function(e) {
445 h <= l.INFO && this._log("INFO: " + e)
446 }
447 }, {
448 key: "warning",
449 value: function(e) {
450 h <= l.WARNING && this._log("WARNING: " + e)
451 }
452 }, {
453 key: "error",
454 value: function(e) {
455 h <= l.ERROR && this._log("ERROR: " + e)
456 }
457 }, {
458 key: "critical",
459 value: function(e) {
460 h <= l.CRITICAL && this._log("CRITICAL: " + e)
461 }
462 }, {
463 key: "_log",
464 value: function(e) {
465 var t = this._opts.prefix + e;
466 this._opts.logFunc ? this._opts.logFunc(t) : c(t)
467 }
468 }]), e
469 }(),
470 d = {
471 setLogger: function(e) {
472 c = "function" == typeof e ? e : a
473 },
474 setLevel: function() {
475 var e = (o.default.urlParams.pubsub_log_level || "").toUpperCase();
476 if (e) {
477 var t = l[e];
478 if (t) return h = t,
479 function() {}
480 }
481 return function(e) {
482 h = e ? l[e.toUpperCase()] || l.WARNING : l.WARNING
483 }
484 }(),
485 _getLogger: function(e) {
486 return u[e] || (u[e] = new f({
487 prefix: "pubsub.js [" + e + "] "
488 })), u[e]
489 },
490 _noopLogger: new f({
491 prefix: "",
492 logFunc: a
493 })
494 },
495 p = window.console;
496 p && p.log && (p.log.apply ? d.setLogger(function() {
497 p.log.apply(p, arguments)
498 }) : d.setLogger(function() {
499 for (var e = [], t = 0; t < arguments.length; ++t) e.push(arguments[t]);
500 p.log(e.join(" "))
501 })), t.default = d
502}, function(e, t, n) {
503 "use strict";
504 Object.defineProperty(t, "__esModule", {
505 value: !0
506 });
507 var i = {};
508 i.randomInt = function(e) {
509 return Math.floor(Math.random() * e)
510 }, i.time = {
511 seconds: function(e) {
512 return 1e3 * e
513 },
514 now: function() {
515 return (new Date).getTime()
516 }
517 }, i.urlParams = function() {
518 for (var e = {}, t = window.location.search.substr(1), n = t.split("&"), i = 0; i < n.length; ++i) {
519 var s = n[i].split("=");
520 e[decodeURIComponent(s[0])] = s.length > 1 ? decodeURIComponent(s[1]) : ""
521 }
522 return e
523 }(), i.generateString = function(e) {
524 for (var t = "", n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", s = 0; s < e; s++) t += n.charAt(i.randomInt(n.length));
525 return t
526 }, i.inIframe = function() {
527 try {
528 return window.self !== window.top
529 } catch (e) {
530 return !0
531 }
532 }, t.default = i
533}, function(e, t, n) {
534 "use strict";
535 n.d(t, "b", function() {
536 return i
537 }), n.d(t, "a", function() {
538 return s
539 });
540 var i;
541 ! function(e) {
542 e.Production = "production", e.Staging = "staging", e.Test = "test"
543 }(i || (i = {}));
544 var s = function() {
545 function e() {}
546 return e
547 }()
548}, function(e, t, n) {
549 "use strict";
550 n.d(t, "c", function() {
551 return v
552 }), n.d(t, "d", function() {
553 return b
554 }), n.d(t, "a", function() {
555 return g
556 }), n.d(t, "b", function() {
557 return y
558 });
559 var i = n(7),
560 s = (n.n(i), n(1)),
561 r = (n.n(s), n(0)),
562 o = (n.n(r), n(22)),
563 a = (n.n(o), n(24)),
564 c = n(26),
565 u = n(33),
566 l = n(35),
567 h = n(37),
568 f = n(47),
569 d = n(48),
570 p = n(50),
571 _ = this && this.__assign || function() {
572 return _ = Object.assign || function(e) {
573 for (var t, n = 1, i = arguments.length; n < i; n++) {
574 t = arguments[n];
575 for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s])
576 }
577 return e
578 }, _.apply(this, arguments)
579 };
580 Object(i.polyfill)();
581 var v, b, g;
582 ! function(e) {
583 e.Authorized = "callback-event-authorized", e.Context = "callback-event-context", e.Error = "callback-event-error", e.Position = "callback-event-position", e.ReloadEntitlements = "callback-event-reload-entitlements", e.Visibility = "callback-event-visibility", e.Highlight = "callback-event-highlight"
584 }(g || (g = {}));
585 var y = function() {
586 function e(e, t) {
587 var n = this;
588 this.packageVersion = t, this.authData = null, this.context = null, this.contextChangedFields = [], this.isVisible = !0, this.handleMessageEvent = function(e) {
589 if (e.source === window.parent) {
590 var t = e.data;
591 switch (t.action) {
592 case r.ExtensionAction.TwitchExtBootstrap:
593 n.features.initializeFeatureFlags(t.features), n.configuration.initializeConfiguration(t.configuration), n.viewer.initializeViewer(t.auth, t.viewerInfo), n.onAuthReceived(t.auth);
594 break;
595 case r.ExtensionAction.TwitchExtReload:
596 window.location.reload();
597 break;
598 case r.ExtensionAction.TwitchExtAuth:
599 n.onAuthReceived(t.auth);
600 break;
601 case r.ExtensionAction.TwitchExtError:
602 n.callbackEvents.emit(g.Error, new Error(t.message));
603 break;
604 case r.ExtensionAction.TwitchExtContext:
605 n.context = t.context, n.contextChangedFields = t.updatedFields, n.callbackEvents.emit(g.Context, n.context, n.contextChangedFields);
606 break;
607 case r.ExtensionAction.TwitchExtVisibilityChanged:
608 n.isVisible = t.isVisible, n.callbackEvents.emit(g.Visibility, t.isVisible, t.context);
609 break;
610 case r.ExtensionAction.TwitchExtPositionChanged:
611 n.callbackEvents.emit(g.Position, t.position);
612 break;
613 case r.ExtensionAction.TwitchExtHighlightChanged:
614 n.callbackEvents.emit(g.Highlight, t.isHighlighted);
615 break;
616 case r.ExtensionAction.TwitchExtViewerUpdate:
617 n.viewer.updateViewerInfo(t.viewerInfo)
618 }
619 n.actions.onControllerMessage(t), n.bits.onControllerMessage(t), n.purchases.onControllerMessage(t), n.pubsub.onControllerMessage(t)
620 }
621 }, this.onAuthorized = function(e) {
622 n.callbackEvents.removeAllListeners(g.Authorized), n.callbackEvents.addListener(g.Authorized, e), n.authData && n.callbackEvents.emit(g.Authorized, n.authData)
623 }, this.onError = function(e) {
624 n.callbackEvents.removeAllListeners(g.Error), n.callbackEvents.addListener(g.Error, e)
625 }, this.onContext = function(e) {
626 n.callbackEvents.removeAllListeners(g.Context), n.callbackEvents.addListener(g.Context, e), n.authData && n.callbackEvents.emit(g.Context, n.context, n.contextChangedFields)
627 }, this.onPositionChanged = function(e) {
628 n.callbackEvents.removeAllListeners(g.Position), n.callbackEvents.addListener(g.Position, e)
629 }, this.onVisibilityChanged = function(e) {
630 n.callbackEvents.removeAllListeners(g.Visibility), n.callbackEvents.addListener(g.Visibility, e), n.isVisible || n.callbackEvents.emit(g.Visibility, n.isVisible, null)
631 }, this.onHighlightChanged = function(e) {
632 n.callbackEvents.removeAllListeners(g.Highlight), n.callbackEvents.addListener(g.Highlight, e)
633 }, this.onNetworkResourceTiming = function() {}, v = this.config = e, b = this.sendCoordinatorMessage, this.features = new l.a, this.callbackEvents = new s.EventEmitter2, this.pubsub = new h.a(this.features, this.callbackEvents), this.actions = new a.a, this.bits = new c.a, this.configuration = new u.a(this.callbackEvents), this.purchases = new f.a, this.rig = new d.a, this.viewer = new p.a;
634 var i = window.performance,
635 _ = window.location.href;
636 Object(o.isSniffingAllowed)(i) && (this.networkSniffer = new o.NetworkSniffer(i, _), this.networkSniffer.start(), this.networkSniffer.addResourceListener(this.onNetworkResourceTiming))
637 }
638 return Object.defineProperty(e.prototype, "publicAPI", {
639 get: function() {
640 var e = this;
641 return _({get version() {
642 return e.packageVersion
643 },
644 get environment() {
645 return e.config.environment
646 },
647 get onAuthorized() {
648 return e.onAuthorized
649 },
650 get onContext() {
651 return e.onContext
652 },
653 get onError() {
654 return e.onError
655 },
656 get onPositionChange() {
657 return e.onPositionChanged
658 },
659 get onPositionChanged() {
660 return e.onPositionChanged
661 },
662 get onVisibilityChanged() {
663 return e.onVisibilityChanged
664 },
665 get onHighlightChanged() {
666 return e.onHighlightChanged
667 }
668 }, this.pubsub.publicAPI, {get actions() {
669 return e.actions.publicAPI
670 },
671 get bits() {
672 return e.bits.publicAPI
673 },
674 get configuration() {
675 return e.configuration.publicAPI
676 },
677 get features() {
678 return e.features.publicAPI
679 },
680 get purchases() {
681 return e.purchases.publicAPI
682 },
683 get rig() {
684 return e.rig.publicAPI
685 },
686 get viewer() {
687 return e.viewer.publicAPI
688 }
689 })
690 },
691 enumerable: !0,
692 configurable: !0
693 }), e.prototype.sendCoordinatorMessage = function(e) {
694 window.parent.postMessage(e, "*")
695 }, e.prototype.onAuthReceived = function(e) {
696 this.authData = e, this.pubsub.setAuth(e), this.viewer.setAuth(e), this.configuration.setAuth(e), this.callbackEvents.emit(g.Authorized, e)
697 }, e
698 }()
699}, function(e, t, n) {
700 "use strict";
701
702 function i(e, t) {
703 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
704 }
705 Object.defineProperty(t, "__esModule", {
706 value: !0
707 });
708 var s = function() {
709 function e(e, t) {
710 for (var n = 0; n < t.length; n++) {
711 var i = t[n];
712 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
713 }
714 }
715 return function(t, n, i) {
716 return n && e(t.prototype, n), i && e(t, i), t
717 }
718 }(),
719 r = function() {
720 function e() {
721 i(this, e)
722 }
723 return s(e, [{
724 key: "on",
725 value: function(e, t, n) {
726 return this._events = this._events || {}, this._events[e] = this._events[e] || [], this._events[e].push(t, n), this
727 }
728 }, {
729 key: "off",
730 value: function(e, t) {
731 if (this._events)
732 for (var n = this._events[e] || [], i = this._events[e] = [], s = 0; s < n.length; s += 2) n[s] !== t && (i.push(n[s]), i.push(n[s + 1]));
733 return this
734 }
735 }, {
736 key: "_trigger",
737 value: function(e) {
738 if (this._events)
739 for (var t = this._events[e] || [], n = 1; n < t.length; n += 2) t[n - 1].apply(t[n], Array.prototype.slice.call(arguments, 1));
740 return this
741 }
742 }, {
743 key: "count",
744 value: function(e) {
745 if (this._events) {
746 return (this._events[e] || []).length / 2
747 }
748 return 0
749 }
750 }]), e
751 }();
752 t.default = r
753}, function(e, t, n) {
754 "use strict";
755 (function(i) {
756 var s, r, o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
757 return typeof e
758 } : function(e) {
759 return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
760 };
761 /*!
762 * @overview es6-promise - a tiny implementation of Promises/A+.
763 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
764 * @license Licensed under MIT license
765 * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
766 * @version v4.2.5+7f2b526d
767 */
768 ! function(i, a) {
769 "object" === o(t) && void 0 !== e ? e.exports = a() : (s = a, void 0 !== (r = "function" == typeof s ? s.call(t, n, t, e) : s) && (e.exports = r))
770 }(0, function() {
771 function e(e) {
772 var t = void 0 === e ? "undefined" : o(e);
773 return null !== e && ("object" === t || "function" === t)
774 }
775
776 function t(e) {
777 return "function" == typeof e
778 }
779
780 function n(e) {
781 D = e
782 }
783
784 function s(e) {
785 V = e
786 }
787
788 function r() {
789 return void 0 !== B ? function() {
790 B(c)
791 } : a()
792 }
793
794 function a() {
795 var e = setTimeout;
796 return function() {
797 return e(c, 1)
798 }
799 }
800
801 function c() {
802 for (var e = 0; e < N; e += 2) {
803 (0, K[e])(K[e + 1]), K[e] = void 0, K[e + 1] = void 0
804 }
805 N = 0
806 }
807
808 function u(e, t) {
809 var n = this,
810 i = new this.constructor(h);
811 void 0 === i[X] && j(i);
812 var s = n._state;
813 if (s) {
814 var r = arguments[s - 1];
815 V(function() {
816 return O(s, i, r, n._result)
817 })
818 } else E(n, i, e, t);
819 return i
820 }
821
822 function l(e) {
823 var t = this;
824 if (e && "object" === (void 0 === e ? "undefined" : o(e)) && e.constructor === t) return e;
825 var n = new t(h);
826 return y(n, e), n
827 }
828
829 function h() {}
830
831 function f() {
832 return new TypeError("You cannot resolve a promise with itself")
833 }
834
835 function d() {
836 return new TypeError("A promises callback cannot return that same promise.")
837 }
838
839 function p(e) {
840 try {
841 return e.then
842 } catch (e) {
843 return ee.error = e, ee
844 }
845 }
846
847 function _(e, t, n, i) {
848 try {
849 e.call(t, n, i)
850 } catch (e) {
851 return e
852 }
853 }
854
855 function v(e, t, n) {
856 V(function(e) {
857 var i = !1,
858 s = _(n, t, function(n) {
859 i || (i = !0, t !== n ? y(e, n) : w(e, n))
860 }, function(t) {
861 i || (i = !0, k(e, t))
862 }, "Settle: " + (e._label || " unknown promise"));
863 !i && s && (i = !0, k(e, s))
864 }, e)
865 }
866
867 function b(e, t) {
868 t._state === Y ? w(e, t._result) : t._state === Z ? k(e, t._result) : E(t, void 0, function(t) {
869 return y(e, t)
870 }, function(t) {
871 return k(e, t)
872 })
873 }
874
875 function g(e, n, i) {
876 n.constructor === e.constructor && i === u && n.constructor.resolve === l ? b(e, n) : i === ee ? (k(e, ee.error), ee.error = null) : void 0 === i ? w(e, n) : t(i) ? v(e, n, i) : w(e, n)
877 }
878
879 function y(t, n) {
880 t === n ? k(t, f()) : e(n) ? g(t, n, p(n)) : w(t, n)
881 }
882
883 function m(e) {
884 e._onerror && e._onerror(e._result), x(e)
885 }
886
887 function w(e, t) {
888 e._state === $ && (e._result = t, e._state = Y, 0 !== e._subscribers.length && V(x, e))
889 }
890
891 function k(e, t) {
892 e._state === $ && (e._state = Z, e._result = t, V(m, e))
893 }
894
895 function E(e, t, n, i) {
896 var s = e._subscribers,
897 r = s.length;
898 e._onerror = null, s[r] = t, s[r + Y] = n, s[r + Z] = i, 0 === r && e._state && V(x, e)
899 }
900
901 function x(e) {
902 var t = e._subscribers,
903 n = e._state;
904 if (0 !== t.length) {
905 for (var i = void 0, s = void 0, r = e._result, o = 0; o < t.length; o += 3) i = t[o], s = t[o + n], i ? O(n, i, s, r) : s(r);
906 e._subscribers.length = 0
907 }
908 }
909
910 function T(e, t) {
911 try {
912 return e(t)
913 } catch (e) {
914 return ee.error = e, ee
915 }
916 }
917
918 function O(e, n, i, s) {
919 var r = t(i),
920 o = void 0,
921 a = void 0,
922 c = void 0,
923 u = void 0;
924 if (r) {
925 if (o = T(i, s), o === ee ? (u = !0, a = o.error, o.error = null) : c = !0, n === o) return void k(n, d())
926 } else o = s, c = !0;
927 n._state !== $ || (r && c ? y(n, o) : u ? k(n, a) : e === Y ? w(n, o) : e === Z && k(n, o))
928 }
929
930 function S(e, t) {
931 try {
932 t(function(t) {
933 y(e, t)
934 }, function(t) {
935 k(e, t)
936 })
937 } catch (t) {
938 k(e, t)
939 }
940 }
941
942 function P() {
943 return te++
944 }
945
946 function j(e) {
947 e[X] = te++, e._state = void 0, e._result = void 0, e._subscribers = []
948 }
949
950 function A() {
951 return new Error("Array Methods must be provided an Array")
952 }
953
954 function L(e) {
955 return new ne(this, e).promise
956 }
957
958 function R(e) {
959 var t = this;
960 return new t(F(e) ? function(n, i) {
961 for (var s = e.length, r = 0; r < s; r++) t.resolve(e[r]).then(n, i)
962 } : function(e, t) {
963 return t(new TypeError("You must pass an array to race."))
964 })
965 }
966
967 function C(e) {
968 var t = this,
969 n = new t(h);
970 return k(n, e), n
971 }
972
973 function M() {
974 throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")
975 }
976
977 function I() {
978 throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")
979 }
980
981 function U() {
982 var e = void 0;
983 if ("undefined" != typeof global) e = global;
984 else if ("undefined" != typeof self) e = self;
985 else try {
986 e = Function("return this")()
987 } catch (e) {
988 throw new Error("polyfill failed because global object is unavailable in this environment")
989 }
990 var t = e.Promise;
991 if (t) {
992 var n = null;
993 try {
994 n = Object.prototype.toString.call(t.resolve())
995 } catch (e) {}
996 if ("[object Promise]" === n && !t.cast) return
997 }
998 e.Promise = ie
999 }
1000 var q = void 0;
1001 q = Array.isArray ? Array.isArray : function(e) {
1002 return "[object Array]" === Object.prototype.toString.call(e)
1003 };
1004 var F = q,
1005 N = 0,
1006 B = void 0,
1007 D = void 0,
1008 V = function(e, t) {
1009 K[N] = e, K[N + 1] = t, 2 === (N += 2) && (D ? D(c) : Q())
1010 },
1011 z = "undefined" != typeof window ? window : void 0,
1012 H = z || {},
1013 W = H.MutationObserver || H.WebKitMutationObserver,
1014 G = "undefined" == typeof self && void 0 !== i && "[object process]" === {}.toString.call(i),
1015 J = "undefined" != typeof Uint8ClampedArray && "undefined" != typeof importScripts && "undefined" != typeof MessageChannel,
1016 K = new Array(1e3),
1017 Q = void 0;
1018 Q = G ? function() {
1019 return function() {
1020 return i.nextTick(c)
1021 }
1022 }() : W ? function() {
1023 var e = 0,
1024 t = new W(c),
1025 n = document.createTextNode("");
1026 return t.observe(n, {
1027 characterData: !0
1028 }),
1029 function() {
1030 n.data = e = ++e % 2
1031 }
1032 }() : J ? function() {
1033 var e = new MessageChannel;
1034 return e.port1.onmessage = c,
1035 function() {
1036 return e.port2.postMessage(0)
1037 }
1038 }() : void 0 === z ? function() {
1039 try {
1040 var e = Function("return this")().require("vertx");
1041 return B = e.runOnLoop || e.runOnContext, r()
1042 } catch (e) {
1043 return a()
1044 }
1045 }() : a();
1046 var X = Math.random().toString(36).substring(2),
1047 $ = void 0,
1048 Y = 1,
1049 Z = 2,
1050 ee = {
1051 error: null
1052 },
1053 te = 0,
1054 ne = function() {
1055 function e(e, t) {
1056 this._instanceConstructor = e, this.promise = new e(h), this.promise[X] || j(this.promise), F(t) ? (this.length = t.length, this._remaining = t.length, this._result = new Array(this.length), 0 === this.length ? w(this.promise, this._result) : (this.length = this.length || 0, this._enumerate(t), 0 === this._remaining && w(this.promise, this._result))) : k(this.promise, A())
1057 }
1058 return e.prototype._enumerate = function(e) {
1059 for (var t = 0; this._state === $ && t < e.length; t++) this._eachEntry(e[t], t)
1060 }, e.prototype._eachEntry = function(e, t) {
1061 var n = this._instanceConstructor,
1062 i = n.resolve;
1063 if (i === l) {
1064 var s = p(e);
1065 if (s === u && e._state !== $) this._settledAt(e._state, t, e._result);
1066 else if ("function" != typeof s) this._remaining--, this._result[t] = e;
1067 else if (n === ie) {
1068 var r = new n(h);
1069 g(r, e, s), this._willSettleAt(r, t)
1070 } else this._willSettleAt(new n(function(t) {
1071 return t(e)
1072 }), t)
1073 } else this._willSettleAt(i(e), t)
1074 }, e.prototype._settledAt = function(e, t, n) {
1075 var i = this.promise;
1076 i._state === $ && (this._remaining--, e === Z ? k(i, n) : this._result[t] = n), 0 === this._remaining && w(i, this._result)
1077 }, e.prototype._willSettleAt = function(e, t) {
1078 var n = this;
1079 E(e, void 0, function(e) {
1080 return n._settledAt(Y, t, e)
1081 }, function(e) {
1082 return n._settledAt(Z, t, e)
1083 })
1084 }, e
1085 }(),
1086 ie = function() {
1087 function e(t) {
1088 this[X] = P(), this._result = this._state = void 0, this._subscribers = [], h !== t && ("function" != typeof t && M(), this instanceof e ? S(this, t) : I())
1089 }
1090 return e.prototype.catch = function(e) {
1091 return this.then(null, e)
1092 }, e.prototype.finally = function(e) {
1093 var n = this,
1094 i = n.constructor;
1095 return t(e) ? n.then(function(t) {
1096 return i.resolve(e()).then(function() {
1097 return t
1098 })
1099 }, function(t) {
1100 return i.resolve(e()).then(function() {
1101 throw t
1102 })
1103 }) : n.then(e, e)
1104 }, e
1105 }();
1106 return ie.prototype.then = u, ie.all = L, ie.race = R, ie.resolve = l, ie.reject = C, ie._setScheduler = n, ie._setAsap = s, ie._asap = V, ie.polyfill = U, ie.Promise = ie, ie
1107 })
1108 }).call(t, n(8))
1109}, function(e, t, n) {
1110 "use strict";
1111
1112 function i() {
1113 throw new Error("setTimeout has not been defined")
1114 }
1115
1116 function s() {
1117 throw new Error("clearTimeout has not been defined")
1118 }
1119
1120 function r(e) {
1121 if (h === setTimeout) return setTimeout(e, 0);
1122 if ((h === i || !h) && setTimeout) return h = setTimeout, setTimeout(e, 0);
1123 try {
1124 return h(e, 0)
1125 } catch (t) {
1126 try {
1127 return h.call(null, e, 0)
1128 } catch (t) {
1129 return h.call(this, e, 0)
1130 }
1131 }
1132 }
1133
1134 function o(e) {
1135 if (f === clearTimeout) return clearTimeout(e);
1136 if ((f === s || !f) && clearTimeout) return f = clearTimeout, clearTimeout(e);
1137 try {
1138 return f(e)
1139 } catch (t) {
1140 try {
1141 return f.call(null, e)
1142 } catch (t) {
1143 return f.call(this, e)
1144 }
1145 }
1146 }
1147
1148 function a() {
1149 v && p && (v = !1, p.length ? _ = p.concat(_) : b = -1, _.length && c())
1150 }
1151
1152 function c() {
1153 if (!v) {
1154 var e = r(a);
1155 v = !0;
1156 for (var t = _.length; t;) {
1157 for (p = _, _ = []; ++b < t;) p && p[b].run();
1158 b = -1, t = _.length
1159 }
1160 p = null, v = !1, o(e)
1161 }
1162 }
1163
1164 function u(e, t) {
1165 this.fun = e, this.array = t
1166 }
1167
1168 function l() {}
1169 var h, f, d = e.exports = {};
1170 ! function() {
1171 try {
1172 h = "function" == typeof setTimeout ? setTimeout : i
1173 } catch (e) {
1174 h = i
1175 }
1176 try {
1177 f = "function" == typeof clearTimeout ? clearTimeout : s
1178 } catch (e) {
1179 f = s
1180 }
1181 }();
1182 var p, _ = [],
1183 v = !1,
1184 b = -1;
1185 d.nextTick = function(e) {
1186 var t = new Array(arguments.length - 1);
1187 if (arguments.length > 1)
1188 for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
1189 _.push(new u(e, t)), 1 !== _.length || v || r(c)
1190 }, u.prototype.run = function() {
1191 this.fun.apply(null, this.array)
1192 }, d.title = "browser", d.browser = !0, d.env = {}, d.argv = [], d.version = "", d.versions = {}, d.on = l, d.addListener = l, d.once = l, d.off = l, d.removeListener = l, d.removeAllListeners = l, d.emit = l, d.prependListener = l, d.prependOnceListener = l, d.listeners = function(e) {
1193 return []
1194 }, d.binding = function(e) {
1195 throw new Error("process.binding is not supported")
1196 }, d.cwd = function() {
1197 return "/"
1198 }, d.chdir = function(e) {
1199 throw new Error("process.chdir is not supported")
1200 }, d.umask = function() {
1201 return 0
1202 }
1203}, function(e, t, n) {
1204 "use strict";
1205 n.d(t, "b", function() {
1206 return c
1207 });
1208 var i = n(4),
1209 s = n(19),
1210 r = n(20),
1211 o = n(21);
1212 n.d(t, "a", function() {
1213 return i.b
1214 });
1215 var a, c = (a = {}, a[i.b.Production] = s.a, a[i.b.Staging] = r.a, a[i.b.Test] = o.a, a)
1216}, function(e, t, n) {
1217 "use strict";
1218
1219 function i(e, t) {
1220 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
1221 }
1222 Object.defineProperty(t, "__esModule", {
1223 value: !0
1224 });
1225 var s = function() {
1226 function e(e, t) {
1227 for (var n = 0; n < t.length; n++) {
1228 var i = t[n];
1229 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
1230 }
1231 }
1232 return function(t, n, i) {
1233 return n && e(t.prototype, n), i && e(t, i), t
1234 }
1235 }(),
1236 r = function() {
1237 function e() {
1238 i(this, e), this._map = {}, this._size = 0
1239 }
1240 return s(e, [{
1241 key: "set",
1242 value: function(e, t) {
1243 this._map.hasOwnProperty(e) || (this._size += 1), this._map[e] = t
1244 }
1245 }, {
1246 key: "get",
1247 value: function(e) {
1248 return this._map[e]
1249 }
1250 }, {
1251 key: "has",
1252 value: function(e) {
1253 return this._map.hasOwnProperty(e)
1254 }
1255 }, {
1256 key: "remove",
1257 value: function(e) {
1258 this._map.hasOwnProperty(e) && (this._size -= 1), delete this._map[e]
1259 }
1260 }, {
1261 key: "size",
1262 value: function() {
1263 return this._size
1264 }
1265 }, {
1266 key: "map",
1267 value: function() {
1268 return this._map
1269 }
1270 }, {
1271 key: "values",
1272 value: function() {
1273 var e = [];
1274 for (var t in this._map) this._map.hasOwnProperty(t) && e.push(this._map[t]);
1275 return e
1276 }
1277 }]), e
1278 }();
1279 t.default = r
1280}, function(e, t, n) {
1281 "use strict";
1282
1283 function i(e, t) {
1284 t || (t = window.location.href), e = e.replace(/[\[\]]/g, "\\$&");
1285 var n = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"),
1286 i = n.exec(t);
1287 return i ? i[2] ? decodeURIComponent(i[2].replace(/\+/g, " ")) : "" : null
1288 }
1289 t.b = i, n.d(t, "c", function() {
1290 return r
1291 }), n.d(t, "a", function() {
1292 return o
1293 });
1294 var s = ["assert", "clear", "count", "debug", "dir", "dirxml", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "profile", "profileEnd", "table", "time", "timeEnd", "timeStamp", "trace", "warn"],
1295 r = function() {
1296 var e;
1297 window.console ? e = Object.keys(window.console).filter(function(e) {
1298 return "function" == typeof window.console[e]
1299 }) : (window.console = {}, e = s), e.forEach(function(e) {
1300 window.console[e] = function() {
1301 return 0
1302 }
1303 })
1304 },
1305 o = function(e) {
1306 [e.documentElement, e.body].forEach(function(e) {
1307 e.style.setProperty("width", "100%", "important"), e.style.setProperty("height", "100%", "important")
1308 }), e.body.setAttribute("tabindex", "-1")
1309 }
1310}, function(e, t, n) {
1311 "use strict";
1312 Object.defineProperty(t, "__esModule", {
1313 value: !0
1314 });
1315 var i = n(7),
1316 s = (n.n(i), n(0)),
1317 r = (n.n(s), n(9)),
1318 o = n(5),
1319 a = n(51),
1320 c = n(11),
1321 u = new r.b.production,
1322 l = new o.b(u, "1.21.3"),
1323 h = {
1324 anchor: Object(c.b)("anchor"),
1325 mode: Object(c.b)("mode"),
1326 state: Object(c.b)("state")
1327 },
1328 f = Object(c.b)("platform");
1329 f && (h.platform = f);
1330 var d = new a.a(h, l.handleMessageEvent, window, document);
1331 d.bindEvents(), h.state === s.ExternalExtensionState.Released && Object(c.c)(), document.body && d.forceVideoOverlayFullSize(), window.Twitch = window.Twitch || {}, window.Twitch.ext = window.Twitch.ext || l.publicAPI
1332}, function(e, t, n) {
1333 "use strict";
1334 Object.defineProperty(t, "__esModule", {
1335 value: !0
1336 });
1337 var i, s = t.ExtensionActivationStatus = void 0;
1338 ! function(e) {
1339 e.Active = "active", e.Inactive = "inactive"
1340 }(s || (t.ExtensionActivationStatus = s = {}));
1341 var r = t.ExtensionAnchor = void 0;
1342 ! function(e) {
1343 e.Hidden = "hidden", e.Panel = "panel", e.Overlay = "video_overlay", e.Component = "component"
1344 }(r || (t.ExtensionAnchor = r = {}));
1345 var o = t.ExtensionMode = void 0;
1346 ! function(e) {
1347 e.Config = "config", e.Dashboard = "dashboard", e.Viewer = "viewer"
1348 }(o || (t.ExtensionMode = o = {}));
1349 var a = t.ExtensionPlatform = void 0;
1350 ! function(e) {
1351 e.Mobile = "mobile", e.Web = "web"
1352 }(a || (t.ExtensionPlatform = a = {}));
1353 var c = t.ExtensionState = void 0;
1354 ! function(e) {
1355 e.Testing = "Testing", e.HostedTest = "Assets Uploaded", e.Approved = "Approved", e.Released = "Released", e.ReadyForReview = "Ready For Review", e.InReview = "In Review", e.PendingAction = "Pending Action", e.Uploading = "Uploading"
1356 }(c || (t.ExtensionState = c = {}));
1357 var u = t.ExternalExtensionState = void 0;
1358 ! function(e) {
1359 e.Testing = "testing", e.HostedTest = "hosted_test", e.Approved = "approved", e.Released = "released", e.ReadyForReview = "ready_for_review", e.InReview = "in_review", e.PendingAction = "pending_action", e.Uploading = "uploading"
1360 }(u || (t.ExternalExtensionState = u = {}));
1361 var l = (t.ExtensionStateMap = (i = {}, i[c.Testing] = u.Testing, i[c.HostedTest] = u.HostedTest, i[c.Approved] = u.Approved, i[c.Released] = u.Released, i[c.ReadyForReview] = u.ReadyForReview, i[c.InReview] = u.InReview, i[c.PendingAction] = u.PendingAction, i[c.Uploading] = u.Uploading, i), t.ExtensionAction = void 0);
1362 ! function(e) {
1363 e.TwitchExtAuth = "twitch-ext-auth", e.TwitchExtBootstrap = "twitch-ext-bootstrap", e.TwitchExtContext = "twitch-ext-context", e.TwitchExtError = "twitch-ext-error", e.TwitchExtLoaded = "twitch-ext-loaded", e.TwitchExtLongtask = "twitch-ext-longtask", e.TwitchExtNetworkTiming = "twitch-ext-network-timing", e.TwitchExtReload = "twitch-ext-reload", e.TwitchExtUserAction = "twitch-ext-user-action", e.TwitchExtConfirmationRequest = "twitch-ext-confirmation-request", e.TwitchExtBeginPurchase = "twitch-ext-begin-purchase", e.TwitchExtReloadEntitlements = "twitch-ext-reload-entitlements", e.TwitchExtProductPrices = "twitch-ext-product-prices", e.TwitchExtVisibilityChanged = "twitch-ext-visibility-changed", e.TwitchExtHighlightChanged = "twitch-ext-highlight-changed", e.TwitchExtBitsProducts = "twitch-ext-bits-products", e.TwitchExtUseBits = "twitch-ext-use-bits", e.TwitchExtBitsTransactionComplete = "twitch-ext-bits-transaction-complete", e.TwitchExtBitsOnHover = "twitch-ext-bits-on-hover", e.TwitchExtPubSubReceived = "twitch-ext-pubsub-received", e.TwitchExtPositionChanged = "twitch-ext-position-changed", e.TwitchExtPubsubMessage = "twitch-ext-pubsub-message", e.TwitchExtPubsubBindFailure = "twitch-ext-pubsub-bind-failure", e.TwitchExtPubsubListen = "twitch-ext-pubsub-listen", e.TwitchExtPubsubUnlisten = "twitch-ext-pubsub-unlisten", e.TwitchExtViewerUpdate = "twitch-ext-viewer-update"
1364 }(l || (t.ExtensionAction = l = {}));
1365 t.DefaultZoomPixelWidth = 1024
1366}, function(e, t, n) {
1367 "use strict";
1368 Object.defineProperty(t, "__esModule", {
1369 value: !0
1370 });
1371 var i = t.SupervisorAction = void 0;
1372 ! function(e) {
1373 e.SupervisorReady = "supervisor-ready", e.SupervisorInit = "supervisor-init"
1374 }(i || (t.SupervisorAction = i = {}))
1375}, function(e, t, n) {
1376 "use strict";
1377 Object.defineProperty(t, "__esModule", {
1378 value: !0
1379 });
1380 var i = t.FunctionAction = void 0;
1381 ! function(e) {
1382 e.LoginRequest = "twitch-ext-login-request", e.FollowAction = "twitch-ext-follow-action", e.FollowComplete = "twitch-ext-follow-complete", e.FollowStatusRequest = "twitch-ext-follow-status", e.FollowStatusResponse = "twitch-ext-follow-status-response", e.IdShareRequest = "twitch-ext-id-share-request", e.TwitchExtMinimize = "twitch-ext-minimize", e.UseBitsPromptRequired = "twitch-ext-use-bits", e.SubscribeToChannel = "twitch-ext-subscribe-to-channel", e.SubscribeToChannelResult = "twitch-ext-subscribe-to-channel-result", e.UseBits = "twitch-ext-use-bits", e.UseBitsComplete = "twitch-ext-use-bits-complete"
1383 }(i || (t.FunctionAction = i = {}))
1384}, function(e, t, n) {
1385 "use strict";
1386 Object.defineProperty(t, "__esModule", {
1387 value: !0
1388 });
1389 var i = (t.DEFAULT_PANEL_HEIGHT = 300, t.ExtensionFrameEvents = void 0);
1390 ! function(e) {
1391 e.ExtensionFrameLoaded = "extensionFrameLoaded", e.IdentityLinked = "identityLinked", e.Minimize = "minimize", e.RequestModal = "requestModal", e.ShowBitsBalance = "showBitsBalance", e.ShowUseBitsSuccess = "showUseBitsSuccess", e.UseBitsError = "useBitsError"
1392 }(i || (t.ExtensionFrameEvents = i = {}))
1393}, function(e, t, n) {
1394 "use strict";
1395 Object.defineProperty(t, "__esModule", {
1396 value: !0
1397 });
1398 var i = t.PlaybackMode = void 0;
1399 ! function(e) {
1400 e.Video = "video", e.Audio = "audio", e.Remote = "remote", e.ChatOnly = "chat-only"
1401 }(i || (t.PlaybackMode = i = {}))
1402}, function(e, t, n) {
1403 "use strict";
1404 Object.defineProperty(t, "__esModule", {
1405 value: !0
1406 });
1407 var i = t.ExtensionServiceEvents = void 0;
1408 ! function(e) {
1409 e.RequestModal = "requestModal", e.ContextUpdate = "contextupdate"
1410 }(i || (t.ExtensionServiceEvents = i = {}))
1411}, function(e, t, n) {
1412 "use strict";
1413 n.d(t, "a", function() {
1414 return r
1415 });
1416 var i = n(4),
1417 s = this && this.__extends || function() {
1418 var e = function(t, n) {
1419 return (e = Object.setPrototypeOf || {
1420 __proto__: []
1421 }
1422 instanceof Array && function(e, t) {
1423 e.__proto__ = t
1424 } || function(e, t) {
1425 for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
1426 })(t, n)
1427 };
1428 return function(t, n) {
1429 function i() {
1430 this.constructor = t
1431 }
1432 e(t, n), t.prototype = null === n ? Object.create(n) : (i.prototype = n.prototype, new i)
1433 }
1434 }(),
1435 r = function(e) {
1436 function t() {
1437 var t = null !== e && e.apply(this, arguments) || this;
1438 return t.environment = i.b.Production, t.pubsubEnvironment = "production", t.pubsubURL = "https://api.twitch.tv/v5/extensions/message", t.twitchAPIURL = "https://api.twitch.tv", t
1439 }
1440 return s(t, e), t
1441 }(i.a)
1442}, function(e, t, n) {
1443 "use strict";
1444 n.d(t, "a", function() {
1445 return r
1446 });
1447 var i = n(4),
1448 s = this && this.__extends || function() {
1449 var e = function(t, n) {
1450 return (e = Object.setPrototypeOf || {
1451 __proto__: []
1452 }
1453 instanceof Array && function(e, t) {
1454 e.__proto__ = t
1455 } || function(e, t) {
1456 for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
1457 })(t, n)
1458 };
1459 return function(t, n) {
1460 function i() {
1461 this.constructor = t
1462 }
1463 e(t, n), t.prototype = null === n ? Object.create(n) : (i.prototype = n.prototype, new i)
1464 }
1465 }(),
1466 r = function(e) {
1467 function t() {
1468 var t = null !== e && e.apply(this, arguments) || this;
1469 return t.environment = i.b.Staging, t.pubsubEnvironment = "darklaunch", t.pubsubURL = "http://pubsub-broker-darklaunch.internal.twitch.tv", t.twitchAPIURL = "https://api.twitch.tv", t
1470 }
1471 return s(t, e), t
1472 }(i.a)
1473}, function(e, t, n) {
1474 "use strict";
1475 n.d(t, "a", function() {
1476 return r
1477 });
1478 var i = n(4),
1479 s = this && this.__extends || function() {
1480 var e = function(t, n) {
1481 return (e = Object.setPrototypeOf || {
1482 __proto__: []
1483 }
1484 instanceof Array && function(e, t) {
1485 e.__proto__ = t
1486 } || function(e, t) {
1487 for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
1488 })(t, n)
1489 };
1490 return function(t, n) {
1491 function i() {
1492 this.constructor = t
1493 }
1494 e(t, n), t.prototype = null === n ? Object.create(n) : (i.prototype = n.prototype, new i)
1495 }
1496 }(),
1497 r = function(e) {
1498 function t() {
1499 var t = null !== e && e.apply(this, arguments) || this;
1500 return t.environment = i.b.Test, t.pubsubEnvironment = "test", t.pubsubURL = "http://test", t.twitchAPIURL = "http://test", t
1501 }
1502 return s(t, e), t
1503 }(i.a)
1504}, function(e, t, n) {
1505 "use strict";
1506 (function(e) {
1507 var n, i, s, r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
1508 return typeof e
1509 } : function(e) {
1510 return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
1511 };
1512 ! function(o, a) {
1513 "object" === r(t) && "object" === r(e) ? e.exports = a() : (i = [], n = a, void 0 !== (s = "function" == typeof n ? n.apply(t, i) : n) && (e.exports = s))
1514 }(0, function() {
1515 return function(e) {
1516 function t(i) {
1517 if (n[i]) return n[i].exports;
1518 var s = n[i] = {
1519 i: i,
1520 l: !1,
1521 exports: {}
1522 };
1523 return e[i].call(s.exports, s, s.exports, t), s.l = !0, s.exports
1524 }
1525 var n = {};
1526 return t.m = e, t.c = n, t.i = function(e) {
1527 return e
1528 }, t.d = function(e, n, i) {
1529 t.o(e, n) || Object.defineProperty(e, n, {
1530 configurable: !1,
1531 enumerable: !0,
1532 get: i
1533 })
1534 }, t.n = function(e) {
1535 var n = e && e.__esModule ? function() {
1536 return e.default
1537 } : function() {
1538 return e
1539 };
1540 return t.d(n, "a", n), n
1541 }, t.o = function(e, t) {
1542 return Object.prototype.hasOwnProperty.call(e, t)
1543 }, t.p = "/assets/", t(t.s = 1)
1544 }([, function(e, t, n) {
1545 function i(e) {
1546 return !!(e && e.timing && e.getEntriesByType && e.setResourceTimingBufferSize && e.clearResourceTimings)
1547 }
1548 Object.defineProperty(t, "__esModule", {
1549 value: !0
1550 }), t.isSniffingAllowed = i, n.d(t, "NetworkSniffer", function() {
1551 return s
1552 });
1553 var s = function() {
1554 function e(e, t) {
1555 this.performance = e, this.frameURL = t, this.resourceEntriesIndex = 0, this.resourceListeners = [], this.startCalled = !1, console.assert(i(e), "performance object does not support sniffing")
1556 }
1557 return e.prototype.start = function() {
1558 return !this.startCalled && (this.startCalled = !0, this.setResourceBufferSize(), setInterval(this.processNewResourceTimings.bind(this), 1e3), !0)
1559 }, e.prototype.getFrameTiming = function() {
1560 return this.performance.timing
1561 }, e.prototype.getAvailableResourceTimings = function() {
1562 return this.performance.getEntriesByType("resource")
1563 }, e.prototype.addResourceListener = function(e) {
1564 this.resourceListeners.push(e)
1565 }, e.prototype.removeResourceListener = function(e) {
1566 this.resourceListeners = this.resourceListeners.filter(function(t) {
1567 return t !== e
1568 })
1569 }, e.prototype.setResourceBufferSize = function() {
1570 this.performance.setResourceTimingBufferSize(1e3)
1571 }, e.prototype.clearResourceBuffer = function() {
1572 this.resourceEntriesIndex = 0, this.performance.clearResourceTimings(), this.setResourceBufferSize()
1573 }, e.prototype.isResourceBufferAlmostFull = function() {
1574 return this.performance.getEntriesByType("resource").length >= 750
1575 }, e.prototype.processNewResourceTimings = function() {
1576 var e = this;
1577 this.performance.getEntriesByType("resource").slice(this.resourceEntriesIndex).forEach(function(t) {
1578 e.resourceEntriesIndex++, e.fireResourceListeners(t)
1579 }), this.isResourceBufferAlmostFull() && this.clearResourceBuffer()
1580 }, e.prototype.fireResourceListeners = function(e) {
1581 this.resourceListeners.forEach(function(t) {
1582 t(e)
1583 })
1584 }, e
1585 }()
1586 }])
1587 })
1588 }).call(t, n(23)(e))
1589}, function(e, t, n) {
1590 "use strict";
1591 e.exports = function(e) {
1592 return e.webpackPolyfill || (e.deprecate = function() {}, e.paths = [], e.children || (e.children = []), Object.defineProperty(e, "loaded", {
1593 enumerable: !0,
1594 get: function() {
1595 return e.l
1596 }
1597 }), Object.defineProperty(e, "id", {
1598 enumerable: !0,
1599 get: function() {
1600 return e.i
1601 }
1602 }), e.webpackPolyfill = 1), e
1603 }
1604}, function(e, t, n) {
1605 "use strict";
1606 var i = n(25);
1607 n.d(t, "a", function() {
1608 return i.a
1609 })
1610}, function(e, t, n) {
1611 "use strict";
1612 n.d(t, "a", function() {
1613 return r
1614 });
1615 var i = n(0),
1616 s = (n.n(i), n(5)),
1617 r = function() {
1618 function e() {
1619 var e = this;
1620 this.callbacks = {}, this.onControllerMessage = function(t) {
1621 switch (t.action) {
1622 case i.FunctionAction.FollowComplete:
1623 var n = e.callbacks[i.FunctionAction.FollowComplete];
1624 n && n(t.didFollow, t.channel);
1625 break;
1626 case i.FunctionAction.SubscribeToChannelResult:
1627 var s = e.callbacks[i.FunctionAction.SubscribeToChannelResult];
1628 s && s({
1629 didSubscribe: t.payload.didSubscribe,
1630 errorCode: t.payload.errorCode
1631 })
1632 }
1633 }, this.followChannel = function(e) {
1634 Object(s.d)({
1635 action: i.FunctionAction.FollowAction,
1636 payload: {
1637 channel: e
1638 }
1639 })
1640 }, this.minimize = function() {
1641 Object(s.d)({
1642 action: i.FunctionAction.TwitchExtMinimize
1643 })
1644 }, this.requestIdShare = function() {
1645 Object(s.d)({
1646 action: i.FunctionAction.IdShareRequest
1647 })
1648 }, this.subscribeToChannel = function(e) {
1649 Object(s.d)({
1650 action: i.FunctionAction.SubscribeToChannel,
1651 payload: e
1652 })
1653 }, this.onFollow = function(t) {
1654 e.callbacks[i.FunctionAction.FollowComplete] = t
1655 }, this.onSubscribe = function(t) {
1656 e.callbacks[i.FunctionAction.SubscribeToChannelResult] = t
1657 }
1658 }
1659 return Object.defineProperty(e.prototype, "publicAPI", {
1660 get: function() {
1661 return {
1662 followChannel: this.followChannel,
1663 onFollow: this.onFollow,
1664 minimize: this.minimize,
1665 requestIdShare: this.requestIdShare,
1666 subscribeToChannel: this.subscribeToChannel,
1667 onSubscribe: this.onSubscribe
1668 }
1669 },
1670 enumerable: !0,
1671 configurable: !0
1672 }), e
1673 }()
1674}, function(e, t, n) {
1675 "use strict";
1676 var i = n(27);
1677 n.d(t, "a", function() {
1678 return i.a
1679 })
1680}, function(e, t, n) {
1681 "use strict";
1682 n.d(t, "a", function() {
1683 return r
1684 });
1685 var i = n(0),
1686 s = (n.n(i), n(28)),
1687 r = (n.n(s), function() {
1688 function e() {
1689 var e = this;
1690 this.authData = null, this.useLoopback = !1, this.onControllerMessage = function(t) {
1691 switch (t.action) {
1692 case i.ExtensionAction.TwitchExtBitsTransactionComplete:
1693 e.onTransactionCompleteCallback && e.onTransactionCompleteCallback({
1694 product: t.product,
1695 transactionId: t.transactionId,
1696 userId: t.userId,
1697 displayName: t.displayName,
1698 initiator: t.initiator,
1699 transactionReceipt: t.transactionReceipt
1700 });
1701 break;
1702 case i.ExtensionAction.TwitchExtBitsProducts:
1703 e.setProducts(t.products);
1704 break;
1705 case i.FunctionAction.UseBitsComplete:
1706 (!t.didConfirm || !t.didUseBits) && e.onTransactionCancelledCallback && e.onTransactionCancelledCallback()
1707 }
1708 }, this.showBitsBalance = function() {
1709 window.parent.postMessage({
1710 action: i.ExtensionAction.TwitchExtBitsOnHover
1711 }, "*")
1712 }, this.useBits = function(t) {
1713 e.useLoopback ? e.loopbackUseBits(t) : window.parent.postMessage({
1714 action: i.ExtensionAction.TwitchExtUseBits,
1715 sku: t
1716 }, "*")
1717 }, this.onTransactionComplete = function(t) {
1718 e.onTransactionCompleteCallback = t
1719 }, this.onTransactionCancelled = function(t) {
1720 e.onTransactionCancelledCallback = t
1721 }, this.getProducts = function() {
1722 return e.bitsProducts
1723 }, this.setUseLoopback = function(t) {
1724 e.useLoopback = t
1725 }, this.loopbackUseBits = function(t) {
1726 var n = e.authData ? e.authData.userId : "0",
1727 i = n + "." + (new Date).valueOf(),
1728 r = {
1729 transactionId: i,
1730 product: {
1731 sku: t,
1732 displayName: "test SKU",
1733 cost: {
1734 amount: "1",
1735 type: "bits"
1736 }
1737 },
1738 userId: n,
1739 displayName: "bits user",
1740 initiator: s.Initiator.CurrentUser
1741 };
1742 window.setTimeout(function() {
1743 e.onTransactionCompleteCallback && e.onTransactionCompleteCallback(r)
1744 }, 1e3)
1745 }, this.setupBitsProducts()
1746 }
1747 return Object.defineProperty(e.prototype, "publicAPI", {
1748 get: function() {
1749 return {
1750 getProducts: this.getProducts,
1751 useBits: this.useBits,
1752 onTransactionComplete: this.onTransactionComplete,
1753 onTransactionCancelled: this.onTransactionCancelled,
1754 showBitsBalance: this.showBitsBalance,
1755 setUseLoopback: this.setUseLoopback
1756 }
1757 },
1758 enumerable: !0,
1759 configurable: !0
1760 }), e.prototype.setAuth = function(e) {
1761 this.authData = e
1762 }, e.prototype.setupBitsProducts = function() {
1763 var e = this;
1764 this.bitsProducts = new Promise(function(t) {
1765 e.setProducts = t
1766 })
1767 }, e
1768 }())
1769}, function(e, t, n) {
1770 "use strict";
1771 Object.defineProperty(t, "__esModule", {
1772 value: !0
1773 }), t.ExtensionCoordinator = t.Initiator = void 0;
1774 var i = n(29),
1775 s = function(e) {
1776 if (e && e.__esModule) return e;
1777 var t = {};
1778 if (null != e)
1779 for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
1780 return t.default = e, t
1781 }(i),
1782 r = n(30),
1783 o = n(0),
1784 a = n(31),
1785 c = n(32),
1786 u = t.Initiator = void 0;
1787 ! function(e) {
1788 e.CurrentUser = "current_user", e.Other = "other"
1789 }(u || (t.Initiator = u = {}));
1790 var l = function(e) {
1791 function t(t) {
1792 var n = e.call(this) || this;
1793 return n.iframe = t, n.destroy = function() {
1794 n.iframe.ownerDocument.defaultView.removeEventListener("message", n.handleMessage)
1795 }, n.sendContext = function(e, t) {
1796 n.sendMessage({
1797 action: o.ExtensionAction.TwitchExtContext,
1798 context: e,
1799 updatedFields: t
1800 })
1801 }, n.sendExtensionAuth = function(e) {
1802 n.sendMessage({
1803 action: o.ExtensionAction.TwitchExtAuth,
1804 auth: e
1805 })
1806 }, n.sendExtensionBootstrap = function(e, t, i, s) {
1807 n.sendMessage({
1808 action: o.ExtensionAction.TwitchExtBootstrap,
1809 auth: e,
1810 features: t,
1811 configuration: i,
1812 viewerInfo: s
1813 })
1814 }, n.sendSupervisorInit = function(e) {
1815 n.sendMessage({
1816 action: o.SupervisorAction.SupervisorInit,
1817 options: e
1818 })
1819 }, n.sendFunctionReply = function(e) {
1820 n.sendMessage(e)
1821 }, n.sendExtensionReloadEntitlementsMessage = function() {
1822 n.sendMessage({
1823 action: o.ExtensionAction.TwitchExtReloadEntitlements
1824 })
1825 }, n.sendVisibilityChanged = function(e, t) {
1826 n.sendMessage({
1827 action: o.ExtensionAction.TwitchExtVisibilityChanged,
1828 isVisible: e,
1829 context: t
1830 })
1831 }, n.sendPositionChange = function(e) {
1832 n.sendMessage({
1833 action: o.ExtensionAction.TwitchExtPositionChanged,
1834 position: e
1835 })
1836 }, n.sendHighlightChange = function(e) {
1837 n.sendMessage({
1838 action: o.ExtensionAction.TwitchExtHighlightChanged,
1839 isHighlighted: e
1840 })
1841 }, n.sendBitsProductsMessage = function(e) {
1842 n.sendMessage({
1843 action: o.ExtensionAction.TwitchExtBitsProducts,
1844 products: e
1845 })
1846 }, n.sendBitsTransactionCompleteMessage = function(e) {
1847 n.sendMessage(e)
1848 }, n.sendHelperPubsubMessage = function(e, t, i) {
1849 n.sendMessage({
1850 action: o.ExtensionAction.TwitchExtPubsubMessage,
1851 payload: {
1852 target: e,
1853 contentType: t,
1854 content: i
1855 }
1856 })
1857 }, n.sendHelperPubsubBindFailure = function(e, t) {
1858 n.sendMessage({
1859 action: o.ExtensionAction.TwitchExtPubsubBindFailure,
1860 payload: {
1861 target: e,
1862 error: t
1863 }
1864 })
1865 }, n.sendViewerUpdateMessage = function(e) {
1866 n.sendMessage({
1867 action: o.ExtensionAction.TwitchExtViewerUpdate,
1868 viewerInfo: e
1869 })
1870 }, n.handleMessage = function(e) {
1871 var t = e.source,
1872 i = e.data;
1873 if (t === n.iframe.contentWindow) try {
1874 n.handleExtensionAction(i)
1875 } catch (e) {}
1876 }, n.handleExtensionAction = function(e) {
1877 -1 !== o.ExtensionEventActions.indexOf(e.action) && n.emit(e.action, e)
1878 }, n.sendMessage = function(e) {
1879 n.iframe && n.iframe.contentWindow && n.iframe.contentWindow.postMessage(e, a.supervisor.supervisorOrigin)
1880 }, n.iframe.ownerDocument.defaultView.addEventListener("message", n.handleMessage), n
1881 }
1882 return s.__extends(t, e), t.prototype.sendExtensionReloadMessage = function() {
1883 this.sendMessage({
1884 action: o.ExtensionAction.TwitchExtReload
1885 })
1886 }, t.prototype.sendExtensionProductPricesMessage = function(e) {
1887 var t = e.products.reduce(function(e, t) {
1888 var n = t.sku,
1889 i = t.price;
1890 return e[n] = {
1891 displayPrice: (0, c.formatPrice)(i.price, i.currency_unit)
1892 }, e
1893 }, {});
1894 this.sendMessage({
1895 action: o.ExtensionAction.TwitchExtProductPrices,
1896 prices: t
1897 })
1898 }, t
1899 }(r.EventEmitter);
1900 t.ExtensionCoordinator = l
1901}, function(e, t, n) {
1902 "use strict";
1903
1904 function i(e, t) {
1905 function n() {
1906 this.constructor = e
1907 }
1908 k(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n)
1909 }
1910
1911 function s(e, t) {
1912 var n = {};
1913 for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && t.indexOf(i) < 0 && (n[i] = e[i]);
1914 if (null != e && "function" == typeof Object.getOwnPropertySymbols)
1915 for (var s = 0, i = Object.getOwnPropertySymbols(e); s < i.length; s++) t.indexOf(i[s]) < 0 && (n[i[s]] = e[i[s]]);
1916 return n
1917 }
1918
1919 function r(e, t, n, i) {
1920 var s, r = arguments.length,
1921 o = r < 3 ? t : null === i ? i = Object.getOwnPropertyDescriptor(t, n) : i;
1922 if ("object" === ("undefined" == typeof Reflect ? "undefined" : w(Reflect)) && "function" == typeof Reflect.decorate) o = Reflect.decorate(e, t, n, i);
1923 else
1924 for (var a = e.length - 1; a >= 0; a--)(s = e[a]) && (o = (r < 3 ? s(o) : r > 3 ? s(t, n, o) : s(t, n)) || o);
1925 return r > 3 && o && Object.defineProperty(t, n, o), o
1926 }
1927
1928 function o(e, t) {
1929 return function(n, i) {
1930 t(n, i, e)
1931 }
1932 }
1933
1934 function a(e, t) {
1935 if ("object" === ("undefined" == typeof Reflect ? "undefined" : w(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t)
1936 }
1937
1938 function c(e, t, n, i) {
1939 return new(n || (n = Promise))(function(s, r) {
1940 function o(e) {
1941 try {
1942 c(i.next(e))
1943 } catch (e) {
1944 r(e)
1945 }
1946 }
1947
1948 function a(e) {
1949 try {
1950 c(i.throw(e))
1951 } catch (e) {
1952 r(e)
1953 }
1954 }
1955
1956 function c(e) {
1957 e.done ? s(e.value) : new n(function(t) {
1958 t(e.value)
1959 }).then(o, a)
1960 }
1961 c((i = i.apply(e, t || [])).next())
1962 })
1963 }
1964
1965 function u(e, t) {
1966 function n(e) {
1967 return function(t) {
1968 return i([e, t])
1969 }
1970 }
1971
1972 function i(n) {
1973 if (s) throw new TypeError("Generator is already executing.");
1974 for (; c;) try {
1975 if (s = 1, r && (o = 2 & n[0] ? r.return : n[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, n[1])).done) return o;
1976 switch (r = 0, o && (n = [2 & n[0], o.value]), n[0]) {
1977 case 0:
1978 case 1:
1979 o = n;
1980 break;
1981 case 4:
1982 return c.label++, {
1983 value: n[1],
1984 done: !1
1985 };
1986 case 5:
1987 c.label++, r = n[1], n = [0];
1988 continue;
1989 case 7:
1990 n = c.ops.pop(), c.trys.pop();
1991 continue;
1992 default:
1993 if (o = c.trys, !(o = o.length > 0 && o[o.length - 1]) && (6 === n[0] || 2 === n[0])) {
1994 c = 0;
1995 continue
1996 }
1997 if (3 === n[0] && (!o || n[1] > o[0] && n[1] < o[3])) {
1998 c.label = n[1];
1999 break
2000 }
2001 if (6 === n[0] && c.label < o[1]) {
2002 c.label = o[1], o = n;
2003 break
2004 }
2005 if (o && c.label < o[2]) {
2006 c.label = o[2], c.ops.push(n);
2007 break
2008 }
2009 o[2] && c.ops.pop(), c.trys.pop();
2010 continue
2011 }
2012 n = t.call(e, c)
2013 } catch (e) {
2014 n = [6, e], r = 0
2015 } finally {
2016 s = o = 0
2017 }
2018 if (5 & n[0]) throw n[1];
2019 return {
2020 value: n[0] ? n[1] : void 0,
2021 done: !0
2022 }
2023 }
2024 var s, r, o, a, c = {
2025 label: 0,
2026 sent: function() {
2027 if (1 & o[0]) throw o[1];
2028 return o[1]
2029 },
2030 trys: [],
2031 ops: []
2032 };
2033 return a = {
2034 next: n(0),
2035 throw: n(1),
2036 return: n(2)
2037 }, "function" == typeof Symbol && (a[Symbol.iterator] = function() {
2038 return this
2039 }), a
2040 }
2041
2042 function l(e, t) {
2043 for (var n in e) t.hasOwnProperty(n) || (t[n] = e[n])
2044 }
2045
2046 function h(e) {
2047 var t = "function" == typeof Symbol && e[Symbol.iterator],
2048 n = 0;
2049 return t ? t.call(e) : {
2050 next: function() {
2051 return e && n >= e.length && (e = void 0), {
2052 value: e && e[n++],
2053 done: !e
2054 }
2055 }
2056 }
2057 }
2058
2059 function f(e, t) {
2060 var n = "function" == typeof Symbol && e[Symbol.iterator];
2061 if (!n) return e;
2062 var i, s, r = n.call(e),
2063 o = [];
2064 try {
2065 for (;
2066 (void 0 === t || t-- > 0) && !(i = r.next()).done;) o.push(i.value)
2067 } catch (e) {
2068 s = {
2069 error: e
2070 }
2071 } finally {
2072 try {
2073 i && !i.done && (n = r.return) && n.call(r)
2074 } finally {
2075 if (s) throw s.error
2076 }
2077 }
2078 return o
2079 }
2080
2081 function d() {
2082 for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(f(arguments[t]));
2083 return e
2084 }
2085
2086 function p(e) {
2087 return this instanceof p ? (this.v = e, this) : new p(e)
2088 }
2089
2090 function _(e, t, n) {
2091 function i(e) {
2092 l[e] && (u[e] = function(t) {
2093 return new Promise(function(n, i) {
2094 h.push([e, t, n, i]) > 1 || s(e, t)
2095 })
2096 })
2097 }
2098
2099 function s(e, t) {
2100 try {
2101 r(l[e](t))
2102 } catch (e) {
2103 c(h[0][3], e)
2104 }
2105 }
2106
2107 function r(e) {
2108 e.value instanceof p ? Promise.resolve(e.value.v).then(o, a) : c(h[0][2], e)
2109 }
2110
2111 function o(e) {
2112 s("next", e)
2113 }
2114
2115 function a(e) {
2116 s("throw", e)
2117 }
2118
2119 function c(e, t) {
2120 e(t), h.shift(), h.length && s(h[0][0], h[0][1])
2121 }
2122 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2123 var u, l = n.apply(e, t || []),
2124 h = [];
2125 return u = {}, i("next"), i("throw"), i("return"), u[Symbol.asyncIterator] = function() {
2126 return this
2127 }, u
2128 }
2129
2130 function v(e) {
2131 function t(t, s) {
2132 n[t] = e[t] ? function(n) {
2133 return (i = !i) ? {
2134 value: p(e[t](n)),
2135 done: "return" === t
2136 } : s ? s(n) : n
2137 } : s
2138 }
2139 var n, i;
2140 return n = {}, t("next"), t("throw", function(e) {
2141 throw e
2142 }), t("return"), n[Symbol.iterator] = function() {
2143 return this
2144 }, n
2145 }
2146
2147 function b(e) {
2148 function t(t) {
2149 i[t] = e[t] && function(i) {
2150 return new Promise(function(s, r) {
2151 i = e[t](i), n(s, r, i.done, i.value)
2152 })
2153 }
2154 }
2155
2156 function n(e, t, n, i) {
2157 Promise.resolve(i).then(function(t) {
2158 e({
2159 value: t,
2160 done: n
2161 })
2162 }, t)
2163 }
2164 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2165 var i, s = e[Symbol.asyncIterator];
2166 return s ? s.call(e) : (e = "function" == typeof h ? h(e) : e[Symbol.iterator](), i = {}, t("next"), t("throw"), t("return"), i[Symbol.asyncIterator] = function() {
2167 return this
2168 }, i)
2169 }
2170
2171 function g(e, t) {
2172 return Object.defineProperty ? Object.defineProperty(e, "raw", {
2173 value: t
2174 }) : e.raw = t, e
2175 }
2176
2177 function y(e) {
2178 if (e && e.__esModule) return e;
2179 var t = {};
2180 if (null != e)
2181 for (var n in e) Object.hasOwnProperty.call(e, n) && (t[n] = e[n]);
2182 return t.default = e, t
2183 }
2184
2185 function m(e) {
2186 return e && e.__esModule ? e : {
2187 default: e
2188 }
2189 }
2190 Object.defineProperty(t, "__esModule", {
2191 value: !0
2192 });
2193 var w = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
2194 return typeof e
2195 } : function(e) {
2196 return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
2197 };
2198 t.__extends = i, t.__rest = s, t.__decorate = r, t.__param = o, t.__metadata = a, t.__awaiter = c, t.__generator = u, t.__exportStar = l, t.__values = h, t.__read = f, t.__spread = d, t.__await = p, t.__asyncGenerator = _, t.__asyncDelegator = v, t.__asyncValues = b, t.__makeTemplateObject = g, t.__importStar = y, t.__importDefault = m;
2199 /*! *****************************************************************************
2200 Copyright (c) Microsoft Corporation. All rights reserved.
2201 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
2202 this file except in compliance with the License. You may obtain a copy of the
2203 License at http://www.apache.org/licenses/LICENSE-2.0
2204
2205 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2206 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
2207 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
2208 MERCHANTABLITY OR NON-INFRINGEMENT.
2209
2210 See the Apache Version 2.0 License for specific language governing permissions
2211 and limitations under the License.
2212 ***************************************************************************** */
2213 var k = function(e, t) {
2214 return (k = Object.setPrototypeOf || {
2215 __proto__: []
2216 }
2217 instanceof Array && function(e, t) {
2218 e.__proto__ = t
2219 } || function(e, t) {
2220 for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
2221 })(e, t)
2222 },
2223 E = function() {
2224 return t.__assign = E = Object.assign || function(e) {
2225 for (var t, n = 1, i = arguments.length; n < i; n++) {
2226 t = arguments[n];
2227 for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s])
2228 }
2229 return e
2230 }, E.apply(this, arguments)
2231 };
2232 t.__assign = E
2233}, function(e, t, n) {
2234 "use strict";
2235
2236 function i() {}
2237
2238 function s(e, t, n) {
2239 this.fn = e, this.context = t, this.once = n || !1
2240 }
2241
2242 function r(e, t, n, i, r) {
2243 if ("function" != typeof n) throw new TypeError("The listener must be a function");
2244 var o = new s(n, i || e, r),
2245 a = u ? u + t : t;
2246 return e._events[a] ? e._events[a].fn ? e._events[a] = [e._events[a], o] : e._events[a].push(o) : (e._events[a] = o, e._eventsCount++), e
2247 }
2248
2249 function o(e, t) {
2250 0 == --e._eventsCount ? e._events = new i : delete e._events[t]
2251 }
2252
2253 function a() {
2254 this._events = new i, this._eventsCount = 0
2255 }
2256 var c = Object.prototype.hasOwnProperty,
2257 u = "~";
2258 Object.create && (i.prototype = Object.create(null), (new i).__proto__ || (u = !1)), a.prototype.eventNames = function() {
2259 var e, t, n = [];
2260 if (0 === this._eventsCount) return n;
2261 for (t in e = this._events) c.call(e, t) && n.push(u ? t.slice(1) : t);
2262 return Object.getOwnPropertySymbols ? n.concat(Object.getOwnPropertySymbols(e)) : n
2263 }, a.prototype.listeners = function(e) {
2264 var t = u ? u + e : e,
2265 n = this._events[t];
2266 if (!n) return [];
2267 if (n.fn) return [n.fn];
2268 for (var i = 0, s = n.length, r = new Array(s); i < s; i++) r[i] = n[i].fn;
2269 return r
2270 }, a.prototype.listenerCount = function(e) {
2271 var t = u ? u + e : e,
2272 n = this._events[t];
2273 return n ? n.fn ? 1 : n.length : 0
2274 }, a.prototype.emit = function(e, t, n, i, s, r) {
2275 var o = u ? u + e : e;
2276 if (!this._events[o]) return !1;
2277 var a, c, l = this._events[o],
2278 h = arguments.length;
2279 if (l.fn) {
2280 switch (l.once && this.removeListener(e, l.fn, void 0, !0), h) {
2281 case 1:
2282 return l.fn.call(l.context), !0;
2283 case 2:
2284 return l.fn.call(l.context, t), !0;
2285 case 3:
2286 return l.fn.call(l.context, t, n), !0;
2287 case 4:
2288 return l.fn.call(l.context, t, n, i), !0;
2289 case 5:
2290 return l.fn.call(l.context, t, n, i, s), !0;
2291 case 6:
2292 return l.fn.call(l.context, t, n, i, s, r), !0
2293 }
2294 for (c = 1, a = new Array(h - 1); c < h; c++) a[c - 1] = arguments[c];
2295 l.fn.apply(l.context, a)
2296 } else {
2297 var f, d = l.length;
2298 for (c = 0; c < d; c++) switch (l[c].once && this.removeListener(e, l[c].fn, void 0, !0), h) {
2299 case 1:
2300 l[c].fn.call(l[c].context);
2301 break;
2302 case 2:
2303 l[c].fn.call(l[c].context, t);
2304 break;
2305 case 3:
2306 l[c].fn.call(l[c].context, t, n);
2307 break;
2308 case 4:
2309 l[c].fn.call(l[c].context, t, n, i);
2310 break;
2311 default:
2312 if (!a)
2313 for (f = 1, a = new Array(h - 1); f < h; f++) a[f - 1] = arguments[f];
2314 l[c].fn.apply(l[c].context, a)
2315 }
2316 }
2317 return !0
2318 }, a.prototype.on = function(e, t, n) {
2319 return r(this, e, t, n, !1)
2320 }, a.prototype.once = function(e, t, n) {
2321 return r(this, e, t, n, !0)
2322 }, a.prototype.removeListener = function(e, t, n, i) {
2323 var s = u ? u + e : e;
2324 if (!this._events[s]) return this;
2325 if (!t) return o(this, s), this;
2326 var r = this._events[s];
2327 if (r.fn) r.fn !== t || i && !r.once || n && r.context !== n || o(this, s);
2328 else {
2329 for (var a = 0, c = [], l = r.length; a < l; a++)(r[a].fn !== t || i && !r[a].once || n && r[a].context !== n) && c.push(r[a]);
2330 c.length ? this._events[s] = 1 === c.length ? c[0] : c : o(this, s)
2331 }
2332 return this
2333 }, a.prototype.removeAllListeners = function(e) {
2334 var t;
2335 return e ? (t = u ? u + e : e, this._events[t] && o(this, t)) : (this._events = new i, this._eventsCount = 0), this
2336 }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = u, a.EventEmitter = a, e.exports = a
2337}, function(e, t, n) {
2338 "use strict";
2339 Object.defineProperty(t, "__esModule", {
2340 value: !0
2341 });
2342 var i = function() {
2343 function e() {
2344 this.SUPERVISOR_LOCATION = {
2345 production: "https://supervisor.ext-twitch.tv",
2346 staging: "https://supervisor.ext-assets.internal.justin.tv"
2347 }, this.env = "production"
2348 }
2349 return Object.defineProperty(e.prototype, "environment", {
2350 get: function() {
2351 return this.env
2352 },
2353 set: function(e) {
2354 this.env = e
2355 },
2356 enumerable: !0,
2357 configurable: !0
2358 }), Object.defineProperty(e.prototype, "supervisorOrigin", {
2359 get: function() {
2360 return this.SUPERVISOR_LOCATION[this.env] || this.SUPERVISOR_LOCATION.production
2361 },
2362 enumerable: !0,
2363 configurable: !0
2364 }), Object.defineProperty(e.prototype, "supervisorURL", {
2365 get: function() {
2366 return this.supervisorOrigin + "/supervisor/v1/index.html"
2367 },
2368 enumerable: !0,
2369 configurable: !0
2370 }), e
2371 }();
2372 t.Supervisor = i;
2373 t.supervisor = new i
2374}, function(e, t, n) {
2375 "use strict";
2376
2377 function i(e, t) {
2378 return "USD" === t ? "$" + e : e + " " + t
2379 }
2380 Object.defineProperty(t, "__esModule", {
2381 value: !0
2382 }), t.formatPrice = i
2383}, function(e, t, n) {
2384 "use strict";
2385 var i = n(34);
2386 n.d(t, "a", function() {
2387 return i.a
2388 })
2389}, function(e, t, n) {
2390 "use strict";
2391 n.d(t, "a", function() {
2392 return a
2393 });
2394 var i, s = n(1),
2395 r = (n.n(s), n(5));
2396 ! function(e) {
2397 e.Broadcaster = "broadcaster", e.Developer = "developer", e.Global = "global"
2398 }(i || (i = {}));
2399 var o;
2400 ! function(e) {
2401 e.ConfigurationReceived = "configuration-received"
2402 }(o || (o = {}));
2403 var a = function() {
2404 function e(e) {
2405 var t = this;
2406 this.callbackEvents = e, this.authData = null, this.eventEmitter = new s.EventEmitter2, this.addConfigurationChangeListener = function(e) {
2407 t.eventEmitter.on(o.ConfigurationReceived, e)
2408 }, this.setConfiguration = function(e, n, i) {
2409 if (!t.authData) return void t.callbackEvents.emit(r.a.Error, new Error("Twitch.ext.configuration.set attempted before onAuthorized returned"));
2410 var s = new XMLHttpRequest;
2411 s.open("PUT", r.c.twitchAPIURL + "/v5/extensions/" + t.authData.clientId + "/configurations/", !0), s.setRequestHeader("Content-Type", "application/json"), s.setRequestHeader("Client-ID", t.authData.clientId), s.setRequestHeader("X-Requested-With", "helper"), s.setRequestHeader("Authorization", "Bearer " + t.authData.token), s.addEventListener("load", t.handleSetLoad), s.addEventListener("error", t.handleSetError), s.send(JSON.stringify({
2412 channel_id: t.authData.channelId,
2413 segment: e,
2414 version: n,
2415 content: i
2416 }))
2417 }, this.handleSetLoad = function(e) {
2418 var n = e.target;
2419 200 !== n.status && 204 !== n.status && t.callbackEvents.emit(r.a.Error, new Error("Twitch.ext.configuration.set failed: " + n.statusText))
2420 }, this.handleSetError = function(e) {
2421 var n = e.message || "Network error";
2422 t.callbackEvents.emit(r.a.Error, new Error(n || "Twitch.ext.configuration.set failed"))
2423 }
2424 }
2425 return Object.defineProperty(e.prototype, "publicAPI", {
2426 get: function() {
2427 var e = this;
2428 return {get onChanged() {
2429 return e.addConfigurationChangeListener
2430 },
2431 get set() {
2432 return e.setConfiguration
2433 },
2434 get broadcaster() {
2435 return e.broadcaster
2436 },
2437 get developer() {
2438 return e.developer
2439 },
2440 get global() {
2441 return e.global
2442 }
2443 }
2444 },
2445 enumerable: !0,
2446 configurable: !0
2447 }), e.prototype.initializeConfiguration = function(e) {
2448 void 0 === e && (e = {}), this.broadcaster = e.broadcaster, this.developer = e.developer, this.global = e.global, this.eventEmitter.emit(o.ConfigurationReceived)
2449 }, e.prototype.setAuth = function(e) {
2450 this.authData = e
2451 }, e
2452 }()
2453}, function(e, t, n) {
2454 "use strict";
2455 var i = n(36);
2456 n.d(t, "a", function() {
2457 return i.a
2458 })
2459}, function(e, t, n) {
2460 "use strict";
2461 n.d(t, "a", function() {
2462 return a
2463 });
2464 var i, s = n(1),
2465 r = (n.n(s), this && this.__assign || function() {
2466 return r = Object.assign || function(e) {
2467 for (var t, n = 1, i = arguments.length; n < i; n++) {
2468 t = arguments[n];
2469 for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s])
2470 }
2471 return e
2472 }, r.apply(this, arguments)
2473 }),
2474 o = ["isChatEnabled", "isBitsEnabled", "isSubscriptionStatusAvailable"];
2475 ! function(e) {
2476 e.ExternalChanged = "external-feature-changed"
2477 }(i || (i = {}));
2478 var a = function() {
2479 function e() {
2480 var e = this;
2481 this.eventEmitter = new s.EventEmitter2, this.featureFlags = {
2482 isChatEnabled: !1,
2483 isBitsEnabled: !1,
2484 isSubscriptionStatusAvailable: !1,
2485 useSharedPubsub: !1,
2486 bits: !1,
2487 sharePubsub: !1
2488 }, this.addFeatureChangeListener = function(t) {
2489 e.eventEmitter.on(i.ExternalChanged, t)
2490 }, this.updateFeatureFlags = function(t) {
2491 var n = Object.keys(t).filter(function(n) {
2492 return -1 !== o.indexOf(n) && t[n] !== e.featureFlags[n]
2493 });
2494 e.featureFlags = r({}, e.featureFlags, t), n.length && e.eventEmitter.emit(i.ExternalChanged, n)
2495 }
2496 }
2497 return Object.defineProperty(e.prototype, "publicAPI", {
2498 get: function() {
2499 var e = this;
2500 return {get isChatEnabled() {
2501 return e.featureFlags.isChatEnabled
2502 },
2503 get isBitsEnabled() {
2504 return e.featureFlags.isBitsEnabled
2505 },
2506 get isSubscriptionStatusAvailable() {
2507 return e.featureFlags.isSubscriptionStatusAvailable
2508 },
2509 get onChanged() {
2510 return e.addFeatureChangeListener
2511 }
2512 }
2513 },
2514 enumerable: !0,
2515 configurable: !0
2516 }), e.prototype.initializeFeatureFlags = function(e) {
2517 this.updateFeatureFlags(e)
2518 }, e.prototype.getFeatureFlag = function(e) {
2519 return this.featureFlags[e]
2520 }, e
2521 }()
2522}, function(e, t, n) {
2523 "use strict";
2524 n.d(t, "a", function() {
2525 return l
2526 });
2527 var i = n(1),
2528 s = (n.n(i), n(0)),
2529 r = (n.n(s), n(38)),
2530 o = n.n(r),
2531 a = n(46),
2532 c = n(9),
2533 u = n(5),
2534 l = function() {
2535 function e(e, t) {
2536 var n = this;
2537 this.features = e, this.callbackEvents = t, this.authData = null, this.listenQueue = [], this.sendQueue = [], this.targetListeners = new i.EventEmitter2, this.send = function(e, t, i) {
2538 var s = {
2539 target: e,
2540 contentType: t,
2541 message: i
2542 };
2543 if (!n.authData) return void n.sendQueue.push(s);
2544 n.sendToPubsub(s)
2545 }, this.listen = function(e, t) {
2546 var i = n.targetListeners.listeners(e),
2547 s = 0 !== i.length;
2548 if (-1 === i.indexOf(t) && n.targetListeners.addListener(e, t), !n.authData) return void n.listenQueue.push(e);
2549 s || n.listenToPubsub(e).catch(function() {
2550 n.targetListeners.removeListener(e, t)
2551 })
2552 }, this.unlisten = function(e, t) {
2553 n.targetListeners.removeListener(e, t), n.targetListeners.listeners(e).length || n.unlistenFromPubsub(e)
2554 }, this.handleSendLoad = function(e) {
2555 var t = e.target;
2556 200 !== t.status && 204 !== t.status && n.callbackEvents.emit(u.a.Error, new Error("sendToPubsub(signal) failed: " + t.statusText))
2557 }, this.handleSendError = function(e) {
2558 var t = e.message || "Network error";
2559 n.callbackEvents.emit(u.a.Error, new Error(t || "sendToPubsub(signal) failed"))
2560 }
2561 }
2562 return Object.defineProperty(e.prototype, "publicAPI", {
2563 get: function() {
2564 var e = this;
2565 return {get send() {
2566 return e.send
2567 },
2568 get listen() {
2569 return e.listen
2570 },
2571 get unlisten() {
2572 return e.unlisten
2573 }
2574 }
2575 },
2576 enumerable: !0,
2577 configurable: !0
2578 }), Object.defineProperty(e.prototype, "driver", {
2579 get: function() {
2580 return this.driverInstance || (this.driverInstance = o.a.getInstance(u.c.pubsubEnvironment), this.mockStatsBackend()), this.driverInstance
2581 },
2582 enumerable: !0,
2583 configurable: !0
2584 }), e.prototype.setAuth = function(e) {
2585 var t = this;
2586 this.authData = e, this.sendQueue.length && (this.sendQueue.forEach(function(e) {
2587 return t.sendToPubsub(e)
2588 }), this.sendQueue = []), this.listenQueue.length && this.listenQueue.forEach(function(e) {
2589 return t.listenToPubsub(e)
2590 })
2591 }, e.prototype.onControllerMessage = function(e) {
2592 switch (e.action) {
2593 case s.ExtensionAction.TwitchExtPubsubMessage:
2594 this.handleSharedPubsubMessage(e);
2595 break;
2596 case s.ExtensionAction.TwitchExtPubsubBindFailure:
2597 this.handleSharedPubsubFailure(e)
2598 }
2599 }, e.prototype.sendToPubsub = function(e) {
2600 if (!this.authData) return void this.callbackEvents.emit(u.a.Error, new Error("Twitch.ext.send attempted before onAuthorized returned"));
2601 var t = new XMLHttpRequest;
2602 t.open("POST", this.getSendRequestURL(), !0), t.setRequestHeader("Content-Type", "application/json"), t.setRequestHeader("Client-ID", this.authData.clientId), t.setRequestHeader("Authorization", "Bearer " + this.authData.token), t.addEventListener("load", this.handleSendLoad), t.addEventListener("error", this.handleSendError), t.send(this.getSendRequestBody(e))
2603 }, e.prototype.getSendRequestURL = function() {
2604 if (!this.authData) return "";
2605 switch (u.c.environment) {
2606 case c.a.Production:
2607 return u.c.twitchAPIURL + "/v5/extensions/message/" + this.authData.channelId;
2608 case c.a.Staging:
2609 return u.c.pubsubURL + "/v1/message";
2610 case c.a.Test:
2611 return "" + u.c.pubsubURL
2612 }
2613 return ""
2614 }, e.prototype.getSendRequestBody = function(e) {
2615 if (!this.authData) return "";
2616 var t = e.contentType,
2617 n = e.message;
2618 switch (e.message instanceof Object && (n = JSON.stringify(e.message), t = "application/json"), u.c.environment) {
2619 case c.a.Production:
2620 return JSON.stringify({
2621 auth: this.authData.token,
2622 content_type: t,
2623 message: n,
2624 targets: [e.target]
2625 });
2626 case c.a.Staging:
2627 return JSON.stringify({
2628 topics: ["channel-ext-v1." + this.authData.channelId + "-" + this.authData.clientId + "-" + e.target],
2629 data: JSON.stringify({
2630 content_type: e.contentType,
2631 content: [e.message],
2632 num_messages: 1,
2633 request_numbers: []
2634 })
2635 });
2636 case c.a.Test:
2637 return "test"
2638 }
2639 return ""
2640 }, e.prototype.getUseSharedPubsub = function() {
2641 return this.features.getFeatureFlag("sharePubsub") || this.features.getFeatureFlag("useSharedPubsub")
2642 }, e.prototype.handleSharedPubsubMessage = function(e) {
2643 var t = this,
2644 n = e.payload,
2645 i = n.target,
2646 s = n.contentType;
2647 n.content.forEach(function(e) {
2648 t.targetListeners.emit(i, i, s, e)
2649 })
2650 }, e.prototype.handleSharedPubsubFailure = function(e) {
2651 this.callbackEvents.emit(u.a.Error, new Error(e.payload.error))
2652 }, e.prototype.listenToPubsub = function(e) {
2653 var t = this;
2654 return new Promise(function(n, i) {
2655 return t.getUseSharedPubsub() ? (Object(u.d)({
2656 action: s.ExtensionAction.TwitchExtPubsubListen,
2657 target: e
2658 }), n()) : t.authData ? void t.driver.Listen({
2659 auth: t.authData.token,
2660 topic: t.targetToTopic(e),
2661 failure: i,
2662 success: n,
2663 message: function(n) {
2664 Object(a.a)(e) || t.targetListeners.emit(e, e, "application/plain", n);
2665 var i;
2666 try {
2667 i = JSON.parse(n)
2668 } catch (e) {
2669 return void t.callbackEvents.emit(u.a.Error, new Error("ill-formed JSON response received"))
2670 }
2671 i.content.forEach(function(n) {
2672 t.targetListeners.emit(e, e, i.content_type, n)
2673 }), i.sequence && Object(u.d)({
2674 action: s.ExtensionAction.TwitchExtPubSubReceived,
2675 payload: {
2676 target: e,
2677 topic: t.targetToTopic(e),
2678 sequenceNumber: i.sequence.number,
2679 sequenceStart: i.sequence.start
2680 }
2681 })
2682 }
2683 }) : i()
2684 })
2685 }, e.prototype.unlistenFromPubsub = function(e) {
2686 var t = this;
2687 return new Promise(function(n, i) {
2688 if (t.getUseSharedPubsub()) return Object(u.d)({
2689 action: s.ExtensionAction.TwitchExtPubsubUnlisten,
2690 target: e
2691 }), n();
2692 t.driver.Unlisten({
2693 topic: t.targetToTopic(e),
2694 failure: i,
2695 success: n,
2696 message: a.b
2697 })
2698 })
2699 }, e.prototype.targetToTopic = function(e) {
2700 if (!this.authData) return "";
2701 if (Object(a.a)(e)) {
2702 var t = this.authData.channelId;
2703 return "global" === e && (t = "all"), "channel-ext-v1." + t + "-" + this.authData.clientId + "-" + e
2704 }
2705 return e
2706 }, e.prototype.mockStatsBackend = function() {
2707 this.driverInstance && (this.driverInstance._stats._backend = {
2708 logCounter: a.b,
2709 logGauge: a.b,
2710 logLine: a.b,
2711 logTimer: a.b,
2712 setPrefix: a.b
2713 })
2714 }, e
2715 }()
2716}, function(e, t, n) {
2717 "use strict";
2718
2719 function i(e) {
2720 return e && e.__esModule ? e : {
2721 default: e
2722 }
2723 }
2724
2725 function s(e, t) {
2726 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
2727 }
2728
2729 function r(e, t) {
2730 if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2731 return !t || "object" != typeof t && "function" != typeof t ? e : t
2732 }
2733
2734 function o(e, t) {
2735 if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
2736 e.prototype = Object.create(t && t.prototype, {
2737 constructor: {
2738 value: e,
2739 enumerable: !1,
2740 writable: !0,
2741 configurable: !0
2742 }
2743 }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
2744 }
2745
2746 function a(e) {
2747 if ("production" !== e && "staging" !== e && "darklaunch" !== e) throw "Invalid Pubsub instance environment";
2748 return null === window.__Twitch__pubsubInstances[e] && (window.__Twitch__pubsubInstances[e] = new P(e)), window.__Twitch__pubsubInstances[e]
2749 }
2750 Object.defineProperty(t, "__esModule", {
2751 value: !0
2752 });
2753 var c = function() {
2754 function e(e, t) {
2755 for (var n = 0; n < t.length; n++) {
2756 var i = t[n];
2757 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
2758 }
2759 }
2760 return function(t, n, i) {
2761 return n && e(t.prototype, n), i && e(t, i), t
2762 }
2763 }(),
2764 u = n(6),
2765 l = i(u),
2766 h = n(2),
2767 f = i(h),
2768 d = n(3),
2769 p = i(d),
2770 _ = n(39),
2771 v = i(_),
2772 b = n(40),
2773 g = i(b),
2774 y = n(41),
2775 m = i(y),
2776 w = n(43),
2777 k = n(45),
2778 E = i(k),
2779 x = f.default._getLogger("PubsubDriver"),
2780 T = 3e4,
2781 O = /^https?:\/\/([\w-]+\.)*twitch\.(tv|tech)(:\d+)?\/.*$/,
2782 S = 1,
2783 P = function(e) {
2784 function t(e) {
2785 s(this, t);
2786 var n = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
2787 return n._env = p.default.urlParams.pubsub_environment || e, n._clientReady = !1, n._hasDisconnected = !1, n._queuedRequests = [], n._stats = w.Stats.getInstance(n._env, "pubsub-js-client"), n._numDisconnects = 0, p.default.inIframe() && O.test(document.referrer) ? (x.debug("Driver is in an iframe"), n._client = new v.default({
2788 parentUrl: document.referrer
2789 }), n._clientType = "iframe-verified") : (x.debug("Driver is not in an iframe"), n._client = new m.default({
2790 env: n._env,
2791 stats: n._stats
2792 }), n._iframeHost = new g.default(n._client), n._clientType = "ws"), n._stats.setPrefix("pubsub-js-client." + n._clientType), "true" === p.default.urlParams.force_pubsub_tester ? S = 1 : "false" === p.default.urlParams.force_pubsub_tester && (S = 0), Math.random() < S && window.setTimeout(n.runTest.bind(n), T), n._client.on("unverified", n._clientUnverified, n), n._client.on("verified", n._clientVerified, n), n._client.verify(), n
2793 }
2794 return o(t, e), c(t, [{
2795 key: "runTest",
2796 value: function() {
2797 this._tester = new E.default({
2798 env: this._env,
2799 driver: this,
2800 stats: this._stats
2801 })
2802 }
2803 }, {
2804 key: "connect",
2805 value: function() {}
2806 }, {
2807 key: "Listen",
2808 value: function(e) {
2809 this._clientReady ? this._client.Listen(e) : this._queuedRequests.push({
2810 type: "LISTEN",
2811 opts: e
2812 })
2813 }
2814 }, {
2815 key: "Unlisten",
2816 value: function(e) {
2817 this._clientReady ? this._client.Unlisten(e) : this._queuedRequests.push({
2818 type: "UNLISTEN",
2819 opts: e
2820 })
2821 }
2822 }, {
2823 key: "_flushQueuedRequests",
2824 value: function() {
2825 for (x.debug("Flushing " + this._queuedRequests.length + " queued requests"); this._queuedRequests.length > 0;) {
2826 var e = this._queuedRequests.shift();
2827 switch (e.type) {
2828 case "LISTEN":
2829 this._client.Listen(e.opts);
2830 break;
2831 case "UNLISTEN":
2832 this._client.Unlisten(e.opts)
2833 }
2834 }
2835 }
2836 }, {
2837 key: "_clientConnected",
2838 value: function() {
2839 x.debug("Client connected"), this._client.on("disconnected", this._clientDisconnected, this), this._stats.logCounter("connected", 1), this._trigger("connected"), this._hasDisconnected && this._trigger("reconnected"), this._clientReady = !0, this._flushQueuedRequests()
2840 }
2841 }, {
2842 key: "_clientDisconnected",
2843 value: function() {
2844 x.debug("Client disconnected"), this._trigger("disconnected"), this._clientReady = !1, this._numDisconnects += 1, this._hasDisconnected = !0
2845 }
2846 }, {
2847 key: "_clientVerified",
2848 value: function() {
2849 x.debug("Client verified (type = " + this._clientType + ")"), this._stats.setPrefix("pubsub-js-client." + this._clientType), this._client.on("connected", this._clientConnected, this), this._client.connect(), window.setInterval(this._sendClientTypeGauge.bind(this), 6e4)
2850 }
2851 }, {
2852 key: "_clientUnverified",
2853 value: function() {
2854 x.debug("Unverified IframeClient"), this._client.off("verified", this._clientVerified, this), this._client.off("unverified", this._clientUnverified, this), this._client = new m.default({
2855 env: this._env,
2856 stats: this._stats
2857 }), this._clientType = "iframe-unverified", this._client.on("unverified", this._clientUnverified, this), this._client.on("verified", this._clientVerified, this), this._client.verify()
2858 }
2859 }, {
2860 key: "_sendClientTypeGauge",
2861 value: function() {
2862 this._stats.logGauge("pubsub-js-client." + this._clientType)
2863 }
2864 }]), t
2865 }(l.default);
2866 window.__Twitch__pubsubInstances = window.__Twitch__pubsubInstances || {
2867 production: null,
2868 staging: null,
2869 darklaunch: null
2870 }, t.default = {
2871 getInstance: a
2872 }
2873}, function(e, t, n) {
2874 "use strict";
2875
2876 function i(e) {
2877 return e && e.__esModule ? e : {
2878 default: e
2879 }
2880 }
2881
2882 function s(e, t) {
2883 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
2884 }
2885
2886 function r(e, t) {
2887 if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2888 return !t || "object" != typeof t && "function" != typeof t ? e : t
2889 }
2890
2891 function o(e, t) {
2892 if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
2893 e.prototype = Object.create(t && t.prototype, {
2894 constructor: {
2895 value: e,
2896 enumerable: !1,
2897 writable: !0,
2898 configurable: !0
2899 }
2900 }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
2901 }
2902 Object.defineProperty(t, "__esModule", {
2903 value: !0
2904 });
2905 var a = function() {
2906 function e(e, t) {
2907 for (var n = 0; n < t.length; n++) {
2908 var i = t[n];
2909 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
2910 }
2911 }
2912 return function(t, n, i) {
2913 return n && e(t.prototype, n), i && e(t, i), t
2914 }
2915 }(),
2916 c = n(6),
2917 u = i(c),
2918 l = n(2),
2919 h = i(l),
2920 f = n(3),
2921 d = i(f),
2922 p = n(10),
2923 _ = i(p),
2924 v = h.default._getLogger("IframeClient"),
2925 b = function(e) {
2926 function t(e) {
2927 s(this, t);
2928 var n = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
2929 return n._parentUrl = e.parentUrl, n._pendingResponses = new _.default, n._listens = new u.default, window.addEventListener("message", n.receiveMessage.bind(n), !1), n
2930 }
2931 return o(t, e), a(t, [{
2932 key: "connect",
2933 value: function() {
2934 window.parent.postMessage({
2935 twitch_protocol: "pubsub",
2936 type: "connect"
2937 }, this._parentUrl)
2938 }
2939 }, {
2940 key: "verify",
2941 value: function() {
2942 window.parent.postMessage({
2943 twitch_protocol: "pubsub",
2944 type: "verify"
2945 }, this._parentUrl), this._verifyTimeout = setTimeout(this._unverified.bind(this), 1e3)
2946 }
2947 }, {
2948 key: "Listen",
2949 value: function(e) {
2950 v.debug("listening on " + e.topic);
2951 var t = this._generateNonce(),
2952 n = {
2953 twitch_protocol: "pubsub",
2954 type: "LISTEN",
2955 nonce: t,
2956 data: {
2957 topics: [e.topic],
2958 auth_token: e.auth
2959 }
2960 };
2961 this._send(t, n, e)
2962 }
2963 }, {
2964 key: "Unlisten",
2965 value: function(e) {
2966 if (v.debug("unlistening on " + e.topic + "(" + this._listens.count(e.topic) + " listeners)"), this._listens.count(e.topic) > 1) return e.message && this._listens.off(e.topic, e.message), e.success && e.success(), void v.debug("now have " + this._listens.count(e.topic) + " listeners");
2967 var t = this._generateNonce(),
2968 n = {
2969 twitch_protocol: "pubsub",
2970 type: "UNLISTEN",
2971 nonce: t,
2972 data: {
2973 topics: [e.topic]
2974 }
2975 };
2976 this._send(t, n, e)
2977 }
2978 }, {
2979 key: "_send",
2980 value: function(e, t, n) {
2981 this._pendingResponses.set(e, {
2982 timeout: setTimeout(this._onResponseTimeout.bind(this), 3e4, e),
2983 topic: n.topic,
2984 auth: n.auth,
2985 message: t,
2986 callbacks: {
2987 success: n.success,
2988 failure: n.failure,
2989 message: n.message
2990 }
2991 }), window.parent.postMessage(t, this._parentUrl)
2992 }
2993 }, {
2994 key: "receiveMessage",
2995 value: function(e) {
2996 if (e.data && "pubsub" == e.data.twitch_protocol) switch (v.debug("Received message: " + JSON.stringify(e.data)), e.data.type) {
2997 case "connected":
2998 this._trigger("connected");
2999 break;
3000 case "disconnected":
3001 this._trigger("disconnected");
3002 break;
3003 case "success":
3004 this.handleResponse(!0, e.data);
3005 break;
3006 case "failure":
3007 this.handleResponse(!1, e.data);
3008 break;
3009 case "message":
3010 this.handleMessage(e.data.topic, e.data.message);
3011 break;
3012 case "verify":
3013 this._verified()
3014 }
3015 }
3016 }, {
3017 key: "handleResponse",
3018 value: function(e, t) {
3019 if (this._pendingResponses.has(t.nonce)) {
3020 var n = this._pendingResponses.get(t.nonce);
3021 v.debug("ResponseInfo: " + JSON.stringify(n)), clearTimeout(n.timeout), this._pendingResponses.remove(t.nonce), e ? (n.callbacks.message && ("LISTEN" === n.message.type ? this._listens.on(n.topic, n.callbacks.message, this) : "UNLISTEN" === n.message.type && this._listens.off(n.topic, n.callbacks.message, this)), n.callbacks.success && n.callbacks.success()) : n.callbacks.failure && n.callbacks.failure(t.error)
3022 }
3023 }
3024 }, {
3025 key: "handleMessage",
3026 value: function(e, t) {
3027 v.debug("received '" + t + "' on topic " + e), this._listens._trigger(e, t)
3028 }
3029 }, {
3030 key: "_onResponseTimeout",
3031 value: function(e) {
3032 v.debug("response timed out: " + e)
3033 }
3034 }, {
3035 key: "_verified",
3036 value: function() {
3037 v.debug("Verified"), clearTimeout(this._verifyTimeout), this._trigger("verified")
3038 }
3039 }, {
3040 key: "_unverified",
3041 value: function() {
3042 window.removeEventListener("message", this.receiveMessage.bind(this), !1), this._trigger("unverified")
3043 }
3044 }, {
3045 key: "_generateNonce",
3046 value: function() {
3047 return d.default.generateString(30)
3048 }
3049 }]), t
3050 }(u.default);
3051 t.default = b
3052}, function(e, t, n) {
3053 "use strict";
3054
3055 function i(e, t) {
3056 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
3057 }
3058 Object.defineProperty(t, "__esModule", {
3059 value: !0
3060 });
3061 var s = function() {
3062 function e(e, t) {
3063 for (var n = 0; n < t.length; n++) {
3064 var i = t[n];
3065 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
3066 }
3067 }
3068 return function(t, n, i) {
3069 return n && e(t.prototype, n), i && e(t, i), t
3070 }
3071 }(),
3072 r = n(2),
3073 o = function(e) {
3074 return e && e.__esModule ? e : {
3075 default: e
3076 }
3077 }(r),
3078 a = 1e4,
3079 c = o.default._getLogger("IframeHost"),
3080 u = function() {
3081 function e(t) {
3082 i(this, e), this._driver = t, this._sources = [], this._listeners = [], this._driver.on("connected", this.handleConnected, this), this._driver.on("disconnected", this.handleDisconnected, this), window.addEventListener("message", this.receiveMessage.bind(this), !1), this._orphanedListenerCheckTimer = setInterval(this._checkOrphanedListeners.bind(this), a)
3083 }
3084 return s(e, [{
3085 key: "destroy",
3086 value: function() {
3087 clearInterval(this._orphanedListenerCheckTimer)
3088 }
3089 }, {
3090 key: "receiveMessage",
3091 value: function(e) {
3092 if (e.data && "pubsub" == e.data.twitch_protocol && e.source) switch (c.debug("Received message: " + JSON.stringify(e.data)), e.data.type) {
3093 case "LISTEN":
3094 this.handleListen(e.source, e.data.nonce, e.data.data);
3095 break;
3096 case "UNLISTEN":
3097 this.handleUnlisten(e.source, e.data.nonce, e.data.data);
3098 break;
3099 case "connect":
3100 this._sources.push(e.source), this._driver.connect();
3101 break;
3102 case "verify":
3103 e.source.postMessage({
3104 twitch_protocol: "pubsub",
3105 type: "verify"
3106 }, "*")
3107 }
3108 }
3109 }, {
3110 key: "_pushListener",
3111 value: function(e, t) {
3112 for (var n = 0; n < this._listeners.length; n++)
3113 if (this._listeners[n].source === e && this._listeners[n].topic === t) return null;
3114 var i = {
3115 source: e,
3116 topic: t,
3117 message: function(n) {
3118 e.postMessage({
3119 twitch_protocol: "pubsub",
3120 type: "message",
3121 topic: t,
3122 message: n
3123 }, "*")
3124 }
3125 };
3126 return this._listeners.push(i), i
3127 }
3128 }, {
3129 key: "_popListener",
3130 value: function(e, t) {
3131 for (var n = 0; n < this._listeners.length; n++)
3132 if (this._listeners[n].source === e && this._listeners[n].topic === t) return this._listeners.splice(n, 1)[0];
3133 return null
3134 }
3135 }, {
3136 key: "_checkOrphanedListeners",
3137 value: function() {
3138 for (var e = 0; e < this._listeners.length; e++) this._listeners[e].source.closed && this._cleanUpOrphanedListener(this._listeners.splice(e--, 1)[0])
3139 }
3140 }, {
3141 key: "_cleanUpOrphanedListener",
3142 value: function(e) {
3143 c.debug("Cleaning up orphaned listener for topic: " + e.topic), this._driver.Unlisten({
3144 topic: e.topic,
3145 success: function() {
3146 c.debug("Success when cleaning up orphaned listener for topic: " + e.topic)
3147 },
3148 failure: function(t) {
3149 c.debug("Error when cleaning up orphaned listener for topic: " + e.topic + " Error: " + t)
3150 },
3151 message: e.message
3152 })
3153 }
3154 }, {
3155 key: "handleListen",
3156 value: function(e, t, n) {
3157 var i = this._pushListener(e, n.topics[0]);
3158 if (!i) return void e.postMessage({
3159 twitch_protocol: "pubsub",
3160 type: "success",
3161 nonce: t
3162 }, "*");
3163 this._driver.Listen({
3164 topic: i.topic,
3165 auth: n.auth_token,
3166 success: function() {
3167 e.postMessage({
3168 twitch_protocol: "pubsub",
3169 type: "success",
3170 nonce: t
3171 }, "*")
3172 },
3173 failure: function(n) {
3174 e.postMessage({
3175 twitch_protocol: "pubsub",
3176 type: "failure",
3177 nonce: t,
3178 error: n
3179 }, "*")
3180 },
3181 message: i.message
3182 })
3183 }
3184 }, {
3185 key: "handleUnlisten",
3186 value: function(e, t, n) {
3187 var i = this._popListener(e, n.topics[0]);
3188 if (!i) return void c.debug("Failed to unlisten, could not find listener for topic " + n.topics[0]);
3189 this._driver.Unlisten({
3190 topic: i.topic,
3191 auth: n.auth_token,
3192 success: function() {
3193 e.postMessage({
3194 twitch_protocol: "pubsub",
3195 type: "success",
3196 nonce: t
3197 }, "*")
3198 },
3199 failure: function(n) {
3200 e.postMessage({
3201 twitch_protocol: "pubsub",
3202 type: "failure",
3203 nonce: t,
3204 error: n
3205 }, "*")
3206 },
3207 message: i.message
3208 })
3209 }
3210 }, {
3211 key: "handleConnected",
3212 value: function() {
3213 for (var e = 0; e < this._sources.length; e++) this._sources[e].postMessage({
3214 twitch_protocol: "pubsub",
3215 type: "connected"
3216 }, "*")
3217 }
3218 }, {
3219 key: "handleDisconnected",
3220 value: function() {
3221 for (var e = 0; e < this._sources.length; e++) this._sources[e].postMessage({
3222 twitch_protocol: "pubsub",
3223 type: "disconnected"
3224 }, "*")
3225 }
3226 }]), e
3227 }();
3228 t.default = u
3229}, function(e, t, n) {
3230 "use strict";
3231
3232 function i(e) {
3233 return e && e.__esModule ? e : {
3234 default: e
3235 }
3236 }
3237
3238 function s(e, t) {
3239 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
3240 }
3241
3242 function r(e, t) {
3243 if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3244 return !t || "object" != typeof t && "function" != typeof t ? e : t
3245 }
3246
3247 function o(e, t) {
3248 if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
3249 e.prototype = Object.create(t && t.prototype, {
3250 constructor: {
3251 value: e,
3252 enumerable: !1,
3253 writable: !0,
3254 configurable: !0
3255 }
3256 }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
3257 }
3258 Object.defineProperty(t, "__esModule", {
3259 value: !0
3260 });
3261 var a = function() {
3262 function e(e, t) {
3263 for (var n = 0; n < t.length; n++) {
3264 var i = t[n];
3265 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
3266 }
3267 }
3268 return function(t, n, i) {
3269 return n && e(t.prototype, n), i && e(t, i), t
3270 }
3271 }(),
3272 c = n(6),
3273 u = i(c),
3274 l = n(2),
3275 h = i(l),
3276 f = n(3),
3277 d = i(f),
3278 p = n(42),
3279 _ = i(p),
3280 v = n(10),
3281 b = i(v),
3282 g = h.default._getLogger("WebsocketClient"),
3283 y = "wss://pubsub-edge.twitch.tv:443/v1",
3284 m = "wss://pubsub-edge-darklaunch.twitch.tv:443/v1",
3285 w = "ws://localhost:6900/v1",
3286 k = function(e) {
3287 function t(e) {
3288 s(this, t);
3289 var n = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
3290 switch (n._opts = e, n._env = e.env, n._stats = e.stats, n._env) {
3291 case "production":
3292 n._addr = y;
3293 break;
3294 case "darklaunch":
3295 n._addr = m;
3296 break;
3297 case "development":
3298 n._addr = w;
3299 break;
3300 default:
3301 n._addr = y
3302 }
3303 return window.WebSocket ? (n._queuedRequests = [], n._pendingResponses = new b.default, n._pendingReplayResponses = new b.default, n._listens = new u.default, n._replays = new b.default, n._replaysSize = 0, n._firstConnectTime = n._firstListenTime = 0, n._connectCalled = n._reconnecting = !1, n._primarySocket = new _.default({
3304 stats: n._stats,
3305 addr: n._addr
3306 }), n._bindPrimary(n._primarySocket), n) : r(n)
3307 }
3308 return o(t, e), a(t, [{
3309 key: "verify",
3310 value: function() {
3311 this._trigger("verified")
3312 }
3313 }, {
3314 key: "connect",
3315 value: function() {
3316 window.WebSocket && (this._connectCalled ? this._primarySocket._isReady() && this._trigger("connected") : (this._connectCalled = !0, this._primarySocket.connect()))
3317 }
3318 }, {
3319 key: "_bindPrimary",
3320 value: function(e) {
3321 e.on("open", this._onPrimaryOpen, this), e.on("response", this._onResponse, this), e.on("message", this._onMessage, this), e.on("reconnect", this._onReconnect, this), e.on("connection_failure", this._onConnectionFailure, this)
3322 }
3323 }, {
3324 key: "_unbindPrimary",
3325 value: function(e) {
3326 e.off("open", this._onPrimaryOpen, this), e.off("response", this._onResponse, this), e.off("message", this._onMessage, this), e.off("reconnect", this._onReconnect, this), e.off("connection_failure", this._onConnectionFailure, this)
3327 }
3328 }, {
3329 key: "_onPrimaryOpen",
3330 value: function() {
3331 g.debug("primary open: " + this._primarySocket._id), 0 === this._firstConnectTime && (this._firstConnectTime = d.default.time.now(), this._firstListenTimeout = setTimeout(this._neverListened.bind(this), 45e3)), this._connected = !0, this._trigger("connected"), this._flushQueuedRequests()
3332 }
3333 }, {
3334 key: "_onResponse",
3335 value: function(e) {
3336 if (g.debug("primary response: " + JSON.stringify(e)), this._pendingResponses.has(e.nonce)) {
3337 var t = this._pendingResponses.get(e.nonce);
3338 g.debug("responseInfo: " + JSON.stringify(t)), clearTimeout(t.timeout), this._pendingResponses.remove(e.nonce), "" === e.error ? ("LISTEN" === t.message.type ? (0 === this._firstListenTime && (clearTimeout(this._firstListenTimeout), this._firstListenTime = d.default.time.now(), this._stats.logTimer("time_to_first_listen", this._firstListenTime - this._firstConnectTime, .1)), this._replays.set(e.nonce, {
3339 nonce: e.nonce,
3340 message: t.callbacks.message,
3341 topic: t.topic,
3342 auth: t.auth
3343 }), t.callbacks.message && this._listens.on(t.topic, t.callbacks.message, this)) : "UNLISTEN" === t.message.type && (this._replays.remove(e.nonce), t.callbacks.message && this._listens.off(t.topic, t.callbacks.message, this)), t.callbacks.success && t.callbacks.success()) : t.callbacks.failure && t.callbacks.failure(e.error)
3344 }
3345 }
3346 }, {
3347 key: "_onResponseTimeout",
3348 value: function(e) {
3349 if (this._pendingResponses.has(e)) {
3350 var t = this._pendingResponses.get(e);
3351 this._pendingResponses.remove(e), t.callbacks.failure && t.callbacks.failure("response timeout")
3352 }
3353 }
3354 }, {
3355 key: "_onMessage",
3356 value: function(e) {
3357 g.debug("primary message: " + JSON.stringify(e)), this._listens._trigger(e.data.topic, e.data.message)
3358 }
3359 }, {
3360 key: "_onConnectionFailure",
3361 value: function() {
3362 g.debug("connection failure"), this._trigger("disconnected"), this._notifyWhenOpen = !0, this._onReconnect()
3363 }
3364 }, {
3365 key: "_onReconnect",
3366 value: function() {
3367 g.debug("reconnecting..."), this._reconnecting = !0, this._backupSocket = new _.default({
3368 stats: this._stats,
3369 addr: this._addr
3370 }), this._bindBackup(this._backupSocket), setTimeout(this._backupSocket.connect.bind(this._backupSocket), this._jitteredReconnectDelay())
3371 }
3372 }, {
3373 key: "_bindBackup",
3374 value: function(e) {
3375 e.on("open", this._onBackupOpen, this), e.on("response", this._onBackupResponse, this)
3376 }
3377 }, {
3378 key: "_unbindBackup",
3379 value: function(e) {
3380 e.off("open", this._onBackupOpen, this), e.off("response", this._onBackupResponse, this)
3381 }
3382 }, {
3383 key: "_onBackupOpen",
3384 value: function() {
3385 g.debug("Backup socket opened"), this._replays.size() > 0 ? this._replayBackup() : (this._swapSockets(), this._notifyWhenOpen && (g.debug("triggering connected"), this._notifyWhenOpen = !1, this._trigger("connected")))
3386 }
3387 }, {
3388 key: "_replayBackup",
3389 value: function() {
3390 for (var e = this._replays.values(), t = 0; t < e.length; t++) {
3391 var n = {
3392 type: "LISTEN",
3393 nonce: this._generateNonce(),
3394 data: {
3395 topics: [e[t].topic],
3396 auth_token: e[t].auth
3397 }
3398 };
3399 this._pendingReplayResponses.set(n.nonce, !0), this._backupSocket.send(n)
3400 }
3401 }
3402 }, {
3403 key: "_onBackupResponse",
3404 value: function(e) {
3405 this._pendingReplayResponses.has(e.nonce) && "" === e.error && (this._pendingReplayResponses.remove(e.nonce), 0 === this._pendingReplayResponses.size() && (this._swapSockets(), this._notifyWhenOpen && (g.debug("triggering connected"), this._notifyWhenOpen = !1, this._trigger("connected"))))
3406 }
3407 }, {
3408 key: "_swapSockets",
3409 value: function() {
3410 g.debug("swapping primary " + this._primarySocket._id + " and backup " + this._backupSocket._id), this._unbindPrimary(this._primarySocket), this._unbindBackup(this._backupSocket), this._bindPrimary(this._backupSocket), this._primarySocket.close(), this._primarySocket = this._backupSocket, this._reconnecting = !1, this._flushQueuedRequests()
3411 }
3412 }, {
3413 key: "Listen",
3414 value: function(e) {
3415 if (window.WebSocket) {
3416 g.debug("listening on " + e.topic);
3417 var t = this._generateNonce(),
3418 n = {
3419 type: "LISTEN",
3420 nonce: t,
3421 data: {
3422 topics: [e.topic],
3423 auth_token: e.auth
3424 }
3425 };
3426 this._queuedSend(t, n, e)
3427 }
3428 }
3429 }, {
3430 key: "Unlisten",
3431 value: function(e) {
3432 if (window.WebSocket) {
3433 if (g.debug("unlistening on " + e.topic + "(" + this._listens.count(e.topic) + " listeners)"), this._listens.count(e.topic) > 1) {
3434 this._listens.off(e.topic, e.message);
3435 for (var t in this._replays.map())
3436 if (this._replays.get(t).message === e.message) {
3437 this._replays.remove(t);
3438 break
3439 }
3440 return e.success && e.success(), void g.debug("now have " + this._listens.count(e.topic) + " listeners")
3441 }
3442 var n = this._generateNonce(),
3443 i = {
3444 type: "UNLISTEN",
3445 nonce: n,
3446 data: {
3447 topics: [e.topic]
3448 }
3449 };
3450 this._queuedSend(n, i, e)
3451 }
3452 }
3453 }, {
3454 key: "_queuedSend",
3455 value: function(e, t, n) {
3456 this._reconnecting || !1 === this._primarySocket._isReady() ? (g.debug("queuing"), this._queuedRequests.push({
3457 nonce: e,
3458 msg: t,
3459 opts: n
3460 })) : (g.debug("sending immediately"), this._send(e, t, n))
3461 }
3462 }, {
3463 key: "_flushQueuedRequests",
3464 value: function() {
3465 for (g.debug("flushing " + this._queuedRequests.length + " listen/unlistens"); this._queuedRequests.length > 0;) {
3466 var e = this._queuedRequests.shift();
3467 this._send(e.nonce, e.msg, e.opts)
3468 }
3469 }
3470 }, {
3471 key: "_send",
3472 value: function(e, t, n) {
3473 this._pendingResponses.set(e, {
3474 timeout: setTimeout(this._onResponseTimeout.bind(this), 3e4, e),
3475 topic: n.topic,
3476 auth: n.auth,
3477 message: t,
3478 callbacks: {
3479 success: n.success,
3480 failure: n.failure,
3481 message: n.message
3482 }
3483 }), this._primarySocket.send(t)
3484 }
3485 }, {
3486 key: "_neverListened",
3487 value: function() {
3488 this._stats.logCounter("first_listen_timeout", 1)
3489 }
3490 }, {
3491 key: "_generateNonce",
3492 value: function() {
3493 return d.default.generateString(30)
3494 }
3495 }, {
3496 key: "_jitteredReconnectDelay",
3497 value: function() {
3498 return d.default.randomInt(2e3)
3499 }
3500 }]), t
3501 }(u.default);
3502 t.default = k
3503}, function(e, t, n) {
3504 "use strict";
3505
3506 function i(e) {
3507 return e && e.__esModule ? e : {
3508 default: e
3509 }
3510 }
3511
3512 function s(e, t) {
3513 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
3514 }
3515
3516 function r(e, t) {
3517 if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3518 return !t || "object" != typeof t && "function" != typeof t ? e : t
3519 }
3520
3521 function o(e, t) {
3522 if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
3523 e.prototype = Object.create(t && t.prototype, {
3524 constructor: {
3525 value: e,
3526 enumerable: !1,
3527 writable: !0,
3528 configurable: !0
3529 }
3530 }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
3531 }
3532 Object.defineProperty(t, "__esModule", {
3533 value: !0
3534 });
3535 var a = function() {
3536 function e(e, t) {
3537 for (var n = 0; n < t.length; n++) {
3538 var i = t[n];
3539 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
3540 }
3541 }
3542 return function(t, n, i) {
3543 return n && e(t.prototype, n), i && e(t, i), t
3544 }
3545 }(),
3546 c = n(6),
3547 u = i(c),
3548 l = n(2),
3549 h = i(l),
3550 f = n(3),
3551 d = i(f),
3552 p = h.default._getLogger("PubsubSocket"),
3553 _ = function(e) {
3554 function t(e) {
3555 s(this, t);
3556 var n = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e));
3557 return n._opts = e, n._addr = e.addr, n._stats = e.stats, n._connectionAttempts = 0, n._sentPing = n._receivedPong = !1, n._id = "[" + d.default.generateString(10) + "] ", window.addEventListener("beforeunload", n._beforeUnload.bind(n)), n
3558 }
3559 return o(t, e), a(t, [{
3560 key: "connect",
3561 value: function() {
3562 p.debug(this._id + "connecting to " + this._addr), this._connecting = !0, this._socketConnectTime = d.default.time.now();
3563 try {
3564 this._socket = new WebSocket(this._addr), this._socket.onmessage = this._onMessage.bind(this), this._socket.onerror = this._onError.bind(this), this._socket.onclose = this._onClose.bind(this), this._socket.onopen = this._onOpen.bind(this)
3565 } catch (e) {
3566 this._stats.logCounter("socket.error.security_err", 1, 1), this._trigger("connection_failure")
3567 }
3568 }
3569 }, {
3570 key: "close",
3571 value: function() {
3572 p.debug(this._id + "closing"), this._closing = !0, this._clearTimeouts(), this._socket.close()
3573 }
3574 }, {
3575 key: "send",
3576 value: function(e) {
3577 p.debug(this._id + "sending " + JSON.stringify(e)), this._isReady() ? this._socket.send(JSON.stringify(e)) : this._trigger("error", "not_ready")
3578 }
3579 }, {
3580 key: "_isReady",
3581 value: function() {
3582 return p.debug(this._id + "_isReady called"), !!this._socket && this._socket.readyState === WebSocket.OPEN
3583 }
3584 }, {
3585 key: "_onMessage",
3586 value: function(e) {
3587 p.debug(this._id + "received message: " + e.data);
3588 try {
3589 var t = JSON.parse(e.data);
3590 switch (t.type) {
3591 case "RESPONSE":
3592 this._trigger("response", t);
3593 break;
3594 case "MESSAGE":
3595 this._trigger("message", t);
3596 break;
3597 case "PONG":
3598 this._receivedPong = !0;
3599 break;
3600 case "RECONNECT":
3601 this._trigger("reconnect")
3602 }
3603 } catch (e) {
3604 this._stats.logLine("onMessage JSON Parse error: " + e)
3605 }
3606 }
3607 }, {
3608 key: "_onError",
3609 value: function(e) {
3610 p.debug(this._id + "error: " + JSON.stringify(e))
3611 }
3612 }, {
3613 key: "_onClose",
3614 value: function(e) {
3615 if (p.debug(this._id + "onClose triggered with code " + e.code + "(closing = " + this._closing + ", connecting = " + this._connecting + ")"), this._clearTimeouts(), this._connecting) {
3616 var t = Math.pow(2, this._connectionAttempts);
3617 t > 120 && (t = 120), p.debug(this._id + "reconnecting in " + t + " seconds"), this._connectionAttempts += 1, this._nextConnectionAttempt = setTimeout(this.connect.bind(this), 1e3 * t)
3618 } else if (this._closing) this._closed = !0, this._trigger("connection_failure");
3619 else {
3620 if (this._windowUnloading) return;
3621 p.debug(this._id + "unexpected close"), this._stats.logCounter("socket.error.unexpected_closed", 1, 1), this._stats.logCounter("socket.error.close." + e.code, 1, 1);
3622 var n = "pubsub-js-client unexpected_close. code: " + e.code + ", reason: " + e.reason + ", wasClean: " + e.wasClean;
3623 this._stats.logLine(n), this._closed = !0, this._trigger("connection_failure")
3624 }
3625 }
3626 }, {
3627 key: "_onOpen",
3628 value: function(e) {
3629 p.debug(this._id + " socket opened"), this._connectionAttempts = 0, this._connecting = !1, this._socketConnectTime && this._stats.logTimer("socket.connect", d.default.time.now() - this._socketConnectTime, .1), this._stats.logCounter("socket.connection_retries." + this._connectionAttempts, 1, .1), this._ping(), this._pingInterval = window.setInterval(this._ping.bind(this), 24e4), this._trigger("open")
3630 }
3631 }, {
3632 key: "_ping",
3633 value: function() {
3634 p.debug(this._id + "sending PING");
3635 try {
3636 this._socket.send(JSON.stringify({
3637 type: "PING"
3638 })), this._sentPing = !0, this._pongTimeout && clearTimeout(this._pongTimeout), this._pongTimeout = setTimeout(this._pongTimedOut.bind(this), 3e4)
3639 } catch (e) {
3640 this._stats.logCounter("socket.error.ping_send_error", 1, 1), this._stats.logLine("ping error: closed: " + this._closed + ", error: " + e), this.close()
3641 }
3642 }
3643 }, {
3644 key: "_pongTimedOut",
3645 value: function() {
3646 this._sentPing && !this._receivedPong && (p.debug(this._id + "Pong timed out!"), this._stats.logCounter("socket.error.pong_timed_out", 1, 1), this.close())
3647 }
3648 }, {
3649 key: "_clearTimeouts",
3650 value: function() {
3651 this._sentPing = this._receivedPong = !1, clearTimeout(this._pongTimeout), clearInterval(this._pingInterval), clearTimeout(this._nextConnectionAttempt)
3652 }
3653 }, {
3654 key: "_beforeUnload",
3655 value: function() {
3656 this._windowUnloading = !0
3657 }
3658 }]), t
3659 }(u.default);
3660 t.default = _
3661}, function(e, t, n) {
3662 "use strict";
3663 Object.defineProperty(t, "__esModule", {
3664 value: !0
3665 }), t.Stats = void 0;
3666 var i = n(44),
3667 s = function(e) {
3668 return e && e.__esModule ? e : {
3669 default: e
3670 }
3671 }(i);
3672 t.Stats = s.default, t.default = {
3673 Stats: s.default
3674 }
3675}, function(e, t, n) {
3676 "use strict";
3677
3678 function i(e, t) {
3679 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
3680 }
3681
3682 function s(e, t) {
3683 var n = u[e];
3684 if (!n) throw new Error("Invalid environment - got " + e);
3685 if (!t) throw new Error("Invalid prefix - got " + t);
3686 window[c] = window[c] || {};
3687 var i = window[c];
3688 i[e] || (i[e] = new l(n));
3689 var s = i[e];
3690 return new h(s, t)
3691 }
3692 Object.defineProperty(t, "__esModule", {
3693 value: !0
3694 });
3695 var r = function() {
3696 function e(e, t) {
3697 for (var n = 0; n < t.length; n++) {
3698 var i = t[n];
3699 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
3700 }
3701 }
3702 return function(t, n, i) {
3703 return n && e(t.prototype, n), i && e(t, i), t
3704 }
3705 }(),
3706 o = 500,
3707 a = 20,
3708 c = "__Twitch__statsInstances_1",
3709 u = {
3710 production: {
3711 addr: "https://client-event-reporter.twitch.tv"
3712 },
3713 darklaunch: {
3714 addr: "https://client-event-reporter-darklaunch.twitch.tv"
3715 }
3716 };
3717 u.staging = u.darklaunch, u.development = u.darklaunch, u.test = u.darklaunch;
3718 var l = function() {
3719 function e(t) {
3720 if (i(this, e), !t) throw new Error("config is required");
3721 this._addr = t.addr, this._resetCombinedStats(), this._recordDelay = o, this._maxPendingStats = a
3722 }
3723 return r(e, [{
3724 key: "logCounter",
3725 value: function(e) {
3726 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1,
3727 n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
3728 this._combinedStats.counters.push({
3729 key: e,
3730 count: t,
3731 sample_rate: n
3732 }), this._record()
3733 }
3734 }, {
3735 key: "logTimer",
3736 value: function(e, t) {
3737 var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
3738 this._combinedStats.timers.push({
3739 key: e,
3740 milliseconds: t,
3741 sample_rate: n
3742 }), this._record()
3743 }
3744 }, {
3745 key: "logLine",
3746 value: function(e) {
3747 this._combinedStats.log_lines.push({
3748 log_line: e
3749 }), this._record()
3750 }
3751 }, {
3752 key: "logGauge",
3753 value: function(e) {
3754 this._combinedStats.gauges.push({
3755 key: e
3756 }), this._record()
3757 }
3758 }, {
3759 key: "_resetCombinedStats",
3760 value: function() {
3761 this._combinedStats = {
3762 timers: [],
3763 counters: [],
3764 log_lines: [],
3765 gauges: []
3766 }
3767 }
3768 }, {
3769 key: "_record",
3770 value: function() {
3771 var e = this;
3772 this._numPendingStats() > this._maxPendingStats ? (this._flushTimeout && (clearTimeout(this._flushTimeout), this._flushTimeout = null), this._flush()) : this._flushTimeout || (this._flushTimeout = setTimeout(function() {
3773 e._flushTimeout = null, e._flush()
3774 }, this._recordDelay))
3775 }
3776 }, {
3777 key: "_flush",
3778 value: function() {
3779 var e = this._combinedStats;
3780 this._resetCombinedStats();
3781 var t = this._addr + "/v1/stats",
3782 n = this._createCorsRequest("POST", t);
3783 if (!n) return void console.log("WARNING: Cannot send stats because CORS is unsupported");
3784 n.setRequestHeader("X-Requested-With", "XMLHttpRequest"), n.setRequestHeader("Content-Type", "application/json"), n.send(JSON.stringify(e))
3785 }
3786 }, {
3787 key: "_numPendingStats",
3788 value: function() {
3789 var e = this._combinedStats;
3790 return e.timers.length + e.counters.length + e.log_lines.length + e.gauges.length
3791 }
3792 }, {
3793 key: "_createCorsRequest",
3794 value: function(e, t) {
3795 var n = new XMLHttpRequest;
3796 return "withCredentials" in n ? n.open(e, t, !0) : "undefined" != typeof XDomainRequest ? (n = new XDomainRequest, n.open(e, t)) : n = null, n
3797 }
3798 }]), e
3799 }(),
3800 h = function() {
3801 function e(t, n) {
3802 if (i(this, e), !t) throw new Error("Missing backend");
3803 if (!n) throw new Error("Missing prefix");
3804 this._backend = t, this._prefix = n
3805 }
3806 return r(e, [{
3807 key: "logCounter",
3808 value: function(e) {
3809 var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1,
3810 n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
3811 this._backend.logCounter(this._prefix + "." + e, t, n)
3812 }
3813 }, {
3814 key: "logTimer",
3815 value: function(e, t) {
3816 var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
3817 this._backend.logTimer(this._prefix + "." + e, t, n)
3818 }
3819 }, {
3820 key: "logLine",
3821 value: function(e) {
3822 this._backend.logLine(e)
3823 }
3824 }, {
3825 key: "logGauge",
3826 value: function(e) {
3827 this._backend.logGauge(e)
3828 }
3829 }, {
3830 key: "setPrefix",
3831 value: function(e) {
3832 if (!e) throw new Error("Missing prefix");
3833 this._prefix = e
3834 }
3835 }]), e
3836 }();
3837 t.StatsBackend = l, t.PrefixedStats = h, t.default = {
3838 getInstance: s
3839 }
3840}, function(e, t, n) {
3841 "use strict";
3842
3843 function i(e) {
3844 return e && e.__esModule ? e : {
3845 default: e
3846 }
3847 }
3848
3849 function s(e, t) {
3850 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
3851 }
3852 Object.defineProperty(t, "__esModule", {
3853 value: !0
3854 });
3855 var r = function() {
3856 function e(e, t) {
3857 for (var n = 0; n < t.length; n++) {
3858 var i = t[n];
3859 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
3860 }
3861 }
3862 return function(t, n, i) {
3863 return n && e(t.prototype, n), i && e(t, i), t
3864 }
3865 }(),
3866 o = n(3),
3867 a = i(o),
3868 c = n(2),
3869 u = i(c),
3870 l = "https://pubster.twitch.tv/publish",
3871 h = "https://pubster-darklaunch.twitch.tv/publish",
3872 f = "pubsubtest.unique.",
3873 d = "pubsubtest.shared." + a.default.randomInt(10),
3874 p = u.default._getLogger("PubsubTest"),
3875 _ = function() {
3876 function e(t) {
3877 if (s(this, e), !window.$) return void p.debug("PubsubTest could not be enabled. JQuery is undefined.");
3878 switch (p.debug("PubsubTest enabled"), this._env = t.env, this._driver = t.driver, this._stats = t.stats, this._env) {
3879 case "production":
3880 this._addr = l;
3881 break;
3882 case "darklaunch":
3883 this._addr = h;
3884 break;
3885 default:
3886 this._env = "production", this._addr = l
3887 }
3888 this._statKeys = {
3889 uniqueSuccess: "test.unique.success",
3890 uniqueFailure: "test.unique.failure",
3891 sharedSuccess: "test.shared.success",
3892 sharedFailure: "test.shared.failure"
3893 }, this._uniqueKey = f + a.default.generateString(20), this._sharedKey = d, this._listeningUnique = this._listeningShared = !1, this.sendListens()
3894 }
3895 return r(e, [{
3896 key: "sendListens",
3897 value: function() {
3898 this._driver.Listen({
3899 topic: this._uniqueKey,
3900 auth: "",
3901 success: this._gotUniqueOk.bind(this),
3902 failure: this._gotUniqueFail.bind(this),
3903 message: this._gotUniqueMessage.bind(this)
3904 }), this._driver.Listen({
3905 topic: this._sharedKey,
3906 auth: "",
3907 success: this._gotSharedOk.bind(this),
3908 failure: this._gotSharedFail.bind(this),
3909 message: this._gotSharedMessage.bind(this)
3910 })
3911 }
3912 }, {
3913 key: "_gotUniqueOk",
3914 value: function() {
3915 this._listeningUnique = !0, this._listeningShared && this.startTesting()
3916 }
3917 }, {
3918 key: "_gotUniqueFail",
3919 value: function(e) {}
3920 }, {
3921 key: "_gotSharedOk",
3922 value: function() {
3923 this._listeningShared = !0, this._listeningUnique && this.startTesting()
3924 }
3925 }, {
3926 key: "_gotSharedFail",
3927 value: function(e) {}
3928 }, {
3929 key: "startTesting",
3930 value: function() {
3931 p.debug("startTesting"), this._driver.on("connected", this.resumeTesting, this), this._driver.on("disconnected", this.stopTesting, this), this.checkAndSend(), this._publishInterval = window.setInterval(this.checkAndSend.bind(this), 6e4)
3932 }
3933 }, {
3934 key: "resumeTesting",
3935 value: function() {
3936 p.debug("resumeTesting"), this.checkAndSend(), this._publishInterval = window.setInterval(this.checkAndSend.bind(this), 6e4)
3937 }
3938 }, {
3939 key: "stopTesting",
3940 value: function() {
3941 p.debug("stopTesting"), clearInterval(this._publishInterval), this._receivedUniqueMessage = this._sentUniqueMessage = !1, this._receivedSharedMessage = this._sentSharedMessage = !1
3942 }
3943 }, {
3944 key: "checkAndSend",
3945 value: function() {
3946 p.debug("checkAndSend: unique: sent = " + this._sentUniqueMessage + ", received = " + this._receivedUniqueMessage), !this._receivedUniqueMessage && this._sentUniqueMessage && (p.debug("unique failure"), this._stats.logCounter(this._statKeys.uniqueFailure, 1, 1)), !this._receivedSharedMessage && this._sentSharedMessage && (p.debug("shared failure"), this._stats.logCounter(this._statKeys.sharedFailure, 1, 1)), this._receivedUniqueMessage = this._sentUniqueMessage = !1, this._receivedSharedMessage = this._sentSharedMessage = !1, this._expectedMessage = a.default.generateString(30), $.ajax({
3947 type: "POST",
3948 url: this._addr,
3949 contentType: "application/json",
3950 timeout: 3e4,
3951 data: JSON.stringify({
3952 topics: [this._uniqueKey],
3953 data: this._expectedMessage
3954 }),
3955 success: function() {
3956 p.debug("unique message sent"), this._sentUniqueMessage = !0
3957 }.bind(this)
3958 }), this._sentUniqueMessageTime = a.default.time.now(), Math.random() < 1e-4 && ($.ajax({
3959 type: "POST",
3960 url: this._addr,
3961 contentType: "application/json",
3962 timeout: 3e4,
3963 data: JSON.stringify({
3964 topics: [this._sharedKey],
3965 data: this._expectedMessage
3966 }),
3967 success: function() {
3968 p.debug("shared message sent"), this._sentSharedMessage = !0
3969 }.bind(this)
3970 }), this._sentSharedMessageTime = a.default.time.now())
3971 }
3972 }, {
3973 key: "_gotUniqueMessage",
3974 value: function(e) {
3975 if (p.debug("received unique message: " + e), e === this._expectedMessage) {
3976 var t = a.default.time.now() - this._sentUniqueMessageTime;
3977 this._receivedUniqueMessage = !0, this._stats.logTimer(this._statKeys.uniqueSuccess, t, .1), this._stats.logCounter(this._statKeys.uniqueSuccess, 1, .1)
3978 }
3979 }
3980 }, {
3981 key: "_gotSharedMessage",
3982 value: function(e) {
3983 if (e === this._expectedMessage) {
3984 var t = a.default.time.now() - this._sentSharedMessageTime;
3985 this._receivedSharedMessage = !0, this._stats.logTimer(this._statKeys.sharedSuccess, t, .1), this._stats.logCounter(this._statKeys.sharedSuccess, 1, .1)
3986 }
3987 }
3988 }]), e
3989 }();
3990 t.default = _
3991}, function(e, t, n) {
3992 "use strict";
3993
3994 function i(e) {
3995 return -1 === e.indexOf(".")
3996 }
3997
3998 function s() {}
3999 t.a = i, t.b = s
4000}, function(e, t, n) {
4001 "use strict";
4002 n.d(t, "a", function() {
4003 return a
4004 });
4005 var i, s = n(1),
4006 r = (n.n(s), n(0)),
4007 o = (n.n(r), n(5));
4008 ! function(e) {
4009 e.Reload = "purchases-event-reload-entitlements"
4010 }(i || (i = {}));
4011 var a = function() {
4012 function e() {
4013 var e = this;
4014 this.eventEmitter = new s.EventEmitter2, this.beginPurchase = function(e) {
4015 Object(o.d)({
4016 action: r.ExtensionAction.TwitchExtBeginPurchase,
4017 payload: {
4018 sku: e
4019 }
4020 })
4021 }, this.onReloadEntitlements = function(t) {
4022 e.eventEmitter.removeAllListeners(i.Reload), e.eventEmitter.addListener(i.Reload, t)
4023 }, this.getPrices = function() {
4024 return e.prices
4025 }, this.setupProducts()
4026 }
4027 return Object.defineProperty(e.prototype, "publicAPI", {
4028 get: function() {
4029 return {
4030 beginPurchase: this.beginPurchase,
4031 getPrices: this.getPrices,
4032 onReloadEntitlements: this.onReloadEntitlements
4033 }
4034 },
4035 enumerable: !0,
4036 configurable: !0
4037 }), e.prototype.onControllerMessage = function(e) {
4038 switch (e.action) {
4039 case r.ExtensionAction.TwitchExtProductPrices:
4040 this.setPrices(e.prices);
4041 break;
4042 case r.ExtensionAction.TwitchExtReloadEntitlements:
4043 this.eventEmitter.emit(i.Reload)
4044 }
4045 }, e.prototype.setupProducts = function() {
4046 var e = this;
4047 this.prices = new Promise(function(t) {
4048 e.setPrices = t
4049 })
4050 }, e
4051 }()
4052}, function(e, t, n) {
4053 "use strict";
4054 var i = n(49);
4055 n.d(t, "a", function() {
4056 return i.a
4057 })
4058}, function(e, t, n) {
4059 "use strict";
4060 n.d(t, "a", function() {
4061 return s
4062 });
4063 var i;
4064 ! function(e) {
4065 e.Log = "twitch-ext-rig-log"
4066 }(i || (i = {}));
4067 var s = function() {
4068 function e() {}
4069 return Object.defineProperty(e.prototype, "publicAPI", {
4070 get: function() {
4071 return {
4072 log: this.log
4073 }
4074 },
4075 enumerable: !0,
4076 configurable: !0
4077 }), e.prototype.log = function(e) {
4078 for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
4079 window.parent.postMessage({
4080 action: i.Log,
4081 messages: [e].concat(t)
4082 }, "*")
4083 }, e
4084 }()
4085}, function(e, t, n) {
4086 "use strict";
4087 n.d(t, "a", function() {
4088 return o
4089 });
4090 var i, s = n(1),
4091 r = (n.n(s), this && this.__assign || function() {
4092 return r = Object.assign || function(e) {
4093 for (var t, n = 1, i = arguments.length; n < i; n++) {
4094 t = arguments[n];
4095 for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s])
4096 }
4097 return e
4098 }, r.apply(this, arguments)
4099 });
4100 ! function(e) {
4101 e.ViewerStatusUpdated = "viewer-status-updated"
4102 }(i || (i = {}));
4103 var o = function() {
4104 function e() {
4105 var e = this;
4106 this.eventEmitter = new s.EventEmitter2, this.viewerStatus = null, this.updateInternalStatus = function(t) {
4107 if (e.viewerStatus) {
4108 var n = Object.keys(t).filter(function(n) {
4109 return !!(e.viewerStatus && n in e.viewerStatus) && t[n] !== e.viewerStatus[n]
4110 });
4111 e.viewerStatus = r({}, e.viewerStatus, t), n.length && e.eventEmitter.emit(i.ViewerStatusUpdated)
4112 }
4113 }, this.addViewerChangeListener = function(t) {
4114 e.eventEmitter.on(i.ViewerStatusUpdated, t)
4115 }
4116 }
4117 return Object.defineProperty(e.prototype, "publicAPI", {
4118 get: function() {
4119 var e = this;
4120 return {get onChanged() {
4121 return e.addViewerChangeListener
4122 },
4123 get id() {
4124 return e.viewerStatus && e.viewerStatus.id
4125 },
4126 get opaqueId() {
4127 return e.viewerStatus && e.viewerStatus.opaqueId
4128 },
4129 get role() {
4130 return e.viewerStatus && e.viewerStatus.role
4131 },
4132 get isLinked() {
4133 return e.viewerStatus && e.viewerStatus.isLinked
4134 },
4135 get sessionToken() {
4136 return e.viewerStatus && e.viewerStatus.sessionToken
4137 },
4138 get subscriptionStatus() {
4139 return e.viewerStatus && e.viewerStatus.subscriptionStatus
4140 }
4141 }
4142 },
4143 enumerable: !0,
4144 configurable: !0
4145 }), e.prototype.initializeViewer = function(e, t) {
4146 var n, s = e.token.split(".")[1];
4147 if (s) {
4148 try {
4149 n = JSON.parse(atob(s))
4150 } catch (e) {
4151 return
4152 }
4153 this.viewerStatus = {
4154 id: n.user_id || null,
4155 opaqueId: n.opaque_user_id,
4156 role: n.role,
4157 isLinked: void 0 !== n.user_id,
4158 sessionToken: e.token,
4159 subscriptionStatus: t ? t.subscriptionStatus : null
4160 }, this.eventEmitter.emit(i.ViewerStatusUpdated)
4161 }
4162 }, e.prototype.updateViewerInfo = function(e) {
4163 if (this.viewerStatus) {
4164 var t = r({}, this.viewerStatus, e);
4165 this.updateInternalStatus(t)
4166 }
4167 }, e.prototype.setAuth = function(e) {
4168 if (this.viewerStatus) {
4169 var t, n = e.token.split(".")[1];
4170 if (n) {
4171 try {
4172 t = JSON.parse(atob(n))
4173 } catch (e) {
4174 return
4175 }
4176 var i = r({}, this.viewerStatus, {
4177 id: t.user_id || null,
4178 opaqueId: t.opaque_user_id,
4179 role: t.role,
4180 isLinked: void 0 !== t.user_id,
4181 sessionToken: e.token
4182 });
4183 this.updateInternalStatus(i)
4184 }
4185 }
4186 }, e
4187 }()
4188}, function(e, t, n) {
4189 "use strict";
4190 n.d(t, "a", function() {
4191 return o
4192 });
4193 var i = n(0),
4194 s = (n.n(i), n(11)),
4195 r = ["click", "mousemove"],
4196 o = function() {
4197 function e(e, t, n, s) {
4198 var r = this;
4199 this.onDOMContentLoaded = function() {
4200 r.window.addEventListener("message", r.handleMessageEvent, !1), r.parentWindow.postMessage({
4201 action: i.ExtensionAction.TwitchExtLoaded
4202 }, "*"), r.forceVideoOverlayFullSize()
4203 }, this.bindLongtaskHandler = function() {
4204 window.PerformanceObserver && window.PerformanceLongTaskTiming && (r.performanceObserver = new window.PerformanceObserver(function(e) {
4205 e.getEntries().forEach(r.trackLongtask)
4206 }), r.performanceObserver.observe({
4207 entryTypes: ["longtask"]
4208 }))
4209 }, this.unbindLongtaskHandler = function() {
4210 r.performanceObserver && (r.performanceObserver.disconnect(), r.performanceObserver = void 0)
4211 }, this.trackLongtask = function(e) {
4212 r.shouldTrackLongtask(e) && r.parentWindow.postMessage({
4213 action: i.ExtensionAction.TwitchExtLongtask,
4214 payload: {
4215 longtask_duration: e.duration
4216 }
4217 }, "*")
4218 }, this.onMouseAction = function(e) {
4219 r.parentWindow.postMessage({
4220 action: i.ExtensionAction.TwitchExtUserAction,
4221 payload: {
4222 type: e.type,
4223 clientX: e.clientX,
4224 clientY: e.clientY
4225 }
4226 }, "*"), r.forceVideoOverlayFullSize()
4227 }, this.onFocus = function(e) {
4228 switch (e.target.tagName.toLowerCase()) {
4229 case "input":
4230 case "select":
4231 case "textarea":
4232 case "button":
4233 return;
4234 default:
4235 r.parentWindow.postMessage({
4236 action: i.ExtensionAction.TwitchExtUserAction,
4237 payload: {
4238 type: e.type
4239 }
4240 }, "*")
4241 }
4242 }, this.window = n || window, this.parentWindow = this.window.parent, this.documentObject = s || document, this.params = e, this.handleMessageEvent = t, this.isViewerVideoOverlay = "video_overlay" === this.params.anchor && this.params.mode === i.ExtensionMode.Viewer
4243 }
4244 return e.prototype.forceVideoOverlayFullSize = function() {
4245 this.isViewerVideoOverlay && Object(s.a)(this.documentObject)
4246 }, e.prototype.bindEvents = function() {
4247 var e = this;
4248 this.documentObject.addEventListener("DOMContentLoaded", this.onDOMContentLoaded), r.forEach(function(t) {
4249 e.documentObject.addEventListener(t, e.onMouseAction, !0)
4250 }), this.documentObject.addEventListener("dblclick", this.onMouseAction), this.documentObject.addEventListener("focusin", this.onFocus, !0), this.bindLongtaskHandler()
4251 }, e.prototype.unbindEvents = function() {
4252 var e = this;
4253 this.documentObject.removeEventListener("DOMContentLoaded", this.onDOMContentLoaded), r.forEach(function(t) {
4254 e.documentObject.removeEventListener(t, e.onMouseAction, !0)
4255 }), this.documentObject.removeEventListener("dblclick", this.onMouseAction), this.documentObject.removeEventListener("focusin", this.onFocus, !0), this.unbindLongtaskHandler()
4256 }, e.prototype.shouldTrackLongtask = function(e) {
4257 var t = .1 > Math.random(),
4258 n = "self" === e.name;
4259 return t && n
4260 }, e
4261 }()
4262}]);