Skip to content

Instantly share code, notes, and snippets.

@jjbubudi
Created December 28, 2018 14:41
Show Gist options
  • Save jjbubudi/86549bd597ffc4d74b30990e7a385f44 to your computer and use it in GitHub Desktop.
Save jjbubudi/86549bd597ffc4d74b30990e7a385f44 to your computer and use it in GitHub Desktop.
var l = l || {}, m = this;
function n(a) {
return "string" == typeof a;
}
function p(a, b) {
a = a.split(".");
b = b || m;
for (var c = 0; c < a.length; c++) {
if (b = b[a[c]], null == b) {
return null;
}
}
return b;
}
function q() {
}
function r(a) {
var b = typeof a;
if ("object" == b) {
if (a) {
if (a instanceof Array) {
return "array";
}
if (a instanceof Object) {
return b;
}
var c = Object.prototype.toString.call(a);
if ("[object Window]" == c) {
return "object";
}
if ("[object Array]" == c || "number" == typeof a.length && "undefined" != typeof a.splice && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("splice")) {
return "array";
}
if ("[object Function]" == c || "undefined" != typeof a.call && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("call")) {
return "function";
}
} else {
return "null";
}
} else {
if ("function" == b && "undefined" == typeof a.call) {
return "object";
}
}
return b;
}
function t(a) {
var b = typeof a;
return "object" == b && null != a || "function" == b;
}
var aa = "closure_uid_" + (1e9 * Math.random() >>> 0), ba = 0;
function ca(a, b, c) {
return a.call.apply(a.bind, arguments);
}
function da(a, b, c) {
if (!a) {
throw Error();
}
if (2 < arguments.length) {
var d = Array.prototype.slice.call(arguments, 2);
return function() {
var c = Array.prototype.slice.call(arguments);
Array.prototype.unshift.apply(c, d);
return a.apply(b, c);
};
}
return function() {
return a.apply(b, arguments);
};
}
function u(a, b, c) {
Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? u = ca : u = da;
return u.apply(null, arguments);
}
var ea = Date.now || function() {
return +new Date;
};
function v(a, b) {
function c() {
}
c.prototype = b.prototype;
a.V = b.prototype;
a.prototype = new c;
a.prototype.constructor = a;
a.W = function(a, c, f) {
for (var d = Array(arguments.length - 2), e = 2; e < arguments.length; e++) {
d[e - 2] = arguments[e];
}
return b.prototype[c].apply(a, d);
};
}
;function fa(a) {
switch(a) {
case 0:
return "No Error";
case 1:
return "Access denied to content document";
case 2:
return "File not found";
case 3:
return "Firefox silently errored";
case 4:
return "Application custom error";
case 5:
return "An exception occurred";
case 6:
return "Http response at 400 or 500 level";
case 7:
return "Request was aborted";
case 8:
return "Request timed out";
case 9:
return "The resource is not available offline";
default:
return "Unrecognized error code";
}
}
;function w(a) {
if (Error.captureStackTrace) {
Error.captureStackTrace(this, w);
} else {
var b = Error().stack;
b && (this.stack = b);
}
a && (this.message = String(a));
}
v(w, Error);
w.prototype.name = "CustomError";
function ha(a, b) {
for (var c = a.split("%s"), d = "", e = Array.prototype.slice.call(arguments, 1); e.length && 1 < c.length;) {
d += c.shift() + e.shift();
}
return d + c.join("%s");
}
var ia = String.prototype.trim ? function(a) {
return a.trim();
} : function(a) {
return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g, "");
};
function x(a, b) {
return a < b ? -1 : a > b ? 1 : 0;
}
;function y(a, b) {
b.unshift(a);
w.call(this, ha.apply(null, b));
b.shift();
}
v(y, w);
y.prototype.name = "AssertionError";
function ja(a, b) {
throw new y("Failure" + (a ? ": " + a : ""), Array.prototype.slice.call(arguments, 1));
}
;function ka() {
this.N = null;
this.h = [];
this.O = 0;
this.m = z;
this.c = this.a = this.g = 0;
this.b = null;
this.f = 0;
}
var z = 0;
function la(a, b, c, d) {
a.m = 3;
a.N = "The stream is broken @" + a.O + "/" + c + ". Error: " + d + ". With input:\n" + b;
throw Error(a.N);
}
function ma(a, b) {
function c(a) {
0 == a ? g.g = a : 128 == a ? g.g = a : la(g, h, k, "invalid frame byte");
g.m = 1;
g.a = 0;
g.c = 0;
}
function d(a) {
g.c++;
g.a = (g.a << 8) + a;
4 == g.c && (g.m = 2, g.f = 0, "undefined" !== typeof Uint8Array ? g.b = new Uint8Array(g.a) : g.b = Array(g.a), 0 == g.a && f());
}
function e(a) {
g.b[g.f++] = a;
g.f == g.a && f();
}
function f() {
var a = {};
a[g.g] = g.b;
g.h.push(a);
g.m = z;
}
for (var g = a, h = b instanceof Array ? b : new Uint8Array(b), k = 0; k < h.length;) {
switch(g.m) {
case 3:
la(g, h, k, "stream already broken");
break;
case z:
c(h[k]);
break;
case 1:
d(h[k]);
break;
case 2:
e(h[k]);
break;
default:
throw Error("unexpected parser state: " + g.m);
}
g.O++;
k++;
}
a = g.h;
g.h = [];
return 0 < a.length ? a : null;
}
;var na = Array.prototype.indexOf ? function(a, b) {
return Array.prototype.indexOf.call(a, b, void 0);
} : function(a, b) {
if (n(a)) {
return n(b) && 1 == b.length ? a.indexOf(b, 0) : -1;
}
for (var c = 0; c < a.length; c++) {
if (c in a && a[c] === b) {
return c;
}
}
return -1;
};
function oa(a) {
a: {
var b = pa;
for (var c = a.length, d = n(a) ? a.split("") : a, e = 0; e < c; e++) {
if (e in d && b.call(void 0, d[e], e, a)) {
b = e;
break a;
}
}
b = -1;
}
return 0 > b ? null : n(a) ? a.charAt(b) : a[b];
}
;var A;
a: {
var qa = m.navigator;
if (qa) {
var ra = qa.userAgent;
if (ra) {
A = ra;
break a;
}
}
A = "";
}
;function sa(a, b) {
for (var c in a) {
b.call(void 0, a[c], c, a);
}
}
var ta = "constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");
function ua(a, b) {
for (var c, d, e = 1; e < arguments.length; e++) {
d = arguments[e];
for (c in d) {
a[c] = d[c];
}
for (var f = 0; f < ta.length; f++) {
c = ta[f], Object.prototype.hasOwnProperty.call(d, c) && (a[c] = d[c]);
}
}
}
;function B() {
0 != va && (this[aa] || (this[aa] = ++ba));
this.G = this.G;
}
var va = 0;
B.prototype.G = !1;
function C(a) {
C[" "](a);
return a;
}
C[" "] = q;
function wa(a, b) {
var c = xa;
return Object.prototype.hasOwnProperty.call(c, a) ? c[a] : c[a] = b(a);
}
;var ya = -1 != A.indexOf("Opera"), D = -1 != A.indexOf("Trident") || -1 != A.indexOf("MSIE"), za = -1 != A.indexOf("Edge"), Aa = -1 != A.indexOf("Gecko") && !(-1 != A.toLowerCase().indexOf("webkit") && -1 == A.indexOf("Edge")) && !(-1 != A.indexOf("Trident") || -1 != A.indexOf("MSIE")) && -1 == A.indexOf("Edge"), Ba = -1 != A.toLowerCase().indexOf("webkit") && -1 == A.indexOf("Edge");
function Ca() {
var a = m.document;
return a ? a.documentMode : void 0;
}
var E;
a: {
var Da = "", Ea = function() {
var a = A;
if (Aa) {
return /rv:([^\);]+)(\)|;)/.exec(a);
}
if (za) {
return /Edge\/([\d\.]+)/.exec(a);
}
if (D) {
return /\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);
}
if (Ba) {
return /WebKit\/(\S+)/.exec(a);
}
if (ya) {
return /(?:Version)[ \/]?(\S+)/.exec(a);
}
}();
Ea && (Da = Ea ? Ea[1] : "");
if (D) {
var Fa = Ca();
if (null != Fa && Fa > parseFloat(Da)) {
E = String(Fa);
break a;
}
}
E = Da;
}
var xa = {};
function Ga(a) {
return wa(a, function() {
for (var b = 0, c = ia(String(E)).split("."), d = ia(String(a)).split("."), e = Math.max(c.length, d.length), f = 0; 0 == b && f < e; f++) {
var g = c[f] || "", h = d[f] || "";
do {
g = /(\d*)(\D*)(.*)/.exec(g) || ["", "", "", ""];
h = /(\d*)(\D*)(.*)/.exec(h) || ["", "", "", ""];
if (0 == g[0].length && 0 == h[0].length) {
break;
}
b = x(0 == g[1].length ? 0 : parseInt(g[1], 10), 0 == h[1].length ? 0 : parseInt(h[1], 10)) || x(0 == g[2].length, 0 == h[2].length) || x(g[2], h[2]);
g = g[3];
h = h[3];
} while (0 == b);
}
return 0 <= b;
});
}
var Ha;
var Ia = m.document;
Ha = Ia && D ? Ca() || ("CSS1Compat" == Ia.compatMode ? parseInt(E, 10) : 5) : void 0;
var Ja = Object.freeze || function(a) {
return a;
};
var Ka;
(Ka = !D) || (Ka = 9 <= Number(Ha));
var La = Ka, Ma = D && !Ga("9"), Na = function() {
if (!m.addEventListener || !Object.defineProperty) {
return !1;
}
var a = !1, b = Object.defineProperty({}, "passive", {get:function() {
a = !0;
}});
m.addEventListener("test", q, b);
m.removeEventListener("test", q, b);
return a;
}();
function F(a, b) {
this.type = a;
this.a = this.target = b;
}
F.prototype.b = function() {
};
function G(a, b) {
F.call(this, a ? a.type : "");
this.relatedTarget = this.a = this.target = null;
this.button = this.screenY = this.screenX = this.clientY = this.clientX = 0;
this.key = "";
this.metaKey = this.shiftKey = this.altKey = this.ctrlKey = !1;
this.pointerId = 0;
this.pointerType = "";
this.c = null;
if (a) {
var c = this.type = a.type, d = a.changedTouches ? a.changedTouches[0] : null;
this.target = a.target || a.srcElement;
this.a = b;
if (b = a.relatedTarget) {
if (Aa) {
a: {
try {
C(b.nodeName);
var e = !0;
break a;
} catch (f) {
}
e = !1;
}
e || (b = null);
}
} else {
"mouseover" == c ? b = a.fromElement : "mouseout" == c && (b = a.toElement);
}
this.relatedTarget = b;
null === d ? (this.clientX = void 0 !== a.clientX ? a.clientX : a.pageX, this.clientY = void 0 !== a.clientY ? a.clientY : a.pageY, this.screenX = a.screenX || 0, this.screenY = a.screenY || 0) : (this.clientX = void 0 !== d.clientX ? d.clientX : d.pageX, this.clientY = void 0 !== d.clientY ? d.clientY : d.pageY, this.screenX = d.screenX || 0, this.screenY = d.screenY || 0);
this.button = a.button;
this.key = a.key || "";
this.ctrlKey = a.ctrlKey;
this.altKey = a.altKey;
this.shiftKey = a.shiftKey;
this.metaKey = a.metaKey;
this.pointerId = a.pointerId || 0;
this.pointerType = n(a.pointerType) ? a.pointerType : Oa[a.pointerType] || "";
this.c = a;
a.defaultPrevented && this.b();
}
}
v(G, F);
var Oa = Ja({2:"touch", 3:"pen", 4:"mouse"});
G.prototype.b = function() {
G.V.b.call(this);
var a = this.c;
if (a.preventDefault) {
a.preventDefault();
} else {
if (a.returnValue = !1, Ma) {
try {
if (a.ctrlKey || 112 <= a.keyCode && 123 >= a.keyCode) {
a.keyCode = -1;
}
} catch (b) {
}
}
}
};
var H = "closure_listenable_" + (1e6 * Math.random() | 0), Pa = 0;
function Qa(a, b, c, d, e) {
this.listener = a;
this.proxy = null;
this.src = b;
this.type = c;
this.capture = !!d;
this.u = e;
this.key = ++Pa;
this.l = this.s = !1;
}
function Ra(a) {
a.l = !0;
a.listener = null;
a.proxy = null;
a.src = null;
a.u = null;
}
;function I(a) {
this.src = a;
this.a = {};
this.b = 0;
}
I.prototype.add = function(a, b, c, d, e) {
var f = a.toString();
a = this.a[f];
a || (a = this.a[f] = [], this.b++);
var g = Sa(a, b, d, e);
-1 < g ? (b = a[g], c || (b.s = !1)) : (b = new Qa(b, this.src, f, !!d, e), b.s = c, a.push(b));
return b;
};
function Ta(a, b) {
var c = b.type;
if (c in a.a) {
var d = a.a[c], e = na(d, b), f;
(f = 0 <= e) && Array.prototype.splice.call(d, e, 1);
f && (Ra(b), 0 == a.a[c].length && (delete a.a[c], a.b--));
}
}
function Sa(a, b, c, d) {
for (var e = 0; e < a.length; ++e) {
var f = a[e];
if (!f.l && f.listener == b && f.capture == !!c && f.u == d) {
return e;
}
}
return -1;
}
;var Ua = "closure_lm_" + (1e6 * Math.random() | 0), Va = {}, Wa = 0;
function Xa(a, b, c, d, e) {
if (d && d.once) {
Ya(a, b, c, d, e);
} else {
if ("array" == r(b)) {
for (var f = 0; f < b.length; f++) {
Xa(a, b[f], c, d, e);
}
} else {
c = Za(c), a && a[H] ? a.f.add(String(b), c, !1, t(d) ? !!d.capture : !!d, e) : $a(a, b, c, !1, d, e);
}
}
}
function $a(a, b, c, d, e, f) {
if (!b) {
throw Error("Invalid event type");
}
var g = t(e) ? !!e.capture : !!e, h = J(a);
h || (a[Ua] = h = new I(a));
c = h.add(b, c, d, g, f);
if (!c.proxy) {
d = ab();
c.proxy = d;
d.src = a;
d.listener = c;
if (a.addEventListener) {
Na || (e = g), void 0 === e && (e = !1), a.addEventListener(b.toString(), d, e);
} else {
if (a.attachEvent) {
a.attachEvent(bb(b.toString()), d);
} else {
if (a.addListener && a.removeListener) {
a.addListener(d);
} else {
throw Error("addEventListener and attachEvent are unavailable.");
}
}
}
Wa++;
}
}
function ab() {
var a = cb, b = La ? function(c) {
return a.call(b.src, b.listener, c);
} : function(c) {
c = a.call(b.src, b.listener, c);
if (!c) {
return c;
}
};
return b;
}
function Ya(a, b, c, d, e) {
if ("array" == r(b)) {
for (var f = 0; f < b.length; f++) {
Ya(a, b[f], c, d, e);
}
} else {
c = Za(c), a && a[H] ? a.f.add(String(b), c, !0, t(d) ? !!d.capture : !!d, e) : $a(a, b, c, !0, d, e);
}
}
function db(a, b, c, d, e) {
if ("array" == r(b)) {
for (var f = 0; f < b.length; f++) {
db(a, b[f], c, d, e);
}
} else {
(d = t(d) ? !!d.capture : !!d, c = Za(c), a && a[H]) ? (a = a.f, b = String(b).toString(), b in a.a && (f = a.a[b], c = Sa(f, c, d, e), -1 < c && (Ra(f[c]), Array.prototype.splice.call(f, c, 1), 0 == f.length && (delete a.a[b], a.b--)))) : a && (a = J(a)) && (b = a.a[b.toString()], a = -1, b && (a = Sa(b, c, d, e)), (c = -1 < a ? b[a] : null) && eb(c));
}
}
function eb(a) {
if ("number" != typeof a && a && !a.l) {
var b = a.src;
if (b && b[H]) {
Ta(b.f, a);
} else {
var c = a.type, d = a.proxy;
b.removeEventListener ? b.removeEventListener(c, d, a.capture) : b.detachEvent ? b.detachEvent(bb(c), d) : b.addListener && b.removeListener && b.removeListener(d);
Wa--;
(c = J(b)) ? (Ta(c, a), 0 == c.b && (c.src = null, b[Ua] = null)) : Ra(a);
}
}
}
function bb(a) {
return a in Va ? Va[a] : Va[a] = "on" + a;
}
function fb(a, b, c, d) {
var e = !0;
if (a = J(a)) {
if (b = a.a[b.toString()]) {
for (b = b.concat(), a = 0; a < b.length; a++) {
var f = b[a];
f && f.capture == c && !f.l && (f = gb(f, d), e = e && !1 !== f);
}
}
}
return e;
}
function gb(a, b) {
var c = a.listener, d = a.u || a.src;
a.s && eb(a);
return c.call(d, b);
}
function cb(a, b) {
if (a.l) {
return !0;
}
if (!La) {
var c = b || p("window.event");
b = new G(c, this);
var d = !0;
if (!(0 > c.keyCode || void 0 != c.returnValue)) {
a: {
var e = !1;
if (0 == c.keyCode) {
try {
c.keyCode = -1;
break a;
} catch (g) {
e = !0;
}
}
if (e || void 0 == c.returnValue) {
c.returnValue = !0;
}
}
c = [];
for (e = b.a; e; e = e.parentNode) {
c.push(e);
}
a = a.type;
for (e = c.length - 1; 0 <= e; e--) {
b.a = c[e];
var f = fb(c[e], a, !0, b);
d = d && f;
}
for (e = 0; e < c.length; e++) {
b.a = c[e], f = fb(c[e], a, !1, b), d = d && f;
}
}
return d;
}
return gb(a, new G(b, this));
}
function J(a) {
a = a[Ua];
return a instanceof I ? a : null;
}
var hb = "__closure_events_fn_" + (1e9 * Math.random() >>> 0);
function Za(a) {
if ("function" == r(a)) {
return a;
}
a[hb] || (a[hb] = function(b) {
return a.handleEvent(b);
});
return a[hb];
}
;function K() {
B.call(this);
this.f = new I(this);
this.R = this;
}
v(K, B);
K.prototype[H] = !0;
K.prototype.removeEventListener = function(a, b, c, d) {
db(this, a, b, c, d);
};
function L(a, b) {
a = a.R;
var c = b.type || b;
if (n(b)) {
b = new F(b, a);
} else {
if (b instanceof F) {
b.target = b.target || a;
} else {
var d = b;
b = new F(c, a);
ua(b, d);
}
}
a = b.a = a;
ib(a, c, !0, b);
ib(a, c, !1, b);
}
function ib(a, b, c, d) {
if (b = a.f.a[String(b)]) {
b = b.concat();
for (var e = !0, f = 0; f < b.length; ++f) {
var g = b[f];
if (g && !g.l && g.capture == c) {
var h = g.listener, k = g.u || g.src;
g.s && Ta(a.f, g);
e = !1 !== h.call(k, d) && e;
}
}
}
}
;function jb(a, b, c) {
if ("function" == r(a)) {
c && (a = u(a, c));
} else {
if (a && "function" == typeof a.handleEvent) {
a = u(a.handleEvent, a);
} else {
throw Error("Invalid listener argument");
}
}
return 2147483647 < Number(b) ? -1 : m.setTimeout(a, b || 0);
}
;function kb(a, b, c) {
this.reset(a, b, c, void 0, void 0);
}
kb.prototype.a = null;
var lb = 0;
kb.prototype.reset = function(a, b, c, d, e) {
"number" == typeof e || lb++;
d || ea();
delete this.a;
};
function mb(a) {
this.f = a;
this.b = this.c = this.a = null;
}
function M(a, b) {
this.name = a;
this.value = b;
}
M.prototype.toString = function() {
return this.name;
};
var nb = new M("SEVERE", 1000), ob = new M("CONFIG", 700), pb = new M("FINE", 500);
function qb(a) {
if (a.c) {
return a.c;
}
if (a.a) {
return qb(a.a);
}
ja("Root logger has no level set.");
return null;
}
mb.prototype.log = function(a, b, c) {
if (a.value >= qb(this).value) {
for ("function" == r(b) && (b = b()), a = new kb(a, String(b), this.f), c && (a.a = c), c = this; c;) {
c = c.a;
}
}
};
var rb = {}, N = null;
function sb(a) {
N || (N = new mb(""), rb[""] = N, N.c = ob);
var b;
if (!(b = rb[a])) {
b = new mb(a);
var c = a.lastIndexOf("."), d = a.substr(c + 1);
c = sb(a.substr(0, c));
c.b || (c.b = {});
c.b[d] = b;
b.a = c;
rb[a] = b;
}
return b;
}
;function O(a, b) {
a && a.log(pb, b, void 0);
}
;function tb() {
}
tb.prototype.a = null;
function ub(a) {
var b;
(b = a.a) || (b = {}, wb(a) && (b[0] = !0, b[1] = !0), b = a.a = b);
return b;
}
;var xb;
function yb() {
}
v(yb, tb);
function zb(a) {
return (a = wb(a)) ? new ActiveXObject(a) : new XMLHttpRequest;
}
function wb(a) {
if (!a.b && "undefined" == typeof XMLHttpRequest && "undefined" != typeof ActiveXObject) {
for (var b = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"], c = 0; c < b.length; c++) {
var d = b[c];
try {
return new ActiveXObject(d), a.b = d;
} catch (e) {
}
}
throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed");
}
return a.b;
}
xb = new yb;
function P(a, b) {
this.b = {};
this.a = [];
this.c = 0;
var c = arguments.length;
if (1 < c) {
if (c % 2) {
throw Error("Uneven number of arguments");
}
for (var d = 0; d < c; d += 2) {
this.set(arguments[d], arguments[d + 1]);
}
} else {
a && Ab(this, a);
}
}
P.prototype.g = function() {
Q(this);
for (var a = [], b = 0; b < this.a.length; b++) {
a.push(this.b[this.a[b]]);
}
return a;
};
P.prototype.f = function() {
Q(this);
return this.a.concat();
};
function Bb(a) {
a.b = {};
a.a.length = 0;
a.c = 0;
}
function Q(a) {
if (a.c != a.a.length) {
for (var b = 0, c = 0; b < a.a.length;) {
var d = a.a[b];
R(a.b, d) && (a.a[c++] = d);
b++;
}
a.a.length = c;
}
if (a.c != a.a.length) {
var e = {};
for (c = b = 0; b < a.a.length;) {
d = a.a[b], R(e, d) || (a.a[c++] = d, e[d] = 1), b++;
}
a.a.length = c;
}
}
P.prototype.get = function(a, b) {
return R(this.b, a) ? this.b[a] : b;
};
P.prototype.set = function(a, b) {
R(this.b, a) || (this.c++, this.a.push(a));
this.b[a] = b;
};
function Ab(a, b) {
if (b instanceof P) {
var c = b.f();
b = b.g();
} else {
c = [];
var d = 0;
for (e in b) {
c[d++] = e;
}
d = [];
var e = 0;
for (var f in b) {
d[e++] = b[f];
}
b = d;
}
for (f = 0; f < c.length; f++) {
a.set(c[f], b[f]);
}
}
P.prototype.forEach = function(a, b) {
for (var c = this.f(), d = 0; d < c.length; d++) {
var e = c[d], f = this.get(e);
a.call(b, f, e, this);
}
};
function Cb(a) {
Q(a);
for (var b = {}, c = 0; c < a.a.length; c++) {
var d = a.a[c];
b[d] = a.b[d];
}
return b;
}
function R(a, b) {
return Object.prototype.hasOwnProperty.call(a, b);
}
;var Db = /^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;
function S(a) {
K.call(this);
this.headers = new P;
this.F = a || null;
this.c = !1;
this.D = this.a = null;
this.J = this.w = "";
this.g = 0;
this.j = "";
this.i = this.I = this.v = this.H = !1;
this.o = 0;
this.B = null;
this.h = Eb;
this.C = this.M = !1;
}
v(S, K);
var Eb = "", Fb = S.prototype, Gb = sb("goog.net.XhrIo");
Fb.b = Gb;
var Hb = /^https?$/i, Ib = ["POST", "PUT"];
function Jb(a, b, c) {
if (a.a) {
throw Error("[goog.net.XhrIo] Object is active with another request=" + a.w + "; newUri=" + b);
}
a.w = b;
a.j = "";
a.g = 0;
a.J = "POST";
a.H = !1;
a.c = !0;
a.a = a.F ? zb(a.F) : zb(xb);
a.D = a.F ? ub(a.F) : ub(xb);
a.a.onreadystatechange = u(a.K, a);
try {
O(a.b, T(a, "Opening Xhr")), a.I = !0, a.a.open("POST", String(b), !0), a.I = !1;
} catch (f) {
O(a.b, T(a, "Error opening Xhr: " + f.message));
Kb(a, f);
return;
}
b = c || "";
c = new P(a.headers);
var d = oa(c.f()), e = m.FormData && b instanceof m.FormData;
!(0 <= na(Ib, "POST")) || d || e || c.set("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
c.forEach(function(a, b) {
this.a.setRequestHeader(b, a);
}, a);
a.h && (a.a.responseType = a.h);
"withCredentials" in a.a && a.a.withCredentials !== a.M && (a.a.withCredentials = a.M);
try {
Lb(a), 0 < a.o && (a.C = Mb(a.a), O(a.b, T(a, "Will abort after " + a.o + "ms if incomplete, xhr2 " + a.C)), a.C ? (a.a.timeout = a.o, a.a.ontimeout = u(a.L, a)) : a.B = jb(a.L, a.o, a)), O(a.b, T(a, "Sending request")), a.v = !0, a.a.send(b), a.v = !1;
} catch (f) {
O(a.b, T(a, "Send error: " + f.message)), Kb(a, f);
}
}
function Mb(a) {
return D && Ga(9) && "number" == typeof a.timeout && void 0 !== a.ontimeout;
}
function pa(a) {
return "content-type" == a.toLowerCase();
}
S.prototype.L = function() {
"undefined" != typeof l && this.a && (this.j = "Timed out after " + this.o + "ms, aborting", this.g = 8, O(this.b, T(this, this.j)), L(this, "timeout"), this.abort(8));
};
function Kb(a, b) {
a.c = !1;
a.a && (a.i = !0, a.a.abort(), a.i = !1);
a.j = b;
a.g = 5;
Nb(a);
Ob(a);
}
function Nb(a) {
a.H || (a.H = !0, L(a, "complete"), L(a, "error"));
}
S.prototype.abort = function(a) {
this.a && this.c && (O(this.b, T(this, "Aborting")), this.c = !1, this.i = !0, this.a.abort(), this.i = !1, this.g = a || 7, L(this, "complete"), L(this, "abort"), Ob(this));
};
S.prototype.K = function() {
this.G || (this.I || this.v || this.i ? Pb(this) : this.S());
};
S.prototype.S = function() {
Pb(this);
};
function Pb(a) {
if (a.c && "undefined" != typeof l) {
if (a.D[1] && 4 == U(a) && 2 == V(a)) {
O(a.b, T(a, "Local request error detected and ignored"));
} else {
if (a.v && 4 == U(a)) {
jb(a.K, 0, a);
} else {
if (L(a, "readystatechange"), 4 == U(a)) {
O(a.b, T(a, "Request complete"));
a.c = !1;
try {
var b = V(a);
a: {
switch(b) {
case 200:
case 201:
case 202:
case 204:
case 206:
case 304:
case 1223:
var c = !0;
break a;
default:
c = !1;
}
}
var d;
if (!(d = c)) {
var e;
if (e = 0 === b) {
var f = String(a.w).match(Db)[1] || null;
if (!f && m.self && m.self.location) {
var g = m.self.location.protocol;
f = g.substr(0, g.length - 1);
}
e = !Hb.test(f ? f.toLowerCase() : "");
}
d = e;
}
if (d) {
L(a, "complete"), L(a, "success");
} else {
a.g = 6;
try {
var h = 2 < U(a) ? a.a.statusText : "";
} catch (k) {
O(a.b, "Can not get status: " + k.message), h = "";
}
a.j = h + " [" + V(a) + "]";
Nb(a);
}
} finally {
Ob(a);
}
}
}
}
}
}
function Ob(a) {
if (a.a) {
Lb(a);
var b = a.a, c = a.D[0] ? q : null;
a.a = null;
a.D = null;
L(a, "ready");
try {
b.onreadystatechange = c;
} catch (d) {
(a = a.b) && a.log(nb, "Problem encountered resetting onreadystatechange: " + d.message, void 0);
}
}
}
function Lb(a) {
a.a && a.C && (a.a.ontimeout = null);
a.B && (m.clearTimeout(a.B), a.B = null);
}
function U(a) {
return a.a ? a.a.readyState : 0;
}
function V(a) {
try {
return 2 < U(a) ? a.a.status : -1;
} catch (b) {
return -1;
}
}
function Qb(a) {
try {
if (!a.a) {
return null;
}
if ("response" in a.a) {
return a.a.response;
}
switch(a.h) {
case Eb:
case "text":
return a.a.responseText;
case "arraybuffer":
if ("mozResponseArrayBuffer" in a.a) {
return a.a.mozResponseArrayBuffer;
}
}
var b = a.b;
b && b.log(nb, "Response type " + a.h + " is not supported on this browser", void 0);
return null;
} catch (c) {
return O(a.b, "Can not get response: " + c.message), null;
}
}
function Rb(a, b) {
if (a.a && 4 == U(a)) {
return a = a.a.getResponseHeader(b), null === a ? void 0 : a;
}
}
function T(a, b) {
return b + " [" + a.J + " " + a.w + " " + V(a) + "]";
}
;var W = null, X = null;
function Sb(a) {
Tb();
for (var b = W, c = [], d = 0; d < a.length; d += 3) {
var e = a[d], f = d + 1 < a.length, g = f ? a[d + 1] : 0, h = d + 2 < a.length, k = h ? a[d + 2] : 0, vb = e >> 2;
e = (e & 3) << 4 | g >> 4;
g = (g & 15) << 2 | k >> 6;
k &= 63;
h || (k = 64, f || (g = 64));
c.push(b[vb], b[e], b[g], b[k]);
}
return c.join("");
}
function Ub(a) {
var b = a.length, c = 0;
"=" === a[b - 2] ? c = 2 : "=" === a[b - 1] && (c = 1);
var d = new Uint8Array(Math.ceil(3 * b / 4) - c), e = 0;
Vb(a, function(a) {
d[e++] = a;
});
return d.subarray(0, e);
}
function Vb(a, b) {
function c(b) {
for (; d < a.length;) {
var c = a.charAt(d++), e = X[c];
if (null != e) {
return e;
}
if (!/^[\s\xa0]*$/.test(c)) {
throw Error("Unknown base64 encoding at char: " + c);
}
}
return b;
}
Tb();
for (var d = 0;;) {
var e = c(-1), f = c(0), g = c(64), h = c(64);
if (64 === h && -1 === e) {
break;
}
b(e << 2 | f >> 4);
64 != g && (b(f << 4 & 240 | g >> 2), 64 != h && b(g << 6 & 192 | h));
}
}
function Tb() {
if (!W) {
W = {};
X = {};
for (var a = 0; 65 > a; a++) {
W[a] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a), X[W[a]] = a, 62 <= a && (X["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(a)] = a);
}
}
}
;function Y(a) {
this.a = a.P;
this.c = this.b = this.f = this.i = this.h = null;
this.g = 0;
this.j = new ka;
var b = this;
Xa(this.a, "readystatechange", function() {
var a = b.a;
if (a = a.a ? a.a.getResponseHeader("Content-Type") : null) {
a = a.toLowerCase();
if (0 == a.lastIndexOf("application/grpc-web-text", 0)) {
a = b.a;
try {
var d = a.a ? a.a.responseText : "";
} catch (k) {
O(a.b, "Can not get responseText: " + k.message), d = "";
}
a = d.length - d.length % 4;
d = d.substr(b.g, a - b.g);
if (0 == d.length) {
return;
}
b.g = a;
d = Ub(d);
} else {
if (0 == a.lastIndexOf("application/grpc", 0)) {
d = new Uint8Array(Qb(b.a));
} else {
return;
}
}
if (d = ma(b.j, [].slice.call(d))) {
for (a = 0; a < d.length; a++) {
if (0 in d[a]) {
var e = d[a][0];
e && (e = b.h(e)) && b.i(e);
}
if (128 in d[a] && 0 < d[a][128].length) {
e = "";
for (var f = 0; f < d[a][128].length; f++) {
e += String.fromCharCode(d[a][128][f]);
}
e = e.trim().split("\r\n");
f = {};
for (var g = 0; g < e.length; g++) {
var h = e[g].indexOf(":");
f[e[g].substring(0, h).trim()] = e[g].substring(h + 1).trim();
}
e = f;
f = 0;
g = "";
"grpc-status" in e && (f = e["grpc-status"]);
"grpc-message" in e && (g = e["grpc-message"]);
b.f && b.f({code:Number(f), details:g, metadata:e});
}
}
4 == U(b.a) && b.c && b.c();
}
}
});
Xa(this.a, "complete", function() {
if (b.b) {
var a = b.a.g;
if (0 != a) {
b.b({code:14, message:fa(a)});
} else {
a = {};
var d = b.a;
d = (d.a && 4 == U(d) ? d.a.getAllResponseHeaders() : "").split("\r\n");
for (var e = 0; e < d.length; e++) {
if (!/^[\s\xa0]*$/.test(d[e])) {
var f = 2;
for (var g = d[e].split(": "), h = []; 0 < f && g.length;) {
h.push(g.shift()), f--;
}
g.length && h.push(g.join(": "));
f = h;
a[f[0]] = a[f[0]] ? a[f[0]] + (", " + f[1]) : f[1];
}
}
"grpc-status" in a && 0 != Number(Rb(b.a, "grpc-status")) && b.b({code:Number(Rb(b.a, "grpc-status")), message:Rb(b.a, "grpc-message")});
}
}
});
}
Y.prototype.A = function(a, b) {
"data" == a ? this.i = b : "status" == a ? this.f = b : "end" == a ? this.c = b : "error" == a && (this.b = b);
return this;
};
Y.prototype.on = Y.prototype.A;
Y.prototype.cancel = function() {
this.a.abort();
};
Y.prototype.cancel = Y.prototype.cancel;
function Wb(a) {
var b = "";
sa(a, function(a, d) {
b += d;
b += ":";
b += a;
b += "\r\n";
});
return b;
}
function Xb(a, b) {
a: {
for (c in b) {
var c = !1;
break a;
}
c = !0;
}
if (c) {
return a;
}
c = Wb(b);
if (n(a)) {
b = encodeURIComponent("$httpHeaders");
c = null != c ? "=" + encodeURIComponent(String(c)) : "";
if (b += c) {
c = a.indexOf("#");
0 > c && (c = a.length);
var d = a.indexOf("?");
if (0 > d || d > c) {
d = c;
var e = "";
} else {
e = a.substring(d + 1, c);
}
a = [a.substr(0, d), e, a.substr(c)];
c = a[1];
a[1] = b ? c ? c + "&" + b : b : c;
a = a[0] + (a[1] ? "?" + a[1] : "") + a[2];
}
return a;
}
a.a("$httpHeaders", c);
return a;
}
;function Z(a) {
this.a = p("format", a) || "text";
this.b = p("suppressCorsPreflight", a) || !1;
}
Z.prototype.T = function(a, b, c, d, e) {
var f = new S, g = new Y({P:f});
g.h = d.b;
g.A("data", function(a) {
e(null, a);
});
g.A("status", function(a) {
0 != a.code && e({code:a.code, message:a.details}, null);
});
g.A("error", function(a) {
0 != a.code && e({code:a.code, message:a.message}, null);
});
Ab(f.headers, c);
Yb(this, f);
this.b && (c = Cb(f.headers), Bb(f.headers), a = Xb(a, c));
b = d.a(b);
b = Zb(b);
"text" == this.a ? b = Sb(b) : "binary" == this.a && (f.h = "arraybuffer");
Jb(f, a, b);
return g;
};
Z.prototype.rpcCall = Z.prototype.T;
Z.prototype.U = function(a, b, c, d) {
var e = new S, f = new Y({P:e});
f.h = d.b;
Ab(e.headers, c);
Yb(this, e);
this.b && (c = Cb(e.headers), Bb(e.headers), a = Xb(a, c));
b = d.a(b);
b = Zb(b);
"text" == this.a ? b = Sb(b) : "binary" == this.a && (e.h = "arraybuffer");
Jb(e, a, b);
return f;
};
Z.prototype.serverStreaming = Z.prototype.U;
function Zb(a) {
for (var b = a.length, c = [0, 0, 0, 0], d = new Uint8Array(5 + b), e = 3; 0 <= e; e--) {
c[e] = b % 256, b >>>= 8;
}
d.set(new Uint8Array(c), 1);
d.set(a, 5);
return d;
}
function Yb(a, b) {
"text" == a.a ? (b.headers.set("Content-Type", "application/grpc-web-text"), b.headers.set("Accept", "application/grpc-web-text")) : b.headers.set("Content-Type", "application/grpc-web+proto");
b.headers.set("X-User-Agent", "grpc-web-javascript/0.1");
b.headers.set("X-Grpc-Web", "1");
if (R(b.headers.b, "deadline")) {
a = b.headers.get("deadline");
a = Math.round(a - (new Date).getTime());
var c = b.headers;
R(c.b, "deadline") && (delete c.b.deadline, c.c--, c.a.length > 2 * c.c && Q(c));
0 < a && b.headers.set("grpc-timeout", a + "m");
}
}
;var $b = module.exports;
$b.AbstractClientBase = {MethodInfo:function(a, b, c) {
this.a = b;
this.b = c;
}};
$b.GrpcWebClientBase = Z;
$b.StatusCode = {OK:0, CANCELLED:1, UNKNOWN:2, INVALID_ARGUMENT:3, DEADLINE_EXCEEDED:4, NOT_FOUND:5, ALREADY_EXISTS:6, PERMISSION_DENIED:7, UNAUTHENTICATED:16, RESOURCE_EXHAUSTED:8, FAILED_PRECONDITION:9, ABORTED:10, OUT_OF_RANGE:11, UNIMPLEMENTED:12, INTERNAL:13, UNAVAILABLE:14, DATA_LOSS:15};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment